From cfa8f37d5c5d6d02bab9acb7b51d6e342aedadc6 Mon Sep 17 00:00:00 2001 From: Dongsheng Cai Date: Fri, 5 Mar 2010 02:56:12 +0000 Subject: [PATCH] "MDL-20470, upgrade to yui3" --- lib/form/url.js | 34 ++++++++++++++++------------------ lib/form/url.php | 27 ++++++++++++++++++--------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/lib/form/url.js b/lib/form/url.js index 28cdd7271b3..cf6047e9dfa 100644 --- a/lib/form/url.js +++ b/lib/form/url.js @@ -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; } diff --git a/lib/form/url.php b/lib/form/url.php index 29161dcdae4..6faeb71e837 100755 --- a/lib/form/url.php +++ b/lib/form/url.php @@ -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 .= <<