-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';
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;
}
function toHtml() {
global $CFG, $COURSE, $USER, $PAGE;
+
if ($this->_flagFrozen) {
return $this->getFrozenHtml();
}
}
$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'];
$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>