Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (40 sloc) 1.19 KB
#
# Name : <plugin name>
# Author : <your name>, <your website url>, <twitter handle>
# Version : <version number>
# Repo : <repo url>
# Website : <website url>
#
jQuery ->
$.pluginName = ( element, options ) ->
# current state
state = ''
# plugin settings
@settings = {}
# jQuery version of DOM element attached to the plugin
@$element = $ element
# set current state
@setState = ( _state ) -> state = _state
#get current state
@getState = -> state
# get particular plugin setting
@getSetting = ( key ) ->
@settings[ key ]
# call one of the plugin setting functions
@callSettingFunction = ( name, args = [] ) ->
@settings[name].apply( this, args )
@init = ->
@settings = $.extend( {}, @defaults, options )
@setState 'ready'
# initialise the plugin
@init()
# make the plugin chainable
this
# default plugin settings
$.pluginName::defaults =
message: 'Hello world' # option description
$.fn.pluginName = ( options ) ->
this.each ->
if $( this ).data( 'pluginName' ) is undefined
plugin = new $.pluginName( this, options )
$( this).data( 'pluginName', plugin )
Something went wrong with that request. Please try again.