app/assets/javascripts/ultimate/jquery-plugin-class.js.coffee in ultimate-base-0.3.4.0 vs app/assets/javascripts/ultimate/jquery-plugin-class.js.coffee in ultimate-base-0.3.5.0
- old
+ new
@@ -16,26 +16,29 @@
# 1 _.outcasts.delete
# 1 _.string.underscored
# 1 _.string.startsWith
class Ultimate.Plugin
+ cid: null
el: null
$el: null
- nodes: {}
- events: {}
+ nodes: null
+ events: null
- options: {}
+ options: null
# @defaultLocales: { en: {} }
locale: 'en'
- translations: {}
+ translations: null
constructor: (options) ->
+ # TODO
throw new Error('Property `el` must be specified at first argument of Ultimate.Plugin.constructor') unless options?.el
@cid = _.uniqueId('ultimatePlugin_')
@_configure options
- @$el = $(@el)
+ @$el = $(@el).first()
+ @el = @$el[0]
@findNodes()
@initialize? arguments...
@delegateEvents()
# jQuery delegate for element lookup, scoped to DOM elements within the
@@ -97,11 +100,12 @@
key = "#{eventName} #{selector}"
normalizedEvents[key] = method
events = normalizedEvents
events
- _configure: (options) ->
+ _configure: (options = {}) ->
+ @options ||= {}
_.extend @options, options
#cout '@options', @options
@_reflectOptions()
@_initTranslations()
@@ -110,9 +114,10 @@
@[attr] = options[attr] for attr in reflectableOptions when not _.isUndefined(options[attr])
@[attr] = value for attr, value of options when not _.isUndefined(@[attr])
# use I18n, and modify locale and translations
_initTranslations: ->
+ @translations ||= {}
if @constructor.defaultLocales?
if not @options["locale"] and I18n?.locale of @constructor.defaultLocales
@locale = I18n.locale
#cout '!!!Set LOCALE FROM I18N ', @locale
defaultTranslations = if @locale then @constructor.defaultLocales[@locale] or {} else {}