Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'origin/Release02x01'
  • Loading branch information
MichaelDaum committed Nov 22, 2016
2 parents ade317b + 9e23155 commit a9f3aba
Showing 1 changed file with 33 additions and 32 deletions.
@@ -1,61 +1,62 @@
/*
* jQuery Empty plugin 1.0
*
* Copyright (c) 20xx Your Name http://...
* Copyright (c) 20xx Your Name http://...
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* How to proceed:
* How to proceed:
* 1 copy this file into a file named jquery.plugin-name.js
* 2 replace the strings "Empty" with "pluginName" in this file
* 2 replace the strings "EmptyPlugin" with the name of your plugin in this file
* 3 edit the global defaults
* 4 refine the init method
*
*/

"use strict";
(function($, window, document) {
(function($) {

// Create the defaults once
var pluginName = "Empty",
defaults = {
foo: "bar"
};
var defaults = {};

// The actual plugin constructor
function Plugin(elem, options) {
// The actual plugin constructor
function EmptyPlugin(elem, opts) {
var self = this;

self.$elem = $(elem);
self.$elem = $(elem);

// gather options by merging global defaults, plugin defaults and element defaults
self.options = $.extend({}, defaults, options, self.$elem.data());
self.init();
}
self.opts = $.extend({}, defaults, self.$elem.data(), opts);
self.init();
}

Plugin.prototype.init = function () {
EmptyPlugin.prototype.init = function () {
var self = this;
// Place initialization logic here
// You already have access to the DOM element and
// the options via the instance, e.g. this.element
// and this.options
};

// A plugin wrapper around the constructor,
// preventing against multiple instantiations
$.fn[pluginName] = function (options) {
return this.each(function () {
if (!$.data(this, pluginName)) {
$.data(this, pluginName, new Plugin(this, options));
}
});

// Place initialization logic here
// You already have access to the DOM element and
// the options via the instance, e.g. this.element
// and this.opts
};

// A plugin wrapper around the constructor,
// preventing against multiple instantiations
$.fn.emptyPlugin = function (opts) {
return this.each(function () {
if (!$.data(this, "EmptyPlugin")) {
$.data(this, "EmptyPlugin", new EmptyPlugin(this, opts));
}
});
};

// Enable declarative widget instanziation
$(".jq"+pluginName).livequery(function() {
// Enable declarative widget instanziation
$(function() {
$(".jqEmptyPlugin:not(.jqEmptyPluginInited)").livequery(function() {
$(this).addClass("jqEmptyPluginInited").emptyPlugin();
});
});

})(jQuery, window, document);
})(jQuery);

0 comments on commit a9f3aba

Please sign in to comment.