Last active
August 29, 2015 14:21
-
-
Save denis-shvets/0f068dfbe3ece59ff9a0 to your computer and use it in GitHub Desktop.
JS: jQuery plugin
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
;(function($, document, window, undefined) { | |
'use strict'; | |
var pluginName = 'pluginname'; | |
var instance = 0; | |
var PluginName = function(el, options, instance) { | |
this.instance = instance; | |
this.options = $.extend({}, options); | |
this.cache = { | |
el: el | |
}; | |
this.init(); | |
}; | |
PluginName.prototype = { | |
init: function() {} | |
}; | |
$.fn[pluginName] = function(options) { | |
return this.each(function() { | |
if (!$.data(this, pluginName)) { | |
$.data(this, pluginName, new PluginName(this, options, instance++)); | |
} | |
}); | |
}; | |
})(jQuery, document, window); | |
// $(selector).pluginname(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment