Sha256: 9b7a0187f62a27fd034b61e915eeee7ef8d23828283d77f3df7376a63515b023
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
#= require ./base class Ultimate.Backbone.App @App: null name: null Models: {} Collections: {} Routers: {} ViewMixins: {} ProtoViews: {} Views: {} viewInstances: [] constructor: (name = null) -> if @constructor.App throw new Error('Can\'t create new Ultimate.Backbone.App because the single instance has already been created') else cout 'info', 'Ultimate.Backbone.App.constructor', name, @ @constructor.App = @ @name = name start: -> @bindViews() @bindCustomElements() bindViews: (jRoot = $('html')) -> bindedViews = [] for viewName, viewClass of @Views when viewClass::el #cout 'info', "Try bind #{viewName} [#{viewClass::el}]" jRoot.find(viewClass::el).each (index, el) => view = new viewClass(el: el) cout 'info', "Binded view #{viewName}:", view @viewInstances.push view bindedViews.push view bindedViews unbindViews: (views) -> view.undelegateEvents() for view in views @viewInstances = _.without(@viewInstances, views...) getFirstView: (viewClass) -> for view in @viewInstances if view.constructor is viewClass return view return null getAllViews: (viewClass) -> _.filter(@viewInstances, (view) -> view.constructor is viewClass) customElementBinders: [] registerCustomElementBinder: (binder) -> @customElementBinders.push binder bindCustomElements: (jRoot = $('body')) -> for binder in @customElementBinders if _.isFunction(binder) binder jRoot else jRoot.find(binder['selector'])[binder['method']] binder['arguments']... _.extend Ultimate.Backbone.App::, Backbone.Events
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ultimate-base-0.6.0 | app/assets/javascripts/ultimate/backbone/app.js.coffee |