mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
"MDL-20470, upgrade to yui3"
This commit is contained in:
parent
7b3f23e4b1
commit
cfa8f37d5c
@ -1,19 +1,17 @@
|
||||
function url_callback(params) {
|
||||
}
|
||||
function url_launch_filepicker(id, client_id, itemid) {
|
||||
var picker = document.createElement('DIV');
|
||||
picker.id = 'file-picker-'+client_id;
|
||||
picker.className = 'file-picker';
|
||||
document.body.appendChild(picker);
|
||||
var el=document.getElementById(id);
|
||||
var params = {};
|
||||
params.env = 'url';
|
||||
params.itemid = itemid;
|
||||
params.maxbytes = -1;
|
||||
params.maxfiles = -1;
|
||||
params.savepath = '/';
|
||||
params.target = el;
|
||||
params.callback = url_callback;
|
||||
var fp = open_filepicker(client_id, params);
|
||||
return false;
|
||||
M.form_url = {};
|
||||
|
||||
M.form_url.init = function(Y, options) {
|
||||
options.formcallback = M.form_url.callback;
|
||||
if (!M.core_filepicker.instances[options.client_id]) {
|
||||
M.core_filepicker.init(Y, options);
|
||||
}
|
||||
Y.on('click', function(e, client_id) {
|
||||
e.preventDefault();
|
||||
M.core_filepicker.instances[client_id].show();
|
||||
}, '#filepicker-button-'+options.client_id, null, options.client_id);
|
||||
|
||||
};
|
||||
|
||||
M.form_url.callback = function (params) {
|
||||
document.getElementById('id_externalurl').value = params.url;
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ class MoodleQuickForm_url extends HTML_QuickForm_text{
|
||||
$this->_options['usefilepicker'] = true;
|
||||
}
|
||||
parent::HTML_QuickForm_text($elementName, $elementLabel, $attributes);
|
||||
//repository_head_setup(); TODO: fixme
|
||||
}
|
||||
|
||||
function setHiddenLabel($hiddenLabel){
|
||||
@ -58,16 +57,26 @@ class MoodleQuickForm_url extends HTML_QuickForm_text{
|
||||
}
|
||||
$client_id = uniqid();
|
||||
|
||||
//$repojs = repository_get_client($context, $client_id, '*', FILE_EXTERNAL);
|
||||
$repojs = ''; //TODO: fixme
|
||||
|
||||
$PAGE->requires->js('/lib/form/url.js');
|
||||
$str .= $repojs;
|
||||
$str .= <<<EOD
|
||||
<button id="filepicker-btn-{$client_id}" style="display:none" onclick="return url_launch_filepicker('$id', '$client_id', 0)">$straddlink</button>
|
||||
<button id="filepicker-button-{$client_id}" style="display:none">
|
||||
$straddlink
|
||||
</button>
|
||||
EOD;
|
||||
// hide the button if javascript is not enabled
|
||||
$str .= html_writer::script(js_writer::function_call('show_item', array("filepicker-btn-{$client_id}")));
|
||||
$args = new stdclass;
|
||||
// need these three to filter repositories list
|
||||
$args->accepted_types = '*';
|
||||
$args->return_types = FILE_EXTERNAL;
|
||||
$args->context = $PAGE->context;
|
||||
|
||||
$options = initialise_filepicker($args);
|
||||
|
||||
$options->client_id = $client_id;
|
||||
$options->env = 'url';
|
||||
|
||||
$module = array('name'=>'form_url', 'fullpath'=>'/lib/form/url.js', 'requires'=>array('core_filepicker'));
|
||||
$PAGE->requires->js_init_call('M.form_url.init', array($options), true, $module);
|
||||
$PAGE->requires->js_function_call('show_item', array('filepicker-button-'.$client_id));
|
||||
|
||||
return $str;
|
||||
}
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user