yano-backbone-rails 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/yano/backbone/rails/version.rb +2 -2
- data/vendor/assets/javascripts/marionette/backbone.marionette.js +419 -329
- data/vendor/assets/javascripts/marionette/backbone.marionette.min.js.erb +3 -3
- data/vendor/assets/source_maps/backbone.marionette.min.js.map +1 -1
- metadata +1 -1
@@ -1,11 +1,11 @@
|
|
1
1
|
// MarionetteJS (Backbone.Marionette)
|
2
2
|
// ----------------------------------
|
3
|
-
// v3.
|
3
|
+
// v3.1.0
|
4
4
|
//
|
5
5
|
// Copyright (c)2016 Derick Bailey, Muted Solutions, LLC.
|
6
6
|
// Distributed under MIT license
|
7
7
|
//
|
8
8
|
// http://marionettejs.com
|
9
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("backbone"),require("underscore"),require("backbone.radio")):"function"==typeof define&&define.amd?define(["backbone","underscore","backbone.radio"],t):e.Marionette=e.Mn=t(e.Backbone,e._,e.Backbone.Radio)}(this,function(e,t,i){"use strict";function n(e,t,i){return i.toUpperCase()}function r(e){for(var i="on"+e.replace(k,n),r=D.call(this,i),s=void 0,o=arguments.length,h=Array(o>1?o-1:0),d=1;d<o;d++)h[d-1]=arguments[d];return t.isFunction(r)&&(s=r.apply(this,h)),this.trigger.apply(this,[e].concat(h)),s}function s(e){for(var i=t.isFunction(e.triggerMethod)?e.triggerMethod:r,n=arguments.length,s=Array(n>1?n-1:0),o=1;o<n;o++)s[o-1]=arguments[o];return i.apply(e,s)}function o(e,i,n){e._getImmediateChildren&&t.each(e._getImmediateChildren(),function(e){n(e)&&s(e,i,e)})}function h(e){return!e._isAttached}function d(e){return!!h(e)&&(e._isAttached=!0,!0)}function a(e){return e._isAttached}function l(e){return!!a(e)&&(e._isAttached=!1,!0)}function c(e){function t(){o(e,"before:attach",h)}function i(){o(e,"attach",d),u()}function n(){o(e,"before:detach",a)}function r(){o(e,"detach",l)}function c(){u()}function u(){e._isAttached&&e._isRendered&&s(e,"dom:refresh",e)}e._areViewEventsMonitored||(e._areViewEventsMonitored=!0,e.on({"before:attach":t,attach:i,"before:detach":n,detach:r,render:c}))}function u(e,i,n,r,s){var o=r.split(/\s+/);t.each(o,function(t){var r=e[t];if(!r)throw new F('Method "'+t+'" was configured as an event handler, but does not exist.');e[s](i,n,r)})}function f(e,i,n,r){if(i&&n){if(!t.isObject(n))throw new F({message:"Bindings must be an object.",url:"marionette.functions.html#marionettebindevents"});t.each(n,function(n,s){return t.isString(n)?void u(e,i,s,n,r):void e[r](i,s,n)})}}function g(e,t){return f(this,e,t,"listenTo"),this}function p(e,t){return f(this,e,t,"stopListening"),this}function v(e,i,n,r){if(i&&n){if(!t.isObject(n))throw new F({message:"Bindings must be an object.",url:"marionette.functions.html#marionettebindrequests"});var s=U.call(e,n);i[r](s,e)}}function _(e,t){return v(this,e,t,"reply"),this}function m(e,t){return v(this,e,t,"stopReplying"),this}function y(e,i){return e.behaviorClass?e.behaviorClass:t.isFunction(e)?e:t.isFunction(Ce.Behaviors.behaviorsLookup)?Ce.Behaviors.behaviorsLookup(e,i)[i]:Ce.Behaviors.behaviorsLookup[i]}function w(e,i){return t.chain(i).map(function(i,n){var r=y(i,n),s=i===r?{}:i,o=new r(s,e),h=w(e,t.result(o,"behaviors"));return[o].concat(h)}).flatten().value()}function E(e,i){return[e+t.uniqueId(".evt"),i].join(" ")}function b(e,i){t.isString(i)&&(i={event:i});var n=i.event,r=i.preventDefault!==!1,s=i.stopPropagation!==!1;return function(t){r&&t.preventDefault(),s&&t.stopPropagation(),e.triggerMethod(n,e)}}function V(e){e.supportsDestroyLifecycle||s(e,"before:destroy",e);var t=!!e._isAttached;t&&s(e,"before:detach",e),e.remove(),t&&(e._isAttached=!1,s(e,"detach",e)),e._isDestroyed=!0,e.supportsDestroyLifecycle||s(e,"destroy",e)}function C(){throw new F({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.md#behaviorslookup"})}function R(e){return!!be[e]}function M(e,t){return be[e]=t}e="default"in e?e.default:e,t="default"in t?t.default:t,i="default"in i?i.default:i;var x="3.0.0",B=function(e){return function(t){for(var i=arguments.length,n=Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return e.apply(t,n)}},I=e.Model.extend,A=function e(i,n){t.isObject(i)&&(i=i.prev+" is going to be removed in the future. Please use "+i.next+" instead."+(i.url?" See: "+i.url:"")),Ce.DEV_MODE&&(void 0!==n&&n||e._cache[i]||(e._warn("Deprecation warning: "+i),e._cache[i]=!0))};A._console="undefined"!=typeof console?console:{},A._warn=function(){var e=A._console.warn||A._console.log||t.noop;return e.apply(A._console,arguments)},A._cache={};var O=function(t){return e.$.contains(document.documentElement,t)},T=function(e,i){e&&t.extend(this,t.pick(e,i))},D=function(e){if(e)return this.options&&void 0!==this.options[e]?this.options[e]:this[e]},U=function(e){var i=this;return t.reduce(e,function(e,n,r){return t.isFunction(n)||(n=i[n]),n&&(e[r]=n),e},{})},k=/(^|:)(\w)/gi,$=["description","fileName","lineNumber","name","message","number"],F=I.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+x+"/",constructor:function(e,i){t.isObject(e)?(i=e,e=i.message):i||(i={});var n=Error.call(this,e);t.extend(this,t.pick(n,$),t.pick(i,$)),this.captureStackTrace(),i.url&&(this.url=this.urlRoot+i.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,F)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}});F.extend=I;var S=function(){for(var e=arguments.length,i=Array(e),n=0;n<e;n++)i[n]=arguments[n];this.options=t.extend.apply(t,[{},t.result(this,"options")].concat(i))},z={normalizeMethods:U,_setOptions:S,mergeOptions:T,getOption:D,bindEvents:g,unbindEvents:p},L={_initRadio:function(){var e=t.result(this,"channelName");if(e){if(!i)throw new F({name:"BackboneRadioMissing",message:'The dependency "backbone.radio" is missing.'});var n=this._channel=i.channel(e),r=t.result(this,"radioEvents");this.bindEvents(n,r);var s=t.result(this,"radioRequests");this.bindRequests(n,s),this.on("destroy",this._destroyRadio)}},_destroyRadio:function(){this._channel.stopReplying(null,null,this)},getChannel:function(){return this._channel},bindEvents:g,unbindEvents:p,bindRequests:_,unbindRequests:m},P=["channelName","radioEvents","radioRequests"],j=function(e){this._setOptions(e),this.mergeOptions(e,P),this.cid=t.uniqueId(this.cidPrefix),this._initRadio(),this.initialize.apply(this,arguments)};j.extend=I,t.extend(j.prototype,e.Events,z,L,{cidPrefix:"mno",_isDestroyed:!1,isDestroyed:function(){return this._isDestroyed},initialize:function(){},destroy:function(){if(this._isDestroyed)return this;for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.triggerMethod.apply(this,["before:destroy",this].concat(t)),this._isDestroyed=!0,this.triggerMethod.apply(this,["destroy",this].concat(t)),this.stopListening(),this},triggerMethod:r});var q=function(e){this.templateId=e};t.extend(q,{templateCaches:{},get:function(e,t){var i=this.templateCaches[e];return i||(i=new q(e),this.templateCaches[e]=i),i.load(t)},clear:function(){for(var e=void 0,t=arguments.length,i=Array(t),n=0;n<t;n++)i[n]=arguments[n];var r=i.length;if(r>0)for(e=0;e<r;e++)delete this.templateCaches[i[e]];else this.templateCaches={}}}),t.extend(q.prototype,{load:function(e){if(this.compiledTemplate)return this.compiledTemplate;var t=this.loadTemplate(this.templateId,e);return this.compiledTemplate=this.compileTemplate(t,e),this.compiledTemplate},loadTemplate:function(t,i){var n=e.$(t);if(!n.length)throw new F({name:"NoTemplateError",message:'Could not find template: "'+t+'"'});return n.html()},compileTemplate:function(e,i){return t.template(e,i)}});var N=t.invokeMap||t.invoke,H=function(e){if(Array.isArray(e)){for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}return Array.from(e)},K={_initBehaviors:function(){var e=t.result(this,"behaviors");this._behaviors=t.isObject(e)?w(this,e):{}},_getBehaviorTriggers:function(){var e=N(this._behaviors,"getTriggers");return t.extend.apply(t,[{}].concat(H(e)))},_getBehaviorEvents:function(){var e=N(this._behaviors,"getEvents");return t.extend.apply(t,[{}].concat(H(e)))},_proxyBehaviorViewProperties:function(){N(this._behaviors,"proxyViewProperties")},_delegateBehaviorEntityEvents:function(){N(this._behaviors,"delegateEntityEvents")},_undelegateBehaviorEntityEvents:function(){N(this._behaviors,"undelegateEntityEvents")},_destroyBehaviors:function(e){N.apply(void 0,[this._behaviors,"destroy"].concat(H(e)))},_bindBehaviorUIElements:function(){N(this._behaviors,"bindUIElements")},_unbindBehaviorUIElements:function(){N(this._behaviors,"unbindUIElements")},_triggerEventOnBehaviors:function(){for(var e=this._behaviors,t=arguments.length,i=Array(t),n=0;n<t;n++)i[n]=arguments[n];for(var s=0,o=e&&e.length;s<o;s++)r.apply(e[s],i)}},Y={_delegateEntityEvents:function(e,i){this._undelegateEntityEvents(e,i);var n=t.result(this,"modelEvents");g.call(this,e,n);var r=t.result(this,"collectionEvents");g.call(this,i,r)},_undelegateEntityEvents:function(e,i){var n=t.result(this,"modelEvents");p.call(this,e,n);var r=t.result(this,"collectionEvents");p.call(this,i,r)}},Z=/^(\S+)\s*(.*)$/,G=function(e){var t=e.match(Z);return E(t[1],t[2])},J={_getViewTriggers:function(e,i){return t.reduce(i,function(t,i,n){return n=G(n),t[n]=b(e,i),t},{})}},Q=function(e,i){return t.reduce(e,function(e,t,n){var r=W(n,i);return e[r]=t,e},{})},W=function(e,t){return e.replace(/@ui\.[a-zA-Z-_$0-9]*/g,function(e){return t[e.slice(4)]})},X=function e(i,n,r){return t.each(i,function(s,o){t.isString(s)?i[o]=W(s,n):t.isObject(s)&&t.isArray(r)&&(t.extend(s,e(t.pick(s,r),n)),t.each(r,function(e){var i=s[e];t.isString(i)&&(s[e]=W(i,n))}))}),i},ee={normalizeUIKeys:function(e){var t=this._getUIBindings();return Q(e,t)},normalizeUIValues:function(e,t){var i=this._getUIBindings();return X(e,i,t)},_getUIBindings:function(){var e=t.result(this,"_uiBindings"),i=t.result(this,"ui");return e||i},_bindUIElements:function(){var e=this;if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var i=t.result(this,"_uiBindings");this._ui={},t.each(i,function(t,i){e._ui[i]=e.$(t)}),this.ui=this._ui}},_unbindUIElements:function(){var e=this;this.ui&&this._uiBindings&&(t.each(this.ui,function(t,i){delete e.ui[i]}),this.ui=this._uiBindings,delete this._uiBindings,delete this._ui)},_getUI:function(e){return this._ui[e]}},te={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},setElement:function(){var t=!!this.el;return e.View.prototype.setElement.apply(this,arguments),t&&(this._isRendered=!!this.$el.length,this._isAttached=O(this.el)),this},delegateEvents:function(i){this._proxyBehaviorViewProperties(),this._buildEventProxies();var n=this._getEvents(i);"undefined"==typeof i&&(this.events=n);var r=t.extend({},this._getBehaviorEvents(),n,this._getBehaviorTriggers(),this.getTriggers());return e.View.prototype.delegateEvents.call(this,r),this},_getEvents:function(e){var i=e||this.events;return t.isFunction(i)?this.normalizeUIKeys(i.call(this)):this.normalizeUIKeys(i)},getTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(t.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},_ensureViewIsIntact:function(){if(this._isDestroyed)throw new F({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(this._isDestroyed)return this;for(var e=!!this._isAttached,t=arguments.length,i=Array(t),n=0;n<t;n++)i[n]=arguments[n];return this.triggerMethod.apply(this,["before:destroy",this].concat(i)),e&&this.triggerMethod("before:detach",this),this.unbindUIElements(),this._removeElement(),e&&(this._isAttached=!1,this.triggerMethod("detach",this)),this._removeChildren(),this._destroyBehaviors(i),this._isDestroyed=!0,this._isRendered=!1,this.triggerMethod.apply(this,["destroy",this].concat(i)),this.stopListening(),this},bindUIElements:function(){return this._bindUIElements(),this._bindBehaviorUIElements(),this},unbindUIElements:function(){return this._unbindUIElements(),this._unbindBehaviorUIElements(),this},getUI:function(e){return this._ensureViewIsIntact(),this._getUI(e)},childViewEventPrefix:"childview",triggerMethod:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];var n=r.apply(this,t);return this._triggerEventOnBehaviors.apply(this,t),this._triggerEventOnParentLayout.apply(this,t),n},_buildEventProxies:function(){this._childViewEvents=t.result(this,"childViewEvents"),this._childViewTriggers=t.result(this,"childViewTriggers")},_triggerEventOnParentLayout:function(e){var i=this._parentView();if(i){for(var n=t.result(i,"childViewEventPrefix"),r=n+":"+e,s=arguments.length,o=Array(s>1?s-1:0),h=1;h<s;h++)o[h-1]=arguments[h];i.triggerMethod.apply(i,[r].concat(o));var d=i.normalizeMethods(i._childViewEvents);d&&t.isFunction(d[e])&&d[e].apply(i,o);var a=i._childViewTriggers;a&&t.isString(a[e])&&i.triggerMethod.apply(i,[a[e]].concat(o))}},_parentView:function(){for(var e=this._parent;e;){if(e instanceof he)return e;e=e._parent}}};t.extend(te,K,z,Y,J,ee);var ie=["allowMissingEl","parentEl","replaceElement"],ne=j.extend({cidPrefix:"mnr",replaceElement:!1,_isReplaced:!1,constructor:function(t){if(this._setOptions(t),this.mergeOptions(t,ie),this._initEl=this.el=this.getOption("el"),this.el=this.el instanceof e.$?this.el[0]:this.el,!this.el)throw new F({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),j.call(this,t)},show:function(e,t){if(this._ensureElement(t))return this._ensureView(e),e===this.currentView?this:(this.triggerMethod("before:show",this,e,t),c(e),this.empty(t),e.on("destroy",this.empty,this),e._parent=this,this._renderView(e),this._attachView(e,t),this.triggerMethod("show",this,e,t),this)},_renderView:function(e){e._isRendered||(e.supportsRenderLifecycle||s(e,"before:render",e),e.render(),e.supportsRenderLifecycle||(e._isRendered=!0,s(e,"render",e)))},_attachView:function(e){var i=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=!e._isAttached&&O(this.el),r="undefined"==typeof i.replaceElement?!!t.result(this,"replaceElement"):!!i.replaceElement;n&&s(e,"before:attach",e),this.attachHtml(e,r),n&&(e._isAttached=!0,s(e,"attach",e)),this.currentView=e},_ensureElement:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];if(t.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||0===this.$el.length){var i="undefined"==typeof e.allowMissingEl?!!t.result(this,"allowMissingEl"):!!e.allowMissingEl;if(i)return!1;throw new F('An "el" must exist in DOM for this region '+this.cid)}return!0},_ensureView:function(e){if(!e)throw new F({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(e._isDestroyed)throw new F({name:"ViewDestroyedError",message:'View (cid: "'+e.cid+'") has already been destroyed and cannot be used.'})},getEl:function(i){return e.$(i,t.result(this,"parentEl"))},_replaceEl:function(e){this._restoreEl();var t=this.el.parentNode;t.replaceChild(e.el,this.el),this._isReplaced=!0},_restoreEl:function(){if(this._isReplaced){var e=this.currentView;if(e){var t=e.el.parentNode;t&&(t.replaceChild(this.el,e.el),this._isReplaced=!1)}}},isReplaced:function(){return!!this._isReplaced},attachHtml:function(e,t){t?this._replaceEl(e):this.el.appendChild(e.el)},empty:function(){var e=arguments.length<=0||void 0===arguments[0]?{allowMissingEl:!0}:arguments[0],t=this.currentView;return t?(t.off("destroy",this.empty,this),this.triggerMethod("before:empty",this,t),this._restoreEl(),delete this.currentView,t._isDestroyed||(this._removeView(t,e),delete t._parent),this.triggerMethod("empty",this,t),this):(this._ensureElement(e)&&this.detachHtml(),this)},_removeView:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],i=t.preventDestroy,n=!!i;return n?void this._detachView(e):void(e.destroy?e.destroy():V(e))},_detachView:function(e){var t=!!e._isAttached;t&&s(e,"before:detach",e),this.detachHtml(),t&&(e._isAttached=!1,s(e,"detach",e))},detachHtml:function(){this.$el.contents().detach()},hasView:function(){return!!this.currentView},reset:function(e){return this.empty(e),this.$el&&(this.el=this._initEl),delete this.$el,this},destroy:function(e){return this.reset(e),j.prototype.destroy.apply(this,arguments)}}),re={regionClass:ne,_initRegions:function(){this.regions=this.regions||{},this._regions={},this.addRegions(t.result(this,"regions"))},_reInitRegions:function(){N(this._regions,"reset")},addRegion:function(e,t){var i={};return i[e]=t,this.addRegions(i)[e]},addRegions:function(e){if(!t.isEmpty(e))return e=this.normalizeUIValues(e,["selector","el"]),this.regions=t.extend({},this.regions,e),this._addRegions(e)},_addRegions:function(e){var i=this;return t.reduce(e,function(e,t,n){return e[n]=i._buildRegion(t),i._addRegion(e[n],n),e},{})},_buildRegion:function(e){return e instanceof ne?e:this._buildRegionFromDefinition(e)},_buildRegionFromDefinition:function(e){if(t.isString(e))return this._buildRegionFromObject({el:e});if(t.isFunction(e))return this._buildRegionFromRegionClass(e);if(t.isObject(e))return this._buildRegionFromObject(e);throw new F({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})},_buildRegionFromObject:function(e){var i=e.regionClass||this.regionClass,n=t.omit(e,"regionClass");return t.defaults(n,{el:e.selector,parentEl:t.partial(t.result,this,"el")}),new i(n)},_buildRegionFromRegionClass:function(e){return new e({parentEl:t.partial(t.result,this,"el")})},_addRegion:function(e,t){this.triggerMethod("before:add:region",this,t,e),e._parent=this,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 t.each(this._regions,t.bind(this._removeRegion,this)),e},_removeRegion:function(e,t){this.triggerMethod("before:remove:region",this,t,e),e.empty(),e.stopListening(),delete this.regions[t],delete this._regions[t],this.triggerMethod("remove:region",this,t,e)},emptyRegions:function(){var e=this.getRegions();return N(e,"empty"),e},hasRegion:function(e){return!!this.getRegion(e)},getRegion:function(e){return this._regions[e]},getRegions:function(){return t.clone(this._regions)},showChildView:function(e,t){for(var i=this.getRegion(e),n=arguments.length,r=Array(n>2?n-2:0),s=2;s<n;s++)r[s-2]=arguments[s];return i.show.apply(i,[t].concat(r))},getChildView:function(e){return this.getRegion(e).currentView}},se={render:function(e,i){if(!e)throw new F({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var n=t.isFunction(e)?e:q.get(e);return n(i)}},oe=["behaviors","childViewEventPrefix","childViewEvents","childViewTriggers","collectionEvents","events","modelEvents","regionClass","regions","template","templateContext","triggers","ui"],he=e.View.extend({constructor:function(i){this.render=t.bind(this.render,this),this._setOptions(i),this.mergeOptions(i,oe),c(this),this._initBehaviors(),this._initRegions();var n=Array.prototype.slice.call(arguments);n[0]=this.options,e.View.prototype.constructor.apply(this,n),this.delegateEntityEvents()},serializeData:function(){return this.model||this.collection?this.model?this.serializeModel():{items:this.serializeCollection()}:{}},serializeModel:function(){return this.model?t.clone(this.model.attributes):{}},serializeCollection:function(){return this.collection?this.collection.map(function(e){return t.clone(e.attributes)}):{}},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._isRendered&&this._reInitRegions(),this._renderTemplate(),this.bindUIElements(),this._isRendered=!0,this.triggerMethod("render",this),this},_renderTemplate:function(){var e=this.getTemplate();if(e!==!1){var t=this.mixinTemplateContext(this.serializeData()),i=se.render(e,t,this);this.attachElContent(i)}},getTemplate:function(){return this.template},mixinTemplateContext:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],i=t.result(this,"templateContext");return t.extend(e,i)},attachElContent:function(e){return this.$el.html(e),this},_removeChildren:function(){this.removeRegions()},_getImmediateChildren:function(){return t.chain(this.getRegions()).map("currentView").compact().value()}});t.extend(he.prototype,te,re);var de=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"],ae=function(e,i){t.each(de,function(n){e[n]=function(){var e=t.values(t.result(this,i)),r=[e].concat(t.toArray(arguments));return t[n].apply(t,r)}})},le=function(e){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),t.each(e,t.bind(this.add,this))};ae(le.prototype,"_views"),t.extend(le.prototype,{add:function(e,t){return this._add(e,t)._updateLength()},_add:function(e,t){var i=e.cid;return this._views[i]=e,e.model&&(this._indexByModel[e.model.cid]=i),t&&(this._indexByCustom[t]=i),this},findByModel:function(e){return this.findByModelCid(e.cid)},findByModelCid:function(e){var t=this._indexByModel[e];return this.findByCid(t)},findByCustom:function(e){var t=this._indexByCustom[e];return this.findByCid(t)},findByIndex:function(e){return t.values(this._views)[e]},findByCid:function(e){return this._views[e]},remove:function(e){return this._remove(e)._updateLength()},_remove:function(e){var i=e.cid;return e.model&&delete this._indexByModel[e.model.cid],t.some(this._indexByCustom,t.bind(function(e,t){if(e===i)return delete this._indexByCustom[t],!0},this)),delete this._views[i],this},_updateLength:function(){return this.length=t.size(this._views),this}});var ce=["behaviors","childView","childViewEventPrefix","childViewEvents","childViewOptions","childViewTriggers","collectionEvents","events","filter","emptyView","emptyViewOptions","modelEvents","reorderOnSort","sort","triggers","ui","viewComparator"],ue=e.View.extend({sort:!0,constructor:function(i){this.render=t.bind(this.render,this),this._setOptions(i),this.mergeOptions(i,ce),c(this),this._initBehaviors(),this.once("render",this._initialEvents),this._initChildViewStorage(),this._bufferedChildren=[];var n=Array.prototype.slice.call(arguments);n[0]=this.options,e.View.prototype.constructor.apply(this,n),this.delegateEntityEvents()},_startBuffering:function(){this._isBuffering=!0},_endBuffering:function(){var e=!!this._isAttached,i=e?this._getImmediateChildren():[];this._isBuffering=!1,t.each(i,function(e){s(e,"before:attach",e)}),this.attachBuffer(this,this._createBuffer()),t.each(i,function(e){e._isAttached=!0,s(e,"attach",e)}),this._bufferedChildren=[]},_getImmediateChildren:function(){return t.values(this.children._views)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this.render),this.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(e,i,n){var r=void 0!==n.at&&(n.index||i.indexOf(e));if((this.filter||r===!1)&&(r=t.indexOf(this._filteredSortedModels(r),e)),this._shouldAddChild(e,r)){this._destroyEmptyView();var s=this._getChildView(e);this._addChild(e,s,r)}},_onCollectionRemove:function(e){var t=this.children.findByModel(e);this.removeChildView(t),this._checkEmpty()},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderChildren(),this._isRendered=!0,this.triggerMethod("render",this),this},setFilter:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],i=t.preventRender,n=this._isRendered&&!this._isDestroyed,r=this.filter!==e,s=n&&r&&!i;if(s){var o=this._filteredSortedModels();this.filter=e;var h=this._filteredSortedModels();this._applyModelDeltas(h,o)}else this.filter=e;return this},removeFilter:function(e){return this.setFilter(null,e)},_applyModelDeltas:function(e,i){var n=this,r={};t.each(e,function(e,t){var i=!n.children.findByModel(e);i&&n._onCollectionAdd(e,n.collection,{at:t}),r[e.cid]=!0}),t.each(i,function(e){var t=!r[e.cid]&&n.children.findByModel(e);t&&n._onCollectionRemove(e)})},reorder:function(){var e=this,i=this.children,n=this._filteredSortedModels();if(!n.length&&this._showingEmptyView)return this;var r=t.some(n,function(e){return!i.findByModel(e)});return r?this.render():!function(){var r=t.map(n,function(e,t){var n=i.findByModel(e);return n._index=t,n.el}),s=i.filter(function(e){return!t.contains(r,e.el)});e.triggerMethod("before:reorder",e),e._appendReorderedChildren(r),t.each(s,t.bind(e.removeChildView,e)),e._checkEmpty(),e.triggerMethod("reorder",e)}(),this},resortView:function(){return this.reorderOnSort?this.reorder():this._renderChildren(),this},_sortViews:function(){var e=this,i=this._filteredSortedModels(),n=t.find(i,function(t,i){var n=e.children.findByModel(t);return!n||n._index!==i});n&&this.resortView()},_emptyViewIndex:-1,_appendReorderedChildren:function(e){this.$el.append(e)},_renderChildren:function(){this._isRendered&&(this._destroyEmptyView(),this._destroyChildren({checkEmpty:!1}));var e=this._filteredSortedModels();this.isEmpty({processedModels:e})?this._showEmptyView():(this.triggerMethod("before:render:children",this),this._startBuffering(),this._showCollection(e),this._endBuffering(),this.triggerMethod("render:children",this))},_showCollection:function(e){var i=this;t.each(e,function(e,t){var n=i._getChildView(e);i._addChild(e,n,t)})},_filteredSortedModels:function(e){if(!this.collection||!this.collection.length)return[];var t=this.getViewComparator(),i=this.collection.models;if(e=Math.min(Math.max(e,0),i.length-1),t){var n=void 0;e&&(n=i[e],i=i.slice(0,e).concat(i.slice(e+1))),i=this._sortModelsBy(i,t),n&&i.splice(e,0,n)}return i=this._filterModels(i)},getViewComparator:function(){return this.viewComparator},_filterModels:function(e){var i=this;return this.filter&&(e=t.filter(e,function(e,t){return i._shouldAddChild(e,t)})),e},_sortModelsBy:function(e,i){return"string"==typeof i?t.sortBy(e,function(e){return e.get(i)}):1===i.length?t.sortBy(e,t.bind(i,this)):e.sort(t.bind(i,this))},_showEmptyView:function(){var i=this._getEmptyView();if(i&&!this._showingEmptyView){this._showingEmptyView=!0;var n=new e.Model,r=this.emptyViewOptions||this.childViewOptions;t.isFunction(r)&&(r=r.call(this,n,this._emptyViewIndex));var s=this.buildChildView(n,i,r);this.triggerMethod("before:render:empty",this,s),this._addChildView(s,0),this.triggerMethod("render:empty",this,s),s._parent=this}},_destroyEmptyView:function(){this._showingEmptyView&&(this.triggerMethod("before:remove:empty",this),this._destroyChildren(),delete this._showingEmptyView,this.triggerMethod("remove:empty",this))},_getEmptyView:function(){var e=this.emptyView;if(e)return this._getView(e)},_getChildView:function(e){var t=this.childView;if(!t)throw new F({name:"NoChildViewError",message:'A "childView" must be specified'});if(t=this._getView(t,e),!t)throw new F({name:"InvalidChildViewError",message:'"childView" must be a view class or a function that returns a view class'});return t},_getView:function(i,n){return i.prototype instanceof e.View||i===e.View?i:t.isFunction(i)?i.call(this,n):void 0},_addChild:function(e,t,i){var n=this._getChildViewOptions(e,i),r=this.buildChildView(e,t,n);return this.addChildView(r,i),r},_getChildViewOptions:function(e,i){return t.isFunction(this.childViewOptions)?this.childViewOptions(e,i):this.childViewOptions},addChildView:function(e,t){return this.triggerMethod("before:add:child",this,e),this._updateIndices(e,!0,t),e._parent=this,this._addChildView(e,t),this.triggerMethod("add:child",this,e),e},_updateIndices:function(e,t,i){this.sort&&(t&&(e._index=i),this.children.each(function(i){i._index>=e._index&&(i._index+=t?1:-1)}))},_addChildView:function(e,t){var i=!this._isBuffering&&this._isAttached;c(e),this._proxyChildEvents(e),this.children.add(e),e.supportsRenderLifecycle||s(e,"before:render",e),e.render(),e.supportsRenderLifecycle||(e._isRendered=!0,s(e,"render",e)),i&&s(e,"before:attach",e),this.attachHtml(this,e,t),i&&(e._isAttached=!0,s(e,"attach",e))},buildChildView:function(e,i,n){var r=t.extend({model:e},n);return new i(r)},removeChildView:function(e){return!e||e._isDestroyed?e:(this.triggerMethod("before:remove:child",this,e),e.destroy?e.destroy():V(e),delete e._parent,this.stopListening(e),this.children.remove(e),this.triggerMethod("remove:child",this,e),this._updateIndices(e,!1),e)},isEmpty:function(e){var i=void 0;return t.result(e,"processedModels")?i=e.processedModels:(i=this.collection?this.collection.models:[],i=this._filterModels(i)),0===i.length},_checkEmpty:function(){this.isEmpty()&&this._showEmptyView()},attachBuffer:function(e,t){e.$el.append(t)},_createBuffer:function(){var e=document.createDocumentFragment();return t.each(this._bufferedChildren,function(t){e.appendChild(t.el)}),e},attachHtml:function(e,t,i){e._isBuffering?e._bufferedChildren.splice(i,0,t):e._insertBefore(t,i)||e._insertAfter(t)},_insertBefore:function(e,t){var i=void 0,n=this.sort&&t<this.children.length-1;return n&&(i=this.children.find(function(e){return e._index===t+1})),!!i&&(i.$el.before(e.el),!0)},_insertAfter:function(e){this.$el.append(e.el)},_initChildViewStorage:function(){this.children=new le},_removeChildren:function(){this._destroyChildren({checkEmpty:!1})},_destroyChildren:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],i=e.checkEmpty;this.triggerMethod("before:destroy:children",this);var n=i!==!1,r=this.children.map(t.identity);return this.children.each(t.bind(this.removeChildView,this)),n&&this._checkEmpty(),this.triggerMethod("destroy:children",this),r},_shouldAddChild:function(e,i){var n=this.filter;return!t.isFunction(n)||n.call(this,e,i,this.collection)},_proxyChildEvents:function(e){var i=this,n=t.result(this,"childViewEventPrefix");this.listenTo(e,"all",function(e){for(var r=arguments.length,s=Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];var h=n+":"+e,d=i.normalizeMethods(i._childViewEvents);"undefined"!=typeof d&&t.isFunction(d[e])&&d[e].apply(i,s);var a=i._childViewTriggers;a&&t.isString(a[e])&&i.triggerMethod.apply(i,[a[e]].concat(s)),i.triggerMethod.apply(i,[h].concat(s))})}});t.extend(ue.prototype,te);var fe=["childViewContainer","template","templateContext"],ge=ue.extend({constructor:function(e){A("CompositeView is deprecated. Convert to View at your earliest convenience"),this.mergeOptions(e,fe),ue.prototype.constructor.apply(this,arguments)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this.renderChildren),this.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_getChildView:function(e){var t=this.childView;if(!t)return this.constructor;if(t=this._getView(t,e),!t)throw new F({name:"InvalidChildViewError",message:'"childView" must be a view class or a function that returns a view class'});return t},serializeData:function(){return this.serializeModel()},render:function(){return this._ensureViewIsIntact(),this._isRendering=!0,this.resetChildViewContainer(),this.triggerMethod("before:render",this),this._renderTemplate(),this.bindUIElements(),this.renderChildren(),this._isRendering=!1,this._isRendered=!0,this.triggerMethod("render",this),this},renderChildren:function(){(this._isRendered||this._isRendering)&&ue.prototype._renderChildren.call(this)},attachBuffer:function(e,t){var i=this.getChildViewContainer(e);i.append(t)},_insertAfter:function(e){var t=this.getChildViewContainer(this,e);t.append(e.el)},_appendReorderedChildren:function(e){var t=this.getChildViewContainer(this);t.append(e)},getChildViewContainer:function(e,i){if(e.$childViewContainer)return e.$childViewContainer;var n=void 0,r=e.childViewContainer;if(r){var s=t.result(e,"childViewContainer");if(n="@"===s.charAt(0)&&e.ui?e.ui[s.substr(4)]:e.$(s),n.length<=0)throw new F({name:"ChildViewContainerMissingError",
|
10
|
-
message:'The specified "childViewContainer" was not found: '+e.childViewContainer})}else n=e.$el;return e.$childViewContainer=n,n},resetChildViewContainer:function(){this.$childViewContainer&&(this.$childViewContainer=void 0)}}),
|
9
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("backbone"),require("underscore"),require("backbone.radio")):"function"==typeof define&&define.amd?define(["backbone","underscore","backbone.radio"],t):e.Marionette=e.Mn=t(e.Backbone,e._,e.Backbone.Radio)}(this,function(e,t,i){"use strict";function n(e,t,i){return i.toUpperCase()}function r(e){for(var i=arguments.length,n=Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];var s=K(e),o=q.call(this,s),h=void 0;return t.isFunction(o)&&(h=o.apply(this,n)),this.trigger.apply(this,arguments),h}function s(e){for(var i=arguments.length,n=Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];return t.isFunction(e.triggerMethod)?e.triggerMethod.apply(e,n):r.apply(e,n)}function o(e,i,n){e._getImmediateChildren&&t.each(e._getImmediateChildren(),function(e){n(e)&&s(e,i,e)})}function h(e){return!e._isAttached}function d(e){return!!h(e)&&(e._isAttached=!0,!0)}function a(e){return e._isAttached}function l(e){return!!a(e)&&(e._isAttached=!1,!0)}function c(e){e._isAttached&&e._isRendered&&s(e,"dom:refresh",e)}function u(){o(this,"before:attach",h)}function f(){o(this,"attach",d),c(this)}function p(){o(this,"before:detach",a)}function g(){o(this,"detach",l)}function _(){c(this)}function v(e){e._areViewEventsMonitored||(e._areViewEventsMonitored=!0,e.on({"before:attach":u,attach:f,"before:detach":p,detach:g,render:_}))}function m(e,i,n,r,s){var o=r.split(/\s+/);t.each(o,function(t){var r=e[t];if(!r)throw new Y('Method "'+t+'" was configured as an event handler, but does not exist.');e[s](i,n,r)})}function w(e,i,n,r){if(i&&n){if(!t.isObject(n))throw new Y({message:"Bindings must be an object.",url:"marionette.functions.html#marionettebindevents"});t.each(n,function(n,s){return t.isString(n)?void m(e,i,s,n,r):void e[r](i,s,n)})}}function y(e,t){return w(this,e,t,"listenTo"),this}function E(e,t){return w(this,e,t,"stopListening"),this}function V(e,i,n,r){if(i&&n){if(!t.isObject(n))throw new Y({message:"Bindings must be an object.",url:"marionette.functions.html#marionettebindrequests"});var s=N.call(e,n);i[r](s,e)}}function C(e,t){return V(this,e,t,"reply"),this}function b(e,t){return V(this,e,t,"stopReplying"),this}function M(e){if(Array.isArray(e)){for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}return Array.from(e)}function R(e,i){return e.behaviorClass?e.behaviorClass:t.isFunction(e)?e:t.isFunction(De.Behaviors.behaviorsLookup)?De.Behaviors.behaviorsLookup(e,i)[i]:De.Behaviors.behaviorsLookup[i]}function x(e,i){return t.chain(i).map(function(i,n){var r=R(i,n),s=i===r?{}:i,o=new r(s,e),h=x(e,t.result(o,"behaviors"));return[o].concat(h)}).flatten().value()}function B(e,i){return[e+t.uniqueId(".evt"),i].join(" ")}function I(e,i){t.isString(i)&&(i={event:i});var n=i.event,r=i.preventDefault!==!1,s=i.stopPropagation!==!1;return function(t){r&&t.preventDefault(),s&&t.stopPropagation(),e.triggerMethod(n,e)}}function A(e){e.supportsDestroyLifecycle||s(e,"before:destroy",e);var t=!!e._isAttached;t&&s(e,"before:detach",e),e.remove(),t&&(e._isAttached=!1,s(e,"detach",e)),e._isDestroyed=!0,e.supportsDestroyLifecycle||s(e,"destroy",e)}function O(e,t){return e instanceof fe?e:T(e,t)}function T(e,i){var n=t.extend({},i);if(t.isString(e))return t.extend(n,{el:e}),U(n);if(t.isFunction(e))return t.extend(n,{regionClass:e}),U(n);if(t.isObject(e))return e.selector&&F("The selector option on a Region definition object is deprecated. Use el to pass a selector string"),t.extend(n,{el:e.selector},e),U(n);throw new Y({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})}function U(e){var i=e.regionClass,n=t.omit(e,"regionClass");return new i(n)}function D(){throw new Y({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.md#behaviorslookup"})}function $(e){return!!Te[e]}function k(e,t){return Te[e]=t}e="default"in e?e.default:e,t="default"in t?t.default:t,i="default"in i?i.default:i;var S="3.1.0",z=function(e){return function(t){for(var i=arguments.length,n=Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return e.apply(t,n)}},L=e.Model.extend,F=function e(i,n){t.isObject(i)&&(i=i.prev+" is going to be removed in the future. Please use "+i.next+" instead."+(i.url?" See: "+i.url:"")),De.DEV_MODE&&(void 0!==n&&n||e._cache[i]||(e._warn("Deprecation warning: "+i),e._cache[i]=!0))};F._console="undefined"!=typeof console?console:{},F._warn=function(){var e=F._console.warn||F._console.log||t.noop;return e.apply(F._console,arguments)},F._cache={};var P=function(t){return e.$.contains(document.documentElement,t)},j=function(e,i){var n=this;e&&t.each(i,function(t){var i=e[t];void 0!==i&&(n[t]=i)})},q=function(e){if(e)return this.options&&void 0!==this.options[e]?this.options[e]:this[e]},N=function(e){var i=this;return t.reduce(e,function(e,n,r){return t.isFunction(n)||(n=i[n]),n&&(e[r]=n),e},{})},H=/(^|:)(\w)/gi,K=t.memoize(function(e){return"on"+e.replace(H,n)}),G=["description","fileName","lineNumber","name","message","number"],Y=L.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+S+"/",constructor:function(e,i){t.isObject(e)?(i=e,e=i.message):i||(i={});var n=Error.call(this,e);t.extend(this,t.pick(n,G),t.pick(i,G)),this.captureStackTrace(),i.url&&(this.url=this.urlRoot+i.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,Y)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}});Y.extend=L;var Z=function(){for(var e=arguments.length,i=Array(e),n=0;n<e;n++)i[n]=arguments[n];this.options=t.extend.apply(t,[{},t.result(this,"options")].concat(i))},J={normalizeMethods:N,_setOptions:Z,mergeOptions:j,getOption:q,bindEvents:y,unbindEvents:E},Q={_initRadio:function(){var e=t.result(this,"channelName");if(e){if(!i)throw new Y({name:"BackboneRadioMissing",message:'The dependency "backbone.radio" is missing.'});var n=this._channel=i.channel(e),r=t.result(this,"radioEvents");this.bindEvents(n,r);var s=t.result(this,"radioRequests");this.bindRequests(n,s),this.on("destroy",this._destroyRadio)}},_destroyRadio:function(){this._channel.stopReplying(null,null,this)},getChannel:function(){return this._channel},bindEvents:y,unbindEvents:E,bindRequests:C,unbindRequests:b},W=["channelName","radioEvents","radioRequests"],X=function(e){this._setOptions(e),this.mergeOptions(e,W),this.cid=t.uniqueId(this.cidPrefix),this._initRadio(),this.initialize.apply(this,arguments)};X.extend=L,t.extend(X.prototype,e.Events,J,Q,{cidPrefix:"mno",_isDestroyed:!1,isDestroyed:function(){return this._isDestroyed},initialize:function(){},destroy:function(){if(this._isDestroyed)return this;for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.triggerMethod.apply(this,["before:destroy",this].concat(t)),this._isDestroyed=!0,this.triggerMethod.apply(this,["destroy",this].concat(t)),this.stopListening(),this},triggerMethod:r});var ee=function(e){this.templateId=e};t.extend(ee,{templateCaches:{},get:function(e,t){var i=this.templateCaches[e];return i||(i=new ee(e),this.templateCaches[e]=i),i.load(t)},clear:function(){for(var e=void 0,t=arguments.length,i=Array(t),n=0;n<t;n++)i[n]=arguments[n];var r=i.length;if(r>0)for(e=0;e<r;e++)delete this.templateCaches[i[e]];else this.templateCaches={}}}),t.extend(ee.prototype,{load:function(e){if(this.compiledTemplate)return this.compiledTemplate;var t=this.loadTemplate(this.templateId,e);return this.compiledTemplate=this.compileTemplate(t,e),this.compiledTemplate},loadTemplate:function(t,i){var n=e.$(t);if(!n.length)throw new Y({name:"NoTemplateError",message:'Could not find template: "'+t+'"'});return n.html()},compileTemplate:function(e,i){return t.template(e,i)}});var te=t.invokeMap||t.invoke,ie={_initBehaviors:function(){var e=t.result(this,"behaviors");this._behaviors=t.isObject(e)?x(this,e):{}},_getBehaviorTriggers:function(){var e=te(this._behaviors,"getTriggers");return t.extend.apply(t,[{}].concat(M(e)))},_getBehaviorEvents:function(){var e=te(this._behaviors,"getEvents");return t.extend.apply(t,[{}].concat(M(e)))},_proxyBehaviorViewProperties:function(){te(this._behaviors,"proxyViewProperties")},_delegateBehaviorEntityEvents:function(){te(this._behaviors,"delegateEntityEvents")},_undelegateBehaviorEntityEvents:function(){te(this._behaviors,"undelegateEntityEvents")},_destroyBehaviors:function(e){te.apply(void 0,[this._behaviors,"destroy"].concat(M(e)))},_bindBehaviorUIElements:function(){te(this._behaviors,"bindUIElements")},_unbindBehaviorUIElements:function(){te(this._behaviors,"unbindUIElements")},_triggerEventOnBehaviors:function(){for(var e=this._behaviors,t=0,i=e&&e.length;t<i;t++)r.apply(e[t],arguments)}},ne={_delegateEntityEvents:function(e,i){this._undelegateEntityEvents(e,i);var n=t.result(this,"modelEvents");y.call(this,e,n);var r=t.result(this,"collectionEvents");y.call(this,i,r)},_undelegateEntityEvents:function(e,i){var n=t.result(this,"modelEvents");E.call(this,e,n);var r=t.result(this,"collectionEvents");E.call(this,i,r)}},re=/^(\S+)\s*(.*)$/,se=function(e){var t=e.match(re);return B(t[1],t[2])},oe={_getViewTriggers:function(e,i){return t.reduce(i,function(t,i,n){return n=se(n),t[n]=I(e,i),t},{})}},he=function(e,i){return t.reduce(e,function(e,t,n){var r=de(n,i);return e[r]=t,e},{})},de=function(e,t){return e.replace(/@ui\.[a-zA-Z-_$0-9]*/g,function(e){return t[e.slice(4)]})},ae=function e(i,n,r){return t.each(i,function(s,o){t.isString(s)?i[o]=de(s,n):t.isObject(s)&&t.isArray(r)&&(t.extend(s,e(t.pick(s,r),n)),t.each(r,function(e){var i=s[e];t.isString(i)&&(s[e]=de(i,n))}))}),i},le={normalizeUIKeys:function(e){var t=this._getUIBindings();return he(e,t)},normalizeUIString:function(e){var t=this._getUIBindings();return de(e,t)},normalizeUIValues:function(e,t){var i=this._getUIBindings();return ae(e,i,t)},_getUIBindings:function(){var e=t.result(this,"_uiBindings"),i=t.result(this,"ui");return e||i},_bindUIElements:function(){var e=this;if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var i=t.result(this,"_uiBindings");this._ui={},t.each(i,function(t,i){e._ui[i]=e.$(t)}),this.ui=this._ui}},_unbindUIElements:function(){var e=this;this.ui&&this._uiBindings&&(t.each(this.ui,function(t,i){delete e.ui[i]}),this.ui=this._uiBindings,delete this._uiBindings,delete this._ui)},_getUI:function(e){return this._ui[e]}},ce={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(i){this._proxyBehaviorViewProperties(),this._buildEventProxies();var n=this._getEvents(i);"undefined"==typeof i&&(this.events=n);var r=t.extend({},this._getBehaviorEvents(),n,this._getBehaviorTriggers(),this.getTriggers());return e.View.prototype.delegateEvents.call(this,r),this},_getEvents:function(e){var i=e||this.events;return t.isFunction(i)?this.normalizeUIKeys(i.call(this)):this.normalizeUIKeys(i)},getTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(t.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},_ensureViewIsIntact:function(){if(this._isDestroyed)throw new Y({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(this._isDestroyed)return this;for(var e=!!this._isAttached,t=arguments.length,i=Array(t),n=0;n<t;n++)i[n]=arguments[n];return this.triggerMethod.apply(this,["before:destroy",this].concat(i)),e&&this.triggerMethod("before:detach",this),this.unbindUIElements(),this._removeElement(),e&&(this._isAttached=!1,this.triggerMethod("detach",this)),this._removeChildren(),this._destroyBehaviors(i),this._isDestroyed=!0,this._isRendered=!1,this.triggerMethod.apply(this,["destroy",this].concat(i)),this.stopListening(),this},bindUIElements:function(){return this._bindUIElements(),this._bindBehaviorUIElements(),this},unbindUIElements:function(){return this._unbindUIElements(),this._unbindBehaviorUIElements(),this},getUI:function(e){return this._ensureViewIsIntact(),this._getUI(e)},childViewEventPrefix:"childview",triggerMethod:function(){var e=r.apply(this,arguments);return this._triggerEventOnBehaviors.apply(this,arguments),this._triggerEventOnParentLayout.apply(this,arguments),e},_buildEventProxies:function(){this._childViewEvents=t.result(this,"childViewEvents"),this._childViewTriggers=t.result(this,"childViewTriggers")},_triggerEventOnParentLayout:function(){var e=this._parentView();e&&e._childViewEventHandler.apply(e,arguments)},_parentView:function(){for(var e=this._parent;e;){if(e instanceof ve)return e;e=e._parent}},_childViewEventHandler:function(e){for(var i=this.normalizeMethods(this._childViewEvents),n=arguments.length,r=Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];"undefined"!=typeof i&&t.isFunction(i[e])&&i[e].apply(this,r);var o=this._childViewTriggers;o&&t.isString(o[e])&&this.triggerMethod.apply(this,[o[e]].concat(r));var h=t.result(this,"childViewEventPrefix");if(h!==!1){var d=h+":"+e;this.triggerMethod.apply(this,[d].concat(r))}}};t.extend(ce,ie,J,ne,oe,le);var ue=["allowMissingEl","parentEl","replaceElement"],fe=X.extend({cidPrefix:"mnr",replaceElement:!1,_isReplaced:!1,constructor:function(t){if(this._setOptions(t),this.mergeOptions(t,ue),this._initEl=this.el=this.getOption("el"),this.el=this.el instanceof e.$?this.el[0]:this.el,!this.el)throw new Y({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),X.call(this,t)},show:function(e,t){if(this._ensureElement(t))return this._ensureView(e),e===this.currentView?this:(this.triggerMethod("before:show",this,e,t),v(e),this.empty(t),e.on("destroy",this._empty,this),e._parent=this,this._renderView(e),this._attachView(e,t),this.triggerMethod("show",this,e,t),this)},_renderView:function(e){e._isRendered||(e.supportsRenderLifecycle||s(e,"before:render",e),e.render(),e.supportsRenderLifecycle||(e._isRendered=!0,s(e,"render",e)))},_attachView:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!e._isAttached&&P(this.el),r="undefined"==typeof i.replaceElement?!!t.result(this,"replaceElement"):!!i.replaceElement;n&&s(e,"before:attach",e),r?this._replaceEl(e):this.attachHtml(e),n&&(e._isAttached=!0,s(e,"attach",e)),this.currentView=e},_ensureElement:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||0===this.$el.length){var i="undefined"==typeof e.allowMissingEl?!!t.result(this,"allowMissingEl"):!!e.allowMissingEl;if(i)return!1;throw new Y('An "el" must exist in DOM for this region '+this.cid)}return!0},_ensureView:function(e){if(!e)throw new Y({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(e._isDestroyed)throw new Y({name:"ViewDestroyedError",message:'View (cid: "'+e.cid+'") has already been destroyed and cannot be used.'})},getEl:function(i){return e.$(i,t.result(this,"parentEl"))},_replaceEl:function(e){this._restoreEl();var t=this.el.parentNode;t.replaceChild(e.el,this.el),this._isReplaced=!0},_restoreEl:function(){if(this._isReplaced){var e=this.currentView;if(e){var t=e.el.parentNode;t&&(t.replaceChild(this.el,e.el),this._isReplaced=!1)}}},isReplaced:function(){return!!this._isReplaced},attachHtml:function(e){this.el.appendChild(e.el)},empty:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{allowMissingEl:!0},t=this.currentView;if(!t)return this._ensureElement(e)&&this.detachHtml(),this;var i=!e.preventDestroy;return i||F("The preventDestroy option is deprecated. Use Region#detachView"),this._empty(t,i),this},_empty:function(e,t){e.off("destroy",this._empty,this),this.triggerMethod("before:empty",this,e),this._restoreEl(),delete this.currentView,e._isDestroyed||(this._removeView(e,t),delete e._parent),this.triggerMethod("empty",this,e)},_removeView:function(e,t){return t?void(e.destroy?e.destroy():A(e)):void this._detachView(e)},detachView:function(){var e=this.currentView;if(e)return this._empty(e),e},_detachView:function(e){var t=!!e._isAttached;t&&s(e,"before:detach",e),this.detachHtml(),t&&(e._isAttached=!1,s(e,"detach",e))},detachHtml:function(){this.$el.contents().detach()},hasView:function(){return!!this.currentView},reset:function(e){return this.empty(e),this.$el&&(this.el=this._initEl),delete this.$el,this},destroy:function(e){return this.reset(e),X.prototype.destroy.apply(this,arguments)}}),pe={regionClass:fe,_initRegions:function(){this.regions=this.regions||{},this._regions={},this.addRegions(t.result(this,"regions"))},_reInitRegions:function(){te(this._regions,"reset")},addRegion:function(e,t){var i={};return i[e]=t,this.addRegions(i)[e]},addRegions:function(e){if(!t.isEmpty(e))return e=this.normalizeUIValues(e,["selector","el"]),this.regions=t.extend({},this.regions,e),this._addRegions(e)},_addRegions:function(e){var i=this,n={regionClass:this.regionClass,parentEl:t.partial(t.result,this,"el")};return t.reduce(e,function(e,t,r){return e[r]=O(t,n),i._addRegion(e[r],r),e},{})},_addRegion:function(e,t){this.triggerMethod("before:add:region",this,t,e),e._parent=this,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 t.each(this._regions,t.bind(this._removeRegion,this)),e},_removeRegion:function(e,t){this.triggerMethod("before:remove:region",this,t,e),e.destroy(),delete this.regions[t],delete this._regions[t],this.triggerMethod("remove:region",this,t,e)},emptyRegions:function(){var e=this.getRegions();return te(e,"empty"),e},hasRegion:function(e){return!!this.getRegion(e)},getRegion:function(e){return this._regions[e]},getRegions:function(){return t.clone(this._regions)},showChildView:function(e,t){for(var i=this.getRegion(e),n=arguments.length,r=Array(n>2?n-2:0),s=2;s<n;s++)r[s-2]=arguments[s];return i.show.apply(i,[t].concat(r))},detachChildView:function(e){return this.getRegion(e).detachView()},getChildView:function(e){return this.getRegion(e).currentView}},ge={render:function(e,i){if(!e)throw new Y({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var n=t.isFunction(e)?e:ee.get(e);return n(i)}},_e=["behaviors","childViewEventPrefix","childViewEvents","childViewTriggers","collectionEvents","events","modelEvents","regionClass","regions","template","templateContext","triggers","ui"],ve=e.View.extend({constructor:function(i){this.render=t.bind(this.render,this),this._setOptions(i),this.mergeOptions(i,_e),v(this),this._initBehaviors(),this._initRegions();var n=Array.prototype.slice.call(arguments);n[0]=this.options,e.View.prototype.constructor.apply(this,n),this.delegateEntityEvents()},serializeData:function(){return this.model||this.collection?this.model?this.serializeModel():{items:this.serializeCollection()}:{}},serializeModel:function(){return this.model?t.clone(this.model.attributes):{}},serializeCollection:function(){return this.collection?this.collection.map(function(e){return t.clone(e.attributes)}):{}},setElement:function(){var t=!!this.el;return e.View.prototype.setElement.apply(this,arguments),t&&(this._isRendered=!!this.$el.length,this._isAttached=P(this.el)),this._isRendered&&this.bindUIElements(),this},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._isRendered&&this._reInitRegions(),this._renderTemplate(),this.bindUIElements(),this._isRendered=!0,this.triggerMethod("render",this),this},_renderTemplate:function(){var e=this.getTemplate();if(e!==!1){var t=this.mixinTemplateContext(this.serializeData()),i=ge.render(e,t,this);this.attachElContent(i)}},getTemplate:function(){return this.template},mixinTemplateContext:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.result(this,"templateContext");return t.extend(e,i)},attachElContent:function(e){return this.$el.html(e),this},_removeChildren:function(){this.removeRegions()},_getImmediateChildren:function(){return t.chain(this.getRegions()).map("currentView").compact().value()}});t.extend(ve.prototype,ce,pe);var me=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"],we=function(e,i){t.each(me,function(n){e[n]=function(){var e=t.values(t.result(this,i)),r=[e].concat(t.toArray(arguments));return t[n].apply(t,r)}})},ye=function(e){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),t.each(e,t.bind(this.add,this))};we(ye.prototype,"_views"),t.extend(ye.prototype,{add:function(e,t){return this._add(e,t)._updateLength()},_add:function(e,t){var i=e.cid;return this._views[i]=e,e.model&&(this._indexByModel[e.model.cid]=i),t&&(this._indexByCustom[t]=i),this},findByModel:function(e){return this.findByModelCid(e.cid)},findByModelCid:function(e){var t=this._indexByModel[e];return this.findByCid(t)},findByCustom:function(e){var t=this._indexByCustom[e];return this.findByCid(t)},findByIndex:function(e){return t.values(this._views)[e]},findByCid:function(e){return this._views[e]},remove:function(e){return this._remove(e)._updateLength()},_remove:function(e){var i=e.cid;return e.model&&delete this._indexByModel[e.model.cid],t.some(this._indexByCustom,t.bind(function(e,t){if(e===i)return delete this._indexByCustom[t],!0},this)),delete this._views[i],this},_updateLength:function(){return this.length=t.size(this._views),this}});var Ee=["behaviors","childView","childViewEventPrefix","childViewEvents","childViewOptions","childViewTriggers","collectionEvents","events","filter","emptyView","emptyViewOptions","modelEvents","reorderOnSort","sort","triggers","ui","viewComparator"],Ve=e.View.extend({sort:!0,constructor:function(i){this.render=t.bind(this.render,this),this._setOptions(i),this.mergeOptions(i,Ee),v(this),this._initBehaviors(),this.once("render",this._initialEvents),this._initChildViewStorage(),this._bufferedChildren=[];var n=Array.prototype.slice.call(arguments);n[0]=this.options,e.View.prototype.constructor.apply(this,n),this.delegateEntityEvents()},_startBuffering:function(){this._isBuffering=!0},_endBuffering:function(){var e=!!this._isAttached,i=e?this._getImmediateChildren():[];this._isBuffering=!1,t.each(i,function(e){s(e,"before:attach",e)}),this.attachBuffer(this,this._createBuffer()),t.each(i,function(e){e._isAttached=!0,s(e,"attach",e)}),this._bufferedChildren=[]},_getImmediateChildren:function(){return t.values(this.children._views)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"update",this._onCollectionUpdate),this.listenTo(this.collection,"reset",this.render),this.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(e,i,n){var r=void 0!==n.at&&(n.index||i.indexOf(e));(this.filter||r===!1)&&(r=t.indexOf(this._filteredSortedModels(r),e)),this._shouldAddChild(e,r)&&(this._destroyEmptyView(),this._addChild(e,r))},_onCollectionUpdate:function(e,t){var i=t.changes;this._removeChildModels(i.removed)},_removeChildModels:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.checkEmpty,n=i!==!1,r=this._getRemovedViews(e);r.length&&(this.children._updateLength(),this._updateIndices(r,!1),n&&this._checkEmpty())},_getRemovedViews:function(e){var i=this;return t.reduce(e,function(e,t){var n=i.children.findByModel(t);return!n||n._isDestroyed?e:(i._removeChildView(n),e.push(n),e)},[])},_findGreatestIndexedView:function(e){return t.reduce(e,function(e,t){return!e||e._index<t._index?t:e},void 0)},_removeChildView:function(e){this.triggerMethod("before:remove:child",this,e),this.children._remove(e),e.destroy?e.destroy():A(e),delete e._parent,this.stopListening(e),this.triggerMethod("remove:child",this,e)},setElement:function(){var t=!!this.el;return e.View.prototype.setElement.apply(this,arguments),t&&(this._isAttached=P(this.el)),this},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderChildren(),this._isRendered=!0,this.triggerMethod("render",this),this},setFilter:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.preventRender,n=this._isRendered&&!this._isDestroyed,r=this.filter!==e,s=n&&r&&!i;if(s){var o=this._filteredSortedModels();this.filter=e;var h=this._filteredSortedModels();this._applyModelDeltas(h,o)}else this.filter=e;return this},removeFilter:function(e){return this.setFilter(null,e)},_applyModelDeltas:function(e,i){var n=this,r={};t.each(e,function(e,t){var i=!n.children.findByModel(e);i&&n._onCollectionAdd(e,n.collection,{at:t}),r[e.cid]=!0});var s=t.filter(i,function(e){return!r[e.cid]&&n.children.findByModel(e)});this._removeChildModels(s)},reorder:function(){var e=this,i=this.children,n=this._filteredSortedModels();if(!n.length&&this._showingEmptyView)return this;var r=t.some(n,function(e){return!i.findByModel(e)});return r?this.render():!function(){var r=[],s=i.reduce(function(e,i){var s=t.indexOf(n,i.model);return s===-1?(r.push(i.model),e):(i._index=s,e[s]=i.el,e)},new Array(n.length));e.triggerMethod("before:reorder",e),e._appendReorderedChildren(s),e._removeChildModels(r),e.triggerMethod("reorder",e)}(),this},resortView:function(){return this.reorderOnSort?this.reorder():this._renderChildren(),this},_sortViews:function(){var e=this,i=this._filteredSortedModels(),n=t.find(i,function(t,i){var n=e.children.findByModel(t);return!n||n._index!==i});n&&this.resortView()},_emptyViewIndex:-1,_appendReorderedChildren:function(e){this.$el.append(e)},_renderChildren:function(){this._isRendered&&(this._destroyEmptyView(),this._destroyChildren({checkEmpty:!1}));var e=this._filteredSortedModels();this.isEmpty({processedModels:e})?this._showEmptyView():(this.triggerMethod("before:render:children",this),this._startBuffering(),this._showCollection(e),this._endBuffering(),this.triggerMethod("render:children",this))},_createView:function(e,t){var i=this._getChildView(e),n=this._getChildViewOptions(e,t),r=this.buildChildView(e,i,n);return r},_setupChildView:function(e,t){e._parent=this,v(e),this._proxyChildEvents(e),this.sort&&(e._index=t)},_showCollection:function(e){t.each(e,t.bind(this._addChild,this)),this.children._updateLength()},_filteredSortedModels:function(e){if(!this.collection||!this.collection.length)return[];var t=this.getViewComparator(),i=this.collection.models;if(e=Math.min(Math.max(e,0),i.length-1),t){var n=void 0;e&&(n=i[e],i=i.slice(0,e).concat(i.slice(e+1))),i=this._sortModelsBy(i,t),n&&i.splice(e,0,n)}return i=this._filterModels(i)},getViewComparator:function(){return this.viewComparator},_filterModels:function(e){var i=this;return this.filter&&(e=t.filter(e,function(e,t){return i._shouldAddChild(e,t)})),e},_sortModelsBy:function(e,i){return"string"==typeof i?t.sortBy(e,function(e){return e.get(i)}):1===i.length?t.sortBy(e,t.bind(i,this)):e.sort(t.bind(i,this))},_showEmptyView:function(){var i=this._getEmptyView();if(i&&!this._showingEmptyView){this._showingEmptyView=!0;var n=new e.Model,r=this.emptyViewOptions||this.childViewOptions;t.isFunction(r)&&(r=r.call(this,n,this._emptyViewIndex));var s=this.buildChildView(n,i,r);this.triggerMethod("before:render:empty",this,s),this.addChildView(s,0),this.triggerMethod("render:empty",this,s)}},_destroyEmptyView:function(){this._showingEmptyView&&(this.triggerMethod("before:remove:empty",this),this._destroyChildren(),delete this._showingEmptyView,this.triggerMethod("remove:empty",this))},_getEmptyView:function(){var e=this.emptyView;if(e)return this._getView(e)},_getChildView:function(e){var t=this.childView;if(!t)throw new Y({name:"NoChildViewError",message:'A "childView" must be specified'});if(t=this._getView(t,e),!t)throw new Y({name:"InvalidChildViewError",message:'"childView" must be a view class or a function that returns a view class'});return t},_getView:function(i,n){return i.prototype instanceof e.View||i===e.View?i:t.isFunction(i)?i.call(this,n):void 0},_addChild:function(e,t){var i=this._createView(e,t);return this.addChildView(i,t),i},_getChildViewOptions:function(e,i){return t.isFunction(this.childViewOptions)?this.childViewOptions(e,i):this.childViewOptions},addChildView:function(e,t){return this.triggerMethod("before:add:child",this,e),this._setupChildView(e,t),this._isBuffering?this.children._add(e):(this._updateIndices(e,!0),this.children.add(e)),this._renderView(e),this._attachView(e,t),this.triggerMethod("add:child",this,e),e},_updateIndices:function(e,i){if(this.sort){var n=t.isArray(e)?this._findGreatestIndexedView(e):e;this.children.each(function(e){e._index>=n._index&&(e._index+=i?1:-1)})}},_renderView:function(e){e._isRendered||(e.supportsRenderLifecycle||s(e,"before:render",e),e.render(),e.supportsRenderLifecycle||(e._isRendered=!0,s(e,"render",e)))},_attachView:function(e,t){var i=!e._isAttached&&!this._isBuffering&&this._isAttached;i&&s(e,"before:attach",e),this.attachHtml(this,e,t),i&&(e._isAttached=!0,s(e,"attach",e))},buildChildView:function(e,i,n){var r=t.extend({model:e},n);return new i(r)},removeChildView:function(e){return!e||e._isDestroyed?e:(this._removeChildView(e),this.children._updateLength(),this._updateIndices(e,!1),e)},isEmpty:function(e){var i=void 0;return t.result(e,"processedModels")?i=e.processedModels:(i=this.collection?this.collection.models:[],i=this._filterModels(i)),0===i.length},_checkEmpty:function(){this.isEmpty()&&this._showEmptyView()},attachBuffer:function(e,t){e.$el.append(t)},_createBuffer:function(){var e=document.createDocumentFragment();return t.each(this._bufferedChildren,function(t){e.appendChild(t.el)}),e},attachHtml:function(e,t,i){e._isBuffering?e._bufferedChildren.splice(i,0,t):e._insertBefore(t,i)||e._insertAfter(t)},_insertBefore:function(e,t){var i=void 0,n=this.sort&&t<this.children.length-1;return n&&(i=this.children.find(function(e){return e._index===t+1})),!!i&&(i.$el.before(e.el),!0)},_insertAfter:function(e){this.$el.append(e.el)},_initChildViewStorage:function(){this.children=new ye},_removeChildren:function(){this._destroyChildren({checkEmpty:!1})},_destroyChildren:function(e){if(this.children.length){this.triggerMethod("before:destroy:children",this);var t=this.children.map("model");this._removeChildModels(t,e),this.triggerMethod("destroy:children",this)}},_shouldAddChild:function(e,i){var n=this.filter;return!t.isFunction(n)||n.call(this,e,i,this.collection)},_proxyChildEvents:function(e){this.listenTo(e,"all",this._childViewEventHandler)}});t.extend(Ve.prototype,ce);var Ce=["childViewContainer","template","templateContext"],be=Ve.extend({constructor:function(e){F("CompositeView is deprecated. Convert to View at your earliest convenience"),this.mergeOptions(e,Ce),Ve.prototype.constructor.apply(this,arguments)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"update",this._onCollectionUpdate),this.listenTo(this.collection,"reset",this.renderChildren),this.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_getChildView:function(e){var t=this.childView;if(!t)return this.constructor;if(t=this._getView(t,e),!t)throw new Y({name:"InvalidChildViewError",message:'"childView" must be a view class or a function that returns a view class'});return t},serializeData:function(){return this.serializeModel()},render:function(){return this._ensureViewIsIntact(),this._isRendering=!0,
|
10
|
+
this.resetChildViewContainer(),this.triggerMethod("before:render",this),this._renderTemplate(),this.bindUIElements(),this.renderChildren(),this._isRendering=!1,this._isRendered=!0,this.triggerMethod("render",this),this},renderChildren:function(){(this._isRendered||this._isRendering)&&Ve.prototype._renderChildren.call(this)},attachBuffer:function(e,t){var i=this.getChildViewContainer(e);i.append(t)},_insertAfter:function(e){var t=this.getChildViewContainer(this,e);t.append(e.el)},_appendReorderedChildren:function(e){var t=this.getChildViewContainer(this);t.append(e)},getChildViewContainer:function(e,i){if(e.$childViewContainer)return e.$childViewContainer;var n=void 0,r=e.childViewContainer;if(r){var s=t.result(e,"childViewContainer");if(n="@"===s.charAt(0)&&e.ui?e.ui[s.substr(4)]:e.$(s),n.length<=0)throw new Y({name:"ChildViewContainerMissingError",message:'The specified "childViewContainer" was not found: '+e.childViewContainer})}else n=e.$el;return e.$childViewContainer=n,n},resetChildViewContainer:function(){this.$childViewContainer&&(this.$childViewContainer=void 0)}}),Me=t.pick(ve.prototype,"serializeModel","getTemplate","_renderTemplate","mixinTemplateContext","attachElContent");t.extend(be.prototype,Me);var Re=["collectionEvents","events","modelEvents","triggers","ui"],xe=X.extend({cidPrefix:"mnb",constructor:function(e,i){this.view=i,this.defaults=t.clone(t.result(this,"defaults",{})),this._setOptions(this.defaults,e),this.mergeOptions(this.options,Re),this.ui=t.extend({},t.result(this,"ui"),t.result(i,"ui")),X.apply(this,arguments)},$:function(){return this.view.$.apply(this.view,arguments)},destroy:function(){return this.stopListening(),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.view._ensureViewIsIntact(),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,i=this.normalizeUIKeys(t.result(this,"events"));return t.reduce(i,function(i,n,r){if(t.isFunction(n)||(n=e[n]),n)return r=se(r),i[r]=t.bind(n,e),i},{})},getTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(t.result(this,"triggers"));return this._getViewTriggers(this.view,e)}}});t.extend(xe.prototype,ne,oe,le);var Be=["region","regionClass"],Ie=X.extend({cidPrefix:"mna",constructor:function(e){this._setOptions(e),this.mergeOptions(e,Be),this._initRegion(),X.prototype.constructor.apply(this,arguments)},regionClass:fe,_initRegion:function(){var e=this.region;if(e){var t={regionClass:this.regionClass};this._region=O(e,t)}},getRegion:function(){return this._region},showView:function(e){for(var t=this.getRegion(),i=arguments.length,n=Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return t.show.apply(t,[e].concat(n))},getView:function(){return this.getRegion().currentView},start:function(e){return this.triggerMethod("before:start",this,e),this.triggerMethod("start",this,e),this}}),Ae=["appRoutes","controller"],Oe=e.Router.extend({constructor:function(t){this._setOptions(t),this.mergeOptions(t,Ae),e.Router.apply(this,arguments);var i=this.appRoutes,n=this._getController();this.processAppRoutes(n,i),this.on("route",this._processOnRoute,this)},appRoute:function(e,t){var i=this._getController();return this._addAppRoute(i,e,t),this},_processOnRoute:function(e,i){if(t.isFunction(this.onRoute)){var n=t.invert(this.appRoutes)[e];this.onRoute(e,n,i)}},processAppRoutes:function(e,i){var n=this;if(!i)return this;var r=t.keys(i).reverse();return t.each(r,function(t){n._addAppRoute(e,t,i[t])}),this},_getController:function(){return this.controller},_addAppRoute:function(e,i,n){var r=e[n];if(!r)throw new Y('Method "'+n+'" was not found on the controller');this.route(i,n,t.bind(r,e))},triggerMethod:r});t.extend(Oe.prototype,J);var Te={},Ue=e.Marionette,De=e.Marionette={};return De.noConflict=function(){return e.Marionette=Ue,this},De.bindEvents=z(y),De.unbindEvents=z(E),De.bindRequests=z(C),De.unbindRequests=z(b),De.mergeOptions=z(j),De.getOption=z(q),De.normalizeMethods=z(N),De.extend=L,De.isNodeAttached=P,De.deprecate=F,De.triggerMethod=z(r),De.triggerMethodOn=s,De.isEnabled=$,De.setEnabled=k,De.monitorViewEvents=v,De.Behaviors={},De.Behaviors.behaviorsLookup=D,De.Application=Ie,De.AppRouter=Oe,De.Renderer=ge,De.TemplateCache=ee,De.View=ve,De.CollectionView=Ve,De.CompositeView=be,De.Behavior=xe,De.Region=fe,De.Error=Y,De.Object=X,De.DEV_MODE=!1,De.FEATURES=Te,De.VERSION=S,De});
|
11
11
|
//# sourceMappingURL=<%= asset_path 'backbone.marionette.min.js.map' %>
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["/source/src/common/trigger-method.js","/source/src/common/monitor-view-events.js","/source/src/common/bind-events.js","/source/src/common/bind-requests.js","/source/src/mixins/behaviors.js","/source/src/utils/get-unique-event-name.js","/source/src/mixins/triggers.js","/source/src/utils/destroy-backbone-view.js","/source/src/config/behaviors-lookup.js","/source/src/config/features.js","/source/src/utils/proxy.js","/source/src/utils/extend.js","/source/src/utils/deprecate.js","/source/src/common/is-node-attached.js","/source/src/common/merge-options.js","/source/src/common/get-option.js","/source/src/common/normalize-methods.js","/source/src/error.js","/source/src/utils/set-options.js","/source/src/mixins/common.js","/source/src/mixins/radio.js","/source/src/object.js","/source/src/template-cache.js","/source/src/utils/invoke.js","/source/src/mixins/delegate-entity-events.js","/source/src/mixins/ui.js","/source/src/mixins/view.js","/source/src/region.js","/source/src/mixins/regions.js","/source/src/config/renderer.js","/source/src/view.js","/source/src/utils/emulate-collection.js","/source/src/child-view-container.js","/source/src/collection-view.js","/source/src/composite-view.js","/source/src/behavior.js","/source/src/application.js","/source/src/app-router.js","/source/src/backbone.marionette.js"],"names":["getEventName","match","prefix","eventName","toUpperCase","triggerMethod","event","methodName","replace","splitter","method","getOption","call","this","result","_len","arguments","length","args","Array","_key","_","isFunction","apply","trigger","concat","triggerMethodOn","context","fnc","_len2","_key2","triggerMethodChildren","view","shouldTrigger","_getImmediateChildren","each","child","shouldTriggerAttach","_isAttached","shouldAttach","shouldTriggerDetach","shouldDetach","monitorViewEvents","handleBeforeAttach","handleAttach","triggerDOMRefresh","handleBeforeDetach","handleDetach","handleRender","_isRendered","_areViewEventsMonitored","on","before:attach","attach","before:detach","detach","render","bindFromStrings","target","entity","evt","methods","actionName","methodNames","split","MarionetteError","iterateEvents","bindings","isObject","message","url","isString","bindEvents","unbindEvents","iterateReplies","channel","normalizedRadioRequests","normalizeMethods","bindRequests","unbindRequests","getBehaviorClass","options","key","behaviorClass","Marionette","Behaviors","behaviorsLookup","parseBehaviors","behaviors","chain","map","BehaviorClass","_options","behavior","nestedBehaviors","flatten","value","uniqueName","selector","uniqueId","join","buildViewTrigger","triggerDef","shouldPreventDefault","preventDefault","shouldStopPropagation","stopPropagation","e","destroyBackboneView","supportsDestroyLifecycle","remove","_isDestroyed","isEnabled","name","FEATURES","setEnabled","state","proxy","extend","Backbone","Model","deprecate","test","prev","next","DEV_MODE","undefined","_cache","_warn","_console","console","warn","log","noop","isNodeAttached","el","$","contains","document","documentElement","mergeOptions","keys","pick","optionName","hash","_this","reduce","normalizedHash","errorProps","Error","urlRoot","version","constructor","error","captureStackTrace","toString","setOptions","CommonMixin","_setOptions","RadioMixin","_initRadio","channelName","Radio","_channel","radioEvents","radioRequests","_destroyRadio","stopReplying","getChannel","ClassOptions","MarionetteObject","cid","cidPrefix","initialize","prototype","Events","isDestroyed","destroy","stopListening","TemplateCache","templateId","templateCaches","get","cachedTemplate","load","clear","i","compiledTemplate","template","loadTemplate","compileTemplate","$template","html","rawTemplate","_invoke","invokeMap","invoke","BehaviorsMixin","_initBehaviors","_behaviors","_getBehaviorTriggers","triggers","toConsumableArray","_getBehaviorEvents","events","_proxyBehaviorViewProperties","_delegateBehaviorEntityEvents","_undelegateBehaviorEntityEvents","_destroyBehaviors","_bindBehaviorUIElements","_unbindBehaviorUIElements","_triggerEventOnBehaviors","DelegateEntityEventsMixin","_delegateEntityEvents","model","collection","_undelegateEntityEvents","modelEvents","collectionEvents","delegateEventSplitter","getUniqueEventName","TriggersMixin","_getViewTriggers","_normalizeUIKeys","ui","memo","val","normalizedKey","normalizeUIString","uiString","r","slice","_normalizeUIValues","properties","isArray","property","propertyVal","UIMixin","normalizeUIKeys","uiBindings","_getUIBindings","normalizeUIValues","_bindUIElements","_uiBindings","_ui","_unbindUIElements","_this2","$el","_getUI","ViewMixin","supportsRenderLifecycle","isRendered","isAttached","setElement","hasEl","View","delegateEvents","eventsArg","_buildEventProxies","viewEvents","_getEvents","combinedEvents","getTriggers","delegateEntityEvents","undelegateEntityEvents","_ensureViewIsIntact","unbindUIElements","_removeElement","_removeChildren","bindUIElements","getUI","childViewEventPrefix","ret","_triggerMethod","_triggerEventOnParentLayout","_childViewEvents","_childViewTriggers","layoutView","_parentView","eventPrefix","prefixedEventName","_len3","_key3","childViewEvents","childViewTriggers","parent","_parent","Region","replaceElement","_isReplaced","_initEl","getEl","show","_ensureElement","_ensureView","currentView","empty","_renderView","_attachView","shouldReplaceEl","attachHtml","allowMissingEl","_replaceEl","_restoreEl","parentNode","replaceChild","isReplaced","shouldReplace","appendChild","off","_removeView","detachHtml","_ref","preventDestroy","shouldPreventDestroy","_detachView","contents","hasView","reset","RegionsMixin","regionClass","_initRegions","regions","_regions","addRegions","_reInitRegions","addRegion","definition","isEmpty","_addRegions","regionDefinitions","_buildRegion","_addRegion","_buildRegionFromDefinition","_buildRegionFromObject","_buildRegionFromRegionClass","RegionClass","omit","defaults","parentEl","partial","region","removeRegion","_removeRegion","removeRegions","getRegions","bind","emptyRegions","hasRegion","getRegion","clone","showChildView","getChildView","Renderer","data","templateFunc","serializeData","serializeModel","items","serializeCollection","attributes","_renderTemplate","getTemplate","mixinTemplateContext","attachElContent","templateContext","compact","emulateCollection","object","listProperty","list","values","toArray","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","add","customIndex","_add","viewCid","findByModel","findByModelCid","modelCid","findByCid","findByCustom","index","findByIndex","_remove","some","size","CollectionView","sort","once","_initialEvents","_initChildViewStorage","_bufferedChildren","_startBuffering","_isBuffering","_endBuffering","triggerOnChildren","attachBuffer","_createBuffer","children","listenTo","_onCollectionAdd","_onCollectionRemove","_sortViews","opts","at","indexOf","filter","_filteredSortedModels","_shouldAddChild","_destroyEmptyView","ChildView","_getChildView","_addChild","removeChildView","_checkEmpty","_renderChildren","setFilter","preventRender","canBeRendered","filterChanged","shouldRender","previousModels","models","_applyModelDeltas","removeFilter","currentIds","addedChildNotExists","prevModel","removedChildExists","reorder","_showingEmptyView","anyModelsAdded","elsToReorder","_index","filteredOutViews","_appendReorderedChildren","resortView","reorderOnSort","_this3","orderChanged","find","item","_emptyViewIndex","append","_destroyChildren","checkEmpty","processedModels","_showEmptyView","_showCollection","_this4","addedAt","viewComparator","getViewComparator","Math","min","max","addedModel","_sortModelsBy","splice","_filterModels","_this5","comparator","sortBy","EmptyView","_getEmptyView","emptyViewOptions","childViewOptions","buildChildView","_addChildView","emptyView","_getView","childView","_getChildViewOptions","addChildView","_updateIndices","increment","laterView","_proxyChildEvents","ChildViewClass","collectionView","buffer","elBuffer","createDocumentFragment","b","_insertBefore","_insertAfter","findPosition","before","ChildViewContainer","_ref2","shouldCheckEmpty","childViews","identity","_this6","childEventName","CompositeView","renderChildren","_isRendering","resetChildViewContainer","compositeView","$container","getChildViewContainer","containerView","$childViewContainer","container","childViewContainer","charAt","substr","MixinFromView","Behavior","proxyViewProperties","getEvents","behaviorEvents","behaviorHandler","behaviorTriggers","Application","_initRegion","_region","showView","getView","start","AppRouter","Router","appRoutes","controller","_getController","processAppRoutes","_processOnRoute","appRoute","route","_addAppRoute","routeName","routeArgs","onRoute","routePath","invert","routeNames","reverse","previousMarionette","noConflict","Object","VERSION"],"mappings":";;;;;;;;4UAWA,SAASA,GAAaC,EAAOC,EAAQC,GACnC,MAAOA,GAAUC,cAUZ,QAASC,GAAcC,GAAgB,IAAA,GAEtCC,GAAa,KAAOD,EAAME,QAAQC,EAAUT,GAC5CU,EAASC,EAAUC,KA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GAAWL,eAAiBsC,EAAMtC,GAClCK,GAAWwD,aAAevB,EAAMuB,GAChCxD,GAAWzE,UAAY0G,EAAM1G,GAC7ByE,GAAWP,iBAAmBwC,EAAMxC,GACpCO,GAAWkC,OAASA,EACpBlC,GAAWkD,eAAiBA,EAC5BlD,GAAWqC,UAAYA,EACvBrC,GAAW/E,cAAgBgH,EAAMhH,GACjC+E,GAAW1D,gBAAkBA,EAC7B0D,GAAW4B,UAAYA,EACvB5B,GAAW+B,WAAaA,EACxB/B,GAAW1C,kBAAoBA,EAE/B0C,GAAWC,aACXD,GAAWC,UAAUC,gBAAkBA,EAGvCF,GAAWsb,YAAcA,GACzBtb,GAAW4b,UAAYA,GACvB5b,GAAW6Q,SAAWA,GACtB7Q,GAAW+F,cAAgBA,EAC3B/F,GAAW2K,KAAOA,GAClB3K,GAAWqT,eAAiBA,GAC5BrT,GAAWka,cAAgBA,GAC3Bla,GAAWgb,SAAWA,GACtBhb,GAAW2M,OAASA,GACpB3M,GAAWiE,MAAQpF,EACnBmB,GAAW+c,OAASzX,EAGpBtF,GAAWyC,UAAW,EACtBzC,GAAW8B,SAAWA,GACtB9B,GAAWgd,QAAU7Y","file":"backbone.marionette.min.js","sourcesContent":["// Trigger Method\n// --------------\n\nimport _ from 'underscore';\nimport getOption from './get-option';\n\n// split the event name on the \":\"\nconst splitter = /(^|:)(\\w)/gi;\n\n// take the event section (\"section1:section2:section3\")\n// and turn it in to uppercase name onSection1Section2Section3\nfunction getEventName(match, prefix, eventName) {\n return eventName.toUpperCase();\n}\n\n// Trigger an event and/or a corresponding method name. Examples:\n//\n// `this.triggerMethod(\"foo\")` will trigger the \"foo\" event and\n// call the \"onFoo\" method.\n//\n// `this.triggerMethod(\"foo:bar\")` will trigger the \"foo:bar\" event and\n// call the \"onFooBar\" method.\nexport function triggerMethod(event, ...args) {\n // get the method name from the event name\n const methodName = 'on' + event.replace(splitter, getEventName);\n const method = getOption.call(this, methodName);\n let result;\n\n // call the onMethodName if it exists\n if (_.isFunction(method)) {\n // pass all args, except the event name\n result = method.apply(this, args);\n }\n\n // trigger the event\n this.trigger(event, ...args);\n\n return result;\n}\n\n// triggerMethodOn invokes triggerMethod on a specific context\n//\n// e.g. `Marionette.triggerMethodOn(view, 'show')`\n// will trigger a \"show\" event or invoke onShow the view.\nexport function triggerMethodOn(context, ...args) {\n const fnc = _.isFunction(context.triggerMethod) ? context.triggerMethod : triggerMethod;\n return fnc.apply(context, args);\n}\n","// DOM Refresh\n// -----------\n\nimport _ from 'underscore';\nimport { triggerMethodOn } from './trigger-method';\n\n// Trigger method on children unless a pure Backbone.View\nfunction triggerMethodChildren(view, event, shouldTrigger) {\n if (!view._getImmediateChildren) { return; }\n _.each(view._getImmediateChildren(), child => {\n if (!shouldTrigger(child)) { return; }\n triggerMethodOn(child, event, child);\n });\n}\n\nfunction shouldTriggerAttach(view) {\n return !view._isAttached;\n}\n\nfunction shouldAttach(view) {\n if (!shouldTriggerAttach(view)) { return false; }\n view._isAttached = true;\n return true;\n}\n\nfunction shouldTriggerDetach(view) {\n return view._isAttached;\n}\n\nfunction shouldDetach(view) {\n if (!shouldTriggerDetach(view)) { return false; }\n view._isAttached = false;\n return true;\n}\n\n// Monitor a view's state, propagating attach/detach events to children and firing dom:refresh\n// whenever a rendered view is attached or an attached view is rendered.\nfunction monitorViewEvents(view) {\n if (view._areViewEventsMonitored) { return; }\n\n view._areViewEventsMonitored = true;\n\n function handleBeforeAttach() {\n triggerMethodChildren(view, 'before:attach', shouldTriggerAttach);\n }\n\n function handleAttach() {\n triggerMethodChildren(view, 'attach', shouldAttach);\n triggerDOMRefresh();\n }\n\n function handleBeforeDetach() {\n triggerMethodChildren(view, 'before:detach', shouldTriggerDetach);\n }\n\n function handleDetach() {\n triggerMethodChildren(view, 'detach', shouldDetach);\n }\n\n function handleRender() {\n triggerDOMRefresh();\n }\n\n function triggerDOMRefresh() {\n if (view._isAttached && view._isRendered) {\n triggerMethodOn(view, 'dom:refresh', view);\n }\n }\n\n view.on({\n 'before:attach': handleBeforeAttach,\n 'attach': handleAttach,\n 'before:detach': handleBeforeDetach,\n 'detach': handleDetach,\n 'render': handleRender\n });\n}\n\nexport default monitorViewEvents;\n","// Bind Entity Events & Unbind Entity Events\n// -----------------------------------------\n//\n// These methods are used to bind/unbind a backbone \"entity\" (e.g. collection/model)\n// to methods on a target object.\n//\n// The first parameter, `target`, must have the Backbone.Events module mixed in.\n//\n// The second parameter is the `entity` (Backbone.Model, Backbone.Collection or\n// any object that has Backbone.Events mixed in) to bind the events from.\n//\n// The third parameter is a hash of { \"event:name\": \"eventHandler\" }\n// configuration. Multiple handlers can be separated by a space. A\n// function can be supplied instead of a string handler name.\n\nimport _ from 'underscore';\nimport MarionetteError from '../error';\n\n// Bind/unbind the event to handlers specified as a string of\n// handler names on the target object\nfunction bindFromStrings(target, entity, evt, methods, actionName) {\n const methodNames = methods.split(/\\s+/);\n\n _.each(methodNames, function(methodName) {\n const method = target[methodName];\n if (!method) {\n throw new MarionetteError(`Method \"${methodName}\" was configured as an event handler, but does not exist.`);\n }\n\n target[actionName](entity, evt, method);\n });\n}\n\n// generic looping function\nfunction iterateEvents(target, entity, bindings, actionName) {\n if (!entity || !bindings) { return; }\n\n // type-check bindings\n if (!_.isObject(bindings)) {\n throw new MarionetteError({\n message: 'Bindings must be an object.',\n url: 'marionette.functions.html#marionettebindevents'\n });\n }\n\n // iterate the bindings and bind/unbind them\n _.each(bindings, function(method, evt) {\n\n // allow for a list of method names as a string\n if (_.isString(method)) {\n bindFromStrings(target, entity, evt, method, actionName);\n return;\n }\n\n target[actionName](entity, evt, method);\n });\n}\n\nfunction bindEvents(entity, bindings) {\n iterateEvents(this, entity, bindings, 'listenTo');\n return this;\n}\n\nfunction unbindEvents(entity, bindings) {\n iterateEvents(this, entity, bindings, 'stopListening');\n return this;\n}\n\n// Export Public API\nexport {\n bindEvents,\n unbindEvents\n};\n","// Bind/Unbind Radio Requests\n// -----------------------------------------\n//\n// These methods are used to bind/unbind a backbone.radio request\n// to methods on a target object.\n//\n// The first parameter, `target`, will set the context of the reply method\n//\n// The second parameter is the `Radio.channel` to bind the reply to.\n//\n// The third parameter is a hash of { \"request:name\": \"replyHandler\" }\n// configuration. A function can be supplied instead of a string handler name.\n\nimport _ from 'underscore';\nimport normalizeMethods from './normalize-methods';\nimport MarionetteError from '../error';\n\nfunction iterateReplies(target, channel, bindings, actionName) {\n if (!channel || !bindings) { return; }\n\n // type-check bindings\n if (!_.isObject(bindings)) {\n throw new MarionetteError({\n message: 'Bindings must be an object.',\n url: 'marionette.functions.html#marionettebindrequests'\n });\n }\n\n const normalizedRadioRequests = normalizeMethods.call(target, bindings);\n\n channel[actionName](normalizedRadioRequests, target);\n}\n\nfunction bindRequests(channel, bindings) {\n iterateReplies(this, channel, bindings, 'reply');\n return this;\n}\n\nfunction unbindRequests(channel, bindings) {\n iterateReplies(this, channel, bindings, 'stopReplying');\n return this;\n}\n\nexport {\n bindRequests,\n unbindRequests\n};\n","import _ from 'underscore';\nimport _invoke from '../utils/invoke';\nimport { triggerMethod } from '../common/trigger-method';\nimport Marionette from '../backbone.marionette';\n\n// MixinOptions\n// - behaviors\n\n// Takes care of getting the behavior class\n// given options and a key.\n// If a user passes in options.behaviorClass\n// default to using that.\n// If a user passes in a Behavior Class directly, use that\n// Otherwise delegate the lookup to the users `behaviorsLookup` implementation.\nfunction getBehaviorClass(options, key) {\n if (options.behaviorClass) {\n return options.behaviorClass;\n //treat functions as a Behavior constructor\n } else if (_.isFunction(options)) {\n return options;\n }\n\n // behaviorsLookup can be either a flat object or a method\n if (_.isFunction(Marionette.Behaviors.behaviorsLookup)) {\n return Marionette.Behaviors.behaviorsLookup(options, key)[key];\n }\n\n return Marionette.Behaviors.behaviorsLookup[key];\n}\n\n// Iterate over the behaviors object, for each behavior\n// instantiate it and get its grouped behaviors.\n// This accepts a list of behaviors in either an object or array form\nfunction parseBehaviors(view, behaviors) {\n return _.chain(behaviors).map(function(options, key) {\n const BehaviorClass = getBehaviorClass(options, key);\n //if we're passed a class directly instead of an object\n const _options = options === BehaviorClass ? {} : options;\n const behavior = new BehaviorClass(_options, view);\n const nestedBehaviors = parseBehaviors(view, _.result(behavior, 'behaviors'));\n\n return [behavior].concat(nestedBehaviors);\n }).flatten().value();\n}\n\nexport default {\n _initBehaviors() {\n const behaviors = _.result(this, 'behaviors');\n\n // Behaviors defined on a view can be a flat object literal\n // or it can be a function that returns an object.\n this._behaviors = _.isObject(behaviors) ? parseBehaviors(this, behaviors) : {};\n },\n\n _getBehaviorTriggers() {\n const triggers = _invoke(this._behaviors, 'getTriggers');\n return _.extend({}, ...triggers);\n },\n\n _getBehaviorEvents() {\n const events = _invoke(this._behaviors, 'getEvents');\n return _.extend({}, ...events);\n },\n\n // proxy behavior $el to the view's $el.\n _proxyBehaviorViewProperties() {\n _invoke(this._behaviors, 'proxyViewProperties');\n },\n\n // delegate modelEvents and collectionEvents\n _delegateBehaviorEntityEvents() {\n _invoke(this._behaviors, 'delegateEntityEvents');\n },\n\n // undelegate modelEvents and collectionEvents\n _undelegateBehaviorEntityEvents() {\n _invoke(this._behaviors, 'undelegateEntityEvents');\n },\n\n _destroyBehaviors(args) {\n // Call destroy on each behavior after\n // destroying the view.\n // This unbinds event listeners\n // that behaviors have registered for.\n _invoke(this._behaviors, 'destroy', ...args);\n },\n\n _bindBehaviorUIElements() {\n _invoke(this._behaviors, 'bindUIElements');\n },\n\n _unbindBehaviorUIElements() {\n _invoke(this._behaviors, 'unbindUIElements');\n },\n\n _triggerEventOnBehaviors(...args) {\n const behaviors = this._behaviors;\n // Use good ol' for as this is a very hot function\n for (let i = 0, length = behaviors && behaviors.length; i < length; i++) {\n triggerMethod.apply(behaviors[i], args);\n }\n }\n};\n","import _ from 'underscore';\n\n// Borrow event splitter from Backbone\nconst delegateEventSplitter = /^(\\S+)\\s*(.*)$/;\n\nfunction uniqueName(eventName, selector) {\n return [eventName + _.uniqueId('.evt'), selector].join(' ');\n}\n\n// Set event name to be namespaced using a unique index\n// to generate a non colliding event namespace\n// http://api.jquery.com/event.namespace/\nconst getUniqueEventName = function(eventName) {\n const match = eventName.match(delegateEventSplitter);\n return uniqueName(match[1], match[2]);\n};\n\nexport default getUniqueEventName;\n","import _ from 'underscore';\nimport getUniqueEventName from '../utils/get-unique-event-name';\n\n// Internal method to create an event handler for a given `triggerDef` like\n// 'click:foo'\nfunction buildViewTrigger(view, triggerDef) {\n if (_.isString(triggerDef)) {\n triggerDef = {event: triggerDef};\n }\n\n const eventName = triggerDef.event;\n const shouldPreventDefault = triggerDef.preventDefault !== false;\n const shouldStopPropagation = triggerDef.stopPropagation !== false;\n\n return function(e) {\n if (shouldPreventDefault) {\n e.preventDefault();\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n\n view.triggerMethod(eventName, view);\n };\n}\n\nexport default {\n\n // Configure `triggers` to forward DOM events to view\n // events. `triggers: {\"click .foo\": \"do:foo\"}`\n _getViewTriggers(view, triggers) {\n // Configure the triggers, prevent default\n // action and stop propagation of DOM events\n return _.reduce(triggers, (events, value, key) => {\n key = getUniqueEventName(key);\n events[key] = buildViewTrigger(view, value);\n return events;\n }, {});\n }\n\n};\n","import { triggerMethodOn } from '../common/trigger-method';\n\nexport default function destroyBackboneView(view) {\n if (!view.supportsDestroyLifecycle) {\n triggerMethodOn(view, 'before:destroy', view);\n }\n\n const shouldTriggerDetach = !!view._isAttached;\n\n if (shouldTriggerDetach) {\n triggerMethodOn(view, 'before:detach', view);\n }\n\n view.remove();\n\n if (shouldTriggerDetach) {\n view._isAttached = false;\n triggerMethodOn(view, 'detach', view);\n }\n\n view._isDestroyed = true;\n\n if (!view.supportsDestroyLifecycle) {\n triggerMethodOn(view, 'destroy', view);\n }\n}\n","import MarionetteError from '../error';\n\n// Placeholder method to be extended by the user.\n// The method should define the object that stores the behaviors.\n// i.e.\n//\n// ```js\n// Marionette.Behaviors.behaviorsLookup: function() {\n// return App.Behaviors\n// }\n// ```\nexport default function behaviorsLookup() {\n throw new MarionetteError({\n message: 'You must define where your behaviors are stored.',\n url: 'marionette.behaviors.md#behaviorslookup'\n });\n}\n","// Add Feature flags here\n// e.g. 'class' => false\nconst FEATURES = {\n};\n\nfunction isEnabled(name) {\n return !!FEATURES[name];\n}\n\nfunction setEnabled(name, state) {\n return FEATURES[name] = state;\n}\n\nexport {\n FEATURES,\n setEnabled,\n isEnabled\n};\n","//Internal utility for creating context style global utils\nconst proxy = function(method) {\n return function(context, ...args) {\n return method.apply(context, args);\n };\n};\n\nexport default proxy;\n","// Marionette.extend\n// -----------------\n\nimport Backbone from 'backbone';\n\n// Borrow the Backbone `extend` method so we can use it as needed\nconst extend = Backbone.Model.extend;\n\nexport default extend;\n","/* global console */\n\nimport _ from 'underscore';\n\nimport Marionette from '../backbone.marionette';\n\nconst deprecate = function(message, test) {\n if (_.isObject(message)) {\n message = (\n message.prev + ' is going to be removed in the future. ' +\n 'Please use ' + message.next + ' instead.' +\n (message.url ? ' See: ' + message.url : '')\n );\n }\n\n if (!Marionette.DEV_MODE) {\n return;\n }\n\n if ((test === undefined || !test) && !deprecate._cache[message]) {\n deprecate._warn('Deprecation warning: ' + message);\n deprecate._cache[message] = true;\n }\n};\n\ndeprecate._console = typeof console !== 'undefined' ? console : {};\ndeprecate._warn = function() {\n const warn = deprecate._console.warn || deprecate._console.log || _.noop;\n return warn.apply(deprecate._console, arguments);\n};\ndeprecate._cache = {};\n\nexport default deprecate;\n","// Marionette.isNodeAttached\n// -------------------------\n\nimport Backbone from 'backbone';\n\n// Determine if `el` is a child of the document\nconst isNodeAttached = function(el) {\n return Backbone.$.contains(document.documentElement, el);\n};\n\nexport default isNodeAttached;\n","import _ from 'underscore';\n\n// Merge `keys` from `options` onto `this`\nconst mergeOptions = function(options, keys) {\n if (!options) { return; }\n _.extend(this, _.pick(options, keys));\n};\n\nexport default mergeOptions;\n","// Marionette.getOption\n// --------------------\n\n// Retrieve an object, function or other value from the\n// object or its `options`, with `options` taking precedence.\nconst getOption = function(optionName) {\n if (!optionName) { return; }\n if (this.options && (this.options[optionName] !== undefined)) {\n return this.options[optionName];\n } else {\n return this[optionName];\n }\n};\n\nexport default getOption;\n","import _ from 'underscore';\n\n// Marionette.normalizeMethods\n// ----------------------\n\n// Pass in a mapping of events => functions or function names\n// and return a mapping of events => functions\nconst normalizeMethods = function(hash) {\n return _.reduce(hash, (normalizedHash, method, name) => {\n if (!_.isFunction(method)) {\n method = this[method];\n }\n if (method) {\n normalizedHash[name] = method;\n }\n return normalizedHash;\n }, {});\n};\n\nexport default normalizeMethods;\n","// Error\n// -----\n\nimport _ from 'underscore';\nimport extend from './utils/extend';\nimport {version} from '../package.json';\n\nconst errorProps = ['description', 'fileName', 'lineNumber', 'name', 'message', 'number'];\n\nconst MarionetteError = extend.call(Error, {\n urlRoot: `http://marionettejs.com/docs/v${version}/`,\n\n constructor(message, options) {\n if (_.isObject(message)) {\n options = message;\n message = options.message;\n } else if (!options) {\n options = {};\n }\n\n const error = Error.call(this, message);\n _.extend(this, _.pick(error, errorProps), _.pick(options, errorProps));\n\n this.captureStackTrace();\n\n if (options.url) {\n this.url = this.urlRoot + options.url;\n }\n },\n\n captureStackTrace() {\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, MarionetteError);\n }\n },\n\n toString() {\n return this.name + ': ' + this.message + (this.url ? ' See: ' + this.url : '');\n }\n});\n\nMarionetteError.extend = extend;\n\nexport default MarionetteError;\n","import _ from 'underscore';\n\n// Internal utility for setting options consistently across Mn\nconst setOptions = function(...args) {\n this.options = _.extend({}, _.result(this, 'options'), ...args);\n};\n\nexport default setOptions;\n","import _setOptions from '../utils/set-options';\nimport getOption from '../common/get-option';\nimport mergeOptions from '../common/merge-options';\nimport normalizeMethods from '../common/normalize-methods';\nimport {\n bindEvents,\n unbindEvents\n} from '../common/bind-events';\n\nexport default {\n\n // Imports the \"normalizeMethods\" to transform hashes of\n // events=>function references/names to a hash of events=>function references\n normalizeMethods: normalizeMethods,\n\n _setOptions: _setOptions,\n\n // A handy way to merge passed-in options onto the instance\n mergeOptions: mergeOptions,\n\n // Enable getting options from this or this.options by name.\n getOption: getOption,\n\n // Enable binding view's events from another entity.\n bindEvents: bindEvents,\n\n // Enable unbinding view's events from another entity.\n unbindEvents: unbindEvents\n};\n","import _ from 'underscore';\nimport Radio from 'backbone.radio';\n\nimport {\n bindRequests,\n unbindRequests\n} from '../common/bind-requests';\n\nimport {\n bindEvents,\n unbindEvents\n} from '../common/bind-events';\n\nimport MarionetteError from '../error';\n\n// MixinOptions\n// - channelName\n// - radioEvents\n// - radioRequests\n\nexport default {\n\n _initRadio() {\n const channelName = _.result(this, 'channelName');\n\n if (!channelName) {\n return;\n }\n\n /* istanbul ignore next */\n if (!Radio) {\n throw new MarionetteError({\n name: 'BackboneRadioMissing',\n message: 'The dependency \"backbone.radio\" is missing.'\n });\n }\n\n const channel = this._channel = Radio.channel(channelName);\n\n const radioEvents = _.result(this, 'radioEvents');\n this.bindEvents(channel, radioEvents);\n\n const radioRequests = _.result(this, 'radioRequests');\n this.bindRequests(channel, radioRequests);\n\n this.on('destroy', this._destroyRadio);\n },\n\n _destroyRadio() {\n this._channel.stopReplying(null, null, this);\n },\n\n getChannel() {\n return this._channel;\n },\n\n // Proxy `bindEvents`\n bindEvents: bindEvents,\n\n // Proxy `unbindEvents`\n unbindEvents: unbindEvents,\n\n // Proxy `bindRequests`\n bindRequests: bindRequests,\n\n // Proxy `unbindRequests`\n unbindRequests: unbindRequests\n\n};\n","// Object\n// ------\n\nimport _ from 'underscore';\nimport Backbone from 'backbone';\nimport extend from './utils/extend';\nimport { triggerMethod } from './common/trigger-method';\nimport CommonMixin from './mixins/common';\nimport RadioMixin from './mixins/radio';\n\nconst ClassOptions = [\n 'channelName',\n 'radioEvents',\n 'radioRequests'\n];\n\n// A Base Class that other Classes should descend from.\n// Object borrows many conventions and utilities from Backbone.\nconst MarionetteObject = function(options) {\n this._setOptions(options);\n this.mergeOptions(options, ClassOptions);\n this.cid = _.uniqueId(this.cidPrefix);\n this._initRadio();\n this.initialize.apply(this, arguments);\n};\n\nMarionetteObject.extend = extend;\n\n// Object Methods\n// --------------\n\n// Ensure it can trigger events with Backbone.Events\n_.extend(MarionetteObject.prototype, Backbone.Events, CommonMixin, RadioMixin, {\n cidPrefix: 'mno',\n\n // for parity with Marionette.AbstractView lifecyle\n _isDestroyed: false,\n\n isDestroyed() {\n return this._isDestroyed;\n },\n\n //this is a noop method intended to be overridden by classes that extend from this base\n initialize() {},\n\n destroy(...args) {\n if (this._isDestroyed) { return this; }\n\n this.triggerMethod('before:destroy', this, ...args);\n\n this._isDestroyed = true;\n this.triggerMethod('destroy', this, ...args);\n this.stopListening();\n\n return this;\n },\n\n triggerMethod: triggerMethod\n});\n\nexport default MarionetteObject;\n","// Template Cache\n// --------------\n\nimport _ from 'underscore';\nimport Backbone from 'backbone';\nimport MarionetteError from './error';\n\n// Manage templates stored in `<script>` blocks,\n// caching them for faster access.\nconst TemplateCache = function(templateId) {\n this.templateId = templateId;\n};\n\n// TemplateCache object-level methods. Manage the template\n// caches from these method calls instead of creating\n// your own TemplateCache instances\n_.extend(TemplateCache, {\n templateCaches: {},\n\n // Get the specified template by id. Either\n // retrieves the cached version, or loads it\n // from the DOM.\n get(templateId, options) {\n let cachedTemplate = this.templateCaches[templateId];\n\n if (!cachedTemplate) {\n cachedTemplate = new TemplateCache(templateId);\n this.templateCaches[templateId] = cachedTemplate;\n }\n\n return cachedTemplate.load(options);\n },\n\n // Clear templates from the cache. If no arguments\n // are specified, clears all templates:\n // `clear()`\n //\n // If arguments are specified, clears each of the\n // specified templates from the cache:\n // `clear(\"#t1\", \"#t2\", \"...\")`\n clear(...args) {\n let i;\n const length = args.length;\n\n if (length > 0) {\n for (i = 0; i < length; i++) {\n delete this.templateCaches[args[i]];\n }\n } else {\n this.templateCaches = {};\n }\n }\n});\n\n// TemplateCache instance methods, allowing each\n// template cache object to manage its own state\n// and know whether or not it has been loaded\n_.extend(TemplateCache.prototype, {\n\n // Internal method to load the template\n load(options) {\n // Guard clause to prevent loading this template more than once\n if (this.compiledTemplate) {\n return this.compiledTemplate;\n }\n\n // Load the template and compile it\n const template = this.loadTemplate(this.templateId, options);\n this.compiledTemplate = this.compileTemplate(template, options);\n\n return this.compiledTemplate;\n },\n\n // Load a template from the DOM, by default. Override\n // this method to provide your own template retrieval\n // For asynchronous loading with AMD/RequireJS, consider\n // using a template-loader plugin as described here:\n // https://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs\n loadTemplate(templateId, options) {\n const $template = Backbone.$(templateId);\n\n if (!$template.length) {\n throw new MarionetteError({\n name: 'NoTemplateError',\n message: `Could not find template: \"${templateId}\"`\n });\n }\n return $template.html();\n },\n\n // Pre-compile the template before caching it. Override\n // this method if you do not need to pre-compile a template\n // (JST / RequireJS for example) or if you want to change\n // the template engine used (Handebars, etc).\n compileTemplate(rawTemplate, options) {\n return _.template(rawTemplate, options);\n }\n});\n\nexport default TemplateCache;\n","// Implementation of the invoke method (http://underscorejs.org/#invoke) with support for\n// lodash v3, v4, and underscore.js\nimport _ from 'underscore';\n\nexport default _.invokeMap || _.invoke;\n","import _ from 'underscore';\n\nimport {\n bindEvents,\n unbindEvents\n} from '../common/bind-events';\n\n// MixinOptions\n// - collectionEvents\n// - modelEvents\n\nexport default {\n // Handle `modelEvents`, and `collectionEvents` configuration\n _delegateEntityEvents(model, collection) {\n this._undelegateEntityEvents(model, collection);\n\n const modelEvents = _.result(this, 'modelEvents');\n bindEvents.call(this, model, modelEvents);\n\n const collectionEvents = _.result(this, 'collectionEvents');\n bindEvents.call(this, collection, collectionEvents);\n },\n\n _undelegateEntityEvents(model, collection) {\n const modelEvents = _.result(this, 'modelEvents');\n unbindEvents.call(this, model, modelEvents);\n\n const collectionEvents = _.result(this, 'collectionEvents');\n unbindEvents.call(this, collection, collectionEvents);\n }\n};\n","import _ from 'underscore';\n// allows for the use of the @ui. syntax within\n// a given key for triggers and events\n// swaps the @ui with the associated selector.\n// Returns a new, non-mutated, parsed events hash.\nconst normalizeUIKeys = function(hash, ui) {\n return _.reduce(hash, (memo, val, key) => {\n const normalizedKey = normalizeUIString(key, ui);\n memo[normalizedKey] = val;\n return memo;\n }, {});\n};\n\n// utility method for parsing @ui. syntax strings\n// into associated selector\nconst normalizeUIString = function(uiString, ui) {\n return uiString.replace(/@ui\\.[a-zA-Z-_$0-9]*/g, (r) => {\n return ui[r.slice(4)];\n });\n};\n\n// allows for the use of the @ui. syntax within\n// a given value for regions\n// swaps the @ui with the associated selector\nconst normalizeUIValues = function(hash, ui, properties) {\n _.each(hash, (val, key) => {\n if (_.isString(val)) {\n hash[key] = normalizeUIString(val, ui);\n } else if (_.isObject(val) && _.isArray(properties)) {\n _.extend(val, normalizeUIValues(_.pick(val, properties), ui));\n /* Value is an object, and we got an array of embedded property names to normalize. */\n _.each(properties, (property) => {\n const propertyVal = val[property];\n if (_.isString(propertyVal)) {\n val[property] = normalizeUIString(propertyVal, ui);\n }\n });\n }\n });\n return hash;\n};\n\nexport default {\n\n // normalize the keys of passed hash with the views `ui` selectors.\n // `{\"@ui.foo\": \"bar\"}`\n normalizeUIKeys(hash) {\n const uiBindings = this._getUIBindings();\n return normalizeUIKeys(hash, uiBindings);\n },\n\n // normalize the values of passed hash with the views `ui` selectors.\n // `{foo: \"@ui.bar\"}`\n normalizeUIValues(hash, properties) {\n const uiBindings = this._getUIBindings();\n return normalizeUIValues(hash, uiBindings, properties);\n },\n\n _getUIBindings() {\n const uiBindings = _.result(this, '_uiBindings');\n const ui = _.result(this, 'ui');\n return uiBindings || ui;\n },\n\n // This method binds the elements specified in the \"ui\" hash inside the view's code with\n // the associated jQuery selectors.\n _bindUIElements() {\n if (!this.ui) { return; }\n\n // store the ui hash in _uiBindings so they can be reset later\n // and so re-rendering the view will be able to find the bindings\n if (!this._uiBindings) {\n this._uiBindings = this.ui;\n }\n\n // get the bindings result, as a function or otherwise\n const bindings = _.result(this, '_uiBindings');\n\n // empty the ui so we don't have anything to start with\n this._ui = {};\n\n // bind each of the selectors\n _.each(bindings, (selector, key) => {\n this._ui[key] = this.$(selector);\n });\n\n this.ui = this._ui;\n },\n\n _unbindUIElements() {\n if (!this.ui || !this._uiBindings) { return; }\n\n // delete all of the existing ui bindings\n _.each(this.ui, ($el, name) => {\n delete this.ui[name];\n });\n\n // reset the ui element to the original bindings configuration\n this.ui = this._uiBindings;\n delete this._uiBindings;\n delete this._ui;\n },\n\n _getUI(name) {\n return this._ui[name];\n }\n};\n","// ViewMixin\n// ---------\n\nimport Backbone from 'backbone';\nimport _ from 'underscore';\nimport isNodeAttached from '../common/is-node-attached';\nimport { triggerMethod } from '../common/trigger-method';\nimport BehaviorsMixin from './behaviors';\nimport CommonMixin from './common';\nimport DelegateEntityEventsMixin from './delegate-entity-events';\nimport TriggersMixin from './triggers';\nimport UIMixin from './ui';\nimport View from '../view';\nimport MarionetteError from '../error';\n\n// MixinOptions\n// - behaviors\n// - childViewEventPrefix\n// - childViewEvents\n// - childViewTriggers\n// - collectionEvents\n// - modelEvents\n// - triggers\n// - ui\n\n\nconst ViewMixin = {\n supportsRenderLifecycle: true,\n supportsDestroyLifecycle: true,\n\n _isDestroyed: false,\n\n isDestroyed() {\n return !!this._isDestroyed;\n },\n\n _isRendered: false,\n\n isRendered() {\n return !!this._isRendered;\n },\n\n _isAttached: false,\n\n isAttached() {\n return !!this._isAttached;\n },\n\n // Overriding Backbone.View's `setElement` to handle\n // if an el was previously defined. If so, the view might be\n // rendered or attached on setElement.\n setElement() {\n const hasEl = !!this.el;\n\n Backbone.View.prototype.setElement.apply(this, arguments);\n\n if (hasEl) {\n this._isRendered = !!this.$el.length;\n this._isAttached = isNodeAttached(this.el);\n }\n\n return this;\n },\n\n // Overriding Backbone.View's `delegateEvents` to handle\n // `events` and `triggers`\n delegateEvents(eventsArg) {\n\n this._proxyBehaviorViewProperties();\n this._buildEventProxies();\n\n const viewEvents = this._getEvents(eventsArg);\n\n if (typeof eventsArg === 'undefined') {\n this.events = viewEvents;\n }\n\n const combinedEvents = _.extend({},\n this._getBehaviorEvents(),\n viewEvents,\n this._getBehaviorTriggers(),\n this.getTriggers()\n );\n\n Backbone.View.prototype.delegateEvents.call(this, combinedEvents);\n\n return this;\n },\n\n _getEvents(eventsArg) {\n const events = eventsArg || this.events;\n\n if (_.isFunction(events)) {\n return this.normalizeUIKeys(events.call(this));\n }\n\n return this.normalizeUIKeys(events);\n },\n\n // Configure `triggers` to forward DOM events to view\n // events. `triggers: {\"click .foo\": \"do:foo\"}`\n getTriggers() {\n if (!this.triggers) { return; }\n\n // Allow `triggers` to be configured as a function\n const triggers = this.normalizeUIKeys(_.result(this, 'triggers'));\n\n // Configure the triggers, prevent default\n // action and stop propagation of DOM events\n return this._getViewTriggers(this, triggers);\n },\n\n // Handle `modelEvents`, and `collectionEvents` configuration\n delegateEntityEvents() {\n this._delegateEntityEvents(this.model, this.collection);\n\n // bind each behaviors model and collection events\n this._delegateBehaviorEntityEvents();\n\n return this;\n },\n\n // Handle unbinding `modelEvents`, and `collectionEvents` configuration\n undelegateEntityEvents() {\n this._undelegateEntityEvents(this.model, this.collection);\n\n // unbind each behaviors model and collection events\n this._undelegateBehaviorEntityEvents();\n\n return this;\n },\n\n // Internal helper method to verify whether the view hasn't been destroyed\n _ensureViewIsIntact() {\n if (this._isDestroyed) {\n throw new MarionetteError({\n name: 'ViewDestroyedError',\n message: `View (cid: \"${this.cid}\") has already been destroyed and cannot be used.`\n });\n }\n },\n\n // Handle destroying the view and its children.\n destroy(...args) {\n if (this._isDestroyed) { return this; }\n const shouldTriggerDetach = !!this._isAttached;\n\n this.triggerMethod('before:destroy', this, ...args);\n if (shouldTriggerDetach) {\n this.triggerMethod('before:detach', this);\n }\n\n // unbind UI elements\n this.unbindUIElements();\n\n // remove the view from the DOM\n // https://github.com/jashkenas/backbone/blob/1.2.3/backbone.js#L1235\n this._removeElement();\n\n if (shouldTriggerDetach) {\n this._isAttached = false;\n this.triggerMethod('detach', this);\n }\n\n // remove children after the remove to prevent extra paints\n this._removeChildren();\n\n this._destroyBehaviors(args);\n\n this._isDestroyed = true;\n this._isRendered = false;\n this.triggerMethod('destroy', this, ...args);\n\n this.stopListening();\n\n return this;\n },\n\n bindUIElements() {\n this._bindUIElements();\n this._bindBehaviorUIElements();\n\n return this;\n },\n\n // This method unbinds the elements specified in the \"ui\" hash\n unbindUIElements() {\n this._unbindUIElements();\n this._unbindBehaviorUIElements();\n\n return this;\n },\n\n getUI(name) {\n this._ensureViewIsIntact();\n return this._getUI(name);\n },\n\n // used as the prefix for child view events\n // that are forwarded through the layoutview\n childViewEventPrefix: 'childview',\n\n // import the `triggerMethod` to trigger events with corresponding\n // methods if the method exists\n triggerMethod(...args) {\n const ret = triggerMethod.apply(this, args);\n\n this._triggerEventOnBehaviors(...args);\n this._triggerEventOnParentLayout(...args);\n\n return ret;\n },\n\n // Cache `childViewEvents` and `childViewTriggers`\n _buildEventProxies() {\n this._childViewEvents = _.result(this, 'childViewEvents');\n this._childViewTriggers = _.result(this, 'childViewTriggers');\n },\n\n _triggerEventOnParentLayout(eventName, ...args) {\n const layoutView = this._parentView();\n if (!layoutView) {\n return;\n }\n\n // invoke triggerMethod on parent view\n const eventPrefix = _.result(layoutView, 'childViewEventPrefix');\n const prefixedEventName = eventPrefix + ':' + eventName;\n\n layoutView.triggerMethod(prefixedEventName, ...args);\n\n // use the parent view's childViewEvents handler\n const childViewEvents = layoutView.normalizeMethods(layoutView._childViewEvents);\n\n if (!!childViewEvents && _.isFunction(childViewEvents[eventName])) {\n childViewEvents[eventName].apply(layoutView, args);\n }\n\n // use the parent view's proxyEvent handlers\n const childViewTriggers = layoutView._childViewTriggers;\n\n // Call the event with the proxy name on the parent layout\n if (childViewTriggers && _.isString(childViewTriggers[eventName])) {\n layoutView.triggerMethod(childViewTriggers[eventName], ...args);\n }\n },\n\n // Walk the _parent tree until we find a view (if one exists).\n // Returns the parent view hierarchically closest to this view.\n _parentView() {\n let parent = this._parent;\n\n while (parent) {\n if (parent instanceof View) {\n return parent;\n }\n parent = parent._parent;\n }\n }\n};\n\n_.extend(ViewMixin, BehaviorsMixin, CommonMixin, DelegateEntityEventsMixin, TriggersMixin, UIMixin);\n\nexport default ViewMixin;\n","// Region\n// ------\n\nimport _ from 'underscore';\nimport Backbone from 'backbone';\nimport destroyBackboneView from './utils/destroy-backbone-view';\nimport monitorViewEvents from './common/monitor-view-events';\nimport isNodeAttached from './common/is-node-attached';\nimport { triggerMethodOn } from './common/trigger-method';\nimport MarionetteObject from './object';\nimport MarionetteError from './error';\n\nconst ClassOptions = [\n 'allowMissingEl',\n 'parentEl',\n 'replaceElement'\n];\n\nconst Region = MarionetteObject.extend({\n cidPrefix: 'mnr',\n replaceElement: false,\n _isReplaced: false,\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n // getOption necessary because options.el may be passed as undefined\n this._initEl = this.el = this.getOption('el');\n\n // Handle when this.el is passed in as a $ wrapped element.\n this.el = this.el instanceof Backbone.$ ? this.el[0] : this.el;\n\n if (!this.el) {\n throw new MarionetteError({\n name: 'NoElError',\n message: 'An \"el\" must be specified for a region.'\n });\n }\n\n this.$el = this.getEl(this.el);\n MarionetteObject.call(this, options);\n },\n\n // Displays a backbone view instance inside of the region. Handles calling the `render`\n // method for you. Reads content directly from the `el` attribute. The `preventDestroy`\n // option can be used to prevent a view from the old view being destroyed on show.\n show(view, options) {\n if (!this._ensureElement(options)) {\n return;\n }\n this._ensureView(view);\n if (view === this.currentView) { return this; }\n\n this.triggerMethod('before:show', this, view, options);\n\n monitorViewEvents(view);\n\n this.empty(options);\n\n // We need to listen for if a view is destroyed in a way other than through the region.\n // If this happens we need to remove the reference to the currentView since once a view\n // has been destroyed we can not reuse it.\n view.on('destroy', this.empty, this);\n\n // Make this region the view's parent.\n // It's important that this parent binding happens before rendering so that any events\n // the child may trigger during render can also be triggered on the child's ancestor views.\n view._parent = this;\n\n this._renderView(view);\n\n this._attachView(view, options);\n\n this.triggerMethod('show', this, view, options);\n return this;\n },\n\n _renderView(view) {\n if (view._isRendered) {\n return;\n }\n\n if (!view.supportsRenderLifecycle) {\n triggerMethodOn(view, 'before:render', view);\n }\n\n view.render();\n\n if (!view.supportsRenderLifecycle) {\n view._isRendered = true;\n triggerMethodOn(view, 'render', view);\n }\n },\n\n _attachView(view, options = {}) {\n const shouldTriggerAttach = !view._isAttached && isNodeAttached(this.el);\n const shouldReplaceEl = typeof options.replaceElement === 'undefined' ? !!_.result(this, 'replaceElement') : !!options.replaceElement;\n\n if (shouldTriggerAttach) {\n triggerMethodOn(view, 'before:attach', view);\n }\n\n this.attachHtml(view, shouldReplaceEl);\n\n if (shouldTriggerAttach) {\n view._isAttached = true;\n triggerMethodOn(view, 'attach', view);\n }\n\n this.currentView = view;\n },\n\n _ensureElement(options = {}) {\n if (!_.isObject(this.el)) {\n this.$el = this.getEl(this.el);\n this.el = this.$el[0];\n }\n\n if (!this.$el || this.$el.length === 0) {\n const allowMissingEl = typeof options.allowMissingEl === 'undefined' ? !!_.result(this, 'allowMissingEl') : !!options.allowMissingEl;\n\n if (allowMissingEl) {\n return false;\n } else {\n throw new MarionetteError(`An \"el\" must exist in DOM for this region ${this.cid}`);\n }\n }\n return true;\n },\n\n _ensureView(view) {\n if (!view) {\n throw new MarionetteError({\n name: 'ViewNotValid',\n message: 'The view passed is undefined and therefore invalid. You must pass a view instance to show.'\n });\n }\n\n if (view._isDestroyed) {\n throw new MarionetteError({\n name: 'ViewDestroyedError',\n message: `View (cid: \"${view.cid}\") has already been destroyed and cannot be used.`\n });\n }\n },\n\n // Override this method to change how the region finds the DOM element that it manages. Return\n // a jQuery selector object scoped to a provided parent el or the document if none exists.\n getEl(el) {\n return Backbone.$(el, _.result(this, 'parentEl'));\n },\n\n _replaceEl(view) {\n // always restore the el to ensure the regions el is present before replacing\n this._restoreEl();\n\n const parent = this.el.parentNode;\n\n parent.replaceChild(view.el, this.el);\n this._isReplaced = true;\n },\n\n // Restore the region's element in the DOM.\n _restoreEl() {\n // There is nothing to replace\n if (!this._isReplaced) {\n return;\n }\n\n const view = this.currentView;\n\n if (!view) {\n return;\n }\n\n const parent = view.el.parentNode;\n\n if (!parent) {\n return;\n }\n\n parent.replaceChild(this.el, view.el);\n this._isReplaced = false;\n },\n\n // Check to see if the region's el was replaced.\n isReplaced() {\n return !!this._isReplaced;\n },\n\n // Override this method to change how the new view is appended to the `$el` that the\n // region is managing\n attachHtml(view, shouldReplace) {\n if (shouldReplace) {\n // replace the region's node with the view's node\n this._replaceEl(view);\n } else {\n this.el.appendChild(view.el);\n }\n },\n\n // Destroy the current view, if there is one. If there is no current view, it does\n // nothing and returns immediately.\n empty(options = { allowMissingEl: true }) {\n const view = this.currentView;\n\n // If there is no view in the region we should only detach current html\n if (!view) {\n if (this._ensureElement(options)) {\n this.detachHtml();\n }\n return this;\n }\n\n view.off('destroy', this.empty, this);\n this.triggerMethod('before:empty', this, view);\n\n this._restoreEl();\n\n delete this.currentView;\n\n if (!view._isDestroyed) {\n this._removeView(view, options);\n delete view._parent;\n }\n\n this.triggerMethod('empty', this, view);\n return this;\n },\n\n _removeView(view, {preventDestroy} = {}) {\n const shouldPreventDestroy = !!preventDestroy;\n\n if (shouldPreventDestroy) {\n this._detachView(view);\n return;\n }\n\n if (view.destroy) {\n view.destroy();\n } else {\n destroyBackboneView(view);\n }\n },\n\n _detachView(view) {\n const shouldTriggerDetach = !!view._isAttached;\n if (shouldTriggerDetach) {\n triggerMethodOn(view, 'before:detach', view);\n }\n\n this.detachHtml();\n\n if (shouldTriggerDetach) {\n view._isAttached = false;\n triggerMethodOn(view, 'detach', view);\n }\n },\n\n // Override this method to change how the region detaches current content\n detachHtml() {\n this.$el.contents().detach();\n },\n\n // Checks whether a view is currently present within the region. Returns `true` if there is\n // and `false` if no view is present.\n hasView() {\n return !!this.currentView;\n },\n\n // Reset the region by destroying any existing view and clearing out the cached `$el`.\n // The next time a view is shown via this region, the region will re-query the DOM for\n // the region's `el`.\n reset(options) {\n this.empty(options);\n\n if (this.$el) {\n this.el = this._initEl;\n }\n\n delete this.$el;\n return this;\n },\n\n destroy(options) {\n this.reset(options);\n return MarionetteObject.prototype.destroy.apply(this, arguments);\n }\n});\n\nexport default Region;\n","import _ from 'underscore';\nimport _invoke from '../utils/invoke';\nimport Region from '../region';\nimport MarionetteError from '../error';\n\n// MixinOptions\n// - regions\n// - regionClass\n\nexport default {\n regionClass: Region,\n\n // Internal method to initialize the regions that have been defined in a\n // `regions` attribute on this View.\n _initRegions() {\n\n // init regions hash\n this.regions = this.regions || {};\n this._regions = {};\n\n this.addRegions(_.result(this, 'regions'));\n },\n\n // Internal method to re-initialize all of the regions by updating\n // the `el` that they point to\n _reInitRegions() {\n _invoke(this._regions, 'reset');\n },\n\n // Add a single region, by name, to the View\n addRegion(name, definition) {\n const regions = {};\n regions[name] = definition;\n return this.addRegions(regions)[name];\n },\n\n // Add multiple regions as a {name: definition, name2: def2} object literal\n addRegions(regions) {\n // If there's nothing to add, stop here.\n if (_.isEmpty(regions)) {\n return;\n }\n\n // Normalize region selectors hash to allow\n // a user to use the @ui. syntax.\n regions = this.normalizeUIValues(regions, ['selector', 'el']);\n\n // Add the regions definitions to the regions property\n this.regions = _.extend({}, this.regions, regions);\n\n return this._addRegions(regions);\n },\n\n // internal method to build and add regions\n _addRegions(regionDefinitions) {\n return _.reduce(regionDefinitions, (regions, definition, name) => {\n regions[name] = this._buildRegion(definition);\n this._addRegion(regions[name], name);\n return regions;\n }, {});\n },\n\n // return the region instance from the definition\n _buildRegion(definition) {\n if (definition instanceof Region) {\n return definition;\n }\n\n return this._buildRegionFromDefinition(definition);\n },\n\n _buildRegionFromDefinition(definition) {\n if (_.isString(definition)) {\n return this._buildRegionFromObject({el: definition});\n }\n\n if (_.isFunction(definition)) {\n return this._buildRegionFromRegionClass(definition);\n }\n\n if (_.isObject(definition)) {\n return this._buildRegionFromObject(definition);\n }\n\n throw new MarionetteError({\n message: 'Improper region configuration type.',\n url: 'marionette.region.html#region-configuration-types'\n });\n },\n\n _buildRegionFromObject(definition) {\n const RegionClass = definition.regionClass || this.regionClass;\n\n const options = _.omit(definition, 'regionClass');\n\n _.defaults(options, {\n el: definition.selector,\n parentEl: _.partial(_.result, this, 'el')\n });\n\n return new RegionClass(options);\n },\n\n // Build the region directly from a given `RegionClass`\n _buildRegionFromRegionClass(RegionClass) {\n return new RegionClass({\n parentEl: _.partial(_.result, this, 'el')\n });\n },\n\n _addRegion(region, name) {\n this.triggerMethod('before:add:region', this, name, region);\n\n region._parent = this;\n\n this._regions[name] = region;\n\n this.triggerMethod('add:region', this, name, region);\n },\n\n // Remove a single region from the View, by name\n removeRegion(name) {\n const region = this._regions[name];\n\n this._removeRegion(region, name);\n\n return region;\n },\n\n // Remove all regions from the View\n removeRegions() {\n const regions = this.getRegions();\n\n _.each(this._regions, _.bind(this._removeRegion, this));\n\n return regions;\n },\n\n _removeRegion(region, name) {\n this.triggerMethod('before:remove:region', this, name, region);\n\n region.empty();\n region.stopListening();\n\n delete this.regions[name];\n delete this._regions[name];\n\n this.triggerMethod('remove:region', this, name, region);\n },\n\n // Empty all regions in the region manager, but\n // leave them attached\n emptyRegions() {\n const regions = this.getRegions();\n _invoke(regions, 'empty');\n return regions;\n },\n\n // Checks to see if view contains region\n // Accepts the region name\n // hasRegion('main')\n hasRegion(name) {\n return !!this.getRegion(name);\n },\n\n // Provides access to regions\n // Accepts the region name\n // getRegion('main')\n getRegion(name) {\n return this._regions[name];\n },\n\n // Get all regions\n getRegions() {\n return _.clone(this._regions);\n },\n\n showChildView(name, view, ...args) {\n const region = this.getRegion(name);\n return region.show(view, ...args);\n },\n\n getChildView(name) {\n return this.getRegion(name).currentView;\n }\n\n};\n","// Renderer\n// --------\n\nimport _ from 'underscore';\nimport MarionetteError from '../error';\nimport TemplateCache from '../template-cache';\n\n// Render a template with data by passing in the template\n// selector and the data to render.\nconst Renderer = {\n\n // Render a template with data. The `template` parameter is\n // passed to the `TemplateCache` object to retrieve the\n // template function. Override this method to provide your own\n // custom rendering and template handling for all of Marionette.\n render(template, data) {\n if (!template) {\n throw new MarionetteError({\n name: 'TemplateNotFoundError',\n message: 'Cannot render the template since its false, null or undefined.'\n });\n }\n\n const templateFunc = _.isFunction(template) ? template : TemplateCache.get(template);\n\n return templateFunc(data);\n }\n};\n\nexport default Renderer;\n","// View\n// ---------\n\nimport _ from 'underscore';\nimport Backbone from 'backbone';\nimport monitorViewEvents from './common/monitor-view-events';\nimport ViewMixin from './mixins/view';\nimport RegionsMixin from './mixins/regions';\nimport Renderer from './config/renderer';\n\nconst ClassOptions = [\n 'behaviors',\n 'childViewEventPrefix',\n 'childViewEvents',\n 'childViewTriggers',\n 'collectionEvents',\n 'events',\n 'modelEvents',\n 'regionClass',\n 'regions',\n 'template',\n 'templateContext',\n 'triggers',\n 'ui'\n];\n\n// The standard view. Includes view events, automatic rendering\n// of Underscore templates, nested views, and more.\nconst View = Backbone.View.extend({\n\n constructor(options) {\n this.render = _.bind(this.render, this);\n\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n monitorViewEvents(this);\n\n this._initBehaviors();\n this._initRegions();\n\n const args = Array.prototype.slice.call(arguments);\n args[0] = this.options;\n Backbone.View.prototype.constructor.apply(this, args);\n\n this.delegateEntityEvents();\n },\n\n // Serialize the view's model *or* collection, if\n // it exists, for the template\n serializeData() {\n if (!this.model && !this.collection) {\n return {};\n }\n\n // If we have a model, we serialize that\n if (this.model) {\n return this.serializeModel();\n }\n\n // Otherwise, we serialize the collection,\n // making it available under the `items` property\n return {\n items: this.serializeCollection()\n };\n },\n\n // Prepares the special `model` property of a view\n // for being displayed in the template. By default\n // we simply clone the attributes. Override this if\n // you need a custom transformation for your view's model\n serializeModel() {\n if (!this.model) { return {}; }\n return _.clone(this.model.attributes);\n },\n\n // Serialize a collection by cloning each of\n // its model's attributes\n serializeCollection() {\n if (!this.collection) { return {}; }\n return this.collection.map(function(model) { return _.clone(model.attributes); });\n },\n\n // Render the view, defaulting to underscore.js templates.\n // You can override this in your view definition to provide\n // a very specific rendering for your view. In general, though,\n // you should override the `Marionette.Renderer` object to\n // change how Marionette renders views.\n // Subsequent renders after the first will re-render all nested\n // views.\n render() {\n this._ensureViewIsIntact();\n\n this.triggerMethod('before:render', this);\n\n // If this is not the first render call, then we need to\n // re-initialize the `el` for each region\n if (this._isRendered) {\n this._reInitRegions();\n }\n\n this._renderTemplate();\n this.bindUIElements();\n\n this._isRendered = true;\n this.triggerMethod('render', this);\n\n return this;\n },\n\n // Internal method to render the template with the serialized data\n // and template context via the `Marionette.Renderer` object.\n _renderTemplate() {\n const template = this.getTemplate();\n\n // Allow template-less views\n if (template === false) {\n return;\n }\n\n // Add in entity data and template context\n const data = this.mixinTemplateContext(this.serializeData());\n\n // Render and add to el\n const html = Renderer.render(template, data, this);\n this.attachElContent(html);\n },\n\n // Get the template for this view\n // instance. You can set a `template` attribute in the view\n // definition or pass a `template: \"whatever\"` parameter in\n // to the constructor options.\n getTemplate() {\n return this.template;\n },\n\n // Mix in template context methods. Looks for a\n // `templateContext` attribute, which can either be an\n // object literal, or a function that returns an object\n // literal. All methods and attributes from this object\n // are copies to the object passed in.\n mixinTemplateContext(target = {}) {\n const templateContext = _.result(this, 'templateContext');\n return _.extend(target, templateContext);\n },\n\n // Attaches the content of a given view.\n // This method can be overridden to optimize rendering,\n // or to render in a non standard way.\n //\n // For example, using `innerHTML` instead of `$el.html`\n //\n // ```js\n // attachElContent(html) {\n // this.el.innerHTML = html;\n // return this;\n // }\n // ```\n attachElContent(html) {\n this.$el.html(html);\n\n return this;\n },\n\n // called by ViewMixin destroy\n _removeChildren() {\n this.removeRegions();\n },\n\n _getImmediateChildren() {\n return _.chain(this.getRegions())\n .map('currentView')\n .compact()\n .value();\n }\n});\n\n_.extend(View.prototype, ViewMixin, RegionsMixin);\n\nexport default View;\n","// Mix in methods from Underscore, for iteration, and other\n// collection related features.\n// Borrowing this code from Backbone.Collection:\n// https://github.com/jashkenas/backbone/blob/1.1.2/backbone.js#L962\n\nimport _ from 'underscore';\n\nconst methods = ['forEach', 'each', 'map', 'find', 'detect', 'filter',\n 'select', 'reject', 'every', 'all', 'some', 'any', 'include',\n 'contains', 'invoke', 'toArray', 'first', 'initial', 'rest',\n 'last', 'without', 'isEmpty', 'pluck', 'reduce'];\n\nconst emulateCollection = function(object, listProperty) {\n _.each(methods, function(method) {\n object[method] = function() {\n const list = _.values(_.result(this, listProperty));\n const args = [list].concat(_.toArray(arguments));\n return _[method].apply(_, args);\n };\n });\n};\n\nexport default emulateCollection;\n","import _ from 'underscore';\nimport emulateCollection from './utils/emulate-collection';\n\n// Provide a container to store, retrieve and\n// shut down child views.\nconst Container = function(views) {\n this._views = {};\n this._indexByModel = {};\n this._indexByCustom = {};\n this._updateLength();\n\n _.each(views, _.bind(this.add, this));\n};\n\nemulateCollection(Container.prototype, '_views');\n\n// Container Methods\n// -----------------\n\n_.extend(Container.prototype, {\n\n // Add a view to this container. Stores the view\n // by `cid` and makes it searchable by the model\n // cid (and model itself). Optionally specify\n // a custom key to store an retrieve the view.\n add(view, customIndex) {\n return this._add(view, customIndex)._updateLength();\n },\n\n // To be used when avoiding call _updateLength\n // When you are done adding all your new views\n // call _updateLength\n _add(view, customIndex) {\n const viewCid = view.cid;\n\n // store the view\n this._views[viewCid] = view;\n\n // index it by model\n if (view.model) {\n this._indexByModel[view.model.cid] = viewCid;\n }\n\n // index by custom\n if (customIndex) {\n this._indexByCustom[customIndex] = viewCid;\n }\n\n return this;\n },\n\n // Find a view by the model that was attached to\n // it. Uses the model's `cid` to find it.\n findByModel(model) {\n return this.findByModelCid(model.cid);\n },\n\n // Find a view by the `cid` of the model that was attached to\n // it. Uses the model's `cid` to find the view `cid` and\n // retrieve the view using it.\n findByModelCid(modelCid) {\n const viewCid = this._indexByModel[modelCid];\n return this.findByCid(viewCid);\n },\n\n // Find a view by a custom indexer.\n findByCustom(index) {\n const viewCid = this._indexByCustom[index];\n return this.findByCid(viewCid);\n },\n\n // Find by index. This is not guaranteed to be a\n // stable index.\n findByIndex(index) {\n return _.values(this._views)[index];\n },\n\n // retrieve a view by its `cid` directly\n findByCid(cid) {\n return this._views[cid];\n },\n\n // Remove a view\n remove(view) {\n return this._remove(view)._updateLength();\n },\n\n // To be used when avoiding call _updateLength\n // When you are done adding all your new views\n // call _updateLength\n _remove(view) {\n const viewCid = view.cid;\n\n // delete model index\n if (view.model) {\n delete this._indexByModel[view.model.cid];\n }\n\n // delete custom index\n _.some(this._indexByCustom, _.bind(function(cid, key) {\n if (cid === viewCid) {\n delete this._indexByCustom[key];\n return true;\n }\n }, this));\n\n // remove the view from the container\n delete this._views[viewCid];\n\n return this;\n },\n\n // Update the `.length` attribute on this container\n _updateLength() {\n this.length = _.size(this._views);\n\n return this;\n }\n});\n\nexport default Container;\n","// Collection View\n// ---------------\n\nimport _ from 'underscore';\nimport Backbone from 'backbone';\nimport destroyBackboneView from './utils/destroy-backbone-view';\nimport monitorViewEvents from './common/monitor-view-events';\nimport { triggerMethodOn } from './common/trigger-method';\nimport ChildViewContainer from './child-view-container';\nimport MarionetteError from './error';\nimport ViewMixin from './mixins/view';\n\nconst ClassOptions = [\n 'behaviors',\n 'childView',\n 'childViewEventPrefix',\n 'childViewEvents',\n 'childViewOptions',\n 'childViewTriggers',\n 'collectionEvents',\n 'events',\n 'filter',\n 'emptyView',\n 'emptyViewOptions',\n 'modelEvents',\n 'reorderOnSort',\n 'sort',\n 'triggers',\n 'ui',\n 'viewComparator'\n];\n\n// A view that iterates over a Backbone.Collection\n// and renders an individual child view for each model.\nconst CollectionView = Backbone.View.extend({\n\n // flag for maintaining the sorted order of the collection\n sort: true,\n\n // constructor\n // option to pass `{sort: false}` to prevent the `CollectionView` from\n // maintaining the sorted order of the collection.\n // This will fallback onto appending childView's to the end.\n //\n // option to pass `{viewComparator: compFunction()}` to allow the `CollectionView`\n // to use a custom sort order for the collection.\n constructor(options) {\n this.render = _.bind(this.render, this);\n\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n monitorViewEvents(this);\n\n this._initBehaviors();\n this.once('render', this._initialEvents);\n this._initChildViewStorage();\n this._bufferedChildren = [];\n\n const args = Array.prototype.slice.call(arguments);\n args[0] = this.options;\n Backbone.View.prototype.constructor.apply(this, args);\n\n this.delegateEntityEvents();\n },\n\n // Instead of inserting elements one by one into the page, it's much more performant to insert\n // elements into a document fragment and then insert that document fragment into the page\n _startBuffering() {\n this._isBuffering = true;\n },\n\n _endBuffering() {\n const shouldTriggerAttach = !!this._isAttached;\n const triggerOnChildren = shouldTriggerAttach ? this._getImmediateChildren() : [];\n\n this._isBuffering = false;\n\n _.each(triggerOnChildren, child => {\n triggerMethodOn(child, 'before:attach', child);\n });\n\n this.attachBuffer(this, this._createBuffer());\n\n _.each(triggerOnChildren, child => {\n child._isAttached = true;\n triggerMethodOn(child, 'attach', child);\n });\n\n this._bufferedChildren = [];\n },\n\n _getImmediateChildren() {\n return _.values(this.children._views);\n },\n\n // Configured the initial events that the collection view binds to.\n _initialEvents() {\n if (this.collection) {\n this.listenTo(this.collection, 'add', this._onCollectionAdd);\n this.listenTo(this.collection, 'remove', this._onCollectionRemove);\n this.listenTo(this.collection, 'reset', this.render);\n\n if (this.sort) {\n this.listenTo(this.collection, 'sort', this._sortViews);\n }\n }\n },\n\n // Handle a child added to the collection\n _onCollectionAdd(child, collection, opts) {\n // `index` is present when adding with `at` since BB 1.2; indexOf fallback for < 1.2\n let index = opts.at !== undefined && (opts.index || collection.indexOf(child));\n\n // When filtered or when there is no initial index, calculate index.\n if (this.filter || index === false) {\n index = _.indexOf(this._filteredSortedModels(index), child);\n }\n\n if (this._shouldAddChild(child, index)) {\n this._destroyEmptyView();\n const ChildView = this._getChildView(child);\n this._addChild(child, ChildView, index);\n }\n },\n\n // get the child view by model it holds, and remove it\n _onCollectionRemove(model) {\n const view = this.children.findByModel(model);\n this.removeChildView(view);\n this._checkEmpty();\n },\n\n // Render children views. Override this method to provide your own implementation of a\n // render function for the collection view.\n render() {\n this._ensureViewIsIntact();\n this.triggerMethod('before:render', this);\n this._renderChildren();\n this._isRendered = true;\n this.triggerMethod('render', this);\n return this;\n },\n\n // An efficient rendering used for filtering. Instead of modifying the whole DOM for the\n // collection view, we are only adding or removing the related childrenViews.\n setFilter(filter, {preventRender} = {}) {\n const canBeRendered = this._isRendered && !this._isDestroyed;\n const filterChanged = this.filter !== filter;\n const shouldRender = canBeRendered && filterChanged && !preventRender;\n\n if (shouldRender) {\n const previousModels = this._filteredSortedModels();\n this.filter = filter;\n const models = this._filteredSortedModels();\n this._applyModelDeltas(models, previousModels);\n } else {\n this.filter = filter;\n }\n\n return this;\n },\n\n // `removeFilter` is actually an alias for removing filters.\n removeFilter(options) {\n return this.setFilter(null, options);\n },\n\n // Calculate and apply difference by cid between `models` and `previousModels`.\n _applyModelDeltas(models, previousModels) {\n const currentIds = {};\n _.each(models, (model, index) => {\n const addedChildNotExists = !this.children.findByModel(model);\n if (addedChildNotExists) {\n this._onCollectionAdd(model, this.collection, {at: index});\n }\n currentIds[model.cid] = true;\n });\n _.each(previousModels, (prevModel) => {\n const removedChildExists = !currentIds[prevModel.cid] && this.children.findByModel(prevModel);\n if (removedChildExists) {\n this._onCollectionRemove(prevModel);\n }\n });\n },\n\n // Reorder DOM after sorting. When your element's rendering do not use their index,\n // you can pass reorderOnSort: true to only reorder the DOM after a sort instead of\n // rendering all the collectionView.\n reorder() {\n const children = this.children;\n const models = this._filteredSortedModels();\n\n if (!models.length && this._showingEmptyView) { return this; }\n\n const anyModelsAdded = _.some(models, function(model) {\n return !children.findByModel(model);\n });\n\n // If there are any new models added due to filtering we need to add child views,\n // so render as normal.\n if (anyModelsAdded) {\n this.render();\n } else {\n // Get the DOM nodes in the same order as the models.\n const elsToReorder = _.map(models, function(model, index) {\n const view = children.findByModel(model);\n view._index = index;\n return view.el;\n });\n\n // Find the views that were children before but aren't in this new ordering.\n const filteredOutViews = children.filter(function(view) {\n return !_.contains(elsToReorder, view.el);\n });\n\n this.triggerMethod('before:reorder', this);\n\n // Since append moves elements that are already in the DOM, appending the elements\n // will effectively reorder them.\n this._appendReorderedChildren(elsToReorder);\n\n // remove any views that have been filtered out\n _.each(filteredOutViews, _.bind(this.removeChildView, this));\n this._checkEmpty();\n\n this.triggerMethod('reorder', this);\n }\n return this;\n },\n\n // Render view after sorting. Override this method to change how the view renders\n // after a `sort` on the collection.\n resortView() {\n if (this.reorderOnSort) {\n this.reorder();\n } else {\n this._renderChildren();\n }\n return this;\n },\n\n // Internal method. This checks for any changes in the order of the collection.\n // If the index of any view doesn't match, it will render.\n _sortViews() {\n const models = this._filteredSortedModels();\n\n // check for any changes in sort order of views\n const orderChanged = _.find(models, (item, index) => {\n const view = this.children.findByModel(item);\n return !view || view._index !== index;\n });\n\n if (orderChanged) {\n this.resortView();\n }\n },\n\n // Internal reference to what index a `emptyView` is.\n _emptyViewIndex: -1,\n\n // Internal method. Separated so that CompositeView can append to the childViewContainer\n // if necessary\n _appendReorderedChildren(children) {\n this.$el.append(children);\n },\n\n // Internal method. Separated so that CompositeView can have more control over events\n // being triggered, around the rendering process\n _renderChildren() {\n if (this._isRendered) {\n this._destroyEmptyView();\n this._destroyChildren({checkEmpty: false});\n }\n\n const models = this._filteredSortedModels();\n if (this.isEmpty({processedModels: models})) {\n this._showEmptyView();\n } else {\n this.triggerMethod('before:render:children', this);\n this._startBuffering();\n this._showCollection(models);\n this._endBuffering();\n this.triggerMethod('render:children', this);\n }\n },\n\n // Internal method to loop through collection and show each child view.\n _showCollection(models) {\n _.each(models, (child, index) => {\n const ChildView = this._getChildView(child);\n this._addChild(child, ChildView, index);\n });\n },\n\n // Allow the collection to be sorted by a custom view comparator\n _filteredSortedModels(addedAt) {\n if (!this.collection || !this.collection.length) { return []; }\n\n const viewComparator = this.getViewComparator();\n let models = this.collection.models;\n addedAt = Math.min(Math.max(addedAt, 0), models.length - 1);\n\n if (viewComparator) {\n let addedModel;\n // Preserve `at` location, even for a sorted view\n if (addedAt) {\n addedModel = models[addedAt];\n models = models.slice(0, addedAt).concat(models.slice(addedAt + 1));\n }\n models = this._sortModelsBy(models, viewComparator);\n if (addedModel) {\n models.splice(addedAt, 0, addedModel);\n }\n }\n\n // Filter after sorting in case the filter uses the index\n models = this._filterModels(models);\n\n return models;\n },\n\n getViewComparator() {\n return this.viewComparator;\n },\n\n // Filter an array of models, if a filter exists\n _filterModels(models) {\n if (this.filter) {\n models = _.filter(models, (model, index) => {\n return this._shouldAddChild(model, index);\n });\n }\n return models;\n },\n\n _sortModelsBy(models, comparator) {\n if (typeof comparator === 'string') {\n return _.sortBy(models, (model) => {\n return model.get(comparator);\n });\n } else if (comparator.length === 1) {\n return _.sortBy(models, _.bind(comparator, this));\n } else {\n return models.sort(_.bind(comparator, this));\n }\n },\n\n // Internal method to show an empty view in place of a collection of child views,\n // when the collection is empty\n _showEmptyView() {\n const EmptyView = this._getEmptyView();\n\n if (EmptyView && !this._showingEmptyView) {\n this._showingEmptyView = true;\n\n const model = new Backbone.Model();\n let emptyViewOptions =\n this.emptyViewOptions || this.childViewOptions;\n if (_.isFunction(emptyViewOptions)) {\n emptyViewOptions = emptyViewOptions.call(this, model, this._emptyViewIndex);\n }\n\n const view = this.buildChildView(model, EmptyView, emptyViewOptions);\n\n this.triggerMethod('before:render:empty', this, view);\n this._addChildView(view, 0);\n this.triggerMethod('render:empty', this, view);\n\n view._parent = this;\n }\n },\n\n // Internal method to destroy an existing emptyView instance if one exists. Called when\n // a collection view has been rendered empty, and then a child is added to the collection.\n _destroyEmptyView() {\n if (this._showingEmptyView) {\n this.triggerMethod('before:remove:empty', this);\n\n this._destroyChildren();\n delete this._showingEmptyView;\n\n this.triggerMethod('remove:empty', this);\n }\n },\n\n // Retrieve the empty view class\n _getEmptyView() {\n const emptyView = this.emptyView;\n\n if (!emptyView) { return; }\n\n return this._getView(emptyView);\n },\n\n // Retrieve the `childView` class\n // The `childView` property can be either a view class or a function that\n // returns a view class. If it is a function, it will receive the model that\n // will be passed to the view instance (created from the returned view class)\n _getChildView(child) {\n let childView = this.childView;\n\n if (!childView) {\n throw new MarionetteError({\n name: 'NoChildViewError',\n message: 'A \"childView\" must be specified'\n });\n }\n\n childView = this._getView(childView, child);\n\n if (!childView) {\n throw new MarionetteError({\n name: 'InvalidChildViewError',\n message: '\"childView\" must be a view class or a function that returns a view class'\n });\n }\n\n return childView;\n },\n\n // First check if the `view` is a view class (the common case)\n // Then check if it's a function (which we assume that returns a view class)\n _getView(view, child) {\n if (view.prototype instanceof Backbone.View || view === Backbone.View) {\n return view;\n } else if (_.isFunction(view)) {\n return view.call(this, child);\n }\n },\n\n // Internal method for building and adding a child view\n _addChild(child, ChildView, index) {\n const childViewOptions = this._getChildViewOptions(child, index);\n\n const view = this.buildChildView(child, ChildView, childViewOptions);\n\n this.addChildView(view, index);\n\n return view;\n },\n\n _getChildViewOptions(child, index) {\n if (_.isFunction(this.childViewOptions)) {\n return this.childViewOptions(child, index);\n }\n\n return this.childViewOptions;\n },\n\n // Render the child's view and add it to the HTML for the collection view at a given index.\n // This will also update the indices of later views in the collection in order to keep the\n // children in sync with the collection.\n addChildView(view, index) {\n this.triggerMethod('before:add:child', this, view);\n\n // increment indices of views after this one\n this._updateIndices(view, true, index);\n\n view._parent = this;\n\n this._addChildView(view, index);\n\n this.triggerMethod('add:child', this, view);\n\n return view;\n },\n\n // Internal method. This decrements or increments the indices of views after the added/removed\n // view to keep in sync with the collection.\n _updateIndices(view, increment, index) {\n if (!this.sort) {\n return;\n }\n\n if (increment) {\n // assign the index to the view\n view._index = index;\n }\n\n // update the indexes of views after this one\n this.children.each((laterView) => {\n if (laterView._index >= view._index) {\n laterView._index += increment ? 1 : -1;\n }\n });\n },\n\n // Internal Method. Add the view to children and render it at the given index.\n _addChildView(view, index) {\n // Only trigger attach if already attached and not buffering,\n // otherwise _endBuffering() or Region#show() handles this.\n const shouldTriggerAttach = !this._isBuffering && this._isAttached;\n\n monitorViewEvents(view);\n\n // set up the child view event forwarding\n this._proxyChildEvents(view);\n\n // Store the child view itself so we can properly remove and/or destroy it later\n this.children.add(view);\n\n if (!view.supportsRenderLifecycle) {\n triggerMethodOn(view, 'before:render', view);\n }\n\n // Render view\n view.render();\n\n if (!view.supportsRenderLifecycle) {\n view._isRendered = true;\n triggerMethodOn(view, 'render', view);\n }\n\n if (shouldTriggerAttach) {\n triggerMethodOn(view, 'before:attach', view);\n }\n\n // Attach view\n this.attachHtml(this, view, index);\n\n if (shouldTriggerAttach) {\n view._isAttached = true;\n triggerMethodOn(view, 'attach', view);\n }\n },\n\n // Build a `childView` for a model in the collection.\n buildChildView(child, ChildViewClass, childViewOptions) {\n const options = _.extend({model: child}, childViewOptions);\n return new ChildViewClass(options);\n },\n\n // Remove the child view and destroy it. This function also updates the indices of later views\n // in the collection in order to keep the children in sync with the collection.\n removeChildView(view) {\n if (!view || view._isDestroyed) {\n return view;\n }\n\n this.triggerMethod('before:remove:child', this, view);\n\n if (view.destroy) {\n view.destroy();\n } else {\n destroyBackboneView(view);\n }\n\n delete view._parent;\n this.stopListening(view);\n this.children.remove(view);\n this.triggerMethod('remove:child', this, view);\n\n // decrement the index of views after this one\n this._updateIndices(view, false);\n\n return view;\n },\n\n // check if the collection is empty or optionally whether an array of pre-processed models is empty\n isEmpty(options) {\n let models;\n if (_.result(options, 'processedModels')) {\n models = options.processedModels;\n } else {\n models = this.collection ? this.collection.models : [];\n models = this._filterModels(models);\n }\n return models.length === 0;\n },\n\n // If empty, show the empty view\n _checkEmpty() {\n if (this.isEmpty()) {\n this._showEmptyView();\n }\n },\n\n // You might need to override this if you've overridden attachHtml\n attachBuffer(collectionView, buffer) {\n collectionView.$el.append(buffer);\n },\n\n // Create a fragment buffer from the currently buffered children\n _createBuffer() {\n const elBuffer = document.createDocumentFragment();\n _.each(this._bufferedChildren, (b) => {\n elBuffer.appendChild(b.el);\n });\n return elBuffer;\n },\n\n // Append the HTML to the collection's `el`. Override this method to do something other\n // than `.append`.\n attachHtml(collectionView, childView, index) {\n if (collectionView._isBuffering) {\n // buffering happens on reset events and initial renders\n // in order to reduce the number of inserts into the\n // document, which are expensive.\n collectionView._bufferedChildren.splice(index, 0, childView);\n } else {\n // If we've already rendered the main collection, append\n // the new child into the correct order if we need to. Otherwise\n // append to the end.\n if (!collectionView._insertBefore(childView, index)) {\n collectionView._insertAfter(childView);\n }\n }\n },\n\n // Internal method. Check whether we need to insert the view into the correct position.\n _insertBefore(childView, index) {\n let currentView;\n const findPosition = this.sort && (index < this.children.length - 1);\n if (findPosition) {\n // Find the view after this one\n currentView = this.children.find((view) => {\n return view._index === index + 1;\n });\n }\n\n if (currentView) {\n currentView.$el.before(childView.el);\n return true;\n }\n\n return false;\n },\n\n // Internal method. Append a view to the end of the $el\n _insertAfter(childView) {\n this.$el.append(childView.el);\n },\n\n // Internal method to set up the `children` object for storing all of the child views\n _initChildViewStorage() {\n this.children = new ChildViewContainer();\n },\n\n // called by ViewMixin destroy\n _removeChildren() {\n this._destroyChildren({checkEmpty: false});\n },\n\n // Destroy the child views that this collection view is holding on to, if any\n _destroyChildren({checkEmpty} = {}) {\n this.triggerMethod('before:destroy:children', this);\n const shouldCheckEmpty = checkEmpty !== false;\n const childViews = this.children.map(_.identity);\n\n this.children.each(_.bind(this.removeChildView, this));\n\n if (shouldCheckEmpty) {\n this._checkEmpty();\n }\n\n this.triggerMethod('destroy:children', this);\n return childViews;\n },\n\n // Return true if the given child should be shown. Return false otherwise.\n // The filter will be passed (child, index, collection), where\n // 'child' is the given model\n // 'index' is the index of that model in the collection\n // 'collection' is the collection referenced by this CollectionView\n _shouldAddChild(child, index) {\n const filter = this.filter;\n return !_.isFunction(filter) || filter.call(this, child, index, this.collection);\n },\n\n // Set up the child view event forwarding. Uses a \"childview:\" prefix in front of all forwarded events.\n _proxyChildEvents(view) {\n const prefix = _.result(this, 'childViewEventPrefix');\n\n // Forward all child view events through the parent,\n // prepending \"childview:\" to the event name\n this.listenTo(view, 'all', (eventName, ...args) => {\n\n const childEventName = prefix + ':' + eventName;\n\n const childViewEvents = this.normalizeMethods(this._childViewEvents);\n\n // call collectionView childViewEvent if defined\n if (typeof childViewEvents !== 'undefined' && _.isFunction(childViewEvents[eventName])) {\n childViewEvents[eventName].apply(this, args);\n }\n\n // use the parent view's proxyEvent handlers\n const childViewTriggers = this._childViewTriggers;\n\n // Call the event with the proxy name on the parent layout\n if (childViewTriggers && _.isString(childViewTriggers[eventName])) {\n this.triggerMethod(childViewTriggers[eventName], ...args);\n }\n\n this.triggerMethod(childEventName, ...args);\n });\n }\n});\n\n_.extend(CollectionView.prototype, ViewMixin);\n\nexport default CollectionView;\n","// Composite View\n// --------------\n\nimport _ from 'underscore';\nimport deprecate from './utils/deprecate';\nimport MarionetteError from './error';\nimport CollectionView from './collection-view';\nimport View from './view';\n\nconst ClassOptions = [\n 'childViewContainer',\n 'template',\n 'templateContext'\n];\n\n// Used for rendering a branch-leaf, hierarchical structure.\n// Extends directly from CollectionView\n// @deprecated\nconst CompositeView = CollectionView.extend({\n\n // Setting up the inheritance chain which allows changes to\n // Marionette.CollectionView.prototype.constructor which allows overriding\n // option to pass '{sort: false}' to prevent the CompositeView from\n // maintaining the sorted order of the collection.\n // This will fallback onto appending childView's to the end.\n constructor(options) {\n deprecate('CompositeView is deprecated. Convert to View at your earliest convenience');\n\n this.mergeOptions(options, ClassOptions);\n\n CollectionView.prototype.constructor.apply(this, arguments);\n },\n\n // Configured the initial events that the composite view\n // binds to. Override this method to prevent the initial\n // events, or to add your own initial events.\n _initialEvents() {\n\n // Bind only after composite view is rendered to avoid adding child views\n // to nonexistent childViewContainer\n\n if (this.collection) {\n this.listenTo(this.collection, 'add', this._onCollectionAdd);\n this.listenTo(this.collection, 'remove', this._onCollectionRemove);\n this.listenTo(this.collection, 'reset', this.renderChildren);\n\n if (this.sort) {\n this.listenTo(this.collection, 'sort', this._sortViews);\n }\n }\n },\n\n // Retrieve the `childView` to be used when rendering each of\n // the items in the collection. The default is to return\n // `this.childView` or Marionette.CompositeView if no `childView`\n // has been defined. As happens in CollectionView, `childView` can\n // be a function (which should return a view class).\n _getChildView(child) {\n let childView = this.childView;\n\n // for CompositeView, if `childView` is not specified, we'll get the same\n // composite view class rendered for each child in the collection\n // then check if the `childView` is a view class (the common case)\n // finally check if it's a function (which we assume that returns a view class)\n if (!childView) {\n return this.constructor;\n }\n\n childView = this._getView(childView, child);\n\n if (!childView) {\n throw new MarionetteError({\n name: 'InvalidChildViewError',\n message: '\"childView\" must be a view class or a function that returns a view class'\n });\n }\n\n return childView;\n },\n\n // Return the serialized model\n serializeData() {\n return this.serializeModel();\n },\n\n // Renders the model and the collection.\n render() {\n this._ensureViewIsIntact();\n this._isRendering = true;\n this.resetChildViewContainer();\n\n this.triggerMethod('before:render', this);\n\n this._renderTemplate();\n this.bindUIElements();\n this.renderChildren();\n\n this._isRendering = false;\n this._isRendered = true;\n this.triggerMethod('render', this);\n return this;\n },\n\n renderChildren() {\n if (this._isRendered || this._isRendering) {\n CollectionView.prototype._renderChildren.call(this);\n }\n },\n\n // You might need to override this if you've overridden attachHtml\n attachBuffer(compositeView, buffer) {\n const $container = this.getChildViewContainer(compositeView);\n $container.append(buffer);\n },\n\n // Internal method. Append a view to the end of the $el.\n // Overidden from CollectionView to ensure view is appended to\n // childViewContainer\n _insertAfter(childView) {\n const $container = this.getChildViewContainer(this, childView);\n $container.append(childView.el);\n },\n\n // Internal method. Append reordered childView'.\n // Overidden from CollectionView to ensure reordered views\n // are appended to childViewContainer\n _appendReorderedChildren(children) {\n const $container = this.getChildViewContainer(this);\n $container.append(children);\n },\n\n // Internal method to ensure an `$childViewContainer` exists, for the\n // `attachHtml` method to use.\n getChildViewContainer(containerView, childView) {\n if (!!containerView.$childViewContainer) {\n return containerView.$childViewContainer;\n }\n\n let container;\n const childViewContainer = containerView.childViewContainer;\n if (childViewContainer) {\n\n const selector = _.result(containerView, 'childViewContainer');\n\n if (selector.charAt(0) === '@' && containerView.ui) {\n container = containerView.ui[selector.substr(4)];\n } else {\n container = containerView.$(selector);\n }\n\n if (container.length <= 0) {\n throw new MarionetteError({\n name: 'ChildViewContainerMissingError',\n message: `The specified \"childViewContainer\" was not found: ${containerView.childViewContainer}`\n });\n }\n\n } else {\n container = containerView.$el;\n }\n\n containerView.$childViewContainer = container;\n return container;\n },\n\n // Internal method to reset the `$childViewContainer` on render\n resetChildViewContainer() {\n if (this.$childViewContainer) {\n this.$childViewContainer = undefined;\n }\n }\n});\n\n// To prevent duplication but allow the best View organization\n// Certain View methods are mixed directly into the deprecated CompositeView\nconst MixinFromView = _.pick(View.prototype, 'serializeModel', 'getTemplate', '_renderTemplate', 'mixinTemplateContext', 'attachElContent');\n_.extend(CompositeView.prototype, MixinFromView);\n\nexport default CompositeView;\n","// Behavior\n// --------\n\n// A Behavior is an isolated set of DOM /\n// user interactions that can be mixed into any View.\n// Behaviors allow you to blackbox View specific interactions\n// into portable logical chunks, keeping your views simple and your code DRY.\n\nimport _ from 'underscore';\nimport getUniqueEventName from './utils/get-unique-event-name';\nimport MarionetteObject from './object';\nimport DelegateEntityEventsMixin from './mixins/delegate-entity-events';\nimport TriggersMixin from './mixins/triggers';\nimport UIMixin from './mixins/ui';\n\nconst ClassOptions = [\n 'collectionEvents',\n 'events',\n 'modelEvents',\n 'triggers',\n 'ui'\n];\n\nconst Behavior = MarionetteObject.extend({\n cidPrefix: 'mnb',\n\n constructor(options, view) {\n // Setup reference to the view.\n // this comes in handle when a behavior\n // wants to directly talk up the chain\n // to the view.\n this.view = view;\n this.defaults = _.clone(_.result(this, 'defaults', {}));\n this._setOptions(this.defaults, options);\n this.mergeOptions(this.options, ClassOptions);\n\n // Construct an internal UI hash using\n // the behaviors UI hash and then the view UI hash.\n // This allows the user to use UI hash elements\n // defined in the parent view as well as those\n // defined in the given behavior.\n // This order will help the reuse and share of a behavior\n // between multiple views, while letting a view override a\n // selector under an UI key.\n this.ui = _.extend({}, _.result(this, 'ui'), _.result(view, 'ui'));\n\n MarionetteObject.apply(this, arguments);\n },\n\n // proxy behavior $ method to the view\n // this is useful for doing jquery DOM lookups\n // scoped to behaviors view.\n $() {\n return this.view.$.apply(this.view, arguments);\n },\n\n // Stops the behavior from listening to events.\n // Overrides Object#destroy to prevent additional events from being triggered.\n destroy() {\n this.stopListening();\n\n return this;\n },\n\n proxyViewProperties() {\n this.$el = this.view.$el;\n this.el = this.view.el;\n\n return this;\n },\n\n bindUIElements() {\n this._bindUIElements();\n\n return this;\n },\n\n unbindUIElements() {\n this._unbindUIElements();\n\n return this;\n },\n\n getUI(name) {\n this.view._ensureViewIsIntact();\n return this._getUI(name);\n },\n\n // Handle `modelEvents`, and `collectionEvents` configuration\n delegateEntityEvents() {\n this._delegateEntityEvents(this.view.model, this.view.collection);\n\n return this;\n },\n\n undelegateEntityEvents() {\n this._undelegateEntityEvents(this.view.model, this.view.collection);\n\n return this;\n },\n\n getEvents() {\n // Normalize behavior events hash to allow\n // a user to use the @ui. syntax.\n const behaviorEvents = this.normalizeUIKeys(_.result(this, 'events'));\n\n // binds the handler to the behavior and builds a unique eventName\n return _.reduce(behaviorEvents, function(events, behaviorHandler, key) {\n if (!_.isFunction(behaviorHandler)) {\n behaviorHandler = this[behaviorHandler];\n }\n if (!behaviorHandler) { return; }\n key = getUniqueEventName(key);\n events[key] = _.bind(behaviorHandler, this);\n return events;\n } , {}, this);\n },\n\n // Internal method to build all trigger handlers for a given behavior\n getTriggers() {\n if (!this.triggers) { return; }\n\n // Normalize behavior triggers hash to allow\n // a user to use the @ui. syntax.\n const behaviorTriggers = this.normalizeUIKeys(_.result(this, 'triggers'));\n\n return this._getViewTriggers(this.view, behaviorTriggers);\n }\n\n});\n\n_.extend(Behavior.prototype, DelegateEntityEventsMixin, TriggersMixin, UIMixin);\n\nexport default Behavior;\n","// Application\n// -----------\nimport _ from 'underscore';\nimport MarionetteObject from './object';\nimport Region from './region';\n\nconst ClassOptions = [\n 'region',\n 'regionClass'\n];\n\n// A container for a Marionette application.\nconst Application = MarionetteObject.extend({\n cidPrefix: 'mna',\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n this._initRegion();\n\n MarionetteObject.prototype.constructor.apply(this, arguments);\n },\n\n regionClass: Region,\n\n _initRegion(options) {\n const region = this.region;\n const RegionClass = this.regionClass;\n\n // if the region is a string expect an el or selector\n // and instantiate a region\n if (_.isString(region)) {\n this._region = new RegionClass({\n el: region\n });\n return;\n }\n\n this._region = region;\n },\n\n getRegion() {\n return this._region;\n },\n\n showView(view, ...args) {\n const region = this.getRegion();\n return region.show(view, ...args);\n },\n\n getView() {\n return this.getRegion().currentView;\n },\n\n // kick off all of the application's processes.\n start(options) {\n this.triggerMethod('before:start', this, options);\n this.triggerMethod('start', this, options);\n return this;\n }\n\n});\n\nexport default Application;\n","// App Router\n// ----------\n\n// Reduce the boilerplate code of handling route events\n// and then calling a single method on another object,\n// called a controller.\n// Have your routers configured to call the method on\n// your controller, directly.\n//\n// Configure an AppRouter with `appRoutes`.\n//\n// App routers can only take one `controller` object.\n// It is recommended that you divide your controller\n// objects in to smaller pieces of related functionality\n// and have multiple routers / controllers, instead of\n// just one giant router and controller.\n//\n// You can also add standard routes to an AppRouter.\n\nimport Backbone from 'backbone';\nimport _ from 'underscore';\nimport { triggerMethod } from './common/trigger-method';\nimport MarionetteError from './error';\nimport CommonMixin from './mixins/common';\n\nconst ClassOptions = [\n 'appRoutes',\n 'controller'\n];\n\nconst AppRouter = Backbone.Router.extend({\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n Backbone.Router.apply(this, arguments);\n\n const appRoutes = this.appRoutes;\n const controller = this._getController();\n this.processAppRoutes(controller, appRoutes);\n this.on('route', this._processOnRoute, this);\n },\n\n // Similar to route method on a Backbone Router but\n // method is called on the controller\n appRoute(route, methodName) {\n const controller = this._getController();\n this._addAppRoute(controller, route, methodName);\n return this;\n },\n\n // process the route event and trigger the onRoute\n // method call, if it exists\n _processOnRoute(routeName, routeArgs) {\n // make sure an onRoute before trying to call it\n if (_.isFunction(this.onRoute)) {\n // find the path that matches the current route\n const routePath = _.invert(this.appRoutes)[routeName];\n this.onRoute(routeName, routePath, routeArgs);\n }\n },\n\n // Internal method to process the `appRoutes` for the\n // router, and turn them in to routes that trigger the\n // specified method on the specified `controller`.\n processAppRoutes(controller, appRoutes) {\n if (!appRoutes) { return this; }\n\n const routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes\n\n _.each(routeNames, route => {\n this._addAppRoute(controller, route, appRoutes[route]);\n });\n\n return this;\n },\n\n _getController() {\n return this.controller;\n },\n\n _addAppRoute(controller, route, methodName) {\n const method = controller[methodName];\n\n if (!method) {\n throw new MarionetteError(`Method \"${methodName}\" was not found on the controller`);\n }\n\n this.route(route, methodName, _.bind(method, controller));\n },\n\n triggerMethod: triggerMethod\n});\n\n_.extend(AppRouter.prototype, CommonMixin);\n\nexport default AppRouter;\n","import Backbone from 'backbone';\nimport {version} from '../package.json';\n\nimport proxy from './utils/proxy';\nimport extend from './utils/extend';\nimport deprecate from './utils/deprecate';\n\nimport isNodeAttached from './common/is-node-attached';\nimport mergeOptions from './common/merge-options';\nimport getOption from './common/get-option';\nimport normalizeMethods from './common/normalize-methods';\nimport monitorViewEvents from './common/monitor-view-events';\n\nimport {\n bindEvents,\n unbindEvents\n} from './common/bind-events';\n\nimport {\n bindRequests,\n unbindRequests\n} from './common/bind-requests';\n\nimport {\n triggerMethod,\n triggerMethodOn\n} from './common/trigger-method';\n\n\nimport MarionetteObject from './object';\nimport TemplateCache from './template-cache';\nimport View from './view';\nimport CollectionView from './collection-view';\nimport CompositeView from './composite-view';\nimport Behavior from './behavior';\nimport Region from './region';\nimport Application from './application';\nimport AppRouter from './app-router';\nimport MarionetteError from './error';\n\nimport behaviorsLookup from './config/behaviors-lookup';\nimport Renderer from './config/renderer';\n\nimport {\n FEATURES,\n isEnabled,\n setEnabled\n} from './config/features';\n\nconst previousMarionette = Backbone.Marionette;\nconst Marionette = Backbone.Marionette = {};\n\n// This allows you to run multiple instances of Marionette on the same\n// webapp. After loading the new version, call `noConflict()` to\n// get a reference to it. At the same time the old version will be\n// returned to Backbone.Marionette.\nMarionette.noConflict = function() {\n Backbone.Marionette = previousMarionette;\n return this;\n};\n\n// Utilities\nMarionette.bindEvents = proxy(bindEvents);\nMarionette.unbindEvents = proxy(unbindEvents);\nMarionette.bindRequests = proxy(bindRequests);\nMarionette.unbindRequests = proxy(unbindRequests);\nMarionette.mergeOptions = proxy(mergeOptions);\nMarionette.getOption = proxy(getOption);\nMarionette.normalizeMethods = proxy(normalizeMethods);\nMarionette.extend = extend;\nMarionette.isNodeAttached = isNodeAttached;\nMarionette.deprecate = deprecate;\nMarionette.triggerMethod = proxy(triggerMethod);\nMarionette.triggerMethodOn = triggerMethodOn;\nMarionette.isEnabled = isEnabled;\nMarionette.setEnabled = setEnabled;\nMarionette.monitorViewEvents = monitorViewEvents;\n\nMarionette.Behaviors = {};\nMarionette.Behaviors.behaviorsLookup = behaviorsLookup;\n\n// Classes\nMarionette.Application = Application;\nMarionette.AppRouter = AppRouter;\nMarionette.Renderer = Renderer;\nMarionette.TemplateCache = TemplateCache;\nMarionette.View = View;\nMarionette.CollectionView = CollectionView;\nMarionette.CompositeView = CompositeView;\nMarionette.Behavior = Behavior;\nMarionette.Region = Region;\nMarionette.Error = MarionetteError;\nMarionette.Object = MarionetteObject;\n\n// Configuration\nMarionette.DEV_MODE = false;\nMarionette.FEATURES = FEATURES;\nMarionette.VERSION = version;\n\nexport default Marionette;\n"],"sourceRoot":"/source/"}
|
1
|
+
{"version":3,"sources":["/source/src/common/trigger-method.js","/source/src/common/monitor-view-events.js","/source/src/common/bind-events.js","/source/src/common/bind-requests.js","/source/src/mixins/behaviors.js","/source/src/utils/get-unique-event-name.js","/source/src/mixins/triggers.js","/source/src/utils/destroy-backbone-view.js","/source/src/common/build-region.js","/source/src/config/behaviors-lookup.js","/source/src/config/features.js","/source/src/utils/proxy.js","/source/src/utils/extend.js","/source/src/utils/deprecate.js","/source/src/common/is-node-attached.js","/source/src/common/merge-options.js","/source/src/common/get-option.js","/source/src/common/normalize-methods.js","/source/src/error.js","/source/src/utils/set-options.js","/source/src/mixins/common.js","/source/src/mixins/radio.js","/source/src/object.js","/source/src/template-cache.js","/source/src/utils/invoke.js","/source/src/mixins/delegate-entity-events.js","/source/src/mixins/ui.js","/source/src/mixins/view.js","/source/src/region.js","/source/src/mixins/regions.js","/source/src/config/renderer.js","/source/src/view.js","/source/src/utils/emulate-collection.js","/source/src/child-view-container.js","/source/src/collection-view.js","/source/src/composite-view.js","/source/src/behavior.js","/source/src/application.js","/source/src/app-router.js","/source/src/backbone.marionette.js"],"names":["getEventName","match","prefix","eventName","toUpperCase","triggerMethod","event","_len","arguments","length","args","Array","_key","methodName","getOnMethodName","method","getOption","call","this","result","_","isFunction","apply","trigger","triggerMethodOn","context","_len2","_key2","triggerMethodChildren","view","shouldTrigger","_getImmediateChildren","each","child","shouldTriggerAttach","_isAttached","shouldAttach","shouldTriggerDetach","shouldDetach","triggerDOMRefresh","_isRendered","handleBeforeAttach","handleAttach","handleBeforeDetach","handleDetach","handleRender","monitorViewEvents","_areViewEventsMonitored","on","before:attach","attach","before:detach","detach","render","bindFromStrings","target","entity","evt","methods","actionName","methodNames","split","MarionetteError","iterateEvents","bindings","isObject","message","url","isString","bindEvents","unbindEvents","iterateReplies","channel","normalizedRadioRequests","normalizeMethods","bindRequests","unbindRequests","getBehaviorClass","options","key","behaviorClass","Marionette","Behaviors","behaviorsLookup","parseBehaviors","behaviors","chain","map","BehaviorClass","_options","behavior","nestedBehaviors","concat","flatten","value","uniqueName","selector","uniqueId","join","buildViewTrigger","triggerDef","shouldPreventDefault","preventDefault","shouldStopPropagation","stopPropagation","e","destroyBackboneView","supportsDestroyLifecycle","remove","_isDestroyed","buildRegion","definition","defaults","Region","buildRegionFromDefinition","opts","extend","el","buildRegionFromObject","regionClass","deprecate","RegionClass","omit","isEnabled","name","FEATURES","setEnabled","state","proxy","Backbone","Model","test","prev","next","DEV_MODE","undefined","_cache","_warn","_console","console","warn","log","noop","isNodeAttached","$","contains","document","documentElement","mergeOptions","keys","_this","option","optionName","hash","reduce","normalizedHash","splitter","memoize","replace","errorProps","Error","urlRoot","version","constructor","error","pick","captureStackTrace","toString","setOptions","CommonMixin","_setOptions","RadioMixin","_initRadio","channelName","Radio","_channel","radioEvents","radioRequests","_destroyRadio","stopReplying","getChannel","ClassOptions","MarionetteObject","cid","cidPrefix","initialize","prototype","Events","isDestroyed","destroy","stopListening","TemplateCache","templateId","templateCaches","get","cachedTemplate","load","clear","i","compiledTemplate","template","loadTemplate","compileTemplate","$template","html","rawTemplate","_invoke","invokeMap","invoke","BehaviorsMixin","_initBehaviors","_behaviors","_getBehaviorTriggers","triggers","_toConsumableArray","_getBehaviorEvents","events","_proxyBehaviorViewProperties","_delegateBehaviorEntityEvents","_undelegateBehaviorEntityEvents","_destroyBehaviors","_bindBehaviorUIElements","_unbindBehaviorUIElements","_triggerEventOnBehaviors","DelegateEntityEventsMixin","_delegateEntityEvents","model","collection","_undelegateEntityEvents","modelEvents","collectionEvents","delegateEventSplitter","getUniqueEventName","TriggersMixin","_getViewTriggers","normalizeUIKeys","ui","memo","val","normalizedKey","normalizeUIString","uiString","r","slice","normalizeUIValues","properties","isArray","property","propertyVal","UIMixin","uiBindings","_getUIBindings","_bindUIElements","_uiBindings","_ui","_unbindUIElements","_this2","$el","_getUI","ViewMixin","supportsRenderLifecycle","isRendered","isAttached","delegateEvents","eventsArg","_buildEventProxies","viewEvents","_getEvents","combinedEvents","getTriggers","View","delegateEntityEvents","undelegateEntityEvents","_ensureViewIsIntact","unbindUIElements","_removeElement","_removeChildren","bindUIElements","getUI","childViewEventPrefix","ret","_triggerEventOnParentLayout","_childViewEvents","_childViewTriggers","layoutView","_parentView","_childViewEventHandler","parent","_parent","childViewEvents","childViewTriggers","childEventName","replaceElement","_isReplaced","_initEl","getEl","show","_ensureElement","_ensureView","currentView","empty","_empty","_renderView","_attachView","shouldReplaceEl","_replaceEl","attachHtml","allowMissingEl","_restoreEl","parentNode","replaceChild","isReplaced","appendChild","detachHtml","shouldDestroy","preventDestroy","off","_removeView","_detachView","detachView","contents","hasView","reset","RegionsMixin","_initRegions","regions","_regions","addRegions","_reInitRegions","addRegion","isEmpty","_addRegions","regionDefinitions","parentEl","partial","_addRegion","region","removeRegion","_removeRegion","removeRegions","getRegions","bind","emptyRegions","hasRegion","getRegion","clone","showChildView","detachChildView","getChildView","Renderer","data","templateFunc","serializeData","serializeModel","items","serializeCollection","attributes","setElement","hasEl","_renderTemplate","getTemplate","mixinTemplateContext","attachElContent","templateContext","compact","emulateCollection","object","listProperty","list","values","toArray","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","add","customIndex","_add","viewCid","findByModel","findByModelCid","modelCid","findByCid","findByCustom","index","findByIndex","_remove","some","size","CollectionView","sort","once","_initialEvents","_initChildViewStorage","_bufferedChildren","_startBuffering","_isBuffering","_endBuffering","triggerOnChildren","attachBuffer","_createBuffer","children","listenTo","_onCollectionAdd","_onCollectionUpdate","_sortViews","at","indexOf","filter","_filteredSortedModels","_shouldAddChild","_destroyEmptyView","_addChild","changes","_removeChildModels","removed","models","_ref","checkEmpty","shouldCheckEmpty","removedViews","_getRemovedViews","_updateIndices","_checkEmpty","removingViews","_removeChildView","push","_findGreatestIndexedView","greatestIndexedView","_index","_renderChildren","setFilter","_ref2","preventRender","canBeRendered","filterChanged","shouldRender","previousModels","_applyModelDeltas","removeFilter","currentIds","addedChildNotExists","removeModels","prevModel","reorder","_this3","_showingEmptyView","anyModelsAdded","filteredOutModels","elsToReorder","viewEls","_appendReorderedChildren","resortView","reorderOnSort","_this4","orderChanged","find","item","_emptyViewIndex","append","_destroyChildren","processedModels","_showEmptyView","_showCollection","_createView","ChildView","_getChildView","childViewOptions","_getChildViewOptions","buildChildView","_setupChildView","_proxyChildEvents","addedAt","viewComparator","getViewComparator","Math","min","max","addedModel","_sortModelsBy","splice","_filterModels","_this5","comparator","sortBy","EmptyView","_getEmptyView","emptyViewOptions","addChildView","emptyView","_getView","childView","increment","laterView","ChildViewClass","removeChildView","collectionView","buffer","elBuffer","createDocumentFragment","b","_insertBefore","_insertAfter","findPosition","before","ChildViewContainer","childModels","CompositeView","renderChildren","_isRendering","resetChildViewContainer","compositeView","$container","getChildViewContainer","containerView","$childViewContainer","container","childViewContainer","charAt","substr","MixinFromView","Behavior","proxyViewProperties","getEvents","behaviorEvents","behaviorHandler","behaviorTriggers","Application","_initRegion","_region","showView","getView","start","AppRouter","Router","appRoutes","controller","_getController","processAppRoutes","_processOnRoute","appRoute","route","_addAppRoute","routeName","routeArgs","onRoute","routePath","invert","routeNames","reverse","previousMarionette","noConflict","Object","VERSION"],"mappings":";;;;;;;;4UAWA,SAASA,GAAaC,EAAOC,EAAQC,GACnC,MAAOA,GAAUC,cAcZ,QAASC,GAAcC,GAAgB,IAAA,GAAAC,GAAAC,UAAAC,OAANC,EAAMC,MAAAJ,EAAA,EAAAA,EAAA,EAAA,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAANF,EAAME,EAAA,GAAAJ,UAAAI,EAE5C,IAAMC,GAAaC,EAAgBR,GAC7BS,EAASC,EAAUC,KAAKC,KAAML,GAChCM,EAAAA,MAWJ,OARIC,GAAEC,WAAWN,KAEfI,EAASJ,EAAOO,MAAMJ,KAAMR,IAI9BQ,KAAKK,QAAQD,MAAMJ,KAAMV,WAElBW,EAOF,QAASK,GAAgBC,GAAkB,IAAA,GAAAC,GAAAlB,UAAAC,OAANC,EAAMC,MAAAe,EAAA,EAAAA,EAAA,EAAA,GAAAC,EAAA,EAAAA,EAAAD,EAAAC,IAANjB,EAAMiB,EAAA,GAAAnB,UAAAmB,EAChD,OAAIP,GAAEC,WAAWI,EAAQpB,eAChBoB,EAAQpB,cAAciB,MAAMG,EAASf,GAGvCL,EAAciB,MAAMG,EAASf,GC9CtC,QAASkB,GAAsBC,EAAMvB,EAAOwB,GACrCD,EAAKE,uBACVX,EAAEY,KAAKH,EAAKE,wBAAyB,SAAAE,GAC9BH,EAAcG,IACnBT,EAAgBS,EAAO3B,EAAO2B,KAIlC,QAASC,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B,GAChCnE,GAAWjE,UAAYgH,EAAMhH,GAC7BiE,GAAWP,iBAAmBsD,EAAMtD,GACpCO,GAAWmC,OAASA,EACpBnC,GAAW8D,eAAiBA,EAC5B9D,GAAWuC,UAAYA,EACvBvC,GAAW5E,cAAgB2H,EAAM3H,GACjC4E,GAAWzD,gBAAkBA,EAC7ByD,GAAW0C,UAAYA,EACvB1C,GAAW6C,WAAaA,EACxB7C,GAAWnC,kBAAoBA,EAE/BmC,GAAWC,aACXD,GAAWC,UAAUC,gBAAkBA,EAGvCF,GAAWgc,YAAcA,GACzBhc,GAAWsc,UAAYA,GACvBtc,GAAW4Q,SAAWA,GACtB5Q,GAAW8G,cAAgBA,GAC3B9G,GAAW6L,KAAOA,GAClB7L,GAAWsT,eAAiBA,GAC5BtT,GAAW4a,cAAgBA,GAC3B5a,GAAW0b,SAAWA,GACtB1b,GAAWgC,OAASA,GACpBhC,GAAW+E,MAAQlG,EACnBmB,GAAWyd,OAASpX,EAGpBrG,GAAWqD,UAAW,EACtBrD,GAAW4C,SAAWA,GACtB5C,GAAW0d,QAAUzY","file":"backbone.marionette.min.js","sourcesContent":["// Trigger Method\n// --------------\n\nimport _ from 'underscore';\nimport getOption from './get-option';\n\n// split the event name on the \":\"\nconst splitter = /(^|:)(\\w)/gi;\n\n// take the event section (\"section1:section2:section3\")\n// and turn it in to uppercase name onSection1Section2Section3\nfunction getEventName(match, prefix, eventName) {\n return eventName.toUpperCase();\n}\n\nconst getOnMethodName = _.memoize(function(event) {\n return 'on' + event.replace(splitter, getEventName);\n});\n\n// Trigger an event and/or a corresponding method name. Examples:\n//\n// `this.triggerMethod(\"foo\")` will trigger the \"foo\" event and\n// call the \"onFoo\" method.\n//\n// `this.triggerMethod(\"foo:bar\")` will trigger the \"foo:bar\" event and\n// call the \"onFooBar\" method.\nexport function triggerMethod(event, ...args) {\n // get the method name from the event name\n const methodName = getOnMethodName(event);\n const method = getOption.call(this, methodName);\n let result;\n\n // call the onMethodName if it exists\n if (_.isFunction(method)) {\n // pass all args, except the event name\n result = method.apply(this, args);\n }\n\n // trigger the event\n this.trigger.apply(this, arguments);\n\n return result;\n}\n\n// triggerMethodOn invokes triggerMethod on a specific context\n//\n// e.g. `Marionette.triggerMethodOn(view, 'show')`\n// will trigger a \"show\" event or invoke onShow the view.\nexport function triggerMethodOn(context, ...args) {\n if (_.isFunction(context.triggerMethod)) {\n return context.triggerMethod.apply(context, args);\n }\n\n return triggerMethod.apply(context, args);\n}\n","// DOM Refresh\n// -----------\n\nimport _ from 'underscore';\nimport { triggerMethodOn } from './trigger-method';\n\n// Trigger method on children unless a pure Backbone.View\nfunction triggerMethodChildren(view, event, shouldTrigger) {\n if (!view._getImmediateChildren) { return; }\n _.each(view._getImmediateChildren(), child => {\n if (!shouldTrigger(child)) { return; }\n triggerMethodOn(child, event, child);\n });\n}\n\nfunction shouldTriggerAttach(view) {\n return !view._isAttached;\n}\n\nfunction shouldAttach(view) {\n if (!shouldTriggerAttach(view)) { return false; }\n view._isAttached = true;\n return true;\n}\n\nfunction shouldTriggerDetach(view) {\n return view._isAttached;\n}\n\nfunction shouldDetach(view) {\n if (!shouldTriggerDetach(view)) { return false; }\n view._isAttached = false;\n return true;\n}\n\nfunction triggerDOMRefresh(view) {\n if (view._isAttached && view._isRendered) {\n triggerMethodOn(view, 'dom:refresh', view);\n }\n}\n\nfunction handleBeforeAttach() {\n triggerMethodChildren(this, 'before:attach', shouldTriggerAttach);\n}\n\nfunction handleAttach() {\n triggerMethodChildren(this, 'attach', shouldAttach);\n triggerDOMRefresh(this);\n}\n\nfunction handleBeforeDetach() {\n triggerMethodChildren(this, 'before:detach', shouldTriggerDetach);\n}\n\nfunction handleDetach() {\n triggerMethodChildren(this, 'detach', shouldDetach);\n}\n\nfunction handleRender() {\n triggerDOMRefresh(this);\n}\n\n// Monitor a view's state, propagating attach/detach events to children and firing dom:refresh\n// whenever a rendered view is attached or an attached view is rendered.\nfunction monitorViewEvents(view) {\n if (view._areViewEventsMonitored) { return; }\n\n view._areViewEventsMonitored = true;\n\n view.on({\n 'before:attach': handleBeforeAttach,\n 'attach': handleAttach,\n 'before:detach': handleBeforeDetach,\n 'detach': handleDetach,\n 'render': handleRender\n });\n}\n\nexport default monitorViewEvents;\n","// Bind Entity Events & Unbind Entity Events\n// -----------------------------------------\n//\n// These methods are used to bind/unbind a backbone \"entity\" (e.g. collection/model)\n// to methods on a target object.\n//\n// The first parameter, `target`, must have the Backbone.Events module mixed in.\n//\n// The second parameter is the `entity` (Backbone.Model, Backbone.Collection or\n// any object that has Backbone.Events mixed in) to bind the events from.\n//\n// The third parameter is a hash of { \"event:name\": \"eventHandler\" }\n// configuration. Multiple handlers can be separated by a space. A\n// function can be supplied instead of a string handler name.\n\nimport _ from 'underscore';\nimport MarionetteError from '../error';\n\n// Bind/unbind the event to handlers specified as a string of\n// handler names on the target object\nfunction bindFromStrings(target, entity, evt, methods, actionName) {\n const methodNames = methods.split(/\\s+/);\n\n _.each(methodNames, function(methodName) {\n const method = target[methodName];\n if (!method) {\n throw new MarionetteError(`Method \"${methodName}\" was configured as an event handler, but does not exist.`);\n }\n\n target[actionName](entity, evt, method);\n });\n}\n\n// generic looping function\nfunction iterateEvents(target, entity, bindings, actionName) {\n if (!entity || !bindings) { return; }\n\n // type-check bindings\n if (!_.isObject(bindings)) {\n throw new MarionetteError({\n message: 'Bindings must be an object.',\n url: 'marionette.functions.html#marionettebindevents'\n });\n }\n\n // iterate the bindings and bind/unbind them\n _.each(bindings, function(method, evt) {\n\n // allow for a list of method names as a string\n if (_.isString(method)) {\n bindFromStrings(target, entity, evt, method, actionName);\n return;\n }\n\n target[actionName](entity, evt, method);\n });\n}\n\nfunction bindEvents(entity, bindings) {\n iterateEvents(this, entity, bindings, 'listenTo');\n return this;\n}\n\nfunction unbindEvents(entity, bindings) {\n iterateEvents(this, entity, bindings, 'stopListening');\n return this;\n}\n\n// Export Public API\nexport {\n bindEvents,\n unbindEvents\n};\n","// Bind/Unbind Radio Requests\n// -----------------------------------------\n//\n// These methods are used to bind/unbind a backbone.radio request\n// to methods on a target object.\n//\n// The first parameter, `target`, will set the context of the reply method\n//\n// The second parameter is the `Radio.channel` to bind the reply to.\n//\n// The third parameter is a hash of { \"request:name\": \"replyHandler\" }\n// configuration. A function can be supplied instead of a string handler name.\n\nimport _ from 'underscore';\nimport normalizeMethods from './normalize-methods';\nimport MarionetteError from '../error';\n\nfunction iterateReplies(target, channel, bindings, actionName) {\n if (!channel || !bindings) { return; }\n\n // type-check bindings\n if (!_.isObject(bindings)) {\n throw new MarionetteError({\n message: 'Bindings must be an object.',\n url: 'marionette.functions.html#marionettebindrequests'\n });\n }\n\n const normalizedRadioRequests = normalizeMethods.call(target, bindings);\n\n channel[actionName](normalizedRadioRequests, target);\n}\n\nfunction bindRequests(channel, bindings) {\n iterateReplies(this, channel, bindings, 'reply');\n return this;\n}\n\nfunction unbindRequests(channel, bindings) {\n iterateReplies(this, channel, bindings, 'stopReplying');\n return this;\n}\n\nexport {\n bindRequests,\n unbindRequests\n};\n","import _ from 'underscore';\nimport _invoke from '../utils/invoke';\nimport { triggerMethod } from '../common/trigger-method';\nimport Marionette from '../backbone.marionette';\n\n// MixinOptions\n// - behaviors\n\n// Takes care of getting the behavior class\n// given options and a key.\n// If a user passes in options.behaviorClass\n// default to using that.\n// If a user passes in a Behavior Class directly, use that\n// Otherwise delegate the lookup to the users `behaviorsLookup` implementation.\nfunction getBehaviorClass(options, key) {\n if (options.behaviorClass) {\n return options.behaviorClass;\n //treat functions as a Behavior constructor\n } else if (_.isFunction(options)) {\n return options;\n }\n\n // behaviorsLookup can be either a flat object or a method\n if (_.isFunction(Marionette.Behaviors.behaviorsLookup)) {\n return Marionette.Behaviors.behaviorsLookup(options, key)[key];\n }\n\n return Marionette.Behaviors.behaviorsLookup[key];\n}\n\n// Iterate over the behaviors object, for each behavior\n// instantiate it and get its grouped behaviors.\n// This accepts a list of behaviors in either an object or array form\nfunction parseBehaviors(view, behaviors) {\n return _.chain(behaviors).map(function(options, key) {\n const BehaviorClass = getBehaviorClass(options, key);\n //if we're passed a class directly instead of an object\n const _options = options === BehaviorClass ? {} : options;\n const behavior = new BehaviorClass(_options, view);\n const nestedBehaviors = parseBehaviors(view, _.result(behavior, 'behaviors'));\n\n return [behavior].concat(nestedBehaviors);\n }).flatten().value();\n}\n\nexport default {\n _initBehaviors() {\n const behaviors = _.result(this, 'behaviors');\n\n // Behaviors defined on a view can be a flat object literal\n // or it can be a function that returns an object.\n this._behaviors = _.isObject(behaviors) ? parseBehaviors(this, behaviors) : {};\n },\n\n _getBehaviorTriggers() {\n const triggers = _invoke(this._behaviors, 'getTriggers');\n return _.extend({}, ...triggers);\n },\n\n _getBehaviorEvents() {\n const events = _invoke(this._behaviors, 'getEvents');\n return _.extend({}, ...events);\n },\n\n // proxy behavior $el to the view's $el.\n _proxyBehaviorViewProperties() {\n _invoke(this._behaviors, 'proxyViewProperties');\n },\n\n // delegate modelEvents and collectionEvents\n _delegateBehaviorEntityEvents() {\n _invoke(this._behaviors, 'delegateEntityEvents');\n },\n\n // undelegate modelEvents and collectionEvents\n _undelegateBehaviorEntityEvents() {\n _invoke(this._behaviors, 'undelegateEntityEvents');\n },\n\n _destroyBehaviors(args) {\n // Call destroy on each behavior after\n // destroying the view.\n // This unbinds event listeners\n // that behaviors have registered for.\n _invoke(this._behaviors, 'destroy', ...args);\n },\n\n _bindBehaviorUIElements() {\n _invoke(this._behaviors, 'bindUIElements');\n },\n\n _unbindBehaviorUIElements() {\n _invoke(this._behaviors, 'unbindUIElements');\n },\n\n _triggerEventOnBehaviors() {\n const behaviors = this._behaviors;\n // Use good ol' for as this is a very hot function\n for (let i = 0, length = behaviors && behaviors.length; i < length; i++) {\n triggerMethod.apply(behaviors[i], arguments);\n }\n }\n};\n","import _ from 'underscore';\n\n// Borrow event splitter from Backbone\nconst delegateEventSplitter = /^(\\S+)\\s*(.*)$/;\n\nfunction uniqueName(eventName, selector) {\n return [eventName + _.uniqueId('.evt'), selector].join(' ');\n}\n\n// Set event name to be namespaced using a unique index\n// to generate a non colliding event namespace\n// http://api.jquery.com/event.namespace/\nconst getUniqueEventName = function(eventName) {\n const match = eventName.match(delegateEventSplitter);\n return uniqueName(match[1], match[2]);\n};\n\nexport default getUniqueEventName;\n","import _ from 'underscore';\nimport getUniqueEventName from '../utils/get-unique-event-name';\n\n// Internal method to create an event handler for a given `triggerDef` like\n// 'click:foo'\nfunction buildViewTrigger(view, triggerDef) {\n if (_.isString(triggerDef)) {\n triggerDef = {event: triggerDef};\n }\n\n const eventName = triggerDef.event;\n const shouldPreventDefault = triggerDef.preventDefault !== false;\n const shouldStopPropagation = triggerDef.stopPropagation !== false;\n\n return function(e) {\n if (shouldPreventDefault) {\n e.preventDefault();\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n\n view.triggerMethod(eventName, view);\n };\n}\n\nexport default {\n\n // Configure `triggers` to forward DOM events to view\n // events. `triggers: {\"click .foo\": \"do:foo\"}`\n _getViewTriggers(view, triggers) {\n // Configure the triggers, prevent default\n // action and stop propagation of DOM events\n return _.reduce(triggers, (events, value, key) => {\n key = getUniqueEventName(key);\n events[key] = buildViewTrigger(view, value);\n return events;\n }, {});\n }\n\n};\n","import { triggerMethodOn } from '../common/trigger-method';\n\nexport default function destroyBackboneView(view) {\n if (!view.supportsDestroyLifecycle) {\n triggerMethodOn(view, 'before:destroy', view);\n }\n\n const shouldTriggerDetach = !!view._isAttached;\n\n if (shouldTriggerDetach) {\n triggerMethodOn(view, 'before:detach', view);\n }\n\n view.remove();\n\n if (shouldTriggerDetach) {\n view._isAttached = false;\n triggerMethodOn(view, 'detach', view);\n }\n\n view._isDestroyed = true;\n\n if (!view.supportsDestroyLifecycle) {\n triggerMethodOn(view, 'destroy', view);\n }\n}\n","import _ from 'underscore';\nimport deprecate from '../utils/deprecate';\nimport MarionetteError from '../error';\nimport Region from '../region';\n\n// return the region instance from the definition\nexport default function(definition, defaults) {\n if (definition instanceof Region) {\n return definition;\n }\n\n return buildRegionFromDefinition(definition, defaults);\n}\n\nfunction buildRegionFromDefinition(definition, defaults) {\n const opts = _.extend({}, defaults);\n\n if (_.isString(definition)) {\n _.extend(opts, { el: definition });\n\n return buildRegionFromObject(opts);\n }\n\n if (_.isFunction(definition)) {\n _.extend(opts, { regionClass: definition });\n\n return buildRegionFromObject(opts);\n }\n\n if (_.isObject(definition)) {\n if (definition.selector) {\n deprecate('The selector option on a Region definition object is deprecated. Use el to pass a selector string');\n }\n\n _.extend(opts, { el: definition.selector }, definition);\n\n return buildRegionFromObject(opts);\n }\n\n throw new MarionetteError({\n message: 'Improper region configuration type.',\n url: 'marionette.region.html#region-configuration-types'\n });\n}\n\nfunction buildRegionFromObject(definition) {\n const RegionClass = definition.regionClass\n\n const options = _.omit(definition, 'regionClass');\n\n return new RegionClass(options);\n}\n","import MarionetteError from '../error';\n\n// Placeholder method to be extended by the user.\n// The method should define the object that stores the behaviors.\n// i.e.\n//\n// ```js\n// Marionette.Behaviors.behaviorsLookup: function() {\n// return App.Behaviors\n// }\n// ```\nexport default function behaviorsLookup() {\n throw new MarionetteError({\n message: 'You must define where your behaviors are stored.',\n url: 'marionette.behaviors.md#behaviorslookup'\n });\n}\n","// Add Feature flags here\n// e.g. 'class' => false\nconst FEATURES = {\n};\n\nfunction isEnabled(name) {\n return !!FEATURES[name];\n}\n\nfunction setEnabled(name, state) {\n return FEATURES[name] = state;\n}\n\nexport {\n FEATURES,\n setEnabled,\n isEnabled\n};\n","//Internal utility for creating context style global utils\nconst proxy = function(method) {\n return function(context, ...args) {\n return method.apply(context, args);\n };\n};\n\nexport default proxy;\n","// Marionette.extend\n// -----------------\n\nimport Backbone from 'backbone';\n\n// Borrow the Backbone `extend` method so we can use it as needed\nconst extend = Backbone.Model.extend;\n\nexport default extend;\n","/* global console */\n\nimport _ from 'underscore';\n\nimport Marionette from '../backbone.marionette';\n\nconst deprecate = function(message, test) {\n if (_.isObject(message)) {\n message = (\n message.prev + ' is going to be removed in the future. ' +\n 'Please use ' + message.next + ' instead.' +\n (message.url ? ' See: ' + message.url : '')\n );\n }\n\n if (!Marionette.DEV_MODE) {\n return;\n }\n\n if ((test === undefined || !test) && !deprecate._cache[message]) {\n deprecate._warn('Deprecation warning: ' + message);\n deprecate._cache[message] = true;\n }\n};\n\ndeprecate._console = typeof console !== 'undefined' ? console : {};\ndeprecate._warn = function() {\n const warn = deprecate._console.warn || deprecate._console.log || _.noop;\n return warn.apply(deprecate._console, arguments);\n};\ndeprecate._cache = {};\n\nexport default deprecate;\n","// Marionette.isNodeAttached\n// -------------------------\n\nimport Backbone from 'backbone';\n\n// Determine if `el` is a child of the document\nconst isNodeAttached = function(el) {\n return Backbone.$.contains(document.documentElement, el);\n};\n\nexport default isNodeAttached;\n","import _ from 'underscore';\n\n// Merge `keys` from `options` onto `this`\nconst mergeOptions = function(options, keys) {\n if (!options) { return; }\n\n _.each(keys, (key) => {\n const option = options[key];\n if (option !== undefined) {\n this[key] = option;\n }\n });\n};\n\nexport default mergeOptions;\n","// Marionette.getOption\n// --------------------\n\n// Retrieve an object, function or other value from the\n// object or its `options`, with `options` taking precedence.\nconst getOption = function(optionName) {\n if (!optionName) { return; }\n if (this.options && (this.options[optionName] !== undefined)) {\n return this.options[optionName];\n } else {\n return this[optionName];\n }\n};\n\nexport default getOption;\n","import _ from 'underscore';\n\n// Marionette.normalizeMethods\n// ----------------------\n\n// Pass in a mapping of events => functions or function names\n// and return a mapping of events => functions\nconst normalizeMethods = function(hash) {\n return _.reduce(hash, (normalizedHash, method, name) => {\n if (!_.isFunction(method)) {\n method = this[method];\n }\n if (method) {\n normalizedHash[name] = method;\n }\n return normalizedHash;\n }, {});\n};\n\nexport default normalizeMethods;\n","// Error\n// -----\n\nimport _ from 'underscore';\nimport extend from './utils/extend';\nimport {version} from '../package.json';\n\nconst errorProps = ['description', 'fileName', 'lineNumber', 'name', 'message', 'number'];\n\nconst MarionetteError = extend.call(Error, {\n urlRoot: `http://marionettejs.com/docs/v${version}/`,\n\n constructor(message, options) {\n if (_.isObject(message)) {\n options = message;\n message = options.message;\n } else if (!options) {\n options = {};\n }\n\n const error = Error.call(this, message);\n _.extend(this, _.pick(error, errorProps), _.pick(options, errorProps));\n\n this.captureStackTrace();\n\n if (options.url) {\n this.url = this.urlRoot + options.url;\n }\n },\n\n captureStackTrace() {\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, MarionetteError);\n }\n },\n\n toString() {\n return this.name + ': ' + this.message + (this.url ? ' See: ' + this.url : '');\n }\n});\n\nMarionetteError.extend = extend;\n\nexport default MarionetteError;\n","import _ from 'underscore';\n\n// Internal utility for setting options consistently across Mn\nconst setOptions = function(...args) {\n this.options = _.extend({}, _.result(this, 'options'), ...args);\n};\n\nexport default setOptions;\n","import _setOptions from '../utils/set-options';\nimport getOption from '../common/get-option';\nimport mergeOptions from '../common/merge-options';\nimport normalizeMethods from '../common/normalize-methods';\nimport {\n bindEvents,\n unbindEvents\n} from '../common/bind-events';\n\nexport default {\n\n // Imports the \"normalizeMethods\" to transform hashes of\n // events=>function references/names to a hash of events=>function references\n normalizeMethods: normalizeMethods,\n\n _setOptions: _setOptions,\n\n // A handy way to merge passed-in options onto the instance\n mergeOptions: mergeOptions,\n\n // Enable getting options from this or this.options by name.\n getOption: getOption,\n\n // Enable binding view's events from another entity.\n bindEvents: bindEvents,\n\n // Enable unbinding view's events from another entity.\n unbindEvents: unbindEvents\n};\n","import _ from 'underscore';\nimport Radio from 'backbone.radio';\n\nimport {\n bindRequests,\n unbindRequests\n} from '../common/bind-requests';\n\nimport {\n bindEvents,\n unbindEvents\n} from '../common/bind-events';\n\nimport MarionetteError from '../error';\n\n// MixinOptions\n// - channelName\n// - radioEvents\n// - radioRequests\n\nexport default {\n\n _initRadio() {\n const channelName = _.result(this, 'channelName');\n\n if (!channelName) {\n return;\n }\n\n /* istanbul ignore next */\n if (!Radio) {\n throw new MarionetteError({\n name: 'BackboneRadioMissing',\n message: 'The dependency \"backbone.radio\" is missing.'\n });\n }\n\n const channel = this._channel = Radio.channel(channelName);\n\n const radioEvents = _.result(this, 'radioEvents');\n this.bindEvents(channel, radioEvents);\n\n const radioRequests = _.result(this, 'radioRequests');\n this.bindRequests(channel, radioRequests);\n\n this.on('destroy', this._destroyRadio);\n },\n\n _destroyRadio() {\n this._channel.stopReplying(null, null, this);\n },\n\n getChannel() {\n return this._channel;\n },\n\n // Proxy `bindEvents`\n bindEvents: bindEvents,\n\n // Proxy `unbindEvents`\n unbindEvents: unbindEvents,\n\n // Proxy `bindRequests`\n bindRequests: bindRequests,\n\n // Proxy `unbindRequests`\n unbindRequests: unbindRequests\n\n};\n","// Object\n// ------\n\nimport _ from 'underscore';\nimport Backbone from 'backbone';\nimport extend from './utils/extend';\nimport { triggerMethod } from './common/trigger-method';\nimport CommonMixin from './mixins/common';\nimport RadioMixin from './mixins/radio';\n\nconst ClassOptions = [\n 'channelName',\n 'radioEvents',\n 'radioRequests'\n];\n\n// A Base Class that other Classes should descend from.\n// Object borrows many conventions and utilities from Backbone.\nconst MarionetteObject = function(options) {\n this._setOptions(options);\n this.mergeOptions(options, ClassOptions);\n this.cid = _.uniqueId(this.cidPrefix);\n this._initRadio();\n this.initialize.apply(this, arguments);\n};\n\nMarionetteObject.extend = extend;\n\n// Object Methods\n// --------------\n\n// Ensure it can trigger events with Backbone.Events\n_.extend(MarionetteObject.prototype, Backbone.Events, CommonMixin, RadioMixin, {\n cidPrefix: 'mno',\n\n // for parity with Marionette.AbstractView lifecyle\n _isDestroyed: false,\n\n isDestroyed() {\n return this._isDestroyed;\n },\n\n //this is a noop method intended to be overridden by classes that extend from this base\n initialize() {},\n\n destroy(...args) {\n if (this._isDestroyed) { return this; }\n\n this.triggerMethod('before:destroy', this, ...args);\n\n this._isDestroyed = true;\n this.triggerMethod('destroy', this, ...args);\n this.stopListening();\n\n return this;\n },\n\n triggerMethod: triggerMethod\n});\n\nexport default MarionetteObject;\n","// Template Cache\n// --------------\n\nimport _ from 'underscore';\nimport Backbone from 'backbone';\nimport MarionetteError from './error';\n\n// Manage templates stored in `<script>` blocks,\n// caching them for faster access.\nconst TemplateCache = function(templateId) {\n this.templateId = templateId;\n};\n\n// TemplateCache object-level methods. Manage the template\n// caches from these method calls instead of creating\n// your own TemplateCache instances\n_.extend(TemplateCache, {\n templateCaches: {},\n\n // Get the specified template by id. Either\n // retrieves the cached version, or loads it\n // from the DOM.\n get(templateId, options) {\n let cachedTemplate = this.templateCaches[templateId];\n\n if (!cachedTemplate) {\n cachedTemplate = new TemplateCache(templateId);\n this.templateCaches[templateId] = cachedTemplate;\n }\n\n return cachedTemplate.load(options);\n },\n\n // Clear templates from the cache. If no arguments\n // are specified, clears all templates:\n // `clear()`\n //\n // If arguments are specified, clears each of the\n // specified templates from the cache:\n // `clear(\"#t1\", \"#t2\", \"...\")`\n clear(...args) {\n let i;\n const length = args.length;\n\n if (length > 0) {\n for (i = 0; i < length; i++) {\n delete this.templateCaches[args[i]];\n }\n } else {\n this.templateCaches = {};\n }\n }\n});\n\n// TemplateCache instance methods, allowing each\n// template cache object to manage its own state\n// and know whether or not it has been loaded\n_.extend(TemplateCache.prototype, {\n\n // Internal method to load the template\n load(options) {\n // Guard clause to prevent loading this template more than once\n if (this.compiledTemplate) {\n return this.compiledTemplate;\n }\n\n // Load the template and compile it\n const template = this.loadTemplate(this.templateId, options);\n this.compiledTemplate = this.compileTemplate(template, options);\n\n return this.compiledTemplate;\n },\n\n // Load a template from the DOM, by default. Override\n // this method to provide your own template retrieval\n // For asynchronous loading with AMD/RequireJS, consider\n // using a template-loader plugin as described here:\n // https://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs\n loadTemplate(templateId, options) {\n const $template = Backbone.$(templateId);\n\n if (!$template.length) {\n throw new MarionetteError({\n name: 'NoTemplateError',\n message: `Could not find template: \"${templateId}\"`\n });\n }\n return $template.html();\n },\n\n // Pre-compile the template before caching it. Override\n // this method if you do not need to pre-compile a template\n // (JST / RequireJS for example) or if you want to change\n // the template engine used (Handebars, etc).\n compileTemplate(rawTemplate, options) {\n return _.template(rawTemplate, options);\n }\n});\n\nexport default TemplateCache;\n","// Implementation of the invoke method (http://underscorejs.org/#invoke) with support for\n// lodash v3, v4, and underscore.js\nimport _ from 'underscore';\n\nexport default _.invokeMap || _.invoke;\n","import _ from 'underscore';\n\nimport {\n bindEvents,\n unbindEvents\n} from '../common/bind-events';\n\n// MixinOptions\n// - collectionEvents\n// - modelEvents\n\nexport default {\n // Handle `modelEvents`, and `collectionEvents` configuration\n _delegateEntityEvents(model, collection) {\n this._undelegateEntityEvents(model, collection);\n\n const modelEvents = _.result(this, 'modelEvents');\n bindEvents.call(this, model, modelEvents);\n\n const collectionEvents = _.result(this, 'collectionEvents');\n bindEvents.call(this, collection, collectionEvents);\n },\n\n _undelegateEntityEvents(model, collection) {\n const modelEvents = _.result(this, 'modelEvents');\n unbindEvents.call(this, model, modelEvents);\n\n const collectionEvents = _.result(this, 'collectionEvents');\n unbindEvents.call(this, collection, collectionEvents);\n }\n};\n","import _ from 'underscore';\n// allows for the use of the @ui. syntax within\n// a given key for triggers and events\n// swaps the @ui with the associated selector.\n// Returns a new, non-mutated, parsed events hash.\nconst normalizeUIKeys = function(hash, ui) {\n return _.reduce(hash, (memo, val, key) => {\n const normalizedKey = normalizeUIString(key, ui);\n memo[normalizedKey] = val;\n return memo;\n }, {});\n};\n\n// utility method for parsing @ui. syntax strings\n// into associated selector\nconst normalizeUIString = function(uiString, ui) {\n return uiString.replace(/@ui\\.[a-zA-Z-_$0-9]*/g, (r) => {\n return ui[r.slice(4)];\n });\n};\n\n// allows for the use of the @ui. syntax within\n// a given value for regions\n// swaps the @ui with the associated selector\nconst normalizeUIValues = function(hash, ui, properties) {\n _.each(hash, (val, key) => {\n if (_.isString(val)) {\n hash[key] = normalizeUIString(val, ui);\n } else if (_.isObject(val) && _.isArray(properties)) {\n _.extend(val, normalizeUIValues(_.pick(val, properties), ui));\n /* Value is an object, and we got an array of embedded property names to normalize. */\n _.each(properties, (property) => {\n const propertyVal = val[property];\n if (_.isString(propertyVal)) {\n val[property] = normalizeUIString(propertyVal, ui);\n }\n });\n }\n });\n return hash;\n};\n\nexport default {\n\n // normalize the keys of passed hash with the views `ui` selectors.\n // `{\"@ui.foo\": \"bar\"}`\n normalizeUIKeys(hash) {\n const uiBindings = this._getUIBindings();\n return normalizeUIKeys(hash, uiBindings);\n },\n\n // normalize the passed string with the views `ui` selectors.\n // `\"@ui.bar\"`\n normalizeUIString(uiString) {\n const uiBindings = this._getUIBindings();\n return normalizeUIString(uiString, uiBindings);\n },\n\n // normalize the values of passed hash with the views `ui` selectors.\n // `{foo: \"@ui.bar\"}`\n normalizeUIValues(hash, properties) {\n const uiBindings = this._getUIBindings();\n return normalizeUIValues(hash, uiBindings, properties);\n },\n\n _getUIBindings() {\n const uiBindings = _.result(this, '_uiBindings');\n const ui = _.result(this, 'ui');\n return uiBindings || ui;\n },\n\n // This method binds the elements specified in the \"ui\" hash inside the view's code with\n // the associated jQuery selectors.\n _bindUIElements() {\n if (!this.ui) { return; }\n\n // store the ui hash in _uiBindings so they can be reset later\n // and so re-rendering the view will be able to find the bindings\n if (!this._uiBindings) {\n this._uiBindings = this.ui;\n }\n\n // get the bindings result, as a function or otherwise\n const bindings = _.result(this, '_uiBindings');\n\n // empty the ui so we don't have anything to start with\n this._ui = {};\n\n // bind each of the selectors\n _.each(bindings, (selector, key) => {\n this._ui[key] = this.$(selector);\n });\n\n this.ui = this._ui;\n },\n\n _unbindUIElements() {\n if (!this.ui || !this._uiBindings) { return; }\n\n // delete all of the existing ui bindings\n _.each(this.ui, ($el, name) => {\n delete this.ui[name];\n });\n\n // reset the ui element to the original bindings configuration\n this.ui = this._uiBindings;\n delete this._uiBindings;\n delete this._ui;\n },\n\n _getUI(name) {\n return this._ui[name];\n }\n};\n","// ViewMixin\n// ---------\n\nimport Backbone from 'backbone';\nimport _ from 'underscore';\nimport { triggerMethod } from '../common/trigger-method';\nimport BehaviorsMixin from './behaviors';\nimport CommonMixin from './common';\nimport DelegateEntityEventsMixin from './delegate-entity-events';\nimport TriggersMixin from './triggers';\nimport UIMixin from './ui';\nimport View from '../view';\nimport MarionetteError from '../error';\n\n// MixinOptions\n// - behaviors\n// - childViewEventPrefix\n// - childViewEvents\n// - childViewTriggers\n// - collectionEvents\n// - modelEvents\n// - triggers\n// - ui\n\n\nconst ViewMixin = {\n supportsRenderLifecycle: true,\n supportsDestroyLifecycle: true,\n\n _isDestroyed: false,\n\n isDestroyed() {\n return !!this._isDestroyed;\n },\n\n _isRendered: false,\n\n isRendered() {\n return !!this._isRendered;\n },\n\n _isAttached: false,\n\n isAttached() {\n return !!this._isAttached;\n },\n\n // Overriding Backbone.View's `delegateEvents` to handle\n // `events` and `triggers`\n delegateEvents(eventsArg) {\n\n this._proxyBehaviorViewProperties();\n this._buildEventProxies();\n\n const viewEvents = this._getEvents(eventsArg);\n\n if (typeof eventsArg === 'undefined') {\n this.events = viewEvents;\n }\n\n const combinedEvents = _.extend({},\n this._getBehaviorEvents(),\n viewEvents,\n this._getBehaviorTriggers(),\n this.getTriggers()\n );\n\n Backbone.View.prototype.delegateEvents.call(this, combinedEvents);\n\n return this;\n },\n\n _getEvents(eventsArg) {\n const events = eventsArg || this.events;\n\n if (_.isFunction(events)) {\n return this.normalizeUIKeys(events.call(this));\n }\n\n return this.normalizeUIKeys(events);\n },\n\n // Configure `triggers` to forward DOM events to view\n // events. `triggers: {\"click .foo\": \"do:foo\"}`\n getTriggers() {\n if (!this.triggers) { return; }\n\n // Allow `triggers` to be configured as a function\n const triggers = this.normalizeUIKeys(_.result(this, 'triggers'));\n\n // Configure the triggers, prevent default\n // action and stop propagation of DOM events\n return this._getViewTriggers(this, triggers);\n },\n\n // Handle `modelEvents`, and `collectionEvents` configuration\n delegateEntityEvents() {\n this._delegateEntityEvents(this.model, this.collection);\n\n // bind each behaviors model and collection events\n this._delegateBehaviorEntityEvents();\n\n return this;\n },\n\n // Handle unbinding `modelEvents`, and `collectionEvents` configuration\n undelegateEntityEvents() {\n this._undelegateEntityEvents(this.model, this.collection);\n\n // unbind each behaviors model and collection events\n this._undelegateBehaviorEntityEvents();\n\n return this;\n },\n\n // Internal helper method to verify whether the view hasn't been destroyed\n _ensureViewIsIntact() {\n if (this._isDestroyed) {\n throw new MarionetteError({\n name: 'ViewDestroyedError',\n message: `View (cid: \"${this.cid}\") has already been destroyed and cannot be used.`\n });\n }\n },\n\n // Handle destroying the view and its children.\n destroy(...args) {\n if (this._isDestroyed) { return this; }\n const shouldTriggerDetach = !!this._isAttached;\n\n this.triggerMethod('before:destroy', this, ...args);\n if (shouldTriggerDetach) {\n this.triggerMethod('before:detach', this);\n }\n\n // unbind UI elements\n this.unbindUIElements();\n\n // remove the view from the DOM\n // https://github.com/jashkenas/backbone/blob/1.2.3/backbone.js#L1235\n this._removeElement();\n\n if (shouldTriggerDetach) {\n this._isAttached = false;\n this.triggerMethod('detach', this);\n }\n\n // remove children after the remove to prevent extra paints\n this._removeChildren();\n\n this._destroyBehaviors(args);\n\n this._isDestroyed = true;\n this._isRendered = false;\n this.triggerMethod('destroy', this, ...args);\n\n this.stopListening();\n\n return this;\n },\n\n bindUIElements() {\n this._bindUIElements();\n this._bindBehaviorUIElements();\n\n return this;\n },\n\n // This method unbinds the elements specified in the \"ui\" hash\n unbindUIElements() {\n this._unbindUIElements();\n this._unbindBehaviorUIElements();\n\n return this;\n },\n\n getUI(name) {\n this._ensureViewIsIntact();\n return this._getUI(name);\n },\n\n // used as the prefix for child view events\n // that are forwarded through the layoutview\n childViewEventPrefix: 'childview',\n\n // import the `triggerMethod` to trigger events with corresponding\n // methods if the method exists\n triggerMethod() {\n const ret = triggerMethod.apply(this, arguments);\n\n this._triggerEventOnBehaviors.apply(this, arguments);\n this._triggerEventOnParentLayout.apply(this, arguments);\n\n return ret;\n },\n\n // Cache `childViewEvents` and `childViewTriggers`\n _buildEventProxies() {\n this._childViewEvents = _.result(this, 'childViewEvents');\n this._childViewTriggers = _.result(this, 'childViewTriggers');\n },\n\n _triggerEventOnParentLayout() {\n const layoutView = this._parentView();\n if (!layoutView) {\n return;\n }\n\n layoutView._childViewEventHandler.apply(layoutView, arguments);\n },\n\n // Walk the _parent tree until we find a view (if one exists).\n // Returns the parent view hierarchically closest to this view.\n _parentView() {\n let parent = this._parent;\n\n while (parent) {\n if (parent instanceof View) {\n return parent;\n }\n parent = parent._parent;\n }\n },\n\n _childViewEventHandler(eventName, ...args) {\n const childViewEvents = this.normalizeMethods(this._childViewEvents);\n\n // call collectionView childViewEvent if defined\n if (typeof childViewEvents !== 'undefined' && _.isFunction(childViewEvents[eventName])) {\n childViewEvents[eventName].apply(this, args);\n }\n\n // use the parent view's proxyEvent handlers\n const childViewTriggers = this._childViewTriggers;\n\n // Call the event with the proxy name on the parent layout\n if (childViewTriggers && _.isString(childViewTriggers[eventName])) {\n this.triggerMethod(childViewTriggers[eventName], ...args);\n }\n\n const prefix = _.result(this, 'childViewEventPrefix');\n\n if (prefix !== false) {\n const childEventName = prefix + ':' + eventName;\n\n this.triggerMethod(childEventName, ...args);\n }\n }\n};\n\n_.extend(ViewMixin, BehaviorsMixin, CommonMixin, DelegateEntityEventsMixin, TriggersMixin, UIMixin);\n\nexport default ViewMixin;\n","// Region\n// ------\n\nimport _ from 'underscore';\nimport Backbone from 'backbone';\nimport deprecate from './utils/deprecate';\nimport destroyBackboneView from './utils/destroy-backbone-view';\nimport monitorViewEvents from './common/monitor-view-events';\nimport isNodeAttached from './common/is-node-attached';\nimport { triggerMethodOn } from './common/trigger-method';\nimport MarionetteObject from './object';\nimport MarionetteError from './error';\n\nconst ClassOptions = [\n 'allowMissingEl',\n 'parentEl',\n 'replaceElement'\n];\n\nconst Region = MarionetteObject.extend({\n cidPrefix: 'mnr',\n replaceElement: false,\n _isReplaced: false,\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n // getOption necessary because options.el may be passed as undefined\n this._initEl = this.el = this.getOption('el');\n\n // Handle when this.el is passed in as a $ wrapped element.\n this.el = this.el instanceof Backbone.$ ? this.el[0] : this.el;\n\n if (!this.el) {\n throw new MarionetteError({\n name: 'NoElError',\n message: 'An \"el\" must be specified for a region.'\n });\n }\n\n this.$el = this.getEl(this.el);\n MarionetteObject.call(this, options);\n },\n\n // Displays a backbone view instance inside of the region. Handles calling the `render`\n // method for you. Reads content directly from the `el` attribute. The `preventDestroy`\n // option can be used to prevent a view from the old view being destroyed on show.\n show(view, options) {\n if (!this._ensureElement(options)) {\n return;\n }\n this._ensureView(view);\n if (view === this.currentView) { return this; }\n\n this.triggerMethod('before:show', this, view, options);\n\n monitorViewEvents(view);\n\n this.empty(options);\n\n // We need to listen for if a view is destroyed in a way other than through the region.\n // If this happens we need to remove the reference to the currentView since once a view\n // has been destroyed we can not reuse it.\n view.on('destroy', this._empty, this);\n\n // Make this region the view's parent.\n // It's important that this parent binding happens before rendering so that any events\n // the child may trigger during render can also be triggered on the child's ancestor views.\n view._parent = this;\n\n this._renderView(view);\n\n this._attachView(view, options);\n\n this.triggerMethod('show', this, view, options);\n return this;\n },\n\n _renderView(view) {\n if (view._isRendered) {\n return;\n }\n\n if (!view.supportsRenderLifecycle) {\n triggerMethodOn(view, 'before:render', view);\n }\n\n view.render();\n\n if (!view.supportsRenderLifecycle) {\n view._isRendered = true;\n triggerMethodOn(view, 'render', view);\n }\n },\n\n _attachView(view, options = {}) {\n const shouldTriggerAttach = !view._isAttached && isNodeAttached(this.el);\n const shouldReplaceEl = typeof options.replaceElement === 'undefined' ? !!_.result(this, 'replaceElement') : !!options.replaceElement;\n\n if (shouldTriggerAttach) {\n triggerMethodOn(view, 'before:attach', view);\n }\n\n if (shouldReplaceEl) {\n this._replaceEl(view);\n } else {\n this.attachHtml(view);\n }\n\n if (shouldTriggerAttach) {\n view._isAttached = true;\n triggerMethodOn(view, 'attach', view);\n }\n\n this.currentView = view;\n },\n\n _ensureElement(options = {}) {\n if (!_.isObject(this.el)) {\n this.$el = this.getEl(this.el);\n this.el = this.$el[0];\n }\n\n if (!this.$el || this.$el.length === 0) {\n const allowMissingEl = typeof options.allowMissingEl === 'undefined' ? !!_.result(this, 'allowMissingEl') : !!options.allowMissingEl;\n\n if (allowMissingEl) {\n return false;\n } else {\n throw new MarionetteError(`An \"el\" must exist in DOM for this region ${this.cid}`);\n }\n }\n return true;\n },\n\n _ensureView(view) {\n if (!view) {\n throw new MarionetteError({\n name: 'ViewNotValid',\n message: 'The view passed is undefined and therefore invalid. You must pass a view instance to show.'\n });\n }\n\n if (view._isDestroyed) {\n throw new MarionetteError({\n name: 'ViewDestroyedError',\n message: `View (cid: \"${view.cid}\") has already been destroyed and cannot be used.`\n });\n }\n },\n\n // Override this method to change how the region finds the DOM element that it manages. Return\n // a jQuery selector object scoped to a provided parent el or the document if none exists.\n getEl(el) {\n return Backbone.$(el, _.result(this, 'parentEl'));\n },\n\n _replaceEl(view) {\n // always restore the el to ensure the regions el is present before replacing\n this._restoreEl();\n\n const parent = this.el.parentNode;\n\n parent.replaceChild(view.el, this.el);\n this._isReplaced = true;\n },\n\n // Restore the region's element in the DOM.\n _restoreEl() {\n // There is nothing to replace\n if (!this._isReplaced) {\n return;\n }\n\n const view = this.currentView;\n\n if (!view) {\n return;\n }\n\n const parent = view.el.parentNode;\n\n if (!parent) {\n return;\n }\n\n parent.replaceChild(this.el, view.el);\n this._isReplaced = false;\n },\n\n // Check to see if the region's el was replaced.\n isReplaced() {\n return !!this._isReplaced;\n },\n\n // Override this method to change how the new view is appended to the `$el` that the\n // region is managing\n attachHtml(view) {\n this.el.appendChild(view.el);\n },\n\n // Destroy the current view, if there is one. If there is no current view, it does\n // nothing and returns immediately.\n empty(options = { allowMissingEl: true }) {\n const view = this.currentView;\n\n // If there is no view in the region we should only detach current html\n if (!view) {\n if (this._ensureElement(options)) {\n this.detachHtml();\n }\n return this;\n }\n\n const shouldDestroy = !options.preventDestroy;\n\n if (!shouldDestroy) {\n deprecate('The preventDestroy option is deprecated. Use Region#detachView');\n }\n\n this._empty(view, shouldDestroy);\n return this;\n },\n\n _empty(view, shouldDestroy) {\n view.off('destroy', this._empty, this);\n this.triggerMethod('before:empty', this, view);\n\n this._restoreEl();\n\n delete this.currentView;\n\n if (!view._isDestroyed) {\n this._removeView(view, shouldDestroy);\n delete view._parent;\n }\n\n this.triggerMethod('empty', this, view);\n },\n\n _removeView(view, shouldDestroy) {\n if (!shouldDestroy) {\n this._detachView(view);\n return;\n }\n\n if (view.destroy) {\n view.destroy();\n } else {\n destroyBackboneView(view);\n }\n },\n\n detachView() {\n const view = this.currentView;\n\n if (!view) {\n return;\n }\n\n this._empty(view);\n\n return view;\n },\n\n _detachView(view) {\n const shouldTriggerDetach = !!view._isAttached;\n if (shouldTriggerDetach) {\n triggerMethodOn(view, 'before:detach', view);\n }\n\n this.detachHtml();\n\n if (shouldTriggerDetach) {\n view._isAttached = false;\n triggerMethodOn(view, 'detach', view);\n }\n },\n\n // Override this method to change how the region detaches current content\n detachHtml() {\n this.$el.contents().detach();\n },\n\n // Checks whether a view is currently present within the region. Returns `true` if there is\n // and `false` if no view is present.\n hasView() {\n return !!this.currentView;\n },\n\n // Reset the region by destroying any existing view and clearing out the cached `$el`.\n // The next time a view is shown via this region, the region will re-query the DOM for\n // the region's `el`.\n reset(options) {\n this.empty(options);\n\n if (this.$el) {\n this.el = this._initEl;\n }\n\n delete this.$el;\n return this;\n },\n\n destroy(options) {\n this.reset(options);\n return MarionetteObject.prototype.destroy.apply(this, arguments);\n }\n});\n\nexport default Region;\n","import _ from 'underscore';\nimport _invoke from '../utils/invoke';\nimport buildRegion from '../common/build-region';\nimport Region from '../region';\n\n// MixinOptions\n// - regions\n// - regionClass\n\nexport default {\n regionClass: Region,\n\n // Internal method to initialize the regions that have been defined in a\n // `regions` attribute on this View.\n _initRegions() {\n\n // init regions hash\n this.regions = this.regions || {};\n this._regions = {};\n\n this.addRegions(_.result(this, 'regions'));\n },\n\n // Internal method to re-initialize all of the regions by updating\n // the `el` that they point to\n _reInitRegions() {\n _invoke(this._regions, 'reset');\n },\n\n // Add a single region, by name, to the View\n addRegion(name, definition) {\n const regions = {};\n regions[name] = definition;\n return this.addRegions(regions)[name];\n },\n\n // Add multiple regions as a {name: definition, name2: def2} object literal\n addRegions(regions) {\n // If there's nothing to add, stop here.\n if (_.isEmpty(regions)) {\n return;\n }\n\n // Normalize region selectors hash to allow\n // a user to use the @ui. syntax.\n regions = this.normalizeUIValues(regions, ['selector', 'el']);\n\n // Add the regions definitions to the regions property\n this.regions = _.extend({}, this.regions, regions);\n\n return this._addRegions(regions);\n },\n\n // internal method to build and add regions\n _addRegions(regionDefinitions) {\n const defaults = {\n regionClass: this.regionClass,\n parentEl: _.partial(_.result, this, 'el')\n };\n\n return _.reduce(regionDefinitions, (regions, definition, name) => {\n regions[name] = buildRegion(definition, defaults);\n this._addRegion(regions[name], name);\n return regions;\n }, {});\n },\n\n _addRegion(region, name) {\n this.triggerMethod('before:add:region', this, name, region);\n\n region._parent = this;\n\n this._regions[name] = region;\n\n this.triggerMethod('add:region', this, name, region);\n },\n\n // Remove a single region from the View, by name\n removeRegion(name) {\n const region = this._regions[name];\n\n this._removeRegion(region, name);\n\n return region;\n },\n\n // Remove all regions from the View\n removeRegions() {\n const regions = this.getRegions();\n\n _.each(this._regions, _.bind(this._removeRegion, this));\n\n return regions;\n },\n\n _removeRegion(region, name) {\n this.triggerMethod('before:remove:region', this, name, region);\n\n region.destroy();\n\n delete this.regions[name];\n delete this._regions[name];\n\n this.triggerMethod('remove:region', this, name, region);\n },\n\n // Empty all regions in the region manager, but\n // leave them attached\n emptyRegions() {\n const regions = this.getRegions();\n _invoke(regions, 'empty');\n return regions;\n },\n\n // Checks to see if view contains region\n // Accepts the region name\n // hasRegion('main')\n hasRegion(name) {\n return !!this.getRegion(name);\n },\n\n // Provides access to regions\n // Accepts the region name\n // getRegion('main')\n getRegion(name) {\n return this._regions[name];\n },\n\n // Get all regions\n getRegions() {\n return _.clone(this._regions);\n },\n\n showChildView(name, view, ...args) {\n const region = this.getRegion(name);\n return region.show(view, ...args);\n },\n\n detachChildView(name) {\n return this.getRegion(name).detachView();\n },\n\n getChildView(name) {\n return this.getRegion(name).currentView;\n }\n\n};\n","// Renderer\n// --------\n\nimport _ from 'underscore';\nimport MarionetteError from '../error';\nimport TemplateCache from '../template-cache';\n\n// Render a template with data by passing in the template\n// selector and the data to render.\nconst Renderer = {\n\n // Render a template with data. The `template` parameter is\n // passed to the `TemplateCache` object to retrieve the\n // template function. Override this method to provide your own\n // custom rendering and template handling for all of Marionette.\n render(template, data) {\n if (!template) {\n throw new MarionetteError({\n name: 'TemplateNotFoundError',\n message: 'Cannot render the template since its false, null or undefined.'\n });\n }\n\n const templateFunc = _.isFunction(template) ? template : TemplateCache.get(template);\n\n return templateFunc(data);\n }\n};\n\nexport default Renderer;\n","// View\n// ---------\n\nimport _ from 'underscore';\nimport Backbone from 'backbone';\nimport isNodeAttached from './common/is-node-attached';\nimport monitorViewEvents from './common/monitor-view-events';\nimport ViewMixin from './mixins/view';\nimport RegionsMixin from './mixins/regions';\nimport Renderer from './config/renderer';\n\nconst ClassOptions = [\n 'behaviors',\n 'childViewEventPrefix',\n 'childViewEvents',\n 'childViewTriggers',\n 'collectionEvents',\n 'events',\n 'modelEvents',\n 'regionClass',\n 'regions',\n 'template',\n 'templateContext',\n 'triggers',\n 'ui'\n];\n\n// The standard view. Includes view events, automatic rendering\n// of Underscore templates, nested views, and more.\nconst View = Backbone.View.extend({\n\n constructor(options) {\n this.render = _.bind(this.render, this);\n\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n monitorViewEvents(this);\n\n this._initBehaviors();\n this._initRegions();\n\n const args = Array.prototype.slice.call(arguments);\n args[0] = this.options;\n Backbone.View.prototype.constructor.apply(this, args);\n\n this.delegateEntityEvents();\n },\n\n // Serialize the view's model *or* collection, if\n // it exists, for the template\n serializeData() {\n if (!this.model && !this.collection) {\n return {};\n }\n\n // If we have a model, we serialize that\n if (this.model) {\n return this.serializeModel();\n }\n\n // Otherwise, we serialize the collection,\n // making it available under the `items` property\n return {\n items: this.serializeCollection()\n };\n },\n\n // Prepares the special `model` property of a view\n // for being displayed in the template. By default\n // we simply clone the attributes. Override this if\n // you need a custom transformation for your view's model\n serializeModel() {\n if (!this.model) { return {}; }\n return _.clone(this.model.attributes);\n },\n\n // Serialize a collection by cloning each of\n // its model's attributes\n serializeCollection() {\n if (!this.collection) { return {}; }\n return this.collection.map(function(model) { return _.clone(model.attributes); });\n },\n\n // Overriding Backbone.View's `setElement` to handle\n // if an el was previously defined. If so, the view might be\n // rendered or attached on setElement.\n setElement() {\n const hasEl = !!this.el;\n\n Backbone.View.prototype.setElement.apply(this, arguments);\n\n if (hasEl) {\n this._isRendered = !!this.$el.length;\n this._isAttached = isNodeAttached(this.el);\n }\n\n if (this._isRendered) {\n this.bindUIElements();\n }\n\n return this;\n },\n\n // Render the view, defaulting to underscore.js templates.\n // You can override this in your view definition to provide\n // a very specific rendering for your view. In general, though,\n // you should override the `Marionette.Renderer` object to\n // change how Marionette renders views.\n // Subsequent renders after the first will re-render all nested\n // views.\n render() {\n this._ensureViewIsIntact();\n\n this.triggerMethod('before:render', this);\n\n // If this is not the first render call, then we need to\n // re-initialize the `el` for each region\n if (this._isRendered) {\n this._reInitRegions();\n }\n\n this._renderTemplate();\n this.bindUIElements();\n\n this._isRendered = true;\n this.triggerMethod('render', this);\n\n return this;\n },\n\n // Internal method to render the template with the serialized data\n // and template context via the `Marionette.Renderer` object.\n _renderTemplate() {\n const template = this.getTemplate();\n\n // Allow template-less views\n if (template === false) {\n return;\n }\n\n // Add in entity data and template context\n const data = this.mixinTemplateContext(this.serializeData());\n\n // Render and add to el\n const html = Renderer.render(template, data, this);\n this.attachElContent(html);\n },\n\n // Get the template for this view\n // instance. You can set a `template` attribute in the view\n // definition or pass a `template: \"whatever\"` parameter in\n // to the constructor options.\n getTemplate() {\n return this.template;\n },\n\n // Mix in template context methods. Looks for a\n // `templateContext` attribute, which can either be an\n // object literal, or a function that returns an object\n // literal. All methods and attributes from this object\n // are copies to the object passed in.\n mixinTemplateContext(target = {}) {\n const templateContext = _.result(this, 'templateContext');\n return _.extend(target, templateContext);\n },\n\n // Attaches the content of a given view.\n // This method can be overridden to optimize rendering,\n // or to render in a non standard way.\n //\n // For example, using `innerHTML` instead of `$el.html`\n //\n // ```js\n // attachElContent(html) {\n // this.el.innerHTML = html;\n // return this;\n // }\n // ```\n attachElContent(html) {\n this.$el.html(html);\n\n return this;\n },\n\n // called by ViewMixin destroy\n _removeChildren() {\n this.removeRegions();\n },\n\n _getImmediateChildren() {\n return _.chain(this.getRegions())\n .map('currentView')\n .compact()\n .value();\n }\n});\n\n_.extend(View.prototype, ViewMixin, RegionsMixin);\n\nexport default View;\n","// Mix in methods from Underscore, for iteration, and other\n// collection related features.\n// Borrowing this code from Backbone.Collection:\n// https://github.com/jashkenas/backbone/blob/1.1.2/backbone.js#L962\n\nimport _ from 'underscore';\n\nconst methods = ['forEach', 'each', 'map', 'find', 'detect', 'filter',\n 'select', 'reject', 'every', 'all', 'some', 'any', 'include',\n 'contains', 'invoke', 'toArray', 'first', 'initial', 'rest',\n 'last', 'without', 'isEmpty', 'pluck', 'reduce'];\n\nconst emulateCollection = function(object, listProperty) {\n _.each(methods, function(method) {\n object[method] = function() {\n const list = _.values(_.result(this, listProperty));\n const args = [list].concat(_.toArray(arguments));\n return _[method].apply(_, args);\n };\n });\n};\n\nexport default emulateCollection;\n","import _ from 'underscore';\nimport emulateCollection from './utils/emulate-collection';\n\n// Provide a container to store, retrieve and\n// shut down child views.\nconst Container = function(views) {\n this._views = {};\n this._indexByModel = {};\n this._indexByCustom = {};\n this._updateLength();\n\n _.each(views, _.bind(this.add, this));\n};\n\nemulateCollection(Container.prototype, '_views');\n\n// Container Methods\n// -----------------\n\n_.extend(Container.prototype, {\n\n // Add a view to this container. Stores the view\n // by `cid` and makes it searchable by the model\n // cid (and model itself). Optionally specify\n // a custom key to store an retrieve the view.\n add(view, customIndex) {\n return this._add(view, customIndex)._updateLength();\n },\n\n // To be used when avoiding call _updateLength\n // When you are done adding all your new views\n // call _updateLength\n _add(view, customIndex) {\n const viewCid = view.cid;\n\n // store the view\n this._views[viewCid] = view;\n\n // index it by model\n if (view.model) {\n this._indexByModel[view.model.cid] = viewCid;\n }\n\n // index by custom\n if (customIndex) {\n this._indexByCustom[customIndex] = viewCid;\n }\n\n return this;\n },\n\n // Find a view by the model that was attached to\n // it. Uses the model's `cid` to find it.\n findByModel(model) {\n return this.findByModelCid(model.cid);\n },\n\n // Find a view by the `cid` of the model that was attached to\n // it. Uses the model's `cid` to find the view `cid` and\n // retrieve the view using it.\n findByModelCid(modelCid) {\n const viewCid = this._indexByModel[modelCid];\n return this.findByCid(viewCid);\n },\n\n // Find a view by a custom indexer.\n findByCustom(index) {\n const viewCid = this._indexByCustom[index];\n return this.findByCid(viewCid);\n },\n\n // Find by index. This is not guaranteed to be a\n // stable index.\n findByIndex(index) {\n return _.values(this._views)[index];\n },\n\n // retrieve a view by its `cid` directly\n findByCid(cid) {\n return this._views[cid];\n },\n\n // Remove a view\n remove(view) {\n return this._remove(view)._updateLength();\n },\n\n // To be used when avoiding call _updateLength\n // When you are done adding all your new views\n // call _updateLength\n _remove(view) {\n const viewCid = view.cid;\n\n // delete model index\n if (view.model) {\n delete this._indexByModel[view.model.cid];\n }\n\n // delete custom index\n _.some(this._indexByCustom, _.bind(function(cid, key) {\n if (cid === viewCid) {\n delete this._indexByCustom[key];\n return true;\n }\n }, this));\n\n // remove the view from the container\n delete this._views[viewCid];\n\n return this;\n },\n\n // Update the `.length` attribute on this container\n _updateLength() {\n this.length = _.size(this._views);\n\n return this;\n }\n});\n\nexport default Container;\n","// Collection View\n// ---------------\n\nimport _ from 'underscore';\nimport Backbone from 'backbone';\nimport destroyBackboneView from './utils/destroy-backbone-view';\nimport isNodeAttached from './common/is-node-attached';\nimport monitorViewEvents from './common/monitor-view-events';\nimport { triggerMethodOn } from './common/trigger-method';\nimport ChildViewContainer from './child-view-container';\nimport MarionetteError from './error';\nimport ViewMixin from './mixins/view';\n\nconst ClassOptions = [\n 'behaviors',\n 'childView',\n 'childViewEventPrefix',\n 'childViewEvents',\n 'childViewOptions',\n 'childViewTriggers',\n 'collectionEvents',\n 'events',\n 'filter',\n 'emptyView',\n 'emptyViewOptions',\n 'modelEvents',\n 'reorderOnSort',\n 'sort',\n 'triggers',\n 'ui',\n 'viewComparator'\n];\n\n// A view that iterates over a Backbone.Collection\n// and renders an individual child view for each model.\nconst CollectionView = Backbone.View.extend({\n\n // flag for maintaining the sorted order of the collection\n sort: true,\n\n // constructor\n // option to pass `{sort: false}` to prevent the `CollectionView` from\n // maintaining the sorted order of the collection.\n // This will fallback onto appending childView's to the end.\n //\n // option to pass `{viewComparator: compFunction()}` to allow the `CollectionView`\n // to use a custom sort order for the collection.\n constructor(options) {\n this.render = _.bind(this.render, this);\n\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n monitorViewEvents(this);\n\n this._initBehaviors();\n this.once('render', this._initialEvents);\n this._initChildViewStorage();\n this._bufferedChildren = [];\n\n const args = Array.prototype.slice.call(arguments);\n args[0] = this.options;\n Backbone.View.prototype.constructor.apply(this, args);\n\n this.delegateEntityEvents();\n },\n\n // Instead of inserting elements one by one into the page, it's much more performant to insert\n // elements into a document fragment and then insert that document fragment into the page\n _startBuffering() {\n this._isBuffering = true;\n },\n\n _endBuffering() {\n const shouldTriggerAttach = !!this._isAttached;\n const triggerOnChildren = shouldTriggerAttach ? this._getImmediateChildren() : [];\n\n this._isBuffering = false;\n\n _.each(triggerOnChildren, child => {\n triggerMethodOn(child, 'before:attach', child);\n });\n\n this.attachBuffer(this, this._createBuffer());\n\n _.each(triggerOnChildren, child => {\n child._isAttached = true;\n triggerMethodOn(child, 'attach', child);\n });\n\n this._bufferedChildren = [];\n },\n\n _getImmediateChildren() {\n return _.values(this.children._views);\n },\n\n // Configured the initial events that the collection view binds to.\n _initialEvents() {\n if (this.collection) {\n this.listenTo(this.collection, 'add', this._onCollectionAdd);\n this.listenTo(this.collection, 'update', this._onCollectionUpdate);\n this.listenTo(this.collection, 'reset', this.render);\n\n if (this.sort) {\n this.listenTo(this.collection, 'sort', this._sortViews);\n }\n }\n },\n\n // Handle a child added to the collection\n _onCollectionAdd(child, collection, opts) {\n // `index` is present when adding with `at` since BB 1.2; indexOf fallback for < 1.2\n let index = opts.at !== undefined && (opts.index || collection.indexOf(child));\n\n // When filtered or when there is no initial index, calculate index.\n if (this.filter || index === false) {\n index = _.indexOf(this._filteredSortedModels(index), child);\n }\n\n if (this._shouldAddChild(child, index)) {\n this._destroyEmptyView();\n this._addChild(child, index)\n }\n },\n\n // Handle collection update model removals\n _onCollectionUpdate(collection, options) {\n const changes = options.changes;\n this._removeChildModels(changes.removed);\n },\n\n // Remove the child views and destroy them.\n // This function also updates the indices of later views\n // in the collection in order to keep the children in sync with the collection.\n // \"models\" is an array of models and the corresponding views\n // will be removed and destroyed from the CollectionView\n _removeChildModels(models, {checkEmpty} = {}) {\n const shouldCheckEmpty = checkEmpty !== false;\n\n // Used to determine where to update the remaining\n // sibling view indices after these views are removed.\n const removedViews = this._getRemovedViews(models);\n\n if (!removedViews.length) {\n return;\n }\n\n this.children._updateLength();\n\n // decrement the index of views after this one\n this._updateIndices(removedViews, false);\n\n if (shouldCheckEmpty) {\n this._checkEmpty();\n }\n },\n\n // Returns the views that will be used for re-indexing\n // through CollectionView#_updateIndices.\n _getRemovedViews(models) {\n\n // Returning a view means something was removed.\n return _.reduce(models, (removingViews, model) => {\n const view = this.children.findByModel(model);\n\n if (!view || view._isDestroyed) {\n return removingViews;\n }\n\n this._removeChildView(view);\n\n removingViews.push(view);\n\n return removingViews;\n }, []);\n },\n\n _findGreatestIndexedView(views) {\n\n return _.reduce(views, (greatestIndexedView, view) => {\n // Even if the index is `undefined`, a view will get returned.\n if (!greatestIndexedView || greatestIndexedView._index < view._index) {\n return view;\n }\n\n return greatestIndexedView;\n }, undefined);\n },\n\n _removeChildView(view) {\n this.triggerMethod('before:remove:child', this, view);\n\n this.children._remove(view);\n if (view.destroy) {\n view.destroy();\n } else {\n destroyBackboneView(view);\n }\n\n delete view._parent;\n this.stopListening(view);\n this.triggerMethod('remove:child', this, view);\n },\n\n // Overriding Backbone.View's `setElement` to handle\n // if an el was previously defined. If so, the view might be\n // attached on setElement.\n setElement() {\n const hasEl = !!this.el;\n\n Backbone.View.prototype.setElement.apply(this, arguments);\n\n if (hasEl) {\n this._isAttached = isNodeAttached(this.el);\n }\n\n return this;\n },\n\n // Render children views. Override this method to provide your own implementation of a\n // render function for the collection view.\n render() {\n this._ensureViewIsIntact();\n this.triggerMethod('before:render', this);\n this._renderChildren();\n this._isRendered = true;\n this.triggerMethod('render', this);\n return this;\n },\n\n // An efficient rendering used for filtering. Instead of modifying the whole DOM for the\n // collection view, we are only adding or removing the related childrenViews.\n setFilter(filter, {preventRender} = {}) {\n const canBeRendered = this._isRendered && !this._isDestroyed;\n const filterChanged = this.filter !== filter;\n const shouldRender = canBeRendered && filterChanged && !preventRender;\n\n if (shouldRender) {\n const previousModels = this._filteredSortedModels();\n this.filter = filter;\n const models = this._filteredSortedModels();\n this._applyModelDeltas(models, previousModels);\n } else {\n this.filter = filter;\n }\n\n return this;\n },\n\n // `removeFilter` is actually an alias for removing filters.\n removeFilter(options) {\n return this.setFilter(null, options);\n },\n\n // Calculate and apply difference by cid between `models` and `previousModels`.\n _applyModelDeltas(models, previousModels) {\n const currentIds = {};\n _.each(models, (model, index) => {\n const addedChildNotExists = !this.children.findByModel(model);\n if (addedChildNotExists) {\n this._onCollectionAdd(model, this.collection, {at: index});\n }\n currentIds[model.cid] = true;\n });\n\n const removeModels = _.filter(previousModels, (prevModel) => {\n return !currentIds[prevModel.cid] && this.children.findByModel(prevModel);\n });\n\n this._removeChildModels(removeModels);\n },\n\n // Reorder DOM after sorting. When your element's rendering do not use their index,\n // you can pass reorderOnSort: true to only reorder the DOM after a sort instead of\n // rendering all the collectionView.\n reorder() {\n const children = this.children;\n const models = this._filteredSortedModels();\n\n if (!models.length && this._showingEmptyView) { return this; }\n\n const anyModelsAdded = _.some(models, function(model) {\n return !children.findByModel(model);\n });\n\n // If there are any new models added due to filtering we need to add child views,\n // so render as normal.\n if (anyModelsAdded) {\n this.render();\n } else {\n\n const filteredOutModels = [];\n\n // Get the DOM nodes in the same order as the models and\n // find the model that were children before but aren't in this new order.\n const elsToReorder = children.reduce(function(viewEls, view) {\n const index = _.indexOf(models, view.model);\n\n if (index === -1) {\n filteredOutModels.push(view.model);\n return viewEls;\n }\n\n view._index = index;\n\n viewEls[index] = view.el;\n\n return viewEls;\n }, new Array(models.length));\n\n this.triggerMethod('before:reorder', this);\n\n // Since append moves elements that are already in the DOM, appending the elements\n // will effectively reorder them.\n this._appendReorderedChildren(elsToReorder);\n\n // remove any views that have been filtered out\n this._removeChildModels(filteredOutModels);\n\n this.triggerMethod('reorder', this);\n }\n return this;\n },\n\n // Render view after sorting. Override this method to change how the view renders\n // after a `sort` on the collection.\n resortView() {\n if (this.reorderOnSort) {\n this.reorder();\n } else {\n this._renderChildren();\n }\n return this;\n },\n\n // Internal method. This checks for any changes in the order of the collection.\n // If the index of any view doesn't match, it will render.\n _sortViews() {\n const models = this._filteredSortedModels();\n\n // check for any changes in sort order of views\n const orderChanged = _.find(models, (item, index) => {\n const view = this.children.findByModel(item);\n return !view || view._index !== index;\n });\n\n if (orderChanged) {\n this.resortView();\n }\n },\n\n // Internal reference to what index a `emptyView` is.\n _emptyViewIndex: -1,\n\n // Internal method. Separated so that CompositeView can append to the childViewContainer\n // if necessary\n _appendReorderedChildren(children) {\n this.$el.append(children);\n },\n\n // Internal method. Separated so that CompositeView can have more control over events\n // being triggered, around the rendering process\n _renderChildren() {\n if (this._isRendered) {\n this._destroyEmptyView();\n this._destroyChildren({checkEmpty: false});\n }\n\n const models = this._filteredSortedModels();\n if (this.isEmpty({processedModels: models})) {\n this._showEmptyView();\n } else {\n this.triggerMethod('before:render:children', this);\n this._startBuffering();\n this._showCollection(models);\n this._endBuffering();\n this.triggerMethod('render:children', this);\n }\n },\n\n _createView(model, index) {\n const ChildView = this._getChildView(model);\n const childViewOptions = this._getChildViewOptions(model, index);\n const view = this.buildChildView(model, ChildView, childViewOptions);\n return view;\n },\n\n _setupChildView(view, index) {\n view._parent = this;\n\n monitorViewEvents(view);\n\n // set up the child view event forwarding\n this._proxyChildEvents(view);\n\n if (this.sort) {\n view._index = index;\n }\n },\n\n // Internal method to loop through collection and show each child view.\n _showCollection(models) {\n _.each(models, _.bind(this._addChild, this));\n this.children._updateLength();\n },\n\n // Allow the collection to be sorted by a custom view comparator\n _filteredSortedModels(addedAt) {\n if (!this.collection || !this.collection.length) { return []; }\n\n const viewComparator = this.getViewComparator();\n let models = this.collection.models;\n addedAt = Math.min(Math.max(addedAt, 0), models.length - 1);\n\n if (viewComparator) {\n let addedModel;\n // Preserve `at` location, even for a sorted view\n if (addedAt) {\n addedModel = models[addedAt];\n models = models.slice(0, addedAt).concat(models.slice(addedAt + 1));\n }\n models = this._sortModelsBy(models, viewComparator);\n if (addedModel) {\n models.splice(addedAt, 0, addedModel);\n }\n }\n\n // Filter after sorting in case the filter uses the index\n models = this._filterModels(models);\n\n return models;\n },\n\n getViewComparator() {\n return this.viewComparator;\n },\n\n // Filter an array of models, if a filter exists\n _filterModels(models) {\n if (this.filter) {\n models = _.filter(models, (model, index) => {\n return this._shouldAddChild(model, index);\n });\n }\n return models;\n },\n\n _sortModelsBy(models, comparator) {\n if (typeof comparator === 'string') {\n return _.sortBy(models, (model) => {\n return model.get(comparator);\n });\n } else if (comparator.length === 1) {\n return _.sortBy(models, _.bind(comparator, this));\n } else {\n return models.sort(_.bind(comparator, this));\n }\n },\n\n // Internal method to show an empty view in place of a collection of child views,\n // when the collection is empty\n _showEmptyView() {\n const EmptyView = this._getEmptyView();\n\n if (EmptyView && !this._showingEmptyView) {\n this._showingEmptyView = true;\n\n const model = new Backbone.Model();\n let emptyViewOptions =\n this.emptyViewOptions || this.childViewOptions;\n if (_.isFunction(emptyViewOptions)) {\n emptyViewOptions = emptyViewOptions.call(this, model, this._emptyViewIndex);\n }\n\n const view = this.buildChildView(model, EmptyView, emptyViewOptions);\n\n this.triggerMethod('before:render:empty', this, view);\n this.addChildView(view, 0);\n this.triggerMethod('render:empty', this, view);\n }\n },\n\n // Internal method to destroy an existing emptyView instance if one exists. Called when\n // a collection view has been rendered empty, and then a child is added to the collection.\n _destroyEmptyView() {\n if (this._showingEmptyView) {\n this.triggerMethod('before:remove:empty', this);\n\n this._destroyChildren();\n delete this._showingEmptyView;\n\n this.triggerMethod('remove:empty', this);\n }\n },\n\n // Retrieve the empty view class\n _getEmptyView() {\n const emptyView = this.emptyView;\n\n if (!emptyView) { return; }\n\n return this._getView(emptyView);\n },\n\n // Retrieve the `childView` class\n // The `childView` property can be either a view class or a function that\n // returns a view class. If it is a function, it will receive the model that\n // will be passed to the view instance (created from the returned view class)\n _getChildView(child) {\n let childView = this.childView;\n\n if (!childView) {\n throw new MarionetteError({\n name: 'NoChildViewError',\n message: 'A \"childView\" must be specified'\n });\n }\n\n childView = this._getView(childView, child);\n\n if (!childView) {\n throw new MarionetteError({\n name: 'InvalidChildViewError',\n message: '\"childView\" must be a view class or a function that returns a view class'\n });\n }\n\n return childView;\n },\n\n // First check if the `view` is a view class (the common case)\n // Then check if it's a function (which we assume that returns a view class)\n _getView(view, child) {\n if (view.prototype instanceof Backbone.View || view === Backbone.View) {\n return view;\n } else if (_.isFunction(view)) {\n return view.call(this, child);\n }\n },\n\n // Internal method for building and adding a child view\n _addChild(child, index) {\n const view = this._createView(child, index);\n this.addChildView(view, index);\n\n return view;\n },\n\n _getChildViewOptions(child, index) {\n if (_.isFunction(this.childViewOptions)) {\n return this.childViewOptions(child, index);\n }\n\n return this.childViewOptions;\n },\n\n // Render the child's view and add it to the HTML for the collection view at a given index.\n // This will also update the indices of later views in the collection in order to keep the\n // children in sync with the collection.\n addChildView(view, index) {\n this.triggerMethod('before:add:child', this, view);\n this._setupChildView(view, index);\n\n // Store the child view itself so we can properly remove and/or destroy it later\n if (this._isBuffering) {\n // Add to children, but don't update children's length.\n this.children._add(view);\n } else {\n // increment indices of views after this one\n this._updateIndices(view, true);\n this.children.add(view);\n }\n\n this._renderView(view);\n\n this._attachView(view, index);\n\n this.triggerMethod('add:child', this, view);\n\n return view;\n },\n\n // Internal method. This decrements or increments the indices of views after the added/removed\n // view to keep in sync with the collection.\n _updateIndices(views, increment) {\n if (!this.sort) {\n return;\n }\n\n const view = _.isArray(views) ? this._findGreatestIndexedView(views) : views;\n\n // update the indexes of views after this one\n this.children.each((laterView) => {\n if (laterView._index >= view._index) {\n laterView._index += increment ? 1 : -1;\n }\n });\n },\n\n _renderView(view) {\n if (view._isRendered) {\n return;\n }\n\n if (!view.supportsRenderLifecycle) {\n triggerMethodOn(view, 'before:render', view);\n }\n\n view.render();\n\n if (!view.supportsRenderLifecycle) {\n view._isRendered = true;\n triggerMethodOn(view, 'render', view);\n }\n },\n\n _attachView(view, index) {\n // Only trigger attach if already attached and not buffering,\n // otherwise _endBuffering() or Region#show() handles this.\n const shouldTriggerAttach = !view._isAttached && !this._isBuffering && this._isAttached;\n\n if (shouldTriggerAttach) {\n triggerMethodOn(view, 'before:attach', view);\n }\n\n this.attachHtml(this, view, index);\n\n if (shouldTriggerAttach) {\n view._isAttached = true;\n triggerMethodOn(view, 'attach', view);\n }\n },\n\n // Build a `childView` for a model in the collection.\n buildChildView(child, ChildViewClass, childViewOptions) {\n const options = _.extend({model: child}, childViewOptions);\n return new ChildViewClass(options);\n },\n\n // Remove the child view and destroy it. This function also updates the indices of later views\n // in the collection in order to keep the children in sync with the collection.\n removeChildView(view) {\n if (!view || view._isDestroyed) {\n return view;\n }\n\n this._removeChildView(view);\n this.children._updateLength();\n // decrement the index of views after this one\n this._updateIndices(view, false);\n return view;\n },\n\n // check if the collection is empty or optionally whether an array of pre-processed models is empty\n isEmpty(options) {\n let models;\n if (_.result(options, 'processedModels')) {\n models = options.processedModels;\n } else {\n models = this.collection ? this.collection.models : [];\n models = this._filterModels(models);\n }\n return models.length === 0;\n },\n\n // If empty, show the empty view\n _checkEmpty() {\n if (this.isEmpty()) {\n this._showEmptyView();\n }\n },\n\n // You might need to override this if you've overridden attachHtml\n attachBuffer(collectionView, buffer) {\n collectionView.$el.append(buffer);\n },\n\n // Create a fragment buffer from the currently buffered children\n _createBuffer() {\n const elBuffer = document.createDocumentFragment();\n _.each(this._bufferedChildren, (b) => {\n elBuffer.appendChild(b.el);\n });\n return elBuffer;\n },\n\n // Append the HTML to the collection's `el`. Override this method to do something other\n // than `.append`.\n attachHtml(collectionView, childView, index) {\n if (collectionView._isBuffering) {\n // buffering happens on reset events and initial renders\n // in order to reduce the number of inserts into the\n // document, which are expensive.\n collectionView._bufferedChildren.splice(index, 0, childView);\n } else {\n // If we've already rendered the main collection, append\n // the new child into the correct order if we need to. Otherwise\n // append to the end.\n if (!collectionView._insertBefore(childView, index)) {\n collectionView._insertAfter(childView);\n }\n }\n },\n\n // Internal method. Check whether we need to insert the view into the correct position.\n _insertBefore(childView, index) {\n let currentView;\n const findPosition = this.sort && (index < this.children.length - 1);\n if (findPosition) {\n // Find the view after this one\n currentView = this.children.find((view) => {\n return view._index === index + 1;\n });\n }\n\n if (currentView) {\n currentView.$el.before(childView.el);\n return true;\n }\n\n return false;\n },\n\n // Internal method. Append a view to the end of the $el\n _insertAfter(childView) {\n this.$el.append(childView.el);\n },\n\n // Internal method to set up the `children` object for storing all of the child views\n _initChildViewStorage() {\n this.children = new ChildViewContainer();\n },\n\n // called by ViewMixin destroy\n _removeChildren() {\n this._destroyChildren({checkEmpty: false});\n },\n\n // Destroy the child views that this collection view is holding on to, if any\n _destroyChildren(options) {\n if (!this.children.length) {\n return;\n }\n\n this.triggerMethod('before:destroy:children', this);\n const childModels = this.children.map('model');\n this._removeChildModels(childModels, options);\n this.triggerMethod('destroy:children', this);\n },\n\n // Return true if the given child should be shown. Return false otherwise.\n // The filter will be passed (child, index, collection), where\n // 'child' is the given model\n // 'index' is the index of that model in the collection\n // 'collection' is the collection referenced by this CollectionView\n _shouldAddChild(child, index) {\n const filter = this.filter;\n return !_.isFunction(filter) || filter.call(this, child, index, this.collection);\n },\n\n // Set up the child view event forwarding. Uses a \"childview:\" prefix in front of all forwarded events.\n _proxyChildEvents(view) {\n this.listenTo(view, 'all', this._childViewEventHandler);\n }\n});\n\n_.extend(CollectionView.prototype, ViewMixin);\n\nexport default CollectionView;\n","// Composite View\n// --------------\n\nimport _ from 'underscore';\nimport deprecate from './utils/deprecate';\nimport MarionetteError from './error';\nimport CollectionView from './collection-view';\nimport View from './view';\n\nconst ClassOptions = [\n 'childViewContainer',\n 'template',\n 'templateContext'\n];\n\n// Used for rendering a branch-leaf, hierarchical structure.\n// Extends directly from CollectionView\n// @deprecated\nconst CompositeView = CollectionView.extend({\n\n // Setting up the inheritance chain which allows changes to\n // Marionette.CollectionView.prototype.constructor which allows overriding\n // option to pass '{sort: false}' to prevent the CompositeView from\n // maintaining the sorted order of the collection.\n // This will fallback onto appending childView's to the end.\n constructor(options) {\n deprecate('CompositeView is deprecated. Convert to View at your earliest convenience');\n\n this.mergeOptions(options, ClassOptions);\n\n CollectionView.prototype.constructor.apply(this, arguments);\n },\n\n // Configured the initial events that the composite view\n // binds to. Override this method to prevent the initial\n // events, or to add your own initial events.\n _initialEvents() {\n\n // Bind only after composite view is rendered to avoid adding child views\n // to nonexistent childViewContainer\n\n if (this.collection) {\n this.listenTo(this.collection, 'add', this._onCollectionAdd);\n this.listenTo(this.collection, 'update', this._onCollectionUpdate);\n this.listenTo(this.collection, 'reset', this.renderChildren);\n\n if (this.sort) {\n this.listenTo(this.collection, 'sort', this._sortViews);\n }\n }\n },\n\n // Retrieve the `childView` to be used when rendering each of\n // the items in the collection. The default is to return\n // `this.childView` or Marionette.CompositeView if no `childView`\n // has been defined. As happens in CollectionView, `childView` can\n // be a function (which should return a view class).\n _getChildView(child) {\n let childView = this.childView;\n\n // for CompositeView, if `childView` is not specified, we'll get the same\n // composite view class rendered for each child in the collection\n // then check if the `childView` is a view class (the common case)\n // finally check if it's a function (which we assume that returns a view class)\n if (!childView) {\n return this.constructor;\n }\n\n childView = this._getView(childView, child);\n\n if (!childView) {\n throw new MarionetteError({\n name: 'InvalidChildViewError',\n message: '\"childView\" must be a view class or a function that returns a view class'\n });\n }\n\n return childView;\n },\n\n // Return the serialized model\n serializeData() {\n return this.serializeModel();\n },\n\n // Renders the model and the collection.\n render() {\n this._ensureViewIsIntact();\n this._isRendering = true;\n this.resetChildViewContainer();\n\n this.triggerMethod('before:render', this);\n\n this._renderTemplate();\n this.bindUIElements();\n this.renderChildren();\n\n this._isRendering = false;\n this._isRendered = true;\n this.triggerMethod('render', this);\n return this;\n },\n\n renderChildren() {\n if (this._isRendered || this._isRendering) {\n CollectionView.prototype._renderChildren.call(this);\n }\n },\n\n // You might need to override this if you've overridden attachHtml\n attachBuffer(compositeView, buffer) {\n const $container = this.getChildViewContainer(compositeView);\n $container.append(buffer);\n },\n\n // Internal method. Append a view to the end of the $el.\n // Overidden from CollectionView to ensure view is appended to\n // childViewContainer\n _insertAfter(childView) {\n const $container = this.getChildViewContainer(this, childView);\n $container.append(childView.el);\n },\n\n // Internal method. Append reordered childView'.\n // Overidden from CollectionView to ensure reordered views\n // are appended to childViewContainer\n _appendReorderedChildren(children) {\n const $container = this.getChildViewContainer(this);\n $container.append(children);\n },\n\n // Internal method to ensure an `$childViewContainer` exists, for the\n // `attachHtml` method to use.\n getChildViewContainer(containerView, childView) {\n if (!!containerView.$childViewContainer) {\n return containerView.$childViewContainer;\n }\n\n let container;\n const childViewContainer = containerView.childViewContainer;\n if (childViewContainer) {\n\n const selector = _.result(containerView, 'childViewContainer');\n\n if (selector.charAt(0) === '@' && containerView.ui) {\n container = containerView.ui[selector.substr(4)];\n } else {\n container = containerView.$(selector);\n }\n\n if (container.length <= 0) {\n throw new MarionetteError({\n name: 'ChildViewContainerMissingError',\n message: `The specified \"childViewContainer\" was not found: ${containerView.childViewContainer}`\n });\n }\n\n } else {\n container = containerView.$el;\n }\n\n containerView.$childViewContainer = container;\n return container;\n },\n\n // Internal method to reset the `$childViewContainer` on render\n resetChildViewContainer() {\n if (this.$childViewContainer) {\n this.$childViewContainer = undefined;\n }\n }\n});\n\n// To prevent duplication but allow the best View organization\n// Certain View methods are mixed directly into the deprecated CompositeView\nconst MixinFromView = _.pick(View.prototype, 'serializeModel', 'getTemplate', '_renderTemplate', 'mixinTemplateContext', 'attachElContent');\n_.extend(CompositeView.prototype, MixinFromView);\n\nexport default CompositeView;\n","// Behavior\n// --------\n\n// A Behavior is an isolated set of DOM /\n// user interactions that can be mixed into any View.\n// Behaviors allow you to blackbox View specific interactions\n// into portable logical chunks, keeping your views simple and your code DRY.\n\nimport _ from 'underscore';\nimport getUniqueEventName from './utils/get-unique-event-name';\nimport MarionetteObject from './object';\nimport DelegateEntityEventsMixin from './mixins/delegate-entity-events';\nimport TriggersMixin from './mixins/triggers';\nimport UIMixin from './mixins/ui';\n\nconst ClassOptions = [\n 'collectionEvents',\n 'events',\n 'modelEvents',\n 'triggers',\n 'ui'\n];\n\nconst Behavior = MarionetteObject.extend({\n cidPrefix: 'mnb',\n\n constructor(options, view) {\n // Setup reference to the view.\n // this comes in handle when a behavior\n // wants to directly talk up the chain\n // to the view.\n this.view = view;\n this.defaults = _.clone(_.result(this, 'defaults', {}));\n this._setOptions(this.defaults, options);\n this.mergeOptions(this.options, ClassOptions);\n\n // Construct an internal UI hash using\n // the behaviors UI hash and then the view UI hash.\n // This allows the user to use UI hash elements\n // defined in the parent view as well as those\n // defined in the given behavior.\n // This order will help the reuse and share of a behavior\n // between multiple views, while letting a view override a\n // selector under an UI key.\n this.ui = _.extend({}, _.result(this, 'ui'), _.result(view, 'ui'));\n\n MarionetteObject.apply(this, arguments);\n },\n\n // proxy behavior $ method to the view\n // this is useful for doing jquery DOM lookups\n // scoped to behaviors view.\n $() {\n return this.view.$.apply(this.view, arguments);\n },\n\n // Stops the behavior from listening to events.\n // Overrides Object#destroy to prevent additional events from being triggered.\n destroy() {\n this.stopListening();\n\n return this;\n },\n\n proxyViewProperties() {\n this.$el = this.view.$el;\n this.el = this.view.el;\n\n return this;\n },\n\n bindUIElements() {\n this._bindUIElements();\n\n return this;\n },\n\n unbindUIElements() {\n this._unbindUIElements();\n\n return this;\n },\n\n getUI(name) {\n this.view._ensureViewIsIntact();\n return this._getUI(name);\n },\n\n // Handle `modelEvents`, and `collectionEvents` configuration\n delegateEntityEvents() {\n this._delegateEntityEvents(this.view.model, this.view.collection);\n\n return this;\n },\n\n undelegateEntityEvents() {\n this._undelegateEntityEvents(this.view.model, this.view.collection);\n\n return this;\n },\n\n getEvents() {\n // Normalize behavior events hash to allow\n // a user to use the @ui. syntax.\n const behaviorEvents = this.normalizeUIKeys(_.result(this, 'events'));\n\n // binds the handler to the behavior and builds a unique eventName\n return _.reduce(behaviorEvents, (events, behaviorHandler, key) => {\n if (!_.isFunction(behaviorHandler)) {\n behaviorHandler = this[behaviorHandler];\n }\n if (!behaviorHandler) { return; }\n key = getUniqueEventName(key);\n events[key] = _.bind(behaviorHandler, this);\n return events;\n }, {});\n },\n\n // Internal method to build all trigger handlers for a given behavior\n getTriggers() {\n if (!this.triggers) { return; }\n\n // Normalize behavior triggers hash to allow\n // a user to use the @ui. syntax.\n const behaviorTriggers = this.normalizeUIKeys(_.result(this, 'triggers'));\n\n return this._getViewTriggers(this.view, behaviorTriggers);\n }\n\n});\n\n_.extend(Behavior.prototype, DelegateEntityEventsMixin, TriggersMixin, UIMixin);\n\nexport default Behavior;\n","// Application\n// -----------\nimport buildRegion from './common/build-region';\nimport MarionetteObject from './object';\nimport Region from './region';\n\nconst ClassOptions = [\n 'region',\n 'regionClass'\n];\n\n// A container for a Marionette application.\nconst Application = MarionetteObject.extend({\n cidPrefix: 'mna',\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n this._initRegion();\n\n MarionetteObject.prototype.constructor.apply(this, arguments);\n },\n\n regionClass: Region,\n\n _initRegion() {\n const region = this.region;\n\n if (!region) { return; }\n\n const defaults = {\n regionClass: this.regionClass\n };\n\n this._region = buildRegion(region, defaults);\n },\n\n getRegion() {\n return this._region;\n },\n\n showView(view, ...args) {\n const region = this.getRegion();\n return region.show(view, ...args);\n },\n\n getView() {\n return this.getRegion().currentView;\n },\n\n // kick off all of the application's processes.\n start(options) {\n this.triggerMethod('before:start', this, options);\n this.triggerMethod('start', this, options);\n return this;\n }\n\n});\n\nexport default Application;\n","// App Router\n// ----------\n\n// Reduce the boilerplate code of handling route events\n// and then calling a single method on another object,\n// called a controller.\n// Have your routers configured to call the method on\n// your controller, directly.\n//\n// Configure an AppRouter with `appRoutes`.\n//\n// App routers can only take one `controller` object.\n// It is recommended that you divide your controller\n// objects in to smaller pieces of related functionality\n// and have multiple routers / controllers, instead of\n// just one giant router and controller.\n//\n// You can also add standard routes to an AppRouter.\n\nimport Backbone from 'backbone';\nimport _ from 'underscore';\nimport { triggerMethod } from './common/trigger-method';\nimport MarionetteError from './error';\nimport CommonMixin from './mixins/common';\n\nconst ClassOptions = [\n 'appRoutes',\n 'controller'\n];\n\nconst AppRouter = Backbone.Router.extend({\n\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n Backbone.Router.apply(this, arguments);\n\n const appRoutes = this.appRoutes;\n const controller = this._getController();\n this.processAppRoutes(controller, appRoutes);\n this.on('route', this._processOnRoute, this);\n },\n\n // Similar to route method on a Backbone Router but\n // method is called on the controller\n appRoute(route, methodName) {\n const controller = this._getController();\n this._addAppRoute(controller, route, methodName);\n return this;\n },\n\n // process the route event and trigger the onRoute\n // method call, if it exists\n _processOnRoute(routeName, routeArgs) {\n // make sure an onRoute before trying to call it\n if (_.isFunction(this.onRoute)) {\n // find the path that matches the current route\n const routePath = _.invert(this.appRoutes)[routeName];\n this.onRoute(routeName, routePath, routeArgs);\n }\n },\n\n // Internal method to process the `appRoutes` for the\n // router, and turn them in to routes that trigger the\n // specified method on the specified `controller`.\n processAppRoutes(controller, appRoutes) {\n if (!appRoutes) { return this; }\n\n const routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes\n\n _.each(routeNames, route => {\n this._addAppRoute(controller, route, appRoutes[route]);\n });\n\n return this;\n },\n\n _getController() {\n return this.controller;\n },\n\n _addAppRoute(controller, route, methodName) {\n const method = controller[methodName];\n\n if (!method) {\n throw new MarionetteError(`Method \"${methodName}\" was not found on the controller`);\n }\n\n this.route(route, methodName, _.bind(method, controller));\n },\n\n triggerMethod: triggerMethod\n});\n\n_.extend(AppRouter.prototype, CommonMixin);\n\nexport default AppRouter;\n","import Backbone from 'backbone';\nimport {version} from '../package.json';\n\nimport proxy from './utils/proxy';\nimport extend from './utils/extend';\nimport deprecate from './utils/deprecate';\n\nimport isNodeAttached from './common/is-node-attached';\nimport mergeOptions from './common/merge-options';\nimport getOption from './common/get-option';\nimport normalizeMethods from './common/normalize-methods';\nimport monitorViewEvents from './common/monitor-view-events';\n\nimport {\n bindEvents,\n unbindEvents\n} from './common/bind-events';\n\nimport {\n bindRequests,\n unbindRequests\n} from './common/bind-requests';\n\nimport {\n triggerMethod,\n triggerMethodOn\n} from './common/trigger-method';\n\n\nimport MarionetteObject from './object';\nimport TemplateCache from './template-cache';\nimport View from './view';\nimport CollectionView from './collection-view';\nimport CompositeView from './composite-view';\nimport Behavior from './behavior';\nimport Region from './region';\nimport Application from './application';\nimport AppRouter from './app-router';\nimport MarionetteError from './error';\n\nimport behaviorsLookup from './config/behaviors-lookup';\nimport Renderer from './config/renderer';\n\nimport {\n FEATURES,\n isEnabled,\n setEnabled\n} from './config/features';\n\nconst previousMarionette = Backbone.Marionette;\nconst Marionette = Backbone.Marionette = {};\n\n// This allows you to run multiple instances of Marionette on the same\n// webapp. After loading the new version, call `noConflict()` to\n// get a reference to it. At the same time the old version will be\n// returned to Backbone.Marionette.\nMarionette.noConflict = function() {\n Backbone.Marionette = previousMarionette;\n return this;\n};\n\n// Utilities\nMarionette.bindEvents = proxy(bindEvents);\nMarionette.unbindEvents = proxy(unbindEvents);\nMarionette.bindRequests = proxy(bindRequests);\nMarionette.unbindRequests = proxy(unbindRequests);\nMarionette.mergeOptions = proxy(mergeOptions);\nMarionette.getOption = proxy(getOption);\nMarionette.normalizeMethods = proxy(normalizeMethods);\nMarionette.extend = extend;\nMarionette.isNodeAttached = isNodeAttached;\nMarionette.deprecate = deprecate;\nMarionette.triggerMethod = proxy(triggerMethod);\nMarionette.triggerMethodOn = triggerMethodOn;\nMarionette.isEnabled = isEnabled;\nMarionette.setEnabled = setEnabled;\nMarionette.monitorViewEvents = monitorViewEvents;\n\nMarionette.Behaviors = {};\nMarionette.Behaviors.behaviorsLookup = behaviorsLookup;\n\n// Classes\nMarionette.Application = Application;\nMarionette.AppRouter = AppRouter;\nMarionette.Renderer = Renderer;\nMarionette.TemplateCache = TemplateCache;\nMarionette.View = View;\nMarionette.CollectionView = CollectionView;\nMarionette.CompositeView = CompositeView;\nMarionette.Behavior = Behavior;\nMarionette.Region = Region;\nMarionette.Error = MarionetteError;\nMarionette.Object = MarionetteObject;\n\n// Configuration\nMarionette.DEV_MODE = false;\nMarionette.FEATURES = FEATURES;\nMarionette.VERSION = version;\n\nexport default Marionette;\n"],"sourceRoot":"/source/"}
|