Skip to content

Instantly share code, notes, and snippets.

@cesarhdz
Created May 15, 2012 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cesarhdz/2703638 to your computer and use it in GitHub Desktop.
Save cesarhdz/2703638 to your computer and use it in GitHub Desktop.
JQUERY: Plugin Template
/**
* myPluginName jQuery plugin
* @author
* @version
* @date
*/
(function($){
//Default options
$.myPluginName = {
'name' : 'my awesome plugin'
};
/*
* This is the main plugin function
* @param element Is the jquery objecto wher the functions was invked
* @param config The merge of user and default config options
*/
var myPluginName = function ( element, config )
{ $.extend(this, {
/*
Her we can add more functions and variables to extend functionality
....
*/
//This can be the main controller
init : function () {
}
});
this.init();
};
// Constructor
$.fn.extend ({
//Merge the user options with plugin default options
myPluginName : function ( options )
{
var config = (options) ? $.extend( {}, $.myPluginName, options ) : $.myPluginName;
return this.each( function () { new myPluginName( this, config ); });
}
});
})(jQuery);//End of plugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment