diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php index b3626250fa7..27d30a80cc1 100644 --- a/lib/ajax/ajaxlib.php +++ b/lib/ajax/ajaxlib.php @@ -221,10 +221,6 @@ class page_requirements_manager { 'loadingicon' => $renderer->pix_url('i/loading_small', 'moodle')->out(false), 'themerev' => theme_get_revision(), 'theme' => $page->theme->name, - 'yui2loaderBase' => $this->yui2loader->base, //will be removed soon - 'yui2loaderComboBase' => $this->yui2loader->comboBase, //will be removed soon - 'yuicombine' => (int)$this->yui3loader->combine, //will be removed soon - ); if (debugging('', DEBUG_DEVELOPER)) { $config['developerdebug'] = true; @@ -237,9 +233,9 @@ class page_requirements_manager { // YUI3 init code $this->yui3_lib(array('cssreset', 'cssbase', 'cssfonts', 'cssgrids')); // full CSS reset - $this->yui3_lib(array('yui', 'loader')); // allows autoloading of everything else - + $this->yui3_lib(array('node', 'loader')); // allows autoloading of everything else + // accessibility stuff $this->skip_link_to('maincontent', get_string('tocontent', 'access')); // Note that, as a short-cut, the code @@ -248,9 +244,6 @@ class page_requirements_manager { $this->yui2_lib('dom'); // needs to be migrated to YUI3 before we release 2.0 $this->yui2_lib('container'); // needs to be migrated to YUI3 before we release 2.0 $this->yui2_lib('connection'); // needs to be migrated to YUI3 before we release 2.0 - // File Picker use this module loading YUI2 widgets - $this->yui2_lib('yuiloader'); // needs to be migrated to YUI3 before we release 2.0 - $this->js_module('filepicker'); // should be migrated elsewhere before 2.0 $this->string_for_js('confirmation', 'admin'); $this->string_for_js('cancel', 'moodle'); @@ -352,7 +345,7 @@ class page_requirements_manager { } else { if ($name === 'filepicker') { // TODO: rename to 'core_filepicker' and move above $pathtofilepicker = $CFG->httpswwwroot.'/repository/filepicker.js'; - $module = array('fullpath'=>$pathtofilepicker, 'requires' => array('base', 'node', 'json', 'async-queue', 'io')); + $module = array('fullpath'=>$pathtofilepicker, 'requires' => array('base', 'node', 'json', 'async-queue', 'io', 'yui2-button', 'yui2-container', 'yui2-treeview', 'yui2-layout')); } //TODO: look for plugin info? } @@ -762,7 +755,7 @@ class page_requirements_manager { if (empty($this->extramodules)) { return ''; } - return html_writer::script(js_writer::function_call('M.yui.add_module', $this->extramodules)); + return html_writer::script(js_writer::function_call('M.yui.add_module', array($this->extramodules))); } /** diff --git a/lib/editor/tinymce/extra/tinymce_utils.js b/lib/editor/tinymce/extra/tinymce_utils.js index 2f81a7abc12..a095c11aeff 100644 --- a/lib/editor/tinymce/extra/tinymce_utils.js +++ b/lib/editor/tinymce/extra/tinymce_utils.js @@ -55,7 +55,7 @@ function editor_init_filepicker(editorid, options) { editor_options[editorid] = options; } function mce_moodlefilemanager(target_id, url, type, win) { - Y.use("filepicker", function (Y) { + YUI(M.yui.loader).use("filepicker", function (Y) { var editor_id = tinyMCE.selectedInstance.editorId; var options = editor_options[editor_id]; var client_id = options.client_id; diff --git a/lib/form/editor.php b/lib/form/editor.php index da4166a1d8e..03b43140dba 100644 --- a/lib/form/editor.php +++ b/lib/form/editor.php @@ -19,7 +19,6 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element { function MoodleQuickForm_editor($elementName=null, $elementLabel=null, $attributes=null, $options=null) { global $CFG, $PAGE; - $PAGE->requires->js('/lib/form/filepicker.js'); $options = (array)$options; foreach ($options as $name=>$value) { @@ -195,6 +194,7 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element { $options->env = 'editor'; $options->itemid = $draftitemid; + $PAGE->requires->js_module('filepicker'); $PAGE->requires->js_function_call('editor_init_filepicker', array($id, $options))->on_dom_ready(); if ($editor->supports_repositories()) { diff --git a/lib/form/filemanager.js b/lib/form/filemanager.js index c2f73e90e86..1821d490f47 100644 --- a/lib/form/filemanager.js +++ b/lib/form/filemanager.js @@ -95,7 +95,7 @@ function fp_filepicker_callback(params) { } function fm_init_filepicker(id, options) { - Y.use("filepicker", function (Y) { + YUI(M.yui.loader).use("filepicker", function (Y) { options.formcallback = filemanager_callback; if (!pickers[options.client_id]) { fm_filepickers[options.client_id] = new Y.filepicker(options); diff --git a/lib/form/filemanager.php b/lib/form/filemanager.php index 1d882c02880..e81a45c1956 100644 --- a/lib/form/filemanager.php +++ b/lib/form/filemanager.php @@ -46,7 +46,6 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element { $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']); } parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes); - $PAGE->requires->js('/repository/filepicker.js'); $PAGE->requires->js('/lib/form/filemanager.js'); } @@ -227,6 +226,7 @@ FMHTML; NONJS; + $PAGE->requires->js_module('filepicker'); $PAGE->requires->js_function_call('destroy_item', array("nonjs-filemanager-{$client_id}"))->on_dom_ready(); $PAGE->requires->js_function_call('show_item', array("filemanager-wrapper-{$client_id}"))->on_dom_ready(); $PAGE->requires->js_function_call('launch_filemanager', array($client_id, $options))->on_dom_ready(); diff --git a/lib/form/filepicker.js b/lib/form/filepicker.js index 20306a6be6f..5159062772d 100644 --- a/lib/form/filepicker.js +++ b/lib/form/filepicker.js @@ -5,7 +5,7 @@ function fp_filepicker_callback(params) { } function fp_init_filepicker(id, options) { - Y.use("filepicker", function (Y) { + YUI(M.yui.loader).use("filepicker", function (Y) { options.formcallback = fp_filepicker_callback; if (!pickers[options.client_id]) { pickers[options.client_id] = new Y.filepicker(options); diff --git a/lib/form/filepicker.php b/lib/form/filepicker.php index cf00a144f4b..2557783359f 100644 --- a/lib/form/filepicker.php +++ b/lib/form/filepicker.php @@ -80,7 +80,6 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input { } $client_id = uniqid(); - $PAGE->requires->js('/lib/form/filepicker.js'); $args = new stdclass; // need these three to filter repositories list @@ -119,6 +118,7 @@ EOD; $str .= $PAGE->requires->js_function_call('destroy_item', array("nonjs-filepicker-{$client_id}"))->asap(); $str .= $PAGE->requires->js_function_call('show_item', array("filepicker-wrapper-{$client_id}"))->asap(); $PAGE->requires->js_function_call('fp_init_filepicker', array('filepicker-button-'.$client_id, $options))->on_dom_ready(); + $PAGE->requires->js_module('filepicker'); return $str; } diff --git a/lib/javascript-static.js b/lib/javascript-static.js index ad7f5548c73..3aa46d4a18a 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -9,7 +9,7 @@ var Y = null; */ M.yui.add_module = function(modules) { for (modname in modules) { - M.yui.loader[modname] = modules[modname]; + M.yui.loader.modules[modname] = modules[modname]; } }; diff --git a/repository/filepicker.js b/repository/filepicker.js index be6ac420267..399eabfe845 100644 --- a/repository/filepicker.js +++ b/repository/filepicker.js @@ -5,11 +5,8 @@ * * File Picker UI * ===== - * this.loaded, it tracks if yui2 and yui3 js files loaded * this.rendered, it tracks if YUI Panel rendered - * this.auto_render, tell launch() to render filepicker when all js files are loaded * this.api, stores the URL to make ajax request - * this.loader, yui2 loader * this.mainui, YUI Panel * this.treeview, YUI Treeview * this.viewbar, a button group to switch view mode @@ -66,25 +63,6 @@ YUI.add('filepicker', function(Y) { api: moodle_cfg.wwwroot+'/repository/repository_ajax.php', initializer: function(args) { this.options = args; - var loader_scope = this; - this.loaded = false; - // load yui2 components - this.loader = new YAHOO.util.YUILoader({ - base: moodle_cfg.yui2loaderBase, - combine: false, - comboBase: moodle_cfg.yui2loaderComboBase, - require: ["button", "container", "treeview", "layout"], - loadOptional: true, - onSuccess: function(o) { - loader_scope.loaded = true; - if (loader_scope.auto_render) { - loader_scope.render(); - } - }, - onProgress: function(o) { - } - }); - this.loader.insert(); }, destructor: function() { }, @@ -1086,11 +1064,7 @@ YUI.add('filepicker', function(Y) { } }, launch: function() { - if (this.loaded) { - this.render(); - } else { - this.auto_render = true; - } + this.render(); } }); Y.filepicker = filepicker;