"MDL-16697, rename callback functions"

This commit is contained in:
dongsheng 2009-08-14 08:22:06 +00:00
parent bff522352e
commit dd07016297
2 changed files with 14 additions and 7 deletions

View 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;
}

View 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>