Last active
October 9, 2015 06:48
-
-
Save bunnymatic/3456358 to your computer and use it in GitHub Desktop.
jquery plugin boilerplate in coffeescript Javascript version is here https://gist.github.com/bunnymatic/1048060
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
| $.myPluginDefaults = | |
| param1: 'default param1' | |
| param2: [] | |
| $.fn.myPlugin = (method) -> | |
| inArgs = arguments | |
| methods = | |
| init: (options) -> | |
| localSettings = $.extend({},$.myPluginDefaults, options); | |
| this.each () -> | |
| # Method calling logic | |
| if ( methods[method] ) | |
| return methods[ method ].apply( this, Array.prototype.slice.call( inArgs, 1 )); | |
| else if ( typeof method == 'object' || ! method ) | |
| return methods.init.apply( this, inArgs ); | |
| else | |
| $.error( 'Method ' + method + ' does not exist on jQuery.myPlugin' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment