mirror of
https://github.com/moodle/moodle.git
synced 2025-07-25 00:02:18 +02:00
"MDL-20470, upgrade to yui3"
This commit is contained in:
@@ -1,19 +1,17 @@
|
|||||||
function url_callback(params) {
|
M.form_url = {};
|
||||||
}
|
|
||||||
function url_launch_filepicker(id, client_id, itemid) {
|
M.form_url.init = function(Y, options) {
|
||||||
var picker = document.createElement('DIV');
|
options.formcallback = M.form_url.callback;
|
||||||
picker.id = 'file-picker-'+client_id;
|
if (!M.core_filepicker.instances[options.client_id]) {
|
||||||
picker.className = 'file-picker';
|
M.core_filepicker.init(Y, options);
|
||||||
document.body.appendChild(picker);
|
}
|
||||||
var el=document.getElementById(id);
|
Y.on('click', function(e, client_id) {
|
||||||
var params = {};
|
e.preventDefault();
|
||||||
params.env = 'url';
|
M.core_filepicker.instances[client_id].show();
|
||||||
params.itemid = itemid;
|
}, '#filepicker-button-'+options.client_id, null, options.client_id);
|
||||||
params.maxbytes = -1;
|
|
||||||
params.maxfiles = -1;
|
};
|
||||||
params.savepath = '/';
|
|
||||||
params.target = el;
|
M.form_url.callback = function (params) {
|
||||||
params.callback = url_callback;
|
document.getElementById('id_externalurl').value = params.url;
|
||||||
var fp = open_filepicker(client_id, params);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,6 @@ class MoodleQuickForm_url extends HTML_QuickForm_text{
|
|||||||
$this->_options['usefilepicker'] = true;
|
$this->_options['usefilepicker'] = true;
|
||||||
}
|
}
|
||||||
parent::HTML_QuickForm_text($elementName, $elementLabel, $attributes);
|
parent::HTML_QuickForm_text($elementName, $elementLabel, $attributes);
|
||||||
//repository_head_setup(); TODO: fixme
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setHiddenLabel($hiddenLabel){
|
function setHiddenLabel($hiddenLabel){
|
||||||
@@ -58,16 +57,26 @@ class MoodleQuickForm_url extends HTML_QuickForm_text{
|
|||||||
}
|
}
|
||||||
$client_id = uniqid();
|
$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
|
$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;
|
EOD;
|
||||||
// hide the button if javascript is not enabled
|
$args = new stdclass;
|
||||||
$str .= html_writer::script(js_writer::function_call('show_item', array("filepicker-btn-{$client_id}")));
|
// 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;
|
return $str;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user