Created
December 9, 2011 05:28
-
-
Save giginet/1450317 to your computer and use it in GitHub Desktop.
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
class SkeltonjQueryPlugin | |
constructor : (@pluginName) -> | |
plugin = @ | |
$.fn[@pluginName] = (method) -> | |
if method and plugin[method]? | |
return plugin[method].apply @, Array::slice.call(arguments, 1) | |
else if typeof method is 'object' or not method | |
return plugin['init'].apply @, arguments | |
else | |
$.error "Method #{method} does not exist on jQuery.#{plugin.pluginName}()." | |
@ | |
init : (custom) -> | |
@options = $.extend true, @options, custom | |
@ | |
options : { | |
} | |
class SamplejQueryPlugin extends SkeltonjQueryPlugin | |
init : (custom) -> | |
super | |
@ | |
options : { | |
message : 'hello' | |
} | |
method : (argment) -> | |
console.log argment | |
new SamplejQueryPlugin('sample') | |
$ -> | |
$('#sample').sample() | |
$('#sample').sample('method', 'fizzbuzz') | |
$('#sample').sample('method2', 'fizzbuzz') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment