Created
April 30, 2012 02:26
-
-
Save awayken/2554985 to your computer and use it in GitHub Desktop.
A blank template for creating a new jQuery plugin, modified from http://starter.pixelgraphics.us/
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
/****************** | |
jQuery Plugin | |
Name: PLUGIN | |
Author: Miles Rausch (http://awayken.com) | |
Version: VER | |
******************/ | |
(function($){ | |
$.PLUGIN = function(el, PARAM, options){ | |
// To avoid scope issues, use 'base' instead of 'this' | |
// to reference this class from internal events and functions. | |
var base = this; | |
// Access to jQuery and DOM versions of element | |
base.$el = $(el); | |
base.el = el; | |
// Add a reverse reference to the DOM object | |
base.$el.data("PLUGIN", base); | |
base.init = function(){ | |
var PARAM; | |
if( typeof( PARAM ) === "undefined" || PARAM === null ) PARAM = "PARAM_DEFAULT"; | |
base.PARAM = PARAM; | |
base.options = $.extend({}, $.PLUGIN.defaultOptions, options); | |
// Put your initialization code here | |
}; | |
// Sample Function, Uncomment to use | |
// base.functionName = function(paramaters){ | |
// | |
// }; | |
// Run initializer | |
base.init(); | |
}; | |
$.PLUGIN.defaultOptions = { | |
OPTION: "OPTION_DEFAULT" | |
}; | |
$.fn.PLUGIN = function(PARAM, options){ | |
return this.each(function(){ | |
(new $.PLUGIN(this, PARAM, options)); | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment