Q.PluginFactory

Plugin Factory provides all necessary methods and properties for easy and flexible jQuery plugin creation. It takes jQuery ease-of-use to a completely new level and allows you to write exceptionally tight and effective code. Some of the features that are responsible for it, are:

Q.PluginFactory can be found at Q.PluginFactory. Plugins created and registered via Q.PluginFactory become proper jQuery plugins, accessible in all the standard ways. On top of that, they come with base implementation methods and properties already predefined for your use. Because of that, you can focus on developing your custom functionality instead of wasting time setting things up.

Tip: Get familiar with $.extend()

This method, in my opinion, is the most underestimated feature of jQuery. It allows you to extend objects and add new methods, override existing ones, even merge whole structures. While constructing Q, I have leveraged this feature. It's what stands behind the flexibility of the library.

Q.PluginFactory in your development

Thanks to flexibility of Q, my first and most important suggestion would be: break down your work into smaller plugins that can be built on top of each other and inherit each other's methods and properties.

By looking at documentation of Q.PluginFactory.Register(), you'll see that one of the parameters you can provide to the method is a reference to a Q plugin already existing in the system. That plugin will be used as a "base" for your new one. Or, if you wish, your new plugin would extend the existing one.

To start using Q.PluginFactory, simply place the Q Library somewhere in your web application's folders, and refer to Q.PluginFactory using the <script> HTML tag:

<script type="text/javascript" src="path_to_file/q.pluginfactory.js"></script>

Using Q.PluginFactory effectively

The whole PluginFactory is designed to provide everything you need for effective development. There simply isn't a way one could use PluginFactory and not be effective.

Q.PluginFactory Properties

PluginFactory does not provide any properties of its own. Instead, look into documentation of individual plugins.

Q.PluginFactory Events

PluginFactory does not provide any events of its own. Instead, look into documentation of individual plugins.

Q.PluginFactory Methods

These are the methods that make PluginFactory the most effective way of developing plugins in the world.

Plugin (Function) Q.PluginFactory.Plugin()

  Returns an executable Function, which becomes the base for your plugin.

Register (void) Q.PluginFactory.Register( {plugin} )

  Creates a namespace within jQuery's plugin space and provides important callback functions as well as direct-call functionality.

plugin
This is a mandatory parameter. A plugin needs to be a Q plugin, initialized using Q.PluginFactory.Plugin() and extended using $.extend() approach.

Note however, that you may Register() your plugin before adding any custom functionality. It is, therefore, perfectly correct to create a plugin in the following manner.

  1. Q.PluginFactory.Base = Q.PluginFactory.Plugin();
  2. Q.PluginFactory.Register(Q.PluginFactory.Base);
  3.  
  4. $.extend(Q.PluginFactory.Base.prototype,{
  5. name: 'Q.PluginFactory.Base',
  6. default_options: {}
  7. });