Created
January 10, 2014 15:28
-
-
Save jugglebird/8356359 to your computer and use it in GitHub Desktop.
A good, minimal template for creating a jQuery plugin.
This file contains hidden or 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($) { | |
| // multiple plugins can go here | |
| (function(pluginName) { | |
| var defaults = { | |
| color: 'black', | |
| testFor: function(div) { | |
| return true; | |
| } | |
| }; | |
| $.fn[pluginName] = function(options) { | |
| options = $.extend(true, {}, defaults, options); | |
| return this.each(function() { | |
| var elem = this, | |
| $elem = $(elem); | |
| // heres the guts of the plugin | |
| if (options.testFor(elem)) { | |
| $elem.css({ | |
| borderWidth: 1, | |
| borderStyle: 'solid', | |
| borderColor: options.color | |
| }); | |
| } | |
| }); | |
| }; | |
| $.fn[pluginName].defaults = defaults; | |
| })('borderize'); | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment