Last active
August 29, 2015 13:59
-
-
Save ace4gi/10960090 to your computer and use it in GitHub Desktop.
jQuery - Flugin format
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($){ | |
| 'use strict'; | |
| if (!Raphael) { throw new Error("jquery.PluginName.js - requires xxx"); } | |
| var PluginName = function(element, _options){ | |
| this.$element = $(element); | |
| this.options = _options; | |
| } | |
| PluginName.DEFAULTS = { | |
| } | |
| PluginName.prototype.show = function($escape){ | |
| this.$element.show(); | |
| } | |
| PluginName.prototype.hide = function($escape){ | |
| } | |
| $.fn.pluginName = function(_options){ | |
| return this.each(function(){ | |
| var $this = $(this), | |
| data = $this.data('ui.pluginName'), | |
| options = $.extend({}, PluginName.DEFAULTS, $this.data(), typeof _options == 'object' && _options); | |
| if(!data) $this.data('ui.pluginName', (data = new PluginName(this, options))); | |
| if(typeof _options == 'string') data[_options](); | |
| else data.show(); | |
| }); | |
| }; | |
| })(jQuery); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment