]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-16697, rename callback functions"
authordongsheng <dongsheng>
Fri, 14 Aug 2009 08:22:06 +0000 (08:22 +0000)
committerdongsheng <dongsheng>
Fri, 14 Aug 2009 08:22:06 +0000 (08:22 +0000)
lib/form/filepicker.js
lib/form/filepicker.php

index 0daf894cf0295c547c066718b4f814f45728fa29..131725b4cde342387cb7f3867d72260d90f31b9d 100644 (file)
@@ -1,7 +1,13 @@
-function fp_callback(params) {
-    document.getElementById('file_info_'+params['client_id']).innerHTML = '<div class="mdl-left"><a href="'+params['url']+'">'+params['file']+'</a></div>';
+function filepicker_callback(params) {
+    alert('test');
+    var html = '<div class="mdl-left"><a href="'+params['url']+'">'+params['file']+'</a>';
+    html += '<a href="###" onclick=\'rm_file('+params['id']+', "'+params['file']+'", this)\'>ii</a>';
+    html += '</div>';
+    document.getElementById('file_info_'+params['client_id']).innerHTML = html;
 }
-function callpicker(id, client_id, itemid) {
+
+// launch file picker from filepicker element
+function launch_filepicker(id, client_id, itemid) {
     var picker = document.createElement('DIV');
     picker.id = 'file-picker-'+client_id;
     picker.className = 'file-picker';
@@ -13,7 +19,7 @@ function callpicker(id, client_id, itemid) {
     params.maxbytes = filepicker.maxbytes;
     params.maxfiles = filepicker.maxfiles;
     params.target = el;
-    params.callback = fp_callback;
+    params.callback = filepicker_callback;
     var fp = open_filepicker(client_id, params);
     return false;
 }
index 2d55ee326b20454b457100c386af1aa23af8c2d7..9a712462438373b6a084d57566f4113073aec08d 100644 (file)
@@ -65,6 +65,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
     function toHtml() {
         global $CFG, $COURSE, $USER, $PAGE;
 
+
         if ($this->_flagFrozen) {
             return $this->getFrozenHtml();
         }
@@ -89,6 +90,8 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
         }
         $client_id = uniqid();
         $repojs = repository_get_client($context, $client_id, $this->_options['filetypes'], $this->_options['returnvalue']);
+        $PAGE->requires->data_for_js('filepicker', array('maxbytes'=>$this->_options['maxbytes'],'maxfiles'=>1));
+        $PAGE->requires->js('lib/form/filepicker.js');
 
         $id     = $this->_attributes['id'];
         $elname = $this->_attributes['name'];
@@ -97,10 +100,8 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
         $str .= '<input type="hidden" name="'.$elname.'" id="'.$id.'" '.$draftvalue.' />';
         $str .= $repojs;
 
-        $str .= $PAGE->requires->data_for_js('filepicker', Array('maxbytes'=>$this->_options['maxbytes'],'maxfiles'=>1))->asap();
-        $str .= $PAGE->requires->js('lib/form/filepicker.js')->asap();
         $str .= <<<EOD
-<button onclick="return callpicker('$id', '$client_id', '$draftvalue')">$straddfile</button>
+<a href="#nonjsfp" onclick="return launch_filepicker('$id', '$client_id', '$draftvalue')">$straddfile</a>
 <span id="file_info_{$client_id}" class="notifysuccess">$currentfile</span>
 
 <noscript>