Posted By

lawlesscreation on 10/25/11


Tagged

plugin jquery boilerplate


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

spee66


jQuery boilerplate


 / Published in: jQuery
 

URL: http://jqueryboilerplate.com/

https://github.com/zenorocha/jquery-boilerplate/blob/master/jquery.boilerplate.min.js

  1. ;(function ( $, window, document, undefined ) {
  2.  
  3. var pluginName = 'defaultPluginName',
  4. defaults = {
  5. propertyName: "value"
  6. };
  7.  
  8. function Plugin( element, options ) {
  9. this.element = element;
  10. this.options = $.extend( {}, defaults, options) ;
  11.  
  12. this._defaults = defaults;
  13. this._name = pluginName;
  14.  
  15. this.init();
  16. }
  17.  
  18. Plugin.prototype.init = function () {
  19. // code goes here
  20. };
  21.  
  22. $.fn[pluginName] = function ( options ) {
  23. return this.each(function () {
  24. if (!$.data(this, 'plugin_' + pluginName)) {
  25. $.data(this, 'plugin_' + pluginName, new Plugin( this, options ));
  26. }
  27. });
  28. }
  29.  
  30. })(jQuery, window, document);

Report this snippet  

You need to login to post a comment.