Author: andrei_exadel
Date: 2008-05-20 04:07:14 -0400 (Tue, 20 May 2008)
New Revision: 8645
Modified:
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
Log:
RF-3438
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-05-19
20:45:33 UTC (rev 8644)
+++
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-05-20
08:07:14 UTC (rev 8645)
@@ -275,7 +275,7 @@
LoadWatcher = Class.create();
Object.extend(LoadWatcher.prototype, {
initialize: function(iframe, callback, viewStateUpdater) {
- this.iframe = $(iframe.id);
+ this.iframe = iframe;
this.callback = callback;
this.viewStateUpdater = viewStateUpdater;
@@ -495,14 +495,13 @@
},
createFrame: function () {
+ if (this.iframe) return;
var div = document.createElement("div");
div.style.display = 'none';
var child = "<iframe name='"+this.id+"_iframe'
id='"+this.id+"_iframe'></iframe>";
div.innerHTML = child;
document.body.appendChild(div);
- var iframe = $(this.id + "_iframe");
- this.iframe = iframe;
- return iframe;
+ this.iframe = $(this.id + "_iframe");
},
checkFrame: function () {
@@ -513,13 +512,19 @@
},
deleteFrame: function() {
- if (this.iframe) {
- this.iframe.src = "about:blank";
- document.body.removeChild(this.iframe.parentNode);
- }
+ this.resetFrame();
+ if (this.iframe) {
+ document.body.removeChild(this.iframe.parentNode);
+ }
this.iframe = null;
},
+ resetFrame: function () {
+ if (this.iframe) {
+ this.iframe.src = "about:blank";
+ }
+ },
+
initEvents : function() {
for (var e in this.events) {
if (e && this.events[e]) {
@@ -564,7 +569,6 @@
this.watcher.stop();
this.watcher.onerror();
this.watcher = null;
- //alert('error: ' + e);
}
},
@@ -609,6 +613,7 @@
}
return;
}
+ this.createFrame();
var newEntry = new FileUploadEntry(elt, this);
this.entries.push(newEntry);
@@ -856,7 +861,7 @@
this.clear(this.activeEntry);
}
this.activeEntry = null;
- this.deleteFrame();
+ this.resetFrame();
},
updateViewState: function (state) {
@@ -1006,8 +1011,7 @@
}
if (!parentForm.onsubmit || parentForm.onsubmit()) {
- var iframe = this.createFrame();
- this.watcher = new LoadWatcher(iframe, function(newState) {
+ this.watcher = new LoadWatcher(this.iframe, function(newState) {
this.finishProgressBar();
this.setState(newState);
}.bind(entry),