-function updatefile(client_id, obj) {
- document.getElementById('repo_info_'+client_id).innerHTML = obj['file'];
+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 callpicker(client_id, id) {
+function callpicker(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 = updatefile;
- open_filepicker(client_id, params);
+ params.callback = fp_callback;
+ var fp = open_filepicker(client_id, params);
return false;
}
$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
-<a href="#nonjsfp" class="btnaddfile" onclick="return callpicker('$client_id', '$id', '$draftvalue')">$straddfile</a>
-<span id="repo_info_{$client_id}" class="notifysuccess">$currentfile</span>
+<button onclick="return callpicker('$id', '$client_id', '$draftvalue')">$straddfile</button>
+<span id="file_info_{$client_id}" class="notifysuccess">$currentfile</span>
+
<noscript>
<a name="nonjsfp"></a>
<object type="text/html" data="{$CFG->httpswwwroot}/repository/filepicker.php?action=embedded&itemid={$draftitemid}&ctx_id=$context->id" height="300" width="800" style="border:1px solid #000">Error</object>