Friday, 22 February
2008
Fri, 22 Feb
'08
9:52 a.m.
Author: dsvyatobatsko
Date: 2008-02-22 10:52:01 -0500 (Fri, 22 Feb 2008)
New Revision: 6302
Modified:
trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
Log:
client side event firing
Modified:
trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
===================================================================
---
trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-02-22
15:26:08 UTC (rev 6301)
+++
trunk/sandbox/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-02-22
15:52:01 UTC (rev 6302)
@@ -413,8 +413,16 @@
initEvents : function() {
for (var e in this.events) {
- if (e) {
- this.element.observe("rich:" + e, this.events[e]);
+ if (e && this.events[e]) {
+ if(e == 'onupload') {
+ this.element.observe("rich:" + e, function(event) {
+ if(this.events[e](event) !== false) {
+ this._upload();
+ }
+ }.bindAsEventListener(this));
+ } else {
+ this.element.observe("rich:" + e, this.events[e]);
+ }
}
}
},
@@ -501,17 +509,18 @@
return null;
},
-
+
upload: function() {
if (this.disabled) return;
if(this.events.onupload) {
- if(this.events.onupload() === false) {
- //the action is cancelled
- return;
- }
+ this.element.fire("rich:onupload", {});
+ } else {
+ this._upload();
}
+ },
+ _upload() {
this.runUpload = true;
if (!this.activeEntry) {
@@ -522,7 +531,7 @@
entry.upload();
}
}
- },
+ }
stop: function() {
if (this.disabled) return;