From dd07016297ecf3d8444910e236dfb8b5a5c309cc Mon Sep 17 00:00:00 2001 From: dongsheng Date: Fri, 14 Aug 2009 08:22:06 +0000 Subject: [PATCH] "MDL-16697, rename callback functions" --- lib/form/filepicker.js | 14 ++++++++++---- lib/form/filepicker.php | 7 ++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/form/filepicker.js b/lib/form/filepicker.js index 0daf894cf0..131725b4cd 100644 --- a/lib/form/filepicker.js +++ b/lib/form/filepicker.js @@ -1,7 +1,13 @@ -function fp_callback(params) { - document.getElementById('file_info_'+params['client_id']).innerHTML = '
'+params['file']+'
'; +function filepicker_callback(params) { + alert('test'); + var html = '
'+params['file']+''; + html += 'ii'; + html += '
'; + 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; } diff --git a/lib/form/filepicker.php b/lib/form/filepicker.php index 2d55ee326b..9a71246243 100644 --- a/lib/form/filepicker.php +++ b/lib/form/filepicker.php @@ -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 .= ''; $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 .= <<$straddfile +$straddfile $currentfile