Author: dsvyatobatsko
Date: 2008-03-25 15:24:14 -0400 (Tue, 25 Mar 2008)
New Revision: 7235
Modified:
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
Log:
[RF-2756] fileUpload: onupload event can't be handled
Modified:
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
===================================================================
---
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-03-25
19:17:35 UTC (rev 7234)
+++
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-03-25
19:24:14 UTC (rev 7235)
@@ -492,11 +492,12 @@
for (var e in this.events) {
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));
+ this.element.observe("rich:" + e, (function (handler) {
+ return function(event) {
+ if(handler(event) !== false) {
+ event.memo.entry.upload();
+ }
+ }.bind(this);}.bind(this))(this.events[e]));
} else {
this.element.observe("rich:" + e, this.events[e]);
}
@@ -564,7 +565,7 @@
newUpload.id = this.id + ":file" + (this.idCounter++);
this.currentInput = newUpload;
elt.parentNode.appendChild(newUpload);
-
+
if (this.runUpload) {
this.upload();
}
@@ -593,26 +594,22 @@
upload: function() {
if (this.disabled) return;
- if(this.events.onupload) {
- this.element.fire("rich:onupload", {});
- } else {
- this._upload();
- }
- },
-
- _upload: function() {
this.runUpload = true;
if (!this.activeEntry) {
//no upload is being run now
-
- var entry = this._selectEntryForUpload();
- if (entry) {
- entry.upload();
+
+ var entry2upload = this._selectEntryForUpload();
+ if (entry2upload) {
+ if(this.events.onupload) {
+ this.element.fire("rich:onupload", {entry : entry2upload});
+ } else {
+ entry2upload.upload();
+ }
}
}
},
-
+
stop: function() {
if (this.disabled) return;
this.runUpload = false;
@@ -742,7 +739,7 @@
if (this.disabled) {
d1.onclick = function() {return false;};
}else {
- d1.onclick = function() {return this.upload();}.bind(this);
+ d1.onclick = function() { return this.upload();}.bind(this);
}
this._updateClassNames(d1, d2, (this.runUpload) ? this.classes.CANCEL :
this.classes.UPDATE, (this.runUpload) ? this.classes.CANCEL_CONTENT :
this.classes.UPDATE_CONTENT);
},
Show replies by date