Skip to content
Browse files

fix typo / bug in layout for default region type. build v0.9.5

  • Loading branch information...
1 parent 5760174 commit dbad3f25c11c82229cf802a7d747d834c04c11e4 @derickbailey committed Jul 21, 2012
View
7 changelog.md
@@ -1,4 +1,9 @@
-### v0.9.4-pre [view commit logs](https://github.com/derickbailey/backbone.marionette/compare/v0.9.3...dev)
+### v0.9.5 [view commit logs](https://github.com/derickbailey/backbone.marionette/compare/v0.9.4...v0.9.5)
+
+* Layout
+ * Fixed a typo / bug in default Region type used for layouts
+
+### v0.9.4 [view commit logs](https://github.com/derickbailey/backbone.marionette/compare/v0.9.3...v0.9.5)
* BindTo -> EventBindings
* **BREAKING:** Renamed `Marionette.BindTo` to `Marionette.EventBindings` and made it a constructor function instead of an object literal
View
4 lib/amd/backbone.marionette.js
@@ -1,4 +1,4 @@
-// Backbone.Marionette v0.9.4
+// Backbone.Marionette v0.9.5
//
// Copyright (C)2012 Derick Bailey, Muted Solutions, LLC
// Distributed Under MIT License
@@ -722,7 +722,7 @@ Marionette.Region.extend = Backbone.View.extend;
// attaches `Region` instances to the specified `regions`.
// Used for composite view management and sub-application areas.
Marionette.Layout = Marionette.ItemView.extend({
- regionType: Backbone.Marionette.Region,
+ regionType: Marionette.Region,
constructor: function () {
Backbone.Marionette.ItemView.apply(this, arguments);
View
4 lib/amd/backbone.marionette.min.js
@@ -1,9 +1,9 @@
-// Backbone.Marionette v0.9.4
+// Backbone.Marionette v0.9.5
//
// Copyright (C)2012 Derick Bailey, Muted Solutions, LLC
// Distributed Under MIT License
//
// Documentation and Full License Available at:
// http://github.com/derickbailey/backbone.marionette
-(function(a,b){if(typeof exports=="object"){var c=require("jquery"),d=require("underscore"),e=require("backbone");module.exports=b(c,d,e)}else typeof define=="function"&&define.amd&&define(["jquery","underscore","backbone"],b)})(this,function(a,b,c){return c.Marionette=function(a,b,c){var d={};d.EventBinder=function(){this._eventBindings=[]},b.extend(d.EventBinder.prototype,{bindTo:function(a,b,c,d){d=d||this,a.on(b,c,d);var e={obj:a,eventName:b,callback:c,context:d};return this._eventBindings.push(e),e},unbindFrom:function(a){a.obj.off(a.eventName,a.callback,a.context),this._eventBindings=b.reject(this._eventBindings,function(b){return b===a})},unbindAll:function(){var a=this,c=b.map(this._eventBindings,b.identity);b.each(c,function(b,c){a.unbindFrom(b)})}}),d.EventBinder.extend=a.View.extend,d.View=a.View.extend({constructor:function(){a.View.prototype.constructor.apply(this,arguments);var c=new d.EventBinder;b.extend(this,c),this.bindTo(this,"show",this.onShowCalled,this)},getTemplate:function(){var a;return this.options&&this.options.template?a=this.options.template:a=this.template,a},serializeData:function(){var a;return this.model?a=this.model.toJSON():this.collection&&(a={items:this.collection.toJSON()}),a=this.mixinTemplateHelpers(a),a},mixinTemplateHelpers:function(a){a=a||{};var c=this.templateHelpers;return b.isFunction(c)&&(c=c.call(this)),b.extend(a,c)},configureTriggers:function(){if(!this.triggers)return;var a=this.triggers,c=this,d={};return b.isFunction(a)&&(a=a.call(this)),b.each(a,function(a,b){d[b]=function(b){b&&b.preventDefault&&b.preventDefault(),b&&b.stopPropagation&&b.stopPropagation(),c.trigger(a)}}),d},delegateEvents:function(c){c=c||this.events,b.isFunction(c)&&(c=c.call(this));var d={},e=this.configureTriggers();b.extend(d,c,e),a.View.prototype.delegateEvents.call(this,d)},onShowCalled:function(){},close:function(){this.beforeClose&&this.beforeClose(),this.remove(),this.onClose&&this.onClose(),this.trigger("close"),this.unbindAll(),this.unbind()},bindUIElements:function(){if(!this.ui)return;var a=this;this.uiBindings||(this.uiBindings=this.ui),this.ui={},b.each(b.keys(this.uiBindings),function(b){var c=a.uiBindings[b];a.ui[b]=a.$(c)})}}),d.ItemView=d.View.extend({constructor:function(){d.View.prototype.constructor.apply(this,arguments),this.initialEvents()},initialEvents:function(){this.collection&&this.bindTo(this.collection,"reset",this.render,this)},render:function(){this.beforeRender&&this.beforeRender(),this.trigger("before:render",this),this.trigger("item:before:render",this);var a=this.serializeData(),b=this.getTemplate(),c=d.Renderer.render(b,a);return this.$el.html(c),this.bindUIElements(),this.onRender&&this.onRender(),this.trigger("render",this),this.trigger("item:rendered",this),this},close:function(){this.trigger("item:before:close"),d.View.prototype.close.apply(this,arguments),this.trigger("item:closed")}}),d.CollectionView=d.View.extend({constructor:function(){d.View.prototype.constructor.apply(this,arguments),this.initChildViewStorage(),this.initialEvents(),this.onShowCallbacks=new d.Callbacks},initialEvents:function(){this.collection&&(this.bindTo(this.collection,"add",this.addChildView,this),this.bindTo(this.collection,"remove",this.removeItemView,this),this.bindTo(this.collection,"reset",this.render,this))},addChildView:function(a,b,c){this.closeEmptyView();var d=this.getItemView();return this.addItemView(a,d,c.index)},onShowCalled:function(){this.onShowCallbacks.run()},triggerBeforeRender:function(){this.beforeRender&&this.beforeRender(),this.trigger("before:render",this),this.trigger("collection:before:render",this)},triggerRendered:function(){this.onRender&&this.onRender(),this.trigger("render",this),this.trigger("collection:rendered",this)},render:function(){return this.triggerBeforeRender(),this.closeEmptyView(),this.closeChildren(),this.collection&&this.collection.length>0?this.showCollection():this.showEmptyView(),this.triggerRendered(),this},showCollection:function(){var a=this,b=this.getItemView();this.collection.each(function(c,d){a.addItemView(c,b,d)})},showEmptyView:function(){var b=this.options.emptyView||this.emptyView;if(b&&!this._showingEmptyView){this._showingEmptyView=!0;var c=new a.Model;this.addItemView(c,b,0)}},closeEmptyView:function(){this._showingEmptyView&&(this.closeChildren(),delete this._showingEmptyView)},getItemView:function(){var a=this.options.itemView||this.itemView;if(!a){var b=new Error("An `itemView` must be specified");throw b.name="NoItemViewError",b}return a},addItemView:function(a,b,c){var d=this,f=this.buildItemView(a,b);this.storeChild(f),this.onItemAdded&&this.onItemAdded(f),this.trigger("item:added",f);var g=this.renderItemView(f,c);f.onShow&&this.onShowCallbacks.add(f.onShow,f);var h=this.bindTo(f,"all",function(){var a=e.call(arguments);a[0]="itemview:"+a[0],a.splice(1,0,f),d.trigger.apply(d,a)});return this.childBindings=this.childBindings||{},this.childBindings[f.cid]=h,g},renderItemView:function(a,b){a.render(),this.appendHtml(this,a,b)},buildItemView:function(a,c){var d=b.result(this,"itemViewOptions"),e=b.extend({model:a},d),f=new c(e);return f},removeItemView:function(a){var b=this.children[a.cid];if(b){var c=this.childBindings[b.cid];c&&(this.unbindFrom(c),delete this.childBindings[b.cid]),b.close(),delete this.children[a.cid]}(!this.collection||this.collection.length===0)&&this.showEmptyView(),this.trigger("item:removed",b)},appendHtml:function(a,b,c){a.$el.append(b.el)},storeChild:function(a){this.children[a.model.cid]=a},initChildViewStorage:function(){this.children={}},close:function(){this.trigger("collection:before:close"),this.closeChildren(),d.View.prototype.close.apply(this,arguments),this.trigger("collection:closed")},closeChildren:function(){var a=this;this.children&&b.each(b.clone(this.children),function(b){a.removeItemView(b.model)})}}),d.CompositeView=d.CollectionView.extend({constructor:function(a){d.CollectionView.apply(this,arguments),this.itemView=this.getItemView()},initialEvents:function(){this.collection&&(this.bindTo(this.collection,"add",this.addChildView,this),this.bindTo(this.collection,"remove",this.removeItemView,this),this.bindTo(this.collection,"reset",this.renderCollection,this))},getItemView:function(){return this.itemView||this.constructor},render:function(){var a=this;this.resetItemViewContainer();var b=this.renderModel();return this.$el.html(b),this.bindUIElements(),this.trigger("composite:model:rendered"),this.trigger("render"),this.renderCollection(),this.trigger("composite:rendered"),this},renderCollection:function(){d.CollectionView.prototype.render.apply(this,arguments),this.trigger("composite:collection:rendered")},renderModel:function(){var a={};a=this.serializeData();var b=this.getTemplate();return d.Renderer.render(b,a)},appendHtml:function(a,b){var c=this.getItemViewContainer(a);c.append(b.el)},getItemViewContainer:function(a){var c;if("$itemViewContainer"in a)c=a.$itemViewContainer;else{if(a.itemViewContainer){c=a.$(b.result(a,"itemViewContainer"));if(c.length<=0){var d=new Error("Missing `itemViewContainer`");throw d.name="ItemViewContainerMissingError",d}}else c=a.$el;a.$itemViewContainer=c}return c},resetItemViewContainer:function(){this.$itemViewContainer&&delete this.$itemViewContainer}}),d.Region=function(a){this.options=a||{};var c=new d.EventBinder;b.extend(this,c,a);if(!this.el){var e=new Error("An 'el' must be specified");throw e.name="NoElError",e}this.initialize&&this.initialize.apply(this,arguments)},b.extend(d.Region.prototype,a.Events,{show:function(a){this.ensureEl(),this.close(),a.render(),this.open(a),a.onShow&&a.onShow(),a.trigger("show"),this.onShow&&this.onShow(a),this.trigger("view:show",a),this.currentView=a},ensureEl:function(){if(!this.$el||this.$el.length===0)this.$el=this.getEl(this.el)},getEl:function(a){return c(a)},open:function(a){this.$el.html(a.el)},close:function(){var a=this.currentView;if(!a)return;a.close&&a.close(),this.trigger("view:closed",a),delete this.currentView},attachView:function(a){this.currentView=a}}),d.Region.extend=a.View.extend,d.Layout=d.ItemView.extend({regionType:a.Marionette.Region,constructor:function(){a.Marionette.ItemView.apply(this,arguments),this.initializeRegions()},render:function(){var a=d.ItemView.prototype.render.apply(this,arguments);return this.render=function(){this.closeRegions(),this.reInitializeRegions();var a=d.ItemView.prototype.render.apply(this,arguments);return a},a},close:function(){this.closeRegions(),this.destroyRegions(),a.Marionette.ItemView.prototype.close.call(this,arguments)},initializeRegions:function(){this.regionManagers||(this.regionManagers={});var a=this;b.each(this.regions,function(b,c){if(typeof b!="string"&&typeof b.selector!="string")throw new Exception("Region must be specified as a selector string or an object with selector property");selector=typeof b=="string"?b:b.selector;var d=typeof b.regionType=="undefined"?a.regionType:b.regionType,e=new d({el:selector,getEl:function(b){return a.$(b)}});a.regionManagers[c]=e,a[c]=e})},reInitializeRegions:function(){this.regionManagers&&b.size(this.regionManagers)===0?this.initializeRegions():b.each(this.regionManagers,function(a){delete a.$el})},closeRegions:function(){var a=this;b.each(this.regionManagers,function(a,b){a.close()})},destroyRegions:function(){var a=this;b.each(this.regionManagers,function(b,c){delete a[c]}),this.regionManagers={}}}),d.Application=function(a){this.initCallbacks=new d.Callbacks,this.vent=new d.EventAggregator,this.submodules={};var c=new d.EventBinder;b.extend(this,c,a)},b.extend(d.Application.prototype,a.Events,{addInitializer:function(a){this.initCallbacks.add(a)},start:function(a){this.trigger("initialize:before",a),this.initCallbacks.run(a,this),this.trigger("initialize:after",a),this.trigger("start",a)},addRegions:function(a){var b,c,e;for(e in a)a.hasOwnProperty(e)&&(b=a[e],typeof b=="string"?c=new d.Region({el:b}):c=new b,this[e]=c)},removeRegion:function(a){this[a].close(),delete this[a]},module:function(a,b){var c=e.call(arguments);return c.unshift(this),d.Module.create.apply(d.Module,c)}}),d.Application.extend=a.View.extend,d.AppRouter=a.Router.extend({constructor:function(b){a.Router.prototype.constructor.call(this,b);if(this.appRoutes){var c=this.controller;b&&b.controller&&(c=b.controller),this.processAppRoutes(c,this.appRoutes)}},processAppRoutes:function(a,c){var d,e,f,g,h,i=[],j=this;for(f in c)c.hasOwnProperty(f)&&i.unshift([f,c[f]]);g=i.length;for(h=0;h<g;h++){f=i[h][0],e=i[h][1],d=a[e];if(!d){var k="Method '"+e+"' was not found on the controller",l=new Error(k);throw l.name="NoMethodError",l}d=b.bind(d,a),j.route(f,e,d)}}}),d.Module=function(a,c,e){this.moduleName=a,this.submodules={},this._initializerCallbacks=new d.Callbacks,this._finalizerCallbacks=new d.Callbacks,this._config={},this._config.app=c,this._config.customArgs=e,this._config.definitions=[];var f=new d.EventBinder;b.extend(this,f)},b.extend(d.Module.prototype,a.Events,{addInitializer:function(a){this._initializerCallbacks.add(a)},addFinalizer:function(a){this._finalizerCallbacks.add(a)},start:function(a){this._runModuleDefinition(),this._initializerCallbacks.run(a,this),this._isInitialized=!0,this.submodules&&b.each(this.submodules,function(a){a.start()})},stop:function(){if(!this._isInitialized)return;this._isInitialized=!1,this._finalizerCallbacks.run(),b.each(this.submodules,function(a){a.stop()})},addDefinition:function(a){this._config.definitions.push(a)},_runModuleDefinition:function(){if(this._config.definitions.length===0)return;var e=b.flatten([this,this._config.app,a,d,c,b,this._config.customArgs]),f=this._config.definitions.length-1;for(var g=0;g<=f;g++){var h=this._config.definitions[g];h.apply(this,e)}}}),b.extend(d.Module,{create:function(a,c,f){var g=this,h=a,c=c.split("."),i=e.apply(arguments);i.splice(0,3);var j=c.length;return b.each(c,function(b,c){var e=c===j-1,k=h[b];k||(k=new d.Module(b,a,i),h[b]=k,h.submodules[b]=k),e&&g._createModuleDefinition(k,f,a),h=k}),h},_createModuleDefinition:function(a,b,c){var d=this._getModuleDefinitionOptions(b);d.definition&&a.addDefinition(d.definition),d.startWithApp&&c.addInitializer(function(b){a.start(b)})},_getModuleDefinitionOptions:function(a){var c={startWithApp:!0};return a?(b.isFunction(a)?c.definition=a:(c.definition=a.define,a.hasOwnProperty("startWithApp")&&(c.startWithApp=a.startWithApp)),c):c}}),d.TemplateCache=function(a){this.templateId=a},b.extend(d.TemplateCache,{templateCaches:{},get:function(a){var b=this,c=this.templateCaches[a];return c||(c=new d.TemplateCache(a),this.templateCaches[a]=c),c.load()},clear:function(){var a,b=arguments.length;if(b>0)for(a=0;a<b;a++)delete this.templateCaches[arguments[a]];else this.templateCaches={}}}),b.extend(d.TemplateCache.prototype,{load:function(){var a=this;if(this.compiledTemplate)return this.compiledTemplate;var b=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(b),this.compiledTemplate},loadTemplate:function(a){var b=c(a).html();if(!b||b.length===0){var d="Could not find template: '"+a+"'",e=new Error(d);throw e.name="NoTemplateError",e}return b},compileTemplate:function(a){return b.template(a)}}),d.Renderer={render:function(a,b){var c=d.TemplateCache.get(a),e=c(b);return e}},d.Callbacks=function(){this.deferred=c.Deferred(),this.promise=this.deferred.promise()},b.extend(d.Callbacks.prototype,{add:function(a,b){this.promise.done(function(c,d){b&&(c=b),a.call(c,d)})},run:function(a,b){this.deferred.resolve(b,a)}}),d.EventAggregator=d.EventBinder.extend({constructor:function(a){d.EventBinder.apply(this,arguments),b.extend(this,a)},bindTo:function(a,b,c){return d.EventBinder.prototype.bindTo.call(this,this,a,b,c)}}),b.extend(d.EventAggregator.prototype,a.Events),d.EventAggregator.extend=a.View.extend;var e=Array.prototype.slice;return d}(c,b,window.jQuery||window.Zepto||window.ender),c.Marionette})
+(function(a,b){if(typeof exports=="object"){var c=require("jquery"),d=require("underscore"),e=require("backbone");module.exports=b(c,d,e)}else typeof define=="function"&&define.amd&&define(["jquery","underscore","backbone"],b)})(this,function(a,b,c){return c.Marionette=function(a,b,c){var d={};d.EventBinder=function(){this._eventBindings=[]},b.extend(d.EventBinder.prototype,{bindTo:function(a,b,c,d){d=d||this,a.on(b,c,d);var e={obj:a,eventName:b,callback:c,context:d};return this._eventBindings.push(e),e},unbindFrom:function(a){a.obj.off(a.eventName,a.callback,a.context),this._eventBindings=b.reject(this._eventBindings,function(b){return b===a})},unbindAll:function(){var a=this,c=b.map(this._eventBindings,b.identity);b.each(c,function(b,c){a.unbindFrom(b)})}}),d.EventBinder.extend=a.View.extend,d.View=a.View.extend({constructor:function(){a.View.prototype.constructor.apply(this,arguments);var c=new d.EventBinder;b.extend(this,c),this.bindTo(this,"show",this.onShowCalled,this)},getTemplate:function(){var a;return this.options&&this.options.template?a=this.options.template:a=this.template,a},serializeData:function(){var a;return this.model?a=this.model.toJSON():this.collection&&(a={items:this.collection.toJSON()}),a=this.mixinTemplateHelpers(a),a},mixinTemplateHelpers:function(a){a=a||{};var c=this.templateHelpers;return b.isFunction(c)&&(c=c.call(this)),b.extend(a,c)},configureTriggers:function(){if(!this.triggers)return;var a=this.triggers,c=this,d={};return b.isFunction(a)&&(a=a.call(this)),b.each(a,function(a,b){d[b]=function(b){b&&b.preventDefault&&b.preventDefault(),b&&b.stopPropagation&&b.stopPropagation(),c.trigger(a)}}),d},delegateEvents:function(c){c=c||this.events,b.isFunction(c)&&(c=c.call(this));var d={},e=this.configureTriggers();b.extend(d,c,e),a.View.prototype.delegateEvents.call(this,d)},onShowCalled:function(){},close:function(){this.beforeClose&&this.beforeClose(),this.remove(),this.onClose&&this.onClose(),this.trigger("close"),this.unbindAll(),this.unbind()},bindUIElements:function(){if(!this.ui)return;var a=this;this.uiBindings||(this.uiBindings=this.ui),this.ui={},b.each(b.keys(this.uiBindings),function(b){var c=a.uiBindings[b];a.ui[b]=a.$(c)})}}),d.ItemView=d.View.extend({constructor:function(){d.View.prototype.constructor.apply(this,arguments),this.initialEvents()},initialEvents:function(){this.collection&&this.bindTo(this.collection,"reset",this.render,this)},render:function(){this.beforeRender&&this.beforeRender(),this.trigger("before:render",this),this.trigger("item:before:render",this);var a=this.serializeData(),b=this.getTemplate(),c=d.Renderer.render(b,a);return this.$el.html(c),this.bindUIElements(),this.onRender&&this.onRender(),this.trigger("render",this),this.trigger("item:rendered",this),this},close:function(){this.trigger("item:before:close"),d.View.prototype.close.apply(this,arguments),this.trigger("item:closed")}}),d.CollectionView=d.View.extend({constructor:function(){d.View.prototype.constructor.apply(this,arguments),this.initChildViewStorage(),this.initialEvents(),this.onShowCallbacks=new d.Callbacks},initialEvents:function(){this.collection&&(this.bindTo(this.collection,"add",this.addChildView,this),this.bindTo(this.collection,"remove",this.removeItemView,this),this.bindTo(this.collection,"reset",this.render,this))},addChildView:function(a,b,c){this.closeEmptyView();var d=this.getItemView();return this.addItemView(a,d,c.index)},onShowCalled:function(){this.onShowCallbacks.run()},triggerBeforeRender:function(){this.beforeRender&&this.beforeRender(),this.trigger("before:render",this),this.trigger("collection:before:render",this)},triggerRendered:function(){this.onRender&&this.onRender(),this.trigger("render",this),this.trigger("collection:rendered",this)},render:function(){return this.triggerBeforeRender(),this.closeEmptyView(),this.closeChildren(),this.collection&&this.collection.length>0?this.showCollection():this.showEmptyView(),this.triggerRendered(),this},showCollection:function(){var a=this,b=this.getItemView();this.collection.each(function(c,d){a.addItemView(c,b,d)})},showEmptyView:function(){var b=this.options.emptyView||this.emptyView;if(b&&!this._showingEmptyView){this._showingEmptyView=!0;var c=new a.Model;this.addItemView(c,b,0)}},closeEmptyView:function(){this._showingEmptyView&&(this.closeChildren(),delete this._showingEmptyView)},getItemView:function(){var a=this.options.itemView||this.itemView;if(!a){var b=new Error("An `itemView` must be specified");throw b.name="NoItemViewError",b}return a},addItemView:function(a,b,c){var d=this,f=this.buildItemView(a,b);this.storeChild(f),this.onItemAdded&&this.onItemAdded(f),this.trigger("item:added",f);var g=this.renderItemView(f,c);f.onShow&&this.onShowCallbacks.add(f.onShow,f);var h=this.bindTo(f,"all",function(){var a=e.call(arguments);a[0]="itemview:"+a[0],a.splice(1,0,f),d.trigger.apply(d,a)});return this.childBindings=this.childBindings||{},this.childBindings[f.cid]=h,g},renderItemView:function(a,b){a.render(),this.appendHtml(this,a,b)},buildItemView:function(a,c){var d=b.result(this,"itemViewOptions"),e=b.extend({model:a},d),f=new c(e);return f},removeItemView:function(a){var b=this.children[a.cid];if(b){var c=this.childBindings[b.cid];c&&(this.unbindFrom(c),delete this.childBindings[b.cid]),b.close(),delete this.children[a.cid]}(!this.collection||this.collection.length===0)&&this.showEmptyView(),this.trigger("item:removed",b)},appendHtml:function(a,b,c){a.$el.append(b.el)},storeChild:function(a){this.children[a.model.cid]=a},initChildViewStorage:function(){this.children={}},close:function(){this.trigger("collection:before:close"),this.closeChildren(),d.View.prototype.close.apply(this,arguments),this.trigger("collection:closed")},closeChildren:function(){var a=this;this.children&&b.each(b.clone(this.children),function(b){a.removeItemView(b.model)})}}),d.CompositeView=d.CollectionView.extend({constructor:function(a){d.CollectionView.apply(this,arguments),this.itemView=this.getItemView()},initialEvents:function(){this.collection&&(this.bindTo(this.collection,"add",this.addChildView,this),this.bindTo(this.collection,"remove",this.removeItemView,this),this.bindTo(this.collection,"reset",this.renderCollection,this))},getItemView:function(){return this.itemView||this.constructor},render:function(){var a=this;this.resetItemViewContainer();var b=this.renderModel();return this.$el.html(b),this.bindUIElements(),this.trigger("composite:model:rendered"),this.trigger("render"),this.renderCollection(),this.trigger("composite:rendered"),this},renderCollection:function(){d.CollectionView.prototype.render.apply(this,arguments),this.trigger("composite:collection:rendered")},renderModel:function(){var a={};a=this.serializeData();var b=this.getTemplate();return d.Renderer.render(b,a)},appendHtml:function(a,b){var c=this.getItemViewContainer(a);c.append(b.el)},getItemViewContainer:function(a){var c;if("$itemViewContainer"in a)c=a.$itemViewContainer;else{if(a.itemViewContainer){c=a.$(b.result(a,"itemViewContainer"));if(c.length<=0){var d=new Error("Missing `itemViewContainer`");throw d.name="ItemViewContainerMissingError",d}}else c=a.$el;a.$itemViewContainer=c}return c},resetItemViewContainer:function(){this.$itemViewContainer&&delete this.$itemViewContainer}}),d.Region=function(a){this.options=a||{};var c=new d.EventBinder;b.extend(this,c,a);if(!this.el){var e=new Error("An 'el' must be specified");throw e.name="NoElError",e}this.initialize&&this.initialize.apply(this,arguments)},b.extend(d.Region.prototype,a.Events,{show:function(a){this.ensureEl(),this.close(),a.render(),this.open(a),a.onShow&&a.onShow(),a.trigger("show"),this.onShow&&this.onShow(a),this.trigger("view:show",a),this.currentView=a},ensureEl:function(){if(!this.$el||this.$el.length===0)this.$el=this.getEl(this.el)},getEl:function(a){return c(a)},open:function(a){this.$el.html(a.el)},close:function(){var a=this.currentView;if(!a)return;a.close&&a.close(),this.trigger("view:closed",a),delete this.currentView},attachView:function(a){this.currentView=a}}),d.Region.extend=a.View.extend,d.Layout=d.ItemView.extend({regionType:d.Region,constructor:function(){a.Marionette.ItemView.apply(this,arguments),this.initializeRegions()},render:function(){var a=d.ItemView.prototype.render.apply(this,arguments);return this.render=function(){this.closeRegions(),this.reInitializeRegions();var a=d.ItemView.prototype.render.apply(this,arguments);return a},a},close:function(){this.closeRegions(),this.destroyRegions(),a.Marionette.ItemView.prototype.close.call(this,arguments)},initializeRegions:function(){this.regionManagers||(this.regionManagers={});var a=this;b.each(this.regions,function(b,c){if(typeof b!="string"&&typeof b.selector!="string")throw new Exception("Region must be specified as a selector string or an object with selector property");selector=typeof b=="string"?b:b.selector;var d=typeof b.regionType=="undefined"?a.regionType:b.regionType,e=new d({el:selector,getEl:function(b){return a.$(b)}});a.regionManagers[c]=e,a[c]=e})},reInitializeRegions:function(){this.regionManagers&&b.size(this.regionManagers)===0?this.initializeRegions():b.each(this.regionManagers,function(a){delete a.$el})},closeRegions:function(){var a=this;b.each(this.regionManagers,function(a,b){a.close()})},destroyRegions:function(){var a=this;b.each(this.regionManagers,function(b,c){delete a[c]}),this.regionManagers={}}}),d.Application=function(a){this.initCallbacks=new d.Callbacks,this.vent=new d.EventAggregator,this.submodules={};var c=new d.EventBinder;b.extend(this,c,a)},b.extend(d.Application.prototype,a.Events,{addInitializer:function(a){this.initCallbacks.add(a)},start:function(a){this.trigger("initialize:before",a),this.initCallbacks.run(a,this),this.trigger("initialize:after",a),this.trigger("start",a)},addRegions:function(a){var b,c,e;for(e in a)a.hasOwnProperty(e)&&(b=a[e],typeof b=="string"?c=new d.Region({el:b}):c=new b,this[e]=c)},removeRegion:function(a){this[a].close(),delete this[a]},module:function(a,b){var c=e.call(arguments);return c.unshift(this),d.Module.create.apply(d.Module,c)}}),d.Application.extend=a.View.extend,d.AppRouter=a.Router.extend({constructor:function(b){a.Router.prototype.constructor.call(this,b);if(this.appRoutes){var c=this.controller;b&&b.controller&&(c=b.controller),this.processAppRoutes(c,this.appRoutes)}},processAppRoutes:function(a,c){var d,e,f,g,h,i=[],j=this;for(f in c)c.hasOwnProperty(f)&&i.unshift([f,c[f]]);g=i.length;for(h=0;h<g;h++){f=i[h][0],e=i[h][1],d=a[e];if(!d){var k="Method '"+e+"' was not found on the controller",l=new Error(k);throw l.name="NoMethodError",l}d=b.bind(d,a),j.route(f,e,d)}}}),d.Module=function(a,c,e){this.moduleName=a,this.submodules={},this._initializerCallbacks=new d.Callbacks,this._finalizerCallbacks=new d.Callbacks,this._config={},this._config.app=c,this._config.customArgs=e,this._config.definitions=[];var f=new d.EventBinder;b.extend(this,f)},b.extend(d.Module.prototype,a.Events,{addInitializer:function(a){this._initializerCallbacks.add(a)},addFinalizer:function(a){this._finalizerCallbacks.add(a)},start:function(a){this._runModuleDefinition(),this._initializerCallbacks.run(a,this),this._isInitialized=!0,this.submodules&&b.each(this.submodules,function(a){a.start()})},stop:function(){if(!this._isInitialized)return;this._isInitialized=!1,this._finalizerCallbacks.run(),b.each(this.submodules,function(a){a.stop()})},addDefinition:function(a){this._config.definitions.push(a)},_runModuleDefinition:function(){if(this._config.definitions.length===0)return;var e=b.flatten([this,this._config.app,a,d,c,b,this._config.customArgs]),f=this._config.definitions.length-1;for(var g=0;g<=f;g++){var h=this._config.definitions[g];h.apply(this,e)}}}),b.extend(d.Module,{create:function(a,c,f){var g=this,h=a,c=c.split("."),i=e.apply(arguments);i.splice(0,3);var j=c.length;return b.each(c,function(b,c){var e=c===j-1,k=h[b];k||(k=new d.Module(b,a,i),h[b]=k,h.submodules[b]=k),e&&g._createModuleDefinition(k,f,a),h=k}),h},_createModuleDefinition:function(a,b,c){var d=this._getModuleDefinitionOptions(b);d.definition&&a.addDefinition(d.definition),d.startWithApp&&c.addInitializer(function(b){a.start(b)})},_getModuleDefinitionOptions:function(a){var c={startWithApp:!0};return a?(b.isFunction(a)?c.definition=a:(c.definition=a.define,a.hasOwnProperty("startWithApp")&&(c.startWithApp=a.startWithApp)),c):c}}),d.TemplateCache=function(a){this.templateId=a},b.extend(d.TemplateCache,{templateCaches:{},get:function(a){var b=this,c=this.templateCaches[a];return c||(c=new d.TemplateCache(a),this.templateCaches[a]=c),c.load()},clear:function(){var a,b=arguments.length;if(b>0)for(a=0;a<b;a++)delete this.templateCaches[arguments[a]];else this.templateCaches={}}}),b.extend(d.TemplateCache.prototype,{load:function(){var a=this;if(this.compiledTemplate)return this.compiledTemplate;var b=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(b),this.compiledTemplate},loadTemplate:function(a){var b=c(a).html();if(!b||b.length===0){var d="Could not find template: '"+a+"'",e=new Error(d);throw e.name="NoTemplateError",e}return b},compileTemplate:function(a){return b.template(a)}}),d.Renderer={render:function(a,b){var c=d.TemplateCache.get(a),e=c(b);return e}},d.Callbacks=function(){this.deferred=c.Deferred(),this.promise=this.deferred.promise()},b.extend(d.Callbacks.prototype,{add:function(a,b){this.promise.done(function(c,d){b&&(c=b),a.call(c,d)})},run:function(a,b){this.deferred.resolve(b,a)}}),d.EventAggregator=d.EventBinder.extend({constructor:function(a){d.EventBinder.apply(this,arguments),b.extend(this,a)},bindTo:function(a,b,c){return d.EventBinder.prototype.bindTo.call(this,this,a,b,c)}}),b.extend(d.EventAggregator.prototype,a.Events),d.EventAggregator.extend=a.View.extend;var e=Array.prototype.slice;return d}(c,b,window.jQuery||window.Zepto||window.ender),c.Marionette})
View
2 lib/backbone.marionette.async.js
@@ -1,4 +1,4 @@
-// Backbone.Marionette v0.9.4
+// Backbone.Marionette v0.9.5
//
// Copyright (C)2012 Derick Bailey, Muted Solutions, LLC
// Distributed Under MIT License
View
2 lib/backbone.marionette.async.min.js
@@ -1,4 +1,4 @@
-// Backbone.Marionette v0.9.4
+// Backbone.Marionette v0.9.5
//
// Copyright (C)2012 Derick Bailey, Muted Solutions, LLC
// Distributed Under MIT License
View
2 lib/backbone.marionette.js
@@ -1,4 +1,4 @@
-// Backbone.Marionette v0.9.4
+// Backbone.Marionette v0.9.5
//
// Copyright (C)2012 Derick Bailey, Muted Solutions, LLC
// Distributed Under MIT License
View
4 lib/backbone.marionette.min.js
@@ -1,9 +1,9 @@
-// Backbone.Marionette v0.9.4
+// Backbone.Marionette v0.9.5
//
// Copyright (C)2012 Derick Bailey, Muted Solutions, LLC
// Distributed Under MIT License
//
// Documentation and Full License Available at:
// http://github.com/derickbailey/backbone.marionette
-Backbone.Marionette=function(a,b,c){var d={};d.EventBinder=function(){this._eventBindings=[]},b.extend(d.EventBinder.prototype,{bindTo:function(a,b,c,d){d=d||this,a.on(b,c,d);var e={obj:a,eventName:b,callback:c,context:d};return this._eventBindings.push(e),e},unbindFrom:function(a){a.obj.off(a.eventName,a.callback,a.context),this._eventBindings=b.reject(this._eventBindings,function(b){return b===a})},unbindAll:function(){var a=this,c=b.map(this._eventBindings,b.identity);b.each(c,function(b,c){a.unbindFrom(b)})}}),d.EventBinder.extend=a.View.extend,d.View=a.View.extend({constructor:function(){a.View.prototype.constructor.apply(this,arguments);var c=new d.EventBinder;b.extend(this,c),this.bindTo(this,"show",this.onShowCalled,this)},getTemplate:function(){var a;return this.options&&this.options.template?a=this.options.template:a=this.template,a},serializeData:function(){var a;return this.model?a=this.model.toJSON():this.collection&&(a={items:this.collection.toJSON()}),a=this.mixinTemplateHelpers(a),a},mixinTemplateHelpers:function(a){a=a||{};var c=this.templateHelpers;return b.isFunction(c)&&(c=c.call(this)),b.extend(a,c)},configureTriggers:function(){if(!this.triggers)return;var a=this.triggers,c=this,d={};return b.isFunction(a)&&(a=a.call(this)),b.each(a,function(a,b){d[b]=function(b){b&&b.preventDefault&&b.preventDefault(),b&&b.stopPropagation&&b.stopPropagation(),c.trigger(a)}}),d},delegateEvents:function(c){c=c||this.events,b.isFunction(c)&&(c=c.call(this));var d={},e=this.configureTriggers();b.extend(d,c,e),a.View.prototype.delegateEvents.call(this,d)},onShowCalled:function(){},close:function(){this.beforeClose&&this.beforeClose(),this.remove(),this.onClose&&this.onClose(),this.trigger("close"),this.unbindAll(),this.unbind()},bindUIElements:function(){if(!this.ui)return;var a=this;this.uiBindings||(this.uiBindings=this.ui),this.ui={},b.each(b.keys(this.uiBindings),function(b){var c=a.uiBindings[b];a.ui[b]=a.$(c)})}}),d.ItemView=d.View.extend({constructor:function(){d.View.prototype.constructor.apply(this,arguments),this.initialEvents()},initialEvents:function(){this.collection&&this.bindTo(this.collection,"reset",this.render,this)},render:function(){this.beforeRender&&this.beforeRender(),this.trigger("before:render",this),this.trigger("item:before:render",this);var a=this.serializeData(),b=this.getTemplate(),c=d.Renderer.render(b,a);return this.$el.html(c),this.bindUIElements(),this.onRender&&this.onRender(),this.trigger("render",this),this.trigger("item:rendered",this),this},close:function(){this.trigger("item:before:close"),d.View.prototype.close.apply(this,arguments),this.trigger("item:closed")}}),d.CollectionView=d.View.extend({constructor:function(){d.View.prototype.constructor.apply(this,arguments),this.initChildViewStorage(),this.initialEvents(),this.onShowCallbacks=new d.Callbacks},initialEvents:function(){this.collection&&(this.bindTo(this.collection,"add",this.addChildView,this),this.bindTo(this.collection,"remove",this.removeItemView,this),this.bindTo(this.collection,"reset",this.render,this))},addChildView:function(a,b,c){this.closeEmptyView();var d=this.getItemView();return this.addItemView(a,d,c.index)},onShowCalled:function(){this.onShowCallbacks.run()},triggerBeforeRender:function(){this.beforeRender&&this.beforeRender(),this.trigger("before:render",this),this.trigger("collection:before:render",this)},triggerRendered:function(){this.onRender&&this.onRender(),this.trigger("render",this),this.trigger("collection:rendered",this)},render:function(){return this.triggerBeforeRender(),this.closeEmptyView(),this.closeChildren(),this.collection&&this.collection.length>0?this.showCollection():this.showEmptyView(),this.triggerRendered(),this},showCollection:function(){var a=this,b=this.getItemView();this.collection.each(function(c,d){a.addItemView(c,b,d)})},showEmptyView:function(){var b=this.options.emptyView||this.emptyView;if(b&&!this._showingEmptyView){this._showingEmptyView=!0;var c=new a.Model;this.addItemView(c,b,0)}},closeEmptyView:function(){this._showingEmptyView&&(this.closeChildren(),delete this._showingEmptyView)},getItemView:function(){var a=this.options.itemView||this.itemView;if(!a){var b=new Error("An `itemView` must be specified");throw b.name="NoItemViewError",b}return a},addItemView:function(a,b,c){var d=this,f=this.buildItemView(a,b);this.storeChild(f),this.onItemAdded&&this.onItemAdded(f),this.trigger("item:added",f);var g=this.renderItemView(f,c);f.onShow&&this.onShowCallbacks.add(f.onShow,f);var h=this.bindTo(f,"all",function(){var a=e.call(arguments);a[0]="itemview:"+a[0],a.splice(1,0,f),d.trigger.apply(d,a)});return this.childBindings=this.childBindings||{},this.childBindings[f.cid]=h,g},renderItemView:function(a,b){a.render(),this.appendHtml(this,a,b)},buildItemView:function(a,c){var d=b.result(this,"itemViewOptions"),e=b.extend({model:a},d),f=new c(e);return f},removeItemView:function(a){var b=this.children[a.cid];if(b){var c=this.childBindings[b.cid];c&&(this.unbindFrom(c),delete this.childBindings[b.cid]),b.close(),delete this.children[a.cid]}(!this.collection||this.collection.length===0)&&this.showEmptyView(),this.trigger("item:removed",b)},appendHtml:function(a,b,c){a.$el.append(b.el)},storeChild:function(a){this.children[a.model.cid]=a},initChildViewStorage:function(){this.children={}},close:function(){this.trigger("collection:before:close"),this.closeChildren(),d.View.prototype.close.apply(this,arguments),this.trigger("collection:closed")},closeChildren:function(){var a=this;this.children&&b.each(b.clone(this.children),function(b){a.removeItemView(b.model)})}}),d.CompositeView=d.CollectionView.extend({constructor:function(a){d.CollectionView.apply(this,arguments),this.itemView=this.getItemView()},initialEvents:function(){this.collection&&(this.bindTo(this.collection,"add",this.addChildView,this),this.bindTo(this.collection,"remove",this.removeItemView,this),this.bindTo(this.collection,"reset",this.renderCollection,this))},getItemView:function(){return this.itemView||this.constructor},render:function(){var a=this;this.resetItemViewContainer();var b=this.renderModel();return this.$el.html(b),this.bindUIElements(),this.trigger("composite:model:rendered"),this.trigger("render"),this.renderCollection(),this.trigger("composite:rendered"),this},renderCollection:function(){d.CollectionView.prototype.render.apply(this,arguments),this.trigger("composite:collection:rendered")},renderModel:function(){var a={};a=this.serializeData();var b=this.getTemplate();return d.Renderer.render(b,a)},appendHtml:function(a,b){var c=this.getItemViewContainer(a);c.append(b.el)},getItemViewContainer:function(a){var c;if("$itemViewContainer"in a)c=a.$itemViewContainer;else{if(a.itemViewContainer){c=a.$(b.result(a,"itemViewContainer"));if(c.length<=0){var d=new Error("Missing `itemViewContainer`");throw d.name="ItemViewContainerMissingError",d}}else c=a.$el;a.$itemViewContainer=c}return c},resetItemViewContainer:function(){this.$itemViewContainer&&delete this.$itemViewContainer}}),d.Region=function(a){this.options=a||{};var c=new d.EventBinder;b.extend(this,c,a);if(!this.el){var e=new Error("An 'el' must be specified");throw e.name="NoElError",e}this.initialize&&this.initialize.apply(this,arguments)},b.extend(d.Region.prototype,a.Events,{show:function(a){this.ensureEl(),this.close(),a.render(),this.open(a),a.onShow&&a.onShow(),a.trigger("show"),this.onShow&&this.onShow(a),this.trigger("view:show",a),this.currentView=a},ensureEl:function(){if(!this.$el||this.$el.length===0)this.$el=this.getEl(this.el)},getEl:function(a){return c(a)},open:function(a){this.$el.html(a.el)},close:function(){var a=this.currentView;if(!a)return;a.close&&a.close(),this.trigger("view:closed",a),delete this.currentView},attachView:function(a){this.currentView=a}}),d.Region.extend=a.View.extend,d.Layout=d.ItemView.extend({regionType:a.Marionette.Region,constructor:function(){a.Marionette.ItemView.apply(this,arguments),this.initializeRegions()},render:function(){var a=d.ItemView.prototype.render.apply(this,arguments);return this.render=function(){this.closeRegions(),this.reInitializeRegions();var a=d.ItemView.prototype.render.apply(this,arguments);return a},a},close:function(){this.closeRegions(),this.destroyRegions(),a.Marionette.ItemView.prototype.close.call(this,arguments)},initializeRegions:function(){this.regionManagers||(this.regionManagers={});var a=this;b.each(this.regions,function(b,c){if(typeof b!="string"&&typeof b.selector!="string")throw new Exception("Region must be specified as a selector string or an object with selector property");selector=typeof b=="string"?b:b.selector;var d=typeof b.regionType=="undefined"?a.regionType:b.regionType,e=new d({el:selector,getEl:function(b){return a.$(b)}});a.regionManagers[c]=e,a[c]=e})},reInitializeRegions:function(){this.regionManagers&&b.size(this.regionManagers)===0?this.initializeRegions():b.each(this.regionManagers,function(a){delete a.$el})},closeRegions:function(){var a=this;b.each(this.regionManagers,function(a,b){a.close()})},destroyRegions:function(){var a=this;b.each(this.regionManagers,function(b,c){delete a[c]}),this.regionManagers={}}}),d.Application=function(a){this.initCallbacks=new d.Callbacks,this.vent=new d.EventAggregator,this.submodules={};var c=new d.EventBinder;b.extend(this,c,a)},b.extend(d.Application.prototype,a.Events,{addInitializer:function(a){this.initCallbacks.add(a)},start:function(a){this.trigger("initialize:before",a),this.initCallbacks.run(a,this),this.trigger("initialize:after",a),this.trigger("start",a)},addRegions:function(a){var b,c,e;for(e in a)a.hasOwnProperty(e)&&(b=a[e],typeof b=="string"?c=new d.Region({el:b}):c=new b,this[e]=c)},removeRegion:function(a){this[a].close(),delete this[a]},module:function(a,b){var c=e.call(arguments);return c.unshift(this),d.Module.create.apply(d.Module,c)}}),d.Application.extend=a.View.extend,d.AppRouter=a.Router.extend({constructor:function(b){a.Router.prototype.constructor.call(this,b);if(this.appRoutes){var c=this.controller;b&&b.controller&&(c=b.controller),this.processAppRoutes(c,this.appRoutes)}},processAppRoutes:function(a,c){var d,e,f,g,h,i=[],j=this;for(f in c)c.hasOwnProperty(f)&&i.unshift([f,c[f]]);g=i.length;for(h=0;h<g;h++){f=i[h][0],e=i[h][1],d=a[e];if(!d){var k="Method '"+e+"' was not found on the controller",l=new Error(k);throw l.name="NoMethodError",l}d=b.bind(d,a),j.route(f,e,d)}}}),d.Module=function(a,c,e){this.moduleName=a,this.submodules={},this._initializerCallbacks=new d.Callbacks,this._finalizerCallbacks=new d.Callbacks,this._config={},this._config.app=c,this._config.customArgs=e,this._config.definitions=[];var f=new d.EventBinder;b.extend(this,f)},b.extend(d.Module.prototype,a.Events,{addInitializer:function(a){this._initializerCallbacks.add(a)},addFinalizer:function(a){this._finalizerCallbacks.add(a)},start:function(a){this._runModuleDefinition(),this._initializerCallbacks.run(a,this),this._isInitialized=!0,this.submodules&&b.each(this.submodules,function(a){a.start()})},stop:function(){if(!this._isInitialized)return;this._isInitialized=!1,this._finalizerCallbacks.run(),b.each(this.submodules,function(a){a.stop()})},addDefinition:function(a){this._config.definitions.push(a)},_runModuleDefinition:function(){if(this._config.definitions.length===0)return;var e=b.flatten([this,this._config.app,a,d,c,b,this._config.customArgs]),f=this._config.definitions.length-1;for(var g=0;g<=f;g++){var h=this._config.definitions[g];h.apply(this,e)}}}),b.extend(d.Module,{create:function(a,c,f){var g=this,h=a,c=c.split("."),i=e.apply(arguments);i.splice(0,3);var j=c.length;return b.each(c,function(b,c){var e=c===j-1,k=h[b];k||(k=new d.Module(b,a,i),h[b]=k,h.submodules[b]=k),e&&g._createModuleDefinition(k,f,a),h=k}),h},_createModuleDefinition:function(a,b,c){var d=this._getModuleDefinitionOptions(b);d.definition&&a.addDefinition(d.definition),d.startWithApp&&c.addInitializer(function(b){a.start(b)})},_getModuleDefinitionOptions:function(a){var c={startWithApp:!0};return a?(b.isFunction(a)?c.definition=a:(c.definition=a.define,a.hasOwnProperty("startWithApp")&&(c.startWithApp=a.startWithApp)),c):c}}),d.TemplateCache=function(a){this.templateId=a},b.extend(d.TemplateCache,{templateCaches:{},get:function(a){var b=this,c=this.templateCaches[a];return c||(c=new d.TemplateCache(a),this.templateCaches[a]=c),c.load()},clear:function(){var a,b=arguments.length;if(b>0)for(a=0;a<b;a++)delete this.templateCaches[arguments[a]];else this.templateCaches={}}}),b.extend(d.TemplateCache.prototype,{load:function(){var a=this;if(this.compiledTemplate)return this.compiledTemplate;var b=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(b),this.compiledTemplate},loadTemplate:function(a){var b=c(a).html();if(!b||b.length===0){var d="Could not find template: '"+a+"'",e=new Error(d);throw e.name="NoTemplateError",e}return b},compileTemplate:function(a){return b.template(a)}}),d.Renderer={render:function(a,b){var c=d.TemplateCache.get(a),e=c(b);return e}},d.Callbacks=function(){this.deferred=c.Deferred(),this.promise=this.deferred.promise()},b.extend(d.Callbacks.prototype,{add:function(a,b){this.promise.done(function(c,d){b&&(c=b),a.call(c,d)})},run:function(a,b){this.deferred.resolve(b,a)}}),d.EventAggregator=d.EventBinder.extend({constructor:function(a){d.EventBinder.apply(this,arguments),b.extend(this,a)},bindTo:function(a,b,c){return d.EventBinder.prototype.bindTo.call(this,this,a,b,c)}}),b.extend(d.EventAggregator.prototype,a.Events),d.EventAggregator.extend=a.View.extend;var e=Array.prototype.slice;return d}(Backbone,_,window.jQuery||window.Zepto||window.ender)
+Backbone.Marionette=function(a,b,c){var d={};d.EventBinder=function(){this._eventBindings=[]},b.extend(d.EventBinder.prototype,{bindTo:function(a,b,c,d){d=d||this,a.on(b,c,d);var e={obj:a,eventName:b,callback:c,context:d};return this._eventBindings.push(e),e},unbindFrom:function(a){a.obj.off(a.eventName,a.callback,a.context),this._eventBindings=b.reject(this._eventBindings,function(b){return b===a})},unbindAll:function(){var a=this,c=b.map(this._eventBindings,b.identity);b.each(c,function(b,c){a.unbindFrom(b)})}}),d.EventBinder.extend=a.View.extend,d.View=a.View.extend({constructor:function(){a.View.prototype.constructor.apply(this,arguments);var c=new d.EventBinder;b.extend(this,c),this.bindTo(this,"show",this.onShowCalled,this)},getTemplate:function(){var a;return this.options&&this.options.template?a=this.options.template:a=this.template,a},serializeData:function(){var a;return this.model?a=this.model.toJSON():this.collection&&(a={items:this.collection.toJSON()}),a=this.mixinTemplateHelpers(a),a},mixinTemplateHelpers:function(a){a=a||{};var c=this.templateHelpers;return b.isFunction(c)&&(c=c.call(this)),b.extend(a,c)},configureTriggers:function(){if(!this.triggers)return;var a=this.triggers,c=this,d={};return b.isFunction(a)&&(a=a.call(this)),b.each(a,function(a,b){d[b]=function(b){b&&b.preventDefault&&b.preventDefault(),b&&b.stopPropagation&&b.stopPropagation(),c.trigger(a)}}),d},delegateEvents:function(c){c=c||this.events,b.isFunction(c)&&(c=c.call(this));var d={},e=this.configureTriggers();b.extend(d,c,e),a.View.prototype.delegateEvents.call(this,d)},onShowCalled:function(){},close:function(){this.beforeClose&&this.beforeClose(),this.remove(),this.onClose&&this.onClose(),this.trigger("close"),this.unbindAll(),this.unbind()},bindUIElements:function(){if(!this.ui)return;var a=this;this.uiBindings||(this.uiBindings=this.ui),this.ui={},b.each(b.keys(this.uiBindings),function(b){var c=a.uiBindings[b];a.ui[b]=a.$(c)})}}),d.ItemView=d.View.extend({constructor:function(){d.View.prototype.constructor.apply(this,arguments),this.initialEvents()},initialEvents:function(){this.collection&&this.bindTo(this.collection,"reset",this.render,this)},render:function(){this.beforeRender&&this.beforeRender(),this.trigger("before:render",this),this.trigger("item:before:render",this);var a=this.serializeData(),b=this.getTemplate(),c=d.Renderer.render(b,a);return this.$el.html(c),this.bindUIElements(),this.onRender&&this.onRender(),this.trigger("render",this),this.trigger("item:rendered",this),this},close:function(){this.trigger("item:before:close"),d.View.prototype.close.apply(this,arguments),this.trigger("item:closed")}}),d.CollectionView=d.View.extend({constructor:function(){d.View.prototype.constructor.apply(this,arguments),this.initChildViewStorage(),this.initialEvents(),this.onShowCallbacks=new d.Callbacks},initialEvents:function(){this.collection&&(this.bindTo(this.collection,"add",this.addChildView,this),this.bindTo(this.collection,"remove",this.removeItemView,this),this.bindTo(this.collection,"reset",this.render,this))},addChildView:function(a,b,c){this.closeEmptyView();var d=this.getItemView();return this.addItemView(a,d,c.index)},onShowCalled:function(){this.onShowCallbacks.run()},triggerBeforeRender:function(){this.beforeRender&&this.beforeRender(),this.trigger("before:render",this),this.trigger("collection:before:render",this)},triggerRendered:function(){this.onRender&&this.onRender(),this.trigger("render",this),this.trigger("collection:rendered",this)},render:function(){return this.triggerBeforeRender(),this.closeEmptyView(),this.closeChildren(),this.collection&&this.collection.length>0?this.showCollection():this.showEmptyView(),this.triggerRendered(),this},showCollection:function(){var a=this,b=this.getItemView();this.collection.each(function(c,d){a.addItemView(c,b,d)})},showEmptyView:function(){var b=this.options.emptyView||this.emptyView;if(b&&!this._showingEmptyView){this._showingEmptyView=!0;var c=new a.Model;this.addItemView(c,b,0)}},closeEmptyView:function(){this._showingEmptyView&&(this.closeChildren(),delete this._showingEmptyView)},getItemView:function(){var a=this.options.itemView||this.itemView;if(!a){var b=new Error("An `itemView` must be specified");throw b.name="NoItemViewError",b}return a},addItemView:function(a,b,c){var d=this,f=this.buildItemView(a,b);this.storeChild(f),this.onItemAdded&&this.onItemAdded(f),this.trigger("item:added",f);var g=this.renderItemView(f,c);f.onShow&&this.onShowCallbacks.add(f.onShow,f);var h=this.bindTo(f,"all",function(){var a=e.call(arguments);a[0]="itemview:"+a[0],a.splice(1,0,f),d.trigger.apply(d,a)});return this.childBindings=this.childBindings||{},this.childBindings[f.cid]=h,g},renderItemView:function(a,b){a.render(),this.appendHtml(this,a,b)},buildItemView:function(a,c){var d=b.result(this,"itemViewOptions"),e=b.extend({model:a},d),f=new c(e);return f},removeItemView:function(a){var b=this.children[a.cid];if(b){var c=this.childBindings[b.cid];c&&(this.unbindFrom(c),delete this.childBindings[b.cid]),b.close(),delete this.children[a.cid]}(!this.collection||this.collection.length===0)&&this.showEmptyView(),this.trigger("item:removed",b)},appendHtml:function(a,b,c){a.$el.append(b.el)},storeChild:function(a){this.children[a.model.cid]=a},initChildViewStorage:function(){this.children={}},close:function(){this.trigger("collection:before:close"),this.closeChildren(),d.View.prototype.close.apply(this,arguments),this.trigger("collection:closed")},closeChildren:function(){var a=this;this.children&&b.each(b.clone(this.children),function(b){a.removeItemView(b.model)})}}),d.CompositeView=d.CollectionView.extend({constructor:function(a){d.CollectionView.apply(this,arguments),this.itemView=this.getItemView()},initialEvents:function(){this.collection&&(this.bindTo(this.collection,"add",this.addChildView,this),this.bindTo(this.collection,"remove",this.removeItemView,this),this.bindTo(this.collection,"reset",this.renderCollection,this))},getItemView:function(){return this.itemView||this.constructor},render:function(){var a=this;this.resetItemViewContainer();var b=this.renderModel();return this.$el.html(b),this.bindUIElements(),this.trigger("composite:model:rendered"),this.trigger("render"),this.renderCollection(),this.trigger("composite:rendered"),this},renderCollection:function(){d.CollectionView.prototype.render.apply(this,arguments),this.trigger("composite:collection:rendered")},renderModel:function(){var a={};a=this.serializeData();var b=this.getTemplate();return d.Renderer.render(b,a)},appendHtml:function(a,b){var c=this.getItemViewContainer(a);c.append(b.el)},getItemViewContainer:function(a){var c;if("$itemViewContainer"in a)c=a.$itemViewContainer;else{if(a.itemViewContainer){c=a.$(b.result(a,"itemViewContainer"));if(c.length<=0){var d=new Error("Missing `itemViewContainer`");throw d.name="ItemViewContainerMissingError",d}}else c=a.$el;a.$itemViewContainer=c}return c},resetItemViewContainer:function(){this.$itemViewContainer&&delete this.$itemViewContainer}}),d.Region=function(a){this.options=a||{};var c=new d.EventBinder;b.extend(this,c,a);if(!this.el){var e=new Error("An 'el' must be specified");throw e.name="NoElError",e}this.initialize&&this.initialize.apply(this,arguments)},b.extend(d.Region.prototype,a.Events,{show:function(a){this.ensureEl(),this.close(),a.render(),this.open(a),a.onShow&&a.onShow(),a.trigger("show"),this.onShow&&this.onShow(a),this.trigger("view:show",a),this.currentView=a},ensureEl:function(){if(!this.$el||this.$el.length===0)this.$el=this.getEl(this.el)},getEl:function(a){return c(a)},open:function(a){this.$el.html(a.el)},close:function(){var a=this.currentView;if(!a)return;a.close&&a.close(),this.trigger("view:closed",a),delete this.currentView},attachView:function(a){this.currentView=a}}),d.Region.extend=a.View.extend,d.Layout=d.ItemView.extend({regionType:d.Region,constructor:function(){a.Marionette.ItemView.apply(this,arguments),this.initializeRegions()},render:function(){var a=d.ItemView.prototype.render.apply(this,arguments);return this.render=function(){this.closeRegions(),this.reInitializeRegions();var a=d.ItemView.prototype.render.apply(this,arguments);return a},a},close:function(){this.closeRegions(),this.destroyRegions(),a.Marionette.ItemView.prototype.close.call(this,arguments)},initializeRegions:function(){this.regionManagers||(this.regionManagers={});var a=this;b.each(this.regions,function(b,c){if(typeof b!="string"&&typeof b.selector!="string")throw new Exception("Region must be specified as a selector string or an object with selector property");selector=typeof b=="string"?b:b.selector;var d=typeof b.regionType=="undefined"?a.regionType:b.regionType,e=new d({el:selector,getEl:function(b){return a.$(b)}});a.regionManagers[c]=e,a[c]=e})},reInitializeRegions:function(){this.regionManagers&&b.size(this.regionManagers)===0?this.initializeRegions():b.each(this.regionManagers,function(a){delete a.$el})},closeRegions:function(){var a=this;b.each(this.regionManagers,function(a,b){a.close()})},destroyRegions:function(){var a=this;b.each(this.regionManagers,function(b,c){delete a[c]}),this.regionManagers={}}}),d.Application=function(a){this.initCallbacks=new d.Callbacks,this.vent=new d.EventAggregator,this.submodules={};var c=new d.EventBinder;b.extend(this,c,a)},b.extend(d.Application.prototype,a.Events,{addInitializer:function(a){this.initCallbacks.add(a)},start:function(a){this.trigger("initialize:before",a),this.initCallbacks.run(a,this),this.trigger("initialize:after",a),this.trigger("start",a)},addRegions:function(a){var b,c,e;for(e in a)a.hasOwnProperty(e)&&(b=a[e],typeof b=="string"?c=new d.Region({el:b}):c=new b,this[e]=c)},removeRegion:function(a){this[a].close(),delete this[a]},module:function(a,b){var c=e.call(arguments);return c.unshift(this),d.Module.create.apply(d.Module,c)}}),d.Application.extend=a.View.extend,d.AppRouter=a.Router.extend({constructor:function(b){a.Router.prototype.constructor.call(this,b);if(this.appRoutes){var c=this.controller;b&&b.controller&&(c=b.controller),this.processAppRoutes(c,this.appRoutes)}},processAppRoutes:function(a,c){var d,e,f,g,h,i=[],j=this;for(f in c)c.hasOwnProperty(f)&&i.unshift([f,c[f]]);g=i.length;for(h=0;h<g;h++){f=i[h][0],e=i[h][1],d=a[e];if(!d){var k="Method '"+e+"' was not found on the controller",l=new Error(k);throw l.name="NoMethodError",l}d=b.bind(d,a),j.route(f,e,d)}}}),d.Module=function(a,c,e){this.moduleName=a,this.submodules={},this._initializerCallbacks=new d.Callbacks,this._finalizerCallbacks=new d.Callbacks,this._config={},this._config.app=c,this._config.customArgs=e,this._config.definitions=[];var f=new d.EventBinder;b.extend(this,f)},b.extend(d.Module.prototype,a.Events,{addInitializer:function(a){this._initializerCallbacks.add(a)},addFinalizer:function(a){this._finalizerCallbacks.add(a)},start:function(a){this._runModuleDefinition(),this._initializerCallbacks.run(a,this),this._isInitialized=!0,this.submodules&&b.each(this.submodules,function(a){a.start()})},stop:function(){if(!this._isInitialized)return;this._isInitialized=!1,this._finalizerCallbacks.run(),b.each(this.submodules,function(a){a.stop()})},addDefinition:function(a){this._config.definitions.push(a)},_runModuleDefinition:function(){if(this._config.definitions.length===0)return;var e=b.flatten([this,this._config.app,a,d,c,b,this._config.customArgs]),f=this._config.definitions.length-1;for(var g=0;g<=f;g++){var h=this._config.definitions[g];h.apply(this,e)}}}),b.extend(d.Module,{create:function(a,c,f){var g=this,h=a,c=c.split("."),i=e.apply(arguments);i.splice(0,3);var j=c.length;return b.each(c,function(b,c){var e=c===j-1,k=h[b];k||(k=new d.Module(b,a,i),h[b]=k,h.submodules[b]=k),e&&g._createModuleDefinition(k,f,a),h=k}),h},_createModuleDefinition:function(a,b,c){var d=this._getModuleDefinitionOptions(b);d.definition&&a.addDefinition(d.definition),d.startWithApp&&c.addInitializer(function(b){a.start(b)})},_getModuleDefinitionOptions:function(a){var c={startWithApp:!0};return a?(b.isFunction(a)?c.definition=a:(c.definition=a.define,a.hasOwnProperty("startWithApp")&&(c.startWithApp=a.startWithApp)),c):c}}),d.TemplateCache=function(a){this.templateId=a},b.extend(d.TemplateCache,{templateCaches:{},get:function(a){var b=this,c=this.templateCaches[a];return c||(c=new d.TemplateCache(a),this.templateCaches[a]=c),c.load()},clear:function(){var a,b=arguments.length;if(b>0)for(a=0;a<b;a++)delete this.templateCaches[arguments[a]];else this.templateCaches={}}}),b.extend(d.TemplateCache.prototype,{load:function(){var a=this;if(this.compiledTemplate)return this.compiledTemplate;var b=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(b),this.compiledTemplate},loadTemplate:function(a){var b=c(a).html();if(!b||b.length===0){var d="Could not find template: '"+a+"'",e=new Error(d);throw e.name="NoTemplateError",e}return b},compileTemplate:function(a){return b.template(a)}}),d.Renderer={render:function(a,b){var c=d.TemplateCache.get(a),e=c(b);return e}},d.Callbacks=function(){this.deferred=c.Deferred(),this.promise=this.deferred.promise()},b.extend(d.Callbacks.prototype,{add:function(a,b){this.promise.done(function(c,d){b&&(c=b),a.call(c,d)})},run:function(a,b){this.deferred.resolve(b,a)}}),d.EventAggregator=d.EventBinder.extend({constructor:function(a){d.EventBinder.apply(this,arguments),b.extend(this,a)},bindTo:function(a,b,c){return d.EventBinder.prototype.bindTo.call(this,this,a,b,c)}}),b.extend(d.EventAggregator.prototype,a.Events),d.EventAggregator.extend=a.View.extend;var e=Array.prototype.slice;return d}(Backbone,_,window.jQuery||window.Zepto||window.ender)
View
2 license.txt
@@ -1,4 +1,4 @@
-// Backbone.Marionette v0.9.4
+// Backbone.Marionette v0.9.5
//
// Copyright (C)2012 Derick Bailey, Muted Solutions, LLC
// Distributed Under MIT License
View
2 src/backbone.marionette.layout.js
@@ -8,7 +8,7 @@
// attaches `Region` instances to the specified `regions`.
// Used for composite view management and sub-application areas.
Marionette.Layout = Marionette.ItemView.extend({
- regionType: Backbone.Marionette.Region,
+ regionType: Marionette.Region,
constructor: function () {
Backbone.Marionette.ItemView.apply(this, arguments);

0 comments on commit dbad3f2

Please sign in to comment.
Something went wrong with that request. Please try again.