Created
October 22, 2013 20:59
-
-
Save bsboris/7108046 to your computer and use it in GitHub Desktop.
jQuery plugin boilerplate for CoffeeScript.
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
| (($, window) -> | |
| class PluginName | |
| constructor: (el, options) -> | |
| @options = $.extend({}, $.fn.pluginName.defaults, options) | |
| @$el = $(el) | |
| _fireCallback: (callback, thisValue, args...) -> callback.apply(thisValue, args) if typeof callback is 'function' | |
| $.fn.pluginName = (option, args...) -> | |
| @each -> | |
| $this = $(this) | |
| data = $this.data('pluginName') | |
| $this.data 'pluginName', (data = new PluginName(this, option)) if !data | |
| data[option].apply(data, args) if typeof option is 'string' and option[0] isnt '_' and typeof data[option] is 'function' | |
| $.fn.pluginName.defaults = | |
| optionA: true | |
| ) window.jQuery, window |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment