Skip to content

Added behavior.load to allow for a single go-to place to register/load javascript libraries. #1192

Closed
wants to merge 1 commit into from

2 participants

@rcorral
rcorral commented May 8, 2012

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

@rcorral rcorral Added feature to JHtmlBehavior register javascript libraries
I have modified the modal method to use the new code I created as an example of usage.
d8ab1a6
@LouisLandry

@rcorral this pull request is no longer mergeable. While I am personally indifferent to the feature, I'm happy to merge it if others are positive towards it. I would probably want to see a couple of unit tests so that we can avoid regressions and confusion about the feature down the road though.

For now I am going to close the pull request. This isn't because I'm rejecting it, but because it really isn't in a reviewable state right now. If you still want to pursue it please rebase the branch so that it is mergeable again and re-open the pull request. If we can get some interest from other developers that will certainly help.

Thanks a bunch for the initiative and work!

@LouisLandry LouisLandry closed this Oct 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.