{"version":3,"sources":["src/common/trigger-method.js","src/common/monitor-view-events.js","src/common/bind-events.js","src/common/bind-requests.js","src/mixins/behaviors.js","src/utils/get-unique-event-name.js","src/config/features.js","src/mixins/triggers.js","src/utils/destroy-backbone-view.js","src/common/build-region.js","src/next-child-view-container.js","src/config/behaviors-lookup.js","src/utils/proxy.js","src/utils/extend.js","src/utils/deprecate.js","src/common/is-node-attached.js","src/common/merge-options.js","src/common/get-option.js","src/common/normalize-methods.js","src/error.js","src/utils/set-options.js","src/mixins/common.js","src/mixins/radio.js","src/object.js","src/mixins/dom.js","src/template-cache.js","src/utils/invoke.js","src/mixins/delegate-entity-events.js","src/mixins/ui.js","src/mixins/view.js","src/region.js","src/mixins/regions.js","src/config/renderer.js","src/view.js","src/utils/emulate-collection.js","src/child-view-container.js","src/collection-view.js","src/next-collection-view.js","src/composite-view.js","src/behavior.js","src/application.js","src/app-router.js","src/backbone.marionette.js"],"names":["getEventName","match","prefix","eventName","toUpperCase","triggerMethod","event","args","Array","_len","_key","arguments","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","triggerDOMRemove","handleBeforeAttach","handleAttach","handleBeforeDetach","handleDetach","handleBeforeRender","handleRender","monitorViewEvents","_areViewEventsMonitored","on","bindFromStrings","target","entity","evt","methods","actionName","methodNames","split","MarionetteError","iterateEvents","bindings","isObject","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","isEnabled","name","FEATURES","setEnabled","state","buildViewTrigger","triggerDef","shouldPreventDefault","preventDefault","shouldStopPropagation","stopPropagation","destroyBackboneView","supportsDestroyLifecycle","remove","_isDestroyed","buildRegionFromDefinition","definition","defaults","opts","extend","el","buildRegionFromObject","regionClass","RegionClass","omit","stringComparator","comparator","model","get","proxy","Backbone","Model","deprecate","message","test","prev","next","url","DEV_MODE","undefined","_cache","_warn","_console","console","warn","log","noop","isNodeAttached","document","documentElement","contains","parentNode","mergeOptions","keys","option","optionName","hash","reduce","normalizedHash","_this","splitter","memoize","replace","errorProps","Error","version","error","pick","captureStackTrace","urlRoot","setOptions","CommonMixin","_setOptions","RadioMixin","channelName","Radio","_channel","radioEvents","radioRequests","_destroyRadio","stopReplying","ClassOptions","MarionetteObject","cid","cidPrefix","_initRadio","initialize","prototype","Events","stopListening","DomMixin","createDocumentFragment","children","$","append","sibling","before","newEl","oldEl","parent","replaceChild","contents","detach","html","TemplateCache","templateId","cachedTemplate","templateCaches","load","i","length","compiledTemplate","template","loadTemplate","compileTemplate","$template","findEls","rawTemplate","_invoke","invokeMap","invoke","BehaviorsMixin","_behaviors","_getBehaviors","triggers","memo","_triggers","events","_events","without","DelegateEntityEventsMixin","collection","_undelegateEntityEvents","modelEvents","collectionEvents","delegateEventSplitter","getUniqueEventName","TriggersMixin","normalizeUIKeys","ui","val","normalizedKey","normalizeUIString","uiString","r","slice","normalizeUIValues","properties","isArray","property","propertyVal","UIMixin","uiBindings","_getUIBindings","_uiBindings","_ui","$el","_this2","ViewMixin","eventsArg","_proxyBehaviorViewProperties","_buildEventProxies","viewEvents","_getEvents","combinedEvents","_getBehaviorEvents","_getBehaviorTriggers","getTriggers","View","delegateEvents","_getViewTriggers","_delegateEntityEvents","_delegateBehaviorEntityEvents","_undelegateBehaviorEntityEvents","unbindUIElements","removeEl","_removeChildren","_destroyBehaviors","_bindUIElements","_bindBehaviorUIElements","_unbindUIElements","_unbindBehaviorUIElements","_getUI","ret","_triggerEventOnBehaviors","_childViewEvents","_childViewTriggers","listenTo","_childViewEventHandler","childViewEvents","childViewTriggers","childEventName","Region","_initEl","getEl","_ensureElement","_getView","currentView","_isSwappingView","empty","_setupChildView","_renderView","_attachView","_proxyChildViewEvents","_empty","parentView","_parentView","supportsRenderLifecycle","render","shouldReplaceEl","replaceElement","_replaceEl","attachHtml","allowMissingEl","viewOptions","_getViewOptions","_restoreEl","replaceEl","_isReplaced","_detachView","appendChildren","detachHtml","shouldDestroy","preventDestroy","off","removeView","_stopChildViewEvents","destroy","destroyView","shouldRestoreEl","detachContents","reset","_name","_removeReferences","buildRegion","RegionsMixin","regions","_regions","addRegions","isEmpty","_addRegions","regionDefinitions","partial","_addRegion","region","_removeRegion","_getRegions","bind","getRegions","getRegion","clone","show","detachView","Renderer","data","templateFunc","_initBehaviors","_initRegions","constructor","delegateEntityEvents","serializeModel","serializeCollection","attributes","hasEl","setElement","bindUIElements","_reInitRegions","_renderTemplate","getTemplate","mixinTemplateContext","serializeData","_renderHtml","attachElContent","templateContext","setInnerContent","removeRegions","compact","renderer","emulateCollection","object","listProperty","list","values","toArray","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","add","customIndex","_add","viewCid","findByModelCid","modelCid","findByCid","index","_remove","some","size","CollectionView","once","_initialEvents","_initChildViewStorage","_bufferedChildren","_isBuffering","triggerOnChildren","attachBuffer","_createBuffer","_onCollectionAdd","_onCollectionUpdate","sort","_sortViews","at","indexOf","filter","_filteredSortedModels","_shouldAddChild","_destroyEmptyView","_addChild","changes","_removeChildModels","removed","models","removedViews","_getRemovedViews","_updateIndices","_showEmptyView","removingViews","findByModel","_removeChildView","push","_renderChildren","preventRender","_ref","canBeRendered","filterChanged","shouldRender","previousModels","_applyModelDeltas","setFilter","currentIds","addedChildNotExists","removeModels","prevModel","_showingEmptyView","anyModelsAdded","filteredOutModels","elsToReorder","viewEls","_index","_appendReorderedChildren","reorderOnSort","reorder","orderChanged","find","item","_this3","resortView","_destroyChildren","processedModels","_startBuffering","_showCollection","_endBuffering","ChildView","_getChildView","childViewOptions","_getChildViewOptions","buildChildView","addedAt","viewComparator","getViewComparator","Math","min","max","addedModel","_sortModelsBy","splice","_filterModels","_this4","sortBy","EmptyView","_getEmptyView","emptyViewOptions","_emptyViewIndex","addChildView","emptyView","childView","_createView","increment","laterView","ChildViewClass","collectionView","buffer","elBuffer","createBuffer","b","_insertBefore","_insertAfter","findPosition","beforeEl","ChildViewContainer","_init","_viewsByCid","_sortBy","sortedViews","_set","findIndexByView","_initEmptyRegion","emptyRegion","_onCollectionSort","_onCollectionReset","sortWithCollection","hasAddedModel","_addChildModels","added","_detachChildren","_showChildren","_removeChildViews","_removeChildModel","_removeChild","_addChildModel","_createChildView","removeChildView","_sortChildren","allViewsFiltered","_getEmptyViewOptions","hasView","getComparator","_sort","comparatorChanged","shouldSort","setComparator","_viewComparator","filteredViews","_filterChildren","viewFilter","_getFilter","partition","getFilter","matcher","matches","_ref2","detachingViews","_detachChildView","detachEl","els","_getBuffer","_attachChildren","_renderChildView","_ref3","_destroyChildView","CompositeView","renderChildren","_isRendering","resetChildViewContainer","compositeView","$container","getChildViewContainer","containerView","$childViewContainer","container","childViewContainer","charAt","substr","MixinFromView","Behavior","_removeBehavior","behaviorEvents","behaviorHandler","behaviorTriggers","Application","_initRegion","_region","AppRouter","Router","appRoutes","controller","_getController","processAppRoutes","_processOnRoute","route","_addAppRoute","routeName","routeArgs","onRoute","routePath","invert","routeNames","reverse","previousMarionette","noConflict","NextCollectionView","Object","VERSION"],"mappings":";;;;;;;;4UAWA,SAASA,GAAaC,EAAOC,EAAQC,SAC5BA,GAAUC,cAcnB,QAAgBC,GAAcC,8BAAUC,EAAMC,MAAAC,EAAA,EAAAA,EAAA,EAAA,GAAAC,EAAA,EAAAA,EAAAD,EAAAC,MAAAA,EAAA,GAAAC,UAAAD,MAEtCE,GAAaC,EAAgBP,GAC7BQ,EAASC,EAAUC,KAAKC,KAAML,GAChCM,EAAAA,aAGAC,GAAEC,WAAWN,OAENA,EAAOO,MAAMJ,KAAMV,SAIzBe,QAAQD,MAAMJ,KAAMN,W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G,EAAM3G,GAC7B4D,GAAWP,iBAAmBsD,EAAMtD,GACpCO,GAAWqC,OAASA,EACpBrC,GAAWiE,eAAiBA,EAC5BjE,GAAWkD,UAAYA,EACvBlD,GAAWtE,cAAgBqH,EAAMrH,GACjCsE,GAAWpD,gBAAkBA,EAC7BoD,GAAWkB,UAAYA,EACvBlB,GAAWqB,WAAaA,EACxBrB,GAAW5B,kBAAoBA,EAE/B4B,GAAWC,aACXD,GAAWC,UAAUC,gBAAkBA,EAGvCF,GAAW0e,YAAcA,GACzB1e,GAAW6e,UAAYA,GACvB7e,GAAW+Q,SAAWA,GACtB/Q,GAAW0H,cAAgBA,GAC3B1H,GAAW0L,KAAOA,GAClB1L,GAAW+T,eAAiBA,GAC5B/T,GAAW+f,mBAAqBA,GAChC/f,GAAWud,cAAgBA,GAC3Bvd,GAAWqe,SAAWA,GACtBre,GAAWkN,OAASA,GACpBlN,GAAWkF,MAAQnG,EACnBiB,GAAWggB,OAAS5Z,GAGpBpG,GAAWwD,UAAW,EACtBxD,GAAWoB,SAAWA,GACtBpB,GAAWigB,QAAU9a","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 triggerDOMRemove(view) {\n if (view._isAttached && view._isRendered) {\n triggerMethodOn(view, 'dom:remove', 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 triggerDOMRemove(this);\n}\n\nfunction handleDetach() {\n triggerMethodChildren(this, 'detach', shouldDetach);\n}\n\nfunction handleBeforeRender() {\n triggerDOMRemove(this);\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 'before:render': handleBeforeRender,\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 this._behaviors = this._getBehaviors();\n },\n\n _getBehaviors() {\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 return _.isObject(behaviors) ? parseBehaviors(this, behaviors) : {};\n },\n\n _getBehaviorTriggers() {\n const triggers = _invoke(this._behaviors, 'getTriggers');\n return _.reduce(triggers, function(memo, _triggers) {\n return _.extend(memo, _triggers);\n }, {});\n },\n\n _getBehaviorEvents() {\n const events = _invoke(this._behaviors, 'getEvents');\n return _.reduce(events, function(memo, _events) {\n return _.extend(memo, _events);\n }, {});\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 // Remove a behavior\n _removeBehavior(behavior) {\n // Don't worry about the clean up if the view is destroyed\n if (this._isDestroyed) { return; }\n this._behaviors = _.without(this._behaviors, behavior);\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","// Add Feature flags here\n// e.g. 'class' => false\nconst FEATURES = {\n childViewEventPrefix: true,\n triggersStopPropagation: true,\n triggersPreventDefault: true\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","import _ from 'underscore';\nimport getUniqueEventName from '../utils/get-unique-event-name';\nimport { isEnabled } from '../config/features';\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\n let shouldPreventDefault = !!triggerDef.preventDefault;\n\n if (isEnabled('triggersPreventDefault')) {\n shouldPreventDefault = triggerDef.preventDefault !== false;\n }\n\n let shouldStopPropagation = !!triggerDef.stopPropagation;\n\n if (isEnabled('triggersStopPropagation')) {\n shouldStopPropagation = triggerDef.stopPropagation !== false;\n }\n\n return function(event) {\n if (shouldPreventDefault) {\n event.preventDefault();\n }\n\n if (shouldStopPropagation) {\n event.stopPropagation();\n }\n\n view.triggerMethod(eventName, view, event);\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 _ 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() {\n this._init();\n};\n\nemulateCollection(Container.prototype, '_views');\n\nfunction stringComparator(comparator, view) {\n return view.model && view.model.get(comparator);\n}\n\n// Container Methods\n// -----------------\n\n_.extend(Container.prototype, {\n\n // Initializes an empty container\n _init() {\n this._views = [];\n this._viewsByCid = {};\n this._indexByModel = {};\n this._updateLength();\n },\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). Additionally it stores\n // the view by index in the _views array\n _add(view, index = this._views.length) {\n const viewCid = view.cid;\n\n // store the view\n this._viewsByCid[viewCid] = view;\n\n // index it by model\n if (view.model) {\n this._indexByModel[view.model.cid] = viewCid;\n }\n\n // add to end by default\n this._views.splice(index, 0, view);\n\n this._updateLength();\n },\n\n // Sort (mutate) and return the array of the child views.\n _sort(comparator) {\n if (typeof comparator === 'string') {\n comparator = _.partial(stringComparator, comparator);\n return this._sortBy(comparator);\n }\n\n if (comparator.length === 1) {\n return this._sortBy(comparator);\n }\n\n return this._views.sort(comparator);\n },\n\n // Makes `_.sortBy` mutate the array to match `this._views.sort`\n _sortBy(comparator) {\n const sortedViews = _.sortBy(this._views, comparator);\n\n this._set(sortedViews);\n\n return sortedViews;\n },\n\n // Replace array contents without overwriting the reference.\n _set(views) {\n this._views.length = 0;\n\n this._views.push.apply(this._views, views.slice(0));\n\n this._updateLength();\n },\n\n // Find a view by the model that was attached to it.\n // 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 it.\n // 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 index.\n findByIndex(index) {\n return this._views[index];\n },\n\n // Find the index of a view instance\n findIndexByView(view) {\n return this._views.indexOf(view);\n },\n\n // Retrieve a view by its `cid` directly\n findByCid(cid) {\n return this._viewsByCid[cid];\n },\n\n // Remove a view and clean up index references.\n _remove(view) {\n if (!this._viewsByCid[view.cid]) {\n return;\n }\n\n // delete model index\n if (view.model) {\n delete this._indexByModel[view.model.cid];\n }\n\n // remove the view from the container\n delete this._viewsByCid[view.cid];\n\n const index = this.findIndexByView(view);\n this._views.splice(index, 1);\n\n this._updateLength();\n },\n\n // Update the `.length` attribute on this container\n _updateLength() {\n this.length = this._views.length;\n }\n});\n\nexport default Container;\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","//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\n// Determine if `el` is a child of the document\nconst isNodeAttached = function(el) {\n return document.documentElement.contains(el && el.parentNode);\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","// DomMixin\n// ---------\n\nimport Backbone from 'backbone';\n\nexport default {\n createBuffer() {\n return document.createDocumentFragment();\n },\n\n appendChildren(el, children) {\n Backbone.$(el).append(children);\n },\n\n beforeEl(el, sibling) {\n Backbone.$(el).before(sibling);\n },\n\n replaceEl(newEl, oldEl) {\n if (newEl === oldEl) {\n return;\n }\n\n const parent = oldEl.parentNode;\n\n if (!parent) {\n return;\n }\n\n parent.replaceChild(newEl, oldEl);\n },\n\n detachContents(el) {\n Backbone.$(el).contents().detach();\n },\n\n setInnerContent(el, html) {\n Backbone.$(el).html(html);\n },\n\n detachEl(el) {\n Backbone.$(el).detach();\n },\n\n removeEl(el) {\n Backbone.$(el).remove();\n },\n\n findEls(selector, context) {\n return Backbone.$(selector, context);\n }\n};\n","// Template Cache\n// --------------\n\nimport _ from 'underscore';\nimport DomMixin from './mixins/dom';\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, DomMixin, {\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 = this.findEls(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 DomMixin from './dom';\nimport TriggersMixin from './triggers';\nimport UIMixin from './ui';\nimport { isEnabled } from '../config/features';\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 // 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 this.removeEl(this.el);\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._isDestroyed = true;\n this._isRendered = false;\n\n // Destroy behaviors after _isDestroyed flag\n this._destroyBehaviors(...args);\n\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 return this._getUI(name);\n },\n\n // used as the prefix for child view events\n // that are forwarded through the layoutview\n childViewEventPrefix() {\n return isEnabled('childViewEventPrefix') ? 'childview' : false;\n },\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\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 _proxyChildViewEvents(view) {\n this.listenTo(view, 'all', this._childViewEventHandler);\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, DomMixin, 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 DomMixin from './mixins/dom';\nimport MarionetteObject from './object';\nimport MarionetteError from './error';\nimport View from './view';\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 _isSwappingView: 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\n view = this._getView(view, options);\n\n if (view === this.currentView) { return this; }\n\n this._isSwappingView = !!this.currentView;\n\n this.triggerMethod('before:show', this, view, options);\n\n // Assume an attached view is already in the region for pre-existing DOM\n if (!view._isAttached) {\n this.empty(options);\n }\n\n this._setupChildView(view);\n\n this._renderView(view);\n\n this._attachView(view, options);\n\n this.currentView = view;\n\n this.triggerMethod('show', this, view, options);\n\n this._isSwappingView = false;\n\n return this;\n },\n\n _setupChildView(view) {\n monitorViewEvents(view);\n\n this._proxyChildViewEvents(view);\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\n _proxyChildViewEvents(view) {\n const parentView = this._parentView;\n\n if (!parentView) { return; }\n\n parentView._proxyChildViewEvents(view);\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\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 _getView(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 if (view instanceof Backbone.View) {\n return view;\n }\n\n const viewOptions = this._getViewOptions(view);\n\n return new View(viewOptions);\n },\n\n // This allows for a template or a static string to be\n // used as a template\n _getViewOptions(viewOptions) {\n if (_.isFunction(viewOptions)) {\n return { template: viewOptions };\n }\n\n if (_.isObject(viewOptions)) {\n return viewOptions;\n }\n\n const template = function() { return viewOptions; };\n\n return { template };\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 this.findEls(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 view.on('before:destroy', this._restoreEl, this);\n\n this.replaceEl(view.el, this.el);\n\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 this._detachView(view);\n\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 // Check to see if a view is being swapped by another\n isSwappingView() {\n return !!this._isSwappingView;\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.appendChildren(this.el, 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 if (shouldDestroy) {\n this.removeView(view);\n } else {\n this._detachView(view);\n }\n this._stopChildViewEvents(view);\n }\n\n this.triggerMethod('empty', this, view);\n },\n\n _stopChildViewEvents(view) {\n const parentView = this._parentView;\n\n if (!parentView) { return; }\n\n this._parentView.stopListening(view);\n },\n\n destroyView(view) {\n if (view._isDestroyed) {\n return view;\n }\n\n if (view.destroy) {\n view.destroy();\n } else {\n destroyBackboneView(view);\n }\n return view;\n },\n\n removeView(view) {\n this.destroyView(view);\n },\n\n // Empties the Region without destroying the view\n // Returns the detached view\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 const shouldRestoreEl = this._isReplaced;\n if (shouldTriggerDetach) {\n triggerMethodOn(view, 'before:detach', view);\n }\n\n if (shouldRestoreEl) {\n this.replaceEl(this.el, view.el);\n } else {\n this.detachHtml();\n }\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.detachContents(this.el);\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 if (this._isDestroyed) { return this; }\n\n this.reset(options);\n\n if (this._name) {\n this._parentView._removeReferences(this._name);\n }\n delete this._parentView;\n delete this._name;\n\n return MarionetteObject.prototype.destroy.apply(this, arguments);\n }\n});\n\n_.extend(Region.prototype, DomMixin);\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._parentView = this;\n region._name = name;\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 this.triggerMethod('remove:region', this, name, region);\n },\n\n // Called in a region's destroy\n _removeReferences(name) {\n delete this.regions[name];\n delete this._regions[name];\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 if (!this._isRendered) {\n this.render();\n }\n return this._regions[name];\n },\n\n // Get all regions\n _getRegions() {\n return _.clone(this._regions);\n },\n\n getRegions() {\n if (!this._isRendered) {\n this.render();\n }\n return this._getRegions();\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 deprecate from './utils/deprecate';\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 this._triggerEventOnBehaviors('initialize', this);\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 if (this._isDestroyed) { return this; }\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 deprecate('template:false is deprecated. Use _.noop.');\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 = this._renderHtml(template, data);\n this.attachElContent(html);\n },\n\n // Renders the data into the template\n _renderHtml(template, data) {\n return Renderer.render(template, data, this);\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.setInnerContent(this.el, 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 // Sets the renderer for the Marionette.View class\n setRenderer(renderer) {\n this.prototype._renderHtml = renderer;\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', 'partition'];\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 this._triggerEventOnBehaviors('initialize', this);\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) {\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 (this.isEmpty()) {\n this._showEmptyView();\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 = model && 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 _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 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 if (this._isDestroyed) { return this; }\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.appendChildren(this.el, 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();\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 monitorViewEvents(view);\n\n // set up the child view event forwarding\n this._proxyChildViewEvents(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 _.clone(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 if (!increment) {\n _.each(_.sortBy(this.children._views, '_index'), (view, index) => {\n view._index = index;\n });\n\n return;\n }\n\n const view = _.isArray(views) ? _.max(views, '_index') : views;\n\n if (_.isObject(view)) {\n // update the indexes of views after this one\n this.children.each((laterView) => {\n if (laterView._index >= view._index) {\n laterView._index += 1;\n }\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 // You might need to override this if you've overridden attachHtml\n attachBuffer(collectionView, buffer) {\n this.appendChildren(collectionView.el, buffer);\n },\n\n // Create a fragment buffer from the currently buffered children\n _createBuffer() {\n const elBuffer = this.createBuffer();\n _.each(this._bufferedChildren, (b) => {\n this.appendChildren(elBuffer, 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 this.beforeEl(currentView.el, 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.appendChildren(this.el, 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();\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 this.children.each(_.bind(this._removeChildView, this));\n this.children._updateLength();\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\n_.extend(CollectionView.prototype, ViewMixin);\n\nexport default CollectionView;\n","// Next 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 './next-child-view-container';\nimport MarionetteError from './error';\nimport Region from './region';\nimport ViewMixin from './mixins/view';\n\nconst ClassOptions = [\n 'behaviors',\n 'childView',\n 'childViewEventPrefix',\n 'childViewEvents',\n 'childViewOptions',\n 'childViewTriggers',\n 'collectionEvents',\n 'emptyView',\n 'emptyViewOptions',\n 'events',\n 'modelEvents',\n 'sortWithCollection',\n 'triggers',\n 'ui',\n 'viewComparator',\n 'viewFilter'\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 // flag for maintaining the sorted order of the collection\n sortWithCollection: true,\n\n // constructor\n constructor(options) {\n this._setOptions(options);\n\n this.mergeOptions(options, ClassOptions);\n\n monitorViewEvents(this);\n\n this.once('render', this._initialEvents);\n\n // This children container isn't really used by a render, but it provides\n // the ability to check `this.children.length` prior to rendering\n // It also allows for cases where only addChildView is used\n this._initChildViewStorage();\n this._initBehaviors();\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._initEmptyRegion();\n\n this.delegateEntityEvents();\n\n this._triggerEventOnBehaviors('initialize', this);\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 // Create an region to show the emptyView\n _initEmptyRegion() {\n this.emptyRegion = new Region({ el: this.el })\n\n this.emptyRegion._parentView = this;\n },\n\n // Configured the initial events that the collection view binds to.\n _initialEvents() {\n this.listenTo(this.collection, {\n 'sort': this._onCollectionSort,\n 'reset': this._onCollectionReset,\n 'update': this._onCollectionUpdate\n });\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 re-sort.\n _onCollectionSort() {\n if (!this.sortWithCollection) {\n return;\n }\n\n // If the data is changing we will handle the sort later\n if (this.collection.length !== this.children.length) {\n return;\n }\n\n // Additional check if the data is changing\n const hasAddedModel = this.collection.some(model => {\n return !this.children.findByModel(model);\n });\n\n if (hasAddedModel) {\n return;\n }\n\n // If the only thing happening here is sorting, sort.\n this.sort();\n },\n\n _onCollectionReset() {\n this.render();\n },\n\n // Handle collection update model additions and removals\n _onCollectionUpdate(collection, options) {\n const changes = options.changes;\n\n // Remove first since it'll be a shorter array lookup.\n const removedViews = this._removeChildModels(changes.removed);\n\n this._addChildModels(changes.added);\n\n this._detachChildren(removedViews);\n\n this._showChildren();\n\n // Destroy removed child views after all of the render is complete\n this._removeChildViews(removedViews);\n },\n\n _removeChildModels(models) {\n return _.map(models, _.bind(this._removeChildModel, this));\n },\n\n _removeChildModel(model) {\n const view = this.children.findByModel(model);\n\n this._removeChild(view);\n\n return view;\n },\n\n _removeChild(view) {\n this.triggerMethod('before:remove:child', this, view);\n\n this.children._remove(view);\n\n this.triggerMethod('remove:child', this, view);\n },\n\n // Added views are returned for consistency with _removeChildModels\n _addChildModels(models) {\n return _.map(models, _.bind(this._addChildModel, this));\n },\n\n _addChildModel(model) {\n const view = this._createChildView(model);\n\n this._addChild(view);\n\n return view;\n },\n\n _createChildView(model) {\n const ChildView = this._getChildView(model);\n const childViewOptions = this._getChildViewOptions(model);\n const view = this.buildChildView(model, ChildView, childViewOptions);\n\n return view;\n },\n\n _addChild(view, index) {\n this.triggerMethod('before:add:child', this, view);\n\n this._setupChildView(view);\n this.children._add(view, index);\n\n this.triggerMethod('add:child', this, view);\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 _getChildViewOptions(child) {\n if (_.isFunction(this.childViewOptions)) {\n return this.childViewOptions(child);\n }\n\n return this.childViewOptions;\n },\n\n // Build a `childView` for a model in the collection.\n // Override to customize the build\n buildChildView(child, ChildViewClass, childViewOptions) {\n const options = _.extend({model: child}, childViewOptions);\n return new ChildViewClass(options);\n },\n\n _setupChildView(view) {\n monitorViewEvents(view);\n\n // We need to listen for if a view is destroyed in a way other\n // than through the CollectionView.\n // If this happens we need to remove the reference to the view\n // since once a view has been destroyed we can not reuse it.\n view.on('destroy', this.removeChildView, this);\n\n // set up the child view event forwarding\n this._proxyChildViewEvents(view);\n },\n\n // used by ViewMixin's `_childViewEventHandler`\n _getImmediateChildren() {\n return this.children._views;\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.\n render() {\n if (this._isDestroyed) { return this; }\n this.triggerMethod('before:render', this);\n\n this._destroyChildren();\n\n // After all children have been destroyed re-init the container\n this.children._init();\n\n if (this.collection) {\n this._addChildModels(this.collection.models);\n }\n\n this._showChildren();\n\n this._isRendered = true;\n\n this.triggerMethod('render', this);\n return this;\n },\n\n // Sorts the children then filters and renders the results.\n sort() {\n if (this._isDestroyed) { return this; }\n\n if (!this.children.length) { return this; }\n\n this._showChildren();\n\n return this;\n },\n\n _showChildren() {\n if (this.isEmpty()) {\n this._showEmptyView();\n return;\n }\n\n this._sortChildren();\n\n this.filter();\n },\n\n // Returns true if the collectionView is considered empty.\n // This is called twice during a render. Once to check the data,\n // and again when views are filtered. Override this function to\n // customize what empty means.\n isEmpty(allViewsFiltered) {\n return allViewsFiltered || !this.children.length;\n },\n\n _showEmptyView() {\n const EmptyView = this._getEmptyView();\n\n if (!EmptyView) {\n return;\n }\n\n const options = this._getEmptyViewOptions();\n\n this.emptyRegion.show(new EmptyView(options));\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 // Remove the emptyView\n _destroyEmptyView() {\n\n // Only empty if a view is show so the region\n // doesn't detach any other unrelated HTML\n if (this.emptyRegion.hasView()) {\n this.emptyRegion.empty();\n }\n },\n\n //\n _getEmptyViewOptions() {\n const emptyViewOptions = this.emptyViewOptions || this.childViewOptions;\n\n if (_.isFunction(emptyViewOptions)) {\n return emptyViewOptions.call(this);\n }\n\n return emptyViewOptions;\n },\n\n // Sorts views by viewComparator and sets the children to the new order\n _sortChildren() {\n this.triggerMethod('before:sort', this);\n\n let viewComparator = this.getComparator();\n\n if (_.isFunction(viewComparator)) {\n // Must use native bind to preserve length\n viewComparator = viewComparator.bind(this);\n }\n\n this.children._sort(viewComparator);\n\n this.triggerMethod('sort', this);\n },\n\n // Sets the view's `viewComparator` and applies the sort if the view is ready.\n // To prevent the render pass `{ preventRender: true }` as the 2nd argument.\n setComparator(comparator, {preventRender} = {}) {\n const comparatorChanged = this.viewComparator !== comparator;\n const shouldSort = comparatorChanged && !preventRender;\n\n this.viewComparator = comparator;\n\n if (shouldSort) {\n this.sort();\n }\n\n return this;\n },\n\n // Clears the `viewComparator` and follows the same rules for rendering as `setComparator`.\n removeComparator(options) {\n return this.setComparator(null, options);\n },\n\n // If viewComparator is overriden it will be returned here.\n // Additionally override this function to provide custom\n // viewComparator logic\n getComparator() {\n return this.viewComparator || this._viewComparator;\n },\n\n // Default internal view comparator that order the views by\n // the order of the collection\n _viewComparator(view) {\n if (!this.collection) { return; }\n return this.collection.indexOf(view.model);\n },\n\n // This method re-filters the children views and re-renders the results\n filter() {\n if (this._isDestroyed) { return this; }\n\n if (!this.children.length) { return this; }\n\n const filteredViews = this._filterChildren();\n\n this._renderChildren(filteredViews);\n\n return this;\n },\n\n _filterChildren() {\n const viewFilter = this._getFilter();\n\n if (!viewFilter) {\n return this.children._views;\n }\n\n this.triggerMethod('before:filter', this);\n\n const filteredViews = this.children.partition(_.bind(viewFilter, this));\n\n this._detachChildren(filteredViews[1]);\n\n this.triggerMethod('filter', this);\n\n return filteredViews[0];\n },\n\n // This method returns a function for the viewFilter\n _getFilter() {\n const viewFilter = this.getFilter();\n\n if (!viewFilter) { return false; }\n\n if (_.isFunction(viewFilter)) {\n return viewFilter;\n }\n\n // Support filter predicates `{ fooFlag: true }`\n if (_.isObject(viewFilter)) {\n const matcher = _.matches(viewFilter);\n return function(view) {\n return matcher(view.model && view.model.attributes);\n };\n }\n\n // Filter by model attribute\n if (_.isString(viewFilter)) {\n return function(view) {\n return view.model && view.model.get(viewFilter);\n };\n }\n\n throw new MarionetteError({\n name: 'InvalidViewFilterError',\n message: '\"viewFilter\" must be a function, predicate object literal, a string indicating a model attribute, or falsy'\n });\n },\n\n // Override this function to provide custom\n // viewFilter logic\n getFilter() {\n return this.viewFilter;\n },\n\n // Sets the view's `viewFilter` and applies the filter if the view is ready.\n // To prevent the render pass `{ preventRender: true }` as the 2nd argument.\n setFilter(filter, {preventRender} = {}) {\n const filterChanged = this.viewFilter !== filter;\n const shouldRender = filterChanged && !preventRender;\n\n this.viewFilter = filter;\n\n if (shouldRender) {\n this.filter();\n }\n\n return this;\n },\n\n // Clears the `viewFilter` and follows the same rules for rendering as `setFilter`.\n removeFilter(options) {\n return this.setFilter(null, options);\n },\n\n _detachChildren(detachingViews) {\n _.each(detachingViews, _.bind(this._detachChildView, this));\n },\n\n _detachChildView(view) {\n const shouldTriggerDetach = !!view._isAttached;\n if (shouldTriggerDetach) {\n triggerMethodOn(view, 'before:detach', view);\n }\n\n this.detachHtml(view);\n\n if (shouldTriggerDetach) {\n view._isAttached = false;\n triggerMethodOn(view, 'detach', view);\n }\n },\n\n // Override this method to change how the collectionView detaches a child view\n detachHtml(view) {\n this.detachEl(view.el);\n },\n\n _renderChildren(views) {\n if (this.isEmpty(!views.length)) {\n this._showEmptyView();\n return;\n }\n\n this._destroyEmptyView();\n\n this.triggerMethod('before:render:children', this, views);\n\n const els = this._getBuffer(views);\n\n this._attachChildren(els, views);\n\n this.triggerMethod('render:children', this, views);\n },\n\n _attachChildren(els, views) {\n const shouldTriggerAttach = !!this._isAttached;\n\n views = shouldTriggerAttach ? views : [];\n\n _.each(views, view => {\n if (view._isAttached) { return; }\n triggerMethodOn(view, 'before:attach', view);\n });\n\n this.attachHtml(this, els);\n\n _.each(views, view => {\n if (view._isAttached) { return; }\n view._isAttached = true;\n triggerMethodOn(view, 'attach', view);\n });\n },\n\n // Renders each view in children and creates a fragment buffer from them\n _getBuffer(views) {\n const elBuffer = this.createBuffer();\n\n _.each(views, view => {\n this._renderChildView(view);\n this.appendChildren(elBuffer, view.el);\n });\n\n return elBuffer;\n },\n\n _renderChildView(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 // Override this method to do something other than `.append`.\n // You can attach any HTML at this point including the els.\n attachHtml(collectionView, els) {\n this.appendChildren(collectionView.el, els);\n },\n\n // Render the child's view and add it to the HTML for the collection view at a given index, based on the current sort\n addChildView(view, index) {\n if (!view || view._isDestroyed) {\n return view;\n }\n\n this._addChild(view, index);\n this._showChildren();\n\n return view;\n },\n\n // Detach a view from the children. Best used when adding a\n // childView from `addChildView`\n detachChildView(view) {\n this.removeChildView(view, { shouldDetach: true });\n\n return view;\n },\n\n // Remove the child view and destroy it. Best used when adding a\n // childView from `addChildView`\n // The options argument is for internal use only\n removeChildView(view, options) {\n if (!view) {\n return view;\n }\n\n this._removeChildView(view, options);\n\n this._removeChild(view);\n\n if (this.isEmpty()) {\n this._showEmptyView();\n }\n\n return view;\n },\n\n _removeChildViews(views) {\n _.each(views, _.bind(this._removeChildView, this));\n },\n\n _removeChildView(view, {shouldDetach} = {}) {\n view.off('destroy', this.removeChildView, this);\n\n if (shouldDetach) {\n this._detachChildView(view);\n } else {\n this._destroyChildView(view);\n }\n\n this.stopListening(view);\n },\n\n _destroyChildView(view) {\n if (view._isDestroyed) {\n return;\n }\n\n if (view.destroy) {\n view.destroy();\n } else {\n destroyBackboneView(view);\n }\n },\n\n // called by ViewMixin destroy\n _removeChildren() {\n this._destroyChildren();\n this.emptyRegion.destroy();\n },\n\n // Destroy the child views that this collection view is holding on to, if any\n _destroyChildren() {\n if (!this.children || !this.children.length) {\n return;\n }\n\n this.triggerMethod('before:destroy:children', this);\n this.children.each(_.bind(this._removeChildView, this));\n this.triggerMethod('destroy:children', this);\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 if (this._isDestroyed) { return this; }\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 this.appendChildren($container, 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 this.appendChildren($container, 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 this.appendChildren($container, 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 = this.findEls(selector, containerView.$el);\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', '_renderHtml', '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 deprecate from './utils/deprecate';\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\n if (this.defaults) {\n deprecate('Behavior defaults are deprecated. For similar functionality set options on the Behavior class.');\n }\n\n this.defaults = _.clone(_.result(this, 'defaults', {}));\n\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 this.view._removeBehavior(this);\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 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 NextCollectionView from './next-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.NextCollectionView = NextCollectionView;\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"]}