From 985d1d1d227828c28ce48ad3cab7dfcd921b9963 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Fri, 25 Dec 2009 15:27:47 +0000 Subject: [PATCH] MDL-21187 brand new yui2 lib loading now using the official YAHOO oholoaders which properly resolves all dependencies; please note we are still suing the YUI2 CSS preloading --- comment/index.php | 14 +- course/view.php | 14 +- lib/ajax/ajaxlib.php | 288 +++++------------------------------- lib/commentlib.php | 12 +- lib/deprecatedlib.php | 4 +- lib/outputrenderers.php | 4 +- lib/resourcelib.php | 4 +- mod/chat/gui_ajax/index.php | 2 +- mod/imscp/view.php | 16 +- mod/quiz/attemptlib.php | 4 +- mod/resource/locallib.php | 2 +- mod/url/locallib.php | 2 +- repository/lib.php | 26 ++-- theme/lines/meta.php | 3 +- 14 files changed, 95 insertions(+), 300 deletions(-) diff --git a/comment/index.php b/comment/index.php index 9b7f2f618974f..a9d9ec0564196 100644 --- a/comment/index.php +++ b/comment/index.php @@ -28,13 +28,13 @@ $context = get_context_instance(CONTEXT_SYSTEM); require_capability('moodle/comment:delete', $context); -$PAGE->requires->yui2_lib('yahoo')->in_head(); -$PAGE->requires->yui2_lib('dom')->in_head(); -$PAGE->requires->yui2_lib('event')->in_head(); -$PAGE->requires->yui2_lib('animation')->in_head(); -$PAGE->requires->yui2_lib('json')->in_head(); -$PAGE->requires->yui2_lib('connection')->in_head(); -$PAGE->requires->js('comment/admin.js')->in_head(); +$PAGE->requires->yui2_lib('yahoo'); +$PAGE->requires->yui2_lib('dom'); +$PAGE->requires->yui2_lib('event'); +$PAGE->requires->yui2_lib('animation'); +$PAGE->requires->yui2_lib('json'); +$PAGE->requires->yui2_lib('connection'); +$PAGE->requires->js('comment/admin.js'); $action = optional_param('action', '', PARAM_ALPHA); $commentid = optional_param('commentid', 0, PARAM_INT); diff --git a/course/view.php b/course/view.php index 2e3a1ad0c6215..fb7319da74613 100644 --- a/course/view.php +++ b/course/view.php @@ -158,11 +158,11 @@ // Course-based switches if (ajaxenabled($CFG->ajaxtestedbrowsers)) { // Browser, user and site-based switches - $PAGE->requires->yui2_lib('dragdrop')->asap(); - $PAGE->requires->yui2_lib('connection')->asap(); - $PAGE->requires->yui2_lib('selector')->asap(); - $PAGE->requires->js('lib/ajax/block_classes.js')->asap(); - $PAGE->requires->js('lib/ajax/section_classes.js')->asap(); + $PAGE->requires->yui2_lib('dragdrop'); + $PAGE->requires->yui2_lib('connection'); + $PAGE->requires->yui2_lib('selector'); + $PAGE->requires->js('lib/ajax/block_classes.js'); + $PAGE->requires->js('lib/ajax/section_classes.js'); // Okay, global variable alert. VERY UGLY. We need to create // this object here before the _print_block() @@ -178,8 +178,8 @@ $completion = new completion_info($course); if ($completion->is_enabled() && ajaxenabled()) { - $PAGE->requires->yui2_lib('connection')->asap(); - $PAGE->requires->js('course/completion.js')->asap(); + $PAGE->requires->yui2_lib('connection'); + $PAGE->requires->js('course/completion.js')->in_head(); $PAGE->requires->js_function_call('completion_init')->on_dom_ready(); $PAGE->requires->data_for_js('completion_strsaved', get_string('saved', 'completion')); $PAGE->requires->data_for_js('completion_strtitley', get_string('completion-title-manual-y', 'completion')); diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php index 48758670eb1d2..9f6de99d4b3a3 100644 --- a/lib/ajax/ajaxlib.php +++ b/lib/ajax/ajaxlib.php @@ -110,8 +110,10 @@ class page_requirements_manager { protected $headdone = false; protected $topofbodydone = false; - /** YUI PHPLoader instance responsible for YUI3 laoding in HEAD */ + /** YUI PHPLoader instance responsible for YUI3 laoding in page head only */ protected $yui3loader; + /** YUI PHPLoader instance responsible for YUI2 laoding */ + protected $yui2loader; /** * Page requirements constructor. @@ -121,23 +123,27 @@ public function __construct() { require_once("$CFG->libdir/yui/phploader/phploader/loader.php"); $this->yui3loader = new YAHOO_util_Loader($CFG->yui3version); + $this->yui2loader = new YAHOO_util_Loader($CFG->yui2version); // set up some loader options - $this->yui3loader->loadOptional = false; if (debugging('', DEBUG_DEVELOPER)) { $this->yui3loader->filter = YUI_DEBUG; // alternatively we could use just YUI_RAW here + $this->yui2loader->filter = YUI_DEBUG; // alternatively we could use just YUI_RAW here } else { $this->yui3loader->filter = null; + $this->yui2loader->filter = null; } if (!empty($CFG->useexternalyui)) { $this->yui3loader->base = 'http://yui.yahooapis.com/' . $CFG->yui3version . '/build/'; + $this->yui2loader->base = 'http://yui.yahooapis.com/' . $CFG->yui2version . '/build/'; } else { $this->yui3loader->base = $CFG->httpswwwroot . '/lib/yui/'. $CFG->yui3version . '/'; - $libpath = $CFG->httpswwwroot . '/lib/yui/'. $CFG->yui2version; + $this->yui2loader->base = $CFG->httpswwwroot . '/lib/yui/'. $CFG->yui2version . '/'; } // This file helps to minimise number of http requests //$this->yui3loader->comboBase = $CFG->httpswwwroot . '/theme/yuicomboloader.php?'; + //$this->yui2loader->comboBase = $CFG->httpswwwroot . '/theme/yuicomboloader.php?'; } /** @@ -188,22 +194,23 @@ public function js($jsfile, $fullurl = false) { * Even if a particular library is requested more than once (perhaps as a dependancy * of other libraries) it will only be linked to once. * - * @param $libname the name of the YUI2 library you require. For example 'autocomplete'. - * @return required_yui2_lib A required_yui2_lib object. This allows you to control when the - * link to the script is output by calling methods like {@link required_yui2_lib::asap()} or - * {@link required_yui2_lib::in_head()}. + * The library is leaded as soon as possible, if $OUTPUT->header() not used yet it + * is put into the page header, otherwise it is loaded in the page footer. + * + * @param string|array $libname the name of the YUI2 library you require. For example 'autocomplete'. + * @return void */ public function yui2_lib($libname) { - $key = 'yui:' . $libname; - if (!isset($this->linkedrequirements[$key])) { - $this->linkedrequirements[$key] = new required_yui2_lib($this, $libname); + $libnames = (array)$libname; + foreach ($libnames as $lib) { + $this->yui2loader->load($lib); } - return $this->linkedrequirements[$key]; } /** * Ensure that the specified YUI3 library file, and all its required dependancies, * are laoded automatically on this page. + * * @param string|array $libname the name of the YUI3 library you require. For example 'overlay'. * @return void */ @@ -424,7 +431,7 @@ public function data_for_js($variable, $data) { public function event_handler($id, $event, $function, $arguments=array()) { $requirement = new required_event_handler($this, $id, $event, $function, $arguments); $this->requiredjscode[] = $requirement; - $this->linkedrequirements[] = new required_yui2_lib($this, 'event'); + $this->yui2_lib('event'); return $requirement; } @@ -462,13 +469,27 @@ protected function get_javascript_code($when, $indent = '') { /** * Returns basic YUI3 JS loading code. - * - * Please note this can be used only from WHEN_IN_HEAD. + * YUI3 is using autoloading of both CSS and JS code. * * @return string */ - protected function get_yui3lib_code() { - return $this->yui3loader->css().$this->yui3loader->script(); + protected function get_yui3lib_headcode() { + return $this->yui3loader->css() . $this->yui3loader->script(); + } + + /** + * Returns basic YUI2 JS loading code. + * It can be called manually at any time. + * + * @return string JS embedding code + */ + public function get_yui2lib_code() { + // All YUI2 CSS is loaded automatically + if ($this->headdone) { + return $this->yui2loader->script_embed(); + } else { + return $this->yui2loader->script(); + } } /** @@ -481,7 +502,8 @@ protected function get_yui3lib_code() { */ public function get_head_code() { setup_core_javascript($this); - $output = $this->get_yui3lib_code(); + $output = $this->get_yui3lib_headcode(); + $output .= $this->get_yui2lib_code(); $output .= $this->get_linked_resources_code(self::WHEN_IN_HEAD); $js = $this->get_javascript_code(self::WHEN_IN_HEAD); $output .= ajax_generate_script_tag($js); @@ -515,7 +537,8 @@ public function get_top_of_body_code() { * @return string the HTML code to to at the end of the page. */ public function get_end_code() { - $output = $this->get_linked_resources_code(self::WHEN_AT_END); + $output = $this->get_yui2lib_code(); + $output .= $this->get_linked_resources_code(self::WHEN_AT_END); if (!empty($this->stringsforjs)) { array_unshift($this->requiredjscode, new required_data_for_js($this, 'mstr', $this->stringsforjs)); @@ -745,127 +768,6 @@ public function at_top_of_body() { } } -/** - * A subclass of {@link linked_requirement} to represent a requried YUI library. - * - * You should not create instances of this class directly. Instead you should - * work with a {@link page_requirements_manager} - and probably the only - * page_requirements_manager you will ever need is the one at $PAGE->requires. - * - * The methods {@link asap()}, {@link in_head()} and {@link at_top_of_body()} - * are indented to be used as a fluid API, so you can say things like - * $PAGE->requires->yui2_lib('autocomplete')->in_head(); - * - * This class (with the help of {@link ajax_resolve_yui2_lib()}) knows about the - * dependancies between the different YUI libraries, and will include all the - * other libraries required by the one you ask for. - * - * By default JavaScript files are included at the end of the HTML. - * This is recommended practice because it means that the web browser will only - * start loading the javascript files after the rest of the page is loaded, and - * that gives the best performance for users. - * - * @copyright 2009 Tim Hunt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since Moodle 2.0 - */ -class required_yui2_lib extends linked_requirement { - protected $jss = array(); - - /** - * Constructor. Normally instances of this class should not be created - * directly. Client code should create them via the page_requirements_manager - * method {@link page_requirements_manager::yui2_lib()}. - * - * @param page_requirements_manager $manager the page_requirements_manager we are associated with. - * @param string $libname The name of the YUI library you want. See the array - * defined in {@link ajax_resolve_yui2_lib()} for a list of known libraries. - */ - public function __construct(page_requirements_manager $manager, $libname) { - parent::__construct($manager, ''); - $this->when = page_requirements_manager::WHEN_AT_END; - - $jsurls = ajax_resolve_yui2_lib($libname); - foreach ($jsurls as $jsurl) { - $this->jss[] = $manager->js($jsurl, true); - } - } - - public function get_html() { - // Since we create a required_js for each of our files, that will generate the HTML. - return ''; - } - - /** - * Indicate that the link to this YUI library file should be output as soon as - * possible. The comment above {@link required_js::asap()} applies to this method too. - * - * @return string The HTML required to include this JavaScript file. The caller - * is responsible for outputting this HTML promptly. For example, a good way to - * call this method is like - *
-     *     echo $PAGE->requires->yui2_lib(...)->asap();
-     * 
- */ - public function asap() { - if ($this->is_done()) { - return; - } - - if (!$this->manager->is_head_done()) { - $this->in_head(); - return ''; - } - - $output = ''; - foreach ($this->jss as $requiredjs) { - $output .= $requiredjs->asap(); - } - $this->mark_done(); - return $output; - } - - /** - * Indicate that the links to this YUI library should be output in the - * section of the HTML. If it too late for this request to be - * satisfied, an exception is thrown. - */ - public function in_head() { - if ($this->is_done() || $this->when <= page_requirements_manager::WHEN_IN_HEAD) { - return; - } - - if ($this->manager->is_head_done()) { - throw new coding_exception('Too late to ask for a YUI library to be linked to from <head>.'); - } - - $this->when = page_requirements_manager::WHEN_IN_HEAD; - foreach ($this->jss as $requiredjs) { - $requiredjs->in_head(); - } - } - - /** - * Indicate that the links to this YUI library should be output in the - * section of the HTML. If it too late for this request to be - * satisfied, an exception is thrown. - */ - public function at_top_of_body() { - if ($this->is_done() || $this->when <= page_requirements_manager::WHEN_TOP_OF_BODY) { - return; - } - - if ($this->manager->is_top_of_body_done()) { - throw new coding_exception('Too late to ask for a YUI library to be linked to from the top of <body>.'); - } - - $this->when = page_requirements_manager::WHEN_TOP_OF_BODY; - foreach ($this->jss as $requiredjs) { - $output .= $requiredjs->at_top_of_body(); - } - } -} - /** * A subclass of {@link linked_requirement} to represent a required CSS file. @@ -1203,114 +1105,6 @@ function ajax_generate_script_tag($js) { } -/** - * Given the name of a YUI library, return a list of the .js that it requries. - * - * This method takes note of the $CFG->useexternalyui setting. - * - * If $CFG->debug is set to DEBUG_DEVELOPER then this method will return links to - * the -debug version of the YUI files, otherwise it will return links to the -min versions. - * - * @param string $libname the name of a YUI library, for example 'autocomplete'. - * @return an array of the JavaScript URLs that must be loaded to make this library work, - * in the order they should be loaded. - */ -function ajax_resolve_yui2_lib($libname) { - global $CFG; - - // Note, we always use yahoo-dom-event, even if we are only asked for part of it. - // because another part of the code may later ask for other bits. It is easier, and - // not very inefficient, just to always use (and get browsers to cache) the combined file. - static $translatelist = array( - 'animation' => array('yahoo-dom-event', 'animation'), - 'autocomplete' => array('yahoo-dom-event', 'datasource', 'autocomplete'), - 'button' => array('yahoo-dom-event', 'element', 'button'), - 'calendar' => array('yahoo-dom-event', 'calendar'), - 'carousel' => array('yahoo-dom-event', 'element', 'carousel'), - 'charts' => array('yahoo-dom-event', 'element', 'datasource', 'json', 'charts'), - 'colorpicker' => array('yahoo-dom-event', 'dragdrop', 'element', 'slider', 'colorpicker'), - 'connection' => array('yahoo-dom-event', 'connection'), - 'container' => array('yahoo-dom-event', 'container'), - 'cookie' => array('yahoo-dom-event', 'cookie'), - 'datasource' => array('yahoo-dom-event', 'datasource'), - 'datatable' => array('yahoo-dom-event', 'element', 'datasource', 'datatable'), - 'datemath' => array('yahoo-dom-event', 'datemath'), - 'dom' => array('yahoo-dom-event'), - 'dom-event' => array('yahoo-dom-event'), - 'dragdrop' => array('yahoo-dom-event', 'dragdrop'), - 'editor' => array('yahoo-dom-event', 'element', 'container', 'menu', 'button', 'editor'), - 'element' => array('yahoo-dom-event', 'element'), - 'element-delegate' => array('yahoo-dom-event', 'element', 'element-delegate'), - 'event' => array('yahoo-dom-event'), - 'event-delegate' => array('yahoo-dom-event', 'event-delegate'), - 'event-mouseenter' => array('yahoo-dom-event', 'event-mouseenter'), - 'event-simulate' => array('yahoo-dom-event', 'event-simulate'), - 'get' => array('yahoo-dom-event', 'get'), - 'history' => array('yahoo-dom-event', 'history'), - 'imagecropper' => array('yahoo-dom-event', 'dragdrop', 'element', 'resize', 'imagecropper'), - 'imageloader' => array('yahoo-dom-event', 'imageloader'), - 'json' => array('yahoo-dom-event', 'json'), - 'layout' => array('yahoo-dom-event', 'dragdrop', 'element', 'layout'), - 'logger' => array('yahoo-dom-event', 'logger'), - 'menu' => array('yahoo-dom-event', 'container', 'menu'), - 'paginator' => array('yahoo-dom-event', 'element', 'paginator'), - 'profiler' => array('yahoo-dom-event', 'profiler'), - 'profilerviewer' => array('yuiloader-dom-event', 'element', 'profiler', 'profilerviewer'), - 'progressbar' => array('yahoo-dom-event', 'progressbar'), - 'resize' => array('yahoo-dom-event', 'dragdrop', 'element', 'resize'), - 'selector' => array('yahoo-dom-event', 'selector'), - 'simpleeditor' => array('yahoo-dom-event', 'element', 'container', 'simpleeditor'), - 'slider' => array('yahoo-dom-event', 'gragdrop', 'slider'), - 'storage' => array('yahoo-dom-event', 'cookie', 'storage'), - 'stylesheet' => array('yahoo-dom-event', 'stylesheet'), - 'swf' => array('yahoo-dom-event', 'swf'), - 'swfdetect' => array('yahoo-dom-event', 'swfdetect'), - 'swfstore' => array('yahoo-dom-event', 'cookie', 'swfstore'), - 'tabview' => array('yahoo-dom-event', 'element', 'tabview'), - 'treeview' => array('yahoo-dom-event', 'treeview'), - 'uploader' => array('yahoo-dom-event', 'element', 'uploader'), - 'utilities' => array('yahoo-dom-event', 'connection', 'animation', 'dragdrop', 'element', 'get'), - 'yahoo' => array('yahoo-dom-event'), - 'yuiloader' => array('yuiloader'), - 'yuitest' => array('yahoo-dom-event', 'logger', 'yuitest'), - ); - if (!isset($translatelist[$libname])) { - throw new coding_exception('Unknown YUI2 library ' . $libname); - } - - $jsnames = $translatelist[$libname]; - - $debugging = debugging('', DEBUG_DEVELOPER); - if ($debugging) { - $suffix = '-debug.js'; - } else { - $suffix = '-min.js'; - } - - if (!empty($CFG->useexternalyui)) { - $libpath = 'http://yui.yahooapis.com/' . $CFG->yui2version . '/build'; - } else { - $libpath = $CFG->httpswwwroot . '/lib/yui/'. $CFG->yui2version; - } - - $jsurls = array(); - foreach ($jsnames as $js) { - if ($js == 'yahoo-dom-event') { - if ($debugging) { - $jsurls[] = $libpath . '/yahoo/yahoo' . $suffix; - $jsurls[] = $libpath . '/dom/dom' . $suffix; - $jsurls[] = $libpath . '/event/event' . $suffix; - } else { - $jsurls[] = $libpath . '/'. $js . '/' . $js . '.js'; - } - } else { - $jsurls[] = $libpath . '/' . $js . '/' . $js . $suffix; - } - } - - return $jsurls; -} - /** * Return the HTML required to link to a JavaScript file. * @param $url the URL of a JavaScript file. diff --git a/lib/commentlib.php b/lib/commentlib.php index deafc233b7970..47c5a8c70bc26 100644 --- a/lib/commentlib.php +++ b/lib/commentlib.php @@ -178,12 +178,12 @@ public static function js() { self::$comment_context = optional_param('comment_context', '', PARAM_INT); self::$comment_area = optional_param('comment_area', '', PARAM_ALPHAEXT); - $PAGE->requires->yui2_lib('yahoo')->in_head(); - $PAGE->requires->yui2_lib('dom')->in_head(); - $PAGE->requires->yui2_lib('event')->in_head(); - $PAGE->requires->yui2_lib('animation')->in_head(); - $PAGE->requires->yui2_lib('json')->in_head(); - $PAGE->requires->yui2_lib('connection')->in_head(); + $PAGE->requires->yui2_lib('yahoo'); + $PAGE->requires->yui2_lib('dom'); + $PAGE->requires->yui2_lib('event'); + $PAGE->requires->yui2_lib('animation'); + $PAGE->requires->yui2_lib('json'); + $PAGE->requires->yui2_lib('connection'); $PAGE->requires->js('comment/comment.js')->in_head(); $PAGE->requires->string_for_js('addcomment', 'moodle'); $PAGE->requires->string_for_js('deletecomment', 'moodle'); diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index a91755aef3d1a..3a4d47b7516ae 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -1676,7 +1676,7 @@ function use_html_editor($name='', $editorhidebuttons='', $id='') { * * @param mixed $lib The library or libraries to load (a string or array of strings) * There are three way to specify the library: - * 1. a shorname like 'yui_yahoo'. This translates into a call to $PAGE->requires->yui2_lib('yahoo')->asap(); + * 1. a shorname like 'yui_yahoo'. This translates into a call to $PAGE->requires->yui2_lib('yahoo'); * 2. the path to the library relative to wwwroot, for example 'lib/javascript-static.js' * 3. (legacy) a full URL like $CFG->wwwroot . '/lib/javascript-static.js'. * 2. and 3. lead to a call $PAGE->requires->js('/lib/javascript-static.js'). @@ -1696,7 +1696,7 @@ function require_js($lib) { 'or $PAGE->requires->yui2_lib() instead.', DEBUG_DEVELOPER); if (strpos($lib, 'yui_') === 0) { - echo $PAGE->requires->yui2_lib(substr($lib, 4))->asap(); + $PAGE->requires->yui2_lib(substr($lib, 4)); } else if (preg_match('/^https?:/', $lib)) { echo $PAGE->requires->js(str_replace($CFG->wwwroot, '', $lib))->asap(); } else { diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 6c971bf32288b..b66c0b319c92d 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -371,8 +371,8 @@ public function standard_head_html() { // Perform a browser environment check for the flash version. Should only run once per login session. if (isloggedin() && !empty($CFG->excludeoldflashclients) && empty($SESSION->flashversion)) { - $this->page->requires->yui2_lib('event')->in_head(); - $this->page->requires->yui2_lib('connection')->in_head(); + $this->page->requires->yui2_lib('event'); + $this->page->requires->yui2_lib('connection'); $this->page->requires->js('lib/swfobject/swfobject.js')->in_head(); $this->page->requires->js('lib/flashdetect/flashdetect.js')->in_head(); $this->page->requires->js_function_call('setflashversiontosession', array($CFG->wwwroot, sesskey())); diff --git a/lib/resourcelib.php b/lib/resourcelib.php index 336942ab67ff2..858c2c3dc8180 100644 --- a/lib/resourcelib.php +++ b/lib/resourcelib.php @@ -167,7 +167,7 @@ function resourcelib_embed_mp3($fullurl, $title, $clicktoopen) { OET; - $PAGE->requires->yui2_lib('dom')->in_head(); + $PAGE->requires->yui2_lib('dom'); $PAGE->requires->js('lib/ufo.js')->in_head(); $PAGE->requires->js('lib/resourcelib.js')->in_head(); $code .= $PAGE->requires->data_for_js('FO', $ufoargs)->asap(); @@ -213,7 +213,7 @@ function resourcelib_embed_flashvideo($fullurl, $title, $clicktoopen) { EOT; - $PAGE->requires->yui2_lib('dom')->in_head(); + $PAGE->requires->yui2_lib('dom'); $PAGE->requires->js('lib/ufo.js')->in_head(); $PAGE->requires->js('lib/resourcelib.js')->in_head(); $code .= $PAGE->requires->data_for_js('FO', $ufoargs)->asap(); diff --git a/mod/chat/gui_ajax/index.php b/mod/chat/gui_ajax/index.php index ae792edcf041a..47d7f51abec29 100644 --- a/mod/chat/gui_ajax/index.php +++ b/mod/chat/gui_ajax/index.php @@ -91,7 +91,7 @@ $PAGE->requires->string_for_js('talk', 'chat'); $PAGE->requires->js('mod/chat/gui_ajax/script.js'); -$PAGE->requires->yui2_lib('animation')->in_head(); +$PAGE->requires->yui2_lib('animation'); $PAGE->add_body_class('yui-skin-sam'); $PAGE->set_pagelayout('embedded'); diff --git a/mod/imscp/view.php b/mod/imscp/view.php index 4cb7f94138289..925cc03d9c132 100644 --- a/mod/imscp/view.php +++ b/mod/imscp/view.php @@ -46,14 +46,14 @@ add_to_log($course->id, 'imscp', 'view', 'view.php?id='.$cm->id, $imscp->id, $cm->id); $PAGE->set_url('mod/imscp/view.php', array('id' => $cm->id)); -$PAGE->requires->yui2_lib('json')->in_head(); -$PAGE->requires->yui2_lib('event')->in_head(); -$PAGE->requires->yui2_lib('treeview')->in_head(); -$PAGE->requires->yui2_lib('layout')->in_head(); -$PAGE->requires->yui2_lib('button')->in_head(); -$PAGE->requires->yui2_lib('container')->in_head(); -$PAGE->requires->yui2_lib('dragdrop')->in_head(); -$PAGE->requires->yui2_lib('resize')->in_head(); +$PAGE->requires->yui2_lib('json'); +$PAGE->requires->yui2_lib('event'); +$PAGE->requires->yui2_lib('treeview'); +$PAGE->requires->yui2_lib('layout'); +$PAGE->requires->yui2_lib('button'); +$PAGE->requires->yui2_lib('container'); +$PAGE->requires->yui2_lib('dragdrop'); +$PAGE->requires->yui2_lib('resize'); $PAGE->requires->js('mod/imscp/functions.js')->in_head(); $PAGE->requires->string_for_js('navigation', 'imscp'); diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index 4d8631a4cb253..00209a2440470 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -722,8 +722,8 @@ public function get_html_head_contributions($page = 'all') { global $PAGE; // The JS does important things like navigation and so must be initialised // as seen as possible, particularly if the page is loading slowly. - $PAGE->requires->yui2_lib('dom')->in_head(); - $PAGE->requires->yui2_lib('event')->in_head(); + $PAGE->requires->yui2_lib('dom'); + $PAGE->requires->yui2_lib('event'); $PAGE->requires->js('mod/quiz/quiz.js')->in_head(); get_html_head_contributions($this->get_question_ids($page), $this->questions, $this->states); } diff --git a/mod/resource/locallib.php b/mod/resource/locallib.php index 169f414f4050e..90e8d48243554 100644 --- a/mod/resource/locallib.php +++ b/mod/resource/locallib.php @@ -104,7 +104,7 @@ function resource_display_embed($resource, $cm, $course, $file) { } else { // anything else - just try object tag enlarged as much as possible $code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype); - $PAGE->requires->yui2_lib('dom')->in_head(); + $PAGE->requires->yui2_lib('dom'); $PAGE->requires->js('mod/url/functions.js')->in_head(); $PAGE->requires->js_function_call('url_init_object'); } diff --git a/mod/url/locallib.php b/mod/url/locallib.php index ca7dffc520e5f..a4a42678ac523 100644 --- a/mod/url/locallib.php +++ b/mod/url/locallib.php @@ -265,7 +265,7 @@ function url_display_embed($url, $cm, $course) { } else { // anything else - just try object tag enlarged as much as possible $code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype); - $PAGE->requires->yui2_lib('dom')->in_head(); + $PAGE->requires->yui2_lib('dom'); $PAGE->requires->js('mod/url/functions.js')->in_head(); $PAGE->requires->js_function_call('url_init_object'); } diff --git a/repository/lib.php b/repository/lib.php index 321f135eefd11..beefe30ea0ca6 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -1763,19 +1763,19 @@ function repository_setup_default_plugins() { function repository_head_setup() { global $PAGE; - $PAGE->requires->yui2_lib('yahoo')->in_head(); - $PAGE->requires->yui2_lib('dom')->in_head(); - $PAGE->requires->yui2_lib('element')->in_head(); - $PAGE->requires->yui2_lib('event')->in_head(); - $PAGE->requires->yui2_lib('json')->in_head(); - $PAGE->requires->yui2_lib('treeview')->in_head(); - $PAGE->requires->yui2_lib('dragdrop')->in_head(); - $PAGE->requires->yui2_lib('container')->in_head(); - $PAGE->requires->yui2_lib('resize')->in_head(); - $PAGE->requires->yui2_lib('layout')->in_head(); - $PAGE->requires->yui2_lib('connection')->in_head(); - $PAGE->requires->yui2_lib('button')->in_head(); - $PAGE->requires->yui2_lib('selector')->in_head(); + $PAGE->requires->yui2_lib('yahoo'); + $PAGE->requires->yui2_lib('dom'); + $PAGE->requires->yui2_lib('element'); + $PAGE->requires->yui2_lib('event'); + $PAGE->requires->yui2_lib('json'); + $PAGE->requires->yui2_lib('treeview'); + $PAGE->requires->yui2_lib('dragdrop'); + $PAGE->requires->yui2_lib('container'); + $PAGE->requires->yui2_lib('resize'); + $PAGE->requires->yui2_lib('layout'); + $PAGE->requires->yui2_lib('connection'); + $PAGE->requires->yui2_lib('button'); + $PAGE->requires->yui2_lib('selector'); //TODO: remove the ->in_head() once we refactor the inline script tags in repo code $PAGE->requires->js('repository/repository.src.js')->in_head(); diff --git a/theme/lines/meta.php b/theme/lines/meta.php index f1713a35924c8..fffd9b06fcc6d 100755 --- a/theme/lines/meta.php +++ b/theme/lines/meta.php @@ -1,6 +1,7 @@ requires->yui2_lib('animation')->asap(); ?> +$PAGE->requires->yui2_lib('animation'); +echo $PAGE->requires->get_yui2lib_code(); ?>