joomla/joomla-cms — pull request #1227 by anibalsanchez (2013-06-03 00:45:19+00:00)
Title: addJavascriptModule, RequireJS (dependency management)

Following the thread, this is the PR to add support for RequireJS (dependecy management)

* With this new JDocument method, a set of Javascript modules (with dependencies can be declared)
* The modules can have a common $moduleId "name", so it can be shared CMS-wide Ej jquery17, backbone, underscore, etc.
* If multiples modules with the same name are defined, it wins the last one.

https://groups.google.com/forum/?fromgroups#!topic/joomla-dev-cms/s2Wqo7eNKfo

/**
* Adds a linked javascript module to the page.
*
* Example:
*
* $doc->addJavascriptModule('mediamanager', 'media/media/js/mediamanager.js');
* $doc->addJavascriptModule('installation', 'installation/template/js/installation.js', array('mediamanager'));
*
* Reference: Why AMD? http://requirejs.org/docs/whyamd.html
*
* @param string $moduleId Value of module identication in the module loader.
* @param string $url URL to the linked script
* @param array $dependencies Array of module dependencies
*
* @return JDocument instance of $this to allow chaining
*
* @since 11.1
*/
public function addJavascriptModule($moduleId, $url, $dependencies = array())