From 5090557c73fceb62b4852540acd6320a0051d8f8 Mon Sep 17 00:00:00 2001 From: Paul Falgout Date: Sun, 21 Apr 2019 23:23:09 +0900 Subject: [PATCH] Bump and build 4.1.2 --- bower.json | 2 +- changelog.md | 5 +++++ lib/backbone.marionette.esm.js | 2 +- lib/backbone.marionette.js | 4 ++-- lib/backbone.marionette.min.js | 4 ++-- package.json | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index a69055ab1f..dd97a44266 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "backbone.marionette", "description": "The Backbone Framework", "homepage": "https://marionettejs.com/", - "version": "4.1.1", + "version": "4.1.2", "main": "./lib/backbone.marionette.js", "license": "MIT", "keywords": [ diff --git a/changelog.md b/changelog.md index 3c5d5f8615..2fbe39a6bb 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +### v4.1.2 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v4.1.1...v4.1.2) + +#### Fixes +* Error in the build's version number. + ### v4.1.1 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v4.1.0...v4.1.1) #### Fixes diff --git a/lib/backbone.marionette.esm.js b/lib/backbone.marionette.esm.js index a90f3dbd39..4597b85aa2 100644 --- a/lib/backbone.marionette.esm.js +++ b/lib/backbone.marionette.esm.js @@ -2,7 +2,7 @@ import Backbone from 'backbone'; import _ from 'underscore'; import Radio from 'backbone.radio'; -var version = "4.1.0"; +var version = "4.1.2"; //Internal utility for creating context style global utils var proxy = function proxy(method) { diff --git a/lib/backbone.marionette.js b/lib/backbone.marionette.js index f720d33abb..33db50b658 100644 --- a/lib/backbone.marionette.js +++ b/lib/backbone.marionette.js @@ -2,7 +2,7 @@ * @license * MarionetteJS (Backbone.Marionette) * ---------------------------------- -* v4.1.0 +* v4.1.2 * * Copyright (c)2019 Derick Bailey, Muted Solutions, LLC. * Distributed under MIT license @@ -26,7 +26,7 @@ _ = _ && _.hasOwnProperty('default') ? _['default'] : _; Radio = Radio && Radio.hasOwnProperty('default') ? Radio['default'] : Radio; - var version = "4.1.0"; + var version = "4.1.2"; //Internal utility for creating context style global utils var proxy = function proxy(method) { diff --git a/lib/backbone.marionette.min.js b/lib/backbone.marionette.min.js index 85d2c88143..29b593cdd0 100644 --- a/lib/backbone.marionette.min.js +++ b/lib/backbone.marionette.min.js @@ -2,12 +2,12 @@ * @license * MarionetteJS (Backbone.Marionette) * ---------------------------------- -* v4.1.0 +* v4.1.2 * * Copyright (c)2019 Derick Bailey, Muted Solutions, LLC. * Distributed under MIT license * * http://marionettejs.com */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("backbone"),require("underscore"),require("backbone.radio")):"function"==typeof define&&define.amd?define(["exports","backbone","underscore","backbone.radio"],t):(e=e||self,function(){var i=e.Marionette,n=e.Marionette={};t(n,e.Backbone,e._,e.Backbone.Radio),n.noConflict=function(){return e.Marionette=i,n}}())}(this,function(e,t,i,n){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,i=i&&i.hasOwnProperty("default")?i.default:i,n=n&&n.hasOwnProperty("default")?n.default:n;var s=function(e){return function(t){for(var i=arguments.length,n=new Array(i>1?i-1:0),s=1;s1?i-1:0),h=1;h1&&void 0!==arguments[1]?arguments[1]:ie(e)).detach()},replaceEl:function(e,t){if(e!==t){var i=t.parentNode;i&&i.replaceChild(e,t)}},swapEl:function(e,t){if(e!==t){var i=e.parentNode,n=t.parentNode;if(i&&n){var s=e.nextSibling,r=t.nextSibling;i.insertBefore(t,s),n.insertBefore(e,r)}}},setContents:function(e,t){(arguments.length>2&&void 0!==arguments[2]?arguments[2]:ie(e)).html(t)},appendContents:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i._$el,s=void 0===n?ie(e):n,r=i._$contents,o=void 0===r?ie(t):r;s.append(o)},hasContents:function(e){return!!e&&e.hasChildNodes()},detachContents:function(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:ie(e)).contents().detach()}},re={Dom:se,_isElAttached:function(){return!!this.el&&this.Dom.hasEl(this.Dom.getDocumentEl(this.el),this.el)},supportsRenderLifecycle:!0,supportsDestroyLifecycle:!0,_isDestroyed:!1,isDestroyed:function(){return!!this._isDestroyed},_isRendered:!1,isRendered:function(){return!!this._isRendered},_isAttached:!1,isAttached:function(){return!!this._isAttached},delegateEvents:function(e){this._proxyBehaviorViewProperties(),this._buildEventProxies();var n=i.extend({},this._getBehaviorEvents(),this._getEvents(e),this._getBehaviorTriggers(),this._getTriggers());return t.View.prototype.delegateEvents.call(this,n),this},_getEvents:function(e){return e?this.normalizeUIKeys(e):this.events?this.normalizeUIKeys(i.result(this,"events")):void 0},_getTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(i.result(this,"triggers"));return this._getViewTriggers(this,e)}},delegateEntityEvents:function(){return this._delegateEntityEvents(this.model,this.collection),this._delegateBehaviorEntityEvents(),this},undelegateEntityEvents:function(){return this._undelegateEntityEvents(this.model,this.collection),this._undelegateBehaviorEntityEvents(),this},destroy:function(e){if(this._isDestroyed||this._isDestroying)return this;this._isDestroying=!0;var t=this._isAttached&&!this._disableDetachEvents;return this.triggerMethod("before:destroy",this,e),t&&this.triggerMethod("before:detach",this),this.unbindUIElements(),this._removeElement(),t&&(this._isAttached=!1,this.triggerMethod("detach",this)),this._removeChildren(),this._isDestroyed=!0,this._isRendered=!1,this._destroyBehaviors(e),this._deleteEntityEventHandlers(),this.triggerMethod("destroy",this,e),this._triggerEventOnBehaviors("destroy",this,e),this.stopListening(),this},_removeElement:function(){this.$el.off().removeData(),this.Dom.detachEl(this.el,this.$el)},bindUIElements:function(){return this._bindUIElements(),this._bindBehaviorUIElements(),this},unbindUIElements:function(){return this._unbindUIElements(),this._unbindBehaviorUIElements(),this},getUI:function(e){return this._getUI(e)},_buildEventProxies:function(){this._childViewEvents=this.normalizeMethods(i.result(this,"childViewEvents")),this._childViewTriggers=i.result(this,"childViewTriggers"),this._eventPrefix=this._getEventPrefix()},_getEventPrefix:function(){var e=!!G("childViewEventPrefix")&&"childview",t=i.result(this,"childViewEventPrefix",e);return!1===t?t:t+":"},_proxyChildViewEvents:function(e){(this._childViewEvents||this._childViewTriggers||this._eventPrefix)&&this.listenTo(e,"all",this._childViewEventHandler)},_childViewEventHandler:function(e){for(var t=this._childViewEvents,i=arguments.length,n=new Array(i>1?i-1:0),s=1;s1&&(this.$el=this.Dom.getEl(this.el))},_setElement:function(e){if(e===this.el)return this;var t=this._isReplaced;if(this._restoreEl(),this.el=e,this._setEl(),this.currentView){var i=this.currentView;t?this._replaceEl(i):this.attachHtml(i)}return this},_setupChildView:function(e){I(e),this._proxyChildViewEvents(e),e.on("destroy",this._empty,this)},_proxyChildViewEvents:function(e){var t=this._parentView;t&&t._proxyChildViewEvents(e)},_shouldDisableMonitoring:function(){return this._parentView&&!1===this._parentView.monitorViewEvents},_isElAttached:function(){return this.Dom.hasEl(this.Dom.getDocumentEl(this.el),this.el)},_attachView:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).replaceElement,n=!e._isAttached&&this._isElAttached()&&!this._shouldDisableMonitoring(),s=void 0===t?!!i.result(this,"replaceElement"):!!t;n&&e.triggerMethod("before:attach",e),s?this._replaceEl(e):this.attachHtml(e),n&&(e._isAttached=!0,e.triggerMethod("attach",e)),e._isShown=!0},_ensureElement:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(i.isObject(this.el)||this._setEl(),!this.$el||0===this.$el.length){if(void 0===e.allowMissingEl?!!i.result(this,"allowMissingEl"):!!e.allowMissingEl)return!1;throw new d({name:"RegionError",message:'An "el" must exist in DOM for this region '.concat(this.cid),url:"marionette.region.html#additional-options"})}return!0},_getView:function(e){if(!e)throw new d({name:"RegionError",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show.",url:"marionette.region.html#showing-a-view"});if(e._isDestroyed)throw new d({name:"RegionError",message:'View (cid: "'.concat(e.cid,'") has already been destroyed and cannot be used.'),url:"marionette.region.html#showing-a-view"});if(e instanceof t.View)return e;var i=this._getViewOptions(e);return new ve(i)},_getViewOptions:function(e){if(i.isFunction(e))return{template:e};if(i.isObject(e))return e;return{template:function(){return e}}},getEl:function(e){var t=i.result(this,"parentEl");return t&&i.isString(e)?this.Dom.findEl(t,e):this.Dom.getEl(e)},_replaceEl:function(e){this._restoreEl(),e.on("before:destroy",this._restoreEl,this),this.Dom.replaceEl(e.el,this.el),this._isReplaced=!0},_restoreEl:function(){if(this._isReplaced){var e=this.currentView;e&&(this._detachView(e),this._isReplaced=!1)}},isReplaced:function(){return!!this._isReplaced},isSwappingView:function(){return!!this._isSwappingView},attachHtml:function(e){this.Dom.appendContents(this.el,e.el,{_$el:this.$el,_$contents:e.$el})},empty:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{allowMissingEl:!0},t=this.currentView;return t?(this._empty(t,!0),this):(this._ensureElement(e)&&this.detachHtml(),this)},_empty:function(e,t){e.off("destroy",this._empty,this),this.triggerMethod("before:empty",this,e),this._restoreEl(),delete this.currentView,e._isDestroyed||(t?this.removeView(e):this._detachView(e),e._isShown=!1,this._stopChildViewEvents(e)),this.triggerMethod("empty",this,e)},_stopChildViewEvents:function(e){this._parentView&&this._parentView.stopListening(e)},destroyView:function(e){return e._isDestroyed?e:(he(e,this._shouldDisableMonitoring()),e)},removeView:function(e){this.destroyView(e)},detachView:function(){var e=this.currentView;if(e)return this._empty(e),e},_detachView:function(e){var t=e._isAttached&&!this._shouldDisableMonitoring(),i=this._isReplaced;t&&e.triggerMethod("before:detach",e),i?this.Dom.replaceEl(this.el,e.el):this.detachHtml(),t&&(e._isAttached=!1,e.triggerMethod("detach",e))},detachHtml:function(){this.Dom.detachContents(this.el,this.$el)},hasView:function(){return!!this.currentView},reset:function(e){return this.empty(e),this.el=this._initEl,delete this.$el,this},_isDestroyed:!1,isDestroyed:function(){return this._isDestroyed},destroy:function(e){return this._isDestroyed?this:(this.triggerMethod("before:destroy",this,e),this._isDestroyed=!0,this.reset(e),this._name&&this._parentView._removeReferences(this._name),delete this._parentView,delete this._name,this.triggerMethod("destroy",this,e),this.stopListening(),this)}});var ue={regionClass:le,_initRegions:function(){this.regions=this.regions||{},this._regions={},this.addRegions(i.result(this,"regions"))},_reInitRegions:function(){H(this._regions,"reset")},addRegion:function(e,t){var i={};return i[e]=t,this.addRegions(i)[e]},addRegions:function(e){if(!i.isEmpty(e))return e=this.normalizeUIValues(e,"el"),this.regions=i.extend({},this.regions,e),this._addRegions(e)},_addRegions:function(e){var t=this,n={regionClass:this.regionClass,parentEl:i.partial(i.result,this,"el")};return i.reduce(e,function(e,i,s){return e[s]=ae(i,n),t._addRegion(e[s],s),e},{})},_addRegion:function(e,t){this.triggerMethod("before:add:region",this,t,e),e._parentView=this,e._name=t,this._regions[t]=e,this.triggerMethod("add:region",this,t,e)},removeRegion:function(e){var t=this._regions[e];return this._removeRegion(t,e),t},removeRegions:function(){var e=this._getRegions();return i.each(this._regions,this._removeRegion.bind(this)),e},_removeRegion:function(e,t){this.triggerMethod("before:remove:region",this,t,e),e.destroy(),this.triggerMethod("remove:region",this,t,e)},_removeReferences:function(e){delete this.regions[e],delete this._regions[e]},emptyRegions:function(){var e=this.getRegions();return H(e,"empty"),e},hasRegion:function(e){return!!this.getRegion(e)},getRegion:function(e){return this._isRendered||this.render(),this._regions[e]},_getRegions:function(){return i.clone(this._regions)},getRegions:function(){return this._isRendered||this.render(),this._getRegions()},showChildView:function(e,t,i){return this.getRegion(e).show(t,i),t},detachChildView:function(e){return this.getRegion(e).detachView()},getChildView:function(e){return this.getRegion(e).currentView}};function ge(e){return this.prototype._renderHtml=e,this}var _e=["behaviors","childViewEventPrefix","childViewEvents","childViewTriggers","collectionEvents","events","modelEvents","regionClass","regions","template","templateContext","triggers","ui"];function fe(e,t){return t.currentView&&e.push(t.currentView),e}var ve=t.View.extend({constructor:function(e){this._setOptions(e,_e),I(this),this._initBehaviors(),this._initRegions(),t.View.prototype.constructor.apply(this,arguments),this.delegateEntityEvents(),this._triggerEventOnBehaviors("initialize",this,e)},setElement:function(){return t.View.prototype.setElement.apply(this,arguments),this._isRendered=this.Dom.hasContents(this.el),this._isAttached=this._isElAttached(),this._isRendered&&this.bindUIElements(),this},render:function(){var e=this.getTemplate();return!1===e||this._isDestroyed?this:(this.triggerMethod("before:render",this),this._isRendered&&this._reInitRegions(),this._renderTemplate(e),this.bindUIElements(),this._isRendered=!0,this.triggerMethod("render",this),this)},_removeChildren:function(){this.removeRegions()},_getImmediateChildren:function(){return i.reduce(this._regions,fe,[])}},{setRenderer:ge,setDomApi:ne});i.extend(ve.prototype,re,ue);var me=function(){this._init()};function pe(e,t){return t.model&&t.model.get(e)}i.each(["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce","partition"],function(e){me.prototype[e]=function(){for(var t=arguments.length,n=new Array(t),s=0;s1&&void 0!==arguments[1]?arguments[1]:this._views.length;this._addViewIndexes(e),this._views.splice(t,0,e),this._updateLength()},_addViewIndexes:function(e){this._viewsByCid[e.cid]=e,e.model&&(this._indexByModel[e.model.cid]=e)},_sort:function(e,t){return"string"==typeof e?(e=i.partial(pe,e),this._sortBy(e)):1===e.length?this._sortBy(e.bind(t)):this._views.sort(e.bind(t))},_sortBy:function(e){var t=i.sortBy(this._views,e);return this._set(t),t},_set:function(e,t){this._views.length=0,this._views.push.apply(this._views,e.slice(0)),t&&(this._viewsByCid={},this._indexByModel={},i.each(e,this._addViewIndexes.bind(this)),this._updateLength())},_swap:function(e,t){var i=this.findIndexByView(e),n=this.findIndexByView(t);if(-1!==i&&-1!==n){var s=this._views[i];this._views[i]=this._views[n],this._views[n]=s}},findByModel:function(e){return this.findByModelCid(e.cid)},findByModelCid:function(e){return this._indexByModel[e]},findByIndex:function(e){return this._views[e]},findIndexByView:function(e){return this._views.indexOf(e)},findByCid:function(e){return this._viewsByCid[e]},hasView:function(e){return!!this.findByCid(e.cid)},_remove:function(e){if(this._viewsByCid[e.cid]){e.model&&delete this._indexByModel[e.model.cid],delete this._viewsByCid[e.cid];var t=this.findIndexByView(e);this._views.splice(t,1),this._updateLength()}},_updateLength:function(){this.length=this._views.length}});var we=["behaviors","childView","childViewContainer","childViewEventPrefix","childViewEvents","childViewOptions","childViewTriggers","collectionEvents","emptyView","emptyViewOptions","events","modelEvents","sortWithCollection","template","templateContext","triggers","ui","viewComparator","viewFilter"],Ee=t.View.extend({sortWithCollection:!0,constructor:function(e){this._setOptions(e,we),I(this),this._initChildViewStorage(),this._initBehaviors(),t.View.prototype.constructor.apply(this,arguments),this.getEmptyRegion(),this.delegateEntityEvents(),this._triggerEventOnBehaviors("initialize",this,e)},_initChildViewStorage:function(){this._children=new me,this.children=new me},getEmptyRegion:function(){var e=this.$container||this.$el;return this._emptyRegion&&!this._emptyRegion.isDestroyed()?(this._emptyRegion._setElement(e[0]),this._emptyRegion):(this._emptyRegion=new le({el:e[0],replaceElement:!1}),this._emptyRegion._parentView=this,this._emptyRegion)},_initialEvents:function(){this._isRendered||this.listenTo(this.collection,{sort:this._onCollectionSort,reset:this._onCollectionReset,update:this._onCollectionUpdate})},_onCollectionSort:function(e,t){var i=t.add,n=t.merge,s=t.remove;this.sortWithCollection&&!1!==this.viewComparator&&(i||s||n||this.sort())},_onCollectionReset:function(){this._destroyChildren(),this._addChildModels(this.collection.models),this.sort()},_onCollectionUpdate:function(e,t){var i=t.changes,n=i.removed.length&&this._removeChildModels(i.removed);this._addedViews=i.added.length&&this._addChildModels(i.added),this._detachChildren(n),this.sort(),this._removeChildViews(n)},_removeChildModels:function(e){var t=this;return i.reduce(e,function(e,i){var n=t._removeChildModel(i);return n&&e.push(n),e},[])},_removeChildModel:function(e){var t=this._children.findByModel(e);return t&&this._removeChild(t),t},_removeChild:function(e){this.triggerMethod("before:remove:child",this,e),this.children._remove(e),this._children._remove(e),this.triggerMethod("remove:child",this,e)},_addChildModels:function(e){return i.map(e,this._addChildModel.bind(this))},_addChildModel:function(e){var t=this._createChildView(e);return this._addChild(t),t},_createChildView:function(e){var t=this._getChildView(e),i=this._getChildViewOptions(e);return this.buildChildView(e,t,i)},_addChild:function(e,t){this.triggerMethod("before:add:child",this,e),this._setupChildView(e),this._children._add(e,t),this.children._add(e,t),this.triggerMethod("add:child",this,e)},_getChildView:function(e){var t=this.childView;if(!t)throw new d({name:"CollectionViewError",message:'A "childView" must be specified',url:"marionette.collectionview.html#collectionviews-childview"});if(!(t=this._getView(t,e)))throw new d({name:"CollectionViewError",message:'"childView" must be a view class or a function that returns a view class',url:"marionette.collectionview.html#collectionviews-childview"});return t},_getView:function(e,n){return e.prototype instanceof t.View||e===t.View?e:i.isFunction(e)?e.call(this,n):void 0},_getChildViewOptions:function(e){return i.isFunction(this.childViewOptions)?this.childViewOptions(e):this.childViewOptions},buildChildView:function(e,t,n){return new t(i.extend({model:e},n))},_setupChildView:function(e){I(e),e.on("destroy",this.removeChildView,this),this._proxyChildViewEvents(e)},_getImmediateChildren:function(){return this.children._views},setElement:function(){return t.View.prototype.setElement.apply(this,arguments),this._isAttached=this._isElAttached(),this},render:function(){if(this._isDestroyed)return this;this.triggerMethod("before:render",this),this._destroyChildren(),this.collection&&(this._addChildModels(this.collection.models),this._initialEvents());var e=this.getTemplate();return e&&(this._renderTemplate(e),this.bindUIElements()),this._getChildViewContainer(),this.sort(),this._isRendered=!0,this.triggerMethod("render",this),this},_getChildViewContainer:function(){var e=i.result(this,"childViewContainer");if(this.$container=e?this.$(e):this.$el,!this.$container.length)throw new d({name:"CollectionViewError",message:'The specified "childViewContainer" was not found: '.concat(e),url:"marionette.collectionview.html#defining-the-childviewcontainer"})},sort:function(){return this._sortChildren(),this.filter(),this},_sortChildren:function(){if(this._children.length){var e=this.getComparator();e&&(delete this._addedViews,this.triggerMethod("before:sort",this),this._children._sort(e,this),this.triggerMethod("sort",this))}},setComparator:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).preventRender,i=this.viewComparator!==e&&!t;return this.viewComparator=e,i&&this.sort(),this},removeComparator:function(e){return this.setComparator(null,e)},getComparator:function(){return this.viewComparator?this.viewComparator:!(!this.sortWithCollection||!1===this.viewComparator||!this.collection)&&this._viewComparator},_viewComparator:function(e){return this.collection.indexOf(e.model)},filter:function(){return this._isDestroyed?this:(this._filterChildren(),this._renderChildren(),this)},_filterChildren:function(){var e=this;if(this._children.length){var t=this._getFilter();if(t){delete this._addedViews,this.triggerMethod("before:filter",this);var n=[],s=[];i.each(this._children._views,function(i,r,o){(t.call(e,i,r,o)?n:s).push(i)}),this._detachChildren(s),this.children._set(n,!0),this.triggerMethod("filter",this,n,s)}else{var r=this.children.length!==this._children.length;this.children._set(this._children._views,r)}}},_getFilter:function(){var e=this.getFilter();if(!e)return!1;if(i.isFunction(e))return e;if(i.isObject(e)){var t=i.matches(e);return function(e){return t(e.model&&e.model.attributes)}}if(i.isString(e))return function(t){return t.model&&t.model.get(e)};throw new d({name:"CollectionViewError",message:'"viewFilter" must be a function, predicate object literal, a string indicating a model attribute, or falsy',url:"marionette.collectionview.html#defining-the-viewfilter"})},getFilter:function(){return this.viewFilter},setFilter:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).preventRender,i=this.viewFilter!==e&&!t;return this.viewFilter=e,i&&this.filter(),this},removeFilter:function(e){return this.setFilter(null,e)},_detachChildren:function(e){i.each(e,this._detachChildView.bind(this))},_detachChildView:function(e){var t=e._isAttached&&!1!==this.monitorViewEvents;t&&e.triggerMethod("before:detach",e),this.detachHtml(e),t&&(e._isAttached=!1,e.triggerMethod("detach",e)),e._isShown=!1},detachHtml:function(e){this.Dom.detachEl(e.el,e.$el)},_renderChildren:function(){this._hasUnrenderedViews&&(delete this._addedViews,delete this._hasUnrenderedViews);var e=this._addedViews||this.children._views;if(this.triggerMethod("before:render:children",this,e),this.isEmpty())this._showEmptyView();else{this._destroyEmptyView();var t=this._getBuffer(e);this._attachChildren(t,e)}delete this._addedViews,this.triggerMethod("render:children",this,e)},_getBuffer:function(e){var t=this,n=this.Dom.createBuffer();return i.each(e,function(e){oe(e),e._isShown=!0,t.Dom.appendContents(n,e.el,{_$contents:e.$el})}),n},_attachChildren:function(e,t){t=this._isAttached&&!1!==this.monitorViewEvents?t:[],i.each(t,function(e){e._isAttached||e.triggerMethod("before:attach",e)}),this.attachHtml(e,this.$container),i.each(t,function(e){e._isAttached||(e._isAttached=!0,e.triggerMethod("attach",e))})},attachHtml:function(e,t){this.Dom.appendContents(t[0],e,{_$el:t})},isEmpty:function(){return!this.children.length},_showEmptyView:function(){var e=this._getEmptyView();if(e){var t=this._getEmptyViewOptions();this.getEmptyRegion().show(new e(t))}},_getEmptyView:function(){var e=this.emptyView;if(e)return this._getView(e)},_destroyEmptyView:function(){var e=this.getEmptyRegion();e.hasView()&&e.empty()},_getEmptyViewOptions:function(){var e=this.emptyViewOptions||this.childViewOptions;return i.isFunction(e)?e.call(this):e},swapChildViews:function(e,t){if(!this._children.hasView(e)||!this._children.hasView(t))throw new d({name:"CollectionViewError",message:"Both views must be children of the collection view to swap.",url:"marionette.collectionview.html#swapping-child-views"});return this._children._swap(e,t),this.Dom.swapEl(e.el,t.el),this.children.hasView(e)!==this.children.hasView(t)?this.filter():this.children._swap(e,t),this},addChildView:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||e._isDestroyed)return e;if(e._isShown)throw new d({name:"CollectionViewError",message:"View is already shown in a Region or CollectionView",url:"marionette.region.html#showing-a-view"});if(i.isObject(t)&&(n=t),null!=n.index&&(t=n.index),this._isRendered||this.render(),this._addChild(e,t),n.preventRender)return this._hasUnrenderedViews=!0,e;var s=void 0!==t;return(!s||t>=this._children.length)&&!this._hasUnrenderedViews&&(this._addedViews=[e]),s?this._renderChildren():this.sort(),e},detachChildView:function(e){return this.removeChildView(e,{shouldDetach:!0}),e},removeChildView:function(e,t){return e?(this._removeChildView(e,t),this._removeChild(e),this.isEmpty()&&this._showEmptyView(),e):e},_removeChildViews:function(e){i.each(e,this._removeChildView.bind(this))},_removeChildView:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).shouldDetach;e.off("destroy",this.removeChildView,this),t?this._detachChildView(e):this._destroyChildView(e),this.stopListening(e)},_destroyChildView:function(e){e._isDestroyed||he(e,!1===this.monitorViewEvents)},_removeChildren:function(){this._destroyChildren(),this.getEmptyRegion().destroy(),delete this._addedViews},_destroyChildren:function(){this._children.length&&(this.triggerMethod("before:destroy:children",this),!1===this.monitorViewEvents&&this.Dom.detachContents(this.el,this.$el),this._removeChildViews(this._children._views),this._children._init(),this.children._init(),this.triggerMethod("destroy:children",this))}},{setDomApi:ne,setRenderer:ge});i.extend(Ee.prototype,re);var ye=["collectionEvents","events","modelEvents","triggers","ui"],Ve=function(e,t){this.view=t,this._setOptions(e,ye),this.cid=i.uniqueId(this.cidPrefix),this.ui=i.extend({},i.result(this,"ui"),i.result(t,"ui")),this.listenTo(t,"all",this.triggerMethod),this.initialize.apply(this,arguments)};Ve.extend=r,i.extend(Ve.prototype,T,N,Q,te,{cidPrefix:"mnb",initialize:function(){},$:function(){return this.view.$.apply(this.view,arguments)},destroy:function(){return this.stopListening(),this.view._removeBehavior(this),this._deleteEntityEventHandlers(),this},proxyViewProperties:function(){return this.$el=this.view.$el,this.el=this.view.el,this},bindUIElements:function(){return this._bindUIElements(),this},unbindUIElements:function(){return this._unbindUIElements(),this},getUI:function(e){return this._getUI(e)},delegateEntityEvents:function(){return this._delegateEntityEvents(this.view.model,this.view.collection),this},undelegateEntityEvents:function(){return this._undelegateEntityEvents(this.view.model,this.view.collection),this},_getEvents:function(){var e=this;if(this.events){var t=this.normalizeUIKeys(i.result(this,"events"));return i.reduce(t,function(t,n,s){return i.isFunction(n)||(n=e[n]),n?(t[s=Y(s,e.cid)]=n.bind(e),t):t},{})}},_getTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(i.result(this,"triggers"));return this._getViewTriggers(this.view,e)}}});var Ce=["channelName","radioEvents","radioRequests","region","regionClass"],be=function(e){this._setOptions(e,Ce),this.cid=i.uniqueId(this.cidPrefix),this._initRegion(),this._initRadio(),this.initialize.apply(this,arguments)};be.extend=r,i.extend(be.prototype,T,z,F,{cidPrefix:"mna",initialize:function(){},start:function(e){return this.triggerMethod("before:start",this,e),this.triggerMethod("start",this,e),this},regionClass:le,_initRegion:function(){var e=this.region;if(e){var t={regionClass:this.regionClass};this._region=ae(e,t)}},getRegion:function(){return this._region},showView:function(e){for(var t=this.getRegion(),i=arguments.length,n=new Array(i>1?i-1:0),s=1;s1?i-1:0),s=1;s1?i-1:0),h=1;h1&&void 0!==arguments[1]?arguments[1]:ie(e)).detach()},replaceEl:function(e,t){if(e!==t){var i=t.parentNode;i&&i.replaceChild(e,t)}},swapEl:function(e,t){if(e!==t){var i=e.parentNode,n=t.parentNode;if(i&&n){var s=e.nextSibling,r=t.nextSibling;i.insertBefore(t,s),n.insertBefore(e,r)}}},setContents:function(e,t){(arguments.length>2&&void 0!==arguments[2]?arguments[2]:ie(e)).html(t)},appendContents:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i._$el,s=void 0===n?ie(e):n,r=i._$contents,o=void 0===r?ie(t):r;s.append(o)},hasContents:function(e){return!!e&&e.hasChildNodes()},detachContents:function(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:ie(e)).contents().detach()}},re={Dom:se,_isElAttached:function(){return!!this.el&&this.Dom.hasEl(this.Dom.getDocumentEl(this.el),this.el)},supportsRenderLifecycle:!0,supportsDestroyLifecycle:!0,_isDestroyed:!1,isDestroyed:function(){return!!this._isDestroyed},_isRendered:!1,isRendered:function(){return!!this._isRendered},_isAttached:!1,isAttached:function(){return!!this._isAttached},delegateEvents:function(e){this._proxyBehaviorViewProperties(),this._buildEventProxies();var n=i.extend({},this._getBehaviorEvents(),this._getEvents(e),this._getBehaviorTriggers(),this._getTriggers());return t.View.prototype.delegateEvents.call(this,n),this},_getEvents:function(e){return e?this.normalizeUIKeys(e):this.events?this.normalizeUIKeys(i.result(this,"events")):void 0},_getTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(i.result(this,"triggers"));return this._getViewTriggers(this,e)}},delegateEntityEvents:function(){return this._delegateEntityEvents(this.model,this.collection),this._delegateBehaviorEntityEvents(),this},undelegateEntityEvents:function(){return this._undelegateEntityEvents(this.model,this.collection),this._undelegateBehaviorEntityEvents(),this},destroy:function(e){if(this._isDestroyed||this._isDestroying)return this;this._isDestroying=!0;var t=this._isAttached&&!this._disableDetachEvents;return this.triggerMethod("before:destroy",this,e),t&&this.triggerMethod("before:detach",this),this.unbindUIElements(),this._removeElement(),t&&(this._isAttached=!1,this.triggerMethod("detach",this)),this._removeChildren(),this._isDestroyed=!0,this._isRendered=!1,this._destroyBehaviors(e),this._deleteEntityEventHandlers(),this.triggerMethod("destroy",this,e),this._triggerEventOnBehaviors("destroy",this,e),this.stopListening(),this},_removeElement:function(){this.$el.off().removeData(),this.Dom.detachEl(this.el,this.$el)},bindUIElements:function(){return this._bindUIElements(),this._bindBehaviorUIElements(),this},unbindUIElements:function(){return this._unbindUIElements(),this._unbindBehaviorUIElements(),this},getUI:function(e){return this._getUI(e)},_buildEventProxies:function(){this._childViewEvents=this.normalizeMethods(i.result(this,"childViewEvents")),this._childViewTriggers=i.result(this,"childViewTriggers"),this._eventPrefix=this._getEventPrefix()},_getEventPrefix:function(){var e=!!G("childViewEventPrefix")&&"childview",t=i.result(this,"childViewEventPrefix",e);return!1===t?t:t+":"},_proxyChildViewEvents:function(e){(this._childViewEvents||this._childViewTriggers||this._eventPrefix)&&this.listenTo(e,"all",this._childViewEventHandler)},_childViewEventHandler:function(e){for(var t=this._childViewEvents,i=arguments.length,n=new Array(i>1?i-1:0),s=1;s1&&(this.$el=this.Dom.getEl(this.el))},_setElement:function(e){if(e===this.el)return this;var t=this._isReplaced;if(this._restoreEl(),this.el=e,this._setEl(),this.currentView){var i=this.currentView;t?this._replaceEl(i):this.attachHtml(i)}return this},_setupChildView:function(e){I(e),this._proxyChildViewEvents(e),e.on("destroy",this._empty,this)},_proxyChildViewEvents:function(e){var t=this._parentView;t&&t._proxyChildViewEvents(e)},_shouldDisableMonitoring:function(){return this._parentView&&!1===this._parentView.monitorViewEvents},_isElAttached:function(){return this.Dom.hasEl(this.Dom.getDocumentEl(this.el),this.el)},_attachView:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).replaceElement,n=!e._isAttached&&this._isElAttached()&&!this._shouldDisableMonitoring(),s=void 0===t?!!i.result(this,"replaceElement"):!!t;n&&e.triggerMethod("before:attach",e),s?this._replaceEl(e):this.attachHtml(e),n&&(e._isAttached=!0,e.triggerMethod("attach",e)),e._isShown=!0},_ensureElement:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(i.isObject(this.el)||this._setEl(),!this.$el||0===this.$el.length){if(void 0===e.allowMissingEl?!!i.result(this,"allowMissingEl"):!!e.allowMissingEl)return!1;throw new d({name:"RegionError",message:'An "el" must exist in DOM for this region '.concat(this.cid),url:"marionette.region.html#additional-options"})}return!0},_getView:function(e){if(!e)throw new d({name:"RegionError",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show.",url:"marionette.region.html#showing-a-view"});if(e._isDestroyed)throw new d({name:"RegionError",message:'View (cid: "'.concat(e.cid,'") has already been destroyed and cannot be used.'),url:"marionette.region.html#showing-a-view"});if(e instanceof t.View)return e;var i=this._getViewOptions(e);return new ve(i)},_getViewOptions:function(e){if(i.isFunction(e))return{template:e};if(i.isObject(e))return e;return{template:function(){return e}}},getEl:function(e){var t=i.result(this,"parentEl");return t&&i.isString(e)?this.Dom.findEl(t,e):this.Dom.getEl(e)},_replaceEl:function(e){this._restoreEl(),e.on("before:destroy",this._restoreEl,this),this.Dom.replaceEl(e.el,this.el),this._isReplaced=!0},_restoreEl:function(){if(this._isReplaced){var e=this.currentView;e&&(this._detachView(e),this._isReplaced=!1)}},isReplaced:function(){return!!this._isReplaced},isSwappingView:function(){return!!this._isSwappingView},attachHtml:function(e){this.Dom.appendContents(this.el,e.el,{_$el:this.$el,_$contents:e.$el})},empty:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{allowMissingEl:!0},t=this.currentView;return t?(this._empty(t,!0),this):(this._ensureElement(e)&&this.detachHtml(),this)},_empty:function(e,t){e.off("destroy",this._empty,this),this.triggerMethod("before:empty",this,e),this._restoreEl(),delete this.currentView,e._isDestroyed||(t?this.removeView(e):this._detachView(e),e._isShown=!1,this._stopChildViewEvents(e)),this.triggerMethod("empty",this,e)},_stopChildViewEvents:function(e){this._parentView&&this._parentView.stopListening(e)},destroyView:function(e){return e._isDestroyed?e:(he(e,this._shouldDisableMonitoring()),e)},removeView:function(e){this.destroyView(e)},detachView:function(){var e=this.currentView;if(e)return this._empty(e),e},_detachView:function(e){var t=e._isAttached&&!this._shouldDisableMonitoring(),i=this._isReplaced;t&&e.triggerMethod("before:detach",e),i?this.Dom.replaceEl(this.el,e.el):this.detachHtml(),t&&(e._isAttached=!1,e.triggerMethod("detach",e))},detachHtml:function(){this.Dom.detachContents(this.el,this.$el)},hasView:function(){return!!this.currentView},reset:function(e){return this.empty(e),this.el=this._initEl,delete this.$el,this},_isDestroyed:!1,isDestroyed:function(){return this._isDestroyed},destroy:function(e){return this._isDestroyed?this:(this.triggerMethod("before:destroy",this,e),this._isDestroyed=!0,this.reset(e),this._name&&this._parentView._removeReferences(this._name),delete this._parentView,delete this._name,this.triggerMethod("destroy",this,e),this.stopListening(),this)}});var ue={regionClass:le,_initRegions:function(){this.regions=this.regions||{},this._regions={},this.addRegions(i.result(this,"regions"))},_reInitRegions:function(){H(this._regions,"reset")},addRegion:function(e,t){var i={};return i[e]=t,this.addRegions(i)[e]},addRegions:function(e){if(!i.isEmpty(e))return e=this.normalizeUIValues(e,"el"),this.regions=i.extend({},this.regions,e),this._addRegions(e)},_addRegions:function(e){var t=this,n={regionClass:this.regionClass,parentEl:i.partial(i.result,this,"el")};return i.reduce(e,function(e,i,s){return e[s]=ae(i,n),t._addRegion(e[s],s),e},{})},_addRegion:function(e,t){this.triggerMethod("before:add:region",this,t,e),e._parentView=this,e._name=t,this._regions[t]=e,this.triggerMethod("add:region",this,t,e)},removeRegion:function(e){var t=this._regions[e];return this._removeRegion(t,e),t},removeRegions:function(){var e=this._getRegions();return i.each(this._regions,this._removeRegion.bind(this)),e},_removeRegion:function(e,t){this.triggerMethod("before:remove:region",this,t,e),e.destroy(),this.triggerMethod("remove:region",this,t,e)},_removeReferences:function(e){delete this.regions[e],delete this._regions[e]},emptyRegions:function(){var e=this.getRegions();return H(e,"empty"),e},hasRegion:function(e){return!!this.getRegion(e)},getRegion:function(e){return this._isRendered||this.render(),this._regions[e]},_getRegions:function(){return i.clone(this._regions)},getRegions:function(){return this._isRendered||this.render(),this._getRegions()},showChildView:function(e,t,i){return this.getRegion(e).show(t,i),t},detachChildView:function(e){return this.getRegion(e).detachView()},getChildView:function(e){return this.getRegion(e).currentView}};function ge(e){return this.prototype._renderHtml=e,this}var _e=["behaviors","childViewEventPrefix","childViewEvents","childViewTriggers","collectionEvents","events","modelEvents","regionClass","regions","template","templateContext","triggers","ui"];function fe(e,t){return t.currentView&&e.push(t.currentView),e}var ve=t.View.extend({constructor:function(e){this._setOptions(e,_e),I(this),this._initBehaviors(),this._initRegions(),t.View.prototype.constructor.apply(this,arguments),this.delegateEntityEvents(),this._triggerEventOnBehaviors("initialize",this,e)},setElement:function(){return t.View.prototype.setElement.apply(this,arguments),this._isRendered=this.Dom.hasContents(this.el),this._isAttached=this._isElAttached(),this._isRendered&&this.bindUIElements(),this},render:function(){var e=this.getTemplate();return!1===e||this._isDestroyed?this:(this.triggerMethod("before:render",this),this._isRendered&&this._reInitRegions(),this._renderTemplate(e),this.bindUIElements(),this._isRendered=!0,this.triggerMethod("render",this),this)},_removeChildren:function(){this.removeRegions()},_getImmediateChildren:function(){return i.reduce(this._regions,fe,[])}},{setRenderer:ge,setDomApi:ne});i.extend(ve.prototype,re,ue);var me=function(){this._init()};function pe(e,t){return t.model&&t.model.get(e)}i.each(["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce","partition"],function(e){me.prototype[e]=function(){for(var t=arguments.length,n=new Array(t),s=0;s1&&void 0!==arguments[1]?arguments[1]:this._views.length;this._addViewIndexes(e),this._views.splice(t,0,e),this._updateLength()},_addViewIndexes:function(e){this._viewsByCid[e.cid]=e,e.model&&(this._indexByModel[e.model.cid]=e)},_sort:function(e,t){return"string"==typeof e?(e=i.partial(pe,e),this._sortBy(e)):1===e.length?this._sortBy(e.bind(t)):this._views.sort(e.bind(t))},_sortBy:function(e){var t=i.sortBy(this._views,e);return this._set(t),t},_set:function(e,t){this._views.length=0,this._views.push.apply(this._views,e.slice(0)),t&&(this._viewsByCid={},this._indexByModel={},i.each(e,this._addViewIndexes.bind(this)),this._updateLength())},_swap:function(e,t){var i=this.findIndexByView(e),n=this.findIndexByView(t);if(-1!==i&&-1!==n){var s=this._views[i];this._views[i]=this._views[n],this._views[n]=s}},findByModel:function(e){return this.findByModelCid(e.cid)},findByModelCid:function(e){return this._indexByModel[e]},findByIndex:function(e){return this._views[e]},findIndexByView:function(e){return this._views.indexOf(e)},findByCid:function(e){return this._viewsByCid[e]},hasView:function(e){return!!this.findByCid(e.cid)},_remove:function(e){if(this._viewsByCid[e.cid]){e.model&&delete this._indexByModel[e.model.cid],delete this._viewsByCid[e.cid];var t=this.findIndexByView(e);this._views.splice(t,1),this._updateLength()}},_updateLength:function(){this.length=this._views.length}});var we=["behaviors","childView","childViewContainer","childViewEventPrefix","childViewEvents","childViewOptions","childViewTriggers","collectionEvents","emptyView","emptyViewOptions","events","modelEvents","sortWithCollection","template","templateContext","triggers","ui","viewComparator","viewFilter"],Ee=t.View.extend({sortWithCollection:!0,constructor:function(e){this._setOptions(e,we),I(this),this._initChildViewStorage(),this._initBehaviors(),t.View.prototype.constructor.apply(this,arguments),this.getEmptyRegion(),this.delegateEntityEvents(),this._triggerEventOnBehaviors("initialize",this,e)},_initChildViewStorage:function(){this._children=new me,this.children=new me},getEmptyRegion:function(){var e=this.$container||this.$el;return this._emptyRegion&&!this._emptyRegion.isDestroyed()?(this._emptyRegion._setElement(e[0]),this._emptyRegion):(this._emptyRegion=new le({el:e[0],replaceElement:!1}),this._emptyRegion._parentView=this,this._emptyRegion)},_initialEvents:function(){this._isRendered||this.listenTo(this.collection,{sort:this._onCollectionSort,reset:this._onCollectionReset,update:this._onCollectionUpdate})},_onCollectionSort:function(e,t){var i=t.add,n=t.merge,s=t.remove;this.sortWithCollection&&!1!==this.viewComparator&&(i||s||n||this.sort())},_onCollectionReset:function(){this._destroyChildren(),this._addChildModels(this.collection.models),this.sort()},_onCollectionUpdate:function(e,t){var i=t.changes,n=i.removed.length&&this._removeChildModels(i.removed);this._addedViews=i.added.length&&this._addChildModels(i.added),this._detachChildren(n),this.sort(),this._removeChildViews(n)},_removeChildModels:function(e){var t=this;return i.reduce(e,function(e,i){var n=t._removeChildModel(i);return n&&e.push(n),e},[])},_removeChildModel:function(e){var t=this._children.findByModel(e);return t&&this._removeChild(t),t},_removeChild:function(e){this.triggerMethod("before:remove:child",this,e),this.children._remove(e),this._children._remove(e),this.triggerMethod("remove:child",this,e)},_addChildModels:function(e){return i.map(e,this._addChildModel.bind(this))},_addChildModel:function(e){var t=this._createChildView(e);return this._addChild(t),t},_createChildView:function(e){var t=this._getChildView(e),i=this._getChildViewOptions(e);return this.buildChildView(e,t,i)},_addChild:function(e,t){this.triggerMethod("before:add:child",this,e),this._setupChildView(e),this._children._add(e,t),this.children._add(e,t),this.triggerMethod("add:child",this,e)},_getChildView:function(e){var t=this.childView;if(!t)throw new d({name:"CollectionViewError",message:'A "childView" must be specified',url:"marionette.collectionview.html#collectionviews-childview"});if(!(t=this._getView(t,e)))throw new d({name:"CollectionViewError",message:'"childView" must be a view class or a function that returns a view class',url:"marionette.collectionview.html#collectionviews-childview"});return t},_getView:function(e,n){return e.prototype instanceof t.View||e===t.View?e:i.isFunction(e)?e.call(this,n):void 0},_getChildViewOptions:function(e){return i.isFunction(this.childViewOptions)?this.childViewOptions(e):this.childViewOptions},buildChildView:function(e,t,n){return new t(i.extend({model:e},n))},_setupChildView:function(e){I(e),e.on("destroy",this.removeChildView,this),this._proxyChildViewEvents(e)},_getImmediateChildren:function(){return this.children._views},setElement:function(){return t.View.prototype.setElement.apply(this,arguments),this._isAttached=this._isElAttached(),this},render:function(){if(this._isDestroyed)return this;this.triggerMethod("before:render",this),this._destroyChildren(),this.collection&&(this._addChildModels(this.collection.models),this._initialEvents());var e=this.getTemplate();return e&&(this._renderTemplate(e),this.bindUIElements()),this._getChildViewContainer(),this.sort(),this._isRendered=!0,this.triggerMethod("render",this),this},_getChildViewContainer:function(){var e=i.result(this,"childViewContainer");if(this.$container=e?this.$(e):this.$el,!this.$container.length)throw new d({name:"CollectionViewError",message:'The specified "childViewContainer" was not found: '.concat(e),url:"marionette.collectionview.html#defining-the-childviewcontainer"})},sort:function(){return this._sortChildren(),this.filter(),this},_sortChildren:function(){if(this._children.length){var e=this.getComparator();e&&(delete this._addedViews,this.triggerMethod("before:sort",this),this._children._sort(e,this),this.triggerMethod("sort",this))}},setComparator:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).preventRender,i=this.viewComparator!==e&&!t;return this.viewComparator=e,i&&this.sort(),this},removeComparator:function(e){return this.setComparator(null,e)},getComparator:function(){return this.viewComparator?this.viewComparator:!(!this.sortWithCollection||!1===this.viewComparator||!this.collection)&&this._viewComparator},_viewComparator:function(e){return this.collection.indexOf(e.model)},filter:function(){return this._isDestroyed?this:(this._filterChildren(),this._renderChildren(),this)},_filterChildren:function(){var e=this;if(this._children.length){var t=this._getFilter();if(t){delete this._addedViews,this.triggerMethod("before:filter",this);var n=[],s=[];i.each(this._children._views,function(i,r,o){(t.call(e,i,r,o)?n:s).push(i)}),this._detachChildren(s),this.children._set(n,!0),this.triggerMethod("filter",this,n,s)}else{var r=this.children.length!==this._children.length;this.children._set(this._children._views,r)}}},_getFilter:function(){var e=this.getFilter();if(!e)return!1;if(i.isFunction(e))return e;if(i.isObject(e)){var t=i.matches(e);return function(e){return t(e.model&&e.model.attributes)}}if(i.isString(e))return function(t){return t.model&&t.model.get(e)};throw new d({name:"CollectionViewError",message:'"viewFilter" must be a function, predicate object literal, a string indicating a model attribute, or falsy',url:"marionette.collectionview.html#defining-the-viewfilter"})},getFilter:function(){return this.viewFilter},setFilter:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).preventRender,i=this.viewFilter!==e&&!t;return this.viewFilter=e,i&&this.filter(),this},removeFilter:function(e){return this.setFilter(null,e)},_detachChildren:function(e){i.each(e,this._detachChildView.bind(this))},_detachChildView:function(e){var t=e._isAttached&&!1!==this.monitorViewEvents;t&&e.triggerMethod("before:detach",e),this.detachHtml(e),t&&(e._isAttached=!1,e.triggerMethod("detach",e)),e._isShown=!1},detachHtml:function(e){this.Dom.detachEl(e.el,e.$el)},_renderChildren:function(){this._hasUnrenderedViews&&(delete this._addedViews,delete this._hasUnrenderedViews);var e=this._addedViews||this.children._views;if(this.triggerMethod("before:render:children",this,e),this.isEmpty())this._showEmptyView();else{this._destroyEmptyView();var t=this._getBuffer(e);this._attachChildren(t,e)}delete this._addedViews,this.triggerMethod("render:children",this,e)},_getBuffer:function(e){var t=this,n=this.Dom.createBuffer();return i.each(e,function(e){oe(e),e._isShown=!0,t.Dom.appendContents(n,e.el,{_$contents:e.$el})}),n},_attachChildren:function(e,t){t=this._isAttached&&!1!==this.monitorViewEvents?t:[],i.each(t,function(e){e._isAttached||e.triggerMethod("before:attach",e)}),this.attachHtml(e,this.$container),i.each(t,function(e){e._isAttached||(e._isAttached=!0,e.triggerMethod("attach",e))})},attachHtml:function(e,t){this.Dom.appendContents(t[0],e,{_$el:t})},isEmpty:function(){return!this.children.length},_showEmptyView:function(){var e=this._getEmptyView();if(e){var t=this._getEmptyViewOptions();this.getEmptyRegion().show(new e(t))}},_getEmptyView:function(){var e=this.emptyView;if(e)return this._getView(e)},_destroyEmptyView:function(){var e=this.getEmptyRegion();e.hasView()&&e.empty()},_getEmptyViewOptions:function(){var e=this.emptyViewOptions||this.childViewOptions;return i.isFunction(e)?e.call(this):e},swapChildViews:function(e,t){if(!this._children.hasView(e)||!this._children.hasView(t))throw new d({name:"CollectionViewError",message:"Both views must be children of the collection view to swap.",url:"marionette.collectionview.html#swapping-child-views"});return this._children._swap(e,t),this.Dom.swapEl(e.el,t.el),this.children.hasView(e)!==this.children.hasView(t)?this.filter():this.children._swap(e,t),this},addChildView:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||e._isDestroyed)return e;if(e._isShown)throw new d({name:"CollectionViewError",message:"View is already shown in a Region or CollectionView",url:"marionette.region.html#showing-a-view"});if(i.isObject(t)&&(n=t),null!=n.index&&(t=n.index),this._isRendered||this.render(),this._addChild(e,t),n.preventRender)return this._hasUnrenderedViews=!0,e;var s=void 0!==t;return(!s||t>=this._children.length)&&!this._hasUnrenderedViews&&(this._addedViews=[e]),s?this._renderChildren():this.sort(),e},detachChildView:function(e){return this.removeChildView(e,{shouldDetach:!0}),e},removeChildView:function(e,t){return e?(this._removeChildView(e,t),this._removeChild(e),this.isEmpty()&&this._showEmptyView(),e):e},_removeChildViews:function(e){i.each(e,this._removeChildView.bind(this))},_removeChildView:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).shouldDetach;e.off("destroy",this.removeChildView,this),t?this._detachChildView(e):this._destroyChildView(e),this.stopListening(e)},_destroyChildView:function(e){e._isDestroyed||he(e,!1===this.monitorViewEvents)},_removeChildren:function(){this._destroyChildren(),this.getEmptyRegion().destroy(),delete this._addedViews},_destroyChildren:function(){this._children.length&&(this.triggerMethod("before:destroy:children",this),!1===this.monitorViewEvents&&this.Dom.detachContents(this.el,this.$el),this._removeChildViews(this._children._views),this._children._init(),this.children._init(),this.triggerMethod("destroy:children",this))}},{setDomApi:ne,setRenderer:ge});i.extend(Ee.prototype,re);var ye=["collectionEvents","events","modelEvents","triggers","ui"],Ve=function(e,t){this.view=t,this._setOptions(e,ye),this.cid=i.uniqueId(this.cidPrefix),this.ui=i.extend({},i.result(this,"ui"),i.result(t,"ui")),this.listenTo(t,"all",this.triggerMethod),this.initialize.apply(this,arguments)};Ve.extend=r,i.extend(Ve.prototype,T,N,Q,te,{cidPrefix:"mnb",initialize:function(){},$:function(){return this.view.$.apply(this.view,arguments)},destroy:function(){return this.stopListening(),this.view._removeBehavior(this),this._deleteEntityEventHandlers(),this},proxyViewProperties:function(){return this.$el=this.view.$el,this.el=this.view.el,this},bindUIElements:function(){return this._bindUIElements(),this},unbindUIElements:function(){return this._unbindUIElements(),this},getUI:function(e){return this._getUI(e)},delegateEntityEvents:function(){return this._delegateEntityEvents(this.view.model,this.view.collection),this},undelegateEntityEvents:function(){return this._undelegateEntityEvents(this.view.model,this.view.collection),this},_getEvents:function(){var e=this;if(this.events){var t=this.normalizeUIKeys(i.result(this,"events"));return i.reduce(t,function(t,n,s){return i.isFunction(n)||(n=e[n]),n?(t[s=Y(s,e.cid)]=n.bind(e),t):t},{})}},_getTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(i.result(this,"triggers"));return this._getViewTriggers(this.view,e)}}});var Ce=["channelName","radioEvents","radioRequests","region","regionClass"],be=function(e){this._setOptions(e,Ce),this.cid=i.uniqueId(this.cidPrefix),this._initRegion(),this._initRadio(),this.initialize.apply(this,arguments)};be.extend=r,i.extend(be.prototype,T,z,F,{cidPrefix:"mna",initialize:function(){},start:function(e){return this.triggerMethod("before:start",this,e),this.triggerMethod("start",this,e),this},regionClass:le,_initRegion:function(){var e=this.region;if(e){var t={regionClass:this.regionClass};this._region=ae(e,t)}},getRegion:function(){return this._region},showView:function(e){for(var t=this.getRegion(),i=arguments.length,n=new Array(i>1?i-1:0),s=1;s