Skip to content

Instantly share code, notes, and snippets.

@mkempe mkempe/class.coffee
Last active Aug 29, 2015

Embed
What would you like to do?
Coffeescript template for jQuery Plugin + Class.
class @Awesome
defaults:
isItAwesome: true
constructor: (element, options) ->
@element = $ element
@options = $.extend { }, @defaults, options
setup.call @
return
setup = ->
console.log "It's awesome..." if @options.isItAwesome?
return
(($, window, document) ->
$.fn.extend awesome: (options, args...) ->
@each ->
element = $ @
data = element.data 'awesome'
if data
data[options].apply data, args if data[options]
else
element.data 'awesome', (data = new Awesome @, options)
) jQuery, window, document
@mkempe

This comment has been minimized.

Copy link
Owner Author

mkempe commented Feb 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.