]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-16597, improve maxfile handling, and position creating folder dialog by PageX...
authordongsheng <dongsheng>
Thu, 24 Sep 2009 08:43:16 +0000 (08:43 +0000)
committerdongsheng <dongsheng>
Thu, 24 Sep 2009 08:43:16 +0000 (08:43 +0000)
lib/form/filemanager.js
lib/form/filemanager.php

index 1c3643bb6a96a4ce0ec63a09a2059dc96b15c006..a14995cdee40763d7f588755ba1c0688ef2911c1 100644 (file)
@@ -29,7 +29,7 @@ function filemanager_callback(obj) {
     refresh_filemanager(obj.filepath, fm_cfg[obj.client_id]);
     fm_cfg[obj.client_id].currentfiles++;
 
-    if (fm_cfg[obj.client_id].currentfiles>=fm_cfg[obj.client_id].maxfiles) {
+    if (fm_cfg[obj.client_id].currentfiles>=fm_cfg[obj.client_id].maxfiles && fm_cfg[client_id].maxfiles!=-1) {
         var btn = document.getElementById('btnadd-'+obj.client_id);
         btn.style.display = 'none';
     }
@@ -55,7 +55,7 @@ function fm_launch_filepicker(el_id, options) {
 }
 
 // create a new folder in draft area
-function mkdir(client_id, itemid) {
+function mkdir(e, client_id, itemid) {
     var mkdir_cb = {
         success: function(o) {
             var result = json_decode(o.responseText);
@@ -82,10 +82,13 @@ function mkdir(client_id, itemid) {
         el.id = 'fm-mkdir-dlg';
         el.innerHTML = '<div class="hd">'+mstr.repository.entername+'</div><div class="bd"><input type="text" id="fm-newname" /></div>';
         document.body.appendChild(el);
+        var x = YAHOO.util.Event.getPageX(e);
+        var y = YAHOO.util.Event.getPageY(e);
         fm_mkdir_dlg = new YAHOO.widget.Dialog("fm-mkdir-dlg", {
              width: "300px",
-             fixedcenter: true,
              visible: true,
+             x:y,
+             y:y,
              constraintoviewport : true
              });
 
@@ -112,6 +115,13 @@ function html_compiler(client_id, options) {
         breadcrumb.innerHTML = '';
         var count = 0;
         for(var p in options.path) {
+            var sep = document.createElement('SPAN');
+            sep.innerHTML = ' ▶ ';
+            if (count==0) {
+                sep.innerHTML = 'Path: ';
+            } else {
+                sep.innerHTML = ' ▶ ';
+            }
             count++;
             var pathid  = 'fm-path-node-'+client_id;
             pathid += ('-'+count);
@@ -120,8 +130,6 @@ function html_compiler(client_id, options) {
             el.id = pathid;
             el.innerHTML = options.path[p].name;
             el.href = '###';
-            var sep = document.createElement('SPAN');
-            sep.innerHTML = ' ▶ ';
             breadcrumb.appendChild(sep);
             breadcrumb.appendChild(el);
 
@@ -650,14 +658,20 @@ function setup_buttons(client_id, options) {
 
     fm_move_dlg.render();
 
-    fileadd.onclick = function(e) {
-        this.options.savepath = this.options.currentpath;
-        fm_launch_filepicker(this.options.target, this.options);
+    // if maxfiles == -1, the no limit
+    if (fm_cfg[client_id].filecount >= fm_cfg[client_id].maxfiles && fm_cfg[client_id].maxfiles!=-1) {
+        fileadd.style.display = 'none';
+    } else {
+        fm_cfg[client_id].currentfiles = fm_cfg[client_id].filecount;
+        fileadd.onclick = function(e) {
+            this.options.savepath = this.options.currentpath;
+            fm_launch_filepicker(this.options.target, this.options);
+        }
+        fileadd.options = fm_cfg[client_id];
     }
-    fileadd.options = fm_cfg[client_id];
     if (fm_cfg[client_id].subdirs) {
-        foldercreate.onclick = function() {
-            mkdir(this.options.client_id, this.options.itemid);
+        foldercreate.onclick = function(e) {
+            mkdir(e, this.options.client_id, this.options.itemid);
         }
         foldercreate.options = fm_cfg[client_id];
     } else {
index 72fd916437c6c1c4faebae288f7180144174385c..7a824080d9c277687ea8761e30f90fef8b34d193 100644 (file)
@@ -178,6 +178,9 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
             $draftitemid = $this->getValue();
         }
 
+        $draftareainfo = file_get_draft_area_info($draftitemid);
+        $filecount = $draftareainfo['filecount'];
+
         if ($COURSE->id == SITEID) {
             $context = get_context_instance(CONTEXT_SYSTEM);
         } else {
@@ -195,6 +198,7 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
         $options->maxbytes  = $this->getMaxbytes();
         $options->maxfiles  = $this->getMaxfiles();
         $options->client_id = $client_id;
+        $options->filecount = $filecount;
         $options->itemid    = $draftitemid;
         $options->subdirs   = $this->_options['subdirs'];
         $options->target    = $id;