]> git.mjollnir.org Git - moodle.git/commit
ajaxlib: MDL-16695 New page_requirements_manager class. Soon to replace require_js.
authortjhunt <tjhunt>
Fri, 12 Jun 2009 03:13:29 +0000 (03:13 +0000)
committertjhunt <tjhunt>
Fri, 12 Jun 2009 03:13:29 +0000 (03:13 +0000)
commitb2330db6062a8b8a3def537db9d152eca78a8c36
tree17291efdfb235f050b95ed030689cc90277bbe55
parent11d51756cc6a544d51297bd65eb7a0d44294378a
ajaxlib: MDL-16695 New page_requirements_manager class. Soon to replace require_js.

This new class does the work that require_js used to do, and more.
It can track a number of different things that may be required to
be output somewhere on the page, including:

    * Links to JS files
    * Links to CSS files
    * Links to YUI libraries (this class knows about the dependancies between the different libs).
    * Skip links that go from the top of <body> to various places in the content.
    * Calls to JavaScript functions (for example to initialise things)
    * Bits of data from PHP that need to be available to JavaScript
    * As a special case of that, an easy way to pass language strings to JS.

The new API looks like

$PAGE->requires->css('mod/mymod/styles.css');
$PAGE->requires->js('mod/mymod/script.js');
$PAGE->requires->js('mod/mymod/small_but_urgent.js')->in_head();
$PAGE->requires->js_function_call('init_mymod', array($data))->on_dom_ready();

$PAGE->requires is the canonical instances of this new class.

The commit also includes unit tests, and hopefully the PHP doc comments are
clear enough that it is easy to understand.
lang/en_utf8/access.php
lib/ajax/ajaxlib.php
lib/ajax/simpletest/testajaxlib.php
lib/pagelib.php