There is a new implementation of require_js in lib/deprecatedlib.php,
based on $PAGE->requires.
There were a few other recently introduced functions in lib/weblib.php,
namely print_js_call, print_delayed_js_call, print_js_config and
standard_js_config. These have been removed, since they were never in
a stable branch, and all the places that used them have been changed
to use the newer $PAGE->requires->... methods.
get_require_js_code is also gone, and the evil places that were calling
it, even though it is an internal function, have been fixed.
Also, I made some minor improvements to the code I committed yesterday
for MDL-16695.
All that remains is to update all the places in core code that are
still using require_js.
(This commit also fixes the problem where the admin tree would not
start with the right categories expanded.)
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.