jQ Module
I just created the jQ module. This attempts to centralize jQuery plugins (from an administration view-point), and somewhat simplify jQuery development. As an example, I also created the hoverIntent wrapper module.
Currently, jQuery plugin support in Drupal is spotty. There are a few modules creating wrappers willy-nilly, some with little or no documentation about how to use them. Based on how Drupal evolves, I imagine that will continue to happen, and is not necessarily a bad thing (except the documentation part).
This initial jQ release creates two things to help out. First, it creates an admin screen to see all registered plugins, with descriptions, versions, and home pages. It uses hook_jq to do this, so that any module may define a plugin, passing along any js or css files that need to be loaded when invoked. This information is cached, so we don't have to poll every single module every page load. Additionally, the administrator may disable plugins globally from this screen.
Secondly, it allows modules or themes to invoke a plugin with a simple jq_add('plugin-name') call. That function will take care of ensuring the plugin is enabled (which is TRUE by default), loading any required files (once), and allowing the plugin wrapper module to do any fancy processing it might want to do.
I believe this will help standardize how plugins are invoked and used, and will help make things a little simpler when developing. I encourage maintainers of other jQuery plugin wrapper modules to support jQ, even optionally. I can help with that if you're interested.
I'd love any feedback, comments, questions, criticisms.
Thanks,
Aaron Winborn
Advomatic


jCarousel support now included
I just added on the "jQ Bridge" module to the project, to support other jQuery wrapper modules that may not have (or wish to) added support for the jQ module. It currently supports the jCarousel module, so that you can invoke that plugin with jq_add('jcarousel'); or even jq_add('jcarousel', 'tango'); to get your custom skins. I plan to go through the existing wrapper modules and add support for them as well, until and unless other maintainers decide this is a good idea and add native support.
Aaron Winborn
Advomatic, Web Design for Progressive Advocacy, Grassroots Movements, and Really Cool Causes
This is a fantastic idea
This is a fantastic idea. Hmm, I think I have a 1.0.4 compatible version of jquery.form.js stashed somewhere that I could try this out on.
I think it will really come into it's own with Drupal 6, if we start collecting 1.2.3 (knock wood) compatible plug-ins from the start.
Awesome! I'll port the
Awesome! I'll port the module to d6 next week to help that along!
Aaron Winborn
Advomatic, Web Design for Progressive Advocacy, Grassroots Movements, and Really Cool Causes
A case use: Views Slideshow
A case use: Views Slideshow will work better with hoverIntent rather than hover. Thus, I'm going to add the following check to make it optionally dependent:
<?phpif (module_invoke('jq', 'add', 'hoverIntent')) {
$hover = 'hoverIntent';
}
else {
$hover = 'hover';
}
?>
That way, in the javascript, it will use .hoverIntent if available & active, and degrade gracefully to .hover if not. The support is optional, unobtrusive, and fully controllable by the administrator. The Views Slideshow admin screen will include a message alerting the admin to the possibility of enhancing their slideshow animation if desired by installing that module.
(If you're looking for this in the module, it's not there yet. This was just a brainstorm. I'll add it next week...)
Aaron Winborn
Advomatic, Web Design for Progressive Advocacy, Grassroots Movements, and Really Cool Causes
same thing on one line. i
same thing on one line. i love when things become simple :)
<?php$hover = module_invoke('jq', 'add', 'hoverIntent') ? 'hoverIntent' : 'hover';
?>
Aaron Winborn
Advomatic, Web Design for Progressive Advocacy, Grassroots Movements, and Really Cool Causes
This is great
I've been waiting for a module like this :)
I have a jQuery module that would be great for Drupal. Will make a jQ module once I have the time.
I added a hook_jq()
I added a hook_jq() implementation to jquery_plugin (which is just Validation plugin and a few others, but I gave it a generic name so other miscellaneous jQuery plugins could be added in the future..)
jQ available for d6
jQ's been ported to d6 now.
New feature for the d6 version:
put your hook_jq function in module_name.jq.inc in your module's folder. it will now automatically be loaded as needed (which is very infrequently).
i might backport this functionality to d5.
Aaron Winborn
AaronWinborn.com (my blog)
Advomatic, Web Design for Progressive Advocacy, Grassroots Movements, and Really Cool Causes
if you're porting your jQ enabled module to d6...
you don't need to do anything special to it (for jQ's sake). the hook is the same (except it being optionally moved to module.jq.inc)
Aaron Winborn
AaronWinborn.com (my blog)
Advomatic, Web Design for Progressive Advocacy, Grassroots Movements, and Really Cool Causes