joomla/joomla-platform — pull request #1192 by rcorral (2012-05-08 16:14:48+00:00)
Title: Added behavior.load to allow for a single go-to place to register/load javascript libraries.

With this I added a central place where javascript libraries can be registered along with their CSS and JS files. Which is something that other implementations don't account for.

An example of this would be doing this:
JHtmlBehavior::register('modal', array(
'script' => array('system/modal.js' => array()),
'stylesheet' => array('system/modal.css' => array(array(), true, false, true))
)
);

If more CSS or JS files need to be included, they can be added to the 'script' or 'stylesheet' array. For each element in the array the key is the path to the file, this file will get parsed by JHtml::_includeRelativeFiles, and the value for the key is an array of arguments that you would liked passed to JHtml::script or JHtml::stylesheet respectively.

I modified JHtmlBehavior::modal as an example of how this new feature can be implemented. It makes a call to self::load('modal'); to add the library to the document.

Please review and comment.

Cheers,
Rafael