From 4a0ceb0b6a813be6110d2e7827bcffcb1649be61 Mon Sep 17 00:00:00 2001 From: Sam Saccone Date: Sun, 22 Feb 2015 18:57:34 -0500 Subject: [PATCH] Bump and build v2.4.0 --- bower.json | 2 +- changelog.md | 72 +++++ component.json | 2 +- lib/backbone.marionette.js | 392 +++++++++++++++++++++------- lib/backbone.marionette.map | 2 +- lib/backbone.marionette.min.js | 6 +- lib/core/backbone.marionette.js | 389 +++++++++++++++++++++------ lib/core/backbone.marionette.map | 2 +- lib/core/backbone.marionette.min.js | 4 +- package.json | 2 +- 10 files changed, 691 insertions(+), 182 deletions(-) diff --git a/bower.json b/bower.json index 2986852f12..3bbd3f45fc 100644 --- a/bower.json +++ b/bower.json @@ -3,7 +3,7 @@ "description": "Make your Backbone.js apps dance with a composite application architecture!", "homepage": "http://marionettejs.org", "main": "./lib/core/backbone.marionette.js", - "version": "2.3.2", + "version": "2.4.0", "keywords": [ "backbone", "framework", diff --git a/changelog.md b/changelog.md index 2891e3af2a..651a17bf5b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,75 @@ +### v2.4.0 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.3.2...v2.4.0) + +#### 2.4 In Overview + +The Marionette 2.4 release is primarily focused around adding power and performance to `Marionette.CollectionView’s` and `CompositeViews`. It is now possible for users to declaratively sort, filter, and reorder in a performant and clear way on the view layer. Prior to this work it was difficult and required significant workarounds. + +As well as working on the `CollectionView` layer we have added full support for lodash and multiple builds of backbone, underscore and lodash. Allowing the user to pick whatever tools they wish. + +The other powerful feature that we introduced in this release is the concept of `childEvents` for `LayoutView` and their subviews. Prior to this release there was never a great way to listen or react to events that were triggered on subviews, like when something was rendered or destroyed. Now we have brought over the declarative `childEvents` hash from `CollectionView` into the `LayoutView`. + +As always come and join us in [chat](https://gitter.im/marionettejs/backbone.marionette/) + +#### Features + +* CollectionView + * You can now set a filter method on a `CollectionView` or `CompositeView` to filter what views are show. This is useful for when you are displaying a list that a user can filter. + * Add the `reorderOnSort` option to `CollectionView` and `CompositeView` to use jQuery to move child nodes around without having to re-render the entire tree. This is a massive perf boost and is an easy win if you are sorting your collections. + * The `CollectionView` now has a `viewComparator`, to enable custom sorting on a per view basis regardless of what how your backing collection is sorted. + * Refactor sort param lookup to use `Marionette.getOption`. + * **Fix** childViews now fire a `before:show` event even if the childView is inserted after the parent `CollectionView` or `CompositeView` has been shown. + +* Regions + * The `empty` method now takes an optional `preventDestroy` flag to prevent the destruction of the view shown within. + * `this.myRegion.empty({preventDestroy: true})` + +* TemplateCache + * The templateCache `get` method now takes a second param of options to enable passing options to the loading of templates. + +* LayoutView + * Add a new helper method for easier showing of child nodes `showChildView` + * `this.showChildView('sidebar', new SidebarView());` + * Add a new helper method of easier retrieving of child nodes `getChildView` + * `this.getChildView(‘sidebar’)` + * Add a `destroyImmediate` option to the `LayoutView`, to destroy the layout view element and then remove the child nodes. This is a perf optimization that you can now opt into. + * `@ui` interpolation is now supported within region definitions on a `LayoutView` + * `regionEvent` support was added + * you can access this functionality via `onChildViewX` or via the declarative `childEvents` hash + +* ItemViews + * the `isRendered` property is now set to `true` after render, even if no template is set. + * Views + * The `destroy` method now returns this instance that was destroyed to enable easier chaining of view actions. + * If you define the options hash on your `Marionette.View` or if you pass options as a function to your `Marionette.View`, pass the result of options down to the backbone view constructor. + * All views now have a `isRendered` property, that is updated after `render` and `destroy`. + +* Object + * The `destroy` method now returns this instance that was destroyed to enable easier chaining of object actions. + +* Behavior + * The `destroy` method now returns this instance that was destroyed to enable easier chaining of behavior actions. + * Expose the `UI` hash to a behavior instance. The behavior `UI` hash is a composite of the view hash and the behavior hash merged with the behavior hash tasking precedence. + +#### Util + +* `Marionette._getValue` will now use `call` under the hood if no arguments are passed (micro optimization). +* Add `Marionette.mergeOptions` to `Marionette.View*` classes, `Marionette.Object`. `Marionette.AppRouter`, `Marionette.Controller` +* `mergeOptions` is a handy function to pluck certain `options` and attach them directly to an instance. + +#### Docs + +* Minor documentation cleanups and fixes + +#### Deprecation Notices + +* Deprecate `Marionette.Controller`, Use `Marionette.Object` instead. + +#### Misc + +* YAML api documentation is now linted on each PR. +* Add `Marionette.FEATURES` flag. +* Refactor several methods to enable 100% compatibility with lodash. + ### v2.3.2 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.3.1...v2.3.2) #### 2.3.2 in overview: diff --git a/component.json b/component.json index 71cc4934e6..a4bd27ef4f 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "backbone.marionette", "description": "Make your Backbone.js apps dance!", - "version": "2.3.2", + "version": "2.4.0", "repo": "marionettejs/backbone.marionette", "main": "lib/core/backbone.marionette.js", "keywords": [ diff --git a/lib/backbone.marionette.js b/lib/backbone.marionette.js index 4730b4f146..9de0354e9e 100644 --- a/lib/backbone.marionette.js +++ b/lib/backbone.marionette.js @@ -1,6 +1,6 @@ // MarionetteJS (Backbone.Marionette) // ---------------------------------- -// v2.3.2 +// v2.4.0 // // Copyright (c)2015 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license @@ -38,9 +38,9 @@ /* istanbul ignore next */ // Backbone.BabySitter // ------------------- - // v0.1.5 + // v0.1.6 // - // Copyright (c)2014 Derick Bailey, Muted Solutions, LLC. + // Copyright (c)2015 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license // // http://github.com/marionettejs/backbone.babysitter @@ -156,7 +156,7 @@ // // Mix in methods from Underscore, for iteration, and other // collection related features. - var methods = [ "forEach", "each", "map", "find", "detect", "filter", "select", "reject", "every", "all", "some", "any", "include", "contains", "invoke", "toArray", "first", "initial", "rest", "last", "without", "isEmpty", "pluck" ]; + var methods = [ "forEach", "each", "map", "find", "detect", "filter", "select", "reject", "every", "all", "some", "any", "include", "contains", "invoke", "toArray", "first", "initial", "rest", "last", "without", "isEmpty", "pluck", "reduce" ]; _.each(methods, function(method) { Container.prototype[method] = function() { var views = _.values(this._views); @@ -167,7 +167,7 @@ // return the public API return Container; }(Backbone, _); - Backbone.ChildViewContainer.VERSION = "0.1.5"; + Backbone.ChildViewContainer.VERSION = "0.1.6"; Backbone.ChildViewContainer.noConflict = function() { Backbone.ChildViewContainer = previousChildViewContainer; return this; @@ -490,13 +490,15 @@ })(Backbone, _); var previousMarionette = root.Marionette; + var previousMn = root.Mn; var Marionette = Backbone.Marionette = {}; - Marionette.VERSION = '2.3.2'; + Marionette.VERSION = '2.4.0'; Marionette.noConflict = function() { root.Marionette = previousMarionette; + root.Mn = previousMn; return this; }; @@ -524,6 +526,11 @@ return Backbone.$.contains(document.documentElement, el); }; + // Merge `keys` from `options` onto `this` + Marionette.mergeOptions = function(options, keys) { + if (!options) { return; } + _.extend(this, _.pick(options, keys)); + }; // Marionette.getOption // -------------------- @@ -550,11 +557,7 @@ // undefined return a default value Marionette._getValue = function(value, context, params) { if (_.isFunction(value)) { - // We need to ensure that params is not undefined - // to prevent `apply` from failing in ie8 - params = params || []; - - value = value.apply(context, params); + value = params ? value.apply(context, params) : value.call(context); } return value; }; @@ -599,11 +602,21 @@ // allows for the use of the @ui. syntax within // a given value for regions // swaps the @ui with the associated selector - Marionette.normalizeUIValues = function(hash, ui) { + Marionette.normalizeUIValues = function(hash, ui, properties) { _.each(hash, function(val, key) { if (_.isString(val)) { hash[key] = Marionette.normalizeUIString(val, ui); } + else if (_.isObject(val) && _.isArray(properties)) { + _.extend(val, Marionette.normalizeUIValues(_.pick(val, properties), ui)); + /* Value is an object, and we got an array of embedded property names to normalize. */ + _.each(properties, function(property) { + var propertyVal = val[property]; + if (_.isString(propertyVal)) { + val[property] = Marionette.normalizeUIString(propertyVal, ui); + } + }); + } }); return hash; }; @@ -682,7 +695,7 @@ // trigger the event, if a trigger method exists if (_.isFunction(context.trigger)) { if (noEventArg + args.length > 1) { - context.trigger.apply(context, noEventArg ? args : [event].concat(_.rest(args, 0))); + context.trigger.apply(context, noEventArg ? args : [event].concat(_.drop(args, 0))); } else { context.trigger(event); } @@ -984,6 +997,9 @@ // methods if the method exists triggerMethod: Marionette.triggerMethod, + // A handy way to merge options onto the instance + mergeOptions: Marionette.mergeOptions, + // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption @@ -1015,12 +1031,17 @@ this.triggerMethod('before:destroy'); this.triggerMethod('destroy'); this.stopListening(); + + return this; }, // Import the `triggerMethod` to trigger events with corresponding // methods if the method exists triggerMethod: Marionette.triggerMethod, + // A handy way to merge options onto the instance + mergeOptions: Marionette.mergeOptions, + // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption, @@ -1235,20 +1256,28 @@ // Destroy the current view, if there is one. If there is no // current view, it does nothing and returns immediately. - empty: function() { + empty: function(options) { var view = this.currentView; + var preventDestroy = Marionette._getValue(options, 'preventDestroy', this); // If there is no view in the region // we should not remove anything if (!view) { return; } view.off('destroy', this.empty, this); this.triggerMethod('before:empty', view); - this._destroyView(); + if (!preventDestroy) { + this._destroyView(); + } this.triggerMethod('empty', view); // Remove region pointer to the currentView delete this.currentView; + + if (preventDestroy) { + this.$el.contents().detach(); + } + return this; }, @@ -1371,6 +1400,7 @@ Marionette.RegionManager = Marionette.Controller.extend({ constructor: function(options) { this._regions = {}; + this.length = 0; Marionette.Controller.call(this, options); @@ -1464,8 +1494,11 @@ // internal method to store regions _store: function(name, region) { + if (!this._regions[name]) { + this.length++; + } + this._regions[name] = region; - this._setLength(); }, // internal method to remove a region @@ -1476,13 +1509,8 @@ delete region._parent; delete this._regions[name]; - this._setLength(); + this.length--; this.triggerMethod('remove:region', name, region); - }, - - // set the number of regions current held - _setLength: function() { - this.length = _.size(this._regions); } }); @@ -1507,7 +1535,7 @@ // Get the specified template by id. Either // retrieves the cached version, or loads it // from the DOM. - get: function(templateId) { + get: function(templateId, options) { var cachedTemplate = this.templateCaches[templateId]; if (!cachedTemplate) { @@ -1515,7 +1543,7 @@ this.templateCaches[templateId] = cachedTemplate; } - return cachedTemplate.load(); + return cachedTemplate.load(options); }, // Clear templates from the cache. If no arguments @@ -1546,15 +1574,15 @@ _.extend(Marionette.TemplateCache.prototype, { // Internal method to load the template - load: function() { + load: function(options) { // Guard clause to prevent loading this template more than once if (this.compiledTemplate) { return this.compiledTemplate; } // Load the template and compile it - var template = this.loadTemplate(this.templateId); - this.compiledTemplate = this.compileTemplate(template); + var template = this.loadTemplate(this.templateId, options); + this.compiledTemplate = this.compileTemplate(template, options); return this.compiledTemplate; }, @@ -1564,7 +1592,7 @@ // For asynchronous loading with AMD/RequireJS, consider // using a template-loader plugin as described here: // https://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs - loadTemplate: function(templateId) { + loadTemplate: function(templateId, options) { var template = Backbone.$(templateId).html(); if (!template || template.length === 0) { @@ -1581,8 +1609,8 @@ // this method if you do not need to pre-compile a template // (JST / RequireJS for example) or if you want to change // the template engine used (Handebars, etc). - compileTemplate: function(rawTemplate) { - return _.template(rawTemplate); + compileTemplate: function(rawTemplate, options) { + return _.template(rawTemplate, options); } }); @@ -1633,10 +1661,9 @@ this._behaviors = Marionette.Behaviors(this); - Backbone.View.apply(this, arguments); + Backbone.View.call(this, this.options); Marionette.MonitorDOMRefresh(this); - this.on('show', this.onShowCalled); }, // Get the template for this view @@ -1674,10 +1701,10 @@ // normalize the values of passed hash with the views `ui` selectors. // `{foo: "@ui.bar"}` - normalizeUIValues: function(hash) { + normalizeUIValues: function(hash, properties) { var ui = _.result(this, 'ui'); var uiBindings = _.result(this, '_uiBindings'); - return Marionette.normalizeUIValues(hash, uiBindings || ui); + return Marionette.normalizeUIValues(hash, uiBindings || ui, properties); }, // Configure `triggers` to forward DOM events to view @@ -1748,9 +1775,6 @@ return this; }, - // Internal method, handles the `show` event. - onShowCalled: function() {}, - // Internal helper method to verify whether the view hasn't been destroyed _ensureViewIsIntact: function() { if (this.isDestroyed) { @@ -1766,7 +1790,7 @@ // for you. You can specify an `onDestroy` method in your view to // add custom code that is called after the view is destroyed. destroy: function() { - if (this.isDestroyed) { return; } + if (this.isDestroyed) { return this; } var args = _.toArray(arguments); @@ -1781,6 +1805,8 @@ // unbind UI elements this.unbindUIElements(); + this.isRendered = false; + // remove the view from the DOM this.remove(); @@ -1887,15 +1913,42 @@ // import the `triggerMethod` to trigger events with corresponding // methods if the method exists triggerMethod: function() { + var ret = Marionette._triggerMethod(this, arguments); + + this._triggerEventOnBehaviors(arguments); + this._triggerEventOnParentLayout(arguments[0], _.rest(arguments)); + + return ret; + }, + + _triggerEventOnBehaviors: function(args) { var triggerMethod = Marionette._triggerMethod; - var ret = triggerMethod(this, arguments); var behaviors = this._behaviors; // Use good ol' for as this is a very hot function for (var i = 0, length = behaviors && behaviors.length; i < length; i++) { - triggerMethod(behaviors[i], arguments); + triggerMethod(behaviors[i], args); } + }, - return ret; + _triggerEventOnParentLayout: function(eventName, args) { + var layoutView = this._parentLayoutView(); + if (!layoutView) { + return; + } + + // invoke triggerMethod on parent view + var eventPrefix = Marionette.getOption(layoutView, 'childViewEventPrefix'); + var prefixedEventName = eventPrefix + ':' + eventName; + + Marionette._triggerMethod(layoutView, [prefixedEventName, this].concat(args)); + + // call the parent view's childEvents handler + var childEvents = Marionette.getOption(layoutView, 'childEvents'); + var normalizedChildEvents = layoutView.normalizeMethods(childEvents); + + if (!!normalizedChildEvents && _.isFunction(normalizedChildEvents[eventName])) { + normalizedChildEvents[eventName].apply(layoutView, [this].concat(args)); + } }, // This method returns any views that are immediate @@ -1916,10 +1969,35 @@ }, children); }, + // Internal utility for building an ancestor + // view tree list. + _getAncestors: function() { + var ancestors = []; + var parent = this._parent; + + while (parent) { + ancestors.push(parent); + parent = parent._parent; + } + + return ancestors; + }, + + // Returns the containing parent view. + _parentLayoutView: function() { + var ancestors = this._getAncestors(); + return _.find(ancestors, function(parent) { + return parent instanceof Marionette.LayoutView; + }); + }, + // Imports the "normalizeMethods" to transform hashes of // events=>function references/names to a hash of events=>function references normalizeMethods: Marionette.normalizeMethods, + // A handy way to merge passed-in options onto the instance + mergeOptions: Marionette.mergeOptions, + // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption, @@ -1986,6 +2064,7 @@ this.triggerMethod('before:render', this); this._renderTemplate(); + this.isRendered = true; this.bindUIElements(); this.triggerMethod('render', this); @@ -2013,8 +2092,7 @@ } // Add in entity data and template helpers - var data = this.serializeData(); - data = this.mixinTemplateHelpers(data); + var data = this.mixinTemplateHelpers(this.serializeData()); // Render and add to el var html = Marionette.Renderer.render(template, data, this); @@ -2055,21 +2133,25 @@ // that are forwarded through the collectionview childViewEventPrefix: 'childview', + // flag for maintaining the sorted order of the collection + sort: true, + // constructor // option to pass `{sort: false}` to prevent the `CollectionView` from // maintaining the sorted order of the collection. // This will fallback onto appending childView's to the end. + // + // option to pass `{comparator: compFunction()}` to allow the `CollectionView` + // to use a custom sort order for the collection. constructor: function(options){ - var initOptions = options || {}; - if (_.isUndefined(this.sort)){ - this.sort = _.isUndefined(initOptions.sort) ? true : initOptions.sort; - } this.once('render', this._initialEvents); this._initChildViewStorage(); Marionette.View.apply(this, arguments); + this.on('show', this._onShowCalled); + this.initRenderBuffer(); }, @@ -2077,7 +2159,6 @@ // it's much more performant to insert elements into a document // fragment and then insert that document fragment into the page initRenderBuffer: function() { - this.elBuffer = document.createDocumentFragment(); this._bufferedChildren = []; }, @@ -2089,7 +2170,9 @@ endBuffering: function() { this.isBuffering = false; this._triggerBeforeShowBufferedChildren(); - this.attachBuffer(this, this.elBuffer); + + this.attachBuffer(this); + this._triggerShowBufferedChildren(); this.initRenderBuffer(); }, @@ -2122,18 +2205,26 @@ this.listenTo(this.collection, 'remove', this._onCollectionRemove); this.listenTo(this.collection, 'reset', this.render); - if (this.sort) { + if (this.getOption('sort')) { this.listenTo(this.collection, 'sort', this._sortViews); } } }, // Handle a child added to the collection - _onCollectionAdd: function(child) { - this.destroyEmptyView(); - var ChildView = this.getChildView(child); - var index = this.collection.indexOf(child); - this.addChild(child, ChildView, index); + _onCollectionAdd: function(child, collection, opts) { + var index; + if (opts.at !== undefined) { + index = opts.at; + } else { + index = _.indexOf(this._filteredSortedModels(), child); + } + + if (this._shouldAddChild(child, index)) { + this.destroyEmptyView(); + var ChildView = this.getChildView(child); + this.addChild(child, ChildView, index); + } }, // get the child view by model it holds, and remove it @@ -2143,8 +2234,7 @@ this.checkEmpty(); }, - // Override from `Marionette.View` to trigger show on child views - onShowCalled: function() { + _onShowCalled: function() { this.children.each(_.partial(this._triggerMethodOnChild, 'show')); }, @@ -2155,23 +2245,60 @@ this._ensureViewIsIntact(); this.triggerMethod('before:render', this); this._renderChildren(); + this.isRendered = true; this.triggerMethod('render', this); return this; }, + // Reorder DOM after sorting. When your element's rendering + // do not use their index, you can pass reorderOnSort: true + // to only reorder the DOM after a sort instead of rendering + // all the collectionView + reorder: function () { + var children = this.children; + var models = this._filteredSortedModels(); + var modelsChanged = _.find(models, function (model) { + return !children.findByModel(model); + }); + + // If the models we're displaying have changed due to filtering + // We need to add and/or remove child views + // So render as normal + if (modelsChanged) { + this.render(); + } else { + // get the DOM nodes in the same order as the models + var els = _.map(models, function (model) { + return children.findByModel(model).el; + }); + + // since append moves elements that are already in the DOM, + // appending the elements will effectively reorder them + this.triggerMethod('before:reorder'); + this.$el.append(els); + this.triggerMethod('reorder'); + } + }, + // Render view after sorting. Override this method to // change how the view renders after a `sort` on the collection. // An example of this would be to only `renderChildren` in a `CompositeView` // rather than the full view. resortView: function() { - this.render(); + if (Marionette.getOption(this, 'reorderOnSort')) { + this.reorder(); + } else { + this.render(); + } }, // Internal method. This checks for any changes in the order of the collection. // If the index of any view doesn't match, it will render. _sortViews: function() { + var models = this._filteredSortedModels(); + // check for any changes in sort order of views - var orderChanged = this.collection.find(function(item, index){ + var orderChanged = _.find(models, function(item, index){ var view = this.children.findByModel(item); return !view || view._index !== index; }, this); @@ -2199,18 +2326,51 @@ this.showCollection(); this.endBuffering(); this.triggerMethod('render:collection', this); + + // If we have shown children and none have passed the filter, show the empty view + if (this.children.isEmpty()) { + this.showEmptyView(); + } } }, // Internal method to loop through collection and show each child view. showCollection: function() { var ChildView; - this.collection.each(function(child, index) { + + var models = this._filteredSortedModels(); + + _.each(models, function(child, index) { ChildView = this.getChildView(child); this.addChild(child, ChildView, index); }, this); }, + // Allow the collection to be sorted by a custom view comparator + _filteredSortedModels: function() { + var models; + var viewComparator = this.getViewComparator(); + + if (viewComparator) { + if (_.isString(viewComparator) || viewComparator.length === 1) { + models = this.collection.sortBy(viewComparator, this); + } else { + models = _.clone(this.collection.models).sort(_.bind(viewComparator, this)); + } + } else { + models = this.collection.models; + } + + // Filter after sorting in case the filter uses the index + if (this.getOption('filter')) { + models = _.filter(models, function (model, index) { + return this._shouldAddChild(model, index); + }, this); + } + + return models; + }, + // Internal method to show an empty view in place of // a collection of child views, when the collection is empty showEmptyView: function() { @@ -2329,7 +2489,7 @@ // Internal method. This decrements or increments the indices of views after the // added/removed view to keep in sync with the collection. _updateIndices: function(view, increment, index) { - if (!this.sort) { + if (!this.getOption('sort')) { return; } @@ -2355,6 +2515,12 @@ this.triggerMethod('before:add:child', view); + // trigger the 'before:show' event on `view` if the collection view + // has already been shown + if (this._isShown && !this.isBuffering) { + Marionette.triggerMethodOn(view, 'before:show'); + } + // Store the child view itself so we can properly // remove and/or destroy it later this.children.add(view); @@ -2417,8 +2583,17 @@ }, // You might need to override this if you've overridden attachHtml - attachBuffer: function(collectionView, buffer) { - collectionView.$el.append(buffer); + attachBuffer: function(collectionView) { + collectionView.$el.append(this._createBuffer(collectionView)); + }, + + // Create a fragment buffer from the currently buffered children + _createBuffer: function(collectionView) { + var elBuffer = document.createDocumentFragment(); + _.each(collectionView._bufferedChildren, function(b) { + elBuffer.appendChild(b.el); + }); + return elBuffer; }, // Append the HTML to the collection's `el`. @@ -2429,8 +2604,7 @@ // buffering happens on reset events and initial renders // in order to reduce the number of inserts into the // document, which are expensive. - collectionView.elBuffer.appendChild(childView.el); - collectionView._bufferedChildren.push(childView); + collectionView._bufferedChildren.splice(index, 0, childView); } else { // If we've already rendered the main collection, append @@ -2446,7 +2620,7 @@ // the correct position. _insertBefore: function(childView, index) { var currentView; - var findPosition = this.sort && (index < this.children.length - 1); + var findPosition = this.getOption('sort') && (index < this.children.length - 1); if (findPosition) { // Find the view after this one currentView = this.children.find(function (view) { @@ -2475,7 +2649,7 @@ // Handle cleanup and other destroying needs for the collection of views destroy: function() { - if (this.isDestroyed) { return; } + if (this.isDestroyed) { return this; } this.triggerMethod('before:destroy:collection'); this.destroyChildren(); @@ -2493,6 +2667,18 @@ return childViews; }, + // Return true if the given child should be shown + // Return false otherwise + // The filter will be passed (child, index, collection) + // Where + // 'child' is the given model + // 'index' is the index of that model in the collection + // 'collection' is the collection referenced by this CollectionView + _shouldAddChild: function (child, index) { + var filter = this.getOption('filter'); + return !_.isFunction(filter) || filter.call(this, child, index, this.collection); + }, + // Set up the child view event forwarding. Uses a "childview:" // prefix in front of all forwarded events. proxyChildEvents: function(view) { @@ -2514,11 +2700,15 @@ } this.triggerMethod.apply(this, args); - }, this); + }); }, _getImmediateChildren: function() { return _.values(this.children._views); + }, + + getViewComparator: function() { + return this.getOption('viewComparator'); } }); @@ -2554,7 +2744,7 @@ this.listenTo(this.collection, 'remove', this._onCollectionRemove); this.listenTo(this.collection, 'reset', this._renderChildren); - if (this.sort) { + if (this.getOption('sort')) { this.listenTo(this.collection, 'sort', this._sortViews); } } @@ -2586,7 +2776,7 @@ // Renders the model and the collection. render: function() { this._ensureViewIsIntact(); - this.isRendered = true; + this._isRendering = true; this.resetChildViewContainer(); this.triggerMethod('before:render', this); @@ -2594,12 +2784,14 @@ this._renderTemplate(); this._renderChildren(); + this._isRendering = false; + this.isRendered = true; this.triggerMethod('render', this); return this; }, _renderChildren: function() { - if (this.isRendered) { + if (this.isRendered || this._isRendering) { Marionette.CollectionView.prototype._renderChildren.call(this); } }, @@ -2643,9 +2835,9 @@ }, // You might need to override this if you've overridden attachHtml - attachBuffer: function(compositeView, buffer) { + attachBuffer: function(compositeView) { var $container = this.getChildViewContainer(compositeView); - $container.append(buffer); + $container.append(this._createBuffer(compositeView)); }, // Internal method. Append a view to the end of the $el. @@ -2710,6 +2902,14 @@ Marionette.LayoutView = Marionette.ItemView.extend({ regionClass: Marionette.Region, + options: { + destroyImmediate: false + }, + + // used as the prefix for child view events + // that are forwarded through the layoutview + childViewEventPrefix: 'childview', + // Ensure the regions are available when the `initialize` method // is called. constructor: function(options) { @@ -2744,11 +2944,23 @@ // Handle destroying regions, and then destroy the view itself. destroy: function() { if (this.isDestroyed) { return this; } - + // #2134: remove parent element before destroying the child views, so + // removing the child views doesn't retrigger repaints + if(this.getOption('destroyImmediate') === true) { + this.$el.remove(); + } this.regionManager.destroy(); return Marionette.ItemView.prototype.destroy.apply(this, arguments); }, + showChildView: function(regionName, view) { + return this.getRegion(regionName).show(view); + }, + + getChildView: function(regionName) { + return this.getRegion(regionName).currentView; + }, + // Add a single region, by name, to the layoutView addRegion: function(name, definition) { var regions = {}; @@ -2808,7 +3020,7 @@ // Normalize region selectors hash to allow // a user to use the @ui. syntax. - regions = this.normalizeUIValues(regions); + regions = this.normalizeUIValues(regions, ['selector', 'el']); this.addRegions(regions); }, @@ -2877,6 +3089,12 @@ this.view = view; this.defaults = _.result(this, 'defaults') || {}; this.options = _.extend({}, this.defaults, options); + // Construct an internal UI hash using + // the views UI hash and then the behaviors UI hash. + // This allows the user to use UI hash elements + // defined in the parent view as well as those + // defined in the given behavior. + this.ui = _.extend({}, _.result(view, 'ui'), _.result(this, 'ui')); Marionette.Object.apply(this, arguments); }, @@ -2892,6 +3110,8 @@ // Overrides Object#destroy to prevent additional events from being triggered. destroy: function() { this.stopListening(); + + return this; }, proxyViewProperties: function (view) { @@ -2939,23 +3159,15 @@ behaviorEvents: function(behaviorEvents, behaviors) { var _behaviorsEvents = {}; - var viewUI = this._uiBindings || _.result(this, 'ui'); _.each(behaviors, function(b, i) { var _events = {}; var behaviorEvents = _.clone(_.result(b, 'events')) || {}; - var behaviorUI = b._uiBindings || _.result(b, 'ui'); - // Construct an internal UI hash first using - // the views UI hash and then the behaviors UI hash. - // This allows the user to use UI hash elements - // defined in the parent view as well as those - // defined in the given behavior. - var ui = _.extend({}, viewUI, behaviorUI); // Normalize behavior events hash to allow // a user to use the @ui. syntax. - behaviorEvents = Marionette.normalizeUIKeys(behaviorEvents, ui); + behaviorEvents = Marionette.normalizeUIKeys(behaviorEvents, getBehaviorsUI(b)); var j = 0; _.each(behaviorEvents, function(behaviour, key) { @@ -3042,7 +3254,6 @@ // for views function BehaviorTriggersBuilder(view, behaviors) { this._view = view; - this._viewUI = _.result(view, 'ui'); this._behaviors = behaviors; this._triggers = {}; } @@ -3056,10 +3267,9 @@ // Internal method to build all trigger handlers for a given behavior _buildTriggerHandlersForBehavior: function(behavior, i) { - var ui = _.extend({}, this._viewUI, _.result(behavior, 'ui')); var triggersHash = _.clone(_.result(behavior, 'triggers')) || {}; - triggersHash = Marionette.normalizeUIKeys(triggersHash, ui); + triggersHash = Marionette.normalizeUIKeys(triggersHash, getBehaviorsUI(behavior)); _.each(triggersHash, _.bind(this._setHandlerForBehavior, this, behavior, i)); }, @@ -3076,6 +3286,10 @@ } }); + function getBehaviorsUI(behavior) { + return behavior._uiBindings || behavior.ui; + } + return Behaviors; })(Marionette, _); @@ -3157,6 +3371,8 @@ this.route(route, methodName, _.bind(method, controller)); }, + mergeOptions: Marionette.mergeOptions, + // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption, @@ -3464,7 +3680,7 @@ // get the custom args passed in after the module definition and // get rid of the module name and definition function - var customArgs = _.rest(arguments, 3); + var customArgs = _.drop(arguments, 3); // Split the module names and get the number of submodules. // i.e. an example module name of `Doge.Wow.Amaze` would diff --git a/lib/backbone.marionette.map b/lib/backbone.marionette.map index 56d84fac5c..edca2cf678 100644 --- a/lib/backbone.marionette.map +++ b/lib/backbone.marionette.map @@ -1 +1 @@ -{"version":3,"sources":["?"],"names":["root","factory","define","amd","Backbone","_","Marionette","Mn","exports","require","module","this","previousChildViewContainer","ChildViewContainer","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","each","add","extend","prototype","view","customIndex","viewCid","cid","model","findByModel","findByModelCid","modelCid","findByCid","findByCustom","index","findByIndex","values","remove","any","key","call","method","apply","tail","arguments","args","isFunction","length","size","methods","concat","toArray","VERSION","noConflict","previousWreqr","Wreqr","Handlers","options","_wreqrHandlers","initialize","Model","Events","setHandlers","handlers","handler","name","context","isObject","callback","setHandler","config","trigger","hasHandler","getHandler","Array","slice","removeHandler","removeAllHandlers","CommandStorage","_commands","getCommands","commandName","commands","command","instances","addCommand","push","clearCommands","Commands","storageType","constructor","_initializeStorage","on","_executeCommands","execute","storage","StorageType","RequestResponse","request","EventAggregator","EA","Channel","channelName","vent","reqres","reset","off","stopListening","connectEvents","hash","_connect","connectCommands","connectRequests","type","fn","eventName","bind","radio","Radio","_channels","_proxyMethods","channel","Error","_getChannel","system","messageSystems","proxyMethod","messageSystem","previousMarionette","Deferred","$","isNodeAttached","el","contains","document","documentElement","getOption","target","optionName","undefined","proxyGetOption","_getValue","value","params","normalizeMethods","reduce","normalizedHash","normalizeUIString","uiString","ui","replace","r","normalizeUIKeys","memo","val","normalizedKey","normalizeUIValues","isString","actAsCollection","object","listProperty","list","result","deprecate","message","test","prev","next","url","_cache","_warn","console","warn","log","_triggerMethod","getEventName","match","prefix","toUpperCase","splitter","event","noEventArg","methodName","rest","triggerMethod","triggerMethodOn","fnc","MonitorDOMRefresh","handleShow","_isShown","triggerDOMRefresh","handleRender","_isRendered","show","render","bindFromStrings","entity","evt","methodNames","split","listenTo","bindToFunction","unbindFromStrings","unbindToFunction","iterateEvents","bindings","functionCallback","stringCallback","bindEntityEvents","unbindEntityEvents","proxyBindEntityEvents","proxyUnbindEntityEvents","errorProps","urlRoot","error","pick","captureStackTrace","toString","Callbacks","_deferred","_callbacks","contextOverride","promise","cb","ctx","then","run","resolve","callbacks","Controller","destroy","Object","Region","$el","getEl","_ensureElement","_ensureViewIsIntact","showOptions","isDifferentView","currentView","preventDestroy","forceShow","isChangingView","_shouldDestroyView","_shouldShowView","_parent","empty","once","attachedRegion","displayedViews","triggerBeforeAttach","triggerAttach","_displayedViews","_triggerAttach","attachHtml","union","selector","isDestroyed","parentEl","contents","detach","appendChild","_destroyView","attachView","hasView","buildRegion","regionConfig","DefaultRegionClass","_buildRegionFromSelector","regionClass","_buildRegionFromObject","_buildRegionFromRegionClass","RegionClass","omit","RegionManager","_regions","addRegions","regionDefinitions","defaults","regions","definition","addRegion","region","_store","get","getRegions","clone","removeRegion","_remove","removeRegions","emptyRegions","invoke","_setLength","TemplateCache","templateId","templateCaches","cachedTemplate","load","clear","i","compiledTemplate","template","loadTemplate","compileTemplate","html","rawTemplate","Renderer","data","templateFunc","View","bindAll","_behaviors","Behaviors","onShowCalled","getTemplate","serializeModel","toJSON","mixinTemplateHelpers","templateHelpers","uiBindings","configureTriggers","triggers","events","_buildViewTrigger","delegateEvents","_delegateDOMEvents","collection","behavior","eventsArg","isUndefined","combinedEvents","behaviorEvents","behaviorTriggers","undelegateEvents","unbindUIElements","bindUIElements","_bindUIElements","_uiBindings","_unbindUIElements","triggerDef","hasOptions","preventDefault","stopPropagation","e","setElement","ret","behaviors","_getImmediateChildren","_getNestedViews","children","ItemView","serializeData","items","serializeCollection","_renderTemplate","attachElContent","CollectionView","childViewEventPrefix","initOptions","sort","_initialEvents","_initChildViewStorage","initRenderBuffer","elBuffer","createDocumentFragment","_bufferedChildren","startBuffering","isBuffering","endBuffering","_triggerBeforeShowBufferedChildren","attachBuffer","_triggerShowBufferedChildren","partial","_triggerMethodOnChild","childView","_onCollectionAdd","_onCollectionRemove","_sortViews","child","destroyEmptyView","ChildView","getChildView","indexOf","addChild","removeChildView","checkEmpty","_renderChildren","resortView","orderChanged","find","item","_index","_emptyViewIndex","destroyChildren","isEmpty","showEmptyView","showCollection","EmptyView","getEmptyView","_showingEmptyView","addEmptyView","emptyViewOptions","buildChildView","proxyChildEvents","renderChildView","childViewOptions","_updateIndices","_addChildView","increment","laterView","ChildViewClass","collectionView","buffer","append","_insertBefore","_insertAfter","findPosition","before","childViews","map","identity","rootEvent","childEvents","splice","CompositeView","isRendered","resetChildViewContainer","compositeView","$container","getChildViewContainer","containerView","$childViewContainer","container","childViewContainer","charAt","substr","LayoutView","_firstRender","_initializeRegions","_reInitializeRegions","regionManager","_buildRegions","getRegion","_initRegionManager","regionOptions","getRegionManager","chain","pluck","compact","Behavior","proxyViewProperties","parseBehaviors","wrap","keys","BehaviorTriggersBuilder","_view","_viewUI","_triggers","delegateEventSplitter","triggerBuilder","buildBehaviorTriggers","_behaviorsEvents","viewUI","b","_events","behaviorUI","j","behaviour","join","eventKey","behaviorsLookup","getBehaviorClass","behaviorClass","BehaviorClass","nestedBehaviors","flatten","_buildTriggerHandlersForBehavior","triggersHash","_setHandlerForBehavior","triggerKey","triggerName","AppRouter","Router","appRoutes","controller","_getController","processAppRoutes","_processOnRoute","appRoute","route","_addAppRoute","routeName","routeArgs","onRoute","routePath","invert","routeNames","reverse","Application","_initCallbacks","submodules","_initChannel","addInitializer","initializer","start","_regionManager","moduleNames","moduleDefinition","ModuleClass","Module","getClass","unshift","create","optionRegions","moduleName","app","_setupInitializersAndFinalizers","startWithParent","_initializerCallbacks","addFinalizer","_finalizerCallbacks","_isInitialized","mod","stop","addDefinition","customArgs","_runModuleDefinition","moduleDefinitions","parentModule","_getModule","_addModuleDefinition","def","moduleClass","_getDefine","_getStartWithParent","_addStartWithParent","swp","startWithParentIsConfigured"],"mappings":"CAmBC,SAASA,EAAMC,GAGd,GAAsB,kBAAXC,SAAyBA,OAAOC,IACzCD,QAAQ,WAAY,cAAe,SAASE,EAAUC,GACpD,MAAQL,GAAKM,WAAaN,EAAKO,GAAKN,EAAQD,EAAMI,EAAUC,SAEzD,IAAuB,mBAAZG,SAAyB,CACzC,GAAIJ,GAAWK,QAAQ,YACnBJ,EAAII,QAAQ,aAChBC,QAAOF,QAAUP,EAAQD,EAAMI,EAAUC,OAEzCL,GAAKM,WAAaN,EAAKO,GAAKN,EAAQD,EAAMA,EAAKI,SAAUJ,E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,EAAM9gB,EAAOgF,YAAYnE,UAAU8e,gBAC5BhgB,EAAEoU,YAAY+M,IAAO,EAAOA,GAGjCnhB,EAAE8D,SAASgd,IACbK,EAAML,EAAId,gBACHhgB,EAAEoU,YAAY+M,IAAO,EAAOA,IAG9B,GAGTH,WAAY,SAASF,GACnB,OAAI9gB,EAAEyC,WAAWqe,IAAUA,EAAI5f,oBAAqBjB,GAAWuf,OAI3Dxf,EAAE8D,SAASgd,GACNA,EAAIjhB,OAGN,KAPEihB,GAUXI,oBAAqB,SAASP,EAActgB,EAAQ2f,GAClD3f,EAAO2f,gBAAkB3f,EAAO2f,iBAAmBA,EAE9C3f,EAAO2f,kBAAqB3f,EAAO+gB,8BAIxC/gB,EAAO+gB,6BAA8B,EAErCT,EAAa1B,eAAe,SAAS7b,GAC/B/C,EAAO2f,iBACT3f,EAAO8e,MAAM/b,SAOdnD","file":"lib/backbone.marionette.min.js"} \ No newline at end of file +{"version":3,"sources":["?"],"names":["root","factory","define","amd","Backbone","_","Marionette","Mn","exports","require","module","this","previousChildViewContainer","ChildViewContainer","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","each","add","extend","prototype","view","customIndex","viewCid","cid","model","findByModel","findByModelCid","modelCid","findByCid","findByCustom","index","findByIndex","values","remove","any","key","call","method","apply","tail","arguments","args","isFunction","length","size","methods","concat","toArray","VERSION","noConflict","previousWreqr","Wreqr","Handlers","options","_wreqrHandlers","initialize","Model","Events","setHandlers","handlers","handler","name","context","isObject","callback","setHandler","config","trigger","hasHandler","getHandler","Array","slice","removeHandler","removeAllHandlers","CommandStorage","_commands","getCommands","commandName","commands","command","instances","addCommand","push","clearCommands","Commands","storageType","constructor","_initializeStorage","on","_executeCommands","execute","storage","StorageType","RequestResponse","request","EventAggregator","EA","Channel","channelName","vent","reqres","reset","off","stopListening","connectEvents","hash","_connect","connectCommands","connectRequests","type","fn","eventName","bind","radio","Radio","_channels","_proxyMethods","channel","Error","_getChannel","system","messageSystems","proxyMethod","messageSystem","previousMarionette","previousMn","Deferred","$","isNodeAttached","el","contains","document","documentElement","mergeOptions","keys","pick","getOption","target","optionName","undefined","proxyGetOption","_getValue","value","params","normalizeMethods","reduce","normalizedHash","normalizeUIString","uiString","ui","replace","r","normalizeUIKeys","memo","val","normalizedKey","normalizeUIValues","properties","isString","isArray","property","propertyVal","actAsCollection","object","listProperty","list","result","deprecate","message","test","prev","next","url","_cache","_warn","console","warn","log","_triggerMethod","getEventName","match","prefix","toUpperCase","splitter","event","noEventArg","methodName","rest","drop","triggerMethod","triggerMethodOn","fnc","MonitorDOMRefresh","handleShow","_isShown","triggerDOMRefresh","handleRender","_isRendered","show","render","bindFromStrings","entity","evt","methodNames","split","listenTo","bindToFunction","unbindFromStrings","unbindToFunction","iterateEvents","bindings","functionCallback","stringCallback","bindEntityEvents","unbindEntityEvents","proxyBindEntityEvents","proxyUnbindEntityEvents","errorProps","urlRoot","error","captureStackTrace","toString","Callbacks","_deferred","_callbacks","contextOverride","promise","cb","ctx","then","run","resolve","callbacks","Controller","destroy","Object","Region","$el","getEl","_ensureElement","_ensureViewIsIntact","showOptions","isDifferentView","currentView","preventDestroy","forceShow","isChangingView","_shouldDestroyView","_shouldShowView","_parent","empty","once","attachedRegion","displayedViews","triggerBeforeAttach","triggerAttach","_displayedViews","_triggerAttach","attachHtml","union","selector","isDestroyed","parentEl","contents","detach","appendChild","_destroyView","attachView","hasView","buildRegion","regionConfig","DefaultRegionClass","_buildRegionFromSelector","regionClass","_buildRegionFromObject","_buildRegionFromRegionClass","RegionClass","omit","RegionManager","_regions","addRegions","regionDefinitions","defaults","regions","definition","addRegion","region","_store","get","getRegions","clone","removeRegion","_remove","removeRegions","emptyRegions","invoke","TemplateCache","templateId","templateCaches","cachedTemplate","load","clear","i","compiledTemplate","template","loadTemplate","compileTemplate","html","rawTemplate","Renderer","data","templateFunc","View","bindAll","_behaviors","Behaviors","getTemplate","serializeModel","toJSON","mixinTemplateHelpers","templateHelpers","uiBindings","configureTriggers","triggers","events","_buildViewTrigger","delegateEvents","_delegateDOMEvents","collection","behavior","eventsArg","isUndefined","combinedEvents","behaviorEvents","behaviorTriggers","undelegateEvents","unbindUIElements","isRendered","bindUIElements","_bindUIElements","_uiBindings","_unbindUIElements","triggerDef","hasOptions","preventDefault","stopPropagation","e","setElement","ret","_triggerEventOnBehaviors","_triggerEventOnParentLayout","behaviors","layoutView","_parentLayoutView","eventPrefix","prefixedEventName","childEvents","normalizedChildEvents","_getImmediateChildren","_getNestedViews","children","_getAncestors","ancestors","parent","find","LayoutView","ItemView","serializeData","items","serializeCollection","_renderTemplate","attachElContent","CollectionView","childViewEventPrefix","sort","_initialEvents","_initChildViewStorage","_onShowCalled","initRenderBuffer","_bufferedChildren","startBuffering","isBuffering","endBuffering","_triggerBeforeShowBufferedChildren","attachBuffer","_triggerShowBufferedChildren","partial","_triggerMethodOnChild","childView","_onCollectionAdd","_onCollectionRemove","_sortViews","child","opts","at","indexOf","_filteredSortedModels","_shouldAddChild","destroyEmptyView","ChildView","getChildView","addChild","removeChildView","checkEmpty","_renderChildren","reorder","models","modelsChanged","els","map","append","resortView","orderChanged","item","_index","_emptyViewIndex","destroyChildren","isEmpty","showEmptyView","showCollection","viewComparator","getViewComparator","sortBy","filter","EmptyView","getEmptyView","_showingEmptyView","addEmptyView","emptyViewOptions","buildChildView","proxyChildEvents","renderChildView","childViewOptions","_updateIndices","_addChildView","increment","laterView","ChildViewClass","collectionView","_createBuffer","elBuffer","createDocumentFragment","b","splice","_insertBefore","_insertAfter","findPosition","before","childViews","identity","rootEvent","CompositeView","_isRendering","resetChildViewContainer","compositeView","$container","getChildViewContainer","containerView","$childViewContainer","container","childViewContainer","charAt","substr","destroyImmediate","_firstRender","_initializeRegions","_reInitializeRegions","regionManager","showChildView","regionName","getRegion","_buildRegions","_initRegionManager","regionOptions","getRegionManager","chain","pluck","compact","Behavior","proxyViewProperties","parseBehaviors","wrap","BehaviorTriggersBuilder","_view","_triggers","getBehaviorsUI","delegateEventSplitter","triggerBuilder","buildBehaviorTriggers","_behaviorsEvents","_events","j","behaviour","join","eventKey","behaviorsLookup","getBehaviorClass","behaviorClass","BehaviorClass","nestedBehaviors","flatten","_buildTriggerHandlersForBehavior","triggersHash","_setHandlerForBehavior","triggerKey","triggerName","AppRouter","Router","appRoutes","controller","_getController","processAppRoutes","_processOnRoute","appRoute","route","_addAppRoute","routeName","routeArgs","onRoute","routePath","invert","routeNames","reverse","Application","_initCallbacks","submodules","_initChannel","addInitializer","initializer","start","_regionManager","moduleNames","moduleDefinition","ModuleClass","Module","getClass","unshift","create","optionRegions","moduleName","app","_setupInitializersAndFinalizers","startWithParent","_initializerCallbacks","addFinalizer","_finalizerCallbacks","_isInitialized","mod","stop","addDefinition","customArgs","_runModuleDefinition","moduleDefinitions","parentModule","_getModule","_addModuleDefinition","def","moduleClass","_getDefine","_getStartWithParent","_addStartWithParent","swp","startWithParentIsConfigured"],"mappings":"CAmBC,SAASA,EAAMC,GAGd,GAAsB,kBAAXC,SAAyBA,OAAOC,IACzCD,QAAQ,WAAY,cAAe,SAASE,EAAUC,GACpD,MAAQL,GAAKM,WAAaN,EAAKO,GAAKN,EAAQD,EAAMI,EAAUC,SAEzD,IAAuB,mBAAZG,SAAyB,CACzC,GAAIJ,GAAWK,QAAQ,YACnBJ,EAAII,QAAQ,aAChBC,QAAOF,QAAUP,EAAQD,EAAMI,EAAUC,OAEzCL,GAAKM,WAAaN,EAAKO,GAAKN,EAAQD,EAAMA,EAAKI,SAAUJ,EAAKK,KAGhEM,KAAM,SAASX,EAAMI,EAAUC,GAC/B,cAWA,SAAUD,EAAUC,GAElB,GAAIO,GAA6BR,EAASS,kBA8H1C,OAxHAT,GAASS,mBAAqB,SAAST,EAAUC,GAG/C,GAAIS,GAAY,SAASC,GACvBJ,KAAKK,UACLL,KAAKM,iBACLN,KAAKO,kBACLP,KAAKQ,gBACLd,EAAEe,KAAKL,EAAOJ,KAAKU,IAAKV,MAI1BN,GAAEiB,OAAOR,EAAUS,WAKjBF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B,OAAKF,GAMDA,EAAiBjgB,oBAAqBkgB,GACjCD,EAGFA,EAAiByB,aAAexB,EAT9BA,GAeXsB,qBAAsB,SAASF,EAAcniB,EAAQsiB,EAAKngB,GACxD,GAAIqE,GAAKvG,KAAKuiB,WAAWF,GACrBd,EAAkBvhB,KAAKwiB,oBAAoBH,EAAKtiB,EAEhDwG,IACFxG,EAAO+hB,cAAcvb,EAAIrE,GAG3BlC,KAAKyiB,oBAAoBP,EAAcniB,EAAQwhB,IAGjDiB,oBAAqB,SAASH,EAAKtiB,GACjC,GAAI2iB,EAEJ,OAAIhjB,GAAEyC,WAAWkgB,IAASA,EAAIzhB,oBAAqBjB,GAAWohB,QAC5D2B,EAAM3iB,EAAOgF,YAAYnE,UAAU2gB,gBAC5B7hB,EAAE0U,YAAYsO,IAAO,EAAOA,GAGjChjB,EAAE8D,SAAS6e,IACbK,EAAML,EAAId,gBACH7hB,EAAE0U,YAAYsO,IAAO,EAAOA,IAG9B,GAGTH,WAAY,SAASF,GACnB,OAAI3iB,EAAEyC,WAAWkgB,IAAUA,EAAIzhB,oBAAqBjB,GAAWohB,OAI3DrhB,EAAE8D,SAAS6e,GACNA,EAAI9iB,OAGN,KAPE8iB,GAUXI,oBAAqB,SAASP,EAAcniB,EAAQwhB,GAClDxhB,EAAOwhB,gBAAkBxhB,EAAOwhB,iBAAmBA,EAE9CxhB,EAAOwhB,kBAAqBxhB,EAAO4iB,8BAIxC5iB,EAAO4iB,6BAA8B,EAErCT,EAAa1B,eAAe,SAAS1d,GAC/B/C,EAAOwhB,iBACTxhB,EAAO2gB,MAAM5d,SAOdnD","file":"lib/backbone.marionette.min.js"} \ No newline at end of file diff --git a/lib/backbone.marionette.min.js b/lib/backbone.marionette.min.js index db8679089b..f4237d5467 100644 --- a/lib/backbone.marionette.min.js +++ b/lib/backbone.marionette.min.js @@ -1,6 +1,6 @@ // MarionetteJS (Backbone.Marionette) // ---------------------------------- -// v2.3.2 +// v2.4.0 // // Copyright (c)2015 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license @@ -17,6 +17,6 @@ */ -(function(e,t){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(i,n){return e.Marionette=e.Mn=t(e,i,n)});else if("undefined"!=typeof exports){var i=require("backbone"),n=require("underscore");module.exports=t(e,i,n)}else e.Marionette=e.Mn=t(e,e.Backbone,e._)})(this,function(e,t,i){"use strict";(function(e,t){var i=e.ChildViewContainer;return e.ChildViewContainer=function(e,t){var i=function(e){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),t.each(e,this.add,this)};t.extend(i.prototype,{add:function(e,t){var i=e.cid;return this._views[i]=e,e.model&&(this._indexByModel[e.model.cid]=i),t&&(this._indexByCustom[t]=i),this._updateLength(),this},findByModel:function(e){return this.findByModelCid(e.cid)},findByModelCid:function(e){var t=this._indexByModel[e];return this.findByCid(t)},findByCustom:function(e){var t=this._indexByCustom[e];return this.findByCid(t)},findByIndex:function(e){return t.values(this._views)[e]},findByCid:function(e){return this._views[e]},remove:function(e){var i=e.cid;return e.model&&delete this._indexByModel[e.model.cid],t.any(this._indexByCustom,function(e,t){return e===i?(delete this._indexByCustom[t],!0):void 0},this),delete this._views[i],this._updateLength(),this},call:function(e){this.apply(e,t.tail(arguments))},apply:function(e,i){t.each(this._views,function(n){t.isFunction(n[e])&&n[e].apply(n,i||[])})},_updateLength:function(){this.length=t.size(this._views)}});var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];return t.each(n,function(e){i.prototype[e]=function(){var i=t.values(this._views),n=[i].concat(t.toArray(arguments));return t[e].apply(t,n)}}),i}(e,t),e.ChildViewContainer.VERSION="0.1.5",e.ChildViewContainer.noConflict=function(){return e.ChildViewContainer=i,this},e.ChildViewContainer})(t,i),function(e,t){var i=e.Wreqr,n=e.Wreqr={};return e.Wreqr.VERSION="1.3.1",e.Wreqr.noConflict=function(){return e.Wreqr=i,this},n.Handlers=function(e,t){var i=function(e){this.options=e,this._wreqrHandlers={},t.isFunction(this.initialize)&&this.initialize(e)};return i.extend=e.Model.extend,t.extend(i.prototype,e.Events,{setHandlers:function(e){t.each(e,function(e,i){var n=null;t.isObject(e)&&!t.isFunction(e)&&(n=e.context,e=e.callback),this.setHandler(i,e,n)},this)},setHandler:function(e,t,i){var n={callback:t,context:i};this._wreqrHandlers[e]=n,this.trigger("handler:add",e,t,i)},hasHandler:function(e){return!!this._wreqrHandlers[e]},getHandler:function(e){var t=this._wreqrHandlers[e];if(t)return function(){var e=Array.prototype.slice.apply(arguments);return t.callback.apply(t.context,e)}},removeHandler:function(e){delete this._wreqrHandlers[e]},removeAllHandlers:function(){this._wreqrHandlers={}}}),i}(e,t),n.CommandStorage=function(){var i=function(e){this.options=e,this._commands={},t.isFunction(this.initialize)&&this.initialize(e)};return t.extend(i.prototype,e.Events,{getCommands:function(e){var t=this._commands[e];return t||(t={command:e,instances:[]},this._commands[e]=t),t},addCommand:function(e,t){var i=this.getCommands(e);i.instances.push(t)},clearCommands:function(e){var t=this.getCommands(e);t.instances=[]}}),i}(),n.Commands=function(e){return e.Handlers.extend({storageType:e.CommandStorage,constructor:function(t){this.options=t||{},this._initializeStorage(this.options),this.on("handler:add",this._executeCommands,this);var i=Array.prototype.slice.call(arguments);e.Handlers.prototype.constructor.apply(this,i)},execute:function(e,t){e=arguments[0],t=Array.prototype.slice.call(arguments,1),this.hasHandler(e)?this.getHandler(e).apply(this,t):this.storage.addCommand(e,t)},_executeCommands:function(e,i,n){var r=this.storage.getCommands(e);t.each(r.instances,function(e){i.apply(n,e)}),this.storage.clearCommands(e)},_initializeStorage:function(e){var i,n=e.storageType||this.storageType;i=t.isFunction(n)?new n:n,this.storage=i}})}(n),n.RequestResponse=function(e){return e.Handlers.extend({request:function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1);return this.hasHandler(e)?this.getHandler(e).apply(this,t):void 0}})}(n),n.EventAggregator=function(e,t){var i=function(){};return i.extend=e.Model.extend,t.extend(i.prototype,e.Events),i}(e,t),n.Channel=function(){var i=function(t){this.vent=new e.Wreqr.EventAggregator,this.reqres=new e.Wreqr.RequestResponse,this.commands=new e.Wreqr.Commands,this.channelName=t};return t.extend(i.prototype,{reset:function(){return this.vent.off(),this.vent.stopListening(),this.reqres.removeAllHandlers(),this.commands.removeAllHandlers(),this},connectEvents:function(e,t){return this._connect("vent",e,t),this},connectCommands:function(e,t){return this._connect("commands",e,t),this},connectRequests:function(e,t){return this._connect("reqres",e,t),this},_connect:function(e,i,n){if(i){n=n||this;var r="vent"===e?"on":"setHandler";t.each(i,function(i,s){this[e][r](s,t.bind(i,n))},this)}}}),i}(n),n.radio=function(e){var i=function(){this._channels={},this.vent={},this.commands={},this.reqres={},this._proxyMethods()};t.extend(i.prototype,{channel:function(e){if(!e)throw Error("Channel must receive a name");return this._getChannel(e)},_getChannel:function(t){var i=this._channels[t];return i||(i=new e.Channel(t),this._channels[t]=i),i},_proxyMethods:function(){t.each(["vent","commands","reqres"],function(e){t.each(n[e],function(t){this[e][t]=r(this,e,t)},this)},this)}});var n={vent:["on","off","trigger","once","stopListening","listenTo","listenToOnce"],commands:["execute","setHandler","setHandlers","removeHandler","removeAllHandlers"],reqres:["request","setHandler","setHandlers","removeHandler","removeAllHandlers"]},r=function(e,t,i){return function(n){var r=e._getChannel(n)[t],s=Array.prototype.slice.call(arguments,1);return r[i].apply(r,s)}};return new i}(n),e.Wreqr}(t,i);var n=e.Marionette,r=t.Marionette={};r.VERSION="2.3.2",r.noConflict=function(){return e.Marionette=n,this},t.Marionette=r,r.Deferred=t.$.Deferred,r.extend=t.Model.extend,r.isNodeAttached=function(e){return t.$.contains(document.documentElement,e)},r.getOption=function(e,t){return e&&t?e.options&&void 0!==e.options[t]?e.options[t]:e[t]:void 0},r.proxyGetOption=function(e){return r.getOption(this,e)},r._getValue=function(e,t,n){return i.isFunction(e)&&(n=n||[],e=e.apply(t,n)),e},r.normalizeMethods=function(e){return i.reduce(e,function(e,t,n){return i.isFunction(t)||(t=this[t]),t&&(e[n]=t),e},{},this)},r.normalizeUIString=function(e,t){return e.replace(/@ui\.[a-zA-Z_$0-9]*/g,function(e){return t[e.slice(4)]})},r.normalizeUIKeys=function(e,t){return i.reduce(e,function(e,i,n){var s=r.normalizeUIString(n,t);return e[s]=i,e},{})},r.normalizeUIValues=function(e,t){return i.each(e,function(n,s){i.isString(n)&&(e[s]=r.normalizeUIString(n,t))}),e},r.actAsCollection=function(e,t){var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];i.each(n,function(n){e[n]=function(){var e=i.values(i.result(this,t)),r=[e].concat(i.toArray(arguments));return i[n].apply(i,r)}})};var s=r.deprecate=function(e,t){i.isObject(e)&&(e=e.prev+" is going to be removed in the future. "+"Please use "+e.next+" instead."+(e.url?" See: "+e.url:"")),void 0!==t&&t||s._cache[e]||(s._warn("Deprecation warning: "+e),s._cache[e]=!0)};s._warn="undefined"!=typeof console&&(console.warn||console.log)||function(){},s._cache={},r._triggerMethod=function(){function e(e,t,i){return i.toUpperCase()}var t=/(^|:)(\w)/gi;return function(n,r,s){var o=3>arguments.length;o&&(s=r,r=s[0]);var h,a="on"+r.replace(t,e),l=n[a];return i.isFunction(l)&&(h=l.apply(n,o?i.rest(s):s)),i.isFunction(n.trigger)&&(o+s.length>1?n.trigger.apply(n,o?s:[r].concat(i.rest(s,0))):n.trigger(r)),h}}(),r.triggerMethod=function(){return r._triggerMethod(this,arguments)},r.triggerMethodOn=function(e){var t=i.isFunction(e.triggerMethod)?e.triggerMethod:r.triggerMethod;return t.apply(e,i.rest(arguments))},r.MonitorDOMRefresh=function(e){function t(){e._isShown=!0,s()}function n(){e._isRendered=!0,s()}function s(){e._isShown&&e._isRendered&&r.isNodeAttached(e.el)&&i.isFunction(e.triggerMethod)&&e.triggerMethod("dom:refresh")}e.on({show:t,render:n})},function(e){function t(t,n,r,s){var o=s.split(/\s+/);i.each(o,function(i){var s=t[i];if(!s)throw new e.Error('Method "'+i+'" was configured as an event handler, but does not exist.');t.listenTo(n,r,s)})}function n(e,t,i,n){e.listenTo(t,i,n)}function r(e,t,n,r){var s=r.split(/\s+/);i.each(s,function(i){var r=e[i];e.stopListening(t,n,r)})}function s(e,t,i,n){e.stopListening(t,i,n)}function o(t,n,r,s,o){if(n&&r){if(!i.isObject(r))throw new e.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});r=e._getValue(r,t),i.each(r,function(e,r){i.isFunction(e)?s(t,n,r,e):o(t,n,r,e)})}}e.bindEntityEvents=function(e,i,r){o(e,i,r,n,t)},e.unbindEntityEvents=function(e,t,i){o(e,t,i,s,r)},e.proxyBindEntityEvents=function(t,i){return e.bindEntityEvents(this,t,i)},e.proxyUnbindEntityEvents=function(t,i){return e.unbindEntityEvents(this,t,i)}}(r);var o=["description","fileName","lineNumber","name","message","number"];return r.Error=r.extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+r.VERSION+"/",constructor:function(e,t){i.isObject(e)?(t=e,e=t.message):t||(t={});var n=Error.call(this,e);i.extend(this,i.pick(n,o),i.pick(t,o)),this.captureStackTrace(),t.url&&(this.url=this.urlRoot+t.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,r.Error)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}}),r.Error.extend=r.extend,r.Callbacks=function(){this._deferred=r.Deferred(),this._callbacks=[]},i.extend(r.Callbacks.prototype,{add:function(e,t){var n=i.result(this._deferred,"promise");this._callbacks.push({cb:e,ctx:t}),n.then(function(i){t&&(i.context=t),e.call(i.context,i.options)})},run:function(e,t){this._deferred.resolve({options:e,context:t})},reset:function(){var e=this._callbacks;this._deferred=r.Deferred(),this._callbacks=[],i.each(e,function(e){this.add(e.cb,e.ctx)},this)}}),r.Controller=function(e){this.options=e||{},i.isFunction(this.initialize)&&this.initialize(this.options)},r.Controller.extend=r.extend,i.extend(r.Controller.prototype,t.Events,{destroy:function(){return r._triggerMethod(this,"before:destroy",arguments),r._triggerMethod(this,"destroy",arguments),this.stopListening(),this.off(),this},triggerMethod:r.triggerMethod,getOption:r.proxyGetOption}),r.Object=function(e){this.options=i.extend({},i.result(this,"options"),e),this.initialize.apply(this,arguments)},r.Object.extend=r.extend,i.extend(r.Object.prototype,t.Events,{initialize:function(){},destroy:function(){this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening()},triggerMethod:r.triggerMethod,getOption:r.proxyGetOption,bindEntityEvents:r.proxyBindEntityEvents,unbindEntityEvents:r.proxyUnbindEntityEvents}),r.Region=r.Object.extend({constructor:function(e){if(this.options=e||{},this.el=this.getOption("el"),this.el=this.el instanceof t.$?this.el[0]:this.el,!this.el)throw new r.Error({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),r.Object.call(this,e)},show:function(e,t){if(this._ensureElement()){this._ensureViewIsIntact(e);var i=t||{},n=e!==this.currentView,s=!!i.preventDestroy,o=!!i.forceShow,h=!!this.currentView,a=n&&!s,l=n||o;if(h&&this.triggerMethod("before:swapOut",this.currentView,this,t),this.currentView&&delete this.currentView._parent,a?this.empty():h&&l&&this.currentView.off("destroy",this.empty,this),l){e.once("destroy",this.empty,this),e.render(),e._parent=this,h&&this.triggerMethod("before:swap",e,this,t),this.triggerMethod("before:show",e,this,t),r.triggerMethodOn(e,"before:show",e,this,t),h&&this.triggerMethod("swapOut",this.currentView,this,t);var u=r.isNodeAttached(this.el),d=[],c=i.triggerBeforeAttach||this.triggerBeforeAttach,g=i.triggerAttach||this.triggerAttach;return u&&c&&(d=this._displayedViews(e),this._triggerAttach(d,"before:")),this.attachHtml(e),this.currentView=e,u&&g&&(d=this._displayedViews(e),this._triggerAttach(d)),h&&this.triggerMethod("swap",e,this,t),this.triggerMethod("show",e,this,t),r.triggerMethodOn(e,"show",e,this,t),this}return this}},triggerBeforeAttach:!0,triggerAttach:!0,_triggerAttach:function(e,t){var n=(t||"")+"attach";i.each(e,function(e){r.triggerMethodOn(e,n,e,this)},this)},_displayedViews:function(e){return i.union([e],i.result(e,"_getNestedViews")||[])},_ensureElement:function(){if(i.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||0===this.$el.length){if(this.getOption("allowMissingEl"))return!1;throw new r.Error('An "el" '+this.$el.selector+" must exist in DOM")}return!0},_ensureViewIsIntact:function(e){if(!e)throw new r.Error({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(e.isDestroyed)throw new r.Error({name:"ViewDestroyedError",message:'View (cid: "'+e.cid+'") has already been destroyed and cannot be used.'})},getEl:function(e){return t.$(e,r._getValue(this.options.parentEl,this))},attachHtml:function(e){this.$el.contents().detach(),this.el.appendChild(e.el)},empty:function(){var e=this.currentView;if(e)return e.off("destroy",this.empty,this),this.triggerMethod("before:empty",e),this._destroyView(),this.triggerMethod("empty",e),delete this.currentView,this},_destroyView:function(){var e=this.currentView;e.destroy&&!e.isDestroyed?e.destroy():e.remove&&(e.remove(),e.isDestroyed=!0)},attachView:function(e){return this.currentView=e,this},hasView:function(){return!!this.currentView},reset:function(){return this.empty(),this.$el&&(this.el=this.$el.selector),delete this.$el,this}},{buildRegion:function(e,t){if(i.isString(e))return this._buildRegionFromSelector(e,t);if(e.selector||e.el||e.regionClass)return this._buildRegionFromObject(e,t);if(i.isFunction(e))return this._buildRegionFromRegionClass(e);throw new r.Error({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})},_buildRegionFromSelector:function(e,t){return new t({el:e})},_buildRegionFromObject:function(e,t){var n=e.regionClass||t,r=i.omit(e,"selector","regionClass");return e.selector&&!r.el&&(r.el=e.selector),new n(r)},_buildRegionFromRegionClass:function(e){return new e}}),r.RegionManager=r.Controller.extend({constructor:function(e){this._regions={},r.Controller.call(this,e),this.addRegions(this.getOption("regions"))},addRegions:function(e,t){return e=r._getValue(e,this,arguments),i.reduce(e,function(e,n,r){return i.isString(n)&&(n={selector:n}),n.selector&&(n=i.defaults({},n,t)),e[r]=this.addRegion(r,n),e},{},this)},addRegion:function(e,t){var i;return i=t instanceof r.Region?t:r.Region.buildRegion(t,r.Region),this.triggerMethod("before:add:region",e,i),i._parent=this,this._store(e,i),this.triggerMethod("add:region",e,i),i},get:function(e){return this._regions[e]},getRegions:function(){return i.clone(this._regions)},removeRegion:function(e){var t=this._regions[e];return this._remove(e,t),t},removeRegions:function(){var e=this.getRegions();return i.each(this._regions,function(e,t){this._remove(t,e)},this),e},emptyRegions:function(){var e=this.getRegions();return i.invoke(e,"empty"),e},destroy:function(){return this.removeRegions(),r.Controller.prototype.destroy.apply(this,arguments)},_store:function(e,t){this._regions[e]=t,this._setLength()},_remove:function(e,t){this.triggerMethod("before:remove:region",e,t),t.empty(),t.stopListening(),delete t._parent,delete this._regions[e],this._setLength(),this.triggerMethod("remove:region",e,t)},_setLength:function(){this.length=i.size(this._regions)}}),r.actAsCollection(r.RegionManager.prototype,"_regions"),r.TemplateCache=function(e){this.templateId=e},i.extend(r.TemplateCache,{templateCaches:{},get:function(e){var t=this.templateCaches[e];return t||(t=new r.TemplateCache(e),this.templateCaches[e]=t),t.load()},clear:function(){var e,t=i.toArray(arguments),n=t.length;if(n>0)for(e=0;n>e;e++)delete this.templateCaches[t[e]];else this.templateCaches={}}}),i.extend(r.TemplateCache.prototype,{load:function(){if(this.compiledTemplate)return this.compiledTemplate;var e=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(e),this.compiledTemplate},loadTemplate:function(e){var i=t.$(e).html();if(!i||0===i.length)throw new r.Error({name:"NoTemplateError",message:'Could not find template: "'+e+'"'});return i},compileTemplate:function(e){return i.template(e)}}),r.Renderer={render:function(e,t){if(!e)throw new r.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var n=i.isFunction(e)?e:r.TemplateCache.get(e);return n(t)}},r.View=t.View.extend({isDestroyed:!1,constructor:function(e){i.bindAll(this,"render"),e=r._getValue(e,this),this.options=i.extend({},i.result(this,"options"),e),this._behaviors=r.Behaviors(this),t.View.apply(this,arguments),r.MonitorDOMRefresh(this),this.on("show",this.onShowCalled)},getTemplate:function(){return this.getOption("template")},serializeModel:function(e){return e.toJSON.apply(e,i.rest(arguments))},mixinTemplateHelpers:function(e){e=e||{};var t=this.getOption("templateHelpers");return t=r._getValue(t,this),i.extend(e,t)},normalizeUIKeys:function(e){var t=i.result(this,"_uiBindings");return r.normalizeUIKeys(e,t||i.result(this,"ui"))},normalizeUIValues:function(e){var t=i.result(this,"ui"),n=i.result(this,"_uiBindings");return r.normalizeUIValues(e,n||t)},configureTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(i.result(this,"triggers"));return i.reduce(e,function(e,t,i){return e[i]=this._buildViewTrigger(t),e},{},this)}},delegateEvents:function(e){return this._delegateDOMEvents(e),this.bindEntityEvents(this.model,this.getOption("modelEvents")),this.bindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(e){e.bindEntityEvents(this.model,e.getOption("modelEvents")),e.bindEntityEvents(this.collection,e.getOption("collectionEvents"))},this),this},_delegateDOMEvents:function(e){var n=r._getValue(e||this.events,this);n=this.normalizeUIKeys(n),i.isUndefined(e)&&(this.events=n);var s={},o=i.result(this,"behaviorEvents")||{},h=this.configureTriggers(),a=i.result(this,"behaviorTriggers")||{};i.extend(s,o,n,h,a),t.View.prototype.delegateEvents.call(this,s)},undelegateEvents:function(){return t.View.prototype.undelegateEvents.apply(this,arguments),this.unbindEntityEvents(this.model,this.getOption("modelEvents")),this.unbindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(e){e.unbindEntityEvents(this.model,e.getOption("modelEvents")),e.unbindEntityEvents(this.collection,e.getOption("collectionEvents"))},this),this},onShowCalled:function(){},_ensureViewIsIntact:function(){if(this.isDestroyed)throw new r.Error({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(!this.isDestroyed){var e=i.toArray(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(e)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(e)),this.unbindUIElements(),this.remove(),i.invoke(this._behaviors,"destroy",e),this}},bindUIElements:function(){this._bindUIElements(),i.invoke(this._behaviors,this._bindUIElements)},_bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var e=i.result(this,"_uiBindings");this.ui={},i.each(e,function(e,t){this.ui[t]=this.$(e)},this)}},unbindUIElements:function(){this._unbindUIElements(),i.invoke(this._behaviors,this._unbindUIElements)},_unbindUIElements:function(){this.ui&&this._uiBindings&&(i.each(this.ui,function(e,t){delete this.ui[t]},this),this.ui=this._uiBindings,delete this._uiBindings)},_buildViewTrigger:function(e){var t=i.isObject(e),n=i.defaults({},t?e:{},{preventDefault:!0,stopPropagation:!0}),r=t?n.event:e;return function(e){e&&(e.preventDefault&&n.preventDefault&&e.preventDefault(),e.stopPropagation&&n.stopPropagation&&e.stopPropagation());var t={view:this,model:this.model,collection:this.collection};this.triggerMethod(r,t)}},setElement:function(){var e=t.View.prototype.setElement.apply(this,arguments);return i.invoke(this._behaviors,"proxyViewProperties",this),e},triggerMethod:function(){for(var e=r._triggerMethod,t=e(this,arguments),i=this._behaviors,n=0,s=i&&i.length;s>n;n++)e(i[n],arguments);return t},_getImmediateChildren:function(){return[]},_getNestedViews:function(){var e=this._getImmediateChildren();return e.length?i.reduce(e,function(e,t){return t._getNestedViews?e.concat(t._getNestedViews()):e},e):e},normalizeMethods:r.normalizeMethods,getOption:r.proxyGetOption,bindEntityEvents:r.proxyBindEntityEvents,unbindEntityEvents:r.proxyUnbindEntityEvents}),r.ItemView=r.View.extend({constructor:function(){r.View.apply(this,arguments)},serializeData:function(){if(!this.model&&!this.collection)return{};var e=[this.model||this.collection];return arguments.length&&e.push.apply(e,arguments),this.model?this.serializeModel.apply(this,e):{items:this.serializeCollection.apply(this,e)}},serializeCollection:function(e){return e.toJSON.apply(e,i.rest(arguments))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderTemplate(),this.bindUIElements(),this.triggerMethod("render",this),this},_renderTemplate:function(){var e=this.getTemplate();if(e!==!1){if(!e)throw new r.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var t=this.serializeData();t=this.mixinTemplateHelpers(t);var i=r.Renderer.render(e,t,this);return this.attachElContent(i),this}},attachElContent:function(e){return this.$el.html(e),this}}),r.CollectionView=r.View.extend({childViewEventPrefix:"childview",constructor:function(e){var t=e||{};i.isUndefined(this.sort)&&(this.sort=i.isUndefined(t.sort)?!0:t.sort),this.once("render",this._initialEvents),this._initChildViewStorage(),r.View.apply(this,arguments),this.initRenderBuffer()},initRenderBuffer:function(){this.elBuffer=document.createDocumentFragment(),this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){this.isBuffering=!1,this._triggerBeforeShowBufferedChildren(),this.attachBuffer(this,this.elBuffer),this._triggerShowBufferedChildren(),this.initRenderBuffer()},_triggerBeforeShowBufferedChildren:function(){this._isShown&&i.each(this._bufferedChildren,i.partial(this._triggerMethodOnChild,"before:show"))},_triggerShowBufferedChildren:function(){this._isShown&&(i.each(this._bufferedChildren,i.partial(this._triggerMethodOnChild,"show")),this._bufferedChildren=[])},_triggerMethodOnChild:function(e,t){r.triggerMethodOn(t,e)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this.render),this.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(e){this.destroyEmptyView();var t=this.getChildView(e),i=this.collection.indexOf(e);this.addChild(e,t,i)},_onCollectionRemove:function(e){var t=this.children.findByModel(e);this.removeChildView(t),this.checkEmpty()},onShowCalled:function(){this.children.each(i.partial(this._triggerMethodOnChild,"show"))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderChildren(),this.triggerMethod("render",this),this},resortView:function(){this.render()},_sortViews:function(){var e=this.collection.find(function(e,t){var i=this.children.findByModel(e);return!i||i._index!==t},this);e&&this.resortView()},_emptyViewIndex:-1,_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren(),this.isEmpty(this.collection)?this.showEmptyView():(this.triggerMethod("before:render:collection",this),this.startBuffering(),this.showCollection(),this.endBuffering(),this.triggerMethod("render:collection",this))},showCollection:function(){var e;this.collection.each(function(t,i){e=this.getChildView(t),this.addChild(t,e,i)},this)},showEmptyView:function(){var e=this.getEmptyView();if(e&&!this._showingEmptyView){this.triggerMethod("before:render:empty"),this._showingEmptyView=!0;var i=new t.Model;this.addEmptyView(i,e),this.triggerMethod("render:empty")}},destroyEmptyView:function(){this._showingEmptyView&&(this.triggerMethod("before:remove:empty"),this.destroyChildren(),delete this._showingEmptyView,this.triggerMethod("remove:empty"))},getEmptyView:function(){return this.getOption("emptyView")},addEmptyView:function(e,t){var n=this.getOption("emptyViewOptions")||this.getOption("childViewOptions");i.isFunction(n)&&(n=n.call(this,e,this._emptyViewIndex));var s=this.buildChildView(e,t,n);s._parent=this,this.proxyChildEvents(s),this._isShown&&r.triggerMethodOn(s,"before:show"),this.children.add(s),this.renderChildView(s,this._emptyViewIndex),this._isShown&&r.triggerMethodOn(s,"show")},getChildView:function(){var e=this.getOption("childView");if(!e)throw new r.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return e},addChild:function(e,t,i){var n=this.getOption("childViewOptions");n=r._getValue(n,this,[e,i]);var s=this.buildChildView(e,t,n);return this._updateIndices(s,!0,i),this._addChildView(s,i),s._parent=this,s},_updateIndices:function(e,t,i){this.sort&&(t&&(e._index=i),this.children.each(function(i){i._index>=e._index&&(i._index+=t?1:-1)}))},_addChildView:function(e,t){this.proxyChildEvents(e),this.triggerMethod("before:add:child",e),this.children.add(e),this.renderChildView(e,t),this._isShown&&!this.isBuffering&&r.triggerMethodOn(e,"show"),this.triggerMethod("add:child",e)},renderChildView:function(e,t){return e.render(),this.attachHtml(this,e,t),e},buildChildView:function(e,t,n){var r=i.extend({model:e},n);return new t(r)},removeChildView:function(e){return e&&(this.triggerMethod("before:remove:child",e),e.destroy?e.destroy():e.remove&&e.remove(),delete e._parent,this.stopListening(e),this.children.remove(e),this.triggerMethod("remove:child",e),this._updateIndices(e,!1)),e},isEmpty:function(){return!this.collection||0===this.collection.length},checkEmpty:function(){this.isEmpty(this.collection)&&this.showEmptyView()},attachBuffer:function(e,t){e.$el.append(t)},attachHtml:function(e,t,i){e.isBuffering?(e.elBuffer.appendChild(t.el),e._bufferedChildren.push(t)):e._insertBefore(t,i)||e._insertAfter(t)},_insertBefore:function(e,t){var i,n=this.sort&&this.children.length-1>t;return n&&(i=this.children.find(function(e){return e._index===t+1})),i?(i.$el.before(e.el),!0):!1},_insertAfter:function(e){this.$el.append(e.el)},_initChildViewStorage:function(){this.children=new t.ChildViewContainer},destroy:function(){return this.isDestroyed?void 0:(this.triggerMethod("before:destroy:collection"),this.destroyChildren(),this.triggerMethod("destroy:collection"),r.View.prototype.destroy.apply(this,arguments))},destroyChildren:function(){var e=this.children.map(i.identity);return this.children.each(this.removeChildView,this),this.checkEmpty(),e},proxyChildEvents:function(e){var t=this.getOption("childViewEventPrefix");this.listenTo(e,"all",function(){var n=i.toArray(arguments),r=n[0],s=this.normalizeMethods(i.result(this,"childEvents"));n[0]=t+":"+r,n.splice(1,0,e),s!==void 0&&i.isFunction(s[r])&&s[r].apply(this,n.slice(1)),this.triggerMethod.apply(this,n)},this)},_getImmediateChildren:function(){return i.values(this.children._views)}}),r.CompositeView=r.CollectionView.extend({constructor:function(){r.CollectionView.apply(this,arguments)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this._renderChildren),this.sort&&this.listenTo(this.collection,"sort",this._sortViews))},getChildView:function(){var e=this.getOption("childView")||this.constructor;return e},serializeData:function(){var e={};return this.model&&(e=i.partial(this.serializeModel,this.model).apply(this,arguments)),e},render:function(){return this._ensureViewIsIntact(),this.isRendered=!0,this.resetChildViewContainer(),this.triggerMethod("before:render",this),this._renderTemplate(),this._renderChildren(),this.triggerMethod("render",this),this},_renderChildren:function(){this.isRendered&&r.CollectionView.prototype._renderChildren.call(this)},_renderTemplate:function(){var e={};e=this.serializeData(),e=this.mixinTemplateHelpers(e),this.triggerMethod("before:render:template");var t=this.getTemplate(),i=r.Renderer.render(t,e,this);this.attachElContent(i),this.bindUIElements(),this.triggerMethod("render:template")},attachElContent:function(e){return this.$el.html(e),this},attachBuffer:function(e,t){var i=this.getChildViewContainer(e);i.append(t)},_insertAfter:function(e){var t=this.getChildViewContainer(this,e);t.append(e.el)},getChildViewContainer:function(e){if("$childViewContainer"in e)return e.$childViewContainer;var t,i=r.getOption(e,"childViewContainer");if(i){var n=r._getValue(i,e);if(t="@"===n.charAt(0)&&e.ui?e.ui[n.substr(4)]:e.$(n),0>=t.length)throw new r.Error({name:"ChildViewContainerMissingError",message:'The specified "childViewContainer" was not found: '+e.childViewContainer})}else t=e.$el;return e.$childViewContainer=t,t},resetChildViewContainer:function(){this.$childViewContainer&&delete this.$childViewContainer}}),r.LayoutView=r.ItemView.extend({regionClass:r.Region,constructor:function(e){e=e||{},this._firstRender=!0,this._initializeRegions(e),r.ItemView.call(this,e)},render:function(){return this._ensureViewIsIntact(),this._firstRender?this._firstRender=!1:this._reInitializeRegions(),r.ItemView.prototype.render.apply(this,arguments)},destroy:function(){return this.isDestroyed?this:(this.regionManager.destroy(),r.ItemView.prototype.destroy.apply(this,arguments))},addRegion:function(e,t){var i={};return i[e]=t,this._buildRegions(i)[e]},addRegions:function(e){return this.regions=i.extend({},this.regions,e),this._buildRegions(e)},removeRegion:function(e){return delete this.regions[e],this.regionManager.removeRegion(e)},getRegion:function(e){return this.regionManager.get(e)},getRegions:function(){return this.regionManager.getRegions()},_buildRegions:function(e){var t={regionClass:this.getOption("regionClass"),parentEl:i.partial(i.result,this,"el")};return this.regionManager.addRegions(e,t)},_initializeRegions:function(e){var t;this._initRegionManager(),t=r._getValue(this.regions,this,[e])||{};var n=this.getOption.call(e,"regions");n=r._getValue(n,this,[e]),i.extend(t,n),t=this.normalizeUIValues(t),this.addRegions(t)},_reInitializeRegions:function(){this.regionManager.invoke("reset")},getRegionManager:function(){return new r.RegionManager},_initRegionManager:function(){this.regionManager=this.getRegionManager(),this.regionManager._parent=this,this.listenTo(this.regionManager,"before:add:region",function(e){this.triggerMethod("before:add:region",e)}),this.listenTo(this.regionManager,"add:region",function(e,t){this[e]=t,this.triggerMethod("add:region",e,t)}),this.listenTo(this.regionManager,"before:remove:region",function(e){this.triggerMethod("before:remove:region",e)}),this.listenTo(this.regionManager,"remove:region",function(e,t){delete this[e],this.triggerMethod("remove:region",e,t)})},_getImmediateChildren:function(){return i.chain(this.regionManager.getRegions()).pluck("currentView").compact().value()}}),r.Behavior=r.Object.extend({constructor:function(e,t){this.view=t,this.defaults=i.result(this,"defaults")||{},this.options=i.extend({},this.defaults,e),r.Object.apply(this,arguments) -},$:function(){return this.view.$.apply(this.view,arguments)},destroy:function(){this.stopListening()},proxyViewProperties:function(e){this.$el=e.$el,this.el=e.el}}),r.Behaviors=function(e,t){function i(e,n){return t.isObject(e.behaviors)?(n=i.parseBehaviors(e,n||t.result(e,"behaviors")),i.wrap(e,n,t.keys(s)),n):{}}function n(e,i){this._view=e,this._viewUI=t.result(e,"ui"),this._behaviors=i,this._triggers={}}var r=/^(\S+)\s*(.*)$/,s={behaviorTriggers:function(e,t){var i=new n(this,t);return i.buildBehaviorTriggers()},behaviorEvents:function(i,n){var s={},o=this._uiBindings||t.result(this,"ui");return t.each(n,function(i,n){var h={},a=t.clone(t.result(i,"events"))||{},l=i._uiBindings||t.result(i,"ui"),u=t.extend({},o,l);a=e.normalizeUIKeys(a,u);var d=0;t.each(a,function(e,s){var o=s.match(r),a=o[1]+"."+[this.cid,n,d++," "].join(""),l=o[2],u=a+l,c=t.isFunction(e)?e:i[e];h[u]=t.bind(c,i)},this),s=t.extend(s,h)},this),s}};return t.extend(i,{behaviorsLookup:function(){throw new e.Error({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.html#behaviorslookup"})},getBehaviorClass:function(t,n){return t.behaviorClass?t.behaviorClass:e._getValue(i.behaviorsLookup,this,[t,n])[n]},parseBehaviors:function(e,n){return t.chain(n).map(function(n,r){var s=i.getBehaviorClass(n,r),o=new s(n,e),h=i.parseBehaviors(e,t.result(o,"behaviors"));return[o].concat(h)}).flatten().value()},wrap:function(e,i,n){t.each(n,function(n){e[n]=t.partial(s[n],e[n],i)})}}),t.extend(n.prototype,{buildBehaviorTriggers:function(){return t.each(this._behaviors,this._buildTriggerHandlersForBehavior,this),this._triggers},_buildTriggerHandlersForBehavior:function(i,n){var r=t.extend({},this._viewUI,t.result(i,"ui")),s=t.clone(t.result(i,"triggers"))||{};s=e.normalizeUIKeys(s,r),t.each(s,t.bind(this._setHandlerForBehavior,this,i,n))},_setHandlerForBehavior:function(e,t,i,n){var r=n.replace(/^\S+/,function(e){return e+"."+"behaviortriggers"+t});this._triggers[r]=this._view._buildViewTrigger(i)}}),i}(r,i),r.AppRouter=t.Router.extend({constructor:function(e){this.options=e||{},t.Router.apply(this,arguments);var i=this.getOption("appRoutes"),n=this._getController();this.processAppRoutes(n,i),this.on("route",this._processOnRoute,this)},appRoute:function(e,t){var i=this._getController();this._addAppRoute(i,e,t)},_processOnRoute:function(e,t){if(i.isFunction(this.onRoute)){var n=i.invert(this.getOption("appRoutes"))[e];this.onRoute(e,n,t)}},processAppRoutes:function(e,t){if(t){var n=i.keys(t).reverse();i.each(n,function(i){this._addAppRoute(e,i,t[i])},this)}},_getController:function(){return this.getOption("controller")},_addAppRoute:function(e,t,n){var s=e[n];if(!s)throw new r.Error('Method "'+n+'" was not found on the controller');this.route(t,n,i.bind(s,e))},getOption:r.proxyGetOption,triggerMethod:r.triggerMethod,bindEntityEvents:r.proxyBindEntityEvents,unbindEntityEvents:r.proxyUnbindEntityEvents}),r.Application=r.Object.extend({constructor:function(e){this._initializeRegions(e),this._initCallbacks=new r.Callbacks,this.submodules={},i.extend(this,e),this._initChannel(),r.Object.call(this,e)},execute:function(){this.commands.execute.apply(this.commands,arguments)},request:function(){return this.reqres.request.apply(this.reqres,arguments)},addInitializer:function(e){this._initCallbacks.add(e)},start:function(e){this.triggerMethod("before:start",e),this._initCallbacks.run(e,this),this.triggerMethod("start",e)},addRegions:function(e){return this._regionManager.addRegions(e)},emptyRegions:function(){return this._regionManager.emptyRegions()},removeRegion:function(e){return this._regionManager.removeRegion(e)},getRegion:function(e){return this._regionManager.get(e)},getRegions:function(){return this._regionManager.getRegions()},module:function(e,t){var n=r.Module.getClass(t),s=i.toArray(arguments);return s.unshift(this),n.create.apply(n,s)},getRegionManager:function(){return new r.RegionManager},_initializeRegions:function(e){var t=i.isFunction(this.regions)?this.regions(e):this.regions||{};this._initRegionManager();var n=r.getOption(e,"regions");return i.isFunction(n)&&(n=n.call(this,e)),i.extend(t,n),this.addRegions(t),this},_initRegionManager:function(){this._regionManager=this.getRegionManager(),this._regionManager._parent=this,this.listenTo(this._regionManager,"before:add:region",function(){r._triggerMethod(this,"before:add:region",arguments)}),this.listenTo(this._regionManager,"add:region",function(e,t){this[e]=t,r._triggerMethod(this,"add:region",arguments)}),this.listenTo(this._regionManager,"before:remove:region",function(){r._triggerMethod(this,"before:remove:region",arguments)}),this.listenTo(this._regionManager,"remove:region",function(e){delete this[e],r._triggerMethod(this,"remove:region",arguments)})},_initChannel:function(){this.channelName=i.result(this,"channelName")||"global",this.channel=i.result(this,"channel")||t.Wreqr.radio.channel(this.channelName),this.vent=i.result(this,"vent")||this.channel.vent,this.commands=i.result(this,"commands")||this.channel.commands,this.reqres=i.result(this,"reqres")||this.channel.reqres}}),r.Module=function(e,t,n){this.moduleName=e,this.options=i.extend({},this.options,n),this.initialize=n.initialize||this.initialize,this.submodules={},this._setupInitializersAndFinalizers(),this.app=t,i.isFunction(this.initialize)&&this.initialize(e,t,this.options)},r.Module.extend=r.extend,i.extend(r.Module.prototype,t.Events,{startWithParent:!0,initialize:function(){},addInitializer:function(e){this._initializerCallbacks.add(e)},addFinalizer:function(e){this._finalizerCallbacks.add(e)},start:function(e){this._isInitialized||(i.each(this.submodules,function(t){t.startWithParent&&t.start(e)}),this.triggerMethod("before:start",e),this._initializerCallbacks.run(e,this),this._isInitialized=!0,this.triggerMethod("start",e))},stop:function(){this._isInitialized&&(this._isInitialized=!1,this.triggerMethod("before:stop"),i.invoke(this.submodules,"stop"),this._finalizerCallbacks.run(void 0,this),this._initializerCallbacks.reset(),this._finalizerCallbacks.reset(),this.triggerMethod("stop"))},addDefinition:function(e,t){this._runModuleDefinition(e,t)},_runModuleDefinition:function(e,n){if(e){var s=i.flatten([this,this.app,t,r,t.$,i,n]);e.apply(this,s)}},_setupInitializersAndFinalizers:function(){this._initializerCallbacks=new r.Callbacks,this._finalizerCallbacks=new r.Callbacks},triggerMethod:r.triggerMethod}),i.extend(r.Module,{create:function(e,t,n){var r=e,s=i.rest(arguments,3);t=t.split(".");var o=t.length,h=[];return h[o-1]=n,i.each(t,function(t,i){var o=r;r=this._getModule(o,t,e,n),this._addModuleDefinition(o,r,h[i],s)},this),r},_getModule:function(e,t,n,r){var s=i.extend({},r),o=this.getClass(r),h=e[t];return h||(h=new o(t,n,s),e[t]=h,e.submodules[t]=h),h},getClass:function(e){var t=r.Module;return e?e.prototype instanceof t?e:e.moduleClass||t:t},_addModuleDefinition:function(e,t,i,n){var r=this._getDefine(i),s=this._getStartWithParent(i,t);r&&t.addDefinition(r,n),this._addStartWithParent(e,t,s)},_getStartWithParent:function(e,t){var n;return i.isFunction(e)&&e.prototype instanceof r.Module?(n=t.constructor.prototype.startWithParent,i.isUndefined(n)?!0:n):i.isObject(e)?(n=e.startWithParent,i.isUndefined(n)?!0:n):!0},_getDefine:function(e){return!i.isFunction(e)||e.prototype instanceof r.Module?i.isObject(e)?e.define:null:e},_addStartWithParent:function(e,t,i){t.startWithParent=t.startWithParent&&i,t.startWithParent&&!t.startWithParentIsConfigured&&(t.startWithParentIsConfigured=!0,e.addInitializer(function(e){t.startWithParent&&t.start(e)}))}}),r}); +(function(e,t){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(i,n){return e.Marionette=e.Mn=t(e,i,n)});else if("undefined"!=typeof exports){var i=require("backbone"),n=require("underscore");module.exports=t(e,i,n)}else e.Marionette=e.Mn=t(e,e.Backbone,e._)})(this,function(e,t,i){"use strict";(function(e,t){var i=e.ChildViewContainer;return e.ChildViewContainer=function(e,t){var i=function(e){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),t.each(e,this.add,this)};t.extend(i.prototype,{add:function(e,t){var i=e.cid;return this._views[i]=e,e.model&&(this._indexByModel[e.model.cid]=i),t&&(this._indexByCustom[t]=i),this._updateLength(),this},findByModel:function(e){return this.findByModelCid(e.cid)},findByModelCid:function(e){var t=this._indexByModel[e];return this.findByCid(t)},findByCustom:function(e){var t=this._indexByCustom[e];return this.findByCid(t)},findByIndex:function(e){return t.values(this._views)[e]},findByCid:function(e){return this._views[e]},remove:function(e){var i=e.cid;return e.model&&delete this._indexByModel[e.model.cid],t.any(this._indexByCustom,function(e,t){return e===i?(delete this._indexByCustom[t],!0):void 0},this),delete this._views[i],this._updateLength(),this},call:function(e){this.apply(e,t.tail(arguments))},apply:function(e,i){t.each(this._views,function(n){t.isFunction(n[e])&&n[e].apply(n,i||[])})},_updateLength:function(){this.length=t.size(this._views)}});var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"];return t.each(n,function(e){i.prototype[e]=function(){var i=t.values(this._views),n=[i].concat(t.toArray(arguments));return t[e].apply(t,n)}}),i}(e,t),e.ChildViewContainer.VERSION="0.1.6",e.ChildViewContainer.noConflict=function(){return e.ChildViewContainer=i,this},e.ChildViewContainer})(t,i),function(e,t){var i=e.Wreqr,n=e.Wreqr={};return e.Wreqr.VERSION="1.3.1",e.Wreqr.noConflict=function(){return e.Wreqr=i,this},n.Handlers=function(e,t){var i=function(e){this.options=e,this._wreqrHandlers={},t.isFunction(this.initialize)&&this.initialize(e)};return i.extend=e.Model.extend,t.extend(i.prototype,e.Events,{setHandlers:function(e){t.each(e,function(e,i){var n=null;t.isObject(e)&&!t.isFunction(e)&&(n=e.context,e=e.callback),this.setHandler(i,e,n)},this)},setHandler:function(e,t,i){var n={callback:t,context:i};this._wreqrHandlers[e]=n,this.trigger("handler:add",e,t,i)},hasHandler:function(e){return!!this._wreqrHandlers[e]},getHandler:function(e){var t=this._wreqrHandlers[e];if(t)return function(){var e=Array.prototype.slice.apply(arguments);return t.callback.apply(t.context,e)}},removeHandler:function(e){delete this._wreqrHandlers[e]},removeAllHandlers:function(){this._wreqrHandlers={}}}),i}(e,t),n.CommandStorage=function(){var i=function(e){this.options=e,this._commands={},t.isFunction(this.initialize)&&this.initialize(e)};return t.extend(i.prototype,e.Events,{getCommands:function(e){var t=this._commands[e];return t||(t={command:e,instances:[]},this._commands[e]=t),t},addCommand:function(e,t){var i=this.getCommands(e);i.instances.push(t)},clearCommands:function(e){var t=this.getCommands(e);t.instances=[]}}),i}(),n.Commands=function(e){return e.Handlers.extend({storageType:e.CommandStorage,constructor:function(t){this.options=t||{},this._initializeStorage(this.options),this.on("handler:add",this._executeCommands,this);var i=Array.prototype.slice.call(arguments);e.Handlers.prototype.constructor.apply(this,i)},execute:function(e,t){e=arguments[0],t=Array.prototype.slice.call(arguments,1),this.hasHandler(e)?this.getHandler(e).apply(this,t):this.storage.addCommand(e,t)},_executeCommands:function(e,i,n){var r=this.storage.getCommands(e);t.each(r.instances,function(e){i.apply(n,e)}),this.storage.clearCommands(e)},_initializeStorage:function(e){var i,n=e.storageType||this.storageType;i=t.isFunction(n)?new n:n,this.storage=i}})}(n),n.RequestResponse=function(e){return e.Handlers.extend({request:function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1);return this.hasHandler(e)?this.getHandler(e).apply(this,t):void 0}})}(n),n.EventAggregator=function(e,t){var i=function(){};return i.extend=e.Model.extend,t.extend(i.prototype,e.Events),i}(e,t),n.Channel=function(){var i=function(t){this.vent=new e.Wreqr.EventAggregator,this.reqres=new e.Wreqr.RequestResponse,this.commands=new e.Wreqr.Commands,this.channelName=t};return t.extend(i.prototype,{reset:function(){return this.vent.off(),this.vent.stopListening(),this.reqres.removeAllHandlers(),this.commands.removeAllHandlers(),this},connectEvents:function(e,t){return this._connect("vent",e,t),this},connectCommands:function(e,t){return this._connect("commands",e,t),this},connectRequests:function(e,t){return this._connect("reqres",e,t),this},_connect:function(e,i,n){if(i){n=n||this;var r="vent"===e?"on":"setHandler";t.each(i,function(i,s){this[e][r](s,t.bind(i,n))},this)}}}),i}(n),n.radio=function(e){var i=function(){this._channels={},this.vent={},this.commands={},this.reqres={},this._proxyMethods()};t.extend(i.prototype,{channel:function(e){if(!e)throw Error("Channel must receive a name");return this._getChannel(e)},_getChannel:function(t){var i=this._channels[t];return i||(i=new e.Channel(t),this._channels[t]=i),i},_proxyMethods:function(){t.each(["vent","commands","reqres"],function(e){t.each(n[e],function(t){this[e][t]=r(this,e,t)},this)},this)}});var n={vent:["on","off","trigger","once","stopListening","listenTo","listenToOnce"],commands:["execute","setHandler","setHandlers","removeHandler","removeAllHandlers"],reqres:["request","setHandler","setHandlers","removeHandler","removeAllHandlers"]},r=function(e,t,i){return function(n){var r=e._getChannel(n)[t],s=Array.prototype.slice.call(arguments,1);return r[i].apply(r,s)}};return new i}(n),e.Wreqr}(t,i);var n=e.Marionette,r=e.Mn,s=t.Marionette={};s.VERSION="2.4.0",s.noConflict=function(){return e.Marionette=n,e.Mn=r,this},t.Marionette=s,s.Deferred=t.$.Deferred,s.extend=t.Model.extend,s.isNodeAttached=function(e){return t.$.contains(document.documentElement,e)},s.mergeOptions=function(e,t){e&&i.extend(this,i.pick(e,t))},s.getOption=function(e,t){return e&&t?e.options&&void 0!==e.options[t]?e.options[t]:e[t]:void 0},s.proxyGetOption=function(e){return s.getOption(this,e)},s._getValue=function(e,t,n){return i.isFunction(e)&&(e=n?e.apply(t,n):e.call(t)),e},s.normalizeMethods=function(e){return i.reduce(e,function(e,t,n){return i.isFunction(t)||(t=this[t]),t&&(e[n]=t),e},{},this)},s.normalizeUIString=function(e,t){return e.replace(/@ui\.[a-zA-Z_$0-9]*/g,function(e){return t[e.slice(4)]})},s.normalizeUIKeys=function(e,t){return i.reduce(e,function(e,i,n){var r=s.normalizeUIString(n,t);return e[r]=i,e},{})},s.normalizeUIValues=function(e,t,n){return i.each(e,function(r,o){i.isString(r)?e[o]=s.normalizeUIString(r,t):i.isObject(r)&&i.isArray(n)&&(i.extend(r,s.normalizeUIValues(i.pick(r,n),t)),i.each(n,function(e){var n=r[e];i.isString(n)&&(r[e]=s.normalizeUIString(n,t))}))}),e},s.actAsCollection=function(e,t){var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];i.each(n,function(n){e[n]=function(){var e=i.values(i.result(this,t)),r=[e].concat(i.toArray(arguments));return i[n].apply(i,r)}})};var o=s.deprecate=function(e,t){i.isObject(e)&&(e=e.prev+" is going to be removed in the future. "+"Please use "+e.next+" instead."+(e.url?" See: "+e.url:"")),void 0!==t&&t||o._cache[e]||(o._warn("Deprecation warning: "+e),o._cache[e]=!0)};o._warn="undefined"!=typeof console&&(console.warn||console.log)||function(){},o._cache={},s._triggerMethod=function(){function e(e,t,i){return i.toUpperCase()}var t=/(^|:)(\w)/gi;return function(n,r,s){var o=3>arguments.length;o&&(s=r,r=s[0]);var h,a="on"+r.replace(t,e),l=n[a];return i.isFunction(l)&&(h=l.apply(n,o?i.rest(s):s)),i.isFunction(n.trigger)&&(o+s.length>1?n.trigger.apply(n,o?s:[r].concat(i.drop(s,0))):n.trigger(r)),h}}(),s.triggerMethod=function(){return s._triggerMethod(this,arguments)},s.triggerMethodOn=function(e){var t=i.isFunction(e.triggerMethod)?e.triggerMethod:s.triggerMethod;return t.apply(e,i.rest(arguments))},s.MonitorDOMRefresh=function(e){function t(){e._isShown=!0,r()}function n(){e._isRendered=!0,r()}function r(){e._isShown&&e._isRendered&&s.isNodeAttached(e.el)&&i.isFunction(e.triggerMethod)&&e.triggerMethod("dom:refresh")}e.on({show:t,render:n})},function(e){function t(t,n,r,s){var o=s.split(/\s+/);i.each(o,function(i){var s=t[i];if(!s)throw new e.Error('Method "'+i+'" was configured as an event handler, but does not exist.');t.listenTo(n,r,s)})}function n(e,t,i,n){e.listenTo(t,i,n)}function r(e,t,n,r){var s=r.split(/\s+/);i.each(s,function(i){var r=e[i];e.stopListening(t,n,r)})}function s(e,t,i,n){e.stopListening(t,i,n)}function o(t,n,r,s,o){if(n&&r){if(!i.isObject(r))throw new e.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});r=e._getValue(r,t),i.each(r,function(e,r){i.isFunction(e)?s(t,n,r,e):o(t,n,r,e)})}}e.bindEntityEvents=function(e,i,r){o(e,i,r,n,t)},e.unbindEntityEvents=function(e,t,i){o(e,t,i,s,r)},e.proxyBindEntityEvents=function(t,i){return e.bindEntityEvents(this,t,i)},e.proxyUnbindEntityEvents=function(t,i){return e.unbindEntityEvents(this,t,i)}}(s);var h=["description","fileName","lineNumber","name","message","number"];return s.Error=s.extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+s.VERSION+"/",constructor:function(e,t){i.isObject(e)?(t=e,e=t.message):t||(t={});var n=Error.call(this,e);i.extend(this,i.pick(n,h),i.pick(t,h)),this.captureStackTrace(),t.url&&(this.url=this.urlRoot+t.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,s.Error)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}}),s.Error.extend=s.extend,s.Callbacks=function(){this._deferred=s.Deferred(),this._callbacks=[]},i.extend(s.Callbacks.prototype,{add:function(e,t){var n=i.result(this._deferred,"promise");this._callbacks.push({cb:e,ctx:t}),n.then(function(i){t&&(i.context=t),e.call(i.context,i.options)})},run:function(e,t){this._deferred.resolve({options:e,context:t})},reset:function(){var e=this._callbacks;this._deferred=s.Deferred(),this._callbacks=[],i.each(e,function(e){this.add(e.cb,e.ctx)},this)}}),s.Controller=function(e){this.options=e||{},i.isFunction(this.initialize)&&this.initialize(this.options)},s.Controller.extend=s.extend,i.extend(s.Controller.prototype,t.Events,{destroy:function(){return s._triggerMethod(this,"before:destroy",arguments),s._triggerMethod(this,"destroy",arguments),this.stopListening(),this.off(),this},triggerMethod:s.triggerMethod,mergeOptions:s.mergeOptions,getOption:s.proxyGetOption}),s.Object=function(e){this.options=i.extend({},i.result(this,"options"),e),this.initialize.apply(this,arguments)},s.Object.extend=s.extend,i.extend(s.Object.prototype,t.Events,{initialize:function(){},destroy:function(){return this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening(),this},triggerMethod:s.triggerMethod,mergeOptions:s.mergeOptions,getOption:s.proxyGetOption,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.Region=s.Object.extend({constructor:function(e){if(this.options=e||{},this.el=this.getOption("el"),this.el=this.el instanceof t.$?this.el[0]:this.el,!this.el)throw new s.Error({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),s.Object.call(this,e)},show:function(e,t){if(this._ensureElement()){this._ensureViewIsIntact(e);var i=t||{},n=e!==this.currentView,r=!!i.preventDestroy,o=!!i.forceShow,h=!!this.currentView,a=n&&!r,l=n||o;if(h&&this.triggerMethod("before:swapOut",this.currentView,this,t),this.currentView&&delete this.currentView._parent,a?this.empty():h&&l&&this.currentView.off("destroy",this.empty,this),l){e.once("destroy",this.empty,this),e.render(),e._parent=this,h&&this.triggerMethod("before:swap",e,this,t),this.triggerMethod("before:show",e,this,t),s.triggerMethodOn(e,"before:show",e,this,t),h&&this.triggerMethod("swapOut",this.currentView,this,t);var d=s.isNodeAttached(this.el),u=[],c=i.triggerBeforeAttach||this.triggerBeforeAttach,g=i.triggerAttach||this.triggerAttach;return d&&c&&(u=this._displayedViews(e),this._triggerAttach(u,"before:")),this.attachHtml(e),this.currentView=e,d&&g&&(u=this._displayedViews(e),this._triggerAttach(u)),h&&this.triggerMethod("swap",e,this,t),this.triggerMethod("show",e,this,t),s.triggerMethodOn(e,"show",e,this,t),this}return this}},triggerBeforeAttach:!0,triggerAttach:!0,_triggerAttach:function(e,t){var n=(t||"")+"attach";i.each(e,function(e){s.triggerMethodOn(e,n,e,this)},this)},_displayedViews:function(e){return i.union([e],i.result(e,"_getNestedViews")||[])},_ensureElement:function(){if(i.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||0===this.$el.length){if(this.getOption("allowMissingEl"))return!1;throw new s.Error('An "el" '+this.$el.selector+" must exist in DOM")}return!0},_ensureViewIsIntact:function(e){if(!e)throw new s.Error({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(e.isDestroyed)throw new s.Error({name:"ViewDestroyedError",message:'View (cid: "'+e.cid+'") has already been destroyed and cannot be used.'})},getEl:function(e){return t.$(e,s._getValue(this.options.parentEl,this))},attachHtml:function(e){this.$el.contents().detach(),this.el.appendChild(e.el)},empty:function(e){var t=this.currentView,i=s._getValue(e,"preventDestroy",this);return t?(t.off("destroy",this.empty,this),this.triggerMethod("before:empty",t),i||this._destroyView(),this.triggerMethod("empty",t),delete this.currentView,i&&this.$el.contents().detach(),this):void 0},_destroyView:function(){var e=this.currentView;e.destroy&&!e.isDestroyed?e.destroy():e.remove&&(e.remove(),e.isDestroyed=!0)},attachView:function(e){return this.currentView=e,this},hasView:function(){return!!this.currentView},reset:function(){return this.empty(),this.$el&&(this.el=this.$el.selector),delete this.$el,this}},{buildRegion:function(e,t){if(i.isString(e))return this._buildRegionFromSelector(e,t);if(e.selector||e.el||e.regionClass)return this._buildRegionFromObject(e,t);if(i.isFunction(e))return this._buildRegionFromRegionClass(e);throw new s.Error({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})},_buildRegionFromSelector:function(e,t){return new t({el:e})},_buildRegionFromObject:function(e,t){var n=e.regionClass||t,r=i.omit(e,"selector","regionClass");return e.selector&&!r.el&&(r.el=e.selector),new n(r)},_buildRegionFromRegionClass:function(e){return new e}}),s.RegionManager=s.Controller.extend({constructor:function(e){this._regions={},this.length=0,s.Controller.call(this,e),this.addRegions(this.getOption("regions"))},addRegions:function(e,t){return e=s._getValue(e,this,arguments),i.reduce(e,function(e,n,r){return i.isString(n)&&(n={selector:n}),n.selector&&(n=i.defaults({},n,t)),e[r]=this.addRegion(r,n),e},{},this)},addRegion:function(e,t){var i;return i=t instanceof s.Region?t:s.Region.buildRegion(t,s.Region),this.triggerMethod("before:add:region",e,i),i._parent=this,this._store(e,i),this.triggerMethod("add:region",e,i),i},get:function(e){return this._regions[e]},getRegions:function(){return i.clone(this._regions)},removeRegion:function(e){var t=this._regions[e];return this._remove(e,t),t},removeRegions:function(){var e=this.getRegions();return i.each(this._regions,function(e,t){this._remove(t,e)},this),e},emptyRegions:function(){var e=this.getRegions();return i.invoke(e,"empty"),e},destroy:function(){return this.removeRegions(),s.Controller.prototype.destroy.apply(this,arguments)},_store:function(e,t){this._regions[e]||this.length++,this._regions[e]=t},_remove:function(e,t){this.triggerMethod("before:remove:region",e,t),t.empty(),t.stopListening(),delete t._parent,delete this._regions[e],this.length--,this.triggerMethod("remove:region",e,t)}}),s.actAsCollection(s.RegionManager.prototype,"_regions"),s.TemplateCache=function(e){this.templateId=e},i.extend(s.TemplateCache,{templateCaches:{},get:function(e,t){var i=this.templateCaches[e];return i||(i=new s.TemplateCache(e),this.templateCaches[e]=i),i.load(t)},clear:function(){var e,t=i.toArray(arguments),n=t.length;if(n>0)for(e=0;n>e;e++)delete this.templateCaches[t[e]];else this.templateCaches={}}}),i.extend(s.TemplateCache.prototype,{load:function(e){if(this.compiledTemplate)return this.compiledTemplate;var t=this.loadTemplate(this.templateId,e);return this.compiledTemplate=this.compileTemplate(t,e),this.compiledTemplate},loadTemplate:function(e){var i=t.$(e).html();if(!i||0===i.length)throw new s.Error({name:"NoTemplateError",message:'Could not find template: "'+e+'"'});return i},compileTemplate:function(e,t){return i.template(e,t)}}),s.Renderer={render:function(e,t){if(!e)throw new s.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var n=i.isFunction(e)?e:s.TemplateCache.get(e);return n(t)}},s.View=t.View.extend({isDestroyed:!1,constructor:function(e){i.bindAll(this,"render"),e=s._getValue(e,this),this.options=i.extend({},i.result(this,"options"),e),this._behaviors=s.Behaviors(this),t.View.call(this,this.options),s.MonitorDOMRefresh(this)},getTemplate:function(){return this.getOption("template")},serializeModel:function(e){return e.toJSON.apply(e,i.rest(arguments))},mixinTemplateHelpers:function(e){e=e||{};var t=this.getOption("templateHelpers");return t=s._getValue(t,this),i.extend(e,t)},normalizeUIKeys:function(e){var t=i.result(this,"_uiBindings");return s.normalizeUIKeys(e,t||i.result(this,"ui"))},normalizeUIValues:function(e,t){var n=i.result(this,"ui"),r=i.result(this,"_uiBindings");return s.normalizeUIValues(e,r||n,t)},configureTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(i.result(this,"triggers"));return i.reduce(e,function(e,t,i){return e[i]=this._buildViewTrigger(t),e},{},this)}},delegateEvents:function(e){return this._delegateDOMEvents(e),this.bindEntityEvents(this.model,this.getOption("modelEvents")),this.bindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(e){e.bindEntityEvents(this.model,e.getOption("modelEvents")),e.bindEntityEvents(this.collection,e.getOption("collectionEvents"))},this),this},_delegateDOMEvents:function(e){var n=s._getValue(e||this.events,this);n=this.normalizeUIKeys(n),i.isUndefined(e)&&(this.events=n);var r={},o=i.result(this,"behaviorEvents")||{},h=this.configureTriggers(),a=i.result(this,"behaviorTriggers")||{};i.extend(r,o,n,h,a),t.View.prototype.delegateEvents.call(this,r)},undelegateEvents:function(){return t.View.prototype.undelegateEvents.apply(this,arguments),this.unbindEntityEvents(this.model,this.getOption("modelEvents")),this.unbindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(e){e.unbindEntityEvents(this.model,e.getOption("modelEvents")),e.unbindEntityEvents(this.collection,e.getOption("collectionEvents"))},this),this},_ensureViewIsIntact:function(){if(this.isDestroyed)throw new s.Error({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(this.isDestroyed)return this;var e=i.toArray(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(e)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(e)),this.unbindUIElements(),this.isRendered=!1,this.remove(),i.invoke(this._behaviors,"destroy",e),this},bindUIElements:function(){this._bindUIElements(),i.invoke(this._behaviors,this._bindUIElements)},_bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var e=i.result(this,"_uiBindings");this.ui={},i.each(e,function(e,t){this.ui[t]=this.$(e)},this)}},unbindUIElements:function(){this._unbindUIElements(),i.invoke(this._behaviors,this._unbindUIElements)},_unbindUIElements:function(){this.ui&&this._uiBindings&&(i.each(this.ui,function(e,t){delete this.ui[t]},this),this.ui=this._uiBindings,delete this._uiBindings)},_buildViewTrigger:function(e){var t=i.isObject(e),n=i.defaults({},t?e:{},{preventDefault:!0,stopPropagation:!0}),r=t?n.event:e;return function(e){e&&(e.preventDefault&&n.preventDefault&&e.preventDefault(),e.stopPropagation&&n.stopPropagation&&e.stopPropagation());var t={view:this,model:this.model,collection:this.collection};this.triggerMethod(r,t)}},setElement:function(){var e=t.View.prototype.setElement.apply(this,arguments);return i.invoke(this._behaviors,"proxyViewProperties",this),e},triggerMethod:function(){var e=s._triggerMethod(this,arguments);return this._triggerEventOnBehaviors(arguments),this._triggerEventOnParentLayout(arguments[0],i.rest(arguments)),e},_triggerEventOnBehaviors:function(e){for(var t=s._triggerMethod,i=this._behaviors,n=0,r=i&&i.length;r>n;n++)t(i[n],e)},_triggerEventOnParentLayout:function(e,t){var n=this._parentLayoutView();if(n){var r=s.getOption(n,"childViewEventPrefix"),o=r+":"+e;s._triggerMethod(n,[o,this].concat(t));var h=s.getOption(n,"childEvents"),a=n.normalizeMethods(h);a&&i.isFunction(a[e])&&a[e].apply(n,[this].concat(t))}},_getImmediateChildren:function(){return[]},_getNestedViews:function(){var e=this._getImmediateChildren();return e.length?i.reduce(e,function(e,t){return t._getNestedViews?e.concat(t._getNestedViews()):e},e):e},_getAncestors:function(){for(var e=[],t=this._parent;t;)e.push(t),t=t._parent;return e},_parentLayoutView:function(){var e=this._getAncestors();return i.find(e,function(e){return e instanceof s.LayoutView})},normalizeMethods:s.normalizeMethods,mergeOptions:s.mergeOptions,getOption:s.proxyGetOption,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.ItemView=s.View.extend({constructor:function(){s.View.apply(this,arguments)},serializeData:function(){if(!this.model&&!this.collection)return{};var e=[this.model||this.collection];return arguments.length&&e.push.apply(e,arguments),this.model?this.serializeModel.apply(this,e):{items:this.serializeCollection.apply(this,e)}},serializeCollection:function(e){return e.toJSON.apply(e,i.rest(arguments))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderTemplate(),this.isRendered=!0,this.bindUIElements(),this.triggerMethod("render",this),this},_renderTemplate:function(){var e=this.getTemplate();if(e!==!1){if(!e)throw new s.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var t=this.mixinTemplateHelpers(this.serializeData()),i=s.Renderer.render(e,t,this);return this.attachElContent(i),this}},attachElContent:function(e){return this.$el.html(e),this}}),s.CollectionView=s.View.extend({childViewEventPrefix:"childview",sort:!0,constructor:function(){this.once("render",this._initialEvents),this._initChildViewStorage(),s.View.apply(this,arguments),this.on("show",this._onShowCalled),this.initRenderBuffer()},initRenderBuffer:function(){this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){this.isBuffering=!1,this._triggerBeforeShowBufferedChildren(),this.attachBuffer(this),this._triggerShowBufferedChildren(),this.initRenderBuffer()},_triggerBeforeShowBufferedChildren:function(){this._isShown&&i.each(this._bufferedChildren,i.partial(this._triggerMethodOnChild,"before:show"))},_triggerShowBufferedChildren:function(){this._isShown&&(i.each(this._bufferedChildren,i.partial(this._triggerMethodOnChild,"show")),this._bufferedChildren=[])},_triggerMethodOnChild:function(e,t){s.triggerMethodOn(t,e)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this.render),this.getOption("sort")&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(e,t,n){var r;if(r=void 0!==n.at?n.at:i.indexOf(this._filteredSortedModels(),e),this._shouldAddChild(e,r)){this.destroyEmptyView();var s=this.getChildView(e);this.addChild(e,s,r)}},_onCollectionRemove:function(e){var t=this.children.findByModel(e);this.removeChildView(t),this.checkEmpty()},_onShowCalled:function(){this.children.each(i.partial(this._triggerMethodOnChild,"show"))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderChildren(),this.isRendered=!0,this.triggerMethod("render",this),this},reorder:function(){var e=this.children,t=this._filteredSortedModels(),n=i.find(t,function(t){return!e.findByModel(t)});if(n)this.render();else{var r=i.map(t,function(t){return e.findByModel(t).el});this.triggerMethod("before:reorder"),this.$el.append(r),this.triggerMethod("reorder")}},resortView:function(){s.getOption(this,"reorderOnSort")?this.reorder():this.render()},_sortViews:function(){var e=this._filteredSortedModels(),t=i.find(e,function(e,t){var i=this.children.findByModel(e);return!i||i._index!==t},this);t&&this.resortView()},_emptyViewIndex:-1,_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren(),this.isEmpty(this.collection)?this.showEmptyView():(this.triggerMethod("before:render:collection",this),this.startBuffering(),this.showCollection(),this.endBuffering(),this.triggerMethod("render:collection",this),this.children.isEmpty()&&this.showEmptyView())},showCollection:function(){var e,t=this._filteredSortedModels();i.each(t,function(t,i){e=this.getChildView(t),this.addChild(t,e,i)},this)},_filteredSortedModels:function(){var e,t=this.getViewComparator();return e=t?i.isString(t)||1===t.length?this.collection.sortBy(t,this):i.clone(this.collection.models).sort(i.bind(t,this)):this.collection.models,this.getOption("filter")&&(e=i.filter(e,function(e,t){return this._shouldAddChild(e,t)},this)),e},showEmptyView:function(){var e=this.getEmptyView();if(e&&!this._showingEmptyView){this.triggerMethod("before:render:empty"),this._showingEmptyView=!0;var i=new t.Model;this.addEmptyView(i,e),this.triggerMethod("render:empty")}},destroyEmptyView:function(){this._showingEmptyView&&(this.triggerMethod("before:remove:empty"),this.destroyChildren(),delete this._showingEmptyView,this.triggerMethod("remove:empty"))},getEmptyView:function(){return this.getOption("emptyView")},addEmptyView:function(e,t){var n=this.getOption("emptyViewOptions")||this.getOption("childViewOptions");i.isFunction(n)&&(n=n.call(this,e,this._emptyViewIndex));var r=this.buildChildView(e,t,n);r._parent=this,this.proxyChildEvents(r),this._isShown&&s.triggerMethodOn(r,"before:show"),this.children.add(r),this.renderChildView(r,this._emptyViewIndex),this._isShown&&s.triggerMethodOn(r,"show")},getChildView:function(){var e=this.getOption("childView");if(!e)throw new s.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return e},addChild:function(e,t,i){var n=this.getOption("childViewOptions");n=s._getValue(n,this,[e,i]);var r=this.buildChildView(e,t,n);return this._updateIndices(r,!0,i),this._addChildView(r,i),r._parent=this,r},_updateIndices:function(e,t,i){this.getOption("sort")&&(t&&(e._index=i),this.children.each(function(i){i._index>=e._index&&(i._index+=t?1:-1)}))},_addChildView:function(e,t){this.proxyChildEvents(e),this.triggerMethod("before:add:child",e),this._isShown&&!this.isBuffering&&s.triggerMethodOn(e,"before:show"),this.children.add(e),this.renderChildView(e,t),this._isShown&&!this.isBuffering&&s.triggerMethodOn(e,"show"),this.triggerMethod("add:child",e)},renderChildView:function(e,t){return e.render(),this.attachHtml(this,e,t),e},buildChildView:function(e,t,n){var r=i.extend({model:e},n);return new t(r)},removeChildView:function(e){return e&&(this.triggerMethod("before:remove:child",e),e.destroy?e.destroy():e.remove&&e.remove(),delete e._parent,this.stopListening(e),this.children.remove(e),this.triggerMethod("remove:child",e),this._updateIndices(e,!1)),e},isEmpty:function(){return!this.collection||0===this.collection.length},checkEmpty:function(){this.isEmpty(this.collection)&&this.showEmptyView()},attachBuffer:function(e){e.$el.append(this._createBuffer(e))},_createBuffer:function(e){var t=document.createDocumentFragment();return i.each(e._bufferedChildren,function(e){t.appendChild(e.el)}),t},attachHtml:function(e,t,i){e.isBuffering?e._bufferedChildren.splice(i,0,t):e._insertBefore(t,i)||e._insertAfter(t)},_insertBefore:function(e,t){var i,n=this.getOption("sort")&&this.children.length-1>t;return n&&(i=this.children.find(function(e){return e._index===t+1})),i?(i.$el.before(e.el),!0):!1},_insertAfter:function(e){this.$el.append(e.el)},_initChildViewStorage:function(){this.children=new t.ChildViewContainer},destroy:function(){return this.isDestroyed?this:(this.triggerMethod("before:destroy:collection"),this.destroyChildren(),this.triggerMethod("destroy:collection"),s.View.prototype.destroy.apply(this,arguments))},destroyChildren:function(){var e=this.children.map(i.identity);return this.children.each(this.removeChildView,this),this.checkEmpty(),e},_shouldAddChild:function(e,t){var n=this.getOption("filter");return!i.isFunction(n)||n.call(this,e,t,this.collection)},proxyChildEvents:function(e){var t=this.getOption("childViewEventPrefix");this.listenTo(e,"all",function(){var n=i.toArray(arguments),r=n[0],s=this.normalizeMethods(i.result(this,"childEvents"));n[0]=t+":"+r,n.splice(1,0,e),s!==void 0&&i.isFunction(s[r])&&s[r].apply(this,n.slice(1)),this.triggerMethod.apply(this,n)})},_getImmediateChildren:function(){return i.values(this.children._views)},getViewComparator:function(){return this.getOption("viewComparator")}}),s.CompositeView=s.CollectionView.extend({constructor:function(){s.CollectionView.apply(this,arguments)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this._renderChildren),this.getOption("sort")&&this.listenTo(this.collection,"sort",this._sortViews))},getChildView:function(){var e=this.getOption("childView")||this.constructor;return e},serializeData:function(){var e={};return this.model&&(e=i.partial(this.serializeModel,this.model).apply(this,arguments)),e},render:function(){return this._ensureViewIsIntact(),this._isRendering=!0,this.resetChildViewContainer(),this.triggerMethod("before:render",this),this._renderTemplate(),this._renderChildren(),this._isRendering=!1,this.isRendered=!0,this.triggerMethod("render",this),this},_renderChildren:function(){(this.isRendered||this._isRendering)&&s.CollectionView.prototype._renderChildren.call(this)},_renderTemplate:function(){var e={};e=this.serializeData(),e=this.mixinTemplateHelpers(e),this.triggerMethod("before:render:template");var t=this.getTemplate(),i=s.Renderer.render(t,e,this);this.attachElContent(i),this.bindUIElements(),this.triggerMethod("render:template")},attachElContent:function(e){return this.$el.html(e),this},attachBuffer:function(e){var t=this.getChildViewContainer(e);t.append(this._createBuffer(e))},_insertAfter:function(e){var t=this.getChildViewContainer(this,e);t.append(e.el)},getChildViewContainer:function(e){if("$childViewContainer"in e)return e.$childViewContainer;var t,i=s.getOption(e,"childViewContainer");if(i){var n=s._getValue(i,e);if(t="@"===n.charAt(0)&&e.ui?e.ui[n.substr(4)]:e.$(n),0>=t.length)throw new s.Error({name:"ChildViewContainerMissingError",message:'The specified "childViewContainer" was not found: '+e.childViewContainer})}else t=e.$el;return e.$childViewContainer=t,t +},resetChildViewContainer:function(){this.$childViewContainer&&delete this.$childViewContainer}}),s.LayoutView=s.ItemView.extend({regionClass:s.Region,options:{destroyImmediate:!1},childViewEventPrefix:"childview",constructor:function(e){e=e||{},this._firstRender=!0,this._initializeRegions(e),s.ItemView.call(this,e)},render:function(){return this._ensureViewIsIntact(),this._firstRender?this._firstRender=!1:this._reInitializeRegions(),s.ItemView.prototype.render.apply(this,arguments)},destroy:function(){return this.isDestroyed?this:(this.getOption("destroyImmediate")===!0&&this.$el.remove(),this.regionManager.destroy(),s.ItemView.prototype.destroy.apply(this,arguments))},showChildView:function(e,t){return this.getRegion(e).show(t)},getChildView:function(e){return this.getRegion(e).currentView},addRegion:function(e,t){var i={};return i[e]=t,this._buildRegions(i)[e]},addRegions:function(e){return this.regions=i.extend({},this.regions,e),this._buildRegions(e)},removeRegion:function(e){return delete this.regions[e],this.regionManager.removeRegion(e)},getRegion:function(e){return this.regionManager.get(e)},getRegions:function(){return this.regionManager.getRegions()},_buildRegions:function(e){var t={regionClass:this.getOption("regionClass"),parentEl:i.partial(i.result,this,"el")};return this.regionManager.addRegions(e,t)},_initializeRegions:function(e){var t;this._initRegionManager(),t=s._getValue(this.regions,this,[e])||{};var n=this.getOption.call(e,"regions");n=s._getValue(n,this,[e]),i.extend(t,n),t=this.normalizeUIValues(t,["selector","el"]),this.addRegions(t)},_reInitializeRegions:function(){this.regionManager.invoke("reset")},getRegionManager:function(){return new s.RegionManager},_initRegionManager:function(){this.regionManager=this.getRegionManager(),this.regionManager._parent=this,this.listenTo(this.regionManager,"before:add:region",function(e){this.triggerMethod("before:add:region",e)}),this.listenTo(this.regionManager,"add:region",function(e,t){this[e]=t,this.triggerMethod("add:region",e,t)}),this.listenTo(this.regionManager,"before:remove:region",function(e){this.triggerMethod("before:remove:region",e)}),this.listenTo(this.regionManager,"remove:region",function(e,t){delete this[e],this.triggerMethod("remove:region",e,t)})},_getImmediateChildren:function(){return i.chain(this.regionManager.getRegions()).pluck("currentView").compact().value()}}),s.Behavior=s.Object.extend({constructor:function(e,t){this.view=t,this.defaults=i.result(this,"defaults")||{},this.options=i.extend({},this.defaults,e),this.ui=i.extend({},i.result(t,"ui"),i.result(this,"ui")),s.Object.apply(this,arguments)},$:function(){return this.view.$.apply(this.view,arguments)},destroy:function(){return this.stopListening(),this},proxyViewProperties:function(e){this.$el=e.$el,this.el=e.el}}),s.Behaviors=function(e,t){function i(e,n){return t.isObject(e.behaviors)?(n=i.parseBehaviors(e,n||t.result(e,"behaviors")),i.wrap(e,n,t.keys(o)),n):{}}function n(e,t){this._view=e,this._behaviors=t,this._triggers={}}function r(e){return e._uiBindings||e.ui}var s=/^(\S+)\s*(.*)$/,o={behaviorTriggers:function(e,t){var i=new n(this,t);return i.buildBehaviorTriggers()},behaviorEvents:function(i,n){var o={};return t.each(n,function(i,n){var h={},a=t.clone(t.result(i,"events"))||{};a=e.normalizeUIKeys(a,r(i));var l=0;t.each(a,function(e,r){var o=r.match(s),a=o[1]+"."+[this.cid,n,l++," "].join(""),d=o[2],u=a+d,c=t.isFunction(e)?e:i[e];h[u]=t.bind(c,i)},this),o=t.extend(o,h)},this),o}};return t.extend(i,{behaviorsLookup:function(){throw new e.Error({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.html#behaviorslookup"})},getBehaviorClass:function(t,n){return t.behaviorClass?t.behaviorClass:e._getValue(i.behaviorsLookup,this,[t,n])[n]},parseBehaviors:function(e,n){return t.chain(n).map(function(n,r){var s=i.getBehaviorClass(n,r),o=new s(n,e),h=i.parseBehaviors(e,t.result(o,"behaviors"));return[o].concat(h)}).flatten().value()},wrap:function(e,i,n){t.each(n,function(n){e[n]=t.partial(o[n],e[n],i)})}}),t.extend(n.prototype,{buildBehaviorTriggers:function(){return t.each(this._behaviors,this._buildTriggerHandlersForBehavior,this),this._triggers},_buildTriggerHandlersForBehavior:function(i,n){var s=t.clone(t.result(i,"triggers"))||{};s=e.normalizeUIKeys(s,r(i)),t.each(s,t.bind(this._setHandlerForBehavior,this,i,n))},_setHandlerForBehavior:function(e,t,i,n){var r=n.replace(/^\S+/,function(e){return e+"."+"behaviortriggers"+t});this._triggers[r]=this._view._buildViewTrigger(i)}}),i}(s,i),s.AppRouter=t.Router.extend({constructor:function(e){this.options=e||{},t.Router.apply(this,arguments);var i=this.getOption("appRoutes"),n=this._getController();this.processAppRoutes(n,i),this.on("route",this._processOnRoute,this)},appRoute:function(e,t){var i=this._getController();this._addAppRoute(i,e,t)},_processOnRoute:function(e,t){if(i.isFunction(this.onRoute)){var n=i.invert(this.getOption("appRoutes"))[e];this.onRoute(e,n,t)}},processAppRoutes:function(e,t){if(t){var n=i.keys(t).reverse();i.each(n,function(i){this._addAppRoute(e,i,t[i])},this)}},_getController:function(){return this.getOption("controller")},_addAppRoute:function(e,t,n){var r=e[n];if(!r)throw new s.Error('Method "'+n+'" was not found on the controller');this.route(t,n,i.bind(r,e))},mergeOptions:s.mergeOptions,getOption:s.proxyGetOption,triggerMethod:s.triggerMethod,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.Application=s.Object.extend({constructor:function(e){this._initializeRegions(e),this._initCallbacks=new s.Callbacks,this.submodules={},i.extend(this,e),this._initChannel(),s.Object.call(this,e)},execute:function(){this.commands.execute.apply(this.commands,arguments)},request:function(){return this.reqres.request.apply(this.reqres,arguments)},addInitializer:function(e){this._initCallbacks.add(e)},start:function(e){this.triggerMethod("before:start",e),this._initCallbacks.run(e,this),this.triggerMethod("start",e)},addRegions:function(e){return this._regionManager.addRegions(e)},emptyRegions:function(){return this._regionManager.emptyRegions()},removeRegion:function(e){return this._regionManager.removeRegion(e)},getRegion:function(e){return this._regionManager.get(e)},getRegions:function(){return this._regionManager.getRegions()},module:function(e,t){var n=s.Module.getClass(t),r=i.toArray(arguments);return r.unshift(this),n.create.apply(n,r)},getRegionManager:function(){return new s.RegionManager},_initializeRegions:function(e){var t=i.isFunction(this.regions)?this.regions(e):this.regions||{};this._initRegionManager();var n=s.getOption(e,"regions");return i.isFunction(n)&&(n=n.call(this,e)),i.extend(t,n),this.addRegions(t),this},_initRegionManager:function(){this._regionManager=this.getRegionManager(),this._regionManager._parent=this,this.listenTo(this._regionManager,"before:add:region",function(){s._triggerMethod(this,"before:add:region",arguments)}),this.listenTo(this._regionManager,"add:region",function(e,t){this[e]=t,s._triggerMethod(this,"add:region",arguments)}),this.listenTo(this._regionManager,"before:remove:region",function(){s._triggerMethod(this,"before:remove:region",arguments)}),this.listenTo(this._regionManager,"remove:region",function(e){delete this[e],s._triggerMethod(this,"remove:region",arguments)})},_initChannel:function(){this.channelName=i.result(this,"channelName")||"global",this.channel=i.result(this,"channel")||t.Wreqr.radio.channel(this.channelName),this.vent=i.result(this,"vent")||this.channel.vent,this.commands=i.result(this,"commands")||this.channel.commands,this.reqres=i.result(this,"reqres")||this.channel.reqres}}),s.Module=function(e,t,n){this.moduleName=e,this.options=i.extend({},this.options,n),this.initialize=n.initialize||this.initialize,this.submodules={},this._setupInitializersAndFinalizers(),this.app=t,i.isFunction(this.initialize)&&this.initialize(e,t,this.options)},s.Module.extend=s.extend,i.extend(s.Module.prototype,t.Events,{startWithParent:!0,initialize:function(){},addInitializer:function(e){this._initializerCallbacks.add(e)},addFinalizer:function(e){this._finalizerCallbacks.add(e)},start:function(e){this._isInitialized||(i.each(this.submodules,function(t){t.startWithParent&&t.start(e)}),this.triggerMethod("before:start",e),this._initializerCallbacks.run(e,this),this._isInitialized=!0,this.triggerMethod("start",e))},stop:function(){this._isInitialized&&(this._isInitialized=!1,this.triggerMethod("before:stop"),i.invoke(this.submodules,"stop"),this._finalizerCallbacks.run(void 0,this),this._initializerCallbacks.reset(),this._finalizerCallbacks.reset(),this.triggerMethod("stop"))},addDefinition:function(e,t){this._runModuleDefinition(e,t)},_runModuleDefinition:function(e,n){if(e){var r=i.flatten([this,this.app,t,s,t.$,i,n]);e.apply(this,r)}},_setupInitializersAndFinalizers:function(){this._initializerCallbacks=new s.Callbacks,this._finalizerCallbacks=new s.Callbacks},triggerMethod:s.triggerMethod}),i.extend(s.Module,{create:function(e,t,n){var r=e,s=i.drop(arguments,3);t=t.split(".");var o=t.length,h=[];return h[o-1]=n,i.each(t,function(t,i){var o=r;r=this._getModule(o,t,e,n),this._addModuleDefinition(o,r,h[i],s)},this),r},_getModule:function(e,t,n,r){var s=i.extend({},r),o=this.getClass(r),h=e[t];return h||(h=new o(t,n,s),e[t]=h,e.submodules[t]=h),h},getClass:function(e){var t=s.Module;return e?e.prototype instanceof t?e:e.moduleClass||t:t},_addModuleDefinition:function(e,t,i,n){var r=this._getDefine(i),s=this._getStartWithParent(i,t);r&&t.addDefinition(r,n),this._addStartWithParent(e,t,s)},_getStartWithParent:function(e,t){var n;return i.isFunction(e)&&e.prototype instanceof s.Module?(n=t.constructor.prototype.startWithParent,i.isUndefined(n)?!0:n):i.isObject(e)?(n=e.startWithParent,i.isUndefined(n)?!0:n):!0},_getDefine:function(e){return!i.isFunction(e)||e.prototype instanceof s.Module?i.isObject(e)?e.define:null:e},_addStartWithParent:function(e,t,i){t.startWithParent=t.startWithParent&&i,t.startWithParent&&!t.startWithParentIsConfigured&&(t.startWithParentIsConfigured=!0,e.addInitializer(function(e){t.startWithParent&&t.start(e)}))}}),s}); //@ sourceMappingURL=backbone.marionette.map \ No newline at end of file diff --git a/lib/core/backbone.marionette.js b/lib/core/backbone.marionette.js index 9fdbc911bd..fdae85a10e 100644 --- a/lib/core/backbone.marionette.js +++ b/lib/core/backbone.marionette.js @@ -1,6 +1,6 @@ // MarionetteJS (Backbone.Marionette) // ---------------------------------- -// v2.3.2 +// v2.4.0 // // Copyright (c)2015 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license @@ -31,7 +31,7 @@ var Marionette = Backbone.Marionette = {}; - Marionette.VERSION = '2.3.2'; + Marionette.VERSION = '2.4.0'; Marionette.noConflict = function() { root.Marionette = previousMarionette; @@ -42,6 +42,13 @@ // Get the Deferred creator for later use Marionette.Deferred = Backbone.$.Deferred; + Marionette.FEATURES = { + }; + + Marionette.isEnabled = function(name) { + return !!Marionette.FEATURES[name]; + }; + /* jshint unused: false *//* global console */ // Helpers @@ -61,6 +68,11 @@ return Backbone.$.contains(document.documentElement, el); }; + // Merge `keys` from `options` onto `this` + Marionette.mergeOptions = function(options, keys) { + if (!options) { return; } + _.extend(this, _.pick(options, keys)); + }; // Marionette.getOption // -------------------- @@ -87,11 +99,7 @@ // undefined return a default value Marionette._getValue = function(value, context, params) { if (_.isFunction(value)) { - // We need to ensure that params is not undefined - // to prevent `apply` from failing in ie8 - params = params || []; - - value = value.apply(context, params); + value = params ? value.apply(context, params) : value.call(context); } return value; }; @@ -136,11 +144,21 @@ // allows for the use of the @ui. syntax within // a given value for regions // swaps the @ui with the associated selector - Marionette.normalizeUIValues = function(hash, ui) { + Marionette.normalizeUIValues = function(hash, ui, properties) { _.each(hash, function(val, key) { if (_.isString(val)) { hash[key] = Marionette.normalizeUIString(val, ui); } + else if (_.isObject(val) && _.isArray(properties)) { + _.extend(val, Marionette.normalizeUIValues(_.pick(val, properties), ui)); + /* Value is an object, and we got an array of embedded property names to normalize. */ + _.each(properties, function(property) { + var propertyVal = val[property]; + if (_.isString(propertyVal)) { + val[property] = Marionette.normalizeUIString(propertyVal, ui); + } + }); + } }); return hash; }; @@ -219,7 +237,7 @@ // trigger the event, if a trigger method exists if (_.isFunction(context.trigger)) { if (noEventArg + args.length > 1) { - context.trigger.apply(context, noEventArg ? args : [event].concat(_.rest(args, 0))); + context.trigger.apply(context, noEventArg ? args : [event].concat(_.drop(args, 0))); } else { context.trigger(event); } @@ -521,6 +539,9 @@ // methods if the method exists triggerMethod: Marionette.triggerMethod, + // A handy way to merge options onto the instance + mergeOptions: Marionette.mergeOptions, + // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption @@ -552,12 +573,17 @@ this.triggerMethod('before:destroy'); this.triggerMethod('destroy'); this.stopListening(); + + return this; }, // Import the `triggerMethod` to trigger events with corresponding // methods if the method exists triggerMethod: Marionette.triggerMethod, + // A handy way to merge options onto the instance + mergeOptions: Marionette.mergeOptions, + // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption, @@ -772,20 +798,28 @@ // Destroy the current view, if there is one. If there is no // current view, it does nothing and returns immediately. - empty: function() { + empty: function(options) { var view = this.currentView; + var preventDestroy = Marionette._getValue(options, 'preventDestroy', this); // If there is no view in the region // we should not remove anything if (!view) { return; } view.off('destroy', this.empty, this); this.triggerMethod('before:empty', view); - this._destroyView(); + if (!preventDestroy) { + this._destroyView(); + } this.triggerMethod('empty', view); // Remove region pointer to the currentView delete this.currentView; + + if (preventDestroy) { + this.$el.contents().detach(); + } + return this; }, @@ -908,6 +942,7 @@ Marionette.RegionManager = Marionette.Controller.extend({ constructor: function(options) { this._regions = {}; + this.length = 0; Marionette.Controller.call(this, options); @@ -1001,8 +1036,11 @@ // internal method to store regions _store: function(name, region) { + if (!this._regions[name]) { + this.length++; + } + this._regions[name] = region; - this._setLength(); }, // internal method to remove a region @@ -1013,13 +1051,8 @@ delete region._parent; delete this._regions[name]; - this._setLength(); + this.length--; this.triggerMethod('remove:region', name, region); - }, - - // set the number of regions current held - _setLength: function() { - this.length = _.size(this._regions); } }); @@ -1044,7 +1077,7 @@ // Get the specified template by id. Either // retrieves the cached version, or loads it // from the DOM. - get: function(templateId) { + get: function(templateId, options) { var cachedTemplate = this.templateCaches[templateId]; if (!cachedTemplate) { @@ -1052,7 +1085,7 @@ this.templateCaches[templateId] = cachedTemplate; } - return cachedTemplate.load(); + return cachedTemplate.load(options); }, // Clear templates from the cache. If no arguments @@ -1083,15 +1116,15 @@ _.extend(Marionette.TemplateCache.prototype, { // Internal method to load the template - load: function() { + load: function(options) { // Guard clause to prevent loading this template more than once if (this.compiledTemplate) { return this.compiledTemplate; } // Load the template and compile it - var template = this.loadTemplate(this.templateId); - this.compiledTemplate = this.compileTemplate(template); + var template = this.loadTemplate(this.templateId, options); + this.compiledTemplate = this.compileTemplate(template, options); return this.compiledTemplate; }, @@ -1101,7 +1134,7 @@ // For asynchronous loading with AMD/RequireJS, consider // using a template-loader plugin as described here: // https://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs - loadTemplate: function(templateId) { + loadTemplate: function(templateId, options) { var template = Backbone.$(templateId).html(); if (!template || template.length === 0) { @@ -1118,8 +1151,8 @@ // this method if you do not need to pre-compile a template // (JST / RequireJS for example) or if you want to change // the template engine used (Handebars, etc). - compileTemplate: function(rawTemplate) { - return _.template(rawTemplate); + compileTemplate: function(rawTemplate, options) { + return _.template(rawTemplate, options); } }); @@ -1170,10 +1203,9 @@ this._behaviors = Marionette.Behaviors(this); - Backbone.View.apply(this, arguments); + Backbone.View.call(this, this.options); Marionette.MonitorDOMRefresh(this); - this.on('show', this.onShowCalled); }, // Get the template for this view @@ -1211,10 +1243,10 @@ // normalize the values of passed hash with the views `ui` selectors. // `{foo: "@ui.bar"}` - normalizeUIValues: function(hash) { + normalizeUIValues: function(hash, properties) { var ui = _.result(this, 'ui'); var uiBindings = _.result(this, '_uiBindings'); - return Marionette.normalizeUIValues(hash, uiBindings || ui); + return Marionette.normalizeUIValues(hash, uiBindings || ui, properties); }, // Configure `triggers` to forward DOM events to view @@ -1285,9 +1317,6 @@ return this; }, - // Internal method, handles the `show` event. - onShowCalled: function() {}, - // Internal helper method to verify whether the view hasn't been destroyed _ensureViewIsIntact: function() { if (this.isDestroyed) { @@ -1303,7 +1332,7 @@ // for you. You can specify an `onDestroy` method in your view to // add custom code that is called after the view is destroyed. destroy: function() { - if (this.isDestroyed) { return; } + if (this.isDestroyed) { return this; } var args = _.toArray(arguments); @@ -1318,6 +1347,8 @@ // unbind UI elements this.unbindUIElements(); + this.isRendered = false; + // remove the view from the DOM this.remove(); @@ -1424,15 +1455,42 @@ // import the `triggerMethod` to trigger events with corresponding // methods if the method exists triggerMethod: function() { + var ret = Marionette._triggerMethod(this, arguments); + + this._triggerEventOnBehaviors(arguments); + this._triggerEventOnParentLayout(arguments[0], _.rest(arguments)); + + return ret; + }, + + _triggerEventOnBehaviors: function(args) { var triggerMethod = Marionette._triggerMethod; - var ret = triggerMethod(this, arguments); var behaviors = this._behaviors; // Use good ol' for as this is a very hot function for (var i = 0, length = behaviors && behaviors.length; i < length; i++) { - triggerMethod(behaviors[i], arguments); + triggerMethod(behaviors[i], args); } + }, - return ret; + _triggerEventOnParentLayout: function(eventName, args) { + var layoutView = this._parentLayoutView(); + if (!layoutView) { + return; + } + + // invoke triggerMethod on parent view + var eventPrefix = Marionette.getOption(layoutView, 'childViewEventPrefix'); + var prefixedEventName = eventPrefix + ':' + eventName; + + Marionette._triggerMethod(layoutView, [prefixedEventName, this].concat(args)); + + // call the parent view's childEvents handler + var childEvents = Marionette.getOption(layoutView, 'childEvents'); + var normalizedChildEvents = layoutView.normalizeMethods(childEvents); + + if (!!normalizedChildEvents && _.isFunction(normalizedChildEvents[eventName])) { + normalizedChildEvents[eventName].apply(layoutView, [this].concat(args)); + } }, // This method returns any views that are immediate @@ -1453,10 +1511,35 @@ }, children); }, + // Internal utility for building an ancestor + // view tree list. + _getAncestors: function() { + var ancestors = []; + var parent = this._parent; + + while (parent) { + ancestors.push(parent); + parent = parent._parent; + } + + return ancestors; + }, + + // Returns the containing parent view. + _parentLayoutView: function() { + var ancestors = this._getAncestors(); + return _.find(ancestors, function(parent) { + return parent instanceof Marionette.LayoutView; + }); + }, + // Imports the "normalizeMethods" to transform hashes of // events=>function references/names to a hash of events=>function references normalizeMethods: Marionette.normalizeMethods, + // A handy way to merge passed-in options onto the instance + mergeOptions: Marionette.mergeOptions, + // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption, @@ -1523,6 +1606,7 @@ this.triggerMethod('before:render', this); this._renderTemplate(); + this.isRendered = true; this.bindUIElements(); this.triggerMethod('render', this); @@ -1550,8 +1634,7 @@ } // Add in entity data and template helpers - var data = this.serializeData(); - data = this.mixinTemplateHelpers(data); + var data = this.mixinTemplateHelpers(this.serializeData()); // Render and add to el var html = Marionette.Renderer.render(template, data, this); @@ -1592,21 +1675,25 @@ // that are forwarded through the collectionview childViewEventPrefix: 'childview', + // flag for maintaining the sorted order of the collection + sort: true, + // constructor // option to pass `{sort: false}` to prevent the `CollectionView` from // maintaining the sorted order of the collection. // This will fallback onto appending childView's to the end. + // + // option to pass `{comparator: compFunction()}` to allow the `CollectionView` + // to use a custom sort order for the collection. constructor: function(options){ - var initOptions = options || {}; - if (_.isUndefined(this.sort)){ - this.sort = _.isUndefined(initOptions.sort) ? true : initOptions.sort; - } this.once('render', this._initialEvents); this._initChildViewStorage(); Marionette.View.apply(this, arguments); + this.on('show', this._onShowCalled); + this.initRenderBuffer(); }, @@ -1614,7 +1701,6 @@ // it's much more performant to insert elements into a document // fragment and then insert that document fragment into the page initRenderBuffer: function() { - this.elBuffer = document.createDocumentFragment(); this._bufferedChildren = []; }, @@ -1626,7 +1712,9 @@ endBuffering: function() { this.isBuffering = false; this._triggerBeforeShowBufferedChildren(); - this.attachBuffer(this, this.elBuffer); + + this.attachBuffer(this); + this._triggerShowBufferedChildren(); this.initRenderBuffer(); }, @@ -1659,18 +1747,26 @@ this.listenTo(this.collection, 'remove', this._onCollectionRemove); this.listenTo(this.collection, 'reset', this.render); - if (this.sort) { + if (this.getOption('sort')) { this.listenTo(this.collection, 'sort', this._sortViews); } } }, // Handle a child added to the collection - _onCollectionAdd: function(child) { - this.destroyEmptyView(); - var ChildView = this.getChildView(child); - var index = this.collection.indexOf(child); - this.addChild(child, ChildView, index); + _onCollectionAdd: function(child, collection, opts) { + var index; + if (opts.at !== undefined) { + index = opts.at; + } else { + index = _.indexOf(this._filteredSortedModels(), child); + } + + if (this._shouldAddChild(child, index)) { + this.destroyEmptyView(); + var ChildView = this.getChildView(child); + this.addChild(child, ChildView, index); + } }, // get the child view by model it holds, and remove it @@ -1680,8 +1776,7 @@ this.checkEmpty(); }, - // Override from `Marionette.View` to trigger show on child views - onShowCalled: function() { + _onShowCalled: function() { this.children.each(_.partial(this._triggerMethodOnChild, 'show')); }, @@ -1692,23 +1787,60 @@ this._ensureViewIsIntact(); this.triggerMethod('before:render', this); this._renderChildren(); + this.isRendered = true; this.triggerMethod('render', this); return this; }, + // Reorder DOM after sorting. When your element's rendering + // do not use their index, you can pass reorderOnSort: true + // to only reorder the DOM after a sort instead of rendering + // all the collectionView + reorder: function () { + var children = this.children; + var models = this._filteredSortedModels(); + var modelsChanged = _.find(models, function (model) { + return !children.findByModel(model); + }); + + // If the models we're displaying have changed due to filtering + // We need to add and/or remove child views + // So render as normal + if (modelsChanged) { + this.render(); + } else { + // get the DOM nodes in the same order as the models + var els = _.map(models, function (model) { + return children.findByModel(model).el; + }); + + // since append moves elements that are already in the DOM, + // appending the elements will effectively reorder them + this.triggerMethod('before:reorder'); + this.$el.append(els); + this.triggerMethod('reorder'); + } + }, + // Render view after sorting. Override this method to // change how the view renders after a `sort` on the collection. // An example of this would be to only `renderChildren` in a `CompositeView` // rather than the full view. resortView: function() { - this.render(); + if (Marionette.getOption(this, 'reorderOnSort')) { + this.reorder(); + } else { + this.render(); + } }, // Internal method. This checks for any changes in the order of the collection. // If the index of any view doesn't match, it will render. _sortViews: function() { + var models = this._filteredSortedModels(); + // check for any changes in sort order of views - var orderChanged = this.collection.find(function(item, index){ + var orderChanged = _.find(models, function(item, index){ var view = this.children.findByModel(item); return !view || view._index !== index; }, this); @@ -1736,18 +1868,51 @@ this.showCollection(); this.endBuffering(); this.triggerMethod('render:collection', this); + + // If we have shown children and none have passed the filter, show the empty view + if (this.children.isEmpty()) { + this.showEmptyView(); + } } }, // Internal method to loop through collection and show each child view. showCollection: function() { var ChildView; - this.collection.each(function(child, index) { + + var models = this._filteredSortedModels(); + + _.each(models, function(child, index) { ChildView = this.getChildView(child); this.addChild(child, ChildView, index); }, this); }, + // Allow the collection to be sorted by a custom view comparator + _filteredSortedModels: function() { + var models; + var viewComparator = this.getViewComparator(); + + if (viewComparator) { + if (_.isString(viewComparator) || viewComparator.length === 1) { + models = this.collection.sortBy(viewComparator, this); + } else { + models = _.clone(this.collection.models).sort(_.bind(viewComparator, this)); + } + } else { + models = this.collection.models; + } + + // Filter after sorting in case the filter uses the index + if (this.getOption('filter')) { + models = _.filter(models, function (model, index) { + return this._shouldAddChild(model, index); + }, this); + } + + return models; + }, + // Internal method to show an empty view in place of // a collection of child views, when the collection is empty showEmptyView: function() { @@ -1866,7 +2031,7 @@ // Internal method. This decrements or increments the indices of views after the // added/removed view to keep in sync with the collection. _updateIndices: function(view, increment, index) { - if (!this.sort) { + if (!this.getOption('sort')) { return; } @@ -1892,6 +2057,12 @@ this.triggerMethod('before:add:child', view); + // trigger the 'before:show' event on `view` if the collection view + // has already been shown + if (this._isShown && !this.isBuffering) { + Marionette.triggerMethodOn(view, 'before:show'); + } + // Store the child view itself so we can properly // remove and/or destroy it later this.children.add(view); @@ -1954,8 +2125,17 @@ }, // You might need to override this if you've overridden attachHtml - attachBuffer: function(collectionView, buffer) { - collectionView.$el.append(buffer); + attachBuffer: function(collectionView) { + collectionView.$el.append(this._createBuffer(collectionView)); + }, + + // Create a fragment buffer from the currently buffered children + _createBuffer: function(collectionView) { + var elBuffer = document.createDocumentFragment(); + _.each(collectionView._bufferedChildren, function(b) { + elBuffer.appendChild(b.el); + }); + return elBuffer; }, // Append the HTML to the collection's `el`. @@ -1966,8 +2146,7 @@ // buffering happens on reset events and initial renders // in order to reduce the number of inserts into the // document, which are expensive. - collectionView.elBuffer.appendChild(childView.el); - collectionView._bufferedChildren.push(childView); + collectionView._bufferedChildren.splice(index, 0, childView); } else { // If we've already rendered the main collection, append @@ -1983,7 +2162,7 @@ // the correct position. _insertBefore: function(childView, index) { var currentView; - var findPosition = this.sort && (index < this.children.length - 1); + var findPosition = this.getOption('sort') && (index < this.children.length - 1); if (findPosition) { // Find the view after this one currentView = this.children.find(function (view) { @@ -2012,7 +2191,7 @@ // Handle cleanup and other destroying needs for the collection of views destroy: function() { - if (this.isDestroyed) { return; } + if (this.isDestroyed) { return this; } this.triggerMethod('before:destroy:collection'); this.destroyChildren(); @@ -2030,6 +2209,18 @@ return childViews; }, + // Return true if the given child should be shown + // Return false otherwise + // The filter will be passed (child, index, collection) + // Where + // 'child' is the given model + // 'index' is the index of that model in the collection + // 'collection' is the collection referenced by this CollectionView + _shouldAddChild: function (child, index) { + var filter = this.getOption('filter'); + return !_.isFunction(filter) || filter.call(this, child, index, this.collection); + }, + // Set up the child view event forwarding. Uses a "childview:" // prefix in front of all forwarded events. proxyChildEvents: function(view) { @@ -2051,11 +2242,15 @@ } this.triggerMethod.apply(this, args); - }, this); + }); }, _getImmediateChildren: function() { return _.values(this.children._views); + }, + + getViewComparator: function() { + return this.getOption('viewComparator'); } }); @@ -2091,7 +2286,7 @@ this.listenTo(this.collection, 'remove', this._onCollectionRemove); this.listenTo(this.collection, 'reset', this._renderChildren); - if (this.sort) { + if (this.getOption('sort')) { this.listenTo(this.collection, 'sort', this._sortViews); } } @@ -2123,7 +2318,7 @@ // Renders the model and the collection. render: function() { this._ensureViewIsIntact(); - this.isRendered = true; + this._isRendering = true; this.resetChildViewContainer(); this.triggerMethod('before:render', this); @@ -2131,12 +2326,14 @@ this._renderTemplate(); this._renderChildren(); + this._isRendering = false; + this.isRendered = true; this.triggerMethod('render', this); return this; }, _renderChildren: function() { - if (this.isRendered) { + if (this.isRendered || this._isRendering) { Marionette.CollectionView.prototype._renderChildren.call(this); } }, @@ -2180,9 +2377,9 @@ }, // You might need to override this if you've overridden attachHtml - attachBuffer: function(compositeView, buffer) { + attachBuffer: function(compositeView) { var $container = this.getChildViewContainer(compositeView); - $container.append(buffer); + $container.append(this._createBuffer(compositeView)); }, // Internal method. Append a view to the end of the $el. @@ -2247,6 +2444,14 @@ Marionette.LayoutView = Marionette.ItemView.extend({ regionClass: Marionette.Region, + options: { + destroyImmediate: false + }, + + // used as the prefix for child view events + // that are forwarded through the layoutview + childViewEventPrefix: 'childview', + // Ensure the regions are available when the `initialize` method // is called. constructor: function(options) { @@ -2281,11 +2486,23 @@ // Handle destroying regions, and then destroy the view itself. destroy: function() { if (this.isDestroyed) { return this; } - + // #2134: remove parent element before destroying the child views, so + // removing the child views doesn't retrigger repaints + if(this.getOption('destroyImmediate') === true) { + this.$el.remove(); + } this.regionManager.destroy(); return Marionette.ItemView.prototype.destroy.apply(this, arguments); }, + showChildView: function(regionName, view) { + return this.getRegion(regionName).show(view); + }, + + getChildView: function(regionName) { + return this.getRegion(regionName).currentView; + }, + // Add a single region, by name, to the layoutView addRegion: function(name, definition) { var regions = {}; @@ -2345,7 +2562,7 @@ // Normalize region selectors hash to allow // a user to use the @ui. syntax. - regions = this.normalizeUIValues(regions); + regions = this.normalizeUIValues(regions, ['selector', 'el']); this.addRegions(regions); }, @@ -2414,6 +2631,12 @@ this.view = view; this.defaults = _.result(this, 'defaults') || {}; this.options = _.extend({}, this.defaults, options); + // Construct an internal UI hash using + // the views UI hash and then the behaviors UI hash. + // This allows the user to use UI hash elements + // defined in the parent view as well as those + // defined in the given behavior. + this.ui = _.extend({}, _.result(view, 'ui'), _.result(this, 'ui')); Marionette.Object.apply(this, arguments); }, @@ -2429,6 +2652,8 @@ // Overrides Object#destroy to prevent additional events from being triggered. destroy: function() { this.stopListening(); + + return this; }, proxyViewProperties: function (view) { @@ -2476,23 +2701,15 @@ behaviorEvents: function(behaviorEvents, behaviors) { var _behaviorsEvents = {}; - var viewUI = this._uiBindings || _.result(this, 'ui'); _.each(behaviors, function(b, i) { var _events = {}; var behaviorEvents = _.clone(_.result(b, 'events')) || {}; - var behaviorUI = b._uiBindings || _.result(b, 'ui'); - // Construct an internal UI hash first using - // the views UI hash and then the behaviors UI hash. - // This allows the user to use UI hash elements - // defined in the parent view as well as those - // defined in the given behavior. - var ui = _.extend({}, viewUI, behaviorUI); // Normalize behavior events hash to allow // a user to use the @ui. syntax. - behaviorEvents = Marionette.normalizeUIKeys(behaviorEvents, ui); + behaviorEvents = Marionette.normalizeUIKeys(behaviorEvents, getBehaviorsUI(b)); var j = 0; _.each(behaviorEvents, function(behaviour, key) { @@ -2579,7 +2796,6 @@ // for views function BehaviorTriggersBuilder(view, behaviors) { this._view = view; - this._viewUI = _.result(view, 'ui'); this._behaviors = behaviors; this._triggers = {}; } @@ -2593,10 +2809,9 @@ // Internal method to build all trigger handlers for a given behavior _buildTriggerHandlersForBehavior: function(behavior, i) { - var ui = _.extend({}, this._viewUI, _.result(behavior, 'ui')); var triggersHash = _.clone(_.result(behavior, 'triggers')) || {}; - triggersHash = Marionette.normalizeUIKeys(triggersHash, ui); + triggersHash = Marionette.normalizeUIKeys(triggersHash, getBehaviorsUI(behavior)); _.each(triggersHash, _.bind(this._setHandlerForBehavior, this, behavior, i)); }, @@ -2613,6 +2828,10 @@ } }); + function getBehaviorsUI(behavior) { + return behavior._uiBindings || behavior.ui; + } + return Behaviors; })(Marionette, _); @@ -2694,6 +2913,8 @@ this.route(route, methodName, _.bind(method, controller)); }, + mergeOptions: Marionette.mergeOptions, + // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption, @@ -3001,7 +3222,7 @@ // get the custom args passed in after the module definition and // get rid of the module name and definition function - var customArgs = _.rest(arguments, 3); + var customArgs = _.drop(arguments, 3); // Split the module names and get the number of submodules. // i.e. an example module name of `Doge.Wow.Amaze` would diff --git a/lib/core/backbone.marionette.map b/lib/core/backbone.marionette.map index dd753104d3..c874a64af8 100644 --- a/lib/core/backbone.marionette.map +++ b/lib/core/backbone.marionette.map @@ -1 +1 @@ -{"version":3,"sources":["core/backbone.marionette.js"],"names":["root","factory","define","amd","Backbone","_","Marionette","Mn","exports","require","module","this","previousMarionette","previousMn","VERSION","noConflict","Deferred","$","extend","Model","isNodeAttached","el","contains","document","documentElement","getOption","target","optionName","options","undefined","proxyGetOption","_getValue","value","context","params","isFunction","apply","normalizeMethods","hash","reduce","normalizedHash","method","name","normalizeUIString","uiString","ui","replace","r","slice","normalizeUIKeys","memo","val","key","normalizedKey","normalizeUIValues","each","isString","actAsCollection","object","listProperty","methods","list","values","result","args","concat","toArray","arguments","deprecate","message","test","isObject","prev","next","url","_cache","_warn","console","warn","log","_triggerMethod","getEventName","match","prefix","eventName","toUpperCase","splitter","event","noEventArg","length","methodName","rest","trigger","triggerMethod","triggerMethodOn","fnc","MonitorDOMRefresh","view","handleShow","_isShown","triggerDOMRefresh","handleRender","_isRendered","on","show","render","bindFromStrings","entity","evt","methodNames","split","Error","listenTo","bindToFunction","unbindFromStrings","stopListening","unbindToFunction","iterateEvents","bindings","functionCallback","stringCallback","bindEntityEvents","unbindEntityEvents","proxyBindEntityEvents","proxyUnbindEntityEvents","errorProps","call","urlRoot","constructor","error","pick","captureStackTrace","toString","Callbacks","_deferred","_callbacks","prototype","add","callback","contextOverride","promise","push","cb","ctx","then","run","resolve","reset","callbacks","Controller","initialize","Events","destroy","off","Object","Region","$el","getEl","_ensureElement","_ensureViewIsIntact","showOptions","isDifferentView","currentView","preventDestroy","forceShow","isChangingView","_shouldDestroyView","_shouldShowView","_parent","empty","once","attachedRegion","displayedViews","triggerBeforeAttach","triggerAttach","_displayedViews","_triggerAttach","attachHtml","views","union","selector","isDestroyed","cid","parentEl","contents","detach","appendChild","_destroyView","remove","attachView","hasView","buildRegion","regionConfig","DefaultRegionClass","_buildRegionFromSelector","regionClass","_buildRegionFromObject","_buildRegionFromRegionClass","RegionClass","omit","RegionManager","_regions","addRegions","regionDefinitions","defaults","regions","definition","addRegion","region","_store","get","getRegions","clone","removeRegion","_remove","removeRegions","emptyRegions","invoke","_setLength","size","TemplateCache","templateId","templateCaches","cachedTemplate","load","clear","i","compiledTemplate","template","loadTemplate","compileTemplate","html","rawTemplate","Renderer","data","templateFunc","View","bindAll","_behaviors","Behaviors","onShowCalled","getTemplate","serializeModel","model","toJSON","mixinTemplateHelpers","templateHelpers","uiBindings","configureTriggers","triggers","events","_buildViewTrigger","delegateEvents","_delegateDOMEvents","collection","behavior","eventsArg","isUndefined","combinedEvents","behaviorEvents","behaviorTriggers","undelegateEvents","unbindUIElements","bindUIElements","_bindUIElements","_uiBindings","_unbindUIElements","triggerDef","hasOptions","preventDefault","stopPropagation","e","setElement","ret","behaviors","_getImmediateChildren","_getNestedViews","children","ItemView","serializeData","items","serializeCollection","_renderTemplate","attachElContent","CollectionView","childViewEventPrefix","initOptions","sort","_initialEvents","_initChildViewStorage","initRenderBuffer","elBuffer","createDocumentFragment","_bufferedChildren","startBuffering","isBuffering","endBuffering","_triggerBeforeShowBufferedChildren","attachBuffer","_triggerShowBufferedChildren","partial","_triggerMethodOnChild","childView","_onCollectionAdd","_onCollectionRemove","_sortViews","child","destroyEmptyView","ChildView","getChildView","index","indexOf","addChild","findByModel","removeChildView","checkEmpty","_renderChildren","resortView","orderChanged","find","item","_index","_emptyViewIndex","destroyChildren","isEmpty","showEmptyView","showCollection","EmptyView","getEmptyView","_showingEmptyView","addEmptyView","emptyViewOptions","buildChildView","proxyChildEvents","renderChildView","childViewOptions","_updateIndices","_addChildView","increment","laterView","ChildViewClass","collectionView","buffer","append","_insertBefore","_insertAfter","findPosition","before","ChildViewContainer","childViews","map","identity","rootEvent","childEvents","splice","_views","CompositeView","isRendered","resetChildViewContainer","compositeView","$container","getChildViewContainer","containerView","$childViewContainer","container","childViewContainer","charAt","substr","LayoutView","_firstRender","_initializeRegions","_reInitializeRegions","regionManager","_buildRegions","getRegion","_initRegionManager","regionOptions","getRegionManager","chain","pluck","compact","Behavior","proxyViewProperties","parseBehaviors","wrap","keys","BehaviorTriggersBuilder","_view","_viewUI","_triggers","delegateEventSplitter","triggerBuilder","buildBehaviorTriggers","_behaviorsEvents","viewUI","b","_events","behaviorUI","j","behaviour","join","eventKey","handler","bind","behaviorsLookup","getBehaviorClass","behaviorClass","BehaviorClass","nestedBehaviors","flatten","_buildTriggerHandlersForBehavior","triggersHash","_setHandlerForBehavior","triggerKey","triggerName","AppRouter","Router","appRoutes","controller","_getController","processAppRoutes","_processOnRoute","appRoute","route","_addAppRoute","routeName","routeArgs","onRoute","routePath","invert","routeNames","reverse","Application","_initCallbacks","submodules","_initChannel","execute","commands","request","reqres","addInitializer","initializer","start","_regionManager","moduleNames","moduleDefinition","ModuleClass","Module","getClass","unshift","create","optionRegions","channelName","channel","Wreqr","radio","vent","moduleName","app","_setupInitializersAndFinalizers","startWithParent","_initializerCallbacks","addFinalizer","_finalizerCallbacks","_isInitialized","mod","stop","addDefinition","customArgs","_runModuleDefinition","moduleDefinitions","parentModule","_getModule","_addModuleDefinition","def","moduleClass","fn","_getDefine","_getStartWithParent","_addStartWithParent","swp","startWithParentIsConfigured"],"mappings":"CASC,SAASA,EAAMC,GAE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EAAOud,8BAIxCvd,EAAOud,6BAA8B,EAErCV,EAAa/B,eAAe,SAAS5Z,GAC/BlB,EAAOkc,iBACTlc,EAAOgb,MAAM9Z,SAOdtB","file":"lib/core/backbone.marionette.min.js"} \ No newline at end of file +{"version":3,"sources":["core/backbone.marionette.js"],"names":["root","factory","define","amd","Backbone","_","Marionette","Mn","exports","require","module","this","previousMarionette","previousMn","VERSION","noConflict","Deferred","$","FEATURES","isEnabled","name","extend","Model","isNodeAttached","el","contains","document","documentElement","mergeOptions","options","keys","pick","getOption","target","optionName","undefined","proxyGetOption","_getValue","value","context","params","isFunction","apply","call","normalizeMethods","hash","reduce","normalizedHash","method","normalizeUIString","uiString","ui","replace","r","slice","normalizeUIKeys","memo","val","key","normalizedKey","normalizeUIValues","properties","each","isString","isObject","isArray","property","propertyVal","actAsCollection","object","listProperty","methods","list","values","result","args","concat","toArray","arguments","deprecate","message","test","prev","next","url","_cache","_warn","console","warn","log","_triggerMethod","getEventName","match","prefix","eventName","toUpperCase","splitter","event","noEventArg","length","methodName","rest","trigger","drop","triggerMethod","triggerMethodOn","fnc","MonitorDOMRefresh","view","handleShow","_isShown","triggerDOMRefresh","handleRender","_isRendered","on","show","render","bindFromStrings","entity","evt","methodNames","split","Error","listenTo","bindToFunction","unbindFromStrings","stopListening","unbindToFunction","iterateEvents","bindings","functionCallback","stringCallback","bindEntityEvents","unbindEntityEvents","proxyBindEntityEvents","proxyUnbindEntityEvents","errorProps","urlRoot","constructor","error","captureStackTrace","toString","Callbacks","_deferred","_callbacks","prototype","add","callback","contextOverride","promise","push","cb","ctx","then","run","resolve","reset","callbacks","Controller","initialize","Events","destroy","off","Object","Region","$el","getEl","_ensureElement","_ensureViewIsIntact","showOptions","isDifferentView","currentView","preventDestroy","forceShow","isChangingView","_shouldDestroyView","_shouldShowView","_parent","empty","once","attachedRegion","displayedViews","triggerBeforeAttach","triggerAttach","_displayedViews","_triggerAttach","attachHtml","views","union","selector","isDestroyed","cid","parentEl","contents","detach","appendChild","_destroyView","remove","attachView","hasView","buildRegion","regionConfig","DefaultRegionClass","_buildRegionFromSelector","regionClass","_buildRegionFromObject","_buildRegionFromRegionClass","RegionClass","omit","RegionManager","_regions","addRegions","regionDefinitions","defaults","regions","definition","addRegion","region","_store","get","getRegions","clone","removeRegion","_remove","removeRegions","emptyRegions","invoke","TemplateCache","templateId","templateCaches","cachedTemplate","load","clear","i","compiledTemplate","template","loadTemplate","compileTemplate","html","rawTemplate","Renderer","data","templateFunc","View","bindAll","_behaviors","Behaviors","getTemplate","serializeModel","model","toJSON","mixinTemplateHelpers","templateHelpers","uiBindings","configureTriggers","triggers","events","_buildViewTrigger","delegateEvents","_delegateDOMEvents","collection","behavior","eventsArg","isUndefined","combinedEvents","behaviorEvents","behaviorTriggers","undelegateEvents","unbindUIElements","isRendered","bindUIElements","_bindUIElements","_uiBindings","_unbindUIElements","triggerDef","hasOptions","preventDefault","stopPropagation","e","setElement","ret","_triggerEventOnBehaviors","_triggerEventOnParentLayout","behaviors","layoutView","_parentLayoutView","eventPrefix","prefixedEventName","childEvents","normalizedChildEvents","_getImmediateChildren","_getNestedViews","children","_getAncestors","ancestors","parent","find","LayoutView","ItemView","serializeData","items","serializeCollection","_renderTemplate","attachElContent","CollectionView","childViewEventPrefix","sort","_initialEvents","_initChildViewStorage","_onShowCalled","initRenderBuffer","_bufferedChildren","startBuffering","isBuffering","endBuffering","_triggerBeforeShowBufferedChildren","attachBuffer","_triggerShowBufferedChildren","partial","_triggerMethodOnChild","childView","_onCollectionAdd","_onCollectionRemove","_sortViews","child","opts","index","at","indexOf","_filteredSortedModels","_shouldAddChild","destroyEmptyView","ChildView","getChildView","addChild","findByModel","removeChildView","checkEmpty","_renderChildren","reorder","models","modelsChanged","els","map","append","resortView","orderChanged","item","_index","_emptyViewIndex","destroyChildren","isEmpty","showEmptyView","showCollection","viewComparator","getViewComparator","sortBy","bind","filter","EmptyView","getEmptyView","_showingEmptyView","addEmptyView","emptyViewOptions","buildChildView","proxyChildEvents","renderChildView","childViewOptions","_updateIndices","_addChildView","increment","laterView","ChildViewClass","collectionView","_createBuffer","elBuffer","createDocumentFragment","b","splice","_insertBefore","_insertAfter","findPosition","before","ChildViewContainer","childViews","identity","rootEvent","_views","CompositeView","_isRendering","resetChildViewContainer","compositeView","$container","getChildViewContainer","containerView","$childViewContainer","container","childViewContainer","charAt","substr","destroyImmediate","_firstRender","_initializeRegions","_reInitializeRegions","regionManager","showChildView","regionName","getRegion","_buildRegions","_initRegionManager","regionOptions","getRegionManager","chain","pluck","compact","Behavior","proxyViewProperties","parseBehaviors","wrap","BehaviorTriggersBuilder","_view","_triggers","getBehaviorsUI","delegateEventSplitter","triggerBuilder","buildBehaviorTriggers","_behaviorsEvents","_events","j","behaviour","join","eventKey","handler","behaviorsLookup","getBehaviorClass","behaviorClass","BehaviorClass","nestedBehaviors","flatten","_buildTriggerHandlersForBehavior","triggersHash","_setHandlerForBehavior","triggerKey","triggerName","AppRouter","Router","appRoutes","controller","_getController","processAppRoutes","_processOnRoute","appRoute","route","_addAppRoute","routeName","routeArgs","onRoute","routePath","invert","routeNames","reverse","Application","_initCallbacks","submodules","_initChannel","execute","commands","request","reqres","addInitializer","initializer","start","_regionManager","moduleNames","moduleDefinition","ModuleClass","Module","getClass","unshift","create","optionRegions","channelName","channel","Wreqr","radio","vent","moduleName","app","_setupInitializersAndFinalizers","startWithParent","_initializerCallbacks","addFinalizer","_finalizerCallbacks","_isInitialized","mod","stop","addDefinition","customArgs","_runModuleDefinition","moduleDefinitions","parentModule","_getModule","_addModuleDefinition","def","moduleClass","fn","_getDefine","_getStartWithParent","_addStartWithParent","swp","startWithParentIsConfigured"],"mappings":"CASC,SAASA,EAAMC,GAEd,GAAsB,kBAAXC,SAAyBA,OAAOC,IACzCD,QAAQ,WAAY,aAAc,iBAAkB,uBAAwB,SAASE,EAAUC,GAC7F,MAAQL,GAAKM,WAAaN,EAAKO,GAAKN,EAAQD,EAAMI,EAAUC,SAEzD,IAAuB,mBAAZ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ItW,oBAAqB3I,GAAWsd,QAC5DiC,EAAMnf,EAAOgI,YAAYO,UAAUwV,gBAC5Bpe,EAAEkQ,YAAYsP,IAAO,EAAOA,GAGjCxf,EAAE2D,SAASub,IACbM,EAAMN,EAAId,gBACHpe,EAAEkQ,YAAYsP,IAAO,EAAOA,IAG9B,GAGTH,WAAY,SAASH,GACnB,OAAIlf,EAAEoC,WAAW8c,IAAUA,EAAItW,oBAAqB3I,GAAWsd,OAI3Dvd,EAAE2D,SAASub,GACNA,EAAIrf,OAGN,KAPEqf,GAUXK,oBAAqB,SAASR,EAAc1e,EAAQ+d,GAClD/d,EAAO+d,gBAAkB/d,EAAO+d,iBAAmBA,EAE9C/d,EAAO+d,kBAAqB/d,EAAOof,8BAIxCpf,EAAOof,6BAA8B,EAErCV,EAAa/B,eAAe,SAASxb,GAC/BnB,EAAO+d,iBACT/d,EAAO6c,MAAM1b,SAOdvB","file":"lib/core/backbone.marionette.min.js"} \ No newline at end of file diff --git a/lib/core/backbone.marionette.min.js b/lib/core/backbone.marionette.min.js index bdb98850f0..58c9a19c53 100644 --- a/lib/core/backbone.marionette.min.js +++ b/lib/core/backbone.marionette.min.js @@ -1,3 +1,3 @@ -(function(e,t){if("function"==typeof define&&define.amd)define(["backbone","underscore","backbone.wreqr","backbone.babysitter"],function(i,n){return e.Marionette=e.Mn=t(e,i,n)});else if("undefined"!=typeof exports){var i=require("backbone"),n=require("underscore");require("backbone.wreqr"),require("backbone.babysitter"),module.exports=t(e,i,n)}else e.Marionette=e.Mn=t(e,e.Backbone,e._)})(this,function(e,t,i){"use strict";var n=e.Marionette,r=e.Mn,s=t.Marionette={};s.VERSION="2.3.2",s.noConflict=function(){return e.Marionette=n,e.Mn=r,this},s.Deferred=t.$.Deferred,s.extend=t.Model.extend,s.isNodeAttached=function(e){return t.$.contains(document.documentElement,e)},s.getOption=function(e,t){return e&&t?e.options&&void 0!==e.options[t]?e.options[t]:e[t]:void 0},s.proxyGetOption=function(e){return s.getOption(this,e)},s._getValue=function(e,t,n){return i.isFunction(e)&&(n=n||[],e=e.apply(t,n)),e},s.normalizeMethods=function(e){return i.reduce(e,function(e,t,n){return i.isFunction(t)||(t=this[t]),t&&(e[n]=t),e},{},this)},s.normalizeUIString=function(e,t){return e.replace(/@ui\.[a-zA-Z_$0-9]*/g,function(e){return t[e.slice(4)]})},s.normalizeUIKeys=function(e,t){return i.reduce(e,function(e,i,n){var r=s.normalizeUIString(n,t);return e[r]=i,e},{})},s.normalizeUIValues=function(e,t){return i.each(e,function(n,r){i.isString(n)&&(e[r]=s.normalizeUIString(n,t))}),e},s.actAsCollection=function(e,t){var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];i.each(n,function(n){e[n]=function(){var e=i.values(i.result(this,t)),r=[e].concat(i.toArray(arguments));return i[n].apply(i,r)}})};var o=s.deprecate=function(e,t){i.isObject(e)&&(e=e.prev+" is going to be removed in the future. "+"Please use "+e.next+" instead."+(e.url?" See: "+e.url:"")),void 0!==t&&t||o._cache[e]||(o._warn("Deprecation warning: "+e),o._cache[e]=!0)};o._warn="undefined"!=typeof console&&(console.warn||console.log)||function(){},o._cache={},s._triggerMethod=function(){function e(e,t,i){return i.toUpperCase()}var t=/(^|:)(\w)/gi;return function(n,r,s){var o=3>arguments.length;o&&(s=r,r=s[0]);var h,a="on"+r.replace(t,e),l=n[a];return i.isFunction(l)&&(h=l.apply(n,o?i.rest(s):s)),i.isFunction(n.trigger)&&(o+s.length>1?n.trigger.apply(n,o?s:[r].concat(i.rest(s,0))):n.trigger(r)),h}}(),s.triggerMethod=function(){return s._triggerMethod(this,arguments)},s.triggerMethodOn=function(e){var t=i.isFunction(e.triggerMethod)?e.triggerMethod:s.triggerMethod;return t.apply(e,i.rest(arguments))},s.MonitorDOMRefresh=function(e){function t(){e._isShown=!0,r()}function n(){e._isRendered=!0,r()}function r(){e._isShown&&e._isRendered&&s.isNodeAttached(e.el)&&i.isFunction(e.triggerMethod)&&e.triggerMethod("dom:refresh")}e.on({show:t,render:n})},function(e){function t(t,n,r,s){var o=s.split(/\s+/);i.each(o,function(i){var s=t[i];if(!s)throw new e.Error('Method "'+i+'" was configured as an event handler, but does not exist.');t.listenTo(n,r,s)})}function n(e,t,i,n){e.listenTo(t,i,n)}function r(e,t,n,r){var s=r.split(/\s+/);i.each(s,function(i){var r=e[i];e.stopListening(t,n,r)})}function s(e,t,i,n){e.stopListening(t,i,n)}function o(t,n,r,s,o){if(n&&r){if(!i.isObject(r))throw new e.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});r=e._getValue(r,t),i.each(r,function(e,r){i.isFunction(e)?s(t,n,r,e):o(t,n,r,e)})}}e.bindEntityEvents=function(e,i,r){o(e,i,r,n,t)},e.unbindEntityEvents=function(e,t,i){o(e,t,i,s,r)},e.proxyBindEntityEvents=function(t,i){return e.bindEntityEvents(this,t,i)},e.proxyUnbindEntityEvents=function(t,i){return e.unbindEntityEvents(this,t,i)}}(s);var h=["description","fileName","lineNumber","name","message","number"];return s.Error=s.extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+s.VERSION+"/",constructor:function(e,t){i.isObject(e)?(t=e,e=t.message):t||(t={});var n=Error.call(this,e);i.extend(this,i.pick(n,h),i.pick(t,h)),this.captureStackTrace(),t.url&&(this.url=this.urlRoot+t.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,s.Error)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}}),s.Error.extend=s.extend,s.Callbacks=function(){this._deferred=s.Deferred(),this._callbacks=[]},i.extend(s.Callbacks.prototype,{add:function(e,t){var n=i.result(this._deferred,"promise");this._callbacks.push({cb:e,ctx:t}),n.then(function(i){t&&(i.context=t),e.call(i.context,i.options)})},run:function(e,t){this._deferred.resolve({options:e,context:t})},reset:function(){var e=this._callbacks;this._deferred=s.Deferred(),this._callbacks=[],i.each(e,function(e){this.add(e.cb,e.ctx)},this)}}),s.Controller=function(e){this.options=e||{},i.isFunction(this.initialize)&&this.initialize(this.options)},s.Controller.extend=s.extend,i.extend(s.Controller.prototype,t.Events,{destroy:function(){return s._triggerMethod(this,"before:destroy",arguments),s._triggerMethod(this,"destroy",arguments),this.stopListening(),this.off(),this},triggerMethod:s.triggerMethod,getOption:s.proxyGetOption}),s.Object=function(e){this.options=i.extend({},i.result(this,"options"),e),this.initialize.apply(this,arguments)},s.Object.extend=s.extend,i.extend(s.Object.prototype,t.Events,{initialize:function(){},destroy:function(){this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening()},triggerMethod:s.triggerMethod,getOption:s.proxyGetOption,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.Region=s.Object.extend({constructor:function(e){if(this.options=e||{},this.el=this.getOption("el"),this.el=this.el instanceof t.$?this.el[0]:this.el,!this.el)throw new s.Error({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),s.Object.call(this,e)},show:function(e,t){if(this._ensureElement()){this._ensureViewIsIntact(e);var i=t||{},n=e!==this.currentView,r=!!i.preventDestroy,o=!!i.forceShow,h=!!this.currentView,a=n&&!r,l=n||o;if(h&&this.triggerMethod("before:swapOut",this.currentView,this,t),this.currentView&&delete this.currentView._parent,a?this.empty():h&&l&&this.currentView.off("destroy",this.empty,this),l){e.once("destroy",this.empty,this),e.render(),e._parent=this,h&&this.triggerMethod("before:swap",e,this,t),this.triggerMethod("before:show",e,this,t),s.triggerMethodOn(e,"before:show",e,this,t),h&&this.triggerMethod("swapOut",this.currentView,this,t);var u=s.isNodeAttached(this.el),d=[],c=i.triggerBeforeAttach||this.triggerBeforeAttach,g=i.triggerAttach||this.triggerAttach;return u&&c&&(d=this._displayedViews(e),this._triggerAttach(d,"before:")),this.attachHtml(e),this.currentView=e,u&&g&&(d=this._displayedViews(e),this._triggerAttach(d)),h&&this.triggerMethod("swap",e,this,t),this.triggerMethod("show",e,this,t),s.triggerMethodOn(e,"show",e,this,t),this}return this}},triggerBeforeAttach:!0,triggerAttach:!0,_triggerAttach:function(e,t){var n=(t||"")+"attach";i.each(e,function(e){s.triggerMethodOn(e,n,e,this)},this)},_displayedViews:function(e){return i.union([e],i.result(e,"_getNestedViews")||[])},_ensureElement:function(){if(i.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||0===this.$el.length){if(this.getOption("allowMissingEl"))return!1;throw new s.Error('An "el" '+this.$el.selector+" must exist in DOM")}return!0},_ensureViewIsIntact:function(e){if(!e)throw new s.Error({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(e.isDestroyed)throw new s.Error({name:"ViewDestroyedError",message:'View (cid: "'+e.cid+'") has already been destroyed and cannot be used.'})},getEl:function(e){return t.$(e,s._getValue(this.options.parentEl,this))},attachHtml:function(e){this.$el.contents().detach(),this.el.appendChild(e.el)},empty:function(){var e=this.currentView;if(e)return e.off("destroy",this.empty,this),this.triggerMethod("before:empty",e),this._destroyView(),this.triggerMethod("empty",e),delete this.currentView,this},_destroyView:function(){var e=this.currentView;e.destroy&&!e.isDestroyed?e.destroy():e.remove&&(e.remove(),e.isDestroyed=!0)},attachView:function(e){return this.currentView=e,this},hasView:function(){return!!this.currentView},reset:function(){return this.empty(),this.$el&&(this.el=this.$el.selector),delete this.$el,this}},{buildRegion:function(e,t){if(i.isString(e))return this._buildRegionFromSelector(e,t);if(e.selector||e.el||e.regionClass)return this._buildRegionFromObject(e,t);if(i.isFunction(e))return this._buildRegionFromRegionClass(e);throw new s.Error({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})},_buildRegionFromSelector:function(e,t){return new t({el:e})},_buildRegionFromObject:function(e,t){var n=e.regionClass||t,r=i.omit(e,"selector","regionClass");return e.selector&&!r.el&&(r.el=e.selector),new n(r)},_buildRegionFromRegionClass:function(e){return new e}}),s.RegionManager=s.Controller.extend({constructor:function(e){this._regions={},s.Controller.call(this,e),this.addRegions(this.getOption("regions"))},addRegions:function(e,t){return e=s._getValue(e,this,arguments),i.reduce(e,function(e,n,r){return i.isString(n)&&(n={selector:n}),n.selector&&(n=i.defaults({},n,t)),e[r]=this.addRegion(r,n),e},{},this)},addRegion:function(e,t){var i;return i=t instanceof s.Region?t:s.Region.buildRegion(t,s.Region),this.triggerMethod("before:add:region",e,i),i._parent=this,this._store(e,i),this.triggerMethod("add:region",e,i),i},get:function(e){return this._regions[e]},getRegions:function(){return i.clone(this._regions)},removeRegion:function(e){var t=this._regions[e];return this._remove(e,t),t},removeRegions:function(){var e=this.getRegions();return i.each(this._regions,function(e,t){this._remove(t,e)},this),e},emptyRegions:function(){var e=this.getRegions();return i.invoke(e,"empty"),e},destroy:function(){return this.removeRegions(),s.Controller.prototype.destroy.apply(this,arguments)},_store:function(e,t){this._regions[e]=t,this._setLength()},_remove:function(e,t){this.triggerMethod("before:remove:region",e,t),t.empty(),t.stopListening(),delete t._parent,delete this._regions[e],this._setLength(),this.triggerMethod("remove:region",e,t)},_setLength:function(){this.length=i.size(this._regions)}}),s.actAsCollection(s.RegionManager.prototype,"_regions"),s.TemplateCache=function(e){this.templateId=e},i.extend(s.TemplateCache,{templateCaches:{},get:function(e){var t=this.templateCaches[e];return t||(t=new s.TemplateCache(e),this.templateCaches[e]=t),t.load()},clear:function(){var e,t=i.toArray(arguments),n=t.length;if(n>0)for(e=0;n>e;e++)delete this.templateCaches[t[e]];else this.templateCaches={}}}),i.extend(s.TemplateCache.prototype,{load:function(){if(this.compiledTemplate)return this.compiledTemplate;var e=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(e),this.compiledTemplate},loadTemplate:function(e){var i=t.$(e).html();if(!i||0===i.length)throw new s.Error({name:"NoTemplateError",message:'Could not find template: "'+e+'"'});return i},compileTemplate:function(e){return i.template(e)}}),s.Renderer={render:function(e,t){if(!e)throw new s.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var n=i.isFunction(e)?e:s.TemplateCache.get(e);return n(t)}},s.View=t.View.extend({isDestroyed:!1,constructor:function(e){i.bindAll(this,"render"),e=s._getValue(e,this),this.options=i.extend({},i.result(this,"options"),e),this._behaviors=s.Behaviors(this),t.View.apply(this,arguments),s.MonitorDOMRefresh(this),this.on("show",this.onShowCalled)},getTemplate:function(){return this.getOption("template")},serializeModel:function(e){return e.toJSON.apply(e,i.rest(arguments))},mixinTemplateHelpers:function(e){e=e||{};var t=this.getOption("templateHelpers");return t=s._getValue(t,this),i.extend(e,t)},normalizeUIKeys:function(e){var t=i.result(this,"_uiBindings");return s.normalizeUIKeys(e,t||i.result(this,"ui"))},normalizeUIValues:function(e){var t=i.result(this,"ui"),n=i.result(this,"_uiBindings");return s.normalizeUIValues(e,n||t)},configureTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(i.result(this,"triggers"));return i.reduce(e,function(e,t,i){return e[i]=this._buildViewTrigger(t),e},{},this)}},delegateEvents:function(e){return this._delegateDOMEvents(e),this.bindEntityEvents(this.model,this.getOption("modelEvents")),this.bindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(e){e.bindEntityEvents(this.model,e.getOption("modelEvents")),e.bindEntityEvents(this.collection,e.getOption("collectionEvents"))},this),this},_delegateDOMEvents:function(e){var n=s._getValue(e||this.events,this);n=this.normalizeUIKeys(n),i.isUndefined(e)&&(this.events=n);var r={},o=i.result(this,"behaviorEvents")||{},h=this.configureTriggers(),a=i.result(this,"behaviorTriggers")||{};i.extend(r,o,n,h,a),t.View.prototype.delegateEvents.call(this,r)},undelegateEvents:function(){return t.View.prototype.undelegateEvents.apply(this,arguments),this.unbindEntityEvents(this.model,this.getOption("modelEvents")),this.unbindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(e){e.unbindEntityEvents(this.model,e.getOption("modelEvents")),e.unbindEntityEvents(this.collection,e.getOption("collectionEvents"))},this),this},onShowCalled:function(){},_ensureViewIsIntact:function(){if(this.isDestroyed)throw new s.Error({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(!this.isDestroyed){var e=i.toArray(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(e)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(e)),this.unbindUIElements(),this.remove(),i.invoke(this._behaviors,"destroy",e),this}},bindUIElements:function(){this._bindUIElements(),i.invoke(this._behaviors,this._bindUIElements)},_bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var e=i.result(this,"_uiBindings");this.ui={},i.each(e,function(e,t){this.ui[t]=this.$(e)},this)}},unbindUIElements:function(){this._unbindUIElements(),i.invoke(this._behaviors,this._unbindUIElements)},_unbindUIElements:function(){this.ui&&this._uiBindings&&(i.each(this.ui,function(e,t){delete this.ui[t]},this),this.ui=this._uiBindings,delete this._uiBindings)},_buildViewTrigger:function(e){var t=i.isObject(e),n=i.defaults({},t?e:{},{preventDefault:!0,stopPropagation:!0}),r=t?n.event:e;return function(e){e&&(e.preventDefault&&n.preventDefault&&e.preventDefault(),e.stopPropagation&&n.stopPropagation&&e.stopPropagation());var t={view:this,model:this.model,collection:this.collection};this.triggerMethod(r,t)}},setElement:function(){var e=t.View.prototype.setElement.apply(this,arguments);return i.invoke(this._behaviors,"proxyViewProperties",this),e},triggerMethod:function(){for(var e=s._triggerMethod,t=e(this,arguments),i=this._behaviors,n=0,r=i&&i.length;r>n;n++)e(i[n],arguments);return t},_getImmediateChildren:function(){return[]},_getNestedViews:function(){var e=this._getImmediateChildren();return e.length?i.reduce(e,function(e,t){return t._getNestedViews?e.concat(t._getNestedViews()):e},e):e},normalizeMethods:s.normalizeMethods,getOption:s.proxyGetOption,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.ItemView=s.View.extend({constructor:function(){s.View.apply(this,arguments)},serializeData:function(){if(!this.model&&!this.collection)return{};var e=[this.model||this.collection];return arguments.length&&e.push.apply(e,arguments),this.model?this.serializeModel.apply(this,e):{items:this.serializeCollection.apply(this,e)}},serializeCollection:function(e){return e.toJSON.apply(e,i.rest(arguments))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderTemplate(),this.bindUIElements(),this.triggerMethod("render",this),this},_renderTemplate:function(){var e=this.getTemplate();if(e!==!1){if(!e)throw new s.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var t=this.serializeData();t=this.mixinTemplateHelpers(t);var i=s.Renderer.render(e,t,this);return this.attachElContent(i),this}},attachElContent:function(e){return this.$el.html(e),this}}),s.CollectionView=s.View.extend({childViewEventPrefix:"childview",constructor:function(e){var t=e||{};i.isUndefined(this.sort)&&(this.sort=i.isUndefined(t.sort)?!0:t.sort),this.once("render",this._initialEvents),this._initChildViewStorage(),s.View.apply(this,arguments),this.initRenderBuffer()},initRenderBuffer:function(){this.elBuffer=document.createDocumentFragment(),this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){this.isBuffering=!1,this._triggerBeforeShowBufferedChildren(),this.attachBuffer(this,this.elBuffer),this._triggerShowBufferedChildren(),this.initRenderBuffer()},_triggerBeforeShowBufferedChildren:function(){this._isShown&&i.each(this._bufferedChildren,i.partial(this._triggerMethodOnChild,"before:show"))},_triggerShowBufferedChildren:function(){this._isShown&&(i.each(this._bufferedChildren,i.partial(this._triggerMethodOnChild,"show")),this._bufferedChildren=[])},_triggerMethodOnChild:function(e,t){s.triggerMethodOn(t,e)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this.render),this.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(e){this.destroyEmptyView();var t=this.getChildView(e),i=this.collection.indexOf(e);this.addChild(e,t,i)},_onCollectionRemove:function(e){var t=this.children.findByModel(e);this.removeChildView(t),this.checkEmpty()},onShowCalled:function(){this.children.each(i.partial(this._triggerMethodOnChild,"show"))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderChildren(),this.triggerMethod("render",this),this},resortView:function(){this.render()},_sortViews:function(){var e=this.collection.find(function(e,t){var i=this.children.findByModel(e);return!i||i._index!==t},this);e&&this.resortView()},_emptyViewIndex:-1,_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren(),this.isEmpty(this.collection)?this.showEmptyView():(this.triggerMethod("before:render:collection",this),this.startBuffering(),this.showCollection(),this.endBuffering(),this.triggerMethod("render:collection",this))},showCollection:function(){var e;this.collection.each(function(t,i){e=this.getChildView(t),this.addChild(t,e,i)},this)},showEmptyView:function(){var e=this.getEmptyView();if(e&&!this._showingEmptyView){this.triggerMethod("before:render:empty"),this._showingEmptyView=!0;var i=new t.Model;this.addEmptyView(i,e),this.triggerMethod("render:empty")}},destroyEmptyView:function(){this._showingEmptyView&&(this.triggerMethod("before:remove:empty"),this.destroyChildren(),delete this._showingEmptyView,this.triggerMethod("remove:empty"))},getEmptyView:function(){return this.getOption("emptyView")},addEmptyView:function(e,t){var n=this.getOption("emptyViewOptions")||this.getOption("childViewOptions");i.isFunction(n)&&(n=n.call(this,e,this._emptyViewIndex));var r=this.buildChildView(e,t,n);r._parent=this,this.proxyChildEvents(r),this._isShown&&s.triggerMethodOn(r,"before:show"),this.children.add(r),this.renderChildView(r,this._emptyViewIndex),this._isShown&&s.triggerMethodOn(r,"show")},getChildView:function(){var e=this.getOption("childView");if(!e)throw new s.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return e},addChild:function(e,t,i){var n=this.getOption("childViewOptions");n=s._getValue(n,this,[e,i]);var r=this.buildChildView(e,t,n);return this._updateIndices(r,!0,i),this._addChildView(r,i),r._parent=this,r},_updateIndices:function(e,t,i){this.sort&&(t&&(e._index=i),this.children.each(function(i){i._index>=e._index&&(i._index+=t?1:-1)}))},_addChildView:function(e,t){this.proxyChildEvents(e),this.triggerMethod("before:add:child",e),this.children.add(e),this.renderChildView(e,t),this._isShown&&!this.isBuffering&&s.triggerMethodOn(e,"show"),this.triggerMethod("add:child",e)},renderChildView:function(e,t){return e.render(),this.attachHtml(this,e,t),e},buildChildView:function(e,t,n){var r=i.extend({model:e},n);return new t(r)},removeChildView:function(e){return e&&(this.triggerMethod("before:remove:child",e),e.destroy?e.destroy():e.remove&&e.remove(),delete e._parent,this.stopListening(e),this.children.remove(e),this.triggerMethod("remove:child",e),this._updateIndices(e,!1)),e},isEmpty:function(){return!this.collection||0===this.collection.length},checkEmpty:function(){this.isEmpty(this.collection)&&this.showEmptyView()},attachBuffer:function(e,t){e.$el.append(t)},attachHtml:function(e,t,i){e.isBuffering?(e.elBuffer.appendChild(t.el),e._bufferedChildren.push(t)):e._insertBefore(t,i)||e._insertAfter(t)},_insertBefore:function(e,t){var i,n=this.sort&&this.children.length-1>t;return n&&(i=this.children.find(function(e){return e._index===t+1})),i?(i.$el.before(e.el),!0):!1},_insertAfter:function(e){this.$el.append(e.el)},_initChildViewStorage:function(){this.children=new t.ChildViewContainer},destroy:function(){return this.isDestroyed?void 0:(this.triggerMethod("before:destroy:collection"),this.destroyChildren(),this.triggerMethod("destroy:collection"),s.View.prototype.destroy.apply(this,arguments))},destroyChildren:function(){var e=this.children.map(i.identity);return this.children.each(this.removeChildView,this),this.checkEmpty(),e},proxyChildEvents:function(e){var t=this.getOption("childViewEventPrefix");this.listenTo(e,"all",function(){var n=i.toArray(arguments),r=n[0],s=this.normalizeMethods(i.result(this,"childEvents"));n[0]=t+":"+r,n.splice(1,0,e),s!==void 0&&i.isFunction(s[r])&&s[r].apply(this,n.slice(1)),this.triggerMethod.apply(this,n)},this)},_getImmediateChildren:function(){return i.values(this.children._views)}}),s.CompositeView=s.CollectionView.extend({constructor:function(){s.CollectionView.apply(this,arguments)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this._renderChildren),this.sort&&this.listenTo(this.collection,"sort",this._sortViews))},getChildView:function(){var e=this.getOption("childView")||this.constructor;return e},serializeData:function(){var e={};return this.model&&(e=i.partial(this.serializeModel,this.model).apply(this,arguments)),e},render:function(){return this._ensureViewIsIntact(),this.isRendered=!0,this.resetChildViewContainer(),this.triggerMethod("before:render",this),this._renderTemplate(),this._renderChildren(),this.triggerMethod("render",this),this},_renderChildren:function(){this.isRendered&&s.CollectionView.prototype._renderChildren.call(this)},_renderTemplate:function(){var e={};e=this.serializeData(),e=this.mixinTemplateHelpers(e),this.triggerMethod("before:render:template");var t=this.getTemplate(),i=s.Renderer.render(t,e,this);this.attachElContent(i),this.bindUIElements(),this.triggerMethod("render:template")},attachElContent:function(e){return this.$el.html(e),this},attachBuffer:function(e,t){var i=this.getChildViewContainer(e);i.append(t)},_insertAfter:function(e){var t=this.getChildViewContainer(this,e);t.append(e.el)},getChildViewContainer:function(e){if("$childViewContainer"in e)return e.$childViewContainer;var t,i=s.getOption(e,"childViewContainer");if(i){var n=s._getValue(i,e);if(t="@"===n.charAt(0)&&e.ui?e.ui[n.substr(4)]:e.$(n),0>=t.length)throw new s.Error({name:"ChildViewContainerMissingError",message:'The specified "childViewContainer" was not found: '+e.childViewContainer})}else t=e.$el;return e.$childViewContainer=t,t},resetChildViewContainer:function(){this.$childViewContainer&&delete this.$childViewContainer}}),s.LayoutView=s.ItemView.extend({regionClass:s.Region,constructor:function(e){e=e||{},this._firstRender=!0,this._initializeRegions(e),s.ItemView.call(this,e)},render:function(){return this._ensureViewIsIntact(),this._firstRender?this._firstRender=!1:this._reInitializeRegions(),s.ItemView.prototype.render.apply(this,arguments)},destroy:function(){return this.isDestroyed?this:(this.regionManager.destroy(),s.ItemView.prototype.destroy.apply(this,arguments))},addRegion:function(e,t){var i={};return i[e]=t,this._buildRegions(i)[e]},addRegions:function(e){return this.regions=i.extend({},this.regions,e),this._buildRegions(e)},removeRegion:function(e){return delete this.regions[e],this.regionManager.removeRegion(e)},getRegion:function(e){return this.regionManager.get(e)},getRegions:function(){return this.regionManager.getRegions()},_buildRegions:function(e){var t={regionClass:this.getOption("regionClass"),parentEl:i.partial(i.result,this,"el")};return this.regionManager.addRegions(e,t)},_initializeRegions:function(e){var t;this._initRegionManager(),t=s._getValue(this.regions,this,[e])||{};var n=this.getOption.call(e,"regions");n=s._getValue(n,this,[e]),i.extend(t,n),t=this.normalizeUIValues(t),this.addRegions(t)},_reInitializeRegions:function(){this.regionManager.invoke("reset")},getRegionManager:function(){return new s.RegionManager},_initRegionManager:function(){this.regionManager=this.getRegionManager(),this.regionManager._parent=this,this.listenTo(this.regionManager,"before:add:region",function(e){this.triggerMethod("before:add:region",e)}),this.listenTo(this.regionManager,"add:region",function(e,t){this[e]=t,this.triggerMethod("add:region",e,t)}),this.listenTo(this.regionManager,"before:remove:region",function(e){this.triggerMethod("before:remove:region",e)}),this.listenTo(this.regionManager,"remove:region",function(e,t){delete this[e],this.triggerMethod("remove:region",e,t)})},_getImmediateChildren:function(){return i.chain(this.regionManager.getRegions()).pluck("currentView").compact().value()}}),s.Behavior=s.Object.extend({constructor:function(e,t){this.view=t,this.defaults=i.result(this,"defaults")||{},this.options=i.extend({},this.defaults,e),s.Object.apply(this,arguments)},$:function(){return this.view.$.apply(this.view,arguments)},destroy:function(){this.stopListening()},proxyViewProperties:function(e){this.$el=e.$el,this.el=e.el}}),s.Behaviors=function(e,t){function i(e,n){return t.isObject(e.behaviors)?(n=i.parseBehaviors(e,n||t.result(e,"behaviors")),i.wrap(e,n,t.keys(s)),n):{}}function n(e,i){this._view=e,this._viewUI=t.result(e,"ui"),this._behaviors=i,this._triggers={}}var r=/^(\S+)\s*(.*)$/,s={behaviorTriggers:function(e,t){var i=new n(this,t);return i.buildBehaviorTriggers()},behaviorEvents:function(i,n){var s={},o=this._uiBindings||t.result(this,"ui");return t.each(n,function(i,n){var h={},a=t.clone(t.result(i,"events"))||{},l=i._uiBindings||t.result(i,"ui"),u=t.extend({},o,l);a=e.normalizeUIKeys(a,u);var d=0;t.each(a,function(e,s){var o=s.match(r),a=o[1]+"."+[this.cid,n,d++," "].join(""),l=o[2],u=a+l,c=t.isFunction(e)?e:i[e];h[u]=t.bind(c,i)},this),s=t.extend(s,h)},this),s}};return t.extend(i,{behaviorsLookup:function(){throw new e.Error({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.html#behaviorslookup"})},getBehaviorClass:function(t,n){return t.behaviorClass?t.behaviorClass:e._getValue(i.behaviorsLookup,this,[t,n])[n]},parseBehaviors:function(e,n){return t.chain(n).map(function(n,r){var s=i.getBehaviorClass(n,r),o=new s(n,e),h=i.parseBehaviors(e,t.result(o,"behaviors"));return[o].concat(h)}).flatten().value()},wrap:function(e,i,n){t.each(n,function(n){e[n]=t.partial(s[n],e[n],i)})}}),t.extend(n.prototype,{buildBehaviorTriggers:function(){return t.each(this._behaviors,this._buildTriggerHandlersForBehavior,this),this._triggers},_buildTriggerHandlersForBehavior:function(i,n){var r=t.extend({},this._viewUI,t.result(i,"ui")),s=t.clone(t.result(i,"triggers"))||{};s=e.normalizeUIKeys(s,r),t.each(s,t.bind(this._setHandlerForBehavior,this,i,n))},_setHandlerForBehavior:function(e,t,i,n){var r=n.replace(/^\S+/,function(e){return e+"."+"behaviortriggers"+t});this._triggers[r]=this._view._buildViewTrigger(i)}}),i}(s,i),s.AppRouter=t.Router.extend({constructor:function(e){this.options=e||{},t.Router.apply(this,arguments);var i=this.getOption("appRoutes"),n=this._getController();this.processAppRoutes(n,i),this.on("route",this._processOnRoute,this)},appRoute:function(e,t){var i=this._getController();this._addAppRoute(i,e,t)},_processOnRoute:function(e,t){if(i.isFunction(this.onRoute)){var n=i.invert(this.getOption("appRoutes"))[e];this.onRoute(e,n,t)}},processAppRoutes:function(e,t){if(t){var n=i.keys(t).reverse();i.each(n,function(i){this._addAppRoute(e,i,t[i])},this)}},_getController:function(){return this.getOption("controller")},_addAppRoute:function(e,t,n){var r=e[n];if(!r)throw new s.Error('Method "'+n+'" was not found on the controller');this.route(t,n,i.bind(r,e))},getOption:s.proxyGetOption,triggerMethod:s.triggerMethod,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.Application=s.Object.extend({constructor:function(e){this._initializeRegions(e),this._initCallbacks=new s.Callbacks,this.submodules={},i.extend(this,e),this._initChannel(),s.Object.call(this,e)},execute:function(){this.commands.execute.apply(this.commands,arguments)},request:function(){return this.reqres.request.apply(this.reqres,arguments)},addInitializer:function(e){this._initCallbacks.add(e)},start:function(e){this.triggerMethod("before:start",e),this._initCallbacks.run(e,this),this.triggerMethod("start",e)},addRegions:function(e){return this._regionManager.addRegions(e)},emptyRegions:function(){return this._regionManager.emptyRegions()},removeRegion:function(e){return this._regionManager.removeRegion(e)},getRegion:function(e){return this._regionManager.get(e)},getRegions:function(){return this._regionManager.getRegions()},module:function(e,t){var n=s.Module.getClass(t),r=i.toArray(arguments);return r.unshift(this),n.create.apply(n,r)},getRegionManager:function(){return new s.RegionManager},_initializeRegions:function(e){var t=i.isFunction(this.regions)?this.regions(e):this.regions||{};this._initRegionManager();var n=s.getOption(e,"regions");return i.isFunction(n)&&(n=n.call(this,e)),i.extend(t,n),this.addRegions(t),this},_initRegionManager:function(){this._regionManager=this.getRegionManager(),this._regionManager._parent=this,this.listenTo(this._regionManager,"before:add:region",function(){s._triggerMethod(this,"before:add:region",arguments)}),this.listenTo(this._regionManager,"add:region",function(e,t){this[e]=t,s._triggerMethod(this,"add:region",arguments)}),this.listenTo(this._regionManager,"before:remove:region",function(){s._triggerMethod(this,"before:remove:region",arguments)}),this.listenTo(this._regionManager,"remove:region",function(e){delete this[e],s._triggerMethod(this,"remove:region",arguments)})},_initChannel:function(){this.channelName=i.result(this,"channelName")||"global",this.channel=i.result(this,"channel")||t.Wreqr.radio.channel(this.channelName),this.vent=i.result(this,"vent")||this.channel.vent,this.commands=i.result(this,"commands")||this.channel.commands,this.reqres=i.result(this,"reqres")||this.channel.reqres}}),s.Module=function(e,t,n){this.moduleName=e,this.options=i.extend({},this.options,n),this.initialize=n.initialize||this.initialize,this.submodules={},this._setupInitializersAndFinalizers(),this.app=t,i.isFunction(this.initialize)&&this.initialize(e,t,this.options)},s.Module.extend=s.extend,i.extend(s.Module.prototype,t.Events,{startWithParent:!0,initialize:function(){},addInitializer:function(e){this._initializerCallbacks.add(e) -},addFinalizer:function(e){this._finalizerCallbacks.add(e)},start:function(e){this._isInitialized||(i.each(this.submodules,function(t){t.startWithParent&&t.start(e)}),this.triggerMethod("before:start",e),this._initializerCallbacks.run(e,this),this._isInitialized=!0,this.triggerMethod("start",e))},stop:function(){this._isInitialized&&(this._isInitialized=!1,this.triggerMethod("before:stop"),i.invoke(this.submodules,"stop"),this._finalizerCallbacks.run(void 0,this),this._initializerCallbacks.reset(),this._finalizerCallbacks.reset(),this.triggerMethod("stop"))},addDefinition:function(e,t){this._runModuleDefinition(e,t)},_runModuleDefinition:function(e,n){if(e){var r=i.flatten([this,this.app,t,s,t.$,i,n]);e.apply(this,r)}},_setupInitializersAndFinalizers:function(){this._initializerCallbacks=new s.Callbacks,this._finalizerCallbacks=new s.Callbacks},triggerMethod:s.triggerMethod}),i.extend(s.Module,{create:function(e,t,n){var r=e,s=i.rest(arguments,3);t=t.split(".");var o=t.length,h=[];return h[o-1]=n,i.each(t,function(t,i){var o=r;r=this._getModule(o,t,e,n),this._addModuleDefinition(o,r,h[i],s)},this),r},_getModule:function(e,t,n,r){var s=i.extend({},r),o=this.getClass(r),h=e[t];return h||(h=new o(t,n,s),e[t]=h,e.submodules[t]=h),h},getClass:function(e){var t=s.Module;return e?e.prototype instanceof t?e:e.moduleClass||t:t},_addModuleDefinition:function(e,t,i,n){var r=this._getDefine(i),s=this._getStartWithParent(i,t);r&&t.addDefinition(r,n),this._addStartWithParent(e,t,s)},_getStartWithParent:function(e,t){var n;return i.isFunction(e)&&e.prototype instanceof s.Module?(n=t.constructor.prototype.startWithParent,i.isUndefined(n)?!0:n):i.isObject(e)?(n=e.startWithParent,i.isUndefined(n)?!0:n):!0},_getDefine:function(e){return!i.isFunction(e)||e.prototype instanceof s.Module?i.isObject(e)?e.define:null:e},_addStartWithParent:function(e,t,i){t.startWithParent=t.startWithParent&&i,t.startWithParent&&!t.startWithParentIsConfigured&&(t.startWithParentIsConfigured=!0,e.addInitializer(function(e){t.startWithParent&&t.start(e)}))}}),s}); +(function(e,t){if("function"==typeof define&&define.amd)define(["backbone","underscore","backbone.wreqr","backbone.babysitter"],function(i,n){return e.Marionette=e.Mn=t(e,i,n)});else if("undefined"!=typeof exports){var i=require("backbone"),n=require("underscore");require("backbone.wreqr"),require("backbone.babysitter"),module.exports=t(e,i,n)}else e.Marionette=e.Mn=t(e,e.Backbone,e._)})(this,function(e,t,i){"use strict";var n=e.Marionette,r=e.Mn,s=t.Marionette={};s.VERSION="2.4.0",s.noConflict=function(){return e.Marionette=n,e.Mn=r,this},s.Deferred=t.$.Deferred,s.FEATURES={},s.isEnabled=function(e){return!!s.FEATURES[e]},s.extend=t.Model.extend,s.isNodeAttached=function(e){return t.$.contains(document.documentElement,e)},s.mergeOptions=function(e,t){e&&i.extend(this,i.pick(e,t))},s.getOption=function(e,t){return e&&t?e.options&&void 0!==e.options[t]?e.options[t]:e[t]:void 0},s.proxyGetOption=function(e){return s.getOption(this,e)},s._getValue=function(e,t,n){return i.isFunction(e)&&(e=n?e.apply(t,n):e.call(t)),e},s.normalizeMethods=function(e){return i.reduce(e,function(e,t,n){return i.isFunction(t)||(t=this[t]),t&&(e[n]=t),e},{},this)},s.normalizeUIString=function(e,t){return e.replace(/@ui\.[a-zA-Z_$0-9]*/g,function(e){return t[e.slice(4)]})},s.normalizeUIKeys=function(e,t){return i.reduce(e,function(e,i,n){var r=s.normalizeUIString(n,t);return e[r]=i,e},{})},s.normalizeUIValues=function(e,t,n){return i.each(e,function(r,o){i.isString(r)?e[o]=s.normalizeUIString(r,t):i.isObject(r)&&i.isArray(n)&&(i.extend(r,s.normalizeUIValues(i.pick(r,n),t)),i.each(n,function(e){var n=r[e];i.isString(n)&&(r[e]=s.normalizeUIString(n,t))}))}),e},s.actAsCollection=function(e,t){var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];i.each(n,function(n){e[n]=function(){var e=i.values(i.result(this,t)),r=[e].concat(i.toArray(arguments));return i[n].apply(i,r)}})};var o=s.deprecate=function(e,t){i.isObject(e)&&(e=e.prev+" is going to be removed in the future. "+"Please use "+e.next+" instead."+(e.url?" See: "+e.url:"")),void 0!==t&&t||o._cache[e]||(o._warn("Deprecation warning: "+e),o._cache[e]=!0)};o._warn="undefined"!=typeof console&&(console.warn||console.log)||function(){},o._cache={},s._triggerMethod=function(){function e(e,t,i){return i.toUpperCase()}var t=/(^|:)(\w)/gi;return function(n,r,s){var o=3>arguments.length;o&&(s=r,r=s[0]);var h,a="on"+r.replace(t,e),l=n[a];return i.isFunction(l)&&(h=l.apply(n,o?i.rest(s):s)),i.isFunction(n.trigger)&&(o+s.length>1?n.trigger.apply(n,o?s:[r].concat(i.drop(s,0))):n.trigger(r)),h}}(),s.triggerMethod=function(){return s._triggerMethod(this,arguments)},s.triggerMethodOn=function(e){var t=i.isFunction(e.triggerMethod)?e.triggerMethod:s.triggerMethod;return t.apply(e,i.rest(arguments))},s.MonitorDOMRefresh=function(e){function t(){e._isShown=!0,r()}function n(){e._isRendered=!0,r()}function r(){e._isShown&&e._isRendered&&s.isNodeAttached(e.el)&&i.isFunction(e.triggerMethod)&&e.triggerMethod("dom:refresh")}e.on({show:t,render:n})},function(e){function t(t,n,r,s){var o=s.split(/\s+/);i.each(o,function(i){var s=t[i];if(!s)throw new e.Error('Method "'+i+'" was configured as an event handler, but does not exist.');t.listenTo(n,r,s)})}function n(e,t,i,n){e.listenTo(t,i,n)}function r(e,t,n,r){var s=r.split(/\s+/);i.each(s,function(i){var r=e[i];e.stopListening(t,n,r)})}function s(e,t,i,n){e.stopListening(t,i,n)}function o(t,n,r,s,o){if(n&&r){if(!i.isObject(r))throw new e.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});r=e._getValue(r,t),i.each(r,function(e,r){i.isFunction(e)?s(t,n,r,e):o(t,n,r,e)})}}e.bindEntityEvents=function(e,i,r){o(e,i,r,n,t)},e.unbindEntityEvents=function(e,t,i){o(e,t,i,s,r)},e.proxyBindEntityEvents=function(t,i){return e.bindEntityEvents(this,t,i)},e.proxyUnbindEntityEvents=function(t,i){return e.unbindEntityEvents(this,t,i)}}(s);var h=["description","fileName","lineNumber","name","message","number"];return s.Error=s.extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+s.VERSION+"/",constructor:function(e,t){i.isObject(e)?(t=e,e=t.message):t||(t={});var n=Error.call(this,e);i.extend(this,i.pick(n,h),i.pick(t,h)),this.captureStackTrace(),t.url&&(this.url=this.urlRoot+t.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,s.Error)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}}),s.Error.extend=s.extend,s.Callbacks=function(){this._deferred=s.Deferred(),this._callbacks=[]},i.extend(s.Callbacks.prototype,{add:function(e,t){var n=i.result(this._deferred,"promise");this._callbacks.push({cb:e,ctx:t}),n.then(function(i){t&&(i.context=t),e.call(i.context,i.options)})},run:function(e,t){this._deferred.resolve({options:e,context:t})},reset:function(){var e=this._callbacks;this._deferred=s.Deferred(),this._callbacks=[],i.each(e,function(e){this.add(e.cb,e.ctx)},this)}}),s.Controller=function(e){this.options=e||{},i.isFunction(this.initialize)&&this.initialize(this.options)},s.Controller.extend=s.extend,i.extend(s.Controller.prototype,t.Events,{destroy:function(){return s._triggerMethod(this,"before:destroy",arguments),s._triggerMethod(this,"destroy",arguments),this.stopListening(),this.off(),this},triggerMethod:s.triggerMethod,mergeOptions:s.mergeOptions,getOption:s.proxyGetOption}),s.Object=function(e){this.options=i.extend({},i.result(this,"options"),e),this.initialize.apply(this,arguments)},s.Object.extend=s.extend,i.extend(s.Object.prototype,t.Events,{initialize:function(){},destroy:function(){return this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening(),this},triggerMethod:s.triggerMethod,mergeOptions:s.mergeOptions,getOption:s.proxyGetOption,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.Region=s.Object.extend({constructor:function(e){if(this.options=e||{},this.el=this.getOption("el"),this.el=this.el instanceof t.$?this.el[0]:this.el,!this.el)throw new s.Error({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),s.Object.call(this,e)},show:function(e,t){if(this._ensureElement()){this._ensureViewIsIntact(e);var i=t||{},n=e!==this.currentView,r=!!i.preventDestroy,o=!!i.forceShow,h=!!this.currentView,a=n&&!r,l=n||o;if(h&&this.triggerMethod("before:swapOut",this.currentView,this,t),this.currentView&&delete this.currentView._parent,a?this.empty():h&&l&&this.currentView.off("destroy",this.empty,this),l){e.once("destroy",this.empty,this),e.render(),e._parent=this,h&&this.triggerMethod("before:swap",e,this,t),this.triggerMethod("before:show",e,this,t),s.triggerMethodOn(e,"before:show",e,this,t),h&&this.triggerMethod("swapOut",this.currentView,this,t);var d=s.isNodeAttached(this.el),u=[],c=i.triggerBeforeAttach||this.triggerBeforeAttach,g=i.triggerAttach||this.triggerAttach;return d&&c&&(u=this._displayedViews(e),this._triggerAttach(u,"before:")),this.attachHtml(e),this.currentView=e,d&&g&&(u=this._displayedViews(e),this._triggerAttach(u)),h&&this.triggerMethod("swap",e,this,t),this.triggerMethod("show",e,this,t),s.triggerMethodOn(e,"show",e,this,t),this}return this}},triggerBeforeAttach:!0,triggerAttach:!0,_triggerAttach:function(e,t){var n=(t||"")+"attach";i.each(e,function(e){s.triggerMethodOn(e,n,e,this)},this)},_displayedViews:function(e){return i.union([e],i.result(e,"_getNestedViews")||[])},_ensureElement:function(){if(i.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||0===this.$el.length){if(this.getOption("allowMissingEl"))return!1;throw new s.Error('An "el" '+this.$el.selector+" must exist in DOM")}return!0},_ensureViewIsIntact:function(e){if(!e)throw new s.Error({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(e.isDestroyed)throw new s.Error({name:"ViewDestroyedError",message:'View (cid: "'+e.cid+'") has already been destroyed and cannot be used.'})},getEl:function(e){return t.$(e,s._getValue(this.options.parentEl,this))},attachHtml:function(e){this.$el.contents().detach(),this.el.appendChild(e.el)},empty:function(e){var t=this.currentView,i=s._getValue(e,"preventDestroy",this);return t?(t.off("destroy",this.empty,this),this.triggerMethod("before:empty",t),i||this._destroyView(),this.triggerMethod("empty",t),delete this.currentView,i&&this.$el.contents().detach(),this):void 0},_destroyView:function(){var e=this.currentView;e.destroy&&!e.isDestroyed?e.destroy():e.remove&&(e.remove(),e.isDestroyed=!0)},attachView:function(e){return this.currentView=e,this},hasView:function(){return!!this.currentView},reset:function(){return this.empty(),this.$el&&(this.el=this.$el.selector),delete this.$el,this}},{buildRegion:function(e,t){if(i.isString(e))return this._buildRegionFromSelector(e,t);if(e.selector||e.el||e.regionClass)return this._buildRegionFromObject(e,t);if(i.isFunction(e))return this._buildRegionFromRegionClass(e);throw new s.Error({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})},_buildRegionFromSelector:function(e,t){return new t({el:e})},_buildRegionFromObject:function(e,t){var n=e.regionClass||t,r=i.omit(e,"selector","regionClass");return e.selector&&!r.el&&(r.el=e.selector),new n(r)},_buildRegionFromRegionClass:function(e){return new e}}),s.RegionManager=s.Controller.extend({constructor:function(e){this._regions={},this.length=0,s.Controller.call(this,e),this.addRegions(this.getOption("regions"))},addRegions:function(e,t){return e=s._getValue(e,this,arguments),i.reduce(e,function(e,n,r){return i.isString(n)&&(n={selector:n}),n.selector&&(n=i.defaults({},n,t)),e[r]=this.addRegion(r,n),e},{},this)},addRegion:function(e,t){var i;return i=t instanceof s.Region?t:s.Region.buildRegion(t,s.Region),this.triggerMethod("before:add:region",e,i),i._parent=this,this._store(e,i),this.triggerMethod("add:region",e,i),i},get:function(e){return this._regions[e]},getRegions:function(){return i.clone(this._regions)},removeRegion:function(e){var t=this._regions[e];return this._remove(e,t),t},removeRegions:function(){var e=this.getRegions();return i.each(this._regions,function(e,t){this._remove(t,e)},this),e},emptyRegions:function(){var e=this.getRegions();return i.invoke(e,"empty"),e},destroy:function(){return this.removeRegions(),s.Controller.prototype.destroy.apply(this,arguments)},_store:function(e,t){this._regions[e]||this.length++,this._regions[e]=t},_remove:function(e,t){this.triggerMethod("before:remove:region",e,t),t.empty(),t.stopListening(),delete t._parent,delete this._regions[e],this.length--,this.triggerMethod("remove:region",e,t)}}),s.actAsCollection(s.RegionManager.prototype,"_regions"),s.TemplateCache=function(e){this.templateId=e},i.extend(s.TemplateCache,{templateCaches:{},get:function(e,t){var i=this.templateCaches[e];return i||(i=new s.TemplateCache(e),this.templateCaches[e]=i),i.load(t)},clear:function(){var e,t=i.toArray(arguments),n=t.length;if(n>0)for(e=0;n>e;e++)delete this.templateCaches[t[e]];else this.templateCaches={}}}),i.extend(s.TemplateCache.prototype,{load:function(e){if(this.compiledTemplate)return this.compiledTemplate;var t=this.loadTemplate(this.templateId,e);return this.compiledTemplate=this.compileTemplate(t,e),this.compiledTemplate},loadTemplate:function(e){var i=t.$(e).html();if(!i||0===i.length)throw new s.Error({name:"NoTemplateError",message:'Could not find template: "'+e+'"'});return i},compileTemplate:function(e,t){return i.template(e,t)}}),s.Renderer={render:function(e,t){if(!e)throw new s.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var n=i.isFunction(e)?e:s.TemplateCache.get(e);return n(t)}},s.View=t.View.extend({isDestroyed:!1,constructor:function(e){i.bindAll(this,"render"),e=s._getValue(e,this),this.options=i.extend({},i.result(this,"options"),e),this._behaviors=s.Behaviors(this),t.View.call(this,this.options),s.MonitorDOMRefresh(this)},getTemplate:function(){return this.getOption("template")},serializeModel:function(e){return e.toJSON.apply(e,i.rest(arguments))},mixinTemplateHelpers:function(e){e=e||{};var t=this.getOption("templateHelpers");return t=s._getValue(t,this),i.extend(e,t)},normalizeUIKeys:function(e){var t=i.result(this,"_uiBindings");return s.normalizeUIKeys(e,t||i.result(this,"ui"))},normalizeUIValues:function(e,t){var n=i.result(this,"ui"),r=i.result(this,"_uiBindings");return s.normalizeUIValues(e,r||n,t)},configureTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(i.result(this,"triggers"));return i.reduce(e,function(e,t,i){return e[i]=this._buildViewTrigger(t),e},{},this)}},delegateEvents:function(e){return this._delegateDOMEvents(e),this.bindEntityEvents(this.model,this.getOption("modelEvents")),this.bindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(e){e.bindEntityEvents(this.model,e.getOption("modelEvents")),e.bindEntityEvents(this.collection,e.getOption("collectionEvents"))},this),this},_delegateDOMEvents:function(e){var n=s._getValue(e||this.events,this);n=this.normalizeUIKeys(n),i.isUndefined(e)&&(this.events=n);var r={},o=i.result(this,"behaviorEvents")||{},h=this.configureTriggers(),a=i.result(this,"behaviorTriggers")||{};i.extend(r,o,n,h,a),t.View.prototype.delegateEvents.call(this,r)},undelegateEvents:function(){return t.View.prototype.undelegateEvents.apply(this,arguments),this.unbindEntityEvents(this.model,this.getOption("modelEvents")),this.unbindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(e){e.unbindEntityEvents(this.model,e.getOption("modelEvents")),e.unbindEntityEvents(this.collection,e.getOption("collectionEvents"))},this),this},_ensureViewIsIntact:function(){if(this.isDestroyed)throw new s.Error({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(this.isDestroyed)return this;var e=i.toArray(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(e)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(e)),this.unbindUIElements(),this.isRendered=!1,this.remove(),i.invoke(this._behaviors,"destroy",e),this},bindUIElements:function(){this._bindUIElements(),i.invoke(this._behaviors,this._bindUIElements)},_bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var e=i.result(this,"_uiBindings");this.ui={},i.each(e,function(e,t){this.ui[t]=this.$(e)},this)}},unbindUIElements:function(){this._unbindUIElements(),i.invoke(this._behaviors,this._unbindUIElements)},_unbindUIElements:function(){this.ui&&this._uiBindings&&(i.each(this.ui,function(e,t){delete this.ui[t]},this),this.ui=this._uiBindings,delete this._uiBindings)},_buildViewTrigger:function(e){var t=i.isObject(e),n=i.defaults({},t?e:{},{preventDefault:!0,stopPropagation:!0}),r=t?n.event:e;return function(e){e&&(e.preventDefault&&n.preventDefault&&e.preventDefault(),e.stopPropagation&&n.stopPropagation&&e.stopPropagation());var t={view:this,model:this.model,collection:this.collection};this.triggerMethod(r,t)}},setElement:function(){var e=t.View.prototype.setElement.apply(this,arguments);return i.invoke(this._behaviors,"proxyViewProperties",this),e},triggerMethod:function(){var e=s._triggerMethod(this,arguments);return this._triggerEventOnBehaviors(arguments),this._triggerEventOnParentLayout(arguments[0],i.rest(arguments)),e},_triggerEventOnBehaviors:function(e){for(var t=s._triggerMethod,i=this._behaviors,n=0,r=i&&i.length;r>n;n++)t(i[n],e)},_triggerEventOnParentLayout:function(e,t){var n=this._parentLayoutView();if(n){var r=s.getOption(n,"childViewEventPrefix"),o=r+":"+e;s._triggerMethod(n,[o,this].concat(t));var h=s.getOption(n,"childEvents"),a=n.normalizeMethods(h);a&&i.isFunction(a[e])&&a[e].apply(n,[this].concat(t))}},_getImmediateChildren:function(){return[]},_getNestedViews:function(){var e=this._getImmediateChildren();return e.length?i.reduce(e,function(e,t){return t._getNestedViews?e.concat(t._getNestedViews()):e},e):e},_getAncestors:function(){for(var e=[],t=this._parent;t;)e.push(t),t=t._parent;return e},_parentLayoutView:function(){var e=this._getAncestors();return i.find(e,function(e){return e instanceof s.LayoutView})},normalizeMethods:s.normalizeMethods,mergeOptions:s.mergeOptions,getOption:s.proxyGetOption,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.ItemView=s.View.extend({constructor:function(){s.View.apply(this,arguments)},serializeData:function(){if(!this.model&&!this.collection)return{};var e=[this.model||this.collection];return arguments.length&&e.push.apply(e,arguments),this.model?this.serializeModel.apply(this,e):{items:this.serializeCollection.apply(this,e)}},serializeCollection:function(e){return e.toJSON.apply(e,i.rest(arguments))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderTemplate(),this.isRendered=!0,this.bindUIElements(),this.triggerMethod("render",this),this},_renderTemplate:function(){var e=this.getTemplate();if(e!==!1){if(!e)throw new s.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var t=this.mixinTemplateHelpers(this.serializeData()),i=s.Renderer.render(e,t,this);return this.attachElContent(i),this}},attachElContent:function(e){return this.$el.html(e),this}}),s.CollectionView=s.View.extend({childViewEventPrefix:"childview",sort:!0,constructor:function(){this.once("render",this._initialEvents),this._initChildViewStorage(),s.View.apply(this,arguments),this.on("show",this._onShowCalled),this.initRenderBuffer()},initRenderBuffer:function(){this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){this.isBuffering=!1,this._triggerBeforeShowBufferedChildren(),this.attachBuffer(this),this._triggerShowBufferedChildren(),this.initRenderBuffer()},_triggerBeforeShowBufferedChildren:function(){this._isShown&&i.each(this._bufferedChildren,i.partial(this._triggerMethodOnChild,"before:show"))},_triggerShowBufferedChildren:function(){this._isShown&&(i.each(this._bufferedChildren,i.partial(this._triggerMethodOnChild,"show")),this._bufferedChildren=[])},_triggerMethodOnChild:function(e,t){s.triggerMethodOn(t,e)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this.render),this.getOption("sort")&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(e,t,n){var r;if(r=void 0!==n.at?n.at:i.indexOf(this._filteredSortedModels(),e),this._shouldAddChild(e,r)){this.destroyEmptyView();var s=this.getChildView(e);this.addChild(e,s,r)}},_onCollectionRemove:function(e){var t=this.children.findByModel(e);this.removeChildView(t),this.checkEmpty()},_onShowCalled:function(){this.children.each(i.partial(this._triggerMethodOnChild,"show"))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderChildren(),this.isRendered=!0,this.triggerMethod("render",this),this},reorder:function(){var e=this.children,t=this._filteredSortedModels(),n=i.find(t,function(t){return!e.findByModel(t)});if(n)this.render();else{var r=i.map(t,function(t){return e.findByModel(t).el});this.triggerMethod("before:reorder"),this.$el.append(r),this.triggerMethod("reorder")}},resortView:function(){s.getOption(this,"reorderOnSort")?this.reorder():this.render()},_sortViews:function(){var e=this._filteredSortedModels(),t=i.find(e,function(e,t){var i=this.children.findByModel(e);return!i||i._index!==t},this);t&&this.resortView()},_emptyViewIndex:-1,_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren(),this.isEmpty(this.collection)?this.showEmptyView():(this.triggerMethod("before:render:collection",this),this.startBuffering(),this.showCollection(),this.endBuffering(),this.triggerMethod("render:collection",this),this.children.isEmpty()&&this.showEmptyView())},showCollection:function(){var e,t=this._filteredSortedModels();i.each(t,function(t,i){e=this.getChildView(t),this.addChild(t,e,i)},this)},_filteredSortedModels:function(){var e,t=this.getViewComparator();return e=t?i.isString(t)||1===t.length?this.collection.sortBy(t,this):i.clone(this.collection.models).sort(i.bind(t,this)):this.collection.models,this.getOption("filter")&&(e=i.filter(e,function(e,t){return this._shouldAddChild(e,t)},this)),e},showEmptyView:function(){var e=this.getEmptyView();if(e&&!this._showingEmptyView){this.triggerMethod("before:render:empty"),this._showingEmptyView=!0;var i=new t.Model;this.addEmptyView(i,e),this.triggerMethod("render:empty")}},destroyEmptyView:function(){this._showingEmptyView&&(this.triggerMethod("before:remove:empty"),this.destroyChildren(),delete this._showingEmptyView,this.triggerMethod("remove:empty"))},getEmptyView:function(){return this.getOption("emptyView")},addEmptyView:function(e,t){var n=this.getOption("emptyViewOptions")||this.getOption("childViewOptions");i.isFunction(n)&&(n=n.call(this,e,this._emptyViewIndex));var r=this.buildChildView(e,t,n);r._parent=this,this.proxyChildEvents(r),this._isShown&&s.triggerMethodOn(r,"before:show"),this.children.add(r),this.renderChildView(r,this._emptyViewIndex),this._isShown&&s.triggerMethodOn(r,"show")},getChildView:function(){var e=this.getOption("childView");if(!e)throw new s.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return e},addChild:function(e,t,i){var n=this.getOption("childViewOptions");n=s._getValue(n,this,[e,i]);var r=this.buildChildView(e,t,n);return this._updateIndices(r,!0,i),this._addChildView(r,i),r._parent=this,r},_updateIndices:function(e,t,i){this.getOption("sort")&&(t&&(e._index=i),this.children.each(function(i){i._index>=e._index&&(i._index+=t?1:-1)}))},_addChildView:function(e,t){this.proxyChildEvents(e),this.triggerMethod("before:add:child",e),this._isShown&&!this.isBuffering&&s.triggerMethodOn(e,"before:show"),this.children.add(e),this.renderChildView(e,t),this._isShown&&!this.isBuffering&&s.triggerMethodOn(e,"show"),this.triggerMethod("add:child",e)},renderChildView:function(e,t){return e.render(),this.attachHtml(this,e,t),e},buildChildView:function(e,t,n){var r=i.extend({model:e},n);return new t(r)},removeChildView:function(e){return e&&(this.triggerMethod("before:remove:child",e),e.destroy?e.destroy():e.remove&&e.remove(),delete e._parent,this.stopListening(e),this.children.remove(e),this.triggerMethod("remove:child",e),this._updateIndices(e,!1)),e},isEmpty:function(){return!this.collection||0===this.collection.length},checkEmpty:function(){this.isEmpty(this.collection)&&this.showEmptyView()},attachBuffer:function(e){e.$el.append(this._createBuffer(e))},_createBuffer:function(e){var t=document.createDocumentFragment();return i.each(e._bufferedChildren,function(e){t.appendChild(e.el)}),t},attachHtml:function(e,t,i){e.isBuffering?e._bufferedChildren.splice(i,0,t):e._insertBefore(t,i)||e._insertAfter(t)},_insertBefore:function(e,t){var i,n=this.getOption("sort")&&this.children.length-1>t;return n&&(i=this.children.find(function(e){return e._index===t+1})),i?(i.$el.before(e.el),!0):!1},_insertAfter:function(e){this.$el.append(e.el)},_initChildViewStorage:function(){this.children=new t.ChildViewContainer},destroy:function(){return this.isDestroyed?this:(this.triggerMethod("before:destroy:collection"),this.destroyChildren(),this.triggerMethod("destroy:collection"),s.View.prototype.destroy.apply(this,arguments))},destroyChildren:function(){var e=this.children.map(i.identity);return this.children.each(this.removeChildView,this),this.checkEmpty(),e},_shouldAddChild:function(e,t){var n=this.getOption("filter");return!i.isFunction(n)||n.call(this,e,t,this.collection)},proxyChildEvents:function(e){var t=this.getOption("childViewEventPrefix");this.listenTo(e,"all",function(){var n=i.toArray(arguments),r=n[0],s=this.normalizeMethods(i.result(this,"childEvents"));n[0]=t+":"+r,n.splice(1,0,e),s!==void 0&&i.isFunction(s[r])&&s[r].apply(this,n.slice(1)),this.triggerMethod.apply(this,n)})},_getImmediateChildren:function(){return i.values(this.children._views)},getViewComparator:function(){return this.getOption("viewComparator")}}),s.CompositeView=s.CollectionView.extend({constructor:function(){s.CollectionView.apply(this,arguments)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this._renderChildren),this.getOption("sort")&&this.listenTo(this.collection,"sort",this._sortViews))},getChildView:function(){var e=this.getOption("childView")||this.constructor;return e},serializeData:function(){var e={};return this.model&&(e=i.partial(this.serializeModel,this.model).apply(this,arguments)),e},render:function(){return this._ensureViewIsIntact(),this._isRendering=!0,this.resetChildViewContainer(),this.triggerMethod("before:render",this),this._renderTemplate(),this._renderChildren(),this._isRendering=!1,this.isRendered=!0,this.triggerMethod("render",this),this},_renderChildren:function(){(this.isRendered||this._isRendering)&&s.CollectionView.prototype._renderChildren.call(this)},_renderTemplate:function(){var e={};e=this.serializeData(),e=this.mixinTemplateHelpers(e),this.triggerMethod("before:render:template");var t=this.getTemplate(),i=s.Renderer.render(t,e,this);this.attachElContent(i),this.bindUIElements(),this.triggerMethod("render:template")},attachElContent:function(e){return this.$el.html(e),this},attachBuffer:function(e){var t=this.getChildViewContainer(e);t.append(this._createBuffer(e))},_insertAfter:function(e){var t=this.getChildViewContainer(this,e);t.append(e.el)},getChildViewContainer:function(e){if("$childViewContainer"in e)return e.$childViewContainer;var t,i=s.getOption(e,"childViewContainer");if(i){var n=s._getValue(i,e);if(t="@"===n.charAt(0)&&e.ui?e.ui[n.substr(4)]:e.$(n),0>=t.length)throw new s.Error({name:"ChildViewContainerMissingError",message:'The specified "childViewContainer" was not found: '+e.childViewContainer})}else t=e.$el;return e.$childViewContainer=t,t},resetChildViewContainer:function(){this.$childViewContainer&&delete this.$childViewContainer}}),s.LayoutView=s.ItemView.extend({regionClass:s.Region,options:{destroyImmediate:!1},childViewEventPrefix:"childview",constructor:function(e){e=e||{},this._firstRender=!0,this._initializeRegions(e),s.ItemView.call(this,e)},render:function(){return this._ensureViewIsIntact(),this._firstRender?this._firstRender=!1:this._reInitializeRegions(),s.ItemView.prototype.render.apply(this,arguments)},destroy:function(){return this.isDestroyed?this:(this.getOption("destroyImmediate")===!0&&this.$el.remove(),this.regionManager.destroy(),s.ItemView.prototype.destroy.apply(this,arguments))},showChildView:function(e,t){return this.getRegion(e).show(t)},getChildView:function(e){return this.getRegion(e).currentView},addRegion:function(e,t){var i={};return i[e]=t,this._buildRegions(i)[e]},addRegions:function(e){return this.regions=i.extend({},this.regions,e),this._buildRegions(e)},removeRegion:function(e){return delete this.regions[e],this.regionManager.removeRegion(e)},getRegion:function(e){return this.regionManager.get(e)},getRegions:function(){return this.regionManager.getRegions()},_buildRegions:function(e){var t={regionClass:this.getOption("regionClass"),parentEl:i.partial(i.result,this,"el")};return this.regionManager.addRegions(e,t)},_initializeRegions:function(e){var t;this._initRegionManager(),t=s._getValue(this.regions,this,[e])||{};var n=this.getOption.call(e,"regions");n=s._getValue(n,this,[e]),i.extend(t,n),t=this.normalizeUIValues(t,["selector","el"]),this.addRegions(t)},_reInitializeRegions:function(){this.regionManager.invoke("reset")},getRegionManager:function(){return new s.RegionManager},_initRegionManager:function(){this.regionManager=this.getRegionManager(),this.regionManager._parent=this,this.listenTo(this.regionManager,"before:add:region",function(e){this.triggerMethod("before:add:region",e)}),this.listenTo(this.regionManager,"add:region",function(e,t){this[e]=t,this.triggerMethod("add:region",e,t)}),this.listenTo(this.regionManager,"before:remove:region",function(e){this.triggerMethod("before:remove:region",e)}),this.listenTo(this.regionManager,"remove:region",function(e,t){delete this[e],this.triggerMethod("remove:region",e,t)})},_getImmediateChildren:function(){return i.chain(this.regionManager.getRegions()).pluck("currentView").compact().value()}}),s.Behavior=s.Object.extend({constructor:function(e,t){this.view=t,this.defaults=i.result(this,"defaults")||{},this.options=i.extend({},this.defaults,e),this.ui=i.extend({},i.result(t,"ui"),i.result(this,"ui")),s.Object.apply(this,arguments)},$:function(){return this.view.$.apply(this.view,arguments)},destroy:function(){return this.stopListening(),this},proxyViewProperties:function(e){this.$el=e.$el,this.el=e.el}}),s.Behaviors=function(e,t){function i(e,n){return t.isObject(e.behaviors)?(n=i.parseBehaviors(e,n||t.result(e,"behaviors")),i.wrap(e,n,t.keys(o)),n):{}}function n(e,t){this._view=e,this._behaviors=t,this._triggers={}}function r(e){return e._uiBindings||e.ui}var s=/^(\S+)\s*(.*)$/,o={behaviorTriggers:function(e,t){var i=new n(this,t);return i.buildBehaviorTriggers()},behaviorEvents:function(i,n){var o={};return t.each(n,function(i,n){var h={},a=t.clone(t.result(i,"events"))||{};a=e.normalizeUIKeys(a,r(i));var l=0;t.each(a,function(e,r){var o=r.match(s),a=o[1]+"."+[this.cid,n,l++," "].join(""),d=o[2],u=a+d,c=t.isFunction(e)?e:i[e];h[u]=t.bind(c,i)},this),o=t.extend(o,h)},this),o}};return t.extend(i,{behaviorsLookup:function(){throw new e.Error({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.html#behaviorslookup"})},getBehaviorClass:function(t,n){return t.behaviorClass?t.behaviorClass:e._getValue(i.behaviorsLookup,this,[t,n])[n]},parseBehaviors:function(e,n){return t.chain(n).map(function(n,r){var s=i.getBehaviorClass(n,r),o=new s(n,e),h=i.parseBehaviors(e,t.result(o,"behaviors"));return[o].concat(h)}).flatten().value()},wrap:function(e,i,n){t.each(n,function(n){e[n]=t.partial(o[n],e[n],i)})}}),t.extend(n.prototype,{buildBehaviorTriggers:function(){return t.each(this._behaviors,this._buildTriggerHandlersForBehavior,this),this._triggers},_buildTriggerHandlersForBehavior:function(i,n){var s=t.clone(t.result(i,"triggers"))||{};s=e.normalizeUIKeys(s,r(i)),t.each(s,t.bind(this._setHandlerForBehavior,this,i,n))},_setHandlerForBehavior:function(e,t,i,n){var r=n.replace(/^\S+/,function(e){return e+"."+"behaviortriggers"+t});this._triggers[r]=this._view._buildViewTrigger(i)}}),i}(s,i),s.AppRouter=t.Router.extend({constructor:function(e){this.options=e||{},t.Router.apply(this,arguments);var i=this.getOption("appRoutes"),n=this._getController();this.processAppRoutes(n,i),this.on("route",this._processOnRoute,this)},appRoute:function(e,t){var i=this._getController();this._addAppRoute(i,e,t)},_processOnRoute:function(e,t){if(i.isFunction(this.onRoute)){var n=i.invert(this.getOption("appRoutes"))[e];this.onRoute(e,n,t)}},processAppRoutes:function(e,t){if(t){var n=i.keys(t).reverse();i.each(n,function(i){this._addAppRoute(e,i,t[i])},this)}},_getController:function(){return this.getOption("controller")},_addAppRoute:function(e,t,n){var r=e[n];if(!r)throw new s.Error('Method "'+n+'" was not found on the controller');this.route(t,n,i.bind(r,e))},mergeOptions:s.mergeOptions,getOption:s.proxyGetOption,triggerMethod:s.triggerMethod,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.Application=s.Object.extend({constructor:function(e){this._initializeRegions(e),this._initCallbacks=new s.Callbacks,this.submodules={},i.extend(this,e),this._initChannel(),s.Object.call(this,e) +},execute:function(){this.commands.execute.apply(this.commands,arguments)},request:function(){return this.reqres.request.apply(this.reqres,arguments)},addInitializer:function(e){this._initCallbacks.add(e)},start:function(e){this.triggerMethod("before:start",e),this._initCallbacks.run(e,this),this.triggerMethod("start",e)},addRegions:function(e){return this._regionManager.addRegions(e)},emptyRegions:function(){return this._regionManager.emptyRegions()},removeRegion:function(e){return this._regionManager.removeRegion(e)},getRegion:function(e){return this._regionManager.get(e)},getRegions:function(){return this._regionManager.getRegions()},module:function(e,t){var n=s.Module.getClass(t),r=i.toArray(arguments);return r.unshift(this),n.create.apply(n,r)},getRegionManager:function(){return new s.RegionManager},_initializeRegions:function(e){var t=i.isFunction(this.regions)?this.regions(e):this.regions||{};this._initRegionManager();var n=s.getOption(e,"regions");return i.isFunction(n)&&(n=n.call(this,e)),i.extend(t,n),this.addRegions(t),this},_initRegionManager:function(){this._regionManager=this.getRegionManager(),this._regionManager._parent=this,this.listenTo(this._regionManager,"before:add:region",function(){s._triggerMethod(this,"before:add:region",arguments)}),this.listenTo(this._regionManager,"add:region",function(e,t){this[e]=t,s._triggerMethod(this,"add:region",arguments)}),this.listenTo(this._regionManager,"before:remove:region",function(){s._triggerMethod(this,"before:remove:region",arguments)}),this.listenTo(this._regionManager,"remove:region",function(e){delete this[e],s._triggerMethod(this,"remove:region",arguments)})},_initChannel:function(){this.channelName=i.result(this,"channelName")||"global",this.channel=i.result(this,"channel")||t.Wreqr.radio.channel(this.channelName),this.vent=i.result(this,"vent")||this.channel.vent,this.commands=i.result(this,"commands")||this.channel.commands,this.reqres=i.result(this,"reqres")||this.channel.reqres}}),s.Module=function(e,t,n){this.moduleName=e,this.options=i.extend({},this.options,n),this.initialize=n.initialize||this.initialize,this.submodules={},this._setupInitializersAndFinalizers(),this.app=t,i.isFunction(this.initialize)&&this.initialize(e,t,this.options)},s.Module.extend=s.extend,i.extend(s.Module.prototype,t.Events,{startWithParent:!0,initialize:function(){},addInitializer:function(e){this._initializerCallbacks.add(e)},addFinalizer:function(e){this._finalizerCallbacks.add(e)},start:function(e){this._isInitialized||(i.each(this.submodules,function(t){t.startWithParent&&t.start(e)}),this.triggerMethod("before:start",e),this._initializerCallbacks.run(e,this),this._isInitialized=!0,this.triggerMethod("start",e))},stop:function(){this._isInitialized&&(this._isInitialized=!1,this.triggerMethod("before:stop"),i.invoke(this.submodules,"stop"),this._finalizerCallbacks.run(void 0,this),this._initializerCallbacks.reset(),this._finalizerCallbacks.reset(),this.triggerMethod("stop"))},addDefinition:function(e,t){this._runModuleDefinition(e,t)},_runModuleDefinition:function(e,n){if(e){var r=i.flatten([this,this.app,t,s,t.$,i,n]);e.apply(this,r)}},_setupInitializersAndFinalizers:function(){this._initializerCallbacks=new s.Callbacks,this._finalizerCallbacks=new s.Callbacks},triggerMethod:s.triggerMethod}),i.extend(s.Module,{create:function(e,t,n){var r=e,s=i.drop(arguments,3);t=t.split(".");var o=t.length,h=[];return h[o-1]=n,i.each(t,function(t,i){var o=r;r=this._getModule(o,t,e,n),this._addModuleDefinition(o,r,h[i],s)},this),r},_getModule:function(e,t,n,r){var s=i.extend({},r),o=this.getClass(r),h=e[t];return h||(h=new o(t,n,s),e[t]=h,e.submodules[t]=h),h},getClass:function(e){var t=s.Module;return e?e.prototype instanceof t?e:e.moduleClass||t:t},_addModuleDefinition:function(e,t,i,n){var r=this._getDefine(i),s=this._getStartWithParent(i,t);r&&t.addDefinition(r,n),this._addStartWithParent(e,t,s)},_getStartWithParent:function(e,t){var n;return i.isFunction(e)&&e.prototype instanceof s.Module?(n=t.constructor.prototype.startWithParent,i.isUndefined(n)?!0:n):i.isObject(e)?(n=e.startWithParent,i.isUndefined(n)?!0:n):!0},_getDefine:function(e){return!i.isFunction(e)||e.prototype instanceof s.Module?i.isObject(e)?e.define:null:e},_addStartWithParent:function(e,t,i){t.startWithParent=t.startWithParent&&i,t.startWithParent&&!t.startWithParentIsConfigured&&(t.startWithParentIsConfigured=!0,e.addInitializer(function(e){t.startWithParent&&t.start(e)}))}}),s}); //@ sourceMappingURL=backbone.marionette.map \ No newline at end of file diff --git a/package.json b/package.json index bdb89d8f42..3822a976bb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "backbone.marionette", "description": "Make your Backbone.js apps dance!", - "version": "2.3.2", + "version": "2.4.0", "homepage": "https://github.com/marionettejs/backbone.marionette", "main": "lib/core/backbone.marionette.js", "keywords": [