-
Notifications
You must be signed in to change notification settings - Fork 0
/
pluginName.coffee
46 lines (36 loc) · 1.09 KB
/
pluginName.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
###!
{{@pluginName}} v0.1.0 (https://github.com/TechTarget/{{@pluginName}})
Author: Morgan Wigmanich <okize123@gmail.com> (http://github.com/okize)
Copyright (c) 2013 | Licensed under the MIT license
http://www.opensource.org/licenses/mit-license.php
###
((factory) ->
# use AMD or browser globals to create a jQuery plugin.
if typeof define is 'function' and define.amd
define [ 'jquery' ], factory
else
factory jQuery
) ($) ->
'use strict'
pluginName = '{{@pluginName}}'
# default plugin options
defaults =
property: true
# plugin constructor
class Plugin
constructor: (@element, options) ->
@options = $.extend({}, defaults, options)
@_defaults = defaults
@_name = pluginName
@el = $(@element)
@init()
# initialize plugin
init: ->
console.log('{{@pluginName}} initialized')
# wrapper around the constructor that prevents multiple instantiations
$.fn[pluginName] = (options) ->
@each ->
if !$.data(@, 'plugin_#{pluginName}')
$.data(@, 'plugin_#{pluginName}', new Plugin(@, options))
return
return