diff --git a/.travis.yml b/.travis.yml index 7263abc52f..38205bc60c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ sudo: false language: node_js node_js: + - "0.12" + - "0.11" - "0.10" env: global: MAINRUN=true @@ -12,6 +14,8 @@ env: - UNDERSCORE=1.6 BACKBONE=1.0 - UNDERSCORE=1.4.4 BACKBONE=1.1.0 - UNDERSCORE=1.5 BACKBONE=1.1 + - UNDERSCORE=1.7 BACKBONE=1.2 + - UNDERSCORE=1.8 BACKBONE=1.2 - LODASH=2.4 BACKBONE=1.1 - LODASH=3.0 BACKBONE=1.1 - LODASH=3.1 BACKBONE=1.0 diff --git a/SpecRunner.html b/SpecRunner.html index 04ccda4e35..06236a61e6 100644 --- a/SpecRunner.html +++ b/SpecRunner.html @@ -119,6 +119,7 @@ + diff --git a/api/collection-view.yaml b/api/collection-view.yaml index c53eaa3b37..a3f15b6d69 100644 --- a/api/collection-view.yaml +++ b/api/collection-view.yaml @@ -324,6 +324,7 @@ functions: ... @api public + @param {Object} options examples: diff --git a/bower.json b/bower.json index b17177099a..78a4524592 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.4.1", + "version": "2.4.2", "keywords": [ "backbone", "framework", @@ -35,8 +35,8 @@ "upgradeGuide.md" ], "dependencies": { - "backbone": "1.0.0 - 1.1.2", - "underscore": "1.4.4 - 1.6.0", + "backbone": "1.0.0 - 1.2.1", + "underscore": "1.4.4 - 1.8.3", "backbone.babysitter": "^0.1.0", "backbone.wreqr": "^1.0.0", "jquery": "^1.8.0 || ^2.0.0" diff --git a/changelog.md b/changelog.md index 62eed71a18..b26636f93a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,25 @@ +### v2.4.2 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.4.1...v2.4.2) + +#### Fixes + +* Fixed a bug where `reorderOnSort` would not reorder back to the original order. +* Stop deleting `$childViewContainer` so that it can be accessed in behaviors. +* Ensure `before:show` and `show` events are triggered on `CollectionView` children. +* Ensure `onBeforeAttach` and `onAttach` are called for `CollectionView` children. +* Allow for disabling of `triggerBeforeAttach` and `triggerAttach` via `show()` options. +* Added the documented `buffer` argument to `attachBuffer` and changed implementation so this was used rather than `_createBuffer`. +* Fixed potential memory leak when destroying children on `CollectionView` by making the `checkEmpty` call optional. + +#### Docs + +* Improve documentation around the requirement for an initial render to bind events in `CollectionView`. +* Add documentation around UI interpolation usage. +* Add documentation to warn about the full re-render of a `CollectionView` or `CompositeView` if `reorderOnSort` is not set. + +#### Misc + +* Bumped Underscore and Backbone dependencies to 1.8.3 and 1.2.1 respectively. + ### v2.4.1 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.4.0...v2.4.1) #### Fixes diff --git a/component.json b/component.json index 2c1b9e3817..dc3a9fdd00 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "backbone.marionette", "description": "Make your Backbone.js apps dance!", - "version": "2.4.1", + "version": "2.4.2", "repo": "marionettejs/backbone.marionette", "main": "lib/core/backbone.marionette.js", "keywords": [ @@ -16,7 +16,7 @@ "client", "browser" ], - "license": "MIT", + "license": "MIT", "licenses": [ { "type": "MIT", @@ -31,8 +31,8 @@ "dependencies": { "marionettejs/backbone.babysitter": "*", "marionettejs/backbone.wreqr": "*", - "jashkenas/backbone": "*", - "jashkenas/underscore": "*" + "jashkenas/backbone": "1.0.0 - 1.2.1", + "jashkenas/underscore": "1.4.4 - 1.8.3" }, "scripts": [ "lib/core/backbone.marionette.js" diff --git a/docs/marionette.collectionview.md b/docs/marionette.collectionview.md index 06683fdc8b..3af17963e6 100644 --- a/docs/marionette.collectionview.md +++ b/docs/marionette.collectionview.md @@ -30,6 +30,7 @@ will provide features such as `onShow` callbacks, etc. Please see * [CollectionView's `getEmptyView`](#collectionviews-getemptyview) * [CollectionView's `isEmpty`](#collectionviews-isempty) * [CollectionView's `emptyViewOptions`](#collectionviews-emptyviewoptions) + * [CollectionView's `destroyChildren`](#collectionviews-destroychildren) * [Callback Methods](#callback-methods) * [onBeforeRender callback](#onbeforerender-callback) * [onRender callback](#onrender-callback) @@ -377,6 +378,16 @@ var CollectionView = Marionette.CollectionView({ }); ``` +### CollectionView's `destroyChildren` + +`CollectionView` provides a `destroyChildren` method that will only destroy it's childViews. This can be useful when you would like to empty your view but keep the data in the `collection`. This method takes an optional `checkEmpty` parameter, by default it is set to `true`, if `false` it will disable the call to `checkEmpty` and `destroyChildren` will not show the `emptyView`. + +```js +myView.destroyChildren(); // will show emptyView +myView.destroyChildren({checkEmpty: false}); // will not show emptyView + +``` + ## Callback Methods There are several callback methods that can be provided on a @@ -747,7 +758,7 @@ new MyCollectionView().render(); ## CollectionView: Automatic Rendering -The collection view binds to the "add", "remove" and "reset" events of the +After the initial render the collection view binds to the "add", "remove" and "reset" events of the collection that is specified. When the collection for the view is "reset", the view will call `render` on @@ -759,6 +770,32 @@ one model in to the collection of child views. When a model is removed from a collection (or destroyed / deleted), the collection view will destroy and remove that model's child view. +When the collection for the view is sorted, the view will automatically re-sort its child views. +if the `reorderOnSort` option is set it will attempt to reorder the DOM and do this without a full re-render, otherwise it will re-render if the order has changed. Please Note that if you apply a filter to the collection view and the filtered views change during a sort then it will always re-render. + +```js +var collection = new Backbone.Collection(); + +var myChildView = Marionette.View.extend({ + template: false +}); + +var MyCollectionView = Marionette.CollectionView.extend({ + childView: myChildView, + collection: collection, +}); + +var myCollectionView = new MyCollectionView(); + +// Collection view will not re-render as it has not been rendered +collection.reset([{foo: 'foo'}]); + +myCollectionView.render(); + +// Collection view will re-render displaying the new model +collection.reset([{foo: 'bar'}]); +``` + ## CollectionView: Re-render Collection If you need to re-render the entire collection, you can call the diff --git a/docs/marionette.compositeview.md b/docs/marionette.compositeview.md index 9426fc2300..9693aef03c 100644 --- a/docs/marionette.compositeview.md +++ b/docs/marionette.compositeview.md @@ -219,6 +219,8 @@ As with item view instances, the composite view instance is passed as the third argument to the `Renderer` object's `render` method, which is useful in custom `Renderer` implementations. +As with CollectionView, CompositeView will maintain the sort order of its child views from the collection. It should be noted that the full view will re-render and not just the children, this is to cater for the use case where no `childViewContainer` is used. + ## Events And Callbacks During the course of rendering a composite, several events will diff --git a/docs/marionette.region.md b/docs/marionette.region.md index 326a4f7ce2..dc318ce116 100644 --- a/docs/marionette.region.md +++ b/docs/marionette.region.md @@ -290,7 +290,7 @@ of the views that are about to be attached – even the nested ones. This can c rendering hundreds or thousands of views at once. If you think these events might be causing some lag in your app, you can selectively turn them off -with the `triggerBeforeAttach` and `triggerAttach` properties. +with the `triggerBeforeAttach` and `triggerAttach` properties or `show()` options. ```js // No longer trigger attach @@ -307,6 +307,13 @@ myRegion.triggerBeforeAttach = false; myRegion.show(myView, {triggerBeforeAttach: true}); ``` +Or you can leave the events on by default but disable them for a single show. + +```js +// This region will trigger attach events by default but not for this particular show. +myRegion.show(myView, {triggerBeforeAttach: false, triggerAttach: false}); +``` + ### Checking whether a region is showing a view If you wish to check whether a region has a view, you can use the `hasView` diff --git a/docs/marionette.view.md b/docs/marionette.view.md index 9aee45d590..1efd3d21fe 100644 --- a/docs/marionette.view.md +++ b/docs/marionette.view.md @@ -33,6 +33,7 @@ behaviors that are shared across all views. * [Accessing Data Within The Helpers](#accessing-data-within-the-helpers) * [Object Or Function As `templateHelpers`](#object-or-function-as-templatehelpers) * [Change Which Template Is Rendered For A View](#change-which-template-is-rendered-for-a-view) +* [UI Interpolation](#ui-interpolation) ## Binding To View Events @@ -568,3 +569,35 @@ var MyView = Marionette.ItemView.extend({ ``` This applies to all view classes. + +## UI Interpolation + +Marionette UI offers a convenient way to reference jQuery elements. +UI elements can also be interpolated into event and region selectors. + +In this example, the buy button is referenced in a DOM event and the checkout section is referenced in the region selector. + + +```js +var MyView = Marionette.ItemView.extend({ + + ui: { + buyButton: '.buy-button', + checkoutSection: '.checkout-section' + }, + + events: { + 'click @ui.buyButton': 'onClickBuyButton' + }, + + regions: { + checkoutSection: '@ui.checkoutSection' + }, + + onShow: function() { + this.getRegion('checkoutSection').show(new CheckoutSection({ + model: this.checkoutModel + })); + } +}); +``` diff --git a/lib/backbone.marionette.js b/lib/backbone.marionette.js index d0e801ddcf..f60778a399 100644 --- a/lib/backbone.marionette.js +++ b/lib/backbone.marionette.js @@ -1,6 +1,6 @@ // MarionetteJS (Backbone.Marionette) // ---------------------------------- -// v2.4.1 +// v2.4.2 // // Copyright (c)2015 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license @@ -38,7 +38,7 @@ /* istanbul ignore next */ // Backbone.BabySitter // ------------------- - // v0.1.6 + // v0.1.7 // // Copyright (c)2015 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license @@ -167,7 +167,7 @@ // return the public API return Container; }(Backbone, _); - Backbone.ChildViewContainer.VERSION = "0.1.6"; + Backbone.ChildViewContainer.VERSION = "0.1.7"; Backbone.ChildViewContainer.noConflict = function() { Backbone.ChildViewContainer = previousChildViewContainer; return this; @@ -178,9 +178,9 @@ /* istanbul ignore next */ // Backbone.Wreqr (Backbone.Marionette) // ---------------------------------- - // v1.3.1 + // v1.3.3 // - // 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.wreqr @@ -188,7 +188,7 @@ "use strict"; var previousWreqr = Backbone.Wreqr; var Wreqr = Backbone.Wreqr = {}; - Backbone.Wreqr.VERSION = "1.3.1"; + Backbone.Wreqr.VERSION = "1.3.3"; Backbone.Wreqr.noConflict = function() { Backbone.Wreqr = previousWreqr; return this; @@ -245,8 +245,7 @@ return; } return function() { - var args = Array.prototype.slice.apply(arguments); - return config.callback.apply(config.context, args); + return config.callback.apply(config.context, arguments); }; }, // Remove a handler for the specified name @@ -312,7 +311,7 @@ // // A simple command pattern implementation. Register a command // handler and execute it. - Wreqr.Commands = function(Wreqr) { + Wreqr.Commands = function(Wreqr, _) { "use strict"; return Wreqr.Handlers.extend({ // default storage type @@ -321,13 +320,12 @@ this.options = options || {}; this._initializeStorage(this.options); this.on("handler:add", this._executeCommands, this); - var args = Array.prototype.slice.call(arguments); - Wreqr.Handlers.prototype.constructor.apply(this, args); + Wreqr.Handlers.prototype.constructor.apply(this, arguments); }, // Execute a named command with the supplied args - execute: function(name, args) { + execute: function(name) { name = arguments[0]; - args = Array.prototype.slice.call(arguments, 1); + var args = _.rest(arguments); if (this.hasHandler(name)) { this.getHandler(name).apply(this, args); } else { @@ -356,24 +354,22 @@ this.storage = storage; } }); - }(Wreqr); + }(Wreqr, _); // Wreqr.RequestResponse // --------------------- // // A simple request/response implementation. Register a // request handler, and return a response from it - Wreqr.RequestResponse = function(Wreqr) { + Wreqr.RequestResponse = function(Wreqr, _) { "use strict"; return Wreqr.Handlers.extend({ - request: function() { - var name = arguments[0]; - var args = Array.prototype.slice.call(arguments, 1); + request: function(name) { if (this.hasHandler(name)) { - return this.getHandler(name).apply(this, args); + return this.getHandler(name).apply(this, _.rest(arguments)); } } }); - }(Wreqr); + }(Wreqr, _); // Event Aggregator // ---------------- // A pub-sub object that can be used to decouple various parts @@ -440,7 +436,7 @@ // -------------- // // An object that lets you communicate with many channels. - Wreqr.radio = function(Wreqr) { + Wreqr.radio = function(Wreqr, _) { "use strict"; var Radio = function() { this._channels = {}; @@ -480,12 +476,11 @@ var proxyMethod = function(radio, system, method) { return function(channelName) { var messageSystem = radio._getChannel(channelName)[system]; - var args = Array.prototype.slice.call(arguments, 1); - return messageSystem[method].apply(messageSystem, args); + return messageSystem[method].apply(messageSystem, _.rest(arguments)); }; }; return new Radio(); - }(Wreqr); + }(Wreqr, _); return Backbone.Wreqr; })(Backbone, _); @@ -494,7 +489,7 @@ var Marionette = Backbone.Marionette = {}; - Marionette.VERSION = '2.4.1'; + Marionette.VERSION = '2.4.2'; Marionette.noConflict = function() { root.Marionette = previousMarionette; @@ -1161,10 +1156,12 @@ // as it's a potentially-slow method var displayedViews = []; - var triggerBeforeAttach = showOptions.triggerBeforeAttach || this.triggerBeforeAttach; - var triggerAttach = showOptions.triggerAttach || this.triggerAttach; + var attachOptions = _.extend({ + triggerBeforeAttach: this.triggerBeforeAttach, + triggerAttach: this.triggerAttach + }, showOptions); - if (attachedRegion && triggerBeforeAttach) { + if (attachedRegion && attachOptions.triggerBeforeAttach) { displayedViews = this._displayedViews(view); this._triggerAttach(displayedViews, 'before:'); } @@ -1172,7 +1169,7 @@ this.attachHtml(view); this.currentView = view; - if (attachedRegion && triggerAttach) { + if (attachedRegion && attachOptions.triggerAttach) { displayedViews = this._displayedViews(view); this._triggerAttach(displayedViews); } @@ -2117,7 +2114,7 @@ } }); - /* jshint maxstatements: 14 */ + /* jshint maxstatements: 20, maxcomplexity: 7 */ // Collection View // --------------- @@ -2141,14 +2138,17 @@ // option to pass `{comparator: compFunction()}` to allow the `CollectionView` // to use a custom sort order for the collection. constructor: function(options) { - this.once('render', this._initialEvents); this._initChildViewStorage(); Marionette.View.apply(this, arguments); - this.on('show', this._onShowCalled); - + this.on({ + 'before:show': this._onBeforeShowCalled, + 'show': this._onShowCalled, + 'before:attach': this._onBeforeAttachCalled, + 'attach': this._onAttachCalled + }); this.initRenderBuffer(); }, @@ -2165,33 +2165,38 @@ }, endBuffering: function() { - this.isBuffering = false; - this._triggerBeforeShowBufferedChildren(); - - this.attachBuffer(this); + // Only trigger attach if already shown and attached, otherwise Region#show() handles this. + var canTriggerAttach = this._isShown && Marionette.isNodeAttached(this.el); + var nestedViews; - this._triggerShowBufferedChildren(); - this.initRenderBuffer(); - }, + this.isBuffering = false; - _triggerBeforeShowBufferedChildren: function() { if (this._isShown) { - _.each(this._bufferedChildren, _.partial(this._triggerMethodOnChild, 'before:show')); + this._triggerMethodMany(this._bufferedChildren, this, 'before:show'); + } + if (canTriggerAttach && this._triggerBeforeAttach) { + nestedViews = this._getNestedViews(); + this._triggerMethodMany(nestedViews, this, 'before:attach'); } - }, - _triggerShowBufferedChildren: function() { - if (this._isShown) { - _.each(this._bufferedChildren, _.partial(this._triggerMethodOnChild, 'show')); + this.attachBuffer(this, this._createBuffer()); - this._bufferedChildren = []; + if (canTriggerAttach && this._triggerAttach) { + nestedViews = this._getNestedViews(); + this._triggerMethodMany(nestedViews, this, 'attach'); + } + if (this._isShown) { + this._triggerMethodMany(this._bufferedChildren, this, 'show'); } + this.initRenderBuffer(); }, - // Internal method for _.each loops to call `Marionette.triggerMethodOn` on - // a child view - _triggerMethodOnChild: function(event, childView) { - Marionette.triggerMethodOn(childView, event); + _triggerMethodMany: function(targets, source, eventName) { + var args = _.drop(arguments, 3); + + _.each(targets, function(target) { + Marionette.triggerMethodOn.apply(target, [target, eventName, target, source].concat(args)); + }); }, // Configured the initial events that the collection view @@ -2231,8 +2236,29 @@ this.checkEmpty(); }, + _onBeforeShowCalled: function() { + // Reset attach event flags at the top of the Region#show() event lifecycle; if the Region's + // show() options permit onBeforeAttach/onAttach events, these flags will be set true again. + this._triggerBeforeAttach = this._triggerAttach = false; + this.children.each(function(childView) { + Marionette.triggerMethodOn(childView, 'before:show', childView); + }); + }, + _onShowCalled: function() { - this.children.each(_.partial(this._triggerMethodOnChild, 'show')); + this.children.each(function(childView) { + Marionette.triggerMethodOn(childView, 'show', childView); + }); + }, + + // If during Region#show() onBeforeAttach was fired, continue firing it for child views + _onBeforeAttachCalled: function() { + this._triggerBeforeAttach = true; + }, + + // If during Region#show() onAttach was fired, continue firing it for child views + _onAttachCalled: function() { + this._triggerAttach = true; }, // Render children views. Override this method to @@ -2265,8 +2291,10 @@ 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; + var els = _.map(models, function(model, index) { + var view = children.findByModel(model); + view._index = index; + return view.el; }); // since append moves elements that are already in the DOM, @@ -2319,7 +2347,7 @@ // process _renderChildren: function() { this.destroyEmptyView(); - this.destroyChildren(); + this.destroyChildren({checkEmpty: false}); if (this.isEmpty(this.collection)) { this.showEmptyView(); @@ -2413,6 +2441,10 @@ // but "add:child" events are not fired, and the event from // emptyView are not forwarded addEmptyView: function(child, EmptyView) { + // Only trigger attach if already shown, attached, and not buffering, otherwise endBuffer() or + // Region#show() handles this. + var canTriggerAttach = this._isShown && !this.isBuffering && Marionette.isNodeAttached(this.el); + var nestedViews; // get the emptyViewOptions, falling back to childViewOptions var emptyViewOptions = this.getOption('emptyViewOptions') || @@ -2430,23 +2462,35 @@ // Proxy emptyView events this.proxyChildEvents(view); - // trigger the 'before:show' event on `view` if the collection view - // has already been shown + // trigger the 'before:show' event on `view` if the collection view has already been shown if (this._isShown) { - Marionette.triggerMethodOn(view, 'before:show'); + Marionette.triggerMethodOn(view, 'before:show', view); } // Store the `emptyView` like a `childView` so we can properly // remove and/or close it later this.children.add(view); + // Trigger `before:attach` following `render` to avoid adding logic and event triggers + // to public method `renderChildView()`. + if (canTriggerAttach && this._triggerBeforeAttach) { + nestedViews = [view].concat(view._getNestedViews()); + view.once('render', function() { + this._triggerMethodMany(nestedViews, this, 'before:attach'); + }, this); + } + // Render it and show it this.renderChildView(view, this._emptyViewIndex); - // call the 'show' method if the collection view - // has already been shown + // Trigger `attach` + if (canTriggerAttach && this._triggerAttach) { + nestedViews = [view].concat(view._getNestedViews()); + this._triggerMethodMany(nestedViews, this, 'attach'); + } + // call the 'show' method if the collection view has already been shown if (this._isShown) { - Marionette.triggerMethodOn(view, 'show'); + Marionette.triggerMethodOn(view, 'show', view); } }, @@ -2482,7 +2526,9 @@ // increment indices of views after this one this._updateIndices(view, true, index); + this.triggerMethod('before:add:child', view); this._addChildView(view, index); + this.triggerMethod('add:child', view); view._parent = this; @@ -2512,27 +2558,42 @@ // Internal Method. Add the view to children and render it at // the given index. _addChildView: function(view, index) { + // Only trigger attach if already shown, attached, and not buffering, otherwise endBuffer() or + // Region#show() handles this. + var canTriggerAttach = this._isShown && !this.isBuffering && Marionette.isNodeAttached(this.el); + var nestedViews; + // set up the child view event forwarding this.proxyChildEvents(view); - this.triggerMethod('before:add:child', view); - - // trigger the 'before:show' event on `view` if the collection view - // has already been shown + // 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'); + Marionette.triggerMethodOn(view, 'before:show', view); } - // Store the child view itself so we can properly - // remove and/or destroy it later + // Store the child view itself so we can properly remove and/or destroy it later this.children.add(view); + + // Trigger `before:attach` following `render` to avoid adding logic and event triggers + // to public method `renderChildView()`. + if (canTriggerAttach && this._triggerBeforeAttach) { + nestedViews = [view].concat(view._getNestedViews()); + view.once('render', function() { + this._triggerMethodMany(nestedViews, this, 'before:attach'); + }, this); + } + this.renderChildView(view, index); + // Trigger `attach` + if (canTriggerAttach && this._triggerAttach) { + nestedViews = [view].concat(view._getNestedViews()); + this._triggerMethodMany(nestedViews, this, 'attach'); + } + // Trigger `show` if (this._isShown && !this.isBuffering) { - Marionette.triggerMethodOn(view, 'show'); + Marionette.triggerMethodOn(view, 'show', view); } - - this.triggerMethod('add:child', view); }, // render the child view @@ -2589,14 +2650,14 @@ }, // You might need to override this if you've overridden attachHtml - attachBuffer: function(collectionView) { - collectionView.$el.append(this._createBuffer(collectionView)); + attachBuffer: function(collectionView, buffer) { + collectionView.$el.append(buffer); }, // Create a fragment buffer from the currently buffered children - _createBuffer: function(collectionView) { + _createBuffer: function() { var elBuffer = document.createDocumentFragment(); - _.each(collectionView._bufferedChildren, function(b) { + _.each(this._bufferedChildren, function(b) { elBuffer.appendChild(b.el); }); return elBuffer; @@ -2657,7 +2718,7 @@ if (this.isDestroyed) { return this; } this.triggerMethod('before:destroy:collection'); - this.destroyChildren(); + this.destroyChildren({checkEmpty: false}); this.triggerMethod('destroy:collection'); return Marionette.View.prototype.destroy.apply(this, arguments); @@ -2665,10 +2726,20 @@ // Destroy the child views that this collection view // is holding on to, if any - destroyChildren: function() { + destroyChildren: function(options) { + var destroyOptions = options || {}; + var shouldCheckEmpty = true; var childViews = this.children.map(_.identity); + + if (!_.isUndefined(destroyOptions.checkEmpty)) { + shouldCheckEmpty = destroyOptions.checkEmpty; + } + this.children.each(this.removeChildView, this); - this.checkEmpty(); + + if (shouldCheckEmpty) { + this.checkEmpty(); + } return childViews; }, @@ -2840,9 +2911,9 @@ }, // You might need to override this if you've overridden attachHtml - attachBuffer: function(compositeView) { + attachBuffer: function(compositeView, buffer) { var $container = this.getChildViewContainer(compositeView); - $container.append(this._createBuffer(compositeView)); + $container.append(buffer); }, // Internal method. Append a view to the end of the $el. @@ -2864,7 +2935,7 @@ // Internal method to ensure an `$childViewContainer` exists, for the // `attachHtml` method to use. getChildViewContainer: function(containerView, childView) { - if ('$childViewContainer' in containerView) { + if (!!containerView.$childViewContainer) { return containerView.$childViewContainer; } @@ -2898,7 +2969,7 @@ // Internal method to reset the `$childViewContainer` on render resetChildViewContainer: function() { if (this.$childViewContainer) { - delete this.$childViewContainer; + this.$childViewContainer = undefined; } } }); diff --git a/lib/backbone.marionette.map b/lib/backbone.marionette.map new file mode 100644 index 0000000000..3be2e7e1c4 --- /dev/null +++ b/lib/backbone.marionette.map @@ -0,0 +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","removeHandler","removeAllHandlers","CommandStorage","_commands","getCommands","commandName","commands","command","instances","addCommand","push","clearCommands","Commands","storageType","constructor","_initializeStorage","on","_executeCommands","execute","rest","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","slice","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","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","attachOptions","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","before:show","_onBeforeShowCalled","_onShowCalled","before:attach","_onBeforeAttachCalled","attach","_onAttachCalled","initRenderBuffer","_bufferedChildren","startBuffering","isBuffering","endBuffering","nestedViews","canTriggerAttach","_triggerMethodMany","_triggerBeforeAttach","attachBuffer","_createBuffer","targets","source","_onCollectionAdd","_onCollectionRemove","_sortViews","child","opts","at","indexOf","_filteredSortedModels","_shouldAddChild","destroyEmptyView","ChildView","getChildView","addChild","removeChildView","checkEmpty","childView","_renderChildren","reorder","models","modelsChanged","els","map","_index","_appendReorderedChildren","resortView","orderChanged","item","_emptyViewIndex","append","destroyChildren","isEmpty","showEmptyView","showCollection","viewComparator","getViewComparator","sortBy","filter","EmptyView","getEmptyView","_showingEmptyView","addEmptyView","emptyViewOptions","buildChildView","proxyChildEvents","renderChildView","childViewOptions","_updateIndices","_addChildView","increment","laterView","ChildViewClass","collectionView","buffer","elBuffer","createDocumentFragment","b","splice","_insertBefore","_insertAfter","findPosition","before","destroyOptions","shouldCheckEmpty","childViews","identity","rootEvent","CompositeView","partial","_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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,kBAAqBriB,EAAOyjB,8BAIxCzjB,EAAOyjB,6BAA8B,EAErCT,EAAa1B,eAAe,SAASve,GAC/B/C,EAAOqiB,iBACTriB,EAAOwhB,MAAMze,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 994efee9bb..a57d510924 100644 --- a/lib/backbone.marionette.min.js +++ b/lib/backbone.marionette.min.js @@ -1,6 +1,6 @@ // MarionetteJS (Backbone.Marionette) // ---------------------------------- -// v2.4.1 +// v2.4.2 // // Copyright (c)2015 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license @@ -17,7 +17,6 @@ */ - -!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(c,d){return a.Marionette=a.Mn=b(a,c,d)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(a,c,d)}else a.Marionette=a.Mn=b(a,a.Backbone,a._)}(this,function(a,b,c){"use strict";!function(a,b){var c=a.ChildViewContainer;return a.ChildViewContainer=function(a,b){var c=function(a){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),b.each(a,this.add,this)};b.extend(c.prototype,{add:function(a,b){var c=a.cid;return this._views[c]=a,a.model&&(this._indexByModel[a.model.cid]=c),b&&(this._indexByCustom[b]=c),this._updateLength(),this},findByModel:function(a){return this.findByModelCid(a.cid)},findByModelCid:function(a){var b=this._indexByModel[a];return this.findByCid(b)},findByCustom:function(a){var b=this._indexByCustom[a];return this.findByCid(b)},findByIndex:function(a){return b.values(this._views)[a]},findByCid:function(a){return this._views[a]},remove:function(a){var c=a.cid;return a.model&&delete this._indexByModel[a.model.cid],b.any(this._indexByCustom,function(a,b){return a===c?(delete this._indexByCustom[b],!0):void 0},this),delete this._views[c],this._updateLength(),this},call:function(a){this.apply(a,b.tail(arguments))},apply:function(a,c){b.each(this._views,function(d){b.isFunction(d[a])&&d[a].apply(d,c||[])})},_updateLength:function(){this.length=b.size(this._views)}});var d=["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 b.each(d,function(a){c.prototype[a]=function(){var c=b.values(this._views),d=[c].concat(b.toArray(arguments));return b[a].apply(b,d)}}),c}(a,b),a.ChildViewContainer.VERSION="0.1.6",a.ChildViewContainer.noConflict=function(){return a.ChildViewContainer=c,this},a.ChildViewContainer}(b,c),function(a,b){var c=a.Wreqr,d=a.Wreqr={};return a.Wreqr.VERSION="1.3.1",a.Wreqr.noConflict=function(){return a.Wreqr=c,this},d.Handlers=function(a,b){var c=function(a){this.options=a,this._wreqrHandlers={},b.isFunction(this.initialize)&&this.initialize(a)};return c.extend=a.Model.extend,b.extend(c.prototype,a.Events,{setHandlers:function(a){b.each(a,function(a,c){var d=null;b.isObject(a)&&!b.isFunction(a)&&(d=a.context,a=a.callback),this.setHandler(c,a,d)},this)},setHandler:function(a,b,c){var d={callback:b,context:c};this._wreqrHandlers[a]=d,this.trigger("handler:add",a,b,c)},hasHandler:function(a){return!!this._wreqrHandlers[a]},getHandler:function(a){var b=this._wreqrHandlers[a];if(b)return function(){var a=Array.prototype.slice.apply(arguments);return b.callback.apply(b.context,a)}},removeHandler:function(a){delete this._wreqrHandlers[a]},removeAllHandlers:function(){this._wreqrHandlers={}}}),c}(a,b),d.CommandStorage=function(){var c=function(a){this.options=a,this._commands={},b.isFunction(this.initialize)&&this.initialize(a)};return b.extend(c.prototype,a.Events,{getCommands:function(a){var b=this._commands[a];return b||(b={command:a,instances:[]},this._commands[a]=b),b},addCommand:function(a,b){var c=this.getCommands(a);c.instances.push(b)},clearCommands:function(a){var b=this.getCommands(a);b.instances=[]}}),c}(),d.Commands=function(a){return a.Handlers.extend({storageType:a.CommandStorage,constructor:function(b){this.options=b||{},this._initializeStorage(this.options),this.on("handler:add",this._executeCommands,this);var c=Array.prototype.slice.call(arguments);a.Handlers.prototype.constructor.apply(this,c)},execute:function(a,b){a=arguments[0],b=Array.prototype.slice.call(arguments,1),this.hasHandler(a)?this.getHandler(a).apply(this,b):this.storage.addCommand(a,b)},_executeCommands:function(a,c,d){var e=this.storage.getCommands(a);b.each(e.instances,function(a){c.apply(d,a)}),this.storage.clearCommands(a)},_initializeStorage:function(a){var c,d=a.storageType||this.storageType;c=b.isFunction(d)?new d:d,this.storage=c}})}(d),d.RequestResponse=function(a){return a.Handlers.extend({request:function(){var a=arguments[0],b=Array.prototype.slice.call(arguments,1);return this.hasHandler(a)?this.getHandler(a).apply(this,b):void 0}})}(d),d.EventAggregator=function(a,b){var c=function(){};return c.extend=a.Model.extend,b.extend(c.prototype,a.Events),c}(a,b),d.Channel=function(){var c=function(b){this.vent=new a.Wreqr.EventAggregator,this.reqres=new a.Wreqr.RequestResponse,this.commands=new a.Wreqr.Commands,this.channelName=b};return b.extend(c.prototype,{reset:function(){return this.vent.off(),this.vent.stopListening(),this.reqres.removeAllHandlers(),this.commands.removeAllHandlers(),this},connectEvents:function(a,b){return this._connect("vent",a,b),this},connectCommands:function(a,b){return this._connect("commands",a,b),this},connectRequests:function(a,b){return this._connect("reqres",a,b),this},_connect:function(a,c,d){if(c){d=d||this;var e="vent"===a?"on":"setHandler";b.each(c,function(c,f){this[a][e](f,b.bind(c,d))},this)}}}),c}(d),d.radio=function(a){var c=function(){this._channels={},this.vent={},this.commands={},this.reqres={},this._proxyMethods()};b.extend(c.prototype,{channel:function(a){if(!a)throw new Error("Channel must receive a name");return this._getChannel(a)},_getChannel:function(b){var c=this._channels[b];return c||(c=new a.Channel(b),this._channels[b]=c),c},_proxyMethods:function(){b.each(["vent","commands","reqres"],function(a){b.each(d[a],function(b){this[a][b]=e(this,a,b)},this)},this)}});var d={vent:["on","off","trigger","once","stopListening","listenTo","listenToOnce"],commands:["execute","setHandler","setHandlers","removeHandler","removeAllHandlers"],reqres:["request","setHandler","setHandlers","removeHandler","removeAllHandlers"]},e=function(a,b,c){return function(d){var e=a._getChannel(d)[b],f=Array.prototype.slice.call(arguments,1);return e[c].apply(e,f)}};return new c}(d),a.Wreqr}(b,c);var d=a.Marionette,e=a.Mn,f=b.Marionette={};f.VERSION="2.4.1",f.noConflict=function(){return a.Marionette=d,a.Mn=e,this},b.Marionette=f,f.Deferred=b.$.Deferred,f.extend=b.Model.extend,f.isNodeAttached=function(a){return b.$.contains(document.documentElement,a)},f.mergeOptions=function(a,b){a&&c.extend(this,c.pick(a,b))},f.getOption=function(a,b){return a&&b?a.options&&void 0!==a.options[b]?a.options[b]:a[b]:void 0},f.proxyGetOption=function(a){return f.getOption(this,a)},f._getValue=function(a,b,d){return c.isFunction(a)&&(a=d?a.apply(b,d):a.call(b)),a},f.normalizeMethods=function(a){return c.reduce(a,function(a,b,d){return c.isFunction(b)||(b=this[b]),b&&(a[d]=b),a},{},this)},f.normalizeUIString=function(a,b){return a.replace(/@ui\.[a-zA-Z_$0-9]*/g,function(a){return b[a.slice(4)]})},f.normalizeUIKeys=function(a,b){return c.reduce(a,function(a,c,d){var e=f.normalizeUIString(d,b);return a[e]=c,a},{})},f.normalizeUIValues=function(a,b,d){return c.each(a,function(e,g){c.isString(e)?a[g]=f.normalizeUIString(e,b):c.isObject(e)&&c.isArray(d)&&(c.extend(e,f.normalizeUIValues(c.pick(e,d),b)),c.each(d,function(a){var d=e[a];c.isString(d)&&(e[a]=f.normalizeUIString(d,b))}))}),a},f.actAsCollection=function(a,b){var d=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];c.each(d,function(d){a[d]=function(){var a=c.values(c.result(this,b)),e=[a].concat(c.toArray(arguments));return c[d].apply(c,e)}})};var g=f.deprecate=function(a,b){c.isObject(a)&&(a=a.prev+" is going to be removed in the future. Please use "+a.next+" instead."+(a.url?" See: "+a.url:"")),void 0!==b&&b||g._cache[a]||(g._warn("Deprecation warning: "+a),g._cache[a]=!0)};g._warn="undefined"!=typeof console&&(console.warn||console.log)||function(){},g._cache={},f._triggerMethod=function(){function a(a,b,c){return c.toUpperCase()}var b=/(^|:)(\w)/gi;return function(d,e,f){var g=arguments.length<3;g&&(f=e,e=f[0]);var h,i="on"+e.replace(b,a),j=d[i];return c.isFunction(j)&&(h=j.apply(d,g?c.rest(f):f)),c.isFunction(d.trigger)&&(g+f.length>1?d.trigger.apply(d,g?f:[e].concat(c.drop(f,0))):d.trigger(e)),h}}(),f.triggerMethod=function(){return f._triggerMethod(this,arguments)},f.triggerMethodOn=function(a){var b=c.isFunction(a.triggerMethod)?a.triggerMethod:f.triggerMethod;return b.apply(a,c.rest(arguments))},f.MonitorDOMRefresh=function(a){function b(){a._isShown=!0,e()}function d(){a._isRendered=!0,e()}function e(){a._isShown&&a._isRendered&&f.isNodeAttached(a.el)&&c.isFunction(a.triggerMethod)&&a.triggerMethod("dom:refresh")}a.on({show:b,render:d})},function(a){function b(b,d,e,f){var g=f.split(/\s+/);c.each(g,function(c){var f=b[c];if(!f)throw new a.Error('Method "'+c+'" was configured as an event handler, but does not exist.');b.listenTo(d,e,f)})}function d(a,b,c,d){a.listenTo(b,c,d)}function e(a,b,d,e){var f=e.split(/\s+/);c.each(f,function(c){var e=a[c];a.stopListening(b,d,e)})}function f(a,b,c,d){a.stopListening(b,c,d)}function g(b,d,e,f,g){if(d&&e){if(!c.isObject(e))throw new a.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});e=a._getValue(e,b),c.each(e,function(a,e){c.isFunction(a)?f(b,d,e,a):g(b,d,e,a)})}}a.bindEntityEvents=function(a,c,e){g(a,c,e,d,b)},a.unbindEntityEvents=function(a,b,c){g(a,b,c,f,e)},a.proxyBindEntityEvents=function(b,c){return a.bindEntityEvents(this,b,c)},a.proxyUnbindEntityEvents=function(b,c){return a.unbindEntityEvents(this,b,c)}}(f);var h=["description","fileName","lineNumber","name","message","number"];return f.Error=f.extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+f.VERSION+"/",constructor:function(a,b){c.isObject(a)?(b=a,a=b.message):b||(b={});var d=Error.call(this,a);c.extend(this,c.pick(d,h),c.pick(b,h)),this.captureStackTrace(),b.url&&(this.url=this.urlRoot+b.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,f.Error)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}}),f.Error.extend=f.extend,f.Callbacks=function(){this._deferred=f.Deferred(),this._callbacks=[]},c.extend(f.Callbacks.prototype,{add:function(a,b){var d=c.result(this._deferred,"promise");this._callbacks.push({cb:a,ctx:b}),d.then(function(c){b&&(c.context=b),a.call(c.context,c.options)})},run:function(a,b){this._deferred.resolve({options:a,context:b})},reset:function(){var a=this._callbacks;this._deferred=f.Deferred(),this._callbacks=[],c.each(a,function(a){this.add(a.cb,a.ctx)},this)}}),f.Controller=function(a){this.options=a||{},c.isFunction(this.initialize)&&this.initialize(this.options)},f.Controller.extend=f.extend,c.extend(f.Controller.prototype,b.Events,{destroy:function(){return f._triggerMethod(this,"before:destroy",arguments),f._triggerMethod(this,"destroy",arguments),this.stopListening(),this.off(),this},triggerMethod:f.triggerMethod,mergeOptions:f.mergeOptions,getOption:f.proxyGetOption}),f.Object=function(a){this.options=c.extend({},c.result(this,"options"),a),this.initialize.apply(this,arguments)},f.Object.extend=f.extend,c.extend(f.Object.prototype,b.Events,{initialize:function(){},destroy:function(){return this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening(),this},triggerMethod:f.triggerMethod,mergeOptions:f.mergeOptions,getOption:f.proxyGetOption,bindEntityEvents:f.proxyBindEntityEvents,unbindEntityEvents:f.proxyUnbindEntityEvents}),f.Region=f.Object.extend({constructor:function(a){if(this.options=a||{},this.el=this.getOption("el"),this.el=this.el instanceof b.$?this.el[0]:this.el,!this.el)throw new f.Error({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),f.Object.call(this,a)},show:function(a,b){if(this._ensureElement()){this._ensureViewIsIntact(a);var c=b||{},d=a!==this.currentView,e=!!c.preventDestroy,g=!!c.forceShow,h=!!this.currentView,i=d&&!e,j=d||g;if(h&&this.triggerMethod("before:swapOut",this.currentView,this,b),this.currentView&&delete this.currentView._parent,i?this.empty():h&&j&&this.currentView.off("destroy",this.empty,this),j){a.once("destroy",this.empty,this),a.render(),a._parent=this,h&&this.triggerMethod("before:swap",a,this,b),this.triggerMethod("before:show",a,this,b),f.triggerMethodOn(a,"before:show",a,this,b),h&&this.triggerMethod("swapOut",this.currentView,this,b);var k=f.isNodeAttached(this.el),l=[],m=c.triggerBeforeAttach||this.triggerBeforeAttach,n=c.triggerAttach||this.triggerAttach;return k&&m&&(l=this._displayedViews(a),this._triggerAttach(l,"before:")),this.attachHtml(a),this.currentView=a,k&&n&&(l=this._displayedViews(a),this._triggerAttach(l)),h&&this.triggerMethod("swap",a,this,b),this.triggerMethod("show",a,this,b),f.triggerMethodOn(a,"show",a,this,b),this}return this}},triggerBeforeAttach:!0,triggerAttach:!0,_triggerAttach:function(a,b){var d=(b||"")+"attach";c.each(a,function(a){f.triggerMethodOn(a,d,a,this)},this)},_displayedViews:function(a){return c.union([a],c.result(a,"_getNestedViews")||[])},_ensureElement:function(){if(c.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 f.Error('An "el" '+this.$el.selector+" must exist in DOM")}return!0},_ensureViewIsIntact:function(a){if(!a)throw new f.Error({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(a.isDestroyed)throw new f.Error({name:"ViewDestroyedError",message:'View (cid: "'+a.cid+'") has already been destroyed and cannot be used.'})},getEl:function(a){return b.$(a,f._getValue(this.options.parentEl,this))},attachHtml:function(a){this.$el.contents().detach(),this.el.appendChild(a.el)},empty:function(a){var b=this.currentView,c=f._getValue(a,"preventDestroy",this);return b?(b.off("destroy",this.empty,this),this.triggerMethod("before:empty",b),c||this._destroyView(),this.triggerMethod("empty",b),delete this.currentView,c&&this.$el.contents().detach(),this):void 0},_destroyView:function(){var a=this.currentView;a.destroy&&!a.isDestroyed?a.destroy():a.remove&&(a.remove(),a.isDestroyed=!0)},attachView:function(a){return this.currentView=a,this},hasView:function(){return!!this.currentView},reset:function(){return this.empty(),this.$el&&(this.el=this.$el.selector),delete this.$el,this}},{buildRegion:function(a,b){if(c.isString(a))return this._buildRegionFromSelector(a,b);if(a.selector||a.el||a.regionClass)return this._buildRegionFromObject(a,b);if(c.isFunction(a))return this._buildRegionFromRegionClass(a);throw new f.Error({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})},_buildRegionFromSelector:function(a,b){return new b({el:a})},_buildRegionFromObject:function(a,b){var d=a.regionClass||b,e=c.omit(a,"selector","regionClass");return a.selector&&!e.el&&(e.el=a.selector),new d(e)},_buildRegionFromRegionClass:function(a){return new a}}),f.RegionManager=f.Controller.extend({constructor:function(a){this._regions={},this.length=0,f.Controller.call(this,a),this.addRegions(this.getOption("regions"))},addRegions:function(a,b){return a=f._getValue(a,this,arguments),c.reduce(a,function(a,d,e){return c.isString(d)&&(d={selector:d}),d.selector&&(d=c.defaults({},d,b)),a[e]=this.addRegion(e,d),a},{},this)},addRegion:function(a,b){var c;return c=b instanceof f.Region?b:f.Region.buildRegion(b,f.Region),this.triggerMethod("before:add:region",a,c),c._parent=this,this._store(a,c),this.triggerMethod("add:region",a,c),c},get:function(a){return this._regions[a]},getRegions:function(){return c.clone(this._regions)},removeRegion:function(a){var b=this._regions[a];return this._remove(a,b),b},removeRegions:function(){var a=this.getRegions();return c.each(this._regions,function(a,b){this._remove(b,a)},this),a},emptyRegions:function(){var a=this.getRegions();return c.invoke(a,"empty"),a},destroy:function(){return this.removeRegions(),f.Controller.prototype.destroy.apply(this,arguments)},_store:function(a,b){this._regions[a]||this.length++,this._regions[a]=b},_remove:function(a,b){this.triggerMethod("before:remove:region",a,b),b.empty(),b.stopListening(),delete b._parent,delete this._regions[a],this.length--,this.triggerMethod("remove:region",a,b)}}),f.actAsCollection(f.RegionManager.prototype,"_regions"),f.TemplateCache=function(a){this.templateId=a},c.extend(f.TemplateCache,{templateCaches:{},get:function(a,b){var c=this.templateCaches[a];return c||(c=new f.TemplateCache(a),this.templateCaches[a]=c),c.load(b)},clear:function(){var a,b=c.toArray(arguments),d=b.length;if(d>0)for(a=0;d>a;a++)delete this.templateCaches[b[a]];else this.templateCaches={}}}),c.extend(f.TemplateCache.prototype,{load:function(a){if(this.compiledTemplate)return this.compiledTemplate;var b=this.loadTemplate(this.templateId,a);return this.compiledTemplate=this.compileTemplate(b,a),this.compiledTemplate},loadTemplate:function(a){var c=b.$(a).html();if(!c||0===c.length)throw new f.Error({name:"NoTemplateError",message:'Could not find template: "'+a+'"'});return c},compileTemplate:function(a,b){return c.template(a,b)}}),f.Renderer={render:function(a,b){if(!a)throw new f.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var d=c.isFunction(a)?a:f.TemplateCache.get(a);return d(b)}},f.View=b.View.extend({isDestroyed:!1,constructor:function(a){c.bindAll(this,"render"),a=f._getValue(a,this),this.options=c.extend({},c.result(this,"options"),a),this._behaviors=f.Behaviors(this),b.View.call(this,this.options),f.MonitorDOMRefresh(this)},getTemplate:function(){return this.getOption("template")},serializeModel:function(a){return a.toJSON.apply(a,c.rest(arguments))},mixinTemplateHelpers:function(a){a=a||{};var b=this.getOption("templateHelpers");return b=f._getValue(b,this),c.extend(a,b)},normalizeUIKeys:function(a){var b=c.result(this,"_uiBindings");return f.normalizeUIKeys(a,b||c.result(this,"ui"))},normalizeUIValues:function(a,b){var d=c.result(this,"ui"),e=c.result(this,"_uiBindings");return f.normalizeUIValues(a,e||d,b)},configureTriggers:function(){if(this.triggers){var a=this.normalizeUIKeys(c.result(this,"triggers"));return c.reduce(a,function(a,b,c){return a[c]=this._buildViewTrigger(b),a},{},this)}},delegateEvents:function(a){return this._delegateDOMEvents(a),this.bindEntityEvents(this.model,this.getOption("modelEvents")),this.bindEntityEvents(this.collection,this.getOption("collectionEvents")),c.each(this._behaviors,function(a){a.bindEntityEvents(this.model,a.getOption("modelEvents")),a.bindEntityEvents(this.collection,a.getOption("collectionEvents"))},this),this},_delegateDOMEvents:function(a){var d=f._getValue(a||this.events,this);d=this.normalizeUIKeys(d),c.isUndefined(a)&&(this.events=d);var e={},g=c.result(this,"behaviorEvents")||{},h=this.configureTriggers(),i=c.result(this,"behaviorTriggers")||{};c.extend(e,g,d,h,i),b.View.prototype.delegateEvents.call(this,e)},undelegateEvents:function(){return b.View.prototype.undelegateEvents.apply(this,arguments),this.unbindEntityEvents(this.model,this.getOption("modelEvents")),this.unbindEntityEvents(this.collection,this.getOption("collectionEvents")),c.each(this._behaviors,function(a){a.unbindEntityEvents(this.model,a.getOption("modelEvents")),a.unbindEntityEvents(this.collection,a.getOption("collectionEvents"))},this),this},_ensureViewIsIntact:function(){if(this.isDestroyed)throw new f.Error({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(this.isDestroyed)return this;var a=c.toArray(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(a)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(a)),this.unbindUIElements(),this.isRendered=!1,this.remove(),c.invoke(this._behaviors,"destroy",a),this},bindUIElements:function(){this._bindUIElements(),c.invoke(this._behaviors,this._bindUIElements)},_bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var a=c.result(this,"_uiBindings");this.ui={},c.each(a,function(a,b){this.ui[b]=this.$(a)},this)}},unbindUIElements:function(){this._unbindUIElements(),c.invoke(this._behaviors,this._unbindUIElements)},_unbindUIElements:function(){this.ui&&this._uiBindings&&(c.each(this.ui,function(a,b){delete this.ui[b]},this),this.ui=this._uiBindings,delete this._uiBindings)},_buildViewTrigger:function(a){var b=c.isObject(a),d=c.defaults({},b?a:{},{preventDefault:!0,stopPropagation:!0}),e=b?d.event:a;return function(a){a&&(a.preventDefault&&d.preventDefault&&a.preventDefault(),a.stopPropagation&&d.stopPropagation&&a.stopPropagation());var b={view:this,model:this.model,collection:this.collection};this.triggerMethod(e,b)}},setElement:function(){var a=b.View.prototype.setElement.apply(this,arguments);return c.invoke(this._behaviors,"proxyViewProperties",this),a},triggerMethod:function(){var a=f._triggerMethod(this,arguments);return this._triggerEventOnBehaviors(arguments),this._triggerEventOnParentLayout(arguments[0],c.rest(arguments)),a},_triggerEventOnBehaviors:function(a){for(var b=f._triggerMethod,c=this._behaviors,d=0,e=c&&c.length;e>d;d++)b(c[d],a)},_triggerEventOnParentLayout:function(a,b){var d=this._parentLayoutView();if(d){var e=f.getOption(d,"childViewEventPrefix"),g=e+":"+a;f._triggerMethod(d,[g,this].concat(b));var h=f.getOption(d,"childEvents"),i=d.normalizeMethods(h);i&&c.isFunction(i[a])&&i[a].apply(d,[this].concat(b))}},_getImmediateChildren:function(){return[]},_getNestedViews:function(){var a=this._getImmediateChildren();return a.length?c.reduce(a,function(a,b){return b._getNestedViews?a.concat(b._getNestedViews()):a},a):a},_getAncestors:function(){for(var a=[],b=this._parent;b;)a.push(b),b=b._parent;return a},_parentLayoutView:function(){var a=this._getAncestors();return c.find(a,function(a){return a instanceof f.LayoutView})},normalizeMethods:f.normalizeMethods,mergeOptions:f.mergeOptions,getOption:f.proxyGetOption,bindEntityEvents:f.proxyBindEntityEvents,unbindEntityEvents:f.proxyUnbindEntityEvents}),f.ItemView=f.View.extend({constructor:function(){f.View.apply(this,arguments)},serializeData:function(){if(!this.model&&!this.collection)return{};var a=[this.model||this.collection];return arguments.length&&a.push.apply(a,arguments),this.model?this.serializeModel.apply(this,a):{items:this.serializeCollection.apply(this,a)}},serializeCollection:function(a){return a.toJSON.apply(a,c.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 a=this.getTemplate();if(a!==!1){if(!a)throw new f.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var b=this.mixinTemplateHelpers(this.serializeData()),c=f.Renderer.render(a,b,this);return this.attachElContent(c),this}},attachElContent:function(a){return this.$el.html(a),this}}),f.CollectionView=f.View.extend({childViewEventPrefix:"childview",sort:!0,constructor:function(){this.once("render",this._initialEvents),this._initChildViewStorage(),f.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&&c.each(this._bufferedChildren,c.partial(this._triggerMethodOnChild,"before:show"))},_triggerShowBufferedChildren:function(){this._isShown&&(c.each(this._bufferedChildren,c.partial(this._triggerMethodOnChild,"show")),this._bufferedChildren=[])},_triggerMethodOnChild:function(a,b){f.triggerMethodOn(b,a)},_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(a,b,d){var e;if(e=void 0!==d.at?d.at:c.indexOf(this._filteredSortedModels(),a),this._shouldAddChild(a,e)){this.destroyEmptyView();var f=this.getChildView(a);this.addChild(a,f,e)}},_onCollectionRemove:function(a){var b=this.children.findByModel(a);this.removeChildView(b),this.checkEmpty()},_onShowCalled:function(){this.children.each(c.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 a=this.children,b=this._filteredSortedModels(),d=c.find(b,function(b){return!a.findByModel(b)});if(d)this.render();else{var e=c.map(b,function(b){return a.findByModel(b).el});this.triggerMethod("before:reorder"),this._appendReorderedChildren(e),this.triggerMethod("reorder")}},resortView:function(){f.getOption(this,"reorderOnSort")?this.reorder():this.render()},_sortViews:function(){var a=this._filteredSortedModels(),b=c.find(a,function(a,b){var c=this.children.findByModel(a);return!c||c._index!==b},this);b&&this.resortView()},_emptyViewIndex:-1,_appendReorderedChildren:function(a){this.$el.append(a)},_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 a,b=this._filteredSortedModels();c.each(b,function(b,c){a=this.getChildView(b),this.addChild(b,a,c)},this)},_filteredSortedModels:function(){var a,b=this.getViewComparator();return a=b?c.isString(b)||1===b.length?this.collection.sortBy(b,this):c.clone(this.collection.models).sort(c.bind(b,this)):this.collection.models,this.getOption("filter")&&(a=c.filter(a,function(a,b){return this._shouldAddChild(a,b)},this)),a},showEmptyView:function(){var a=this.getEmptyView();if(a&&!this._showingEmptyView){this.triggerMethod("before:render:empty"),this._showingEmptyView=!0;var c=new b.Model;this.addEmptyView(c,a),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(a,b){var d=this.getOption("emptyViewOptions")||this.getOption("childViewOptions");c.isFunction(d)&&(d=d.call(this,a,this._emptyViewIndex));var e=this.buildChildView(a,b,d);e._parent=this,this.proxyChildEvents(e),this._isShown&&f.triggerMethodOn(e,"before:show"),this.children.add(e),this.renderChildView(e,this._emptyViewIndex),this._isShown&&f.triggerMethodOn(e,"show")},getChildView:function(){var a=this.getOption("childView");if(!a)throw new f.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return a},addChild:function(a,b,c){var d=this.getOption("childViewOptions");d=f._getValue(d,this,[a,c]);var e=this.buildChildView(a,b,d);return this._updateIndices(e,!0,c),this._addChildView(e,c),e._parent=this,e},_updateIndices:function(a,b,c){this.getOption("sort")&&(b&&(a._index=c),this.children.each(function(c){c._index>=a._index&&(c._index+=b?1:-1)}))},_addChildView:function(a,b){this.proxyChildEvents(a),this.triggerMethod("before:add:child",a),this._isShown&&!this.isBuffering&&f.triggerMethodOn(a,"before:show"),this.children.add(a),this.renderChildView(a,b),this._isShown&&!this.isBuffering&&f.triggerMethodOn(a,"show"),this.triggerMethod("add:child",a)},renderChildView:function(a,b){return a.render(),this.attachHtml(this,a,b),a},buildChildView:function(a,b,d){var e=c.extend({model:a},d);return new b(e)},removeChildView:function(a){return a&&(this.triggerMethod("before:remove:child",a),a.destroy?a.destroy():a.remove&&a.remove(),delete a._parent,this.stopListening(a),this.children.remove(a),this.triggerMethod("remove:child",a),this._updateIndices(a,!1)),a},isEmpty:function(){return!this.collection||0===this.collection.length},checkEmpty:function(){this.isEmpty(this.collection)&&this.showEmptyView()},attachBuffer:function(a){a.$el.append(this._createBuffer(a))},_createBuffer:function(a){var b=document.createDocumentFragment();return c.each(a._bufferedChildren,function(a){b.appendChild(a.el)}),b},attachHtml:function(a,b,c){a.isBuffering?a._bufferedChildren.splice(c,0,b):a._insertBefore(b,c)||a._insertAfter(b)},_insertBefore:function(a,b){var c,d=this.getOption("sort")&&barguments.length;o&&(s=r,r=s[0]);var h,a="on"+r.replace(e,t),d=n[a];return i.isFunction(d)&&(h=d.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(t){var e=i.isFunction(t.triggerMethod)?t.triggerMethod:s.triggerMethod;return e.apply(t,i.rest(arguments))},s.MonitorDOMRefresh=function(t){function e(){t._isShown=!0,r()}function n(){t._isRendered=!0,r()}function r(){t._isShown&&t._isRendered&&s.isNodeAttached(t.el)&&i.isFunction(t.triggerMethod)&&t.triggerMethod("dom:refresh")}t.on({show:e,render:n})},function(t){function e(e,n,r,s){var o=s.split(/\s+/);i.each(o,function(i){var s=e[i];if(!s)throw new t.Error('Method "'+i+'" was configured as an event handler, but does not exist.');e.listenTo(n,r,s)})}function n(t,e,i,n){t.listenTo(e,i,n)}function r(t,e,n,r){var s=r.split(/\s+/);i.each(s,function(i){var r=t[i];t.stopListening(e,n,r)})}function s(t,e,i,n){t.stopListening(e,i,n)}function o(e,n,r,s,o){if(n&&r){if(!i.isObject(r))throw new t.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});r=t._getValue(r,e),i.each(r,function(t,r){i.isFunction(t)?s(e,n,r,t):o(e,n,r,t)})}}t.bindEntityEvents=function(t,i,r){o(t,i,r,n,e)},t.unbindEntityEvents=function(t,e,i){o(t,e,i,s,r)},t.proxyBindEntityEvents=function(e,i){return t.bindEntityEvents(this,e,i)},t.proxyUnbindEntityEvents=function(e,i){return t.unbindEntityEvents(this,e,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(t,e){i.isObject(t)?(e=t,t=e.message):e||(e={});var n=Error.call(this,t);i.extend(this,i.pick(n,h),i.pick(e,h)),this.captureStackTrace(),e.url&&(this.url=this.urlRoot+e.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(t,e){var n=i.result(this._deferred,"promise");this._callbacks.push({cb:t,ctx:e}),n.then(function(i){e&&(i.context=e),t.call(i.context,i.options)})},run:function(t,e){this._deferred.resolve({options:t,context:e})},reset:function(){var t=this._callbacks;this._deferred=s.Deferred(),this._callbacks=[],i.each(t,function(t){this.add(t.cb,t.ctx)},this)}}),s.Controller=function(t){this.options=t||{},i.isFunction(this.initialize)&&this.initialize(this.options)},s.Controller.extend=s.extend,i.extend(s.Controller.prototype,e.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(t){this.options=i.extend({},i.result(this,"options"),t),this.initialize.apply(this,arguments)},s.Object.extend=s.extend,i.extend(s.Object.prototype,e.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(t){if(this.options=t||{},this.el=this.getOption("el"),this.el=this.el instanceof e.$?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,t)},show:function(t,e){if(this._ensureElement()){this._ensureViewIsIntact(t);var n=e||{},r=t!==this.currentView,o=!!n.preventDestroy,h=!!n.forceShow,a=!!this.currentView,d=r&&!o,l=r||h;if(a&&this.triggerMethod("before:swapOut",this.currentView,this,e),this.currentView&&delete this.currentView._parent,d?this.empty():a&&l&&this.currentView.off("destroy",this.empty,this),l){t.once("destroy",this.empty,this),t.render(),t._parent=this,a&&this.triggerMethod("before:swap",t,this,e),this.triggerMethod("before:show",t,this,e),s.triggerMethodOn(t,"before:show",t,this,e),a&&this.triggerMethod("swapOut",this.currentView,this,e);var c=s.isNodeAttached(this.el),u=[],g=i.extend({triggerBeforeAttach:this.triggerBeforeAttach,triggerAttach:this.triggerAttach},n);return c&&g.triggerBeforeAttach&&(u=this._displayedViews(t),this._triggerAttach(u,"before:")),this.attachHtml(t),this.currentView=t,c&&g.triggerAttach&&(u=this._displayedViews(t),this._triggerAttach(u)),a&&this.triggerMethod("swap",t,this,e),this.triggerMethod("show",t,this,e),s.triggerMethodOn(t,"show",t,this,e),this}return this}},triggerBeforeAttach:!0,triggerAttach:!0,_triggerAttach:function(t,e){var n=(e||"")+"attach";i.each(t,function(t){s.triggerMethodOn(t,n,t,this)},this)},_displayedViews:function(t){return i.union([t],i.result(t,"_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(t){if(!t)throw new s.Error({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(t.isDestroyed)throw new s.Error({name:"ViewDestroyedError",message:'View (cid: "'+t.cid+'") has already been destroyed and cannot be used.'})},getEl:function(t){return e.$(t,s._getValue(this.options.parentEl,this))},attachHtml:function(t){this.$el.contents().detach(),this.el.appendChild(t.el)},empty:function(t){var e=this.currentView,i=s._getValue(t,"preventDestroy",this);return e?(e.off("destroy",this.empty,this),this.triggerMethod("before:empty",e),i||this._destroyView(),this.triggerMethod("empty",e),delete this.currentView,i&&this.$el.contents().detach(),this):void 0},_destroyView:function(){var t=this.currentView;t.destroy&&!t.isDestroyed?t.destroy():t.remove&&(t.remove(),t.isDestroyed=!0)},attachView:function(t){return this.currentView=t,this},hasView:function(){return!!this.currentView},reset:function(){return this.empty(),this.$el&&(this.el=this.$el.selector),delete this.$el,this}},{buildRegion:function(t,e){if(i.isString(t))return this._buildRegionFromSelector(t,e);if(t.selector||t.el||t.regionClass)return this._buildRegionFromObject(t,e);if(i.isFunction(t))return this._buildRegionFromRegionClass(t);throw new s.Error({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})},_buildRegionFromSelector:function(t,e){return new e({el:t})},_buildRegionFromObject:function(t,e){var n=t.regionClass||e,r=i.omit(t,"selector","regionClass");return t.selector&&!r.el&&(r.el=t.selector),new n(r)},_buildRegionFromRegionClass:function(t){return new t}}),s.RegionManager=s.Controller.extend({constructor:function(t){this._regions={},this.length=0,s.Controller.call(this,t),this.addRegions(this.getOption("regions"))},addRegions:function(t,e){return t=s._getValue(t,this,arguments),i.reduce(t,function(t,n,r){return i.isString(n)&&(n={selector:n}),n.selector&&(n=i.defaults({},n,e)),t[r]=this.addRegion(r,n),t},{},this)},addRegion:function(t,e){var i;return i=e instanceof s.Region?e:s.Region.buildRegion(e,s.Region),this.triggerMethod("before:add:region",t,i),i._parent=this,this._store(t,i),this.triggerMethod("add:region",t,i),i},get:function(t){return this._regions[t]},getRegions:function(){return i.clone(this._regions)},removeRegion:function(t){var e=this._regions[t];return this._remove(t,e),e},removeRegions:function(){var t=this.getRegions();return i.each(this._regions,function(t,e){this._remove(e,t)},this),t},emptyRegions:function(){var t=this.getRegions();return i.invoke(t,"empty"),t},destroy:function(){return this.removeRegions(),s.Controller.prototype.destroy.apply(this,arguments)},_store:function(t,e){this._regions[t]||this.length++,this._regions[t]=e},_remove:function(t,e){this.triggerMethod("before:remove:region",t,e),e.empty(),e.stopListening(),delete e._parent,delete this._regions[t],this.length--,this.triggerMethod("remove:region",t,e)}}),s.actAsCollection(s.RegionManager.prototype,"_regions"),s.TemplateCache=function(t){this.templateId=t},i.extend(s.TemplateCache,{templateCaches:{},get:function(t,e){var i=this.templateCaches[t];return i||(i=new s.TemplateCache(t),this.templateCaches[t]=i),i.load(e)},clear:function(){var t,e=i.toArray(arguments),n=e.length;if(n>0)for(t=0;n>t;t++)delete this.templateCaches[e[t]];else this.templateCaches={}}}),i.extend(s.TemplateCache.prototype,{load:function(t){if(this.compiledTemplate)return this.compiledTemplate;var e=this.loadTemplate(this.templateId,t);return this.compiledTemplate=this.compileTemplate(e,t),this.compiledTemplate},loadTemplate:function(t){var i=e.$(t).html();if(!i||0===i.length)throw new s.Error({name:"NoTemplateError",message:'Could not find template: "'+t+'"'});return i},compileTemplate:function(t,e){return i.template(t,e)}}),s.Renderer={render:function(t,e){if(!t)throw new s.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var n=i.isFunction(t)?t:s.TemplateCache.get(t);return n(e)}},s.View=e.View.extend({isDestroyed:!1,constructor:function(t){i.bindAll(this,"render"),t=s._getValue(t,this),this.options=i.extend({},i.result(this,"options"),t),this._behaviors=s.Behaviors(this),e.View.call(this,this.options),s.MonitorDOMRefresh(this)},getTemplate:function(){return this.getOption("template")},serializeModel:function(t){return t.toJSON.apply(t,i.rest(arguments))},mixinTemplateHelpers:function(t){t=t||{};var e=this.getOption("templateHelpers");return e=s._getValue(e,this),i.extend(t,e)},normalizeUIKeys:function(t){var e=i.result(this,"_uiBindings");return s.normalizeUIKeys(t,e||i.result(this,"ui"))},normalizeUIValues:function(t,e){var n=i.result(this,"ui"),r=i.result(this,"_uiBindings");return s.normalizeUIValues(t,r||n,e)},configureTriggers:function(){if(this.triggers){var t=this.normalizeUIKeys(i.result(this,"triggers"));return i.reduce(t,function(t,e,i){return t[i]=this._buildViewTrigger(e),t},{},this)}},delegateEvents:function(t){return this._delegateDOMEvents(t),this.bindEntityEvents(this.model,this.getOption("modelEvents")),this.bindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(t){t.bindEntityEvents(this.model,t.getOption("modelEvents")),t.bindEntityEvents(this.collection,t.getOption("collectionEvents"))},this),this},_delegateDOMEvents:function(t){var n=s._getValue(t||this.events,this);n=this.normalizeUIKeys(n),i.isUndefined(t)&&(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),e.View.prototype.delegateEvents.call(this,r)},undelegateEvents:function(){return e.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(t){t.unbindEntityEvents(this.model,t.getOption("modelEvents")),t.unbindEntityEvents(this.collection,t.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 t=i.toArray(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(t)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(t)),this.unbindUIElements(),this.isRendered=!1,this.remove(),i.invoke(this._behaviors,"destroy",t),this},bindUIElements:function(){this._bindUIElements(),i.invoke(this._behaviors,this._bindUIElements)},_bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var t=i.result(this,"_uiBindings");this.ui={},i.each(t,function(t,e){this.ui[e]=this.$(t)},this)}},unbindUIElements:function(){this._unbindUIElements(),i.invoke(this._behaviors,this._unbindUIElements)},_unbindUIElements:function(){this.ui&&this._uiBindings&&(i.each(this.ui,function(t,e){delete this.ui[e]},this),this.ui=this._uiBindings,delete this._uiBindings)},_buildViewTrigger:function(t){var e=i.isObject(t),n=i.defaults({},e?t:{},{preventDefault:!0,stopPropagation:!0}),r=e?n.event:t;return function(t){t&&(t.preventDefault&&n.preventDefault&&t.preventDefault(),t.stopPropagation&&n.stopPropagation&&t.stopPropagation());var e={view:this,model:this.model,collection:this.collection};this.triggerMethod(r,e)}},setElement:function(){var t=e.View.prototype.setElement.apply(this,arguments);return i.invoke(this._behaviors,"proxyViewProperties",this),t},triggerMethod:function(){var t=s._triggerMethod(this,arguments);return this._triggerEventOnBehaviors(arguments),this._triggerEventOnParentLayout(arguments[0],i.rest(arguments)),t},_triggerEventOnBehaviors:function(t){for(var e=s._triggerMethod,i=this._behaviors,n=0,r=i&&i.length;r>n;n++)e(i[n],t)},_triggerEventOnParentLayout:function(t,e){var n=this._parentLayoutView();if(n){var r=s.getOption(n,"childViewEventPrefix"),o=r+":"+t;s._triggerMethod(n,[o,this].concat(e));var h=s.getOption(n,"childEvents"),a=n.normalizeMethods(h);a&&i.isFunction(a[t])&&a[t].apply(n,[this].concat(e))}},_getImmediateChildren:function(){return[]},_getNestedViews:function(){var t=this._getImmediateChildren();return t.length?i.reduce(t,function(t,e){return e._getNestedViews?t.concat(e._getNestedViews()):t},t):t},_getAncestors:function(){for(var t=[],e=this._parent;e;)t.push(e),e=e._parent;return t},_parentLayoutView:function(){var t=this._getAncestors();return i.find(t,function(t){return t 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 t=[this.model||this.collection];return arguments.length&&t.push.apply(t,arguments),this.model?this.serializeModel.apply(this,t):{items:this.serializeCollection.apply(this,t)}},serializeCollection:function(t){return t.toJSON.apply(t,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 t=this.getTemplate();if(t!==!1){if(!t)throw new s.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var e=this.mixinTemplateHelpers(this.serializeData()),i=s.Renderer.render(t,e,this);return this.attachElContent(i),this}},attachElContent:function(t){return this.$el.html(t),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({"before:show":this._onBeforeShowCalled,show:this._onShowCalled,"before:attach":this._onBeforeAttachCalled,attach:this._onAttachCalled}),this.initRenderBuffer()},initRenderBuffer:function(){this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){var t,e=this._isShown&&s.isNodeAttached(this.el);this.isBuffering=!1,this._isShown&&this._triggerMethodMany(this._bufferedChildren,this,"before:show"),e&&this._triggerBeforeAttach&&(t=this._getNestedViews(),this._triggerMethodMany(t,this,"before:attach")),this.attachBuffer(this,this._createBuffer()),e&&this._triggerAttach&&(t=this._getNestedViews(),this._triggerMethodMany(t,this,"attach")),this._isShown&&this._triggerMethodMany(this._bufferedChildren,this,"show"),this.initRenderBuffer()},_triggerMethodMany:function(t,e,n){var r=i.drop(arguments,3);i.each(t,function(t){s.triggerMethodOn.apply(t,[t,n,t,e].concat(r))})},_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(t,e,n){var r;if(r=void 0!==n.at?n.at:i.indexOf(this._filteredSortedModels(),t),this._shouldAddChild(t,r)){this.destroyEmptyView();var s=this.getChildView(t);this.addChild(t,s,r)}},_onCollectionRemove:function(t){var e=this.children.findByModel(t);this.removeChildView(e),this.checkEmpty()},_onBeforeShowCalled:function(){this._triggerBeforeAttach=this._triggerAttach=!1,this.children.each(function(t){s.triggerMethodOn(t,"before:show",t)})},_onShowCalled:function(){this.children.each(function(t){s.triggerMethodOn(t,"show",t)})},_onBeforeAttachCalled:function(){this._triggerBeforeAttach=!0},_onAttachCalled:function(){this._triggerAttach=!0},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderChildren(),this.isRendered=!0,this.triggerMethod("render",this),this},reorder:function(){var t=this.children,e=this._filteredSortedModels(),n=i.find(e,function(e){return!t.findByModel(e)});if(n)this.render();else{var r=i.map(e,function(e,i){var n=t.findByModel(e);return n._index=i,n.el});this.triggerMethod("before:reorder"),this._appendReorderedChildren(r),this.triggerMethod("reorder")}},resortView:function(){s.getOption(this,"reorderOnSort")?this.reorder():this.render()},_sortViews:function(){var t=this._filteredSortedModels(),e=i.find(t,function(t,e){var i=this.children.findByModel(t);return!i||i._index!==e},this);e&&this.resortView()},_emptyViewIndex:-1,_appendReorderedChildren:function(t){this.$el.append(t)},_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren({checkEmpty:!1}),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 t,e=this._filteredSortedModels();i.each(e,function(e,i){t=this.getChildView(e),this.addChild(e,t,i)},this)},_filteredSortedModels:function(){var t,e=this.getViewComparator();return t=e?i.isString(e)||1===e.length?this.collection.sortBy(e,this):i.clone(this.collection.models).sort(i.bind(e,this)):this.collection.models,this.getOption("filter")&&(t=i.filter(t,function(t,e){return this._shouldAddChild(t,e)},this)),t},showEmptyView:function(){var t=this.getEmptyView();if(t&&!this._showingEmptyView){this.triggerMethod("before:render:empty"),this._showingEmptyView=!0;var i=new e.Model;this.addEmptyView(i,t),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(t,e){var n,r=this._isShown&&!this.isBuffering&&s.isNodeAttached(this.el),o=this.getOption("emptyViewOptions")||this.getOption("childViewOptions");i.isFunction(o)&&(o=o.call(this,t,this._emptyViewIndex));var h=this.buildChildView(t,e,o);h._parent=this,this.proxyChildEvents(h),this._isShown&&s.triggerMethodOn(h,"before:show",h),this.children.add(h),r&&this._triggerBeforeAttach&&(n=[h].concat(h._getNestedViews()),h.once("render",function(){this._triggerMethodMany(n,this,"before:attach")},this)),this.renderChildView(h,this._emptyViewIndex),r&&this._triggerAttach&&(n=[h].concat(h._getNestedViews()),this._triggerMethodMany(n,this,"attach")),this._isShown&&s.triggerMethodOn(h,"show",h)},getChildView:function(){var t=this.getOption("childView");if(!t)throw new s.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return t},addChild:function(t,e,i){var n=this.getOption("childViewOptions");n=s._getValue(n,this,[t,i]);var r=this.buildChildView(t,e,n);return this._updateIndices(r,!0,i),this.triggerMethod("before:add:child",r),this._addChildView(r,i),this.triggerMethod("add:child",r),r._parent=this,r},_updateIndices:function(t,e,i){this.getOption("sort")&&(e&&(t._index=i),this.children.each(function(i){i._index>=t._index&&(i._index+=e?1:-1)}))},_addChildView:function(t,e){var i,n=this._isShown&&!this.isBuffering&&s.isNodeAttached(this.el);this.proxyChildEvents(t),this._isShown&&!this.isBuffering&&s.triggerMethodOn(t,"before:show",t),this.children.add(t),n&&this._triggerBeforeAttach&&(i=[t].concat(t._getNestedViews()),t.once("render",function(){this._triggerMethodMany(i,this,"before:attach")},this)),this.renderChildView(t,e),n&&this._triggerAttach&&(i=[t].concat(t._getNestedViews()),this._triggerMethodMany(i,this,"attach")),this._isShown&&!this.isBuffering&&s.triggerMethodOn(t,"show",t)},renderChildView:function(t,e){return t.render(),this.attachHtml(this,t,e),t},buildChildView:function(t,e,n){var r=i.extend({model:t},n);return new e(r)},removeChildView:function(t){return t&&(this.triggerMethod("before:remove:child",t),t.destroy?t.destroy():t.remove&&t.remove(),delete t._parent,this.stopListening(t),this.children.remove(t),this.triggerMethod("remove:child",t),this._updateIndices(t,!1)),t},isEmpty:function(){return!this.collection||0===this.collection.length},checkEmpty:function(){this.isEmpty(this.collection)&&this.showEmptyView()},attachBuffer:function(t,e){t.$el.append(e)},_createBuffer:function(){var t=document.createDocumentFragment();return i.each(this._bufferedChildren,function(e){t.appendChild(e.el)}),t},attachHtml:function(t,e,i){t.isBuffering?t._bufferedChildren.splice(i,0,e):t._insertBefore(e,i)||t._insertAfter(e)},_insertBefore:function(t,e){var i,n=this.getOption("sort")&&this.children.length-1>e;return n&&(i=this.children.find(function(t){return t._index===e+1})),i?(i.$el.before(t.el),!0):!1},_insertAfter:function(t){this.$el.append(t.el)},_initChildViewStorage:function(){this.children=new e.ChildViewContainer},destroy:function(){return this.isDestroyed?this:(this.triggerMethod("before:destroy:collection"),this.destroyChildren({checkEmpty:!1}),this.triggerMethod("destroy:collection"),s.View.prototype.destroy.apply(this,arguments))},destroyChildren:function(t){var e=t||{},n=!0,r=this.children.map(i.identity);return i.isUndefined(e.checkEmpty)||(n=e.checkEmpty),this.children.each(this.removeChildView,this),n&&this.checkEmpty(),r},_shouldAddChild:function(t,e){var n=this.getOption("filter");return!i.isFunction(n)||n.call(this,t,e,this.collection)},proxyChildEvents:function(t){var e=this.getOption("childViewEventPrefix");this.listenTo(t,"all",function(){var n=i.toArray(arguments),r=n[0],s=this.normalizeMethods(i.result(this,"childEvents"));n[0]=e+":"+r,n.splice(1,0,t),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 t=this.getOption("childView")||this.constructor;return t},serializeData:function(){var t={};return this.model&&(t=i.partial(this.serializeModel,this.model).apply(this,arguments)),t},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 t={};t=this.serializeData(),t=this.mixinTemplateHelpers(t),this.triggerMethod("before:render:template");var e=this.getTemplate(),i=s.Renderer.render(e,t,this);this.attachElContent(i),this.bindUIElements(),this.triggerMethod("render:template")},attachElContent:function(t){return this.$el.html(t),this},attachBuffer:function(t,e){var i=this.getChildViewContainer(t);i.append(e)},_insertAfter:function(t){var e=this.getChildViewContainer(this,t);e.append(t.el)},_appendReorderedChildren:function(t){var e=this.getChildViewContainer(this);e.append(t)},getChildViewContainer:function(t){if(t.$childViewContainer)return t.$childViewContainer;var e,i=s.getOption(t,"childViewContainer");if(i){var n=s._getValue(i,t);if(e="@"===n.charAt(0)&&t.ui?t.ui[n.substr(4)]:t.$(n),0>=e.length)throw new s.Error({name:"ChildViewContainerMissingError",message:'The specified "childViewContainer" was not found: '+t.childViewContainer})}else e=t.$el;return t.$childViewContainer=e,e},resetChildViewContainer:function(){this.$childViewContainer&&(this.$childViewContainer=void 0)}}),s.LayoutView=s.ItemView.extend({regionClass:s.Region,options:{destroyImmediate:!1},childViewEventPrefix:"childview",constructor:function(t){t=t||{},this._firstRender=!0,this._initializeRegions(t),s.ItemView.call(this,t)},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(t,e){return this.getRegion(t).show(e)},getChildView:function(t){return this.getRegion(t).currentView},addRegion:function(t,e){var i={};return i[t]=e,this._buildRegions(i)[t]},addRegions:function(t){return this.regions=i.extend({},this.regions,t),this._buildRegions(t)},removeRegion:function(t){return delete this.regions[t],this.regionManager.removeRegion(t)},getRegion:function(t){return this.regionManager.get(t)},getRegions:function(){return this.regionManager.getRegions()},_buildRegions:function(t){var e={regionClass:this.getOption("regionClass"),parentEl:i.partial(i.result,this,"el")};return this.regionManager.addRegions(t,e)},_initializeRegions:function(t){var e;this._initRegionManager(),e=s._getValue(this.regions,this,[t])||{};var n=this.getOption.call(t,"regions");n=s._getValue(n,this,[t]),i.extend(e,n),e=this.normalizeUIValues(e,["selector","el"]),this.addRegions(e)},_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(t){this.triggerMethod("before:add:region",t)}),this.listenTo(this.regionManager,"add:region",function(t,e){this[t]=e,this.triggerMethod("add:region",t,e)}),this.listenTo(this.regionManager,"before:remove:region",function(t){this.triggerMethod("before:remove:region",t)}),this.listenTo(this.regionManager,"remove:region",function(t,e){delete this[t],this.triggerMethod("remove:region",t,e)})},_getImmediateChildren:function(){return i.chain(this.regionManager.getRegions()).pluck("currentView").compact().value()}}),s.Behavior=s.Object.extend({constructor:function(t,e){this.view=e,this.defaults=i.result(this,"defaults")||{},this.options=i.extend({},this.defaults,t),this.ui=i.extend({},i.result(e,"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(t){this.$el=t.$el,this.el=t.el}}),s.Behaviors=function(t,e){function i(t,n){return e.isObject(t.behaviors)?(n=i.parseBehaviors(t,n||e.result(t,"behaviors")),i.wrap(t,n,e.keys(o)),n):{}}function n(t,e){this._view=t,this._behaviors=e,this._triggers={}}function r(t){return t._uiBindings||t.ui}var s=/^(\S+)\s*(.*)$/,o={behaviorTriggers:function(t,e){var i=new n(this,e);return i.buildBehaviorTriggers()},behaviorEvents:function(i,n){var o={};return e.each(n,function(i,n){var h={},a=e.clone(e.result(i,"events"))||{};a=t.normalizeUIKeys(a,r(i));var d=0;e.each(a,function(t,r){var o=r.match(s),a=o[1]+"."+[this.cid,n,d++," "].join(""),l=o[2],c=a+l,u=e.isFunction(t)?t:i[t];h[c]=e.bind(u,i)},this),o=e.extend(o,h)},this),o}};return e.extend(i,{behaviorsLookup:function(){throw new t.Error({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.html#behaviorslookup"})},getBehaviorClass:function(e,n){return e.behaviorClass?e.behaviorClass:t._getValue(i.behaviorsLookup,this,[e,n])[n]},parseBehaviors:function(t,n){return e.chain(n).map(function(n,r){var s=i.getBehaviorClass(n,r),o=new s(n,t),h=i.parseBehaviors(t,e.result(o,"behaviors"));return[o].concat(h)}).flatten().value()},wrap:function(t,i,n){e.each(n,function(n){t[n]=e.partial(o[n],t[n],i)})}}),e.extend(n.prototype,{buildBehaviorTriggers:function(){return e.each(this._behaviors,this._buildTriggerHandlersForBehavior,this),this._triggers},_buildTriggerHandlersForBehavior:function(i,n){var s=e.clone(e.result(i,"triggers"))||{};s=t.normalizeUIKeys(s,r(i)),e.each(s,e.bind(this._setHandlerForBehavior,this,i,n))},_setHandlerForBehavior:function(t,e,i,n){var r=n.replace(/^\S+/,function(t){return t+"."+"behaviortriggers"+e});this._triggers[r]=this._view._buildViewTrigger(i)}}),i}(s,i),s.AppRouter=e.Router.extend({constructor:function(t){this.options=t||{},e.Router.apply(this,arguments);var i=this.getOption("appRoutes"),n=this._getController();this.processAppRoutes(n,i),this.on("route",this._processOnRoute,this)},appRoute:function(t,e){var i=this._getController();this._addAppRoute(i,t,e)},_processOnRoute:function(t,e){if(i.isFunction(this.onRoute)){var n=i.invert(this.getOption("appRoutes"))[t];this.onRoute(t,n,e)}},processAppRoutes:function(t,e){if(e){var n=i.keys(e).reverse();i.each(n,function(i){this._addAppRoute(t,i,e[i])},this)}},_getController:function(){return this.getOption("controller")},_addAppRoute:function(t,e,n){var r=t[n];if(!r)throw new s.Error('Method "'+n+'" was not found on the controller');this.route(e,n,i.bind(r,t))},mergeOptions:s.mergeOptions,getOption:s.proxyGetOption,triggerMethod:s.triggerMethod,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.Application=s.Object.extend({constructor:function(t){this._initializeRegions(t),this._initCallbacks=new s.Callbacks,this.submodules={},i.extend(this,t),this._initChannel(),s.Object.call(this,t)},execute:function(){this.commands.execute.apply(this.commands,arguments)},request:function(){return this.reqres.request.apply(this.reqres,arguments)},addInitializer:function(t){this._initCallbacks.add(t)},start:function(t){this.triggerMethod("before:start",t),this._initCallbacks.run(t,this),this.triggerMethod("start",t)},addRegions:function(t){return this._regionManager.addRegions(t)},emptyRegions:function(){return this._regionManager.emptyRegions()},removeRegion:function(t){return this._regionManager.removeRegion(t)},getRegion:function(t){return this._regionManager.get(t)},getRegions:function(){return this._regionManager.getRegions()},module:function(t,e){var n=s.Module.getClass(e),r=i.toArray(arguments);return r.unshift(this),n.create.apply(n,r)},getRegionManager:function(){return new s.RegionManager},_initializeRegions:function(t){var e=i.isFunction(this.regions)?this.regions(t):this.regions||{};this._initRegionManager();var n=s.getOption(t,"regions");return i.isFunction(n)&&(n=n.call(this,t)),i.extend(e,n),this.addRegions(e),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(t,e){this[t]=e,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(t){delete this[t],s._triggerMethod(this,"remove:region",arguments)})},_initChannel:function(){this.channelName=i.result(this,"channelName")||"global",this.channel=i.result(this,"channel")||e.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(t,e,n){this.moduleName=t,this.options=i.extend({},this.options,n),this.initialize=n.initialize||this.initialize,this.submodules={},this._setupInitializersAndFinalizers(),this.app=e,i.isFunction(this.initialize)&&this.initialize(t,e,this.options)},s.Module.extend=s.extend,i.extend(s.Module.prototype,e.Events,{startWithParent:!0,initialize:function(){},addInitializer:function(t){this._initializerCallbacks.add(t)},addFinalizer:function(t){this._finalizerCallbacks.add(t)},start:function(t){this._isInitialized||(i.each(this.submodules,function(e){e.startWithParent&&e.start(t)}),this.triggerMethod("before:start",t),this._initializerCallbacks.run(t,this),this._isInitialized=!0,this.triggerMethod("start",t))},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(t,e){this._runModuleDefinition(t,e)},_runModuleDefinition:function(t,n){if(t){var r=i.flatten([this,this.app,e,s,e.$,i,n]);t.apply(this,r)}},_setupInitializersAndFinalizers:function(){this._initializerCallbacks=new s.Callbacks,this._finalizerCallbacks=new s.Callbacks},triggerMethod:s.triggerMethod}),i.extend(s.Module,{create:function(t,e,n){var r=t,s=i.drop(arguments,3);e=e.split(".");var o=e.length,h=[];return h[o-1]=n,i.each(e,function(e,i){var o=r;r=this._getModule(o,e,t,n),this._addModuleDefinition(o,r,h[i],s)},this),r},_getModule:function(t,e,n,r){var s=i.extend({},r),o=this.getClass(r),h=t[e];return h||(h=new o(e,n,s),t[e]=h,t.submodules[e]=h),h},getClass:function(t){var e=s.Module;return t?t.prototype instanceof e?t:t.moduleClass||e:e},_addModuleDefinition:function(t,e,i,n){var r=this._getDefine(i),s=this._getStartWithParent(i,e);r&&e.addDefinition(r,n),this._addStartWithParent(t,e,s)},_getStartWithParent:function(t,e){var n;return i.isFunction(t)&&t.prototype instanceof s.Module?(n=e.constructor.prototype.startWithParent,i.isUndefined(n)?!0:n):i.isObject(t)?(n=t.startWithParent,i.isUndefined(n)?!0:n):!0},_getDefine:function(t){return!i.isFunction(t)||t.prototype instanceof s.Module?i.isObject(t)?t.define:null:t},_addStartWithParent:function(t,e,i){e.startWithParent=e.startWithParent&&i,e.startWithParent&&!e.startWithParentIsConfigured&&(e.startWithParentIsConfigured=!0,t.addInitializer(function(t){e.startWithParent&&e.start(t)}))}}),s}); +//@ sourceMappingURL=backbone.marionette.map \ No newline at end of file diff --git a/lib/backbone.marionette.min.js.map b/lib/backbone.marionette.min.js.map deleted file mode 100644 index d1fbecbd84..0000000000 --- a/lib/backbone.marionette.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"backbone.marionette.min.js","sources":["backbone.marionette.js"],"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","_appendReorderedChildren","resortView","orderChanged","item","_index","_emptyViewIndex","append","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,IAGhEM,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,IAAK,SAASG,EAAMC,GAClB,GAAIC,GAAUF,EAAKG,GAYnB,OAVAhB,MAAKK,OAAOU,GAAWF,EAEnBA,EAAKI,QACPjB,KAAKM,cAAcO,EAAKI,MAAMD,KAAOD,GAGnCD,IACFd,KAAKO,eAAeO,GAAeC,GAErCf,KAAKQ,gBACER,MAITkB,YAAa,SAASD,GACpB,MAAOjB,MAAKmB,eAAeF,EAAMD,MAKnCG,eAAgB,SAASC,GACvB,GAAIL,GAAUf,KAAKM,cAAcc,EACjC,OAAOpB,MAAKqB,UAAUN,IAGxBO,aAAc,SAASC,GACrB,GAAIR,GAAUf,KAAKO,eAAegB,EAClC,OAAOvB,MAAKqB,UAAUN,IAIxBS,YAAa,SAASD,GACpB,MAAO7B,GAAE+B,O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,GAAI4iB,EAEJ,OAAIjjB,GAAEyC,WAAWmgB,IAASA,EAAI1hB,oBAAqBjB,GAAWqhB,QAC5D2B,EAAM5iB,EAAOgF,YAAYnE,UAAU4gB,gBAC5B9hB,EAAE0U,YAAYuO,IAAO,EAAOA,GAGjCjjB,EAAE8D,SAAS8e,IACbK,EAAML,EAAId,gBACH9hB,EAAE0U,YAAYuO,IAAO,EAAOA,IAG9B,GAGTH,WAAY,SAASF,GACnB,OAAI5iB,EAAEyC,WAAWmgB,IAAUA,EAAI1hB,oBAAqBjB,GAAWqhB,OAI3DthB,EAAE8D,SAAS8e,GACNA,EAAI/iB,OAGN,KAPE+iB,GAUXI,oBAAqB,SAASP,EAAcpiB,EAAQyhB,GAClDzhB,EAAOyhB,gBAAkBzhB,EAAOyhB,iBAAmBA,EAE9CzhB,EAAOyhB,kBAAqBzhB,EAAO6iB,8BAIxC7iB,EAAO6iB,6BAA8B,EAErCT,EAAa1B,eAAe,SAAS3d,GAC/B/C,EAAOyhB,iBACTzhB,EAAO4gB,MAAM7d,SAOdnD"} \ No newline at end of file diff --git a/lib/core/backbone.marionette.js b/lib/core/backbone.marionette.js index adc980fdc2..ed7e1f3718 100644 --- a/lib/core/backbone.marionette.js +++ b/lib/core/backbone.marionette.js @@ -1,6 +1,6 @@ // MarionetteJS (Backbone.Marionette) // ---------------------------------- -// v2.4.1 +// v2.4.2 // // Copyright (c)2015 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license @@ -31,7 +31,7 @@ var Marionette = Backbone.Marionette = {}; - Marionette.VERSION = '2.4.1'; + Marionette.VERSION = '2.4.2'; Marionette.noConflict = function() { root.Marionette = previousMarionette; @@ -703,10 +703,12 @@ // as it's a potentially-slow method var displayedViews = []; - var triggerBeforeAttach = showOptions.triggerBeforeAttach || this.triggerBeforeAttach; - var triggerAttach = showOptions.triggerAttach || this.triggerAttach; + var attachOptions = _.extend({ + triggerBeforeAttach: this.triggerBeforeAttach, + triggerAttach: this.triggerAttach + }, showOptions); - if (attachedRegion && triggerBeforeAttach) { + if (attachedRegion && attachOptions.triggerBeforeAttach) { displayedViews = this._displayedViews(view); this._triggerAttach(displayedViews, 'before:'); } @@ -714,7 +716,7 @@ this.attachHtml(view); this.currentView = view; - if (attachedRegion && triggerAttach) { + if (attachedRegion && attachOptions.triggerAttach) { displayedViews = this._displayedViews(view); this._triggerAttach(displayedViews); } @@ -1659,7 +1661,7 @@ } }); - /* jshint maxstatements: 14 */ + /* jshint maxstatements: 20, maxcomplexity: 7 */ // Collection View // --------------- @@ -1683,14 +1685,17 @@ // option to pass `{comparator: compFunction()}` to allow the `CollectionView` // to use a custom sort order for the collection. constructor: function(options) { - this.once('render', this._initialEvents); this._initChildViewStorage(); Marionette.View.apply(this, arguments); - this.on('show', this._onShowCalled); - + this.on({ + 'before:show': this._onBeforeShowCalled, + 'show': this._onShowCalled, + 'before:attach': this._onBeforeAttachCalled, + 'attach': this._onAttachCalled + }); this.initRenderBuffer(); }, @@ -1707,33 +1712,38 @@ }, endBuffering: function() { - this.isBuffering = false; - this._triggerBeforeShowBufferedChildren(); - - this.attachBuffer(this); + // Only trigger attach if already shown and attached, otherwise Region#show() handles this. + var canTriggerAttach = this._isShown && Marionette.isNodeAttached(this.el); + var nestedViews; - this._triggerShowBufferedChildren(); - this.initRenderBuffer(); - }, + this.isBuffering = false; - _triggerBeforeShowBufferedChildren: function() { if (this._isShown) { - _.each(this._bufferedChildren, _.partial(this._triggerMethodOnChild, 'before:show')); + this._triggerMethodMany(this._bufferedChildren, this, 'before:show'); + } + if (canTriggerAttach && this._triggerBeforeAttach) { + nestedViews = this._getNestedViews(); + this._triggerMethodMany(nestedViews, this, 'before:attach'); } - }, - _triggerShowBufferedChildren: function() { - if (this._isShown) { - _.each(this._bufferedChildren, _.partial(this._triggerMethodOnChild, 'show')); + this.attachBuffer(this, this._createBuffer()); - this._bufferedChildren = []; + if (canTriggerAttach && this._triggerAttach) { + nestedViews = this._getNestedViews(); + this._triggerMethodMany(nestedViews, this, 'attach'); } + if (this._isShown) { + this._triggerMethodMany(this._bufferedChildren, this, 'show'); + } + this.initRenderBuffer(); }, - // Internal method for _.each loops to call `Marionette.triggerMethodOn` on - // a child view - _triggerMethodOnChild: function(event, childView) { - Marionette.triggerMethodOn(childView, event); + _triggerMethodMany: function(targets, source, eventName) { + var args = _.drop(arguments, 3); + + _.each(targets, function(target) { + Marionette.triggerMethodOn.apply(target, [target, eventName, target, source].concat(args)); + }); }, // Configured the initial events that the collection view @@ -1773,8 +1783,29 @@ this.checkEmpty(); }, + _onBeforeShowCalled: function() { + // Reset attach event flags at the top of the Region#show() event lifecycle; if the Region's + // show() options permit onBeforeAttach/onAttach events, these flags will be set true again. + this._triggerBeforeAttach = this._triggerAttach = false; + this.children.each(function(childView) { + Marionette.triggerMethodOn(childView, 'before:show', childView); + }); + }, + _onShowCalled: function() { - this.children.each(_.partial(this._triggerMethodOnChild, 'show')); + this.children.each(function(childView) { + Marionette.triggerMethodOn(childView, 'show', childView); + }); + }, + + // If during Region#show() onBeforeAttach was fired, continue firing it for child views + _onBeforeAttachCalled: function() { + this._triggerBeforeAttach = true; + }, + + // If during Region#show() onAttach was fired, continue firing it for child views + _onAttachCalled: function() { + this._triggerAttach = true; }, // Render children views. Override this method to @@ -1807,8 +1838,10 @@ 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; + var els = _.map(models, function(model, index) { + var view = children.findByModel(model); + view._index = index; + return view.el; }); // since append moves elements that are already in the DOM, @@ -1861,7 +1894,7 @@ // process _renderChildren: function() { this.destroyEmptyView(); - this.destroyChildren(); + this.destroyChildren({checkEmpty: false}); if (this.isEmpty(this.collection)) { this.showEmptyView(); @@ -1955,6 +1988,10 @@ // but "add:child" events are not fired, and the event from // emptyView are not forwarded addEmptyView: function(child, EmptyView) { + // Only trigger attach if already shown, attached, and not buffering, otherwise endBuffer() or + // Region#show() handles this. + var canTriggerAttach = this._isShown && !this.isBuffering && Marionette.isNodeAttached(this.el); + var nestedViews; // get the emptyViewOptions, falling back to childViewOptions var emptyViewOptions = this.getOption('emptyViewOptions') || @@ -1972,23 +2009,35 @@ // Proxy emptyView events this.proxyChildEvents(view); - // trigger the 'before:show' event on `view` if the collection view - // has already been shown + // trigger the 'before:show' event on `view` if the collection view has already been shown if (this._isShown) { - Marionette.triggerMethodOn(view, 'before:show'); + Marionette.triggerMethodOn(view, 'before:show', view); } // Store the `emptyView` like a `childView` so we can properly // remove and/or close it later this.children.add(view); + // Trigger `before:attach` following `render` to avoid adding logic and event triggers + // to public method `renderChildView()`. + if (canTriggerAttach && this._triggerBeforeAttach) { + nestedViews = [view].concat(view._getNestedViews()); + view.once('render', function() { + this._triggerMethodMany(nestedViews, this, 'before:attach'); + }, this); + } + // Render it and show it this.renderChildView(view, this._emptyViewIndex); - // call the 'show' method if the collection view - // has already been shown + // Trigger `attach` + if (canTriggerAttach && this._triggerAttach) { + nestedViews = [view].concat(view._getNestedViews()); + this._triggerMethodMany(nestedViews, this, 'attach'); + } + // call the 'show' method if the collection view has already been shown if (this._isShown) { - Marionette.triggerMethodOn(view, 'show'); + Marionette.triggerMethodOn(view, 'show', view); } }, @@ -2024,7 +2073,9 @@ // increment indices of views after this one this._updateIndices(view, true, index); + this.triggerMethod('before:add:child', view); this._addChildView(view, index); + this.triggerMethod('add:child', view); view._parent = this; @@ -2054,27 +2105,42 @@ // Internal Method. Add the view to children and render it at // the given index. _addChildView: function(view, index) { + // Only trigger attach if already shown, attached, and not buffering, otherwise endBuffer() or + // Region#show() handles this. + var canTriggerAttach = this._isShown && !this.isBuffering && Marionette.isNodeAttached(this.el); + var nestedViews; + // set up the child view event forwarding this.proxyChildEvents(view); - this.triggerMethod('before:add:child', view); - - // trigger the 'before:show' event on `view` if the collection view - // has already been shown + // 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'); + Marionette.triggerMethodOn(view, 'before:show', view); } - // Store the child view itself so we can properly - // remove and/or destroy it later + // Store the child view itself so we can properly remove and/or destroy it later this.children.add(view); + + // Trigger `before:attach` following `render` to avoid adding logic and event triggers + // to public method `renderChildView()`. + if (canTriggerAttach && this._triggerBeforeAttach) { + nestedViews = [view].concat(view._getNestedViews()); + view.once('render', function() { + this._triggerMethodMany(nestedViews, this, 'before:attach'); + }, this); + } + this.renderChildView(view, index); + // Trigger `attach` + if (canTriggerAttach && this._triggerAttach) { + nestedViews = [view].concat(view._getNestedViews()); + this._triggerMethodMany(nestedViews, this, 'attach'); + } + // Trigger `show` if (this._isShown && !this.isBuffering) { - Marionette.triggerMethodOn(view, 'show'); + Marionette.triggerMethodOn(view, 'show', view); } - - this.triggerMethod('add:child', view); }, // render the child view @@ -2131,14 +2197,14 @@ }, // You might need to override this if you've overridden attachHtml - attachBuffer: function(collectionView) { - collectionView.$el.append(this._createBuffer(collectionView)); + attachBuffer: function(collectionView, buffer) { + collectionView.$el.append(buffer); }, // Create a fragment buffer from the currently buffered children - _createBuffer: function(collectionView) { + _createBuffer: function() { var elBuffer = document.createDocumentFragment(); - _.each(collectionView._bufferedChildren, function(b) { + _.each(this._bufferedChildren, function(b) { elBuffer.appendChild(b.el); }); return elBuffer; @@ -2199,7 +2265,7 @@ if (this.isDestroyed) { return this; } this.triggerMethod('before:destroy:collection'); - this.destroyChildren(); + this.destroyChildren({checkEmpty: false}); this.triggerMethod('destroy:collection'); return Marionette.View.prototype.destroy.apply(this, arguments); @@ -2207,10 +2273,20 @@ // Destroy the child views that this collection view // is holding on to, if any - destroyChildren: function() { + destroyChildren: function(options) { + var destroyOptions = options || {}; + var shouldCheckEmpty = true; var childViews = this.children.map(_.identity); + + if (!_.isUndefined(destroyOptions.checkEmpty)) { + shouldCheckEmpty = destroyOptions.checkEmpty; + } + this.children.each(this.removeChildView, this); - this.checkEmpty(); + + if (shouldCheckEmpty) { + this.checkEmpty(); + } return childViews; }, @@ -2382,9 +2458,9 @@ }, // You might need to override this if you've overridden attachHtml - attachBuffer: function(compositeView) { + attachBuffer: function(compositeView, buffer) { var $container = this.getChildViewContainer(compositeView); - $container.append(this._createBuffer(compositeView)); + $container.append(buffer); }, // Internal method. Append a view to the end of the $el. @@ -2406,7 +2482,7 @@ // Internal method to ensure an `$childViewContainer` exists, for the // `attachHtml` method to use. getChildViewContainer: function(containerView, childView) { - if ('$childViewContainer' in containerView) { + if (!!containerView.$childViewContainer) { return containerView.$childViewContainer; } @@ -2440,7 +2516,7 @@ // Internal method to reset the `$childViewContainer` on render resetChildViewContainer: function() { if (this.$childViewContainer) { - delete this.$childViewContainer; + this.$childViewContainer = undefined; } } }); diff --git a/lib/core/backbone.marionette.map b/lib/core/backbone.marionette.map new file mode 100644 index 0000000000..5d0eec5af2 --- /dev/null +++ b/lib/core/backbone.marionette.map @@ -0,0 +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","$","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","attachOptions","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","before:show","_onBeforeShowCalled","_onShowCalled","before:attach","_onBeforeAttachCalled","attach","_onAttachCalled","initRenderBuffer","_bufferedChildren","startBuffering","isBuffering","endBuffering","nestedViews","canTriggerAttach","_triggerMethodMany","_triggerBeforeAttach","attachBuffer","_createBuffer","targets","source","_onCollectionAdd","_onCollectionRemove","_sortViews","child","opts","index","at","indexOf","_filteredSortedModels","_shouldAddChild","destroyEmptyView","ChildView","getChildView","addChild","findByModel","removeChildView","checkEmpty","childView","_renderChildren","reorder","models","modelsChanged","els","map","_index","_appendReorderedChildren","resortView","orderChanged","item","_emptyViewIndex","append","destroyChildren","isEmpty","showEmptyView","showCollection","viewComparator","getViewComparator","sortBy","bind","filter","EmptyView","getEmptyView","_showingEmptyView","addEmptyView","emptyViewOptions","buildChildView","proxyChildEvents","renderChildView","childViewOptions","_updateIndices","_addChildView","increment","laterView","ChildViewClass","collectionView","buffer","elBuffer","createDocumentFragment","b","splice","_insertBefore","_insertAfter","findPosition","before","ChildViewContainer","destroyOptions","shouldCheckEmpty","childViews","identity","rootEvent","_views","CompositeView","partial","_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,mBAAZG,SAAyB,CACzC,GAAIJ,GAAWK,QAAQ,YACnBJ,EAAII,QAAQ,aACJA,SAAQ,kBACHA,QAAQ,uBACzBC,OAAOF,QAAUP,EAAQD,EAAMI,EAAUC,OAEzCL,GAAKM,WAAaN,EAAKO,GAAKN,EAAQD,EAAMA,EAAKI,SAAUJ,EAAKK,KAGhEM,KAAM,SAASX,EAAMI,EAAUC,GAC/B,YAEA,IAAIO,GAAqBZ,EAAKM,WAC1BO,EAAab,EAAKO,GAElBD,EAAaF,EAASE,aAE1BA,GAAWQ,QAAU,QAErBR,EAAWS,WAAa,WAGtB,MAFAf,GAAKM,WAAaM,EAClBZ,EAAKO,GAAKM,EACHF,MAITL,EAAWU,SAAWZ,EAASa,EAAED,SAEjCV,EAAWY,YAGXZ,EAAWa,UAAY,SAASC,GAC9B,QAASd,EAAWY,SAASE,IAY/Bd,EAAWe,OAASjB,EAASkB,MAAMD,OAMnCf,EAAWiB,eAAiB,SAASC,GACnC,MAAOpB,GAASa,EAAEQ,SAASC,SAASC,gBAAiBH,IAIvDlB,EAAWsB,aAAe,SAASC,EAASC,GACrCD,GACLxB,EAAEgB,OAAOV,KAAMN,EAAE0B,KAAKF,EAASC,KAQjCxB,EAAW0B,UAAY,SAASC,EAAQC,GACt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E2D,SAASqc,GACNA,EAAIngB,OAGN,KAPEmgB,GAUXK,oBAAqB,SAASR,EAAcxf,EAAQ6e,GAClD7e,EAAO6e,gBAAkB7e,EAAO6e,iBAAmBA,EAE9C7e,EAAO6e,kBAAqB7e,EAAOkgB,8BAIxClgB,EAAOkgB,6BAA8B,EAErCV,EAAa/B,eAAe,SAAStc,GAC/BnB,EAAO6e,iBACT7e,EAAO2d,MAAMxc,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 e51ca5fbea..cbc5ae73b4 100644 --- a/lib/core/backbone.marionette.min.js +++ b/lib/core/backbone.marionette.min.js @@ -1,3 +1,3 @@ -!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore","backbone.wreqr","backbone.babysitter"],function(c,d){return a.Marionette=a.Mn=b(a,c,d)});else if("undefined"!=typeof exports){{var c=require("backbone"),d=require("underscore");require("backbone.wreqr"),require("backbone.babysitter")}module.exports=b(a,c,d)}else a.Marionette=a.Mn=b(a,a.Backbone,a._)}(this,function(a,b,c){"use strict";var d=a.Marionette,e=a.Mn,f=b.Marionette={};f.VERSION="2.4.1",f.noConflict=function(){return a.Marionette=d,a.Mn=e,this},f.Deferred=b.$.Deferred,f.FEATURES={},f.isEnabled=function(a){return!!f.FEATURES[a]},f.extend=b.Model.extend,f.isNodeAttached=function(a){return b.$.contains(document.documentElement,a)},f.mergeOptions=function(a,b){a&&c.extend(this,c.pick(a,b))},f.getOption=function(a,b){return a&&b?a.options&&void 0!==a.options[b]?a.options[b]:a[b]:void 0},f.proxyGetOption=function(a){return f.getOption(this,a)},f._getValue=function(a,b,d){return c.isFunction(a)&&(a=d?a.apply(b,d):a.call(b)),a},f.normalizeMethods=function(a){return c.reduce(a,function(a,b,d){return c.isFunction(b)||(b=this[b]),b&&(a[d]=b),a},{},this)},f.normalizeUIString=function(a,b){return a.replace(/@ui\.[a-zA-Z_$0-9]*/g,function(a){return b[a.slice(4)]})},f.normalizeUIKeys=function(a,b){return c.reduce(a,function(a,c,d){var e=f.normalizeUIString(d,b);return a[e]=c,a},{})},f.normalizeUIValues=function(a,b,d){return c.each(a,function(e,g){c.isString(e)?a[g]=f.normalizeUIString(e,b):c.isObject(e)&&c.isArray(d)&&(c.extend(e,f.normalizeUIValues(c.pick(e,d),b)),c.each(d,function(a){var d=e[a];c.isString(d)&&(e[a]=f.normalizeUIString(d,b))}))}),a},f.actAsCollection=function(a,b){var d=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];c.each(d,function(d){a[d]=function(){var a=c.values(c.result(this,b)),e=[a].concat(c.toArray(arguments));return c[d].apply(c,e)}})};var g=f.deprecate=function(a,b){c.isObject(a)&&(a=a.prev+" is going to be removed in the future. Please use "+a.next+" instead."+(a.url?" See: "+a.url:"")),void 0!==b&&b||g._cache[a]||(g._warn("Deprecation warning: "+a),g._cache[a]=!0)};g._warn="undefined"!=typeof console&&(console.warn||console.log)||function(){},g._cache={},f._triggerMethod=function(){function a(a,b,c){return c.toUpperCase()}var b=/(^|:)(\w)/gi;return function(d,e,f){var g=arguments.length<3;g&&(f=e,e=f[0]);var h,i="on"+e.replace(b,a),j=d[i];return c.isFunction(j)&&(h=j.apply(d,g?c.rest(f):f)),c.isFunction(d.trigger)&&(g+f.length>1?d.trigger.apply(d,g?f:[e].concat(c.drop(f,0))):d.trigger(e)),h}}(),f.triggerMethod=function(){return f._triggerMethod(this,arguments)},f.triggerMethodOn=function(a){var b=c.isFunction(a.triggerMethod)?a.triggerMethod:f.triggerMethod;return b.apply(a,c.rest(arguments))},f.MonitorDOMRefresh=function(a){function b(){a._isShown=!0,e()}function d(){a._isRendered=!0,e()}function e(){a._isShown&&a._isRendered&&f.isNodeAttached(a.el)&&c.isFunction(a.triggerMethod)&&a.triggerMethod("dom:refresh")}a.on({show:b,render:d})},function(a){function b(b,d,e,f){var g=f.split(/\s+/);c.each(g,function(c){var f=b[c];if(!f)throw new a.Error('Method "'+c+'" was configured as an event handler, but does not exist.');b.listenTo(d,e,f)})}function d(a,b,c,d){a.listenTo(b,c,d)}function e(a,b,d,e){var f=e.split(/\s+/);c.each(f,function(c){var e=a[c];a.stopListening(b,d,e)})}function f(a,b,c,d){a.stopListening(b,c,d)}function g(b,d,e,f,g){if(d&&e){if(!c.isObject(e))throw new a.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});e=a._getValue(e,b),c.each(e,function(a,e){c.isFunction(a)?f(b,d,e,a):g(b,d,e,a)})}}a.bindEntityEvents=function(a,c,e){g(a,c,e,d,b)},a.unbindEntityEvents=function(a,b,c){g(a,b,c,f,e)},a.proxyBindEntityEvents=function(b,c){return a.bindEntityEvents(this,b,c)},a.proxyUnbindEntityEvents=function(b,c){return a.unbindEntityEvents(this,b,c)}}(f);var h=["description","fileName","lineNumber","name","message","number"];return f.Error=f.extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+f.VERSION+"/",constructor:function(a,b){c.isObject(a)?(b=a,a=b.message):b||(b={});var d=Error.call(this,a);c.extend(this,c.pick(d,h),c.pick(b,h)),this.captureStackTrace(),b.url&&(this.url=this.urlRoot+b.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,f.Error)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}}),f.Error.extend=f.extend,f.Callbacks=function(){this._deferred=f.Deferred(),this._callbacks=[]},c.extend(f.Callbacks.prototype,{add:function(a,b){var d=c.result(this._deferred,"promise");this._callbacks.push({cb:a,ctx:b}),d.then(function(c){b&&(c.context=b),a.call(c.context,c.options)})},run:function(a,b){this._deferred.resolve({options:a,context:b})},reset:function(){var a=this._callbacks;this._deferred=f.Deferred(),this._callbacks=[],c.each(a,function(a){this.add(a.cb,a.ctx)},this)}}),f.Controller=function(a){this.options=a||{},c.isFunction(this.initialize)&&this.initialize(this.options)},f.Controller.extend=f.extend,c.extend(f.Controller.prototype,b.Events,{destroy:function(){return f._triggerMethod(this,"before:destroy",arguments),f._triggerMethod(this,"destroy",arguments),this.stopListening(),this.off(),this},triggerMethod:f.triggerMethod,mergeOptions:f.mergeOptions,getOption:f.proxyGetOption}),f.Object=function(a){this.options=c.extend({},c.result(this,"options"),a),this.initialize.apply(this,arguments)},f.Object.extend=f.extend,c.extend(f.Object.prototype,b.Events,{initialize:function(){},destroy:function(){return this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening(),this},triggerMethod:f.triggerMethod,mergeOptions:f.mergeOptions,getOption:f.proxyGetOption,bindEntityEvents:f.proxyBindEntityEvents,unbindEntityEvents:f.proxyUnbindEntityEvents}),f.Region=f.Object.extend({constructor:function(a){if(this.options=a||{},this.el=this.getOption("el"),this.el=this.el instanceof b.$?this.el[0]:this.el,!this.el)throw new f.Error({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),f.Object.call(this,a)},show:function(a,b){if(this._ensureElement()){this._ensureViewIsIntact(a);var c=b||{},d=a!==this.currentView,e=!!c.preventDestroy,g=!!c.forceShow,h=!!this.currentView,i=d&&!e,j=d||g;if(h&&this.triggerMethod("before:swapOut",this.currentView,this,b),this.currentView&&delete this.currentView._parent,i?this.empty():h&&j&&this.currentView.off("destroy",this.empty,this),j){a.once("destroy",this.empty,this),a.render(),a._parent=this,h&&this.triggerMethod("before:swap",a,this,b),this.triggerMethod("before:show",a,this,b),f.triggerMethodOn(a,"before:show",a,this,b),h&&this.triggerMethod("swapOut",this.currentView,this,b);var k=f.isNodeAttached(this.el),l=[],m=c.triggerBeforeAttach||this.triggerBeforeAttach,n=c.triggerAttach||this.triggerAttach;return k&&m&&(l=this._displayedViews(a),this._triggerAttach(l,"before:")),this.attachHtml(a),this.currentView=a,k&&n&&(l=this._displayedViews(a),this._triggerAttach(l)),h&&this.triggerMethod("swap",a,this,b),this.triggerMethod("show",a,this,b),f.triggerMethodOn(a,"show",a,this,b),this}return this}},triggerBeforeAttach:!0,triggerAttach:!0,_triggerAttach:function(a,b){var d=(b||"")+"attach";c.each(a,function(a){f.triggerMethodOn(a,d,a,this)},this)},_displayedViews:function(a){return c.union([a],c.result(a,"_getNestedViews")||[])},_ensureElement:function(){if(c.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 f.Error('An "el" '+this.$el.selector+" must exist in DOM")}return!0},_ensureViewIsIntact:function(a){if(!a)throw new f.Error({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(a.isDestroyed)throw new f.Error({name:"ViewDestroyedError",message:'View (cid: "'+a.cid+'") has already been destroyed and cannot be used.'})},getEl:function(a){return b.$(a,f._getValue(this.options.parentEl,this))},attachHtml:function(a){this.$el.contents().detach(),this.el.appendChild(a.el)},empty:function(a){var b=this.currentView,c=f._getValue(a,"preventDestroy",this);return b?(b.off("destroy",this.empty,this),this.triggerMethod("before:empty",b),c||this._destroyView(),this.triggerMethod("empty",b),delete this.currentView,c&&this.$el.contents().detach(),this):void 0},_destroyView:function(){var a=this.currentView;a.destroy&&!a.isDestroyed?a.destroy():a.remove&&(a.remove(),a.isDestroyed=!0)},attachView:function(a){return this.currentView=a,this},hasView:function(){return!!this.currentView},reset:function(){return this.empty(),this.$el&&(this.el=this.$el.selector),delete this.$el,this}},{buildRegion:function(a,b){if(c.isString(a))return this._buildRegionFromSelector(a,b);if(a.selector||a.el||a.regionClass)return this._buildRegionFromObject(a,b);if(c.isFunction(a))return this._buildRegionFromRegionClass(a);throw new f.Error({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})},_buildRegionFromSelector:function(a,b){return new b({el:a})},_buildRegionFromObject:function(a,b){var d=a.regionClass||b,e=c.omit(a,"selector","regionClass");return a.selector&&!e.el&&(e.el=a.selector),new d(e)},_buildRegionFromRegionClass:function(a){return new a}}),f.RegionManager=f.Controller.extend({constructor:function(a){this._regions={},this.length=0,f.Controller.call(this,a),this.addRegions(this.getOption("regions"))},addRegions:function(a,b){return a=f._getValue(a,this,arguments),c.reduce(a,function(a,d,e){return c.isString(d)&&(d={selector:d}),d.selector&&(d=c.defaults({},d,b)),a[e]=this.addRegion(e,d),a},{},this)},addRegion:function(a,b){var c;return c=b instanceof f.Region?b:f.Region.buildRegion(b,f.Region),this.triggerMethod("before:add:region",a,c),c._parent=this,this._store(a,c),this.triggerMethod("add:region",a,c),c},get:function(a){return this._regions[a]},getRegions:function(){return c.clone(this._regions)},removeRegion:function(a){var b=this._regions[a];return this._remove(a,b),b},removeRegions:function(){var a=this.getRegions();return c.each(this._regions,function(a,b){this._remove(b,a)},this),a},emptyRegions:function(){var a=this.getRegions();return c.invoke(a,"empty"),a},destroy:function(){return this.removeRegions(),f.Controller.prototype.destroy.apply(this,arguments)},_store:function(a,b){this._regions[a]||this.length++,this._regions[a]=b},_remove:function(a,b){this.triggerMethod("before:remove:region",a,b),b.empty(),b.stopListening(),delete b._parent,delete this._regions[a],this.length--,this.triggerMethod("remove:region",a,b)}}),f.actAsCollection(f.RegionManager.prototype,"_regions"),f.TemplateCache=function(a){this.templateId=a},c.extend(f.TemplateCache,{templateCaches:{},get:function(a,b){var c=this.templateCaches[a];return c||(c=new f.TemplateCache(a),this.templateCaches[a]=c),c.load(b)},clear:function(){var a,b=c.toArray(arguments),d=b.length;if(d>0)for(a=0;d>a;a++)delete this.templateCaches[b[a]];else this.templateCaches={}}}),c.extend(f.TemplateCache.prototype,{load:function(a){if(this.compiledTemplate)return this.compiledTemplate;var b=this.loadTemplate(this.templateId,a);return this.compiledTemplate=this.compileTemplate(b,a),this.compiledTemplate},loadTemplate:function(a){var c=b.$(a).html();if(!c||0===c.length)throw new f.Error({name:"NoTemplateError",message:'Could not find template: "'+a+'"'});return c},compileTemplate:function(a,b){return c.template(a,b)}}),f.Renderer={render:function(a,b){if(!a)throw new f.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var d=c.isFunction(a)?a:f.TemplateCache.get(a);return d(b)}},f.View=b.View.extend({isDestroyed:!1,constructor:function(a){c.bindAll(this,"render"),a=f._getValue(a,this),this.options=c.extend({},c.result(this,"options"),a),this._behaviors=f.Behaviors(this),b.View.call(this,this.options),f.MonitorDOMRefresh(this)},getTemplate:function(){return this.getOption("template")},serializeModel:function(a){return a.toJSON.apply(a,c.rest(arguments))},mixinTemplateHelpers:function(a){a=a||{};var b=this.getOption("templateHelpers");return b=f._getValue(b,this),c.extend(a,b)},normalizeUIKeys:function(a){var b=c.result(this,"_uiBindings");return f.normalizeUIKeys(a,b||c.result(this,"ui"))},normalizeUIValues:function(a,b){var d=c.result(this,"ui"),e=c.result(this,"_uiBindings");return f.normalizeUIValues(a,e||d,b)},configureTriggers:function(){if(this.triggers){var a=this.normalizeUIKeys(c.result(this,"triggers"));return c.reduce(a,function(a,b,c){return a[c]=this._buildViewTrigger(b),a},{},this)}},delegateEvents:function(a){return this._delegateDOMEvents(a),this.bindEntityEvents(this.model,this.getOption("modelEvents")),this.bindEntityEvents(this.collection,this.getOption("collectionEvents")),c.each(this._behaviors,function(a){a.bindEntityEvents(this.model,a.getOption("modelEvents")),a.bindEntityEvents(this.collection,a.getOption("collectionEvents"))},this),this},_delegateDOMEvents:function(a){var d=f._getValue(a||this.events,this);d=this.normalizeUIKeys(d),c.isUndefined(a)&&(this.events=d);var e={},g=c.result(this,"behaviorEvents")||{},h=this.configureTriggers(),i=c.result(this,"behaviorTriggers")||{};c.extend(e,g,d,h,i),b.View.prototype.delegateEvents.call(this,e)},undelegateEvents:function(){return b.View.prototype.undelegateEvents.apply(this,arguments),this.unbindEntityEvents(this.model,this.getOption("modelEvents")),this.unbindEntityEvents(this.collection,this.getOption("collectionEvents")),c.each(this._behaviors,function(a){a.unbindEntityEvents(this.model,a.getOption("modelEvents")),a.unbindEntityEvents(this.collection,a.getOption("collectionEvents"))},this),this},_ensureViewIsIntact:function(){if(this.isDestroyed)throw new f.Error({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(this.isDestroyed)return this;var a=c.toArray(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(a)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(a)),this.unbindUIElements(),this.isRendered=!1,this.remove(),c.invoke(this._behaviors,"destroy",a),this},bindUIElements:function(){this._bindUIElements(),c.invoke(this._behaviors,this._bindUIElements)},_bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var a=c.result(this,"_uiBindings");this.ui={},c.each(a,function(a,b){this.ui[b]=this.$(a)},this)}},unbindUIElements:function(){this._unbindUIElements(),c.invoke(this._behaviors,this._unbindUIElements)},_unbindUIElements:function(){this.ui&&this._uiBindings&&(c.each(this.ui,function(a,b){delete this.ui[b]},this),this.ui=this._uiBindings,delete this._uiBindings)},_buildViewTrigger:function(a){var b=c.isObject(a),d=c.defaults({},b?a:{},{preventDefault:!0,stopPropagation:!0}),e=b?d.event:a;return function(a){a&&(a.preventDefault&&d.preventDefault&&a.preventDefault(),a.stopPropagation&&d.stopPropagation&&a.stopPropagation());var b={view:this,model:this.model,collection:this.collection};this.triggerMethod(e,b)}},setElement:function(){var a=b.View.prototype.setElement.apply(this,arguments);return c.invoke(this._behaviors,"proxyViewProperties",this),a},triggerMethod:function(){var a=f._triggerMethod(this,arguments);return this._triggerEventOnBehaviors(arguments),this._triggerEventOnParentLayout(arguments[0],c.rest(arguments)),a},_triggerEventOnBehaviors:function(a){for(var b=f._triggerMethod,c=this._behaviors,d=0,e=c&&c.length;e>d;d++)b(c[d],a)},_triggerEventOnParentLayout:function(a,b){var d=this._parentLayoutView();if(d){var e=f.getOption(d,"childViewEventPrefix"),g=e+":"+a;f._triggerMethod(d,[g,this].concat(b));var h=f.getOption(d,"childEvents"),i=d.normalizeMethods(h);i&&c.isFunction(i[a])&&i[a].apply(d,[this].concat(b))}},_getImmediateChildren:function(){return[]},_getNestedViews:function(){var a=this._getImmediateChildren();return a.length?c.reduce(a,function(a,b){return b._getNestedViews?a.concat(b._getNestedViews()):a},a):a},_getAncestors:function(){for(var a=[],b=this._parent;b;)a.push(b),b=b._parent;return a},_parentLayoutView:function(){var a=this._getAncestors();return c.find(a,function(a){return a instanceof f.LayoutView})},normalizeMethods:f.normalizeMethods,mergeOptions:f.mergeOptions,getOption:f.proxyGetOption,bindEntityEvents:f.proxyBindEntityEvents,unbindEntityEvents:f.proxyUnbindEntityEvents}),f.ItemView=f.View.extend({constructor:function(){f.View.apply(this,arguments)},serializeData:function(){if(!this.model&&!this.collection)return{};var a=[this.model||this.collection];return arguments.length&&a.push.apply(a,arguments),this.model?this.serializeModel.apply(this,a):{items:this.serializeCollection.apply(this,a)}},serializeCollection:function(a){return a.toJSON.apply(a,c.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 a=this.getTemplate();if(a!==!1){if(!a)throw new f.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var b=this.mixinTemplateHelpers(this.serializeData()),c=f.Renderer.render(a,b,this);return this.attachElContent(c),this}},attachElContent:function(a){return this.$el.html(a),this}}),f.CollectionView=f.View.extend({childViewEventPrefix:"childview",sort:!0,constructor:function(){this.once("render",this._initialEvents),this._initChildViewStorage(),f.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&&c.each(this._bufferedChildren,c.partial(this._triggerMethodOnChild,"before:show"))},_triggerShowBufferedChildren:function(){this._isShown&&(c.each(this._bufferedChildren,c.partial(this._triggerMethodOnChild,"show")),this._bufferedChildren=[])},_triggerMethodOnChild:function(a,b){f.triggerMethodOn(b,a)},_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(a,b,d){var e;if(e=void 0!==d.at?d.at:c.indexOf(this._filteredSortedModels(),a),this._shouldAddChild(a,e)){this.destroyEmptyView();var f=this.getChildView(a);this.addChild(a,f,e)}},_onCollectionRemove:function(a){var b=this.children.findByModel(a);this.removeChildView(b),this.checkEmpty()},_onShowCalled:function(){this.children.each(c.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 a=this.children,b=this._filteredSortedModels(),d=c.find(b,function(b){return!a.findByModel(b)});if(d)this.render();else{var e=c.map(b,function(b){return a.findByModel(b).el});this.triggerMethod("before:reorder"),this._appendReorderedChildren(e),this.triggerMethod("reorder")}},resortView:function(){f.getOption(this,"reorderOnSort")?this.reorder():this.render()},_sortViews:function(){var a=this._filteredSortedModels(),b=c.find(a,function(a,b){var c=this.children.findByModel(a);return!c||c._index!==b},this);b&&this.resortView()},_emptyViewIndex:-1,_appendReorderedChildren:function(a){this.$el.append(a)},_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 a,b=this._filteredSortedModels();c.each(b,function(b,c){a=this.getChildView(b),this.addChild(b,a,c)},this)},_filteredSortedModels:function(){var a,b=this.getViewComparator();return a=b?c.isString(b)||1===b.length?this.collection.sortBy(b,this):c.clone(this.collection.models).sort(c.bind(b,this)):this.collection.models,this.getOption("filter")&&(a=c.filter(a,function(a,b){return this._shouldAddChild(a,b)},this)),a},showEmptyView:function(){var a=this.getEmptyView();if(a&&!this._showingEmptyView){this.triggerMethod("before:render:empty"),this._showingEmptyView=!0;var c=new b.Model;this.addEmptyView(c,a),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(a,b){var d=this.getOption("emptyViewOptions")||this.getOption("childViewOptions");c.isFunction(d)&&(d=d.call(this,a,this._emptyViewIndex));var e=this.buildChildView(a,b,d);e._parent=this,this.proxyChildEvents(e),this._isShown&&f.triggerMethodOn(e,"before:show"),this.children.add(e),this.renderChildView(e,this._emptyViewIndex),this._isShown&&f.triggerMethodOn(e,"show")},getChildView:function(){var a=this.getOption("childView");if(!a)throw new f.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return a},addChild:function(a,b,c){var d=this.getOption("childViewOptions");d=f._getValue(d,this,[a,c]);var e=this.buildChildView(a,b,d);return this._updateIndices(e,!0,c),this._addChildView(e,c),e._parent=this,e},_updateIndices:function(a,b,c){this.getOption("sort")&&(b&&(a._index=c),this.children.each(function(c){c._index>=a._index&&(c._index+=b?1:-1)}))},_addChildView:function(a,b){this.proxyChildEvents(a),this.triggerMethod("before:add:child",a),this._isShown&&!this.isBuffering&&f.triggerMethodOn(a,"before:show"),this.children.add(a),this.renderChildView(a,b),this._isShown&&!this.isBuffering&&f.triggerMethodOn(a,"show"),this.triggerMethod("add:child",a)},renderChildView:function(a,b){return a.render(),this.attachHtml(this,a,b),a},buildChildView:function(a,b,d){var e=c.extend({model:a},d);return new b(e)},removeChildView:function(a){return a&&(this.triggerMethod("before:remove:child",a),a.destroy?a.destroy():a.remove&&a.remove(),delete a._parent,this.stopListening(a),this.children.remove(a),this.triggerMethod("remove:child",a),this._updateIndices(a,!1)),a},isEmpty:function(){return!this.collection||0===this.collection.length},checkEmpty:function(){this.isEmpty(this.collection)&&this.showEmptyView()},attachBuffer:function(a){a.$el.append(this._createBuffer(a))},_createBuffer:function(a){var b=document.createDocumentFragment();return c.each(a._bufferedChildren,function(a){b.appendChild(a.el)}),b},attachHtml:function(a,b,c){a.isBuffering?a._bufferedChildren.splice(c,0,b):a._insertBefore(b,c)||a._insertAfter(b)},_insertBefore:function(a,b){var c,d=this.getOption("sort")&&barguments.length;o&&(s=r,r=s[0]);var h,a="on"+r.replace(e,t),d=n[a];return i.isFunction(d)&&(h=d.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(t){var e=i.isFunction(t.triggerMethod)?t.triggerMethod:s.triggerMethod;return e.apply(t,i.rest(arguments))},s.MonitorDOMRefresh=function(t){function e(){t._isShown=!0,r()}function n(){t._isRendered=!0,r()}function r(){t._isShown&&t._isRendered&&s.isNodeAttached(t.el)&&i.isFunction(t.triggerMethod)&&t.triggerMethod("dom:refresh")}t.on({show:e,render:n})},function(t){function e(e,n,r,s){var o=s.split(/\s+/);i.each(o,function(i){var s=e[i];if(!s)throw new t.Error('Method "'+i+'" was configured as an event handler, but does not exist.');e.listenTo(n,r,s)})}function n(t,e,i,n){t.listenTo(e,i,n)}function r(t,e,n,r){var s=r.split(/\s+/);i.each(s,function(i){var r=t[i];t.stopListening(e,n,r)})}function s(t,e,i,n){t.stopListening(e,i,n)}function o(e,n,r,s,o){if(n&&r){if(!i.isObject(r))throw new t.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});r=t._getValue(r,e),i.each(r,function(t,r){i.isFunction(t)?s(e,n,r,t):o(e,n,r,t)})}}t.bindEntityEvents=function(t,i,r){o(t,i,r,n,e)},t.unbindEntityEvents=function(t,e,i){o(t,e,i,s,r)},t.proxyBindEntityEvents=function(e,i){return t.bindEntityEvents(this,e,i)},t.proxyUnbindEntityEvents=function(e,i){return t.unbindEntityEvents(this,e,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(t,e){i.isObject(t)?(e=t,t=e.message):e||(e={});var n=Error.call(this,t);i.extend(this,i.pick(n,h),i.pick(e,h)),this.captureStackTrace(),e.url&&(this.url=this.urlRoot+e.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(t,e){var n=i.result(this._deferred,"promise");this._callbacks.push({cb:t,ctx:e}),n.then(function(i){e&&(i.context=e),t.call(i.context,i.options)})},run:function(t,e){this._deferred.resolve({options:t,context:e})},reset:function(){var t=this._callbacks;this._deferred=s.Deferred(),this._callbacks=[],i.each(t,function(t){this.add(t.cb,t.ctx)},this)}}),s.Controller=function(t){this.options=t||{},i.isFunction(this.initialize)&&this.initialize(this.options)},s.Controller.extend=s.extend,i.extend(s.Controller.prototype,e.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(t){this.options=i.extend({},i.result(this,"options"),t),this.initialize.apply(this,arguments)},s.Object.extend=s.extend,i.extend(s.Object.prototype,e.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(t){if(this.options=t||{},this.el=this.getOption("el"),this.el=this.el instanceof e.$?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,t)},show:function(t,e){if(this._ensureElement()){this._ensureViewIsIntact(t);var n=e||{},r=t!==this.currentView,o=!!n.preventDestroy,h=!!n.forceShow,a=!!this.currentView,d=r&&!o,l=r||h;if(a&&this.triggerMethod("before:swapOut",this.currentView,this,e),this.currentView&&delete this.currentView._parent,d?this.empty():a&&l&&this.currentView.off("destroy",this.empty,this),l){t.once("destroy",this.empty,this),t.render(),t._parent=this,a&&this.triggerMethod("before:swap",t,this,e),this.triggerMethod("before:show",t,this,e),s.triggerMethodOn(t,"before:show",t,this,e),a&&this.triggerMethod("swapOut",this.currentView,this,e);var c=s.isNodeAttached(this.el),u=[],g=i.extend({triggerBeforeAttach:this.triggerBeforeAttach,triggerAttach:this.triggerAttach},n);return c&&g.triggerBeforeAttach&&(u=this._displayedViews(t),this._triggerAttach(u,"before:")),this.attachHtml(t),this.currentView=t,c&&g.triggerAttach&&(u=this._displayedViews(t),this._triggerAttach(u)),a&&this.triggerMethod("swap",t,this,e),this.triggerMethod("show",t,this,e),s.triggerMethodOn(t,"show",t,this,e),this}return this}},triggerBeforeAttach:!0,triggerAttach:!0,_triggerAttach:function(t,e){var n=(e||"")+"attach";i.each(t,function(t){s.triggerMethodOn(t,n,t,this)},this)},_displayedViews:function(t){return i.union([t],i.result(t,"_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(t){if(!t)throw new s.Error({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(t.isDestroyed)throw new s.Error({name:"ViewDestroyedError",message:'View (cid: "'+t.cid+'") has already been destroyed and cannot be used.'})},getEl:function(t){return e.$(t,s._getValue(this.options.parentEl,this))},attachHtml:function(t){this.$el.contents().detach(),this.el.appendChild(t.el)},empty:function(t){var e=this.currentView,i=s._getValue(t,"preventDestroy",this);return e?(e.off("destroy",this.empty,this),this.triggerMethod("before:empty",e),i||this._destroyView(),this.triggerMethod("empty",e),delete this.currentView,i&&this.$el.contents().detach(),this):void 0},_destroyView:function(){var t=this.currentView;t.destroy&&!t.isDestroyed?t.destroy():t.remove&&(t.remove(),t.isDestroyed=!0)},attachView:function(t){return this.currentView=t,this},hasView:function(){return!!this.currentView},reset:function(){return this.empty(),this.$el&&(this.el=this.$el.selector),delete this.$el,this}},{buildRegion:function(t,e){if(i.isString(t))return this._buildRegionFromSelector(t,e);if(t.selector||t.el||t.regionClass)return this._buildRegionFromObject(t,e);if(i.isFunction(t))return this._buildRegionFromRegionClass(t);throw new s.Error({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})},_buildRegionFromSelector:function(t,e){return new e({el:t})},_buildRegionFromObject:function(t,e){var n=t.regionClass||e,r=i.omit(t,"selector","regionClass");return t.selector&&!r.el&&(r.el=t.selector),new n(r)},_buildRegionFromRegionClass:function(t){return new t}}),s.RegionManager=s.Controller.extend({constructor:function(t){this._regions={},this.length=0,s.Controller.call(this,t),this.addRegions(this.getOption("regions"))},addRegions:function(t,e){return t=s._getValue(t,this,arguments),i.reduce(t,function(t,n,r){return i.isString(n)&&(n={selector:n}),n.selector&&(n=i.defaults({},n,e)),t[r]=this.addRegion(r,n),t},{},this)},addRegion:function(t,e){var i;return i=e instanceof s.Region?e:s.Region.buildRegion(e,s.Region),this.triggerMethod("before:add:region",t,i),i._parent=this,this._store(t,i),this.triggerMethod("add:region",t,i),i},get:function(t){return this._regions[t]},getRegions:function(){return i.clone(this._regions)},removeRegion:function(t){var e=this._regions[t];return this._remove(t,e),e},removeRegions:function(){var t=this.getRegions();return i.each(this._regions,function(t,e){this._remove(e,t)},this),t},emptyRegions:function(){var t=this.getRegions();return i.invoke(t,"empty"),t},destroy:function(){return this.removeRegions(),s.Controller.prototype.destroy.apply(this,arguments)},_store:function(t,e){this._regions[t]||this.length++,this._regions[t]=e},_remove:function(t,e){this.triggerMethod("before:remove:region",t,e),e.empty(),e.stopListening(),delete e._parent,delete this._regions[t],this.length--,this.triggerMethod("remove:region",t,e)}}),s.actAsCollection(s.RegionManager.prototype,"_regions"),s.TemplateCache=function(t){this.templateId=t},i.extend(s.TemplateCache,{templateCaches:{},get:function(t,e){var i=this.templateCaches[t];return i||(i=new s.TemplateCache(t),this.templateCaches[t]=i),i.load(e)},clear:function(){var t,e=i.toArray(arguments),n=e.length;if(n>0)for(t=0;n>t;t++)delete this.templateCaches[e[t]];else this.templateCaches={}}}),i.extend(s.TemplateCache.prototype,{load:function(t){if(this.compiledTemplate)return this.compiledTemplate;var e=this.loadTemplate(this.templateId,t);return this.compiledTemplate=this.compileTemplate(e,t),this.compiledTemplate},loadTemplate:function(t){var i=e.$(t).html();if(!i||0===i.length)throw new s.Error({name:"NoTemplateError",message:'Could not find template: "'+t+'"'});return i},compileTemplate:function(t,e){return i.template(t,e)}}),s.Renderer={render:function(t,e){if(!t)throw new s.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var n=i.isFunction(t)?t:s.TemplateCache.get(t);return n(e)}},s.View=e.View.extend({isDestroyed:!1,constructor:function(t){i.bindAll(this,"render"),t=s._getValue(t,this),this.options=i.extend({},i.result(this,"options"),t),this._behaviors=s.Behaviors(this),e.View.call(this,this.options),s.MonitorDOMRefresh(this)},getTemplate:function(){return this.getOption("template")},serializeModel:function(t){return t.toJSON.apply(t,i.rest(arguments))},mixinTemplateHelpers:function(t){t=t||{};var e=this.getOption("templateHelpers");return e=s._getValue(e,this),i.extend(t,e)},normalizeUIKeys:function(t){var e=i.result(this,"_uiBindings");return s.normalizeUIKeys(t,e||i.result(this,"ui"))},normalizeUIValues:function(t,e){var n=i.result(this,"ui"),r=i.result(this,"_uiBindings");return s.normalizeUIValues(t,r||n,e)},configureTriggers:function(){if(this.triggers){var t=this.normalizeUIKeys(i.result(this,"triggers"));return i.reduce(t,function(t,e,i){return t[i]=this._buildViewTrigger(e),t},{},this)}},delegateEvents:function(t){return this._delegateDOMEvents(t),this.bindEntityEvents(this.model,this.getOption("modelEvents")),this.bindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(t){t.bindEntityEvents(this.model,t.getOption("modelEvents")),t.bindEntityEvents(this.collection,t.getOption("collectionEvents"))},this),this},_delegateDOMEvents:function(t){var n=s._getValue(t||this.events,this);n=this.normalizeUIKeys(n),i.isUndefined(t)&&(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),e.View.prototype.delegateEvents.call(this,r)},undelegateEvents:function(){return e.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(t){t.unbindEntityEvents(this.model,t.getOption("modelEvents")),t.unbindEntityEvents(this.collection,t.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 t=i.toArray(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(t)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(t)),this.unbindUIElements(),this.isRendered=!1,this.remove(),i.invoke(this._behaviors,"destroy",t),this},bindUIElements:function(){this._bindUIElements(),i.invoke(this._behaviors,this._bindUIElements)},_bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var t=i.result(this,"_uiBindings");this.ui={},i.each(t,function(t,e){this.ui[e]=this.$(t)},this)}},unbindUIElements:function(){this._unbindUIElements(),i.invoke(this._behaviors,this._unbindUIElements)},_unbindUIElements:function(){this.ui&&this._uiBindings&&(i.each(this.ui,function(t,e){delete this.ui[e]},this),this.ui=this._uiBindings,delete this._uiBindings)},_buildViewTrigger:function(t){var e=i.isObject(t),n=i.defaults({},e?t:{},{preventDefault:!0,stopPropagation:!0}),r=e?n.event:t;return function(t){t&&(t.preventDefault&&n.preventDefault&&t.preventDefault(),t.stopPropagation&&n.stopPropagation&&t.stopPropagation());var e={view:this,model:this.model,collection:this.collection};this.triggerMethod(r,e)}},setElement:function(){var t=e.View.prototype.setElement.apply(this,arguments);return i.invoke(this._behaviors,"proxyViewProperties",this),t},triggerMethod:function(){var t=s._triggerMethod(this,arguments);return this._triggerEventOnBehaviors(arguments),this._triggerEventOnParentLayout(arguments[0],i.rest(arguments)),t},_triggerEventOnBehaviors:function(t){for(var e=s._triggerMethod,i=this._behaviors,n=0,r=i&&i.length;r>n;n++)e(i[n],t)},_triggerEventOnParentLayout:function(t,e){var n=this._parentLayoutView();if(n){var r=s.getOption(n,"childViewEventPrefix"),o=r+":"+t;s._triggerMethod(n,[o,this].concat(e));var h=s.getOption(n,"childEvents"),a=n.normalizeMethods(h);a&&i.isFunction(a[t])&&a[t].apply(n,[this].concat(e))}},_getImmediateChildren:function(){return[]},_getNestedViews:function(){var t=this._getImmediateChildren();return t.length?i.reduce(t,function(t,e){return e._getNestedViews?t.concat(e._getNestedViews()):t},t):t},_getAncestors:function(){for(var t=[],e=this._parent;e;)t.push(e),e=e._parent;return t},_parentLayoutView:function(){var t=this._getAncestors();return i.find(t,function(t){return t 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 t=[this.model||this.collection];return arguments.length&&t.push.apply(t,arguments),this.model?this.serializeModel.apply(this,t):{items:this.serializeCollection.apply(this,t)}},serializeCollection:function(t){return t.toJSON.apply(t,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 t=this.getTemplate();if(t!==!1){if(!t)throw new s.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var e=this.mixinTemplateHelpers(this.serializeData()),i=s.Renderer.render(t,e,this);return this.attachElContent(i),this}},attachElContent:function(t){return this.$el.html(t),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({"before:show":this._onBeforeShowCalled,show:this._onShowCalled,"before:attach":this._onBeforeAttachCalled,attach:this._onAttachCalled}),this.initRenderBuffer()},initRenderBuffer:function(){this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){var t,e=this._isShown&&s.isNodeAttached(this.el);this.isBuffering=!1,this._isShown&&this._triggerMethodMany(this._bufferedChildren,this,"before:show"),e&&this._triggerBeforeAttach&&(t=this._getNestedViews(),this._triggerMethodMany(t,this,"before:attach")),this.attachBuffer(this,this._createBuffer()),e&&this._triggerAttach&&(t=this._getNestedViews(),this._triggerMethodMany(t,this,"attach")),this._isShown&&this._triggerMethodMany(this._bufferedChildren,this,"show"),this.initRenderBuffer()},_triggerMethodMany:function(t,e,n){var r=i.drop(arguments,3);i.each(t,function(t){s.triggerMethodOn.apply(t,[t,n,t,e].concat(r))})},_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(t,e,n){var r;if(r=void 0!==n.at?n.at:i.indexOf(this._filteredSortedModels(),t),this._shouldAddChild(t,r)){this.destroyEmptyView();var s=this.getChildView(t);this.addChild(t,s,r)}},_onCollectionRemove:function(t){var e=this.children.findByModel(t);this.removeChildView(e),this.checkEmpty()},_onBeforeShowCalled:function(){this._triggerBeforeAttach=this._triggerAttach=!1,this.children.each(function(t){s.triggerMethodOn(t,"before:show",t)})},_onShowCalled:function(){this.children.each(function(t){s.triggerMethodOn(t,"show",t)})},_onBeforeAttachCalled:function(){this._triggerBeforeAttach=!0},_onAttachCalled:function(){this._triggerAttach=!0},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderChildren(),this.isRendered=!0,this.triggerMethod("render",this),this},reorder:function(){var t=this.children,e=this._filteredSortedModels(),n=i.find(e,function(e){return!t.findByModel(e)});if(n)this.render();else{var r=i.map(e,function(e,i){var n=t.findByModel(e);return n._index=i,n.el});this.triggerMethod("before:reorder"),this._appendReorderedChildren(r),this.triggerMethod("reorder")}},resortView:function(){s.getOption(this,"reorderOnSort")?this.reorder():this.render()},_sortViews:function(){var t=this._filteredSortedModels(),e=i.find(t,function(t,e){var i=this.children.findByModel(t);return!i||i._index!==e},this);e&&this.resortView()},_emptyViewIndex:-1,_appendReorderedChildren:function(t){this.$el.append(t)},_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren({checkEmpty:!1}),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 t,e=this._filteredSortedModels();i.each(e,function(e,i){t=this.getChildView(e),this.addChild(e,t,i)},this)},_filteredSortedModels:function(){var t,e=this.getViewComparator();return t=e?i.isString(e)||1===e.length?this.collection.sortBy(e,this):i.clone(this.collection.models).sort(i.bind(e,this)):this.collection.models,this.getOption("filter")&&(t=i.filter(t,function(t,e){return this._shouldAddChild(t,e)},this)),t},showEmptyView:function(){var t=this.getEmptyView();if(t&&!this._showingEmptyView){this.triggerMethod("before:render:empty"),this._showingEmptyView=!0;var i=new e.Model;this.addEmptyView(i,t),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(t,e){var n,r=this._isShown&&!this.isBuffering&&s.isNodeAttached(this.el),o=this.getOption("emptyViewOptions")||this.getOption("childViewOptions");i.isFunction(o)&&(o=o.call(this,t,this._emptyViewIndex));var h=this.buildChildView(t,e,o);h._parent=this,this.proxyChildEvents(h),this._isShown&&s.triggerMethodOn(h,"before:show",h),this.children.add(h),r&&this._triggerBeforeAttach&&(n=[h].concat(h._getNestedViews()),h.once("render",function(){this._triggerMethodMany(n,this,"before:attach")},this)),this.renderChildView(h,this._emptyViewIndex),r&&this._triggerAttach&&(n=[h].concat(h._getNestedViews()),this._triggerMethodMany(n,this,"attach")),this._isShown&&s.triggerMethodOn(h,"show",h)},getChildView:function(){var t=this.getOption("childView");if(!t)throw new s.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return t},addChild:function(t,e,i){var n=this.getOption("childViewOptions");n=s._getValue(n,this,[t,i]);var r=this.buildChildView(t,e,n);return this._updateIndices(r,!0,i),this.triggerMethod("before:add:child",r),this._addChildView(r,i),this.triggerMethod("add:child",r),r._parent=this,r},_updateIndices:function(t,e,i){this.getOption("sort")&&(e&&(t._index=i),this.children.each(function(i){i._index>=t._index&&(i._index+=e?1:-1)}))},_addChildView:function(t,e){var i,n=this._isShown&&!this.isBuffering&&s.isNodeAttached(this.el);this.proxyChildEvents(t),this._isShown&&!this.isBuffering&&s.triggerMethodOn(t,"before:show",t),this.children.add(t),n&&this._triggerBeforeAttach&&(i=[t].concat(t._getNestedViews()),t.once("render",function(){this._triggerMethodMany(i,this,"before:attach")},this)),this.renderChildView(t,e),n&&this._triggerAttach&&(i=[t].concat(t._getNestedViews()),this._triggerMethodMany(i,this,"attach")),this._isShown&&!this.isBuffering&&s.triggerMethodOn(t,"show",t)},renderChildView:function(t,e){return t.render(),this.attachHtml(this,t,e),t},buildChildView:function(t,e,n){var r=i.extend({model:t},n);return new e(r)},removeChildView:function(t){return t&&(this.triggerMethod("before:remove:child",t),t.destroy?t.destroy():t.remove&&t.remove(),delete t._parent,this.stopListening(t),this.children.remove(t),this.triggerMethod("remove:child",t),this._updateIndices(t,!1)),t},isEmpty:function(){return!this.collection||0===this.collection.length},checkEmpty:function(){this.isEmpty(this.collection)&&this.showEmptyView()},attachBuffer:function(t,e){t.$el.append(e)},_createBuffer:function(){var t=document.createDocumentFragment();return i.each(this._bufferedChildren,function(e){t.appendChild(e.el)}),t},attachHtml:function(t,e,i){t.isBuffering?t._bufferedChildren.splice(i,0,e):t._insertBefore(e,i)||t._insertAfter(e)},_insertBefore:function(t,e){var i,n=this.getOption("sort")&&this.children.length-1>e;return n&&(i=this.children.find(function(t){return t._index===e+1})),i?(i.$el.before(t.el),!0):!1},_insertAfter:function(t){this.$el.append(t.el)},_initChildViewStorage:function(){this.children=new e.ChildViewContainer},destroy:function(){return this.isDestroyed?this:(this.triggerMethod("before:destroy:collection"),this.destroyChildren({checkEmpty:!1}),this.triggerMethod("destroy:collection"),s.View.prototype.destroy.apply(this,arguments))},destroyChildren:function(t){var e=t||{},n=!0,r=this.children.map(i.identity);return i.isUndefined(e.checkEmpty)||(n=e.checkEmpty),this.children.each(this.removeChildView,this),n&&this.checkEmpty(),r},_shouldAddChild:function(t,e){var n=this.getOption("filter");return!i.isFunction(n)||n.call(this,t,e,this.collection)},proxyChildEvents:function(t){var e=this.getOption("childViewEventPrefix");this.listenTo(t,"all",function(){var n=i.toArray(arguments),r=n[0],s=this.normalizeMethods(i.result(this,"childEvents"));n[0]=e+":"+r,n.splice(1,0,t),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 t=this.getOption("childView")||this.constructor;return t},serializeData:function(){var t={};return this.model&&(t=i.partial(this.serializeModel,this.model).apply(this,arguments)),t},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 t={};t=this.serializeData(),t=this.mixinTemplateHelpers(t),this.triggerMethod("before:render:template");var e=this.getTemplate(),i=s.Renderer.render(e,t,this);this.attachElContent(i),this.bindUIElements(),this.triggerMethod("render:template")},attachElContent:function(t){return this.$el.html(t),this},attachBuffer:function(t,e){var i=this.getChildViewContainer(t);i.append(e)},_insertAfter:function(t){var e=this.getChildViewContainer(this,t);e.append(t.el)},_appendReorderedChildren:function(t){var e=this.getChildViewContainer(this);e.append(t)},getChildViewContainer:function(t){if(t.$childViewContainer)return t.$childViewContainer;var e,i=s.getOption(t,"childViewContainer");if(i){var n=s._getValue(i,t);if(e="@"===n.charAt(0)&&t.ui?t.ui[n.substr(4)]:t.$(n),0>=e.length)throw new s.Error({name:"ChildViewContainerMissingError",message:'The specified "childViewContainer" was not found: '+t.childViewContainer})}else e=t.$el;return t.$childViewContainer=e,e},resetChildViewContainer:function(){this.$childViewContainer&&(this.$childViewContainer=void 0)}}),s.LayoutView=s.ItemView.extend({regionClass:s.Region,options:{destroyImmediate:!1},childViewEventPrefix:"childview",constructor:function(t){t=t||{},this._firstRender=!0,this._initializeRegions(t),s.ItemView.call(this,t)},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(t,e){return this.getRegion(t).show(e)},getChildView:function(t){return this.getRegion(t).currentView},addRegion:function(t,e){var i={};return i[t]=e,this._buildRegions(i)[t]},addRegions:function(t){return this.regions=i.extend({},this.regions,t),this._buildRegions(t)},removeRegion:function(t){return delete this.regions[t],this.regionManager.removeRegion(t)},getRegion:function(t){return this.regionManager.get(t)},getRegions:function(){return this.regionManager.getRegions()},_buildRegions:function(t){var e={regionClass:this.getOption("regionClass"),parentEl:i.partial(i.result,this,"el")};return this.regionManager.addRegions(t,e)},_initializeRegions:function(t){var e;this._initRegionManager(),e=s._getValue(this.regions,this,[t])||{};var n=this.getOption.call(t,"regions");n=s._getValue(n,this,[t]),i.extend(e,n),e=this.normalizeUIValues(e,["selector","el"]),this.addRegions(e)},_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(t){this.triggerMethod("before:add:region",t)}),this.listenTo(this.regionManager,"add:region",function(t,e){this[t]=e,this.triggerMethod("add:region",t,e)}),this.listenTo(this.regionManager,"before:remove:region",function(t){this.triggerMethod("before:remove:region",t)}),this.listenTo(this.regionManager,"remove:region",function(t,e){delete this[t],this.triggerMethod("remove:region",t,e)})},_getImmediateChildren:function(){return i.chain(this.regionManager.getRegions()).pluck("currentView").compact().value()}}),s.Behavior=s.Object.extend({constructor:function(t,e){this.view=e,this.defaults=i.result(this,"defaults")||{},this.options=i.extend({},this.defaults,t),this.ui=i.extend({},i.result(e,"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(t){this.$el=t.$el,this.el=t.el}}),s.Behaviors=function(t,e){function i(t,n){return e.isObject(t.behaviors)?(n=i.parseBehaviors(t,n||e.result(t,"behaviors")),i.wrap(t,n,e.keys(o)),n):{}}function n(t,e){this._view=t,this._behaviors=e,this._triggers={}}function r(t){return t._uiBindings||t.ui}var s=/^(\S+)\s*(.*)$/,o={behaviorTriggers:function(t,e){var i=new n(this,e);return i.buildBehaviorTriggers()},behaviorEvents:function(i,n){var o={};return e.each(n,function(i,n){var h={},a=e.clone(e.result(i,"events"))||{};a=t.normalizeUIKeys(a,r(i));var d=0;e.each(a,function(t,r){var o=r.match(s),a=o[1]+"."+[this.cid,n,d++," "].join(""),l=o[2],c=a+l,u=e.isFunction(t)?t:i[t];h[c]=e.bind(u,i)},this),o=e.extend(o,h)},this),o}};return e.extend(i,{behaviorsLookup:function(){throw new t.Error({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.html#behaviorslookup"})},getBehaviorClass:function(e,n){return e.behaviorClass?e.behaviorClass:t._getValue(i.behaviorsLookup,this,[e,n])[n]},parseBehaviors:function(t,n){return e.chain(n).map(function(n,r){var s=i.getBehaviorClass(n,r),o=new s(n,t),h=i.parseBehaviors(t,e.result(o,"behaviors"));return[o].concat(h)}).flatten().value()},wrap:function(t,i,n){e.each(n,function(n){t[n]=e.partial(o[n],t[n],i)})}}),e.extend(n.prototype,{buildBehaviorTriggers:function(){return e.each(this._behaviors,this._buildTriggerHandlersForBehavior,this),this._triggers +},_buildTriggerHandlersForBehavior:function(i,n){var s=e.clone(e.result(i,"triggers"))||{};s=t.normalizeUIKeys(s,r(i)),e.each(s,e.bind(this._setHandlerForBehavior,this,i,n))},_setHandlerForBehavior:function(t,e,i,n){var r=n.replace(/^\S+/,function(t){return t+"."+"behaviortriggers"+e});this._triggers[r]=this._view._buildViewTrigger(i)}}),i}(s,i),s.AppRouter=e.Router.extend({constructor:function(t){this.options=t||{},e.Router.apply(this,arguments);var i=this.getOption("appRoutes"),n=this._getController();this.processAppRoutes(n,i),this.on("route",this._processOnRoute,this)},appRoute:function(t,e){var i=this._getController();this._addAppRoute(i,t,e)},_processOnRoute:function(t,e){if(i.isFunction(this.onRoute)){var n=i.invert(this.getOption("appRoutes"))[t];this.onRoute(t,n,e)}},processAppRoutes:function(t,e){if(e){var n=i.keys(e).reverse();i.each(n,function(i){this._addAppRoute(t,i,e[i])},this)}},_getController:function(){return this.getOption("controller")},_addAppRoute:function(t,e,n){var r=t[n];if(!r)throw new s.Error('Method "'+n+'" was not found on the controller');this.route(e,n,i.bind(r,t))},mergeOptions:s.mergeOptions,getOption:s.proxyGetOption,triggerMethod:s.triggerMethod,bindEntityEvents:s.proxyBindEntityEvents,unbindEntityEvents:s.proxyUnbindEntityEvents}),s.Application=s.Object.extend({constructor:function(t){this._initializeRegions(t),this._initCallbacks=new s.Callbacks,this.submodules={},i.extend(this,t),this._initChannel(),s.Object.call(this,t)},execute:function(){this.commands.execute.apply(this.commands,arguments)},request:function(){return this.reqres.request.apply(this.reqres,arguments)},addInitializer:function(t){this._initCallbacks.add(t)},start:function(t){this.triggerMethod("before:start",t),this._initCallbacks.run(t,this),this.triggerMethod("start",t)},addRegions:function(t){return this._regionManager.addRegions(t)},emptyRegions:function(){return this._regionManager.emptyRegions()},removeRegion:function(t){return this._regionManager.removeRegion(t)},getRegion:function(t){return this._regionManager.get(t)},getRegions:function(){return this._regionManager.getRegions()},module:function(t,e){var n=s.Module.getClass(e),r=i.toArray(arguments);return r.unshift(this),n.create.apply(n,r)},getRegionManager:function(){return new s.RegionManager},_initializeRegions:function(t){var e=i.isFunction(this.regions)?this.regions(t):this.regions||{};this._initRegionManager();var n=s.getOption(t,"regions");return i.isFunction(n)&&(n=n.call(this,t)),i.extend(e,n),this.addRegions(e),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(t,e){this[t]=e,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(t){delete this[t],s._triggerMethod(this,"remove:region",arguments)})},_initChannel:function(){this.channelName=i.result(this,"channelName")||"global",this.channel=i.result(this,"channel")||e.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(t,e,n){this.moduleName=t,this.options=i.extend({},this.options,n),this.initialize=n.initialize||this.initialize,this.submodules={},this._setupInitializersAndFinalizers(),this.app=e,i.isFunction(this.initialize)&&this.initialize(t,e,this.options)},s.Module.extend=s.extend,i.extend(s.Module.prototype,e.Events,{startWithParent:!0,initialize:function(){},addInitializer:function(t){this._initializerCallbacks.add(t)},addFinalizer:function(t){this._finalizerCallbacks.add(t)},start:function(t){this._isInitialized||(i.each(this.submodules,function(e){e.startWithParent&&e.start(t)}),this.triggerMethod("before:start",t),this._initializerCallbacks.run(t,this),this._isInitialized=!0,this.triggerMethod("start",t))},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(t,e){this._runModuleDefinition(t,e)},_runModuleDefinition:function(t,n){if(t){var r=i.flatten([this,this.app,e,s,e.$,i,n]);t.apply(this,r)}},_setupInitializersAndFinalizers:function(){this._initializerCallbacks=new s.Callbacks,this._finalizerCallbacks=new s.Callbacks},triggerMethod:s.triggerMethod}),i.extend(s.Module,{create:function(t,e,n){var r=t,s=i.drop(arguments,3);e=e.split(".");var o=e.length,h=[];return h[o-1]=n,i.each(e,function(e,i){var o=r;r=this._getModule(o,e,t,n),this._addModuleDefinition(o,r,h[i],s)},this),r},_getModule:function(t,e,n,r){var s=i.extend({},r),o=this.getClass(r),h=t[e];return h||(h=new o(e,n,s),t[e]=h,t.submodules[e]=h),h},getClass:function(t){var e=s.Module;return t?t.prototype instanceof e?t:t.moduleClass||e:e},_addModuleDefinition:function(t,e,i,n){var r=this._getDefine(i),s=this._getStartWithParent(i,e);r&&e.addDefinition(r,n),this._addStartWithParent(t,e,s)},_getStartWithParent:function(t,e){var n;return i.isFunction(t)&&t.prototype instanceof s.Module?(n=e.constructor.prototype.startWithParent,i.isUndefined(n)?!0:n):i.isObject(t)?(n=t.startWithParent,i.isUndefined(n)?!0:n):!0},_getDefine:function(t){return!i.isFunction(t)||t.prototype instanceof s.Module?i.isObject(t)?t.define:null:t},_addStartWithParent:function(t,e,i){e.startWithParent=e.startWithParent&&i,e.startWithParent&&!e.startWithParentIsConfigured&&(e.startWithParentIsConfigured=!0,t.addInitializer(function(t){e.startWithParent&&e.start(t)}))}}),s}); +//@ sourceMappingURL=backbone.marionette.map \ No newline at end of file diff --git a/lib/core/backbone.marionette.min.js.map b/lib/core/backbone.marionette.min.js.map deleted file mode 100644 index 0b15909f7b..0000000000 --- a/lib/core/backbone.marionette.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"backbone.marionette.min.js","sources":["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","_appendReorderedChildren","resortView","orderChanged","item","_index","_emptyViewIndex","append","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,mBAAZG,SAAyB,CACzC,CAAA,GAAIJ,GAAWK,QAAQ,YACnBJ,EAAII,QAAQ,aACJA,SAAQ,kBACHA,QAAQ,uBACzBC,OAAOF,QAAUP,EAAQD,EAAMI,EAAUC,OAEzCL,GAAKM,WAAaN,EAAKO,GAAKN,EAAQD,EAAMA,EAAKI,SAAUJ,EAAKK,IAGhEM,KAAM,SAASX,EAAMI,EAAUC,GAC/B,YAEA,IAAIO,GAAqBZ,EAAKM,WAC1BO,EAAab,EAAKO,GAElBD,EAAaF,EAASE,aAE1BA,GAAWQ,QAAU,QAErBR,EAAWS,WAAa,WAGtB,MAFAf,GAAKM,WAAaM,EAClBZ,EAAKO,GAAKM,EACHF,MAITL,EAAWU,SAAWZ,EAASa,EAAED,SAEjCV,EAAWY,YAGXZ,EAAWa,UAAY,SAASC,GAC9B,QAASd,EAAWY,SAASE,IAY/Bd,EAAWe,OAASjB,EAASkB,MAAMD,OAMnCf,EAAWiB,eAAiB,SAASC,GACnC,MAAOpB,G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e,SAASzb,GAC/BnB,EAAOge,iBACThe,EAAO8c,MAAM3b,SAOdvB"} \ No newline at end of file diff --git a/package.json b/package.json index 2857333dd1..9b386c78b4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "backbone.marionette", "description": "Make your Backbone.js apps dance!", - "version": "2.4.1", + "version": "2.4.2", "homepage": "https://github.com/marionettejs/backbone.marionette", "main": "lib/core/backbone.marionette.js", "keywords": [ @@ -42,8 +42,8 @@ "dependencies": { "backbone.babysitter": "^0.1.0", "backbone.wreqr": "^1.0.0", - "backbone": "1.0.0 - 1.1.2", - "underscore": "1.4.4 - 1.6.0" + "backbone": "1.0.0 - 1.2.1", + "underscore": "1.4.4 - 1.8.3" }, "devDependencies": { "chai": "1.9.1", @@ -62,7 +62,7 @@ "grunt-env": "0.4.1", "grunt-istanbul": "0.3.0", "grunt-jscs": "^1.5.0", - "grunt-lintspaces": "0.4.1", + "grunt-lintspaces": "0.7.0", "grunt-mocha-test": "0.10.2", "grunt-plato": "0.1.4", "grunt-preprocess": "4.0.0", @@ -70,7 +70,7 @@ "highlight.js": "8.2.0", "jquery": "2.1.1", "js-yaml": "3.1.0", - "jsdom": "0.10.5", + "jsdom": "2.0.0", "load-grunt-tasks": "0.3.0", "marked": "0.3", "mocha": "1.19.0", diff --git a/src/collection-view.js b/src/collection-view.js index e542f973bc..da5d45d3d5 100644 --- a/src/collection-view.js +++ b/src/collection-view.js @@ -1,4 +1,4 @@ -/* jshint maxstatements: 14 */ +/* jshint maxstatements: 20, maxcomplexity: 7 */ // Collection View // --------------- @@ -22,14 +22,17 @@ Marionette.CollectionView = Marionette.View.extend({ // option to pass `{comparator: compFunction()}` to allow the `CollectionView` // to use a custom sort order for the collection. constructor: function(options) { - this.once('render', this._initialEvents); this._initChildViewStorage(); Marionette.View.apply(this, arguments); - this.on('show', this._onShowCalled); - + this.on({ + 'before:show': this._onBeforeShowCalled, + 'show': this._onShowCalled, + 'before:attach': this._onBeforeAttachCalled, + 'attach': this._onAttachCalled + }); this.initRenderBuffer(); }, @@ -46,33 +49,38 @@ Marionette.CollectionView = Marionette.View.extend({ }, endBuffering: function() { - this.isBuffering = false; - this._triggerBeforeShowBufferedChildren(); - - this.attachBuffer(this); + // Only trigger attach if already shown and attached, otherwise Region#show() handles this. + var canTriggerAttach = this._isShown && Marionette.isNodeAttached(this.el); + var nestedViews; - this._triggerShowBufferedChildren(); - this.initRenderBuffer(); - }, + this.isBuffering = false; - _triggerBeforeShowBufferedChildren: function() { if (this._isShown) { - _.each(this._bufferedChildren, _.partial(this._triggerMethodOnChild, 'before:show')); + this._triggerMethodMany(this._bufferedChildren, this, 'before:show'); + } + if (canTriggerAttach && this._triggerBeforeAttach) { + nestedViews = this._getNestedViews(); + this._triggerMethodMany(nestedViews, this, 'before:attach'); } - }, - _triggerShowBufferedChildren: function() { - if (this._isShown) { - _.each(this._bufferedChildren, _.partial(this._triggerMethodOnChild, 'show')); + this.attachBuffer(this, this._createBuffer()); - this._bufferedChildren = []; + if (canTriggerAttach && this._triggerAttach) { + nestedViews = this._getNestedViews(); + this._triggerMethodMany(nestedViews, this, 'attach'); } + if (this._isShown) { + this._triggerMethodMany(this._bufferedChildren, this, 'show'); + } + this.initRenderBuffer(); }, - // Internal method for _.each loops to call `Marionette.triggerMethodOn` on - // a child view - _triggerMethodOnChild: function(event, childView) { - Marionette.triggerMethodOn(childView, event); + _triggerMethodMany: function(targets, source, eventName) { + var args = _.drop(arguments, 3); + + _.each(targets, function(target) { + Marionette.triggerMethodOn.apply(target, [target, eventName, target, source].concat(args)); + }); }, // Configured the initial events that the collection view @@ -112,8 +120,29 @@ Marionette.CollectionView = Marionette.View.extend({ this.checkEmpty(); }, + _onBeforeShowCalled: function() { + // Reset attach event flags at the top of the Region#show() event lifecycle; if the Region's + // show() options permit onBeforeAttach/onAttach events, these flags will be set true again. + this._triggerBeforeAttach = this._triggerAttach = false; + this.children.each(function(childView) { + Marionette.triggerMethodOn(childView, 'before:show', childView); + }); + }, + _onShowCalled: function() { - this.children.each(_.partial(this._triggerMethodOnChild, 'show')); + this.children.each(function(childView) { + Marionette.triggerMethodOn(childView, 'show', childView); + }); + }, + + // If during Region#show() onBeforeAttach was fired, continue firing it for child views + _onBeforeAttachCalled: function() { + this._triggerBeforeAttach = true; + }, + + // If during Region#show() onAttach was fired, continue firing it for child views + _onAttachCalled: function() { + this._triggerAttach = true; }, // Render children views. Override this method to @@ -146,8 +175,10 @@ Marionette.CollectionView = Marionette.View.extend({ 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; + var els = _.map(models, function(model, index) { + var view = children.findByModel(model); + view._index = index; + return view.el; }); // since append moves elements that are already in the DOM, @@ -200,7 +231,7 @@ Marionette.CollectionView = Marionette.View.extend({ // process _renderChildren: function() { this.destroyEmptyView(); - this.destroyChildren(); + this.destroyChildren({checkEmpty: false}); if (this.isEmpty(this.collection)) { this.showEmptyView(); @@ -294,6 +325,10 @@ Marionette.CollectionView = Marionette.View.extend({ // but "add:child" events are not fired, and the event from // emptyView are not forwarded addEmptyView: function(child, EmptyView) { + // Only trigger attach if already shown, attached, and not buffering, otherwise endBuffer() or + // Region#show() handles this. + var canTriggerAttach = this._isShown && !this.isBuffering && Marionette.isNodeAttached(this.el); + var nestedViews; // get the emptyViewOptions, falling back to childViewOptions var emptyViewOptions = this.getOption('emptyViewOptions') || @@ -311,23 +346,35 @@ Marionette.CollectionView = Marionette.View.extend({ // Proxy emptyView events this.proxyChildEvents(view); - // trigger the 'before:show' event on `view` if the collection view - // has already been shown + // trigger the 'before:show' event on `view` if the collection view has already been shown if (this._isShown) { - Marionette.triggerMethodOn(view, 'before:show'); + Marionette.triggerMethodOn(view, 'before:show', view); } // Store the `emptyView` like a `childView` so we can properly // remove and/or close it later this.children.add(view); + // Trigger `before:attach` following `render` to avoid adding logic and event triggers + // to public method `renderChildView()`. + if (canTriggerAttach && this._triggerBeforeAttach) { + nestedViews = [view].concat(view._getNestedViews()); + view.once('render', function() { + this._triggerMethodMany(nestedViews, this, 'before:attach'); + }, this); + } + // Render it and show it this.renderChildView(view, this._emptyViewIndex); - // call the 'show' method if the collection view - // has already been shown + // Trigger `attach` + if (canTriggerAttach && this._triggerAttach) { + nestedViews = [view].concat(view._getNestedViews()); + this._triggerMethodMany(nestedViews, this, 'attach'); + } + // call the 'show' method if the collection view has already been shown if (this._isShown) { - Marionette.triggerMethodOn(view, 'show'); + Marionette.triggerMethodOn(view, 'show', view); } }, @@ -363,7 +410,9 @@ Marionette.CollectionView = Marionette.View.extend({ // increment indices of views after this one this._updateIndices(view, true, index); + this.triggerMethod('before:add:child', view); this._addChildView(view, index); + this.triggerMethod('add:child', view); view._parent = this; @@ -393,27 +442,42 @@ Marionette.CollectionView = Marionette.View.extend({ // Internal Method. Add the view to children and render it at // the given index. _addChildView: function(view, index) { + // Only trigger attach if already shown, attached, and not buffering, otherwise endBuffer() or + // Region#show() handles this. + var canTriggerAttach = this._isShown && !this.isBuffering && Marionette.isNodeAttached(this.el); + var nestedViews; + // set up the child view event forwarding this.proxyChildEvents(view); - this.triggerMethod('before:add:child', view); - - // trigger the 'before:show' event on `view` if the collection view - // has already been shown + // 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'); + Marionette.triggerMethodOn(view, 'before:show', view); } - // Store the child view itself so we can properly - // remove and/or destroy it later + // Store the child view itself so we can properly remove and/or destroy it later this.children.add(view); + + // Trigger `before:attach` following `render` to avoid adding logic and event triggers + // to public method `renderChildView()`. + if (canTriggerAttach && this._triggerBeforeAttach) { + nestedViews = [view].concat(view._getNestedViews()); + view.once('render', function() { + this._triggerMethodMany(nestedViews, this, 'before:attach'); + }, this); + } + this.renderChildView(view, index); + // Trigger `attach` + if (canTriggerAttach && this._triggerAttach) { + nestedViews = [view].concat(view._getNestedViews()); + this._triggerMethodMany(nestedViews, this, 'attach'); + } + // Trigger `show` if (this._isShown && !this.isBuffering) { - Marionette.triggerMethodOn(view, 'show'); + Marionette.triggerMethodOn(view, 'show', view); } - - this.triggerMethod('add:child', view); }, // render the child view @@ -470,14 +534,14 @@ Marionette.CollectionView = Marionette.View.extend({ }, // You might need to override this if you've overridden attachHtml - attachBuffer: function(collectionView) { - collectionView.$el.append(this._createBuffer(collectionView)); + attachBuffer: function(collectionView, buffer) { + collectionView.$el.append(buffer); }, // Create a fragment buffer from the currently buffered children - _createBuffer: function(collectionView) { + _createBuffer: function() { var elBuffer = document.createDocumentFragment(); - _.each(collectionView._bufferedChildren, function(b) { + _.each(this._bufferedChildren, function(b) { elBuffer.appendChild(b.el); }); return elBuffer; @@ -538,7 +602,7 @@ Marionette.CollectionView = Marionette.View.extend({ if (this.isDestroyed) { return this; } this.triggerMethod('before:destroy:collection'); - this.destroyChildren(); + this.destroyChildren({checkEmpty: false}); this.triggerMethod('destroy:collection'); return Marionette.View.prototype.destroy.apply(this, arguments); @@ -546,10 +610,20 @@ Marionette.CollectionView = Marionette.View.extend({ // Destroy the child views that this collection view // is holding on to, if any - destroyChildren: function() { + destroyChildren: function(options) { + var destroyOptions = options || {}; + var shouldCheckEmpty = true; var childViews = this.children.map(_.identity); + + if (!_.isUndefined(destroyOptions.checkEmpty)) { + shouldCheckEmpty = destroyOptions.checkEmpty; + } + this.children.each(this.removeChildView, this); - this.checkEmpty(); + + if (shouldCheckEmpty) { + this.checkEmpty(); + } return childViews; }, diff --git a/src/composite-view.js b/src/composite-view.js index 6af218c5a0..7bbc818907 100644 --- a/src/composite-view.js +++ b/src/composite-view.js @@ -121,9 +121,9 @@ Marionette.CompositeView = Marionette.CollectionView.extend({ }, // You might need to override this if you've overridden attachHtml - attachBuffer: function(compositeView) { + attachBuffer: function(compositeView, buffer) { var $container = this.getChildViewContainer(compositeView); - $container.append(this._createBuffer(compositeView)); + $container.append(buffer); }, // Internal method. Append a view to the end of the $el. @@ -145,7 +145,7 @@ Marionette.CompositeView = Marionette.CollectionView.extend({ // Internal method to ensure an `$childViewContainer` exists, for the // `attachHtml` method to use. getChildViewContainer: function(containerView, childView) { - if ('$childViewContainer' in containerView) { + if (!!containerView.$childViewContainer) { return containerView.$childViewContainer; } @@ -179,7 +179,7 @@ Marionette.CompositeView = Marionette.CollectionView.extend({ // Internal method to reset the `$childViewContainer` on render resetChildViewContainer: function() { if (this.$childViewContainer) { - delete this.$childViewContainer; + this.$childViewContainer = undefined; } } }); diff --git a/src/region.js b/src/region.js index 3973bc316e..0d3f6179f3 100644 --- a/src/region.js +++ b/src/region.js @@ -110,10 +110,12 @@ Marionette.Region = Marionette.Object.extend({ // as it's a potentially-slow method var displayedViews = []; - var triggerBeforeAttach = showOptions.triggerBeforeAttach || this.triggerBeforeAttach; - var triggerAttach = showOptions.triggerAttach || this.triggerAttach; + var attachOptions = _.extend({ + triggerBeforeAttach: this.triggerBeforeAttach, + triggerAttach: this.triggerAttach + }, showOptions); - if (attachedRegion && triggerBeforeAttach) { + if (attachedRegion && attachOptions.triggerBeforeAttach) { displayedViews = this._displayedViews(view); this._triggerAttach(displayedViews, 'before:'); } @@ -121,7 +123,7 @@ Marionette.Region = Marionette.Object.extend({ this.attachHtml(view); this.currentView = view; - if (attachedRegion && triggerAttach) { + if (attachedRegion && attachOptions.triggerAttach) { displayedViews = this._displayedViews(view); this._triggerAttach(displayedViews); } diff --git a/test/unit/collection-view.spec.js b/test/unit/collection-view.spec.js index 34caa020fc..76e9d535b5 100644 --- a/test/unit/collection-view.spec.js +++ b/test/unit/collection-view.spec.js @@ -5,16 +5,46 @@ describe('collection view', function() { // Shared View Definitions // ----------------------- + var spec = this; + this.ChildView = Backbone.Marionette.ItemView.extend({ tagName: 'span', + // Stub methods in contructor to ensure calls are counted from the moment the parent + // CollectionView instantiates it. + constructor: function(options) { + Marionette.ItemView.prototype.constructor.call(this, options); + this.onBeforeShow = spec.sinon.stub(); + this.onShow = spec.sinon.stub(); + this.onDomRefresh = spec.sinon.stub(); + }, render: function() { this.$el.html(this.model.get('foo')); this.trigger('render'); }, - onRender: function() {} - }); - - this.MockCollectionView = Backbone.Marionette.CollectionView.extend({ + // Init region manager creates a circular reference, which + // explodes Sinon's deep equals assertion. These tests + // do not care if the view has a region manager or not. + _initializeRegions: function() {}, + // The ItemView's destroy method tries to destroy the + // RegionManager, which, from the above, does not exist. + destroy: Marionette.View.prototype.destroy, + onRender: function() {}, + onBeforeShow: function() {}, + onShow: function() {}, + onDomRefresh: function() {}, + }); + + this.DeepEqualChildView = this.ChildView.extend({ + // Init region manager creates a circular reference, which explodes Sinon's deep equals + // assertion. Some tests do not care if the view has a region manager or not, but do care + // about deep equality. + _initializeRegions: function() {}, + // The View's destroy method tries to destroy the RegionManager, which, from the above, + // does not exist. + destroy: Marionette.View.prototype.destroy + }); + + this.CollectionView = Marionette.CollectionView.extend({ childView: this.ChildView, onBeforeRender: function() { return this.isRendered; @@ -29,6 +59,10 @@ describe('collection view', function() { onRenderCollection: function() {}, onBeforeRenderCollection: function() {} }); + + this.DeepEqualCollectionView = this.CollectionView.extend({ + childView: this.DeepEqualChildView, + }); }); // Collection View Specs @@ -37,7 +71,7 @@ describe('collection view', function() { describe('before rendering a collection view', function() { beforeEach(function() { this.collection = new Backbone.Collection([]); - this.CollectionView = this.MockCollectionView.extend({ + this.CollectionView = this.DeepEqualCollectionView.extend({ sort: function() { return 1; } }); @@ -99,7 +133,7 @@ describe('collection view', function() { this.childViewRender = this.sinon.stub(); - this.collectionView = new this.MockCollectionView({ + this.collectionView = new this.DeepEqualCollectionView({ collection: this.collection }); @@ -238,7 +272,7 @@ describe('collection view', function() { this.collection = new Backbone.Collection([{foo: 'bar'}, {foo: 'baz'}]); - this.collectionView = new this.MockCollectionView({ + this.collectionView = new this.DeepEqualCollectionView({ collection: this.collection }); @@ -256,7 +290,7 @@ describe('collection view', function() { describe('when rendering a collection view without a collection', function() { beforeEach(function() { - this.collectionView = new this.MockCollectionView(); + this.collectionView = new this.DeepEqualCollectionView(); this.sinon.spy(this.collectionView, 'onRender'); this.sinon.spy(this.collectionView, 'onBeforeRender'); @@ -303,14 +337,15 @@ describe('collection view', function() { describe('when sorting a collection', function() { beforeEach(function() { this.collection = new Backbone.Collection([{ - foo: 'foo' - }, { - foo: 'bar' - }, { - foo: 'biz' - }, { - foo: 'baz' - }]); + foo: 'foo' + }, { + foo: 'bar' + }, { + foo: 'biz' + }, { + foo: 'baz' + } + ]); this.collection.comparator = function(model) { return model.get('foo'); }; @@ -358,7 +393,7 @@ describe('collection view', function() { describe('when a model is added to the collection', function() { beforeEach(function() { this.collection = new Backbone.Collection(); - this.collectionView = new this.MockCollectionView({ + this.collectionView = new this.DeepEqualCollectionView({ childView: this.ChildView, collection: this.collection }); @@ -394,7 +429,7 @@ describe('collection view', function() { beforeEach(function() { this.collection = new Backbone.Collection({foo: 'bar'}); - this.collectionView = new this.MockCollectionView({ + this.collectionView = new this.DeepEqualCollectionView({ childView: this.ChildView, collection: this.collection }); @@ -492,7 +527,7 @@ describe('collection view', function() { this.collection = new Backbone.Collection(); this.collection.add(this.model); - this.collectionView = new this.MockCollectionView({ + this.collectionView = new this.DeepEqualCollectionView({ childView: this.ChildView, collection: this.collection }); @@ -582,6 +617,7 @@ describe('collection view', function() { this.sinon.spy(this.collectionView, 'onDestroy'); this.sinon.spy(this.collectionView, 'onBeforeDestroy'); this.sinon.spy(this.collectionView, 'trigger'); + this.sinon.spy(this.collectionView, 'checkEmpty'); this.collectionView.bind('destroy:collection', this.destroyHandler); @@ -674,6 +710,10 @@ describe('collection view', function() { expect(this.collectionView).to.have.property('isRendered', false); }); + it('should not call checkEmpty', function() { + expect(this.collectionView.checkEmpty).to.have.not.been.called; + }); + it('should return the CollectionView', function() { expect(this.collectionView.destroy).to.have.returned(this.collectionView); }); @@ -732,6 +772,7 @@ describe('collection view', function() { this.childrenViews = this.collectionView.children.map(_.identity); this.sinon.spy(this.collectionView, 'destroyChildren'); + this.sinon.spy(this.collectionView, 'checkEmpty'); this.collectionView.destroyChildren(); }); @@ -743,6 +784,24 @@ describe('collection view', function() { it('should return the child views', function() { expect(this.collectionView.destroyChildren).to.have.returned(this.childrenViews); }); + + it('should call checkEmpty', function() { + expect(this.collectionView.checkEmpty).to.have.been.calledOnce; + }); + + describe('with the checkEmpty flag set as false', function() { + it('should not call checkEmpty', function() { + this.collectionView.destroyChildren({checkEmpty: false}); + expect(this.collectionView.checkEmpty).to.have.been.calledOnce; + }); + }); + + describe('with the checkEmpty flag set as true', function() { + it('should call checkEmpty', function() { + this.collectionView.destroyChildren({checkEmpty: true}); + expect(this.collectionView.checkEmpty).to.have.been.calledTwice; + }); + }); }); describe('when override attachHtml', function() { @@ -776,7 +835,7 @@ describe('collection view', function() { this.model = new Backbone.Model({foo: 'bar'}); this.collection = new Backbone.Collection([this.model]); - this.collectionView = new this.MockCollectionView({collection: this.collection}); + this.collectionView = new this.DeepEqualCollectionView({collection: this.collection}); this.collectionView.on('childview:some:event', this.someEventSpy); this.collectionView.render(); @@ -796,7 +855,7 @@ describe('collection view', function() { describe('when configuring a custom childViewEventPrefix', function() { beforeEach(function() { - this.CollectionView = this.MockCollectionView.extend({ + this.CollectionView = this.DeepEqualCollectionView.extend({ childViewEventPrefix: 'myPrefix' }); @@ -828,7 +887,7 @@ describe('collection view', function() { this.model = new Backbone.Model({foo: 'bar'}); this.collection = new Backbone.Collection([this.model]); - this.collectionView = new this.MockCollectionView({ + this.collectionView = new this.DeepEqualCollectionView({ childView: Backbone.Marionette.ItemView.extend({ template: function() { return '<%= foo %>'; } }), @@ -883,7 +942,7 @@ describe('collection view', function() { this.model = new Backbone.Model({foo: 'bar'}); this.collection = new Backbone.Collection([this.model]); - this.collectionView = new this.MockCollectionView({ + this.collectionView = new this.DeepEqualCollectionView({ template: '#itemTemplate', collection: this.collection }); @@ -917,7 +976,7 @@ describe('collection view', function() { this.model = new Backbone.Model({foo: 'bar'}); this.collection = new Backbone.Collection([this.model]); - this.collectionView = new this.MockCollectionView({ + this.collectionView = new this.DeepEqualCollectionView({ template: '#itemTemplate', collection: this.collection }); @@ -943,22 +1002,7 @@ describe('collection view', function() { describe('when a child view is added to a collection view, after the collection view has been shown', function() { beforeEach(function() { - this.ChildView = Backbone.Marionette.ItemView.extend({ - onBeforeShow: function() {}, - onShow: function() {}, - onDomRefresh: function() {}, - onRender: function() {}, - template: _.template('<%= foo %>') - }); - - this.CollectionView = Backbone.Marionette.CollectionView.extend({ - childView: this.ChildView, - onShow: function() {} - }); - - this.sinon.spy(this.ChildView.prototype, 'onBeforeShow'); - this.sinon.spy(this.ChildView.prototype, 'onShow'); - this.sinon.spy(this.ChildView.prototype, 'onDomRefresh'); + this.setFixtures($('
')); this.model1 = new Backbone.Model({foo: 1}); this.model2 = new Backbone.Model({foo: 2}); @@ -966,44 +1010,41 @@ describe('collection view', function() { this.collectionView = new this.CollectionView({ collection: this.collection }); - $('body').append(this.collectionView.el); + $('#fixture-container').append(this.collectionView.el); this.collectionView.render(); - this.collectionView.onShow(); this.collectionView.trigger('show'); this.sinon.spy(this.collectionView, 'attachBuffer'); this.sinon.spy(this.collectionView, 'getChildView'); this.collection.add(this.model2); - this.view = this.collectionView.children.findByIndex(1); + this.childView2 = this.collectionView.children.findByIndex(1); }); it('should not use the render buffer', function() { expect(this.collectionView.attachBuffer).not.to.have.been.called; }); - it('should call the "onBeforeShow" method of the child view', function() { - expect(this.ChildView.prototype.onBeforeShow).to.have.been.called; - }); - - it('should call the childs "onBeforeShow" method with itself as the context', function() { - expect(this.ChildView.prototype.onBeforeShow).to.have.been.calledOn(this.view); - }); - - it('should call the "onShow" method of the child view', function() { - expect(this.ChildView.prototype.onShow).to.have.been.called; + it('should call onBeforeShow of the added child view', function() { + expect(this.childView2.onBeforeShow).to.have.been.calledOnce; + expect(this.childView2.onBeforeShow).to.have.been.calledOn(this.childView2); + expect(this.childView2.onBeforeShow).to.have.been.calledWith(this.childView2); }); - it('should call the childs "onShow" method with itself as the context', function() { - expect(this.ChildView.prototype.onShow).to.have.been.calledOn(this.view); + it('should call onShow of the added child view', function() { + expect(this.childView2.onShow).to.have.been.calledOnce; + expect(this.childView2.onShow).to.have.been.calledOn(this.childView2); + expect(this.childView2.onShow).to.have.been.calledWith(this.childView2); }); - it('should call the childs "onDomRefresh" method with itself as the context', function() { - expect(this.ChildView.prototype.onDomRefresh).to.have.been.called; + it('should call onDomRefresh of the added child view', function() { + expect(this.childView2.onDomRefresh).to.have.been.calledOnce; + expect(this.childView2.onDomRefresh).to.have.been.calledOn(this.childView2); + expect(this.childView2.onDomRefresh).to.have.been.calledWithExactly(); // no args }); - it('should call "getChildView" with the new model', function() { + it('should call getChildView with the new model', function() { expect(this.collectionView.getChildView).to.have.been.calledWith(this.model2); }); @@ -1050,7 +1091,7 @@ describe('collection view', function() { describe('when calling childEvents via a childEvents method', function() { beforeEach(function() { - this.CollectionView = this.MockCollectionView.extend({ + this.CollectionView = this.DeepEqualCollectionView.extend({ childEvents: function() { return { 'some:event': 'someEvent' @@ -1085,7 +1126,7 @@ describe('collection view', function() { beforeEach(function() { this.onSomeEventSpy = this.sinon.stub(); - this.CollectionView = this.MockCollectionView.extend({ + this.CollectionView = this.DeepEqualCollectionView.extend({ childEvents: { 'some:event': this.onSomeEventSpy } @@ -1113,7 +1154,7 @@ describe('collection view', function() { describe('when calling childEvents via the childEvents hash with a string of the function name', function() { beforeEach(function() { - this.CollectionView = this.MockCollectionView.extend({ + this.CollectionView = this.DeepEqualCollectionView.extend({ childEvents: { 'some:event': 'someEvent' } @@ -1294,4 +1335,38 @@ describe('collection view', function() { expect(this.childView.$el).to.contain.$text('bar'); }); }); + + describe('when a collection view is initially shown', function() { + beforeEach(function() { + this.collection = new Backbone.Collection([{foo: 1}, {foo: 2}]); + this.collectionView = new this.CollectionView({ + collection: this.collection + }); + + this.collectionView.render(); + this.collectionView.trigger('before:show'); + this.collectionView.trigger('show'); + + this.childView1 = this.collectionView.children.findByIndex(0); + this.childView2 = this.collectionView.children.findByIndex(1); + }); + + it('onBeforeShow should propagate to each child view', function() { + expect(this.childView1.onBeforeShow).to.have.been.calledOnce; + expect(this.childView1.onBeforeShow).to.have.been.calledOn(this.childView1); + expect(this.childView1.onBeforeShow).to.have.been.calledWith(this.childView1); + expect(this.childView2.onBeforeShow).to.have.been.calledOnce; + expect(this.childView2.onBeforeShow).to.have.been.calledOn(this.childView2); + expect(this.childView2.onBeforeShow).to.have.been.calledWith(this.childView2); + }); + + it('onShow should propagate to each child view', function() { + expect(this.childView1.onShow).to.have.been.calledOnce; + expect(this.childView1.onShow).to.have.been.calledOn(this.childView1); + expect(this.childView1.onShow).to.have.been.calledWith(this.childView1); + expect(this.childView2.onShow).to.have.been.calledOnce; + expect(this.childView2.onShow).to.have.been.calledOn(this.childView2); + expect(this.childView2.onShow).to.have.been.calledWith(this.childView2); + }); + }); }); diff --git a/test/unit/on-attach.spec.js b/test/unit/on-attach.spec.js index f4715442c9..55a1c70e83 100644 --- a/test/unit/on-attach.spec.js +++ b/test/unit/on-attach.spec.js @@ -14,6 +14,28 @@ describe('onAttach', function() { onAttach: function() {}, onBeforeAttach: function() {} }); + + var spec = this; + this.EmptyView = Marionette.ItemView.extend({ + template: false, + constructor: function(options) { + Marionette.ItemView.prototype.constructor.call(this, options); + this.onAttach = spec.sinon.stub(); + this.onBeforeAttach = spec.sinon.stub(); + } + }); + this.ChildView = Marionette.ItemView.extend({ + template: false, + constructor: function(options) { + Marionette.ItemView.prototype.constructor.call(this, options); + this.onAttach = spec.sinon.stub(); + this.onBeforeAttach = spec.sinon.stub(); + } + }); + this.BasicCollectionView = Marionette.CollectionView.extend({ + childView: this.ChildView, + emptyView: this.EmptyView + }); }); describe('when showing a region that is not attached to the document', function() { @@ -103,6 +125,26 @@ describe('onAttach', function() { }); }); + describe('when showing a region that is attached to the document & triggerBeforeAttach defaults to true, but the option is passed as false', function() { + beforeEach(function() { + this.view = new this.BasicView(); + this.view.onAttach = this.sinon.stub(); + this.view.onBeforeAttach = this.sinon.stub(); + + this.region.show(this.view, {triggerBeforeAttach: false}); + }); + + it('should not call onBeforeAttach on the view', function() { + expect(this.view.onBeforeAttach).to.not.have.been.called; + }); + + it('should call onAttach on the view', function() { + expect(this.view.onAttach) + .to.have.been.calledOnce + .and.to.have.been.calledWithExactly(this.view, this.region); + }); + }); + describe('when showing a region that is attached to the document & has triggerAttach set to false', function() { beforeEach(function() { this.view = new this.BasicView(); @@ -147,6 +189,26 @@ describe('onAttach', function() { }); }); + describe('when showing a region that is attached to the document & triggerAttach defaults to true, but the option is passed as false', function() { + beforeEach(function() { + this.view = new this.BasicView(); + this.view.onAttach = this.sinon.stub(); + this.view.onBeforeAttach = this.sinon.stub(); + + this.region.show(this.view, {triggerAttach: false}); + }); + + it('should call onBeforeAttach on the view', function() { + expect(this.view.onBeforeAttach) + .to.have.been.calledOnce + .and.to.have.been.calledWithExactly(this.view, this.region); + }); + + it('should not call onAttach on the view', function() { + expect(this.view.onAttach).to.not.have.been.called; + }); + }); + describe('when a view is shown in a region', function() { beforeEach(function() { this.childView = new this.BasicView(); @@ -749,4 +811,210 @@ describe('onAttach', function() { }); }); }); + + describe('when showing an empty CollectionView', function() { + beforeEach(function() { + this.collection = new Backbone.Collection(); + this.collectionView = new this.BasicCollectionView({ + collection: this.collection + }); + this.region.show(this.collectionView); + this.childView = this.collectionView.children.findByIndex(0); + }); + + it('should trigger onBeforeAttach and onAttach on the emptyView a single time', function() { + expect(this.childView).to.be.an.instanceof(this.EmptyView); + expect(this.childView.onBeforeAttach).to.have.been.calledOnce; + expect(this.childView.onBeforeAttach).to.have.been.calledOn(this.childView); + expect(this.childView.onBeforeAttach).to.have.been.calledWith(this.childView); + expect(this.childView.onAttach).to.have.been.calledOnce; + expect(this.childView.onAttach).to.have.been.calledOn(this.childView); + expect(this.childView.onAttach).to.have.been.calledWith(this.childView); + }); + + describe('when adding a new element to the collection', function() { + beforeEach(function() { + this.collection.add({id: 1}); + this.childView = this.collectionView.children.findByIndex(0); + }); + it('should trigger onBeforeAttach and onAttach on the childView a single time', function() { + expect(this.childView).to.be.an.instanceof(this.ChildView); + expect(this.childView.onBeforeAttach).to.have.been.calledOnce; + expect(this.childView.onBeforeAttach).to.have.been.calledOn(this.childView); + expect(this.childView.onBeforeAttach).to.have.been.calledWith(this.childView); + expect(this.childView.onAttach).to.have.been.calledOnce; + expect(this.childView.onAttach).to.have.been.calledOn(this.childView); + expect(this.childView.onAttach).to.have.been.calledWith(this.childView); + }); + }); + }); + + describe('when showing an empty CollectionView with triggerBeforeAttach and triggerAttach set to false on the region', function() { + beforeEach(function() { + this.collection = new Backbone.Collection(); + this.collectionView = new this.BasicCollectionView({ + collection: this.collection + }); + this.region.triggerAttach = false; + this.region.triggerBeforeAttach = false; + this.region.show(this.collectionView); + this.childView = this.collectionView.children.findByIndex(0); + }); + + it('should not trigger onAttach or onBeforeAttach on the emptyView a single time', function() { + expect(this.childView).to.be.an.instanceof(this.EmptyView); + expect(this.childView.onBeforeAttach).to.not.have.been.calledOnce; + expect(this.childView.onBeforeAttach).to.not.have.been.calledOn(this.childView); + expect(this.childView.onBeforeAttach).to.not.have.been.calledWith(this.childView); + expect(this.childView.onAttach).to.not.have.been.calledOnce; + expect(this.childView.onAttach).to.not.have.been.calledOn(this.childView); + expect(this.childView.onAttach).to.not.have.been.calledWith(this.childView); + }); + + describe('when adding a new element to the collection', function() { + beforeEach(function() { + this.collection.add({id: 1}); + this.childView = this.collectionView.children.findByIndex(0); + }); + it('should not trigger onBeforeAttach or onAttach on the childView a single time', function() { + expect(this.childView).to.be.an.instanceof(this.ChildView); + expect(this.childView.onBeforeAttach).to.not.have.been.calledOnce; + expect(this.childView.onBeforeAttach).to.not.have.been.calledOn(this.childView); + expect(this.childView.onBeforeAttach).to.not.have.been.calledWith(this.childView); + expect(this.childView.onAttach).to.not.have.been.calledOnce; + expect(this.childView.onAttach).to.not.have.been.calledOn(this.childView); + expect(this.childView.onAttach).to.not.have.been.calledWith(this.childView); + }); + }); + }); + + describe('when showing a non-empty CollectionView', function() { + beforeEach(function() { + this.collection = new Backbone.Collection([{id: 1}, {id: 2}]); + this.collectionView = new this.BasicCollectionView({ + collection: this.collection + }); + this.region.show(this.collectionView); + this.childView1 = this.collectionView.children.findByIndex(0); + this.childView2 = this.collectionView.children.findByIndex(1); + }); + + it('should trigger onBeforeAttach and onAttach on each of its childViews a single time', function() { + expect(this.childView1.onBeforeAttach).to.have.been.calledOnce; + expect(this.childView1.onBeforeAttach).to.have.been.calledOn(this.childView1); + expect(this.childView1.onBeforeAttach).to.have.been.calledWith(this.childView1); + expect(this.childView1.onAttach).to.have.been.calledOnce; + expect(this.childView1.onAttach).to.have.been.calledOn(this.childView1); + expect(this.childView1.onAttach).to.have.been.calledWith(this.childView1); + expect(this.childView2.onBeforeAttach).to.have.been.calledOnce; + expect(this.childView2.onBeforeAttach).to.have.been.calledOn(this.childView2); + expect(this.childView2.onBeforeAttach).to.have.been.calledWith(this.childView2); + expect(this.childView2.onAttach).to.have.been.calledOnce; + expect(this.childView2.onAttach).to.have.been.calledOn(this.childView2); + expect(this.childView2.onAttach).to.have.been.calledWith(this.childView2); + }); + + describe('when re-rendering the CollectionView', function() { + beforeEach(function() { + this.collectionView.render(); + }); + + it('should trigger onBeforeAttach and onAttach on each of its childViews a single time', function() { + expect(this.childView1.onBeforeAttach).to.have.been.calledOnce; + expect(this.childView1.onBeforeAttach).to.have.been.calledOn(this.childView1); + expect(this.childView1.onBeforeAttach).to.have.been.calledWith(this.childView1); + expect(this.childView1.onAttach).to.have.been.calledOnce; + expect(this.childView1.onAttach).to.have.been.calledOn(this.childView1); + expect(this.childView1.onAttach).to.have.been.calledWith(this.childView1); + expect(this.childView2.onBeforeAttach).to.have.been.calledOnce; + expect(this.childView2.onBeforeAttach).to.have.been.calledOn(this.childView2); + expect(this.childView2.onBeforeAttach).to.have.been.calledWith(this.childView2); + expect(this.childView2.onAttach).to.have.been.calledOnce; + expect(this.childView2.onAttach).to.have.been.calledOn(this.childView2); + expect(this.childView2.onAttach).to.have.been.calledWith(this.childView2); + }); + }); + + describe('when emptying the collection', function() { + beforeEach(function() { + this.collection.reset(); + this.childView = this.collectionView.children.findByIndex(0); + }); + it('should trigger onBeforeAttach and onAttach on the emptyView a single time', function() { + expect(this.childView).to.be.an.instanceof(this.EmptyView); + expect(this.childView.onBeforeAttach).to.have.been.calledOnce; + expect(this.childView.onBeforeAttach).to.have.been.calledOn(this.childView); + expect(this.childView.onBeforeAttach).to.have.been.calledWith(this.childView); + expect(this.childView.onAttach).to.have.been.calledOnce; + expect(this.childView.onAttach).to.have.been.calledOn(this.childView); + expect(this.childView.onAttach).to.have.been.calledWith(this.childView); + }); + }); + }); + + describe('when showing a non-empty CollectionView with triggerBeforeAttach and triggerAttach set to false on the region', function() { + beforeEach(function() { + this.collection = new Backbone.Collection([{id: 1}, {id: 2}]); + this.collectionView = new this.BasicCollectionView({ + collection: this.collection + }); + this.region.triggerAttach = false; + this.region.triggerBeforeAttach = false; + this.region.show(this.collectionView); + this.childView1 = this.collectionView.children.findByIndex(0); + this.childView2 = this.collectionView.children.findByIndex(1); + }); + + it('should not trigger onBeforeAttach or onAttach on each of its childViews a single time', function() { + expect(this.childView1.onBeforeAttach).to.not.have.been.calledOnce; + expect(this.childView1.onBeforeAttach).to.not.have.been.calledOn(this.childView1); + expect(this.childView1.onBeforeAttach).to.not.have.been.calledWith(this.childView1); + expect(this.childView1.onAttach).to.not.have.been.calledOnce; + expect(this.childView1.onAttach).to.not.have.been.calledOn(this.childView1); + expect(this.childView1.onAttach).to.not.have.been.calledWith(this.childView1); + expect(this.childView2.onBeforeAttach).to.not.have.been.calledOnce; + expect(this.childView2.onBeforeAttach).to.not.have.been.calledOn(this.childView2); + expect(this.childView2.onBeforeAttach).to.not.have.been.calledWith(this.childView2); + expect(this.childView2.onAttach).to.not.have.been.calledOnce; + expect(this.childView2.onAttach).to.not.have.been.calledOn(this.childView2); + expect(this.childView2.onAttach).to.not.have.been.calledWith(this.childView2); + }); + + describe('when re-rendering the CollectionView', function() { + beforeEach(function() { + this.collectionView.render(); + }); + + it('should not trigger onBeforeAttach or onAttach on each of its childViews a single time', function() { + expect(this.childView1.onBeforeAttach).to.not.have.been.calledOnce; + expect(this.childView1.onBeforeAttach).to.not.have.been.calledOn(this.childView1); + expect(this.childView1.onBeforeAttach).to.not.have.been.calledWith(this.childView1); + expect(this.childView1.onAttach).to.not.have.been.calledOnce; + expect(this.childView1.onAttach).to.not.have.been.calledOn(this.childView1); + expect(this.childView1.onAttach).to.not.have.been.calledWith(this.childView1); + expect(this.childView2.onBeforeAttach).to.not.have.been.calledOnce; + expect(this.childView2.onBeforeAttach).to.not.have.been.calledOn(this.childView2); + expect(this.childView2.onBeforeAttach).to.not.have.been.calledWith(this.childView2); + expect(this.childView2.onAttach).to.not.have.been.calledOnce; + expect(this.childView2.onAttach).to.not.have.been.calledOn(this.childView2); + expect(this.childView2.onAttach).to.not.have.been.calledWith(this.childView2); + }); + }); + + describe('when emptying the collection', function() { + beforeEach(function() { + this.collection.reset(); + this.childView = this.collectionView.children.findByIndex(0); + }); + it('should not trigger onBeforeAttach or onAttach on the emptyView a single time', function() { + expect(this.childView).to.be.an.instanceof(this.EmptyView); + expect(this.childView.onBeforeAttach).to.not.have.been.calledOnce; + expect(this.childView.onBeforeAttach).to.not.have.been.calledOn(this.childView); + expect(this.childView.onBeforeAttach).to.not.have.been.calledWith(this.childView); + expect(this.childView.onAttach).to.not.have.been.calledOnce; + expect(this.childView.onAttach).to.not.have.been.calledOn(this.childView); + expect(this.childView.onAttach).to.not.have.been.calledWith(this.childView); + }); + }); + }); }); diff --git a/test/unit/setup/helpers.js b/test/unit/setup/helpers.js index 8aa449e755..937d1267e5 100644 --- a/test/unit/setup/helpers.js +++ b/test/unit/setup/helpers.js @@ -23,8 +23,8 @@ beforeEach(function () { afterEach(function () { this.sinon.restore(); - clearFixtures(); window.location.hash = ''; Backbone.history.stop(); Backbone.history.handlers.length = 0; + clearFixtures(); }); diff --git a/test/unit/setup/node.js b/test/unit/setup/node.js index 3e1c0b9fa4..4046caecf5 100644 --- a/test/unit/setup/node.js +++ b/test/unit/setup/node.js @@ -20,7 +20,7 @@ if (!global.document || !global.window) { QuerySelector : false }); - global.window = document.createWindow(); + global.window = document.parentWindow; global.navigator = global.window.navigator; global.window.Node.prototype.contains = function (node) { diff --git a/test/unit/sorted-views.spec.js b/test/unit/sorted-views.spec.js index c6e47c8ac9..ccbb0614cf 100644 --- a/test/unit/sorted-views.spec.js +++ b/test/unit/sorted-views.spec.js @@ -453,6 +453,7 @@ describe('collection/composite view sorting', function() { var cmp = function(m) { return m.get('bar'); }; + if (specOptions.viewComparator) { this.collection.comparator = 'foo'; this.collectionView.options.viewComparator = cmp; @@ -485,6 +486,26 @@ describe('collection/composite view sorting', function() { it('should respect the childViewContainer in a CompositeView', function() { expect(this.compositeView.$('#container')).to.have.$text('321'); }); + + describe('and reversing the sort', function() { + beforeEach(function() { + var cmp = function(m) { + return m.get('foo'); + }; + if (specOptions.viewComparator) { + this.collection.comparator = 'bar'; + this.collectionView.options.viewComparator = cmp; + this.compositeView.options.viewComparator = cmp; + } else { + this.collection.comparator = cmp; + } + this.collection.sort(); + }); + + it('should reorder the DOM', function() { + expect(this.collectionView.$el).to.have.$text('123'); + }); + }); }); };