From c14b11525c09c7d6a43a1052a7dad0eaae3198d0 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Wed, 10 Nov 2010 14:25:03 +0800 Subject: [PATCH] Roo/form/Action.js --- Roo/form/Action.js | 49 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/Roo/form/Action.js b/Roo/form/Action.js index c15ffc9780..cfee2edd2d 100644 --- a/Roo/form/Action.js +++ b/Roo/form/Action.js @@ -130,6 +130,49 @@ Roo.form.Action.Submit = function(form, options){ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, { type : 'submit', + + uploadProgress : function() + { + var dlg = this; + if (!dlg.haveProgress) { + Roo.MessageBox.progress("Uploading", "Uploading"); + } + if (dlg.uploadComplete) { + Roo.MessageBox.hide(); + return; + } + dlg.haveProgress = true; + + var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue(); + Pman.request({ + url : this.form.progressUrl, + params: { + id : uid + }, + method: 'GET', + success : function(data){ + //console.log(data); + if (dlg.uploadComplete) { + Roo.MessageBox.hide(); + return; + } + + if (data){ + Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total, + Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining' + ); + } + dlg.uploadProgress.defer(2000,dlg); + }, + failure: function(data) { + // console.log('fail'); + // console.log(data); + } + }) + + }, + + run : function() { // run get Values on the form, so it syncs any secondary forms. @@ -139,8 +182,12 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, { var method = this.getMethod(); var isPost = method == 'POST'; if(o.clientValidation === false || this.form.isValid()){ - if (this.form.findField( 'UPLOAD_IDENTIFIER')) { + if (this.form.progressUrl && this.form.findField( 'UPLOAD_IDENTIFIER')) { // use upload progress bar.. + this.findField('UPLOAD_IDENTIFIER').setValue( + (new Date() * 1) + '' + Math.random()); + + } -- 2.39.2