-
-
Save nickw/2475462 to your computer and use it in GitHub Desktop.
Example jQuery plugin written in CoffeeScript, and the resulting compiled JavaScript file.
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
$.fn.extend | |
myplugin: (options) -> | |
self = $.fn.myplugin | |
opts = $.extend {}, self.defaultOptions, options | |
for el in this | |
self.init el, opts | |
self.log el if opts.log | |
$.extend $.fn.myplugin, | |
defaultOptions: | |
color: 'red' | |
log: true | |
init: (el, opts) -> | |
this.color el, opts | |
color: (el, opts) -> | |
$(el).css('color', opts.color) | |
log: (msg) -> | |
console.log msg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment