Slide 51
Slide 51 text
;(function($, window, document, undefined) {
// Plugin constructor
var Plugin = function(elem, options) {
this.elem = elem;
this.$elem = $(elem);
this.options = options;
this.metadata = this.$elem.data('plugin-options');
};
// Plugin prototype
Plugin.prototype = {
defaults: {
one: 'some thing',
two: 'another thing'
},
init: function() {
this.config = $.extend({}, this.defaults, this.options, this.metadata);
return this;
}
// Plugin methods go here
};
Plugin.defaults = Plugin.prototype.defaults;
$.fn.pluginName = function(options) {
return this.each(function() {
new Plugin(this, options).init();
});
};
})(jQuery, window, document);