Author: michiel
Date: 2009-09-29 18:05:34 +0200 (Tue, 29 Sep 2009)
New Revision: 38920

Modified:
   
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
Log:
started on progress bar for upload

Modified: 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
===================================================================
--- 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
      2009-09-29 15:30:06 UTC (rev 38919)
+++ 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
      2009-09-29 16:05:34 UTC (rev 38920)
@@ -164,6 +164,8 @@
 
     this.logEnabled = false;
 
+    this.uploading = {};
+
     if ($(this.div).hasClass("POST")) {
         $(this.div).trigger("mmsrRelatedNodesPost", [self]);
         this.afterPost();
@@ -481,13 +483,27 @@
     return params;
 }
 
+List.prototype.uploadProgress = function() {
+    this.find("status", 
"span").load("${mm:link('/mmbase/upload/progress.jspx?unit=px')}");
+}
 
-
 List.prototype.upload = function(fileid) {
     var self = this;
+    if (self.uploading[fileid]) {
+        // uploading already
+        return;
+    }
+    self.uploading[fileid] = true;
     var fileItem = $("#" + fileid);
     var li = fileItem.parents("li");
     var node = self.getNodeForLi(li);
+    var progress = function() {
+        self.uploadProgress();
+        if (self.uploading[fileid]) {
+            setTimeout(progress, 1000);
+        }
+    };
+    progress();
     $.ajaxFileUpload ({
             url: "${mm:link('/mmbase/searchrelate/list/upload.jspx')}" + 
"?rid=" + self.rid + "&name=" + fileItem.attr("name") + "&n=" + node,
             secureuri: false,
@@ -512,9 +528,11 @@
                     }
 
                 }
+                self.uploading[fileid] = false;
             },
             error: function (data, status, e) {
                 alert(e);
+                self.uploading[fileid] = false;
             }
         }
         )
@@ -528,6 +546,15 @@
     var result;
     var self = this;
     if(this.needsCommit()) {
+        this.find(null, "input").each(function() {
+                if (this.type == 'file') {
+                    if ($(this).val().length > 0) {
+                        //console.log("Uploading " + this.id);
+                        self.upload(this.id);
+                    }
+                }
+            });
+
         if (this.valid) {
             var now = new Date();
             if (stale == null) stale = this.defaultStale; //
@@ -543,12 +570,6 @@
                     if (this.checked || this.type == 'text' || this.type == 
'hidden' || this.type == 'password') {
                         params[this.name || this.id || this.parentNode.name || 
this.parentNode.id ] = this.value;
                     }
-                    if (this.type == 'file') {
-                        if ($(this).val().length > 0) {
-                            //console.log("Uploading " + this.id);
-                            self.upload(this.id);
-                        }
-                    }
                 });
 
                 this.find(null, "option").each(function() {

_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to