Created
March 28, 2013 20:32
-
-
Save keighl/5266534 to your computer and use it in GitHub Desktop.
jQuery plugin boilerplate
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
"use strict"; | |
methods = | |
init: (options) -> | |
$(this).each -> | |
$self = $(@) | |
data = $self.data 'hotttness' | |
settings = | |
before: -> | |
after: -> | |
$.extend(settings, options) if options | |
$self.data 'hotttness', setting | |
destroy: -> | |
$self = $(@) | |
data = $self.data 'hotttness' | |
return false unless data | |
########################### | |
$ = jQuery | |
$.fn.hotttness = (method) -> | |
if methods[method] | |
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)) | |
else if (typeof method == 'object' || !method) | |
return methods.init.apply(this, arguments); | |
else | |
$.error('Method ' + method + ' does not exist on jQuery.hotttness!') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment