Created
November 15, 2011 17:23
-
-
Save dmohl/1367682 to your computer and use it in GitHub Desktop.
CoffeeScript Destructure and Splat Example
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
do ($) -> | |
methods = | |
init: (options) -> | |
options = $.extend dialogSelector:'.dialog', inputSelector:'.input', options | |
dialogElement = $(options.dialogSelector) | |
dialog = dialogElement.dialog autoOpen: false, modal: true, resizable: false | |
$(options.inputSelector).click -> dialog.dialog 'open' | |
$.fn.simple = (method) -> | |
[_, args...] = arguments | |
if methods[method] then methods[method] args... | |
else if typeof method is 'object' or not method | |
methods.init arguments... | |
else $.error("Method #{method} does not exist in jQuery simple") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment