Created
February 22, 2013 18:34
-
-
Save cmalven/5015546 to your computer and use it in GitHub Desktop.
CoffeeScript jQuery Plugin
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
# Reference jQuery | |
$ = jQuery | |
# Adds plugin object to jQuery | |
$.fn.extend | |
# Change pluginName to your plugin's name. | |
pluginName: (options) -> | |
# Default settings | |
settings = | |
option1: true | |
option2: false | |
debug: false | |
# Merge default settings with options. | |
settings = $.extend settings, options | |
# Simple logger. | |
log = (msg) -> | |
console?.log msg if settings.debug | |
# _Insert magic here._ | |
return @each ()-> | |
log "Preparing magic show." | |
# You can use your settings in here now. | |
log "Option 1 value: #{settings.option1}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment