Created
May 15, 2012 17:44
-
-
Save cesarhdz/2703638 to your computer and use it in GitHub Desktop.
JQUERY: Plugin Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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