diff --git a/bower.json b/bower.json index ce53036f03..59c044b976 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.2.2", + "version": "2.3.0-pre", "keywords": [ "backbone", "framework", diff --git a/changelog.md b/changelog.md index 38ea54c9e1..be15adc3bf 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,71 @@ +### v2.3.0-pre [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.2.2...v2.3.0-pre) + +#### 2.3.0 in overview: + +This release of Marionette contains a significant amount of code optimizations and refactors. These changes will not be visible to you as end user however as they improve the underlying base of Marionette and speed up your app to improve consistency across the base classes. Such speed ups are most visible in the great work @megawac has been doing in both [serializeData]( +https://github.com/marionettejs/backbone.marionette/commit/62f15dc7ec880631a0bb79b18470c94b0a0ad086) and [triggerMethod](https://github.com/marionettejs/backbone.marionette/commit/e5957dde9a9a48eeb8097a0ce2f628d795668e64) + +As always you can come chat with us in the main chatroom at https://gitter.im/marionettejs/backbone.marionette/ + +Work has been continuing on improving the documentation of Marionette, via an external custom JSDOC tool that @ChetHarrison has been spear heading via https://github.com/ChetHarrison/jsdoccer + +If you have not already checked out Marionette Inspector, it is a great tool that Jason Laster has been working on to make debugging and working with marionette much easier. https://github.com/MarionetteLabs/marionette.inspector + +##### Features + +* Marionette.isNodeAttached + * Determines whether the passed-in node is a child of the `document` or not. +* View "attach" / onAttach event +* Triggered anytime that showing the view in a Region causes it to be attached to the `document`. Like other Marionette events, it also executes a callback method, `onAttach`, if you've specified one. +* View "before:attach" / onBeforeAttach + * This is just like the attach event described above, but it's triggered right before the view is attached to the document. +* AppRouter Enhancements +* `triggerMethod`, `bindEntityEvents`, and `unbindEntityEvents` are now available on AppRouter +* Marionette.Application is now a subclass of Marionette.Object +* Marionette.Behavior is now a subclass of Marionette.Object +* Marionette.Region is now a subclass of Marionette.Object +* CompositeView’s `getChildViewContainer` now receives `childView` as a second argument. +* Region Triggers now pass the view, region instance, and trigger options to all handler methods +* CollectionView `emptyViewOption` method now receives the model, and index as options. +* Allow non-DOM-backed regions with `allowMissingEl` +* `allowMissingEl` option is respected by `_ensureElement` +* `_ensureElement` returns boolean, indicating whether or not element is available +* Region#show early-terminates on missing element +* Regions now ensure the view being shown is valid + * Allowing you to handle the error of a region.show without the region killing the currentView and breaking without recourse. +* Appending isDestroyed to a Backbone.View on region empty now adds the same safety for not re-showing a removed backbone view. +* Marionette is now aliased as Mn on the window. +* Collection/Composite Views now support passing in 'sort' as both a class property and as an option. +* RegionManager will now auto instantiate regions that are attached to the regionManager instance. + +```js +new Marionette.RegionManager({ + regions: { + "aRegion": "#bar" + } +}); +``` + +##### Fixes + +* Region now uses `$.el.html(‘’)` instead of `.innerHTML` to clear contents. + * We can not use `.innerHTML` due to the fact that IE will not let us clear the html of tables and selects. We also do not want to use the more declarative `empty` method that jquery exposes since `.empty` loops over all of the children DOM nodes and unsets the listeners on each node. While this seems like a desirable thing, it comes at quite a high perf cost. For that reason we are simply clearing the html contents of the node. +* Destroying and old view kept alive by `{preventDestroy: true}` no longer empties it’s former region. +* Now the destroy listener from previous view is removed on region show +* AppRouter `this.options` now assigned prior to `initialize` being called. + + +##### Deprecation Warnings + +* Marionette.Application.addInitializer +* Marionette.Application Channel +* Marionette.Application Regions +* Marionette.Callbacks +* Marionette.Deferred +* Marionette.Module.addInitializer +* Marionette.Module.addFinalizer + + ### v2.2.2 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.2.1...v2.2.2) * Fixes diff --git a/lib/backbone.marionette.js b/lib/backbone.marionette.js index 0c43da4409..74e3b618aa 100644 --- a/lib/backbone.marionette.js +++ b/lib/backbone.marionette.js @@ -1,6 +1,6 @@ // MarionetteJS (Backbone.Marionette) // ---------------------------------- -// v2.2.2 +// v2.3.0-pre // // Copyright (c)2014 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license @@ -22,14 +22,14 @@ /* istanbul ignore next */ if (typeof define === 'function' && define.amd) { define(['backbone', 'underscore'], function(Backbone, _) { - return (root.Marionette = factory(root, Backbone, _)); + return (root.Marionette = root.Mn = factory(root, Backbone, _)); }); } else if (typeof exports !== 'undefined') { var Backbone = require('backbone'); var _ = require('underscore'); module.exports = factory(root, Backbone, _); } else { - root.Marionette = factory(root, root.Backbone, root._); + root.Marionette = root.Mn = factory(root, root.Backbone, root._); } }(this, function(root, Backbone, _) { @@ -493,7 +493,7 @@ var Marionette = Backbone.Marionette = {}; - Marionette.VERSION = '2.2.2'; + Marionette.VERSION = '2.3.0-pre'; Marionette.noConflict = function() { root.Marionette = previousMarionette; @@ -505,20 +505,26 @@ // Get the Deferred creator for later use Marionette.Deferred = Backbone.$.Deferred; - /* jshint unused: false */ + /* jshint unused: false *//* global console */ // Helpers // ------- - // For slicing `arguments` in functions - var slice = Array.prototype.slice; - // Marionette.extend // ----------------- // Borrow the Backbone `extend` method so we can use it as needed Marionette.extend = Backbone.Model.extend; + // Marionette.isNodeAttached + // ------------------------- + + // Determine if `el` is a child of the document + Marionette.isNodeAttached = function(el) { + return Backbone.$.contains(document.documentElement, el); + }; + + // Marionette.getOption // -------------------- @@ -526,15 +532,11 @@ // object or its `options`, with `options` taking precedence. Marionette.getOption = function(target, optionName) { if (!target || !optionName) { return; } - var value; - if (target.options && (target.options[optionName] !== undefined)) { - value = target.options[optionName]; + return target.options[optionName]; } else { - value = target[optionName]; + return target[optionName]; } - - return value; }; // Proxy `Marionette.getOption` @@ -548,17 +550,15 @@ // Pass in a mapping of events => functions or function names // and return a mapping of events => functions Marionette.normalizeMethods = function(hash) { - var normalizedHash = {}; - _.each(hash, function(method, name) { + return _.reduce(hash, function(normalizedHash, method, name) { if (!_.isFunction(method)) { method = this[method]; } - if (!method) { - return; + if (method) { + normalizedHash[name] = method; } - normalizedHash[name] = method; - }, this); - return normalizedHash; + return normalizedHash; + }, {}, this); }; // utility method for parsing @ui. syntax strings @@ -574,37 +574,22 @@ // swaps the @ui with the associated selector. // Returns a new, non-mutated, parsed events hash. Marionette.normalizeUIKeys = function(hash, ui) { - if (typeof(hash) === 'undefined') { - return; - } - - hash = _.clone(hash); - - _.each(_.keys(hash), function(key) { + return _.reduce(hash, function(memo, val, key) { var normalizedKey = Marionette.normalizeUIString(key, ui); - if (normalizedKey !== key) { - hash[normalizedKey] = hash[key]; - delete hash[key]; - } - }); - - return hash; + memo[normalizedKey] = val; + return memo; + }, {}); }; // allows for the use of the @ui. syntax within // a given value for regions // swaps the @ui with the associated selector Marionette.normalizeUIValues = function(hash, ui) { - if (typeof(hash) === 'undefined') { - return; - } - _.each(hash, function(val, key) { if (_.isString(val)) { hash[key] = Marionette.normalizeUIString(val, ui); } }); - return hash; }; @@ -627,15 +612,31 @@ }); }; - // Trigger an event and/or a corresponding method name. Examples: - // - // `this.triggerMethod("foo")` will trigger the "foo" event and - // call the "onFoo" method. - // - // `this.triggerMethod("foo:bar")` will trigger the "foo:bar" event and - // call the "onFooBar" method. - Marionette.triggerMethod = function(event) { + var deprecate = Marionette.deprecate = function(message, test) { + if (_.isObject(message)) { + message = ( + message.prev + ' is going to be removed in the future. ' + + 'Please use ' + message.next + ' instead.' + + (message.url ? ' See: ' + message.url : '') + ); + } + + if ((test === undefined || !test) && !deprecate._cache[message]) { + deprecate._warn('Deprecation warning: ' + message); + deprecate._cache[message] = true; + } + }; + + deprecate._warn = typeof console !== 'undefined' && (console.warn || console.log) || function() {}; + deprecate._cache = {}; + + /* jshint maxstatements: 14, maxcomplexity: 7 */ + // Trigger Method + // -------------- + + + Marionette._triggerMethod = (function() { // split the event name on the ":" var splitter = /(^|:)(\w)/gi; @@ -645,93 +646,101 @@ return eventName.toUpperCase(); } - // get the method name from the event name - var methodName = 'on' + event.replace(splitter, getEventName); - var method = this[methodName]; - var result; + return function(context, event, args) { + var noEventArg = arguments.length < 3; + if (noEventArg) { + args = event; + event = args[0]; + } - // call the onMethodName if it exists - if (_.isFunction(method)) { - // pass all arguments, except the event name - result = method.apply(this, _.tail(arguments)); - } + // get the method name from the event name + var methodName = 'on' + event.replace(splitter, getEventName); + var method = context[methodName]; + var result; - // trigger the event, if a trigger method exists - if (_.isFunction(this.trigger)) { - this.trigger.apply(this, arguments); - } + // call the onMethodName if it exists + if (_.isFunction(method)) { + // pass all args, except the event name + result = method.apply(context, noEventArg ? _.rest(args) : args); + } + + // trigger the event, if a trigger method exists + if (_.isFunction(context.trigger)) { + if (noEventArg + args.length > 1) { + context.trigger.apply(context, noEventArg ? args : [event].concat(_.rest(args, 0))); + } else { + context.trigger(event); + } + } - return result; + return result; + }; + })(); + + // Trigger an event and/or a corresponding method name. Examples: + // + // `this.triggerMethod("foo")` will trigger the "foo" event and + // call the "onFoo" method. + // + // `this.triggerMethod("foo:bar")` will trigger the "foo:bar" event and + // call the "onFooBar" method. + Marionette.triggerMethod = function(event) { + return Marionette._triggerMethod(this, arguments); }; // triggerMethodOn invokes triggerMethod on a specific context // // e.g. `Marionette.triggerMethodOn(view, 'show')` // will trigger a "show" event or invoke onShow the view. - Marionette.triggerMethodOn = function(context, event) { - var args = _.tail(arguments, 2); - var fnc; + Marionette.triggerMethodOn = function(context) { + var fnc = _.isFunction(context.triggerMethod) ? + context.triggerMethod : + Marionette.triggerMethod; - if (_.isFunction(context.triggerMethod)) { - fnc = context.triggerMethod; - } else { - fnc = Marionette.triggerMethod; - } - - return fnc.apply(context, [event].concat(args)); + return fnc.apply(context, _.rest(arguments)); }; - // DOMRefresh - // ---------- - // + // DOM Refresh + // ----------- + // Monitor a view's state, and after it has been rendered and shown // in the DOM, trigger a "dom:refresh" event every time it is // re-rendered. - Marionette.MonitorDOMRefresh = (function(documentElement) { + Marionette.MonitorDOMRefresh = function(view) { + // track when the view has been shown in the DOM, // using a Marionette.Region (or by other means of triggering "show") - function handleShow(view) { + function handleShow() { view._isShown = true; - triggerDOMRefresh(view); + triggerDOMRefresh(); } // track when the view has been rendered - function handleRender(view) { + function handleRender() { view._isRendered = true; - triggerDOMRefresh(view); + triggerDOMRefresh(); } // Trigger the "dom:refresh" event and corresponding "onDomRefresh" method - function triggerDOMRefresh(view) { - if (view._isShown && view._isRendered && isInDOM(view)) { + function triggerDOMRefresh() { + if (view._isShown && view._isRendered && Marionette.isNodeAttached(view.el)) { if (_.isFunction(view.triggerMethod)) { view.triggerMethod('dom:refresh'); } } } - function isInDOM(view) { - return Backbone.$.contains(documentElement, view.el); - } - - // Export public API - return function(view) { - view.listenTo(view, 'show', function() { - handleShow(view); - }); - - view.listenTo(view, 'render', function() { - handleRender(view); - }); - }; - })(document.documentElement); + view.on({ + show: handleShow, + render: handleRender + }); + }; - /* jshint maxparams: 5 */ - // Marionette.bindEntityEvents & unbindEntityEvents - // --------------------------- + // Bind Entity Events & Unbind Entity Events + // ----------------------------------------- // // These methods are used to bind/unbind a backbone "entity" (collection/model) // to methods on a target object. @@ -840,6 +849,9 @@ })(Marionette); + // Error + // ----- + var errorProps = ['description', 'fileName', 'lineNumber', 'name', 'message', 'number']; Marionette.Error = Marionette.extend.call(Error, { @@ -926,9 +938,9 @@ } }); - // Marionette Controller - // --------------------- - // + // Controller + // ---------- + // A multi-purpose object to use as a controller for // modules and routers, and as a mediator for workflow // and coordination of other objects, views, and more. @@ -948,9 +960,8 @@ // Ensure it can trigger events with Backbone.Events _.extend(Marionette.Controller.prototype, Backbone.Events, { destroy: function() { - var args = slice.call(arguments); - this.triggerMethod.apply(this, ['before:destroy'].concat(args)); - this.triggerMethod.apply(this, ['destroy'].concat(args)); + Marionette._triggerMethod(this, 'before:destroy', arguments); + Marionette._triggerMethod(this, 'destroy', arguments); this.stopListening(); this.off(); @@ -966,9 +977,9 @@ }); - // Marionette Object - // --------------------- - // + // Object + // ------ + // A Base Class that other Classes should descend from. // Object borrows many conventions and utilities from Backbone. Marionette.Object = function(options) { @@ -982,7 +993,8 @@ // Object Methods // -------------- - _.extend(Marionette.Object.prototype, { + // Ensure it can trigger events with Backbone.Events + _.extend(Marionette.Object.prototype, Backbone.Events, { //this is a noop method intended to be overridden by classes that extend from this base initialize: function() {}, @@ -1000,138 +1012,43 @@ // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption, - // Proxy `unbindEntityEvents` to enable binding view's events from another entity. + // Proxy `bindEntityEvents` to enable binding view's events from another entity. bindEntityEvents: Marionette.proxyBindEntityEvents, // Proxy `unbindEntityEvents` to enable unbinding view's events from another entity. unbindEntityEvents: Marionette.proxyUnbindEntityEvents }); - // Ensure it can trigger events with Backbone.Events - _.extend(Marionette.Object.prototype, Backbone.Events); - - /* jshint maxcomplexity: 10, maxstatements: 29 */ + /* jshint maxcomplexity: 16, maxstatements: 45, maxlen: 120 */ // Region // ------ - // + // Manage the visual regions of your composite application. See // http://lostechies.com/derickbailey/2011/12/12/composite-js-apps-regions-and-region-managers/ - Marionette.Region = function(options) { - this.options = options || {}; - this.el = this.getOption('el'); - - // Handle when this.el is passed in as a $ wrapped element. - this.el = this.el instanceof Backbone.$ ? this.el[0] : this.el; + Marionette.Region = Marionette.Object.extend({ + constructor: function (options) { - if (!this.el) { - throw new Marionette.Error({ - name: 'NoElError', - message: 'An "el" must be specified for a region.' - }); - } - - this.$el = this.getEl(this.el); - - if (this.initialize) { - var args = slice.apply(arguments); - this.initialize.apply(this, args); - } - }; - - - // Region Class methods - // ------------------- - - _.extend(Marionette.Region, { - - // Build an instance of a region by passing in a configuration object - // and a default region class to use if none is specified in the config. - // - // The config object should either be a string as a jQuery DOM selector, - // a Region class directly, or an object literal that specifies both - // a selector and regionClass: - // - // ```js - // { - // selector: "#foo", - // regionClass: MyCustomRegion - // } - // ``` - // - buildRegion: function(regionConfig, DefaultRegionClass) { - if (_.isString(regionConfig)) { - return this._buildRegionFromSelector(regionConfig, DefaultRegionClass); - } - - if (regionConfig.selector || regionConfig.el || regionConfig.regionClass) { - return this._buildRegionFromObject(regionConfig, DefaultRegionClass); - } - - if (_.isFunction(regionConfig)) { - return this._buildRegionFromRegionClass(regionConfig); - } - - throw new Marionette.Error({ - message: 'Improper region configuration type.', - url: 'marionette.region.html#region-configuration-types' - }); - }, - - // Build the region from a string selector like '#foo-region' - _buildRegionFromSelector: function(selector, DefaultRegionClass) { - return new DefaultRegionClass({ el: selector }); - }, - - // Build the region from a configuration object - // ```js - // { selector: '#foo', regionClass: FooRegion } - // ``` - _buildRegionFromObject: function(regionConfig, DefaultRegionClass) { - var RegionClass = regionConfig.regionClass || DefaultRegionClass; - var options = _.omit(regionConfig, 'selector', 'regionClass'); - - if (regionConfig.selector && !options.el) { - options.el = regionConfig.selector; - } + // set options temporarily so that we can get `el`. + // options will be overriden by Object.constructor + this.options = options || {}; + this.el = this.getOption('el'); - var region = new RegionClass(options); + // Handle when this.el is passed in as a $ wrapped element. + this.el = this.el instanceof Backbone.$ ? this.el[0] : this.el; - // override the `getEl` function if we have a parentEl - // this must be overridden to ensure the selector is found - // on the first use of the region. if we try to assign the - // region's `el` to `parentEl.find(selector)` in the object - // literal to build the region, the element will not be - // guaranteed to be in the DOM already, and will cause problems - if (regionConfig.parentEl) { - region.getEl = function(el) { - if (_.isObject(el)) { - return Backbone.$(el); - } - var parentEl = regionConfig.parentEl; - if (_.isFunction(parentEl)) { - parentEl = parentEl(); - } - return parentEl.find(el); - }; + if (!this.el) { + throw new Marionette.Error({ + name: 'NoElError', + message: 'An "el" must be specified for a region.' + }); } - return region; + this.$el = this.getEl(this.el); + Marionette.Object.call(this, options); }, - // Build the region directly from a given `RegionClass` - _buildRegionFromRegionClass: function(RegionClass) { - return new RegionClass(); - } - - }); - - // Region Instance Methods - // ----------------------- - - _.extend(Marionette.Region.prototype, Backbone.Events, { - // Displays a backbone view instance inside of the region. // Handles calling the `render` method for you. Reads content // directly from the `el` attribute. Also calls an optional @@ -1141,9 +1058,12 @@ // the old view being destroyed on show. // The `forceShow` option can be used to force a view to be // re-rendered if it's already shown in the region. - show: function(view, options){ - this._ensureElement(); + if (!this._ensureElement()) { + return; + } + + this._ensureViewIsIntact(view); var showOptions = options || {}; var isDifferentView = view !== this.currentView; @@ -1163,11 +1083,21 @@ var _shouldShowView = isDifferentView || forceShow; if (isChangingView) { - this.triggerMethod('before:swapOut', this.currentView); + this.triggerMethod('before:swapOut', this.currentView, this, options); + } + + if (this.currentView) { + delete this.currentView._parent; } if (_shouldDestroyView) { this.empty(); + + // A `destroy` event is attached to the clean up manually removed views. + // We need to detach this event when a new view is going to be shown as it + // is no longer relevant. + } else if (isChangingView && _shouldShowView) { + this.currentView.off('destroy', this.empty, this); } if (_shouldShowView) { @@ -1180,27 +1110,49 @@ view.once('destroy', this.empty, this); view.render(); + view._parent = this; + if (isChangingView) { - this.triggerMethod('before:swap', view); + this.triggerMethod('before:swap', view, this, options); } - this.triggerMethod('before:show', view); - Marionette.triggerMethodOn(view, 'before:show'); - - this.attachHtml(view); + this.triggerMethod('before:show', view, this, options); + Marionette.triggerMethodOn(view, 'before:show', view, this, options); if (isChangingView) { - this.triggerMethod('swapOut', this.currentView); + this.triggerMethod('swapOut', this.currentView, this, options); } + // An array of views that we're about to display + var attachedRegion = Marionette.isNodeAttached(this.el); + + // The views that we're about to attach to the document + // It's important that we prevent _getNestedViews from being executed unnecessarily + // as it's a potentially-slow method + var displayedViews = []; + + var triggerBeforeAttach = showOptions.triggerBeforeAttach || this.triggerBeforeAttach; + var triggerAttach = showOptions.triggerAttach || this.triggerAttach; + + if (attachedRegion && triggerBeforeAttach) { + displayedViews = this._displayedViews(view); + this._triggerAttach(displayedViews, 'before:'); + } + + this.attachHtml(view); this.currentView = view; + if (attachedRegion && triggerAttach) { + displayedViews = this._displayedViews(view); + this._triggerAttach(displayedViews); + } + if (isChangingView) { - this.triggerMethod('swap', view); + this.triggerMethod('swap', view, this, options); } - this.triggerMethod('show', view); - Marionette.triggerMethodOn(view, 'show'); + this.triggerMethod('show', view, this, options); + Marionette.triggerMethodOn(view, 'show', view, this, options); return this; } @@ -1208,6 +1160,20 @@ return this; }, + triggerBeforeAttach: true, + triggerAttach: true, + + _triggerAttach: function(views, prefix) { + var eventName = (prefix || '') + 'attach'; + _.each(views, function(view) { + Marionette.triggerMethodOn(view, eventName, view, this); + }, this); + }, + + _displayedViews: function(view) { + return _.union([view], _.result(view, '_getNestedViews') || []); + }, + _ensureElement: function(){ if (!_.isObject(this.el)) { this.$el = this.getEl(this.el); @@ -1215,7 +1181,28 @@ } if (!this.$el || this.$el.length === 0) { - throw new Marionette.Error('An "el" ' + this.$el.selector + ' must exist in DOM'); + if (this.getOption('allowMissingEl')) { + return false; + } else { + throw new Marionette.Error('An "el" ' + this.$el.selector + ' must exist in DOM'); + } + } + return true; + }, + + _ensureViewIsIntact: function(view) { + if (!view) { + throw new Marionette.Error({ + name: 'ViewNotValid', + message: 'The view passed is undefined and therefore invalid. You must pass a view instance to show.' + }); + } + + if (view.isDestroyed) { + throw new Marionette.Error({ + name: 'ViewDestroyedError', + message: 'View (cid: "' + view.cid + '") has already been destroyed and cannot be used.' + }); } }, @@ -1229,7 +1216,14 @@ // appended to the `$el` that the region is managing attachHtml: function(view) { // empty the node and append new view - this.el.innerHTML=''; + // We can not use `.innerHTML` due to the fact that IE + // will not let us clear the html of tables and selects. + // We also do not want to use the more declarative `empty` method + // that jquery exposes since `.empty` loops over all of the children DOM + // nodes and unsets the listeners on each node. While this seems like + // a desirable thing, it comes at quite a high perf cost. For that reason + // we are simply clearing the html contents of the node. + this.$el.html(''); this.el.appendChild(view.el); }, @@ -1261,6 +1255,10 @@ view.destroy(); } else if (view.remove) { view.remove(); + + // appending isDestroyed to raw Backbone View allows regions + // to throw a ViewDestroyedError for this view + view.isDestroyed = true; } }, @@ -1293,152 +1291,224 @@ delete this.$el; return this; - }, + } - // Proxy `getOption` to enable getting options from this or this.options by name. - getOption: Marionette.proxyGetOption, + }, - // import the `triggerMethod` to trigger events with corresponding - // methods if the method exists - triggerMethod: Marionette.triggerMethod - }); + // Static Methods + { - // Copy the `extend` function used by Backbone's classes - Marionette.Region.extend = Marionette.extend; + // Build an instance of a region by passing in a configuration object + // and a default region class to use if none is specified in the config. + // + // The config object should either be a string as a jQuery DOM selector, + // a Region class directly, or an object literal that specifies a selector, + // a custom regionClass, and any options to be supplied to the region: + // + // ```js + // { + // selector: "#foo", + // regionClass: MyCustomRegion, + // allowMissingEl: false + // } + // ``` + // + buildRegion: function(regionConfig, DefaultRegionClass) { + if (_.isString(regionConfig)) { + return this._buildRegionFromSelector(regionConfig, DefaultRegionClass); + } - // Marionette.RegionManager - // ------------------------ - // - // Manage one or more related `Marionette.Region` objects. - Marionette.RegionManager = (function(Marionette) { + if (regionConfig.selector || regionConfig.el || regionConfig.regionClass) { + return this._buildRegionFromObject(regionConfig, DefaultRegionClass); + } - var RegionManager = Marionette.Controller.extend({ - constructor: function(options) { - this._regions = {}; - Marionette.Controller.call(this, options); - }, + if (_.isFunction(regionConfig)) { + return this._buildRegionFromRegionClass(regionConfig); + } - // Add multiple regions using an object literal or a - // function that returns an object literal, where - // each key becomes the region name, and each value is - // the region definition. - addRegions: function(regionDefinitions, defaults) { - if (_.isFunction(regionDefinitions)) { - regionDefinitions = regionDefinitions.apply(this, arguments); - } + throw new Marionette.Error({ + message: 'Improper region configuration type.', + url: 'marionette.region.html#region-configuration-types' + }); + }, - var regions = {}; + // Build the region from a string selector like '#foo-region' + _buildRegionFromSelector: function(selector, DefaultRegionClass) { + return new DefaultRegionClass({ el: selector }); + }, - _.each(regionDefinitions, function(definition, name) { - if (_.isString(definition)) { - definition = {selector: definition}; - } + // Build the region from a configuration object + // ```js + // { selector: '#foo', regionClass: FooRegion, allowMissingEl: false } + // ``` + _buildRegionFromObject: function(regionConfig, DefaultRegionClass) { + var RegionClass = regionConfig.regionClass || DefaultRegionClass; + var options = _.omit(regionConfig, 'selector', 'regionClass'); + + if (regionConfig.selector && !options.el) { + options.el = regionConfig.selector; + } - if (definition.selector) { - definition = _.defaults({}, definition, defaults); + var region = new RegionClass(options); + + // override the `getEl` function if we have a parentEl + // this must be overridden to ensure the selector is found + // on the first use of the region. if we try to assign the + // region's `el` to `parentEl.find(selector)` in the object + // literal to build the region, the element will not be + // guaranteed to be in the DOM already, and will cause problems + if (regionConfig.parentEl) { + region.getEl = function(el) { + if (_.isObject(el)) { + return Backbone.$(el); + } + var parentEl = regionConfig.parentEl; + if (_.isFunction(parentEl)) { + parentEl = parentEl(); } + return parentEl.find(el); + }; + } - var region = this.addRegion(name, definition); - regions[name] = region; - }, this); + return region; + }, - return regions; - }, + // Build the region directly from a given `RegionClass` + _buildRegionFromRegionClass: function(RegionClass) { + return new RegionClass(); + } + }); - // Add an individual region to the region manager, - // and return the region instance - addRegion: function(name, definition) { - var region; + // Region Manager + // -------------- - if (definition instanceof Marionette.Region) { - region = definition; - } else { - region = Marionette.Region.buildRegion(definition, Marionette.Region); + // Manage one or more related `Marionette.Region` objects. + Marionette.RegionManager = Marionette.Controller.extend({ + constructor: function(options) { + this._regions = {}; + + Marionette.Controller.call(this, options); + + this.addRegions(this.getOption('regions')); + }, + + // Add multiple regions using an object literal or a + // function that returns an object literal, where + // each key becomes the region name, and each value is + // the region definition. + addRegions: function(regionDefinitions, defaults) { + if (_.isFunction(regionDefinitions)) { + regionDefinitions = regionDefinitions.apply(this, arguments); + } + + var regions = {}; + + _.each(regionDefinitions, function(definition, name) { + if (_.isString(definition)) { + definition = {selector: definition}; } - this.triggerMethod('before:add:region', name, region); + if (definition.selector) { + definition = _.defaults({}, definition, defaults); + } - this._store(name, region); + var region = this.addRegion(name, definition); + regions[name] = region; + }, this); - this.triggerMethod('add:region', name, region); - return region; - }, + return regions; + }, - // Get a region by name - get: function(name) { - return this._regions[name]; - }, + // Add an individual region to the region manager, + // and return the region instance + addRegion: function(name, definition) { + var region; - // Gets all the regions contained within - // the `regionManager` instance. - getRegions: function(){ - return _.clone(this._regions); - }, + if (definition instanceof Marionette.Region) { + region = definition; + } else { + region = Marionette.Region.buildRegion(definition, Marionette.Region); + } - // Remove a region by name - removeRegion: function(name) { - var region = this._regions[name]; - this._remove(name, region); + this.triggerMethod('before:add:region', name, region); - return region; - }, + region._parent = this; + this._store(name, region); - // Empty all regions in the region manager, and - // remove them - removeRegions: function() { - var regions = this.getRegions(); - _.each(this._regions, function(region, name) { - this._remove(name, region); - }, this); + this.triggerMethod('add:region', name, region); + return region; + }, - return regions; - }, + // Get a region by name + get: function(name) { + return this._regions[name]; + }, - // Empty all regions in the region manager, but - // leave them attached - emptyRegions: function() { - var regions = this.getRegions(); - _.each(regions, function(region) { - region.empty(); - }, this); + // Gets all the regions contained within + // the `regionManager` instance. + getRegions: function(){ + return _.clone(this._regions); + }, - return regions; - }, + // Remove a region by name + removeRegion: function(name) { + var region = this._regions[name]; + this._remove(name, region); - // Destroy all regions and shut down the region - // manager entirely - destroy: function() { - this.removeRegions(); - return Marionette.Controller.prototype.destroy.apply(this, arguments); - }, + return region; + }, - // internal method to store regions - _store: function(name, region) { - this._regions[name] = region; - this._setLength(); - }, + // Empty all regions in the region manager, and + // remove them + removeRegions: function() { + var regions = this.getRegions(); + _.each(this._regions, function(region, name) { + this._remove(name, region); + }, this); - // internal method to remove a region - _remove: function(name, region) { - this.triggerMethod('before:remove:region', name, region); - region.empty(); - region.stopListening(); - delete this._regions[name]; - this._setLength(); - this.triggerMethod('remove:region', name, region); - }, + return regions; + }, - // set the number of regions current held - _setLength: function() { - this.length = _.size(this._regions); - } + // Empty all regions in the region manager, but + // leave them attached + emptyRegions: function() { + var regions = this.getRegions(); + _.invoke(regions, 'empty'); + return regions; + }, - }); + // Destroy all regions and shut down the region + // manager entirely + destroy: function() { + this.removeRegions(); + return Marionette.Controller.prototype.destroy.apply(this, arguments); + }, - Marionette.actAsCollection(RegionManager.prototype, '_regions'); + // internal method to store regions + _store: function(name, region) { + this._regions[name] = region; + this._setLength(); + }, - return RegionManager; - })(Marionette); + // internal method to remove a region + _remove: function(name, region) { + this.triggerMethod('before:remove:region', name, region); + region.empty(); + region.stopListening(); + + delete region._parent; + delete this._regions[name]; + this._setLength(); + this.triggerMethod('remove:region', name, region); + }, + + // set the number of regions current held + _setLength: function() { + this.length = _.size(this._regions); + } + }); + + Marionette.actAsCollection(Marionette.RegionManager.prototype, '_regions'); // Template Cache @@ -1479,7 +1549,7 @@ // `clear("#t1", "#t2", "...")` clear: function() { var i; - var args = slice.call(arguments); + var args = _.toArray(arguments); var length = args.length; if (length > 0) { @@ -1570,8 +1640,8 @@ /* jshint maxlen: 114, nonew: false */ - // Marionette.View - // --------------- + // View + // ---- // The core view class that other Marionette views extend from. Marionette.View = Backbone.View.extend({ @@ -1579,18 +1649,20 @@ constructor: function(options) { _.bindAll(this, 'render'); + options = _.isFunction(options) ? options.call(this) : options; + // this exposes view options to the view initializer // this is a backfill since backbone removed the assignment // of this.options // at some point however this may be removed - this.options = _.extend({}, _.result(this, 'options'), _.isFunction(options) ? options.call(this) : options); + this.options = _.extend({}, _.result(this, 'options'), options); this._behaviors = Marionette.Behaviors(this); Backbone.View.apply(this, arguments); Marionette.MonitorDOMRefresh(this); - this.listenTo(this, 'show', this.onShowCalled); + this.on('show', this.onShowCalled); }, // Get the template for this view @@ -1604,7 +1676,7 @@ // Serialize a model by returning its attributes. Clones // the attributes to allow modification. serializeModel: function(model){ - return model.toJSON.apply(model, slice.call(arguments, 1)); + return model.toJSON.apply(model, _.rest(arguments)); }, // Mix in template helper methods. Looks for a @@ -1624,9 +1696,8 @@ // normalize the keys of passed hash with the views `ui` selectors. // `{"@ui.foo": "bar"}` normalizeUIKeys: function(hash) { - var ui = _.result(this, 'ui'); var uiBindings = _.result(this, '_uiBindings'); - return Marionette.normalizeUIKeys(hash, uiBindings || ui); + return Marionette.normalizeUIKeys(hash, uiBindings || _.result(this, 'ui')); }, // normalize the values of passed hash with the views `ui` selectors. @@ -1642,18 +1713,15 @@ configureTriggers: function() { if (!this.triggers) { return; } - var triggerEvents = {}; - // Allow `triggers` to be configured as a function var triggers = this.normalizeUIKeys(_.result(this, 'triggers')); // Configure the triggers, prevent default // action and stop propagation of DOM events - _.each(triggers, function(value, key) { - triggerEvents[key] = this._buildViewTrigger(value); - }, this); - - return triggerEvents; + return _.reduce(triggers, function(events, value, key) { + events[key] = this._buildViewTrigger(value); + return events; + }, {}, this); }, // Overriding Backbone.View's delegateEvents to handle @@ -1696,8 +1764,7 @@ // Overriding Backbone.View's undelegateEvents to handle unbinding // the `triggers`, `modelEvents`, and `collectionEvents` config undelegateEvents: function() { - var args = slice.call(arguments); - Backbone.View.prototype.undelegateEvents.apply(this, args); + Backbone.View.prototype.undelegateEvents.apply(this, arguments); this.unbindEntityEvents(this.model, this.getOption('modelEvents')); this.unbindEntityEvents(this.collection, this.getOption('collectionEvents')); @@ -1730,7 +1797,7 @@ destroy: function() { if (this.isDestroyed) { return; } - var args = slice.call(arguments); + var args = _.toArray(arguments); this.triggerMethod.apply(this, ['before:destroy'].concat(args)); @@ -1850,17 +1917,35 @@ // import the `triggerMethod` to trigger events with corresponding // methods if the method exists triggerMethod: function() { - var args = arguments; - var triggerMethod = Marionette.triggerMethod; - - var ret = triggerMethod.apply(this, args); - _.each(this._behaviors, function(b) { - triggerMethod.apply(b, args); - }); + var triggerMethod = Marionette._triggerMethod; + var ret = triggerMethod(this, arguments); + var behaviors = this._behaviors; + // Use good ol' for as this is a very hot function + for (var i = 0, length = behaviors && behaviors.length; i < length; i++) { + triggerMethod(behaviors[i], arguments); + } return ret; }, + // This method returns any views that are immediate + // children of this view + _getImmediateChildren: function() { + return []; + }, + + // Returns an array of every nested view within this view + _getNestedViews: function() { + var children = this._getImmediateChildren(); + + if (!children.length) { return children; } + + return _.reduce(children, function(memo, view) { + if (!view._getNestedViews) { return memo; } + return memo.concat(view._getNestedViews()); + }, children); + }, + // Imports the "normalizeMethods" to transform hashes of // events=>function references/names to a hash of events=>function references normalizeMethods: Marionette.normalizeMethods, @@ -1868,7 +1953,7 @@ // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption, - // Proxy `unbindEntityEvents` to enable binding view's events from another entity. + // Proxy `bindEntityEvents` to enable binding view's events from another entity. bindEntityEvents: Marionette.proxyBindEntityEvents, // Proxy `unbindEntityEvents` to enable unbinding view's events from another entity. @@ -1897,21 +1982,27 @@ // You can override the `serializeData` method in your own view definition, // to provide custom serialization for your view's data. serializeData: function(){ - var data = {}; - - if (this.model) { - data = _.partial(this.serializeModel, this.model).apply(this, arguments); + if (!this.model && !this.collection) { + return {}; } - else if (this.collection) { - data = { items: _.partial(this.serializeCollection, this.collection).apply(this, arguments) }; + + var args = [this.model || this.collection]; + if (arguments.length) { + args.push.apply(args, arguments); } - return data; + if (this.model) { + return this.serializeModel.apply(this, args); + } else { + return { + items: this.serializeCollection.apply(this, args) + }; + } }, // Serialize a collection by serializing each of its models. serializeCollection: function(collection){ - return collection.toJSON.apply(collection, slice.call(arguments, 1)); + return collection.toJSON.apply(collection, _.rest(arguments)); }, // Render the view, defaulting to underscore.js templates. @@ -1978,14 +2069,6 @@ this.$el.html(html); return this; - }, - - // Override the default destroy event to add a few - // more events that are triggered. - destroy: function() { - if (this.isDestroyed) { return; } - - return Marionette.View.prototype.destroy.apply(this, arguments); } }); @@ -2008,7 +2091,9 @@ // This will fallback onto appending childView's to the end. constructor: function(options){ var initOptions = options || {}; - this.sort = _.isUndefined(initOptions.sort) ? true : initOptions.sort; + if (_.isUndefined(this.sort)){ + this.sort = _.isUndefined(initOptions.sort) ? true : initOptions.sort; + } this.once('render', this._initialEvents); this._initChildViewStorage(); @@ -2126,6 +2211,9 @@ } }, + // Internal reference to what index a `emptyView` is. + _emptyViewIndex: -1, + // Internal method. Separated so that CompositeView can have // more control over events being triggered, around the rendering // process @@ -2198,12 +2286,14 @@ this.getOption('childViewOptions'); if (_.isFunction(emptyViewOptions)){ - emptyViewOptions = emptyViewOptions.call(this); + emptyViewOptions = emptyViewOptions.call(this, child, this._emptyViewIndex); } // build the empty view var view = this.buildChildView(child, EmptyView, emptyViewOptions); + view._parent = this; + // Proxy emptyView events this.proxyChildEvents(view); @@ -2218,7 +2308,7 @@ this.children.add(view); // Render it and show it - this.renderChildView(view, -1); + this.renderChildView(view, this._emptyViewIndex); // call the 'show' method if the collection view // has already been shown @@ -2263,6 +2353,8 @@ this._addChildView(view, index); + view._parent = this; + return view; }, @@ -2340,6 +2432,7 @@ if (view.destroy) { view.destroy(); } else if (view.remove) { view.remove(); } + delete view._parent; this.stopListening(view); this.children.remove(view); this.triggerMethod('remove:child', view); @@ -2448,7 +2541,7 @@ // Forward all child view events through the parent, // prepending "childview:" to the event name this.listenTo(view, 'all', function() { - var args = slice.call(arguments); + var args = _.toArray(arguments); var rootEvent = args[0]; var childEvents = this.normalizeMethods(_.result(this, 'childEvents')); @@ -2462,6 +2555,10 @@ this.triggerMethod.apply(this, args); }, this); + }, + + _getImmediateChildren: function() { + return _.values(this.children._views); } }); @@ -2510,17 +2607,10 @@ getChildView: function(child) { var childView = this.getOption('childView') || this.constructor; - if (!childView) { - throw new Marionette.Error({ - name: 'NoChildViewError', - message: 'A "childView" must be specified' - }); - } - return childView; }, - // Serialize the collection for the view. + // Serialize the model for the view. // You can override the `serializeData` method in your own view // definition, to provide custom serialization for your view's data. serializeData: function() { @@ -2533,9 +2623,7 @@ return data; }, - // Renders the model once, and the collection once. Calling - // this again will tell the model's view to re-render itself - // but the collection will not re-render. + // Renders the model and the collection. render: function() { this._ensureViewIsIntact(); this.isRendered = true; @@ -2604,13 +2692,13 @@ // Overidden from CollectionView to ensure view is appended to // childViewContainer _insertAfter: function (childView) { - var $container = this.getChildViewContainer(this); + var $container = this.getChildViewContainer(this, childView); $container.append(childView.el); }, // Internal method to ensure an `$childViewContainer` exists, for the // `attachHtml` method to use. - getChildViewContainer: function(containerView) { + getChildViewContainer: function(containerView, childView) { if ('$childViewContainer' in containerView) { return containerView.$childViewContainer; } @@ -2650,8 +2738,8 @@ } }); - // LayoutView - // ---------- + // Layout View + // ----------- // Used for managing application layoutViews, nested layoutViews and // multiple regions within an application or sub-application. @@ -2734,11 +2822,9 @@ // internal method to build regions _buildRegions: function(regions) { - var that = this; - var defaults = { regionClass: this.getOption('regionClass'), - parentEl: function() { return that.$el; } + parentEl: _.partial(_.result, this, '$el') }; return this.regionManager.addRegions(regions, defaults); @@ -2776,7 +2862,6 @@ // Internal method to re-initialize all of the regions by updating the `el` that // they point to _reInitializeRegions: function() { - this.regionManager.emptyRegions(); this.regionManager.each(function(region) { region.reset(); }); @@ -2793,6 +2878,7 @@ // and all regions in it _initRegionManager: function() { this.regionManager = this.getRegionManager(); + this.regionManager._parent = this; this.listenTo(this.regionManager, 'before:add:region', function(name) { this.triggerMethod('before:add:region', name); @@ -2811,20 +2897,27 @@ delete this[name]; this.triggerMethod('remove:region', name, region); }); + }, + + _getImmediateChildren: function() { + return _.chain(this.regionManager.getRegions()) + .pluck('currentView') + .compact() + .value(); } }); // Behavior - // ----------- + // -------- // A Behavior is an isolated set of DOM / // user interactions that can be mixed into any View. // Behaviors allow you to blackbox View specific interactions // into portable logical chunks, keeping your views simple and your code DRY. - Marionette.Behavior = (function(_, Backbone) { - function Behavior(options, view) { + Marionette.Behavior = Marionette.Object.extend({ + constructor: function(options, view) { // Setup reference to the view. // this comes in handle when a behavior // wants to directly talk up the chain @@ -2833,57 +2926,31 @@ this.defaults = _.result(this, 'defaults') || {}; this.options = _.extend({}, this.defaults, options); - // proxy behavior $ method to the view - // this is useful for doing jquery DOM lookups - // scoped to behaviors view. - this.$ = function() { - return this.view.$.apply(this.view, arguments); - }; - - // Call the initialize method passing - // the arguments from the instance constructor - this.initialize.apply(this, arguments); - } - - _.extend(Behavior.prototype, Backbone.Events, { - initialize: function() {}, - - // stopListening to behavior `onListen` events. - destroy: function() { - this.stopListening(); - }, - - proxyViewProperties: function (view) { - this.$el = view.$el; - this.el = view.el; - }, - - // import the `triggerMethod` to trigger events with corresponding - // methods if the method exists - triggerMethod: Marionette.triggerMethod, - - // Proxy `getOption` to enable getting options from this or this.options by name. - getOption: Marionette.proxyGetOption, - - // Proxy `unbindEntityEvents` to enable binding view's events from another entity. - bindEntityEvents: Marionette.proxyBindEntityEvents, + Marionette.Object.apply(this, arguments); + }, - // Proxy `unbindEntityEvents` to enable unbinding view's events from another entity. - unbindEntityEvents: Marionette.proxyUnbindEntityEvents - }); + // proxy behavior $ method to the view + // this is useful for doing jquery DOM lookups + // scoped to behaviors view. + $: function() { + return this.view.$.apply(this.view, arguments); + }, - // Borrow Backbones extend implementation - // this allows us to setup a proper - // inheritance pattern that follows suit - // with the rest of Marionette views. - Behavior.extend = Marionette.extend; + // Stops the behavior from listening to events. + // Overrides Object#destroy to prevent additional events from being triggered. + destroy: function() { + this.stopListening(); + }, - return Behavior; - })(_, Backbone); + proxyViewProperties: function (view) { + this.$el = view.$el; + this.el = view.el; + } + }); /* jshint maxlen: 143 */ - // Marionette.Behaviors - // -------- + // Behaviors + // --------- // Behaviors is a utility class that takes care of // gluing your behavior instances to their given View. @@ -3056,8 +3123,8 @@ })(Marionette, _); - // AppRouter - // --------- + // App Router + // ---------- // Reduce the boilerplate code of handling route events // and then calling a single method on another object. @@ -3077,10 +3144,10 @@ Marionette.AppRouter = Backbone.Router.extend({ constructor: function(options) { - Backbone.Router.apply(this, arguments); - this.options = options || {}; + Backbone.Router.apply(this, arguments); + var appRoutes = this.getOption('appRoutes'); var controller = this._getController(); this.processAppRoutes(controller, appRoutes); @@ -3097,11 +3164,10 @@ // process the route event and trigger the onRoute // method call, if it exists _processOnRoute: function(routeName, routeArgs) { - // find the path that matched - var routePath = _.invert(this.getOption('appRoutes'))[routeName]; - - // make sure an onRoute is there, and call it + // make sure an onRoute before trying to call it if (_.isFunction(this.onRoute)) { + // find the path that matches the current route + var routePath = _.invert(this.getOption('appRoutes'))[routeName]; this.onRoute(routeName, routePath, routeArgs); } }, @@ -3134,7 +3200,13 @@ }, // Proxy `getOption` to enable getting options from this or this.options by name. - getOption: Marionette.proxyGetOption + getOption: Marionette.proxyGetOption, + + triggerMethod: Marionette.triggerMethod, + + bindEntityEvents: Marionette.proxyBindEntityEvents, + + unbindEntityEvents: Marionette.proxyUnbindEntityEvents }); // Application @@ -3143,20 +3215,15 @@ // Contain and manage the composite application as a whole. // Stores and starts up `Region` objects, includes an // event aggregator as `app.vent` - Marionette.Application = function(options) { - this.options = options; - this._initializeRegions(options); - this._initCallbacks = new Marionette.Callbacks(); - this.submodules = {}; - _.extend(this, options); - this._initChannel(); - this.initialize.apply(this, arguments); - }; - - _.extend(Marionette.Application.prototype, Backbone.Events, { - // Initialize is an empty function by default. Override it with your own - // initialization logic. - initialize: function() {}, + Marionette.Application = Marionette.Object.extend({ + constructor: function(options) { + this._initializeRegions(options); + this._initCallbacks = new Marionette.Callbacks(); + this.submodules = {}; + _.extend(this, options); + this._initChannel(); + Marionette.Object.call(this, options); + }, // Command execution, facilitated by Backbone.Wreqr.Commands execute: function() { @@ -3222,9 +3289,7 @@ // Overwrite the module class if the user specifies one var ModuleClass = Marionette.Module.getClass(moduleDefinition); - // slice the args, and add this application object as the - // first argument of the array - var args = slice.call(arguments); + var args = _.toArray(arguments); args.unshift(this); // see the Marionette.Module object for more information @@ -3264,23 +3329,24 @@ // Internal method to set up the region manager _initRegionManager: function() { this._regionManager = this.getRegionManager(); + this._regionManager._parent = this; - this.listenTo(this._regionManager, 'before:add:region', function(name) { - this.triggerMethod('before:add:region', name); + this.listenTo(this._regionManager, 'before:add:region', function() { + Marionette._triggerMethod(this, 'before:add:region', arguments); }); this.listenTo(this._regionManager, 'add:region', function(name, region) { this[name] = region; - this.triggerMethod('add:region', name, region); + Marionette._triggerMethod(this, 'add:region', arguments); }); - this.listenTo(this._regionManager, 'before:remove:region', function(name) { - this.triggerMethod('before:remove:region', name); + this.listenTo(this._regionManager, 'before:remove:region', function() { + Marionette._triggerMethod(this, 'before:remove:region', arguments); }); - this.listenTo(this._regionManager, 'remove:region', function(name, region) { + this.listenTo(this._regionManager, 'remove:region', function(name) { delete this[name]; - this.triggerMethod('remove:region', name, region); + Marionette._triggerMethod(this, 'remove:region', arguments); }); }, @@ -3291,19 +3357,9 @@ this.vent = _.result(this, 'vent') || this.channel.vent; this.commands = _.result(this, 'commands') || this.channel.commands; this.reqres = _.result(this, 'reqres') || this.channel.reqres; - }, - - // import the `triggerMethod` to trigger events with corresponding - // methods if the method exists - triggerMethod: Marionette.triggerMethod, - - // Proxy `getOption` to enable getting options from this or this.options by name. - getOption: Marionette.proxyGetOption + } }); - // Copy the `extend` function used by Backbone's classes - Marionette.Application.extend = Marionette.extend; - /* jshint maxparams: 9 */ // Module @@ -3391,7 +3447,7 @@ // stop the sub-modules; depth-first, to make sure the // sub-modules are stopped / finalized before parents - _.each(this.submodules, function(mod) { mod.stop(); }); + _.invoke(this.submodules, 'stop'); // run the finalizers this._finalizerCallbacks.run(undefined, this); @@ -3450,8 +3506,7 @@ // get the custom args passed in after the module definition and // get rid of the module name and definition function - var customArgs = slice.call(arguments); - customArgs.splice(0, 3); + var customArgs = _.rest(arguments, 3); // Split the module names and get the number of submodules. // i.e. an example module name of `Doge.Wow.Amaze` would diff --git a/lib/backbone.marionette.map b/lib/backbone.marionette.map index 77fc0dbf50..d21ba1db7a 100644 --- a/lib/backbone.marionette.map +++ b/lib/backbone.marionette.map @@ -1 +1 @@ -{"version":3,"file":"lib/backbone.marionette.min.js","sources":["?"],"names":["root","factory","define","amd","Backbone","_","Marionette","exports","require","module","this","previousChildViewContainer","ChildViewContainer","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","each","add","extend","prototype","view","customIndex","viewCid","cid","model","findByModel","findByModelCid","modelCid","findByCid","findByCustom","index","findByIndex","values","remove","any","key","call","method","apply","tail","arguments","args","isFunction","length","size","methods","concat","toArray","VERSION","noConflict","previousWreqr","Wreqr","Handlers","options","_wreqrHandlers","initialize","Model","Events","setHandlers","handlers","handler","name","context","isObject","callback","setHandler","config","trigger","hasHandler","getHandler","Array","slice","removeHandler","removeAllHandlers","CommandStorage","_commands","getCommands","commandName","commands","command","instances","addCommand","push","clearCommands","Commands","storageType","constructor","_initializeStorage","on","_executeCommands","execute","storage","StorageType","RequestResponse","request","EventAggregator","EA","Channel","channelName","vent","reqres","reset","off","stopListening","connectEvents","hash","_connect","connectCommands","connectRequests","type","fn","eventName","bind","radio","Radio","_channels","_proxyMethods","channel","Error","_getChannel","system","messageSystems","proxyMethod","messageSystem","previousMarionette","Deferred","$","getOption","target","optionName","value","undefined","proxyGetOption","normalizeMethods","normalizedHash","normalizeUIString","uiString","ui","replace","r","normalizeUIKeys","clone","keys","normalizedKey","normalizeUIValues","val","isString","actAsCollection","object","listProperty","list","result","triggerMethod","event","getEventName","match","prefix","toUpperCase","splitter","methodName","triggerMethodOn","fnc","MonitorDOMRefresh","documentElement","handleShow","_isShown","triggerDOMRefresh","handleRender","_isRendered","isInDOM","contains","el","listenTo","document","bindFromStrings","entity","evt","methodNames","split","bindToFunction","unbindFromStrings","unbindToFunction","iterateEvents","bindings","functionCallback","stringCallback","message","url","bindEntityEvents","unbindEntityEvents","proxyBindEntityEvents","proxyUnbindEntityEvents","errorProps","urlRoot","error","pick","captureStackTrace","toString","Callbacks","_deferred","_callbacks","contextOverride","promise","cb","ctx","then","run","resolve","callbacks","Controller","destroy","Object","Region","$el","getEl","buildRegion","regionConfig","DefaultRegionClass","_buildRegionFromSelector","selector","regionClass","_buildRegionFromObject","_buildRegionFromRegionClass","RegionClass","omit","region","parentEl","find","show","_ensureElement","showOptions","isDifferentView","currentView","preventDestroy","forceShow","isChangingView","_shouldDestroyView","_shouldShowView","empty","once","render","attachHtml","innerHTML","appendChild","_destroyView","isDestroyed","attachView","hasView","RegionManager","_regions","addRegions","regionDefinitions","defaults","regions","definition","addRegion","_store","get","getRegions","removeRegion","_remove","removeRegions","emptyRegions","_setLength","TemplateCache","templateId","templateCaches","cachedTemplate","load","clear","i","compiledTemplate","template","loadTemplate","compileTemplate","html","rawTemplate","Renderer","data","templateFunc","View","bindAll","_behaviors","Behaviors","onShowCalled","getTemplate","serializeModel","toJSON","mixinTemplateHelpers","templateHelpers","uiBindings","configureTriggers","triggers","triggerEvents","_buildViewTrigger","delegateEvents","events","_delegateDOMEvents","collection","behavior","eventsArg","isUndefined","combinedEvents","behaviorEvents","behaviorTriggers","undelegateEvents","_ensureViewIsIntact","unbindUIElements","invoke","bindUIElements","_bindUIElements","_uiBindings","_unbindUIElements","triggerDef","hasOptions","preventDefault","stopPropagation","e","setElement","ret","b","ItemView","serializeData","partial","items","serializeCollection","_renderTemplate","attachElContent","CollectionView","childViewEventPrefix","initOptions","sort","_initialEvents","_initChildViewStorage","initRenderBuffer","elBuffer","createDocumentFragment","_bufferedChildren","startBuffering","isBuffering","endBuffering","_triggerBeforeShowBufferedChildren","attachBuffer","_triggerShowBufferedChildren","_triggerMethodOnChild","childView","_onCollectionAdd","_onCollectionRemove","_sortViews","child","destroyEmptyView","ChildView","getChildView","indexOf","addChild","children","removeChildView","checkEmpty","_renderChildren","resortView","orderChanged","item","_index","destroyChildren","isEmpty","showEmptyView","showCollection","EmptyView","getEmptyView","_showingEmptyView","addEmptyView","emptyViewOptions","buildChildView","proxyChildEvents","renderChildView","childViewOptions","_updateIndices","_addChildView","increment","laterView","ChildViewClass","collectionView","buffer","append","_insertBefore","_insertAfter","findPosition","before","childViews","map","identity","rootEvent","childEvents","splice","CompositeView","isRendered","resetChildViewContainer","compositeView","$container","getChildViewContainer","containerView","$childViewContainer","container","childViewContainer","charAt","substr","LayoutView","_firstRender","_initializeRegions","_reInitializeRegions","regionManager","_buildRegions","getRegion","that","_initRegionManager","regionOptions","getRegionManager","Behavior","proxyViewProperties","behaviors","parseBehaviors","wrap","BehaviorTriggersBuilder","_view","_viewUI","_triggers","triggerBuilder","buildBehaviorTriggers","_behaviorsEvents","viewUI","_events","behaviorUI","whitespace","join","eventKey","behaviorsLookup","getBehaviorClass","behaviorClass","chain","BehaviorClass","nestedBehaviors","flatten","_buildTriggerHandlersForBehavior","triggersHash","_setHandlerForBehavior","triggerKey","triggerName","AppRouter","Router","appRoutes","controller","_getController","processAppRoutes","_processOnRoute","appRoute","route","_addAppRoute","routeName","routeArgs","routePath","invert","onRoute","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,WAAaL,EAAQD,EAAMI,EAAUC,SAE/C,IAAuB,mBAAZE,SAAyB,CACzC,GAAIH,GAAWI,QAAQ,YACnBH,EAAIG,QAAQ,aAChBC,QAAOF,QAAUN,EAAQD,EAAMI,EAAUC,OAEzCL,GAAKM,WAAaL,EAAQD,EAAMA,EAAKI,SAAUJ,EAAKK,IAGtDK,KAAM,SAASV,EAAMI,EAAUC,GAC/B,cAWA,SAAUD,EAAUC,GAElB,GAAIM,GAA6BP,EAASQ,kBA8H1C,OAxHAR,GAASQ,mBAAqB,SAASR,EAAUC,GAG/C,GAAIQ,GAAY,SAASC,GACvBJ,KAAKK,UACLL,KAAKM,iBACLN,KAAKO,kBACLP,KAAKQ,gBACLb,EAAEc,KAAKL,EAAOJ,KAAKU,IAAKV,MAI1BL,GAAEgB,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,K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AAWuc,IAAUA,EAAI9d,oBAAqBhB,GAAWwd,OAI3Dzd,EAAE6D,SAASkb,GACNA,EAAIlf,OAGN,KAPEkf,GAUXI,oBAAqB,SAASP,EAAcxe,EAAQ6d,GAClD7d,EAAO6d,gBAAkB7d,EAAO6d,iBAAmBA,EAE9C7d,EAAO6d,kBAAqB7d,EAAOif,8BAIxCjf,EAAOif,6BAA8B,EAErCT,EAAa1B,eAAe,SAAS/Z,GAC/B/C,EAAO6d,iBACT7d,EAAOgd,MAAMja,SAOdlD"} \ No newline at end of file +{"version":3,"file":"lib/backbone.marionette.min.js","sources":["?"],"names":["root","factory","define","amd","Backbone","_","Marionette","Mn","exports","require","module","this","previousChildViewContainer","ChildViewContainer","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","each","add","extend","prototype","view","customIndex","viewCid","cid","model","findByModel","findByModelCid","modelCid","findByCid","findByCustom","index","findByIndex","values","remove","any","key","call","method","apply","tail","arguments","args","isFunction","length","size","methods","concat","toArray","VERSION","noConflict","previousWreqr","Wreqr","Handlers","options","_wreqrHandlers","initialize","Model","Events","setHandlers","handlers","handler","name","context","isObject","callback","setHandler","config","trigger","hasHandler","getHandler","Array","slice","removeHandler","removeAllHandlers","CommandStorage","_commands","getCommands","commandName","commands","command","instances","addCommand","push","clearCommands","Commands","storageType","constructor","_initializeStorage","on","_executeCommands","execute","storage","StorageType","RequestResponse","request","EventAggregator","EA","Channel","channelName","vent","reqres","reset","off","stopListening","connectEvents","hash","_connect","connectCommands","connectRequests","type","fn","eventName","bind","radio","Radio","_channels","_proxyMethods","channel","Error","_getChannel","system","messageSystems","proxyMethod","messageSystem","previousMarionette","Deferred","$","isNodeAttached","el","contains","document","documentElement","getOption","target","optionName","undefined","proxyGetOption","normalizeMethods","reduce","normalizedHash","normalizeUIString","uiString","ui","replace","r","normalizeUIKeys","memo","val","normalizedKey","normalizeUIValues","isString","actAsCollection","object","listProperty","list","result","deprecate","message","test","prev","next","url","_cache","_warn","console","warn","log","_triggerMethod","getEventName","match","prefix","toUpperCase","splitter","event","noEventArg","methodName","rest","triggerMethod","triggerMethodOn","fnc","MonitorDOMRefresh","handleShow","_isShown","triggerDOMRefresh","handleRender","_isRendered","show","render","bindFromStrings","entity","evt","methodNames","split","listenTo","bindToFunction","unbindFromStrings","unbindToFunction","iterateEvents","bindings","functionCallback","stringCallback","bindEntityEvents","unbindEntityEvents","proxyBindEntityEvents","proxyUnbindEntityEvents","errorProps","urlRoot","error","pick","captureStackTrace","toString","Callbacks","_deferred","_callbacks","contextOverride","promise","cb","ctx","then","run","resolve","callbacks","Controller","destroy","Object","Region","$el","getEl","_ensureElement","_ensureViewIsIntact","showOptions","isDifferentView","currentView","preventDestroy","forceShow","isChangingView","_shouldDestroyView","_shouldShowView","_parent","empty","once","attachedRegion","displayedViews","triggerBeforeAttach","triggerAttach","_displayedViews","_triggerAttach","attachHtml","union","selector","isDestroyed","html","appendChild","_destroyView","attachView","hasView","buildRegion","regionConfig","DefaultRegionClass","_buildRegionFromSelector","regionClass","_buildRegionFromObject","_buildRegionFromRegionClass","RegionClass","omit","region","parentEl","find","RegionManager","_regions","addRegions","regionDefinitions","defaults","regions","definition","addRegion","_store","get","getRegions","clone","removeRegion","_remove","removeRegions","emptyRegions","invoke","_setLength","TemplateCache","templateId","templateCaches","cachedTemplate","load","clear","i","compiledTemplate","template","loadTemplate","compileTemplate","rawTemplate","Renderer","data","templateFunc","View","bindAll","_behaviors","Behaviors","onShowCalled","getTemplate","serializeModel","toJSON","mixinTemplateHelpers","templateHelpers","uiBindings","configureTriggers","triggers","events","value","_buildViewTrigger","delegateEvents","_delegateDOMEvents","collection","behavior","eventsArg","isUndefined","combinedEvents","behaviorEvents","behaviorTriggers","undelegateEvents","unbindUIElements","bindUIElements","_bindUIElements","_uiBindings","keys","_unbindUIElements","triggerDef","hasOptions","preventDefault","stopPropagation","e","setElement","ret","behaviors","_getImmediateChildren","_getNestedViews","children","ItemView","serializeData","items","serializeCollection","_renderTemplate","attachElContent","CollectionView","childViewEventPrefix","initOptions","sort","_initialEvents","_initChildViewStorage","initRenderBuffer","elBuffer","createDocumentFragment","_bufferedChildren","startBuffering","isBuffering","endBuffering","_triggerBeforeShowBufferedChildren","attachBuffer","_triggerShowBufferedChildren","partial","_triggerMethodOnChild","childView","_onCollectionAdd","_onCollectionRemove","_sortViews","child","destroyEmptyView","ChildView","getChildView","indexOf","addChild","removeChildView","checkEmpty","_renderChildren","resortView","orderChanged","item","_index","_emptyViewIndex","destroyChildren","isEmpty","showEmptyView","showCollection","EmptyView","getEmptyView","_showingEmptyView","addEmptyView","emptyViewOptions","buildChildView","proxyChildEvents","renderChildView","childViewOptions","_updateIndices","_addChildView","increment","laterView","ChildViewClass","collectionView","buffer","append","_insertBefore","_insertAfter","findPosition","before","childViews","map","identity","rootEvent","childEvents","splice","CompositeView","isRendered","resetChildViewContainer","compositeView","$container","getChildViewContainer","containerView","$childViewContainer","container","childViewContainer","charAt","substr","LayoutView","_firstRender","_initializeRegions","_reInitializeRegions","regionManager","_buildRegions","getRegion","_initRegionManager","regionOptions","getRegionManager","chain","pluck","compact","Behavior","proxyViewProperties","parseBehaviors","wrap","BehaviorTriggersBuilder","_view","_viewUI","_triggers","triggerBuilder","buildBehaviorTriggers","_behaviorsEvents","viewUI","b","_events","behaviorUI","whitespace","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,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backbone.marionette.min.js b/lib/backbone.marionette.min.js index cf8ef0c9cb..910b1ddbaa 100644 --- a/lib/backbone.marionette.min.js +++ b/lib/backbone.marionette.min.js @@ -1,6 +1,6 @@ // MarionetteJS (Backbone.Marionette) // ---------------------------------- -// v2.2.2 +// v2.3.0-pre // // Copyright (c)2014 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license @@ -18,6 +18,6 @@ -!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(c,d){return a.Marionette=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=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"];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.4",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=b.Marionette={};e.VERSION="2.2.2",e.noConflict=function(){return a.Marionette=d,this},b.Marionette=e,e.Deferred=b.$.Deferred;var f=Array.prototype.slice;e.extend=b.Model.extend,e.getOption=function(a,b){if(a&&b){var c;return c=a.options&&void 0!==a.options[b]?a.options[b]:a[b]}},e.proxyGetOption=function(a){return e.getOption(this,a)},e.normalizeMethods=function(a){var b={};return c.each(a,function(a,d){c.isFunction(a)||(a=this[a]),a&&(b[d]=a)},this),b},e.normalizeUIString=function(a,b){return a.replace(/@ui\.[a-zA-Z_$0-9]*/g,function(a){return b[a.slice(4)]})},e.normalizeUIKeys=function(a,b){return"undefined"!=typeof a?(a=c.clone(a),c.each(c.keys(a),function(c){var d=e.normalizeUIString(c,b);d!==c&&(a[d]=a[c],delete a[c])}),a):void 0},e.normalizeUIValues=function(a,b){return"undefined"!=typeof a?(c.each(a,function(d,f){c.isString(d)&&(a[f]=e.normalizeUIString(d,b))}),a):void 0},e.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)}})},e.triggerMethod=function(a){function b(a,b,c){return c.toUpperCase()}var d,e=/(^|:)(\w)/gi,f="on"+a.replace(e,b),g=this[f];return c.isFunction(g)&&(d=g.apply(this,c.tail(arguments))),c.isFunction(this.trigger)&&this.trigger.apply(this,arguments),d},e.triggerMethodOn=function(a,b){var d,f=c.tail(arguments,2);return d=c.isFunction(a.triggerMethod)?a.triggerMethod:e.triggerMethod,d.apply(a,[b].concat(f))},e.MonitorDOMRefresh=function(a){function d(a){a._isShown=!0,f(a)}function e(a){a._isRendered=!0,f(a)}function f(a){a._isShown&&a._isRendered&&g(a)&&c.isFunction(a.triggerMethod)&&a.triggerMethod("dom:refresh")}function g(c){return b.$.contains(a,c.el)}return function(a){a.listenTo(a,"show",function(){d(a)}),a.listenTo(a,"render",function(){e(a)})}}(document.documentElement),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.isFunction(e)&&!c.isObject(e))throw new a.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});c.isFunction(e)&&(e=e.call(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)}}(e);var g=["description","fileName","lineNumber","name","message","number"];return e.Error=e.extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+e.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,g),c.pick(b,g)),this.captureStackTrace(),b.url&&(this.url=this.urlRoot+b.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,e.Error)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}}),e.Error.extend=e.extend,e.Callbacks=function(){this._deferred=e.Deferred(),this._callbacks=[]},c.extend(e.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=e.Deferred(),this._callbacks=[],c.each(a,function(a){this.add(a.cb,a.ctx)},this)}}),e.Controller=function(a){this.options=a||{},c.isFunction(this.initialize)&&this.initialize(this.options)},e.Controller.extend=e.extend,c.extend(e.Controller.prototype,b.Events,{destroy:function(){var a=f.call(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(a)),this.triggerMethod.apply(this,["destroy"].concat(a)),this.stopListening(),this.off(),this},triggerMethod:e.triggerMethod,getOption:e.proxyGetOption}),e.Object=function(a){this.options=c.extend({},c.result(this,"options"),a),this.initialize.apply(this,arguments)},e.Object.extend=e.extend,c.extend(e.Object.prototype,{initialize:function(){},destroy:function(){this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening()},triggerMethod:e.triggerMethod,getOption:e.proxyGetOption,bindEntityEvents:e.proxyBindEntityEvents,unbindEntityEvents:e.proxyUnbindEntityEvents}),c.extend(e.Object.prototype,b.Events),e.Region=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 e.Error({name:"NoElError",message:'An "el" must be specified for a region.'});if(this.$el=this.getEl(this.el),this.initialize){var c=f.apply(arguments);this.initialize.apply(this,c)}},c.extend(e.Region,{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 e.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,d){var e=a.regionClass||d,f=c.omit(a,"selector","regionClass");a.selector&&!f.el&&(f.el=a.selector);var g=new e(f);return a.parentEl&&(g.getEl=function(d){if(c.isObject(d))return b.$(d);var e=a.parentEl;return c.isFunction(e)&&(e=e()),e.find(d)}),g},_buildRegionFromRegionClass:function(a){return new a}}),c.extend(e.Region.prototype,b.Events,{show:function(a,b){this._ensureElement();var c=b||{},d=a!==this.currentView,f=!!c.preventDestroy,g=!!c.forceShow,h=!!this.currentView,i=d&&!f,j=d||g;return h&&this.triggerMethod("before:swapOut",this.currentView),i&&this.empty(),j?(a.once("destroy",this.empty,this),a.render(),h&&this.triggerMethod("before:swap",a),this.triggerMethod("before:show",a),e.triggerMethodOn(a,"before:show"),this.attachHtml(a),h&&this.triggerMethod("swapOut",this.currentView),this.currentView=a,h&&this.triggerMethod("swap",a),this.triggerMethod("show",a),e.triggerMethodOn(a,"show"),this):this},_ensureElement:function(){if(c.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||0===this.$el.length)throw new e.Error('An "el" '+this.$el.selector+" must exist in DOM")},getEl:function(a){return b.$(a)},attachHtml:function(a){this.el.innerHTML="",this.el.appendChild(a.el)},empty:function(){var a=this.currentView;if(a)return a.off("destroy",this.empty,this),this.triggerMethod("before:empty",a),this._destroyView(),this.triggerMethod("empty",a),delete this.currentView,this},_destroyView:function(){var a=this.currentView;a.destroy&&!a.isDestroyed?a.destroy():a.remove&&a.remove()},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},getOption:e.proxyGetOption,triggerMethod:e.triggerMethod}),e.Region.extend=e.extend,e.RegionManager=function(a){var b=a.Controller.extend({constructor:function(b){this._regions={},a.Controller.call(this,b)},addRegions:function(a,b){c.isFunction(a)&&(a=a.apply(this,arguments));var d={};return c.each(a,function(a,e){c.isString(a)&&(a={selector:a}),a.selector&&(a=c.defaults({},a,b));var f=this.addRegion(e,a);d[e]=f},this),d},addRegion:function(b,c){var d;return d=c instanceof a.Region?c:a.Region.buildRegion(c,a.Region),this.triggerMethod("before:add:region",b,d),this._store(b,d),this.triggerMethod("add:region",b,d),d},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.each(a,function(a){a.empty()},this),a},destroy:function(){return this.removeRegions(),a.Controller.prototype.destroy.apply(this,arguments)},_store:function(a,b){this._regions[a]=b,this._setLength()},_remove:function(a,b){this.triggerMethod("before:remove:region",a,b),b.empty(),b.stopListening(),delete this._regions[a],this._setLength(),this.triggerMethod("remove:region",a,b)},_setLength:function(){this.length=c.size(this._regions)}});return a.actAsCollection(b.prototype,"_regions"),b}(e),e.TemplateCache=function(a){this.templateId=a},c.extend(e.TemplateCache,{templateCaches:{},get:function(a){var b=this.templateCaches[a];return b||(b=new e.TemplateCache(a),this.templateCaches[a]=b),b.load()},clear:function(){var a,b=f.call(arguments),c=b.length;if(c>0)for(a=0;c>a;a++)delete this.templateCaches[b[a]];else this.templateCaches={}}}),c.extend(e.TemplateCache.prototype,{load:function(){if(this.compiledTemplate)return this.compiledTemplate;var a=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(a),this.compiledTemplate},loadTemplate:function(a){var c=b.$(a).html();if(!c||0===c.length)throw new e.Error({name:"NoTemplateError",message:'Could not find template: "'+a+'"'});return c},compileTemplate:function(a){return c.template(a)}}),e.Renderer={render:function(a,b){if(!a)throw new e.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var c;return(c="function"==typeof a?a:e.TemplateCache.get(a))(b)}},e.View=b.View.extend({constructor:function(a){c.bindAll(this,"render"),this.options=c.extend({},c.result(this,"options"),c.isFunction(a)?a.call(this):a),this._behaviors=e.Behaviors(this),b.View.apply(this,arguments),e.MonitorDOMRefresh(this),this.listenTo(this,"show",this.onShowCalled)},getTemplate:function(){return this.getOption("template")},serializeModel:function(a){return a.toJSON.apply(a,f.call(arguments,1))},mixinTemplateHelpers:function(a){a=a||{};var b=this.getOption("templateHelpers");return c.isFunction(b)&&(b=b.call(this)),c.extend(a,b)},normalizeUIKeys:function(a){var b=c.result(this,"ui"),d=c.result(this,"_uiBindings");return e.normalizeUIKeys(a,d||b)},normalizeUIValues:function(a){var b=c.result(this,"ui"),d=c.result(this,"_uiBindings");return e.normalizeUIValues(a,d||b)},configureTriggers:function(){if(this.triggers){var a={},b=this.normalizeUIKeys(c.result(this,"triggers"));return c.each(b,function(b,c){a[c]=this._buildViewTrigger(b)},this),a}},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=a||this.events;c.isFunction(d)&&(d=d.call(this)),d=this.normalizeUIKeys(d),c.isUndefined(a)&&(this.events=d);var e={},f=c.result(this,"behaviorEvents")||{},g=this.configureTriggers(),h=c.result(this,"behaviorTriggers")||{};c.extend(e,f,d,g,h),b.View.prototype.delegateEvents.call(this,e)},undelegateEvents:function(){var a=f.call(arguments);return b.View.prototype.undelegateEvents.apply(this,a),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},onShowCalled:function(){},_ensureViewIsIntact:function(){if(this.isDestroyed)throw new e.Error({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(!this.isDestroyed){var a=f.call(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(a)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(a)),this.unbindUIElements(),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(c.keys(a),function(b){var c=a[b];this.ui[b]=this.$(c)},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=arguments,b=e.triggerMethod,d=b.apply(this,a);return c.each(this._behaviors,function(c){b.apply(c,a)}),d},normalizeMethods:e.normalizeMethods,getOption:e.proxyGetOption,bindEntityEvents:e.proxyBindEntityEvents,unbindEntityEvents:e.proxyUnbindEntityEvents}),e.ItemView=e.View.extend({constructor:function(){e.View.apply(this,arguments)},serializeData:function(){var a={};return this.model?a=c.partial(this.serializeModel,this.model).apply(this,arguments):this.collection&&(a={items:c.partial(this.serializeCollection,this.collection).apply(this,arguments)}),a},serializeCollection:function(a){return a.toJSON.apply(a,f.call(arguments,1))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderTemplate(),this.bindUIElements(),this.triggerMethod("render",this),this},_renderTemplate:function(){var a=this.getTemplate();if(a!==!1){if(!a)throw new e.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var b=this.serializeData();b=this.mixinTemplateHelpers(b);var c=e.Renderer.render(a,b,this);return this.attachElContent(c),this}},attachElContent:function(a){return this.$el.html(a),this},destroy:function(){return this.isDestroyed?void 0:e.View.prototype.destroy.apply(this,arguments)}}),e.CollectionView=e.View.extend({childViewEventPrefix:"childview",constructor:function(a){var b=a||{};this.sort=c.isUndefined(b.sort)?!0:b.sort,this.once("render",this._initialEvents),this._initChildViewStorage(),e.View.apply(this,arguments),this.initRenderBuffer()},initRenderBuffer:function(){this.elBuffer=document.createDocumentFragment(),this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){this.isBuffering=!1,this._triggerBeforeShowBufferedChildren(),this.attachBuffer(this,this.elBuffer),this._triggerShowBufferedChildren(),this.initRenderBuffer()},_triggerBeforeShowBufferedChildren:function(){this._isShown&&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){e.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.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(a){this.destroyEmptyView();var b=this.getChildView(a),c=this.collection.indexOf(a);this.addChild(a,b,c)},_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.triggerMethod("render",this),this},resortView:function(){this.render()},_sortViews:function(){var a=this.collection.find(function(a,b){var c=this.children.findByModel(a);return!c||c._index!==b},this);a&&this.resortView()},_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren(),this.isEmpty(this.collection)?this.showEmptyView():(this.triggerMethod("before:render:collection",this),this.startBuffering(),this.showCollection(),this.endBuffering(),this.triggerMethod("render:collection",this))},showCollection:function(){var a;this.collection.each(function(b,c){a=this.getChildView(b),this.addChild(b,a,c)},this)},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));var f=this.buildChildView(a,b,d);this.proxyChildEvents(f),this._isShown&&e.triggerMethodOn(f,"before:show"),this.children.add(f),this.renderChildView(f,-1),this._isShown&&e.triggerMethodOn(f,"show")},getChildView:function(){var a=this.getOption("childView");if(!a)throw new e.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return a},addChild:function(a,b,d){var e=this.getOption("childViewOptions");c.isFunction(e)&&(e=e.call(this,a,d));var f=this.buildChildView(a,b,e);return this._updateIndices(f,!0,d),this._addChildView(f,d),f},_updateIndices:function(a,b,c){this.sort&&(b?(a._index=c,this.children.each(function(b){b._index>=a._index&&b._index++})):this.children.each(function(b){b._index>=a._index&&b._index--}))},_addChildView:function(a,b){this.proxyChildEvents(a),this.triggerMethod("before:add:child",a),this.children.add(a),this.renderChildView(a,b),this._isShown&&!this.isBuffering&&e.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(),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,b){a.$el.append(b)},attachHtml:function(a,b,c){a.isBuffering?(a.elBuffer.appendChild(b.el),a._bufferedChildren.push(b)):a._insertBefore(b,c)||a._insertAfter(b)},_insertBefore:function(a,b){var c,d=this.sort&&b1?d.trigger.apply(d,g?f:[e].concat(c.rest(f,0))):d.trigger(e)),h}}(),e.triggerMethod=function(){return e._triggerMethod(this,arguments)},e.triggerMethodOn=function(a){var b=c.isFunction(a.triggerMethod)?a.triggerMethod:e.triggerMethod;return b.apply(a,c.rest(arguments))},e.MonitorDOMRefresh=function(a){function b(){a._isShown=!0,f()}function d(){a._isRendered=!0,f()}function f(){a._isShown&&a._isRendered&&e.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.isFunction(e)&&!c.isObject(e))throw new a.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});c.isFunction(e)&&(e=e.call(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)}}(e);var g=["description","fileName","lineNumber","name","message","number"];return e.Error=e.extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+e.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,g),c.pick(b,g)),this.captureStackTrace(),b.url&&(this.url=this.urlRoot+b.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,e.Error)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}}),e.Error.extend=e.extend,e.Callbacks=function(){this._deferred=e.Deferred(),this._callbacks=[]},c.extend(e.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=e.Deferred(),this._callbacks=[],c.each(a,function(a){this.add(a.cb,a.ctx)},this)}}),e.Controller=function(a){this.options=a||{},c.isFunction(this.initialize)&&this.initialize(this.options)},e.Controller.extend=e.extend,c.extend(e.Controller.prototype,b.Events,{destroy:function(){return e._triggerMethod(this,"before:destroy",arguments),e._triggerMethod(this,"destroy",arguments),this.stopListening(),this.off(),this},triggerMethod:e.triggerMethod,getOption:e.proxyGetOption}),e.Object=function(a){this.options=c.extend({},c.result(this,"options"),a),this.initialize.apply(this,arguments)},e.Object.extend=e.extend,c.extend(e.Object.prototype,b.Events,{initialize:function(){},destroy:function(){this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening()},triggerMethod:e.triggerMethod,getOption:e.proxyGetOption,bindEntityEvents:e.proxyBindEntityEvents,unbindEntityEvents:e.proxyUnbindEntityEvents}),e.Region=e.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 e.Error({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),e.Object.call(this,a)},show:function(a,b){if(this._ensureElement()){this._ensureViewIsIntact(a);var c=b||{},d=a!==this.currentView,f=!!c.preventDestroy,g=!!c.forceShow,h=!!this.currentView,i=d&&!f,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),e.triggerMethodOn(a,"before:show",a,this,b),h&&this.triggerMethod("swapOut",this.currentView,this,b);var k=e.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),e.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){e.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 e.Error('An "el" '+this.$el.selector+" must exist in DOM")}return!0},_ensureViewIsIntact:function(a){if(!a)throw new e.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 e.Error({name:"ViewDestroyedError",message:'View (cid: "'+a.cid+'") has already been destroyed and cannot be used.'})},getEl:function(a){return b.$(a)},attachHtml:function(a){this.$el.html(""),this.el.appendChild(a.el)},empty:function(){var a=this.currentView;if(a)return a.off("destroy",this.empty,this),this.triggerMethod("before:empty",a),this._destroyView(),this.triggerMethod("empty",a),delete this.currentView,this},_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 e.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,d){var e=a.regionClass||d,f=c.omit(a,"selector","regionClass");a.selector&&!f.el&&(f.el=a.selector);var g=new e(f);return a.parentEl&&(g.getEl=function(d){if(c.isObject(d))return b.$(d);var e=a.parentEl;return c.isFunction(e)&&(e=e()),e.find(d)}),g},_buildRegionFromRegionClass:function(a){return new a}}),e.RegionManager=e.Controller.extend({constructor:function(a){this._regions={},e.Controller.call(this,a),this.addRegions(this.getOption("regions"))},addRegions:function(a,b){c.isFunction(a)&&(a=a.apply(this,arguments));var d={};return c.each(a,function(a,e){c.isString(a)&&(a={selector:a}),a.selector&&(a=c.defaults({},a,b));var f=this.addRegion(e,a);d[e]=f},this),d},addRegion:function(a,b){var c;return c=b instanceof e.Region?b:e.Region.buildRegion(b,e.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(),e.Controller.prototype.destroy.apply(this,arguments)},_store:function(a,b){this._regions[a]=b,this._setLength()},_remove:function(a,b){this.triggerMethod("before:remove:region",a,b),b.empty(),b.stopListening(),delete b._parent,delete this._regions[a],this._setLength(),this.triggerMethod("remove:region",a,b)},_setLength:function(){this.length=c.size(this._regions)}}),e.actAsCollection(e.RegionManager.prototype,"_regions"),e.TemplateCache=function(a){this.templateId=a},c.extend(e.TemplateCache,{templateCaches:{},get:function(a){var b=this.templateCaches[a];return b||(b=new e.TemplateCache(a),this.templateCaches[a]=b),b.load()},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(e.TemplateCache.prototype,{load:function(){if(this.compiledTemplate)return this.compiledTemplate;var a=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(a),this.compiledTemplate},loadTemplate:function(a){var c=b.$(a).html();if(!c||0===c.length)throw new e.Error({name:"NoTemplateError",message:'Could not find template: "'+a+'"'});return c},compileTemplate:function(a){return c.template(a)}}),e.Renderer={render:function(a,b){if(!a)throw new e.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var c;return(c="function"==typeof a?a:e.TemplateCache.get(a))(b)}},e.View=b.View.extend({constructor:function(a){c.bindAll(this,"render"),a=c.isFunction(a)?a.call(this):a,this.options=c.extend({},c.result(this,"options"),a),this._behaviors=e.Behaviors(this),b.View.apply(this,arguments),e.MonitorDOMRefresh(this),this.on("show",this.onShowCalled)},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 c.isFunction(b)&&(b=b.call(this)),c.extend(a,b)},normalizeUIKeys:function(a){var b=c.result(this,"_uiBindings");return e.normalizeUIKeys(a,b||c.result(this,"ui"))},normalizeUIValues:function(a){var b=c.result(this,"ui"),d=c.result(this,"_uiBindings");return e.normalizeUIValues(a,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=a||this.events;c.isFunction(d)&&(d=d.call(this)),d=this.normalizeUIKeys(d),c.isUndefined(a)&&(this.events=d);var e={},f=c.result(this,"behaviorEvents")||{},g=this.configureTriggers(),h=c.result(this,"behaviorTriggers")||{};c.extend(e,f,d,g,h),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},onShowCalled:function(){},_ensureViewIsIntact:function(){if(this.isDestroyed)throw new e.Error({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(!this.isDestroyed){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.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(c.keys(a),function(b){var c=a[b];this.ui[b]=this.$(c)},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(){for(var a=e._triggerMethod,b=a(this,arguments),c=this._behaviors,d=0,f=c&&c.length;f>d;d++)a(c[d],arguments);return 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},normalizeMethods:e.normalizeMethods,getOption:e.proxyGetOption,bindEntityEvents:e.proxyBindEntityEvents,unbindEntityEvents:e.proxyUnbindEntityEvents}),e.ItemView=e.View.extend({constructor:function(){e.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.bindUIElements(),this.triggerMethod("render",this),this},_renderTemplate:function(){var a=this.getTemplate();if(a!==!1){if(!a)throw new e.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var b=this.serializeData();b=this.mixinTemplateHelpers(b);var c=e.Renderer.render(a,b,this);return this.attachElContent(c),this}},attachElContent:function(a){return this.$el.html(a),this}}),e.CollectionView=e.View.extend({childViewEventPrefix:"childview",constructor:function(a){var b=a||{};c.isUndefined(this.sort)&&(this.sort=c.isUndefined(b.sort)?!0:b.sort),this.once("render",this._initialEvents),this._initChildViewStorage(),e.View.apply(this,arguments),this.initRenderBuffer()},initRenderBuffer:function(){this.elBuffer=document.createDocumentFragment(),this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){this.isBuffering=!1,this._triggerBeforeShowBufferedChildren(),this.attachBuffer(this,this.elBuffer),this._triggerShowBufferedChildren(),this.initRenderBuffer()},_triggerBeforeShowBufferedChildren:function(){this._isShown&&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){e.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.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(a){this.destroyEmptyView();var b=this.getChildView(a),c=this.collection.indexOf(a);this.addChild(a,b,c)},_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.triggerMethod("render",this),this},resortView:function(){this.render()},_sortViews:function(){var a=this.collection.find(function(a,b){var c=this.children.findByModel(a);return!c||c._index!==b},this);a&&this.resortView()},_emptyViewIndex:-1,_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren(),this.isEmpty(this.collection)?this.showEmptyView():(this.triggerMethod("before:render:collection",this),this.startBuffering(),this.showCollection(),this.endBuffering(),this.triggerMethod("render:collection",this))},showCollection:function(){var a;this.collection.each(function(b,c){a=this.getChildView(b),this.addChild(b,a,c)},this)},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 f=this.buildChildView(a,b,d);f._parent=this,this.proxyChildEvents(f),this._isShown&&e.triggerMethodOn(f,"before:show"),this.children.add(f),this.renderChildView(f,this._emptyViewIndex),this._isShown&&e.triggerMethodOn(f,"show")},getChildView:function(){var a=this.getOption("childView");if(!a)throw new e.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return a},addChild:function(a,b,d){var e=this.getOption("childViewOptions");c.isFunction(e)&&(e=e.call(this,a,d));var f=this.buildChildView(a,b,e);return this._updateIndices(f,!0,d),this._addChildView(f,d),f._parent=this,f},_updateIndices:function(a,b,c){this.sort&&(b?(a._index=c,this.children.each(function(b){b._index>=a._index&&b._index++})):this.children.each(function(b){b._index>=a._index&&b._index--}))},_addChildView:function(a,b){this.proxyChildEvents(a),this.triggerMethod("before:add:child",a),this.children.add(a),this.renderChildView(a,b),this._isShown&&!this.isBuffering&&e.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,b){a.$el.append(b)},attachHtml:function(a,b,c){a.isBuffering?(a.elBuffer.appendChild(b.el),a._bufferedChildren.push(b)):a._insertBefore(b,c)||a._insertAfter(b)},_insertBefore:function(a,b){var c,d=this.sort&&b functions or function names // and return a mapping of events => functions Marionette.normalizeMethods = function(hash) { - var normalizedHash = {}; - _.each(hash, function(method, name) { + return _.reduce(hash, function(normalizedHash, method, name) { if (!_.isFunction(method)) { method = this[method]; } - if (!method) { - return; + if (method) { + normalizedHash[name] = method; } - normalizedHash[name] = method; - }, this); - return normalizedHash; + return normalizedHash; + }, {}, this); }; // utility method for parsing @ui. syntax strings @@ -109,37 +111,22 @@ // swaps the @ui with the associated selector. // Returns a new, non-mutated, parsed events hash. Marionette.normalizeUIKeys = function(hash, ui) { - if (typeof(hash) === 'undefined') { - return; - } - - hash = _.clone(hash); - - _.each(_.keys(hash), function(key) { + return _.reduce(hash, function(memo, val, key) { var normalizedKey = Marionette.normalizeUIString(key, ui); - if (normalizedKey !== key) { - hash[normalizedKey] = hash[key]; - delete hash[key]; - } - }); - - return hash; + memo[normalizedKey] = val; + return memo; + }, {}); }; // allows for the use of the @ui. syntax within // a given value for regions // swaps the @ui with the associated selector Marionette.normalizeUIValues = function(hash, ui) { - if (typeof(hash) === 'undefined') { - return; - } - _.each(hash, function(val, key) { if (_.isString(val)) { hash[key] = Marionette.normalizeUIString(val, ui); } }); - return hash; }; @@ -162,15 +149,31 @@ }); }; - // Trigger an event and/or a corresponding method name. Examples: - // - // `this.triggerMethod("foo")` will trigger the "foo" event and - // call the "onFoo" method. - // - // `this.triggerMethod("foo:bar")` will trigger the "foo:bar" event and - // call the "onFooBar" method. - Marionette.triggerMethod = function(event) { + var deprecate = Marionette.deprecate = function(message, test) { + if (_.isObject(message)) { + message = ( + message.prev + ' is going to be removed in the future. ' + + 'Please use ' + message.next + ' instead.' + + (message.url ? ' See: ' + message.url : '') + ); + } + + if ((test === undefined || !test) && !deprecate._cache[message]) { + deprecate._warn('Deprecation warning: ' + message); + deprecate._cache[message] = true; + } + }; + + deprecate._warn = typeof console !== 'undefined' && (console.warn || console.log) || function() {}; + deprecate._cache = {}; + + /* jshint maxstatements: 14, maxcomplexity: 7 */ + // Trigger Method + // -------------- + + + Marionette._triggerMethod = (function() { // split the event name on the ":" var splitter = /(^|:)(\w)/gi; @@ -180,93 +183,101 @@ return eventName.toUpperCase(); } - // get the method name from the event name - var methodName = 'on' + event.replace(splitter, getEventName); - var method = this[methodName]; - var result; + return function(context, event, args) { + var noEventArg = arguments.length < 3; + if (noEventArg) { + args = event; + event = args[0]; + } - // call the onMethodName if it exists - if (_.isFunction(method)) { - // pass all arguments, except the event name - result = method.apply(this, _.tail(arguments)); - } + // get the method name from the event name + var methodName = 'on' + event.replace(splitter, getEventName); + var method = context[methodName]; + var result; - // trigger the event, if a trigger method exists - if (_.isFunction(this.trigger)) { - this.trigger.apply(this, arguments); - } + // call the onMethodName if it exists + if (_.isFunction(method)) { + // pass all args, except the event name + result = method.apply(context, noEventArg ? _.rest(args) : args); + } + + // trigger the event, if a trigger method exists + if (_.isFunction(context.trigger)) { + if (noEventArg + args.length > 1) { + context.trigger.apply(context, noEventArg ? args : [event].concat(_.rest(args, 0))); + } else { + context.trigger(event); + } + } - return result; + return result; + }; + })(); + + // Trigger an event and/or a corresponding method name. Examples: + // + // `this.triggerMethod("foo")` will trigger the "foo" event and + // call the "onFoo" method. + // + // `this.triggerMethod("foo:bar")` will trigger the "foo:bar" event and + // call the "onFooBar" method. + Marionette.triggerMethod = function(event) { + return Marionette._triggerMethod(this, arguments); }; // triggerMethodOn invokes triggerMethod on a specific context // // e.g. `Marionette.triggerMethodOn(view, 'show')` // will trigger a "show" event or invoke onShow the view. - Marionette.triggerMethodOn = function(context, event) { - var args = _.tail(arguments, 2); - var fnc; + Marionette.triggerMethodOn = function(context) { + var fnc = _.isFunction(context.triggerMethod) ? + context.triggerMethod : + Marionette.triggerMethod; - if (_.isFunction(context.triggerMethod)) { - fnc = context.triggerMethod; - } else { - fnc = Marionette.triggerMethod; - } - - return fnc.apply(context, [event].concat(args)); + return fnc.apply(context, _.rest(arguments)); }; - // DOMRefresh - // ---------- - // + // DOM Refresh + // ----------- + // Monitor a view's state, and after it has been rendered and shown // in the DOM, trigger a "dom:refresh" event every time it is // re-rendered. - Marionette.MonitorDOMRefresh = (function(documentElement) { + Marionette.MonitorDOMRefresh = function(view) { + // track when the view has been shown in the DOM, // using a Marionette.Region (or by other means of triggering "show") - function handleShow(view) { + function handleShow() { view._isShown = true; - triggerDOMRefresh(view); + triggerDOMRefresh(); } // track when the view has been rendered - function handleRender(view) { + function handleRender() { view._isRendered = true; - triggerDOMRefresh(view); + triggerDOMRefresh(); } // Trigger the "dom:refresh" event and corresponding "onDomRefresh" method - function triggerDOMRefresh(view) { - if (view._isShown && view._isRendered && isInDOM(view)) { + function triggerDOMRefresh() { + if (view._isShown && view._isRendered && Marionette.isNodeAttached(view.el)) { if (_.isFunction(view.triggerMethod)) { view.triggerMethod('dom:refresh'); } } } - function isInDOM(view) { - return Backbone.$.contains(documentElement, view.el); - } - - // Export public API - return function(view) { - view.listenTo(view, 'show', function() { - handleShow(view); - }); - - view.listenTo(view, 'render', function() { - handleRender(view); - }); - }; - })(document.documentElement); + view.on({ + show: handleShow, + render: handleRender + }); + }; - /* jshint maxparams: 5 */ - // Marionette.bindEntityEvents & unbindEntityEvents - // --------------------------- + // Bind Entity Events & Unbind Entity Events + // ----------------------------------------- // // These methods are used to bind/unbind a backbone "entity" (collection/model) // to methods on a target object. @@ -375,6 +386,9 @@ })(Marionette); + // Error + // ----- + var errorProps = ['description', 'fileName', 'lineNumber', 'name', 'message', 'number']; Marionette.Error = Marionette.extend.call(Error, { @@ -461,9 +475,9 @@ } }); - // Marionette Controller - // --------------------- - // + // Controller + // ---------- + // A multi-purpose object to use as a controller for // modules and routers, and as a mediator for workflow // and coordination of other objects, views, and more. @@ -483,9 +497,8 @@ // Ensure it can trigger events with Backbone.Events _.extend(Marionette.Controller.prototype, Backbone.Events, { destroy: function() { - var args = slice.call(arguments); - this.triggerMethod.apply(this, ['before:destroy'].concat(args)); - this.triggerMethod.apply(this, ['destroy'].concat(args)); + Marionette._triggerMethod(this, 'before:destroy', arguments); + Marionette._triggerMethod(this, 'destroy', arguments); this.stopListening(); this.off(); @@ -501,9 +514,9 @@ }); - // Marionette Object - // --------------------- - // + // Object + // ------ + // A Base Class that other Classes should descend from. // Object borrows many conventions and utilities from Backbone. Marionette.Object = function(options) { @@ -517,7 +530,8 @@ // Object Methods // -------------- - _.extend(Marionette.Object.prototype, { + // Ensure it can trigger events with Backbone.Events + _.extend(Marionette.Object.prototype, Backbone.Events, { //this is a noop method intended to be overridden by classes that extend from this base initialize: function() {}, @@ -535,138 +549,43 @@ // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption, - // Proxy `unbindEntityEvents` to enable binding view's events from another entity. + // Proxy `bindEntityEvents` to enable binding view's events from another entity. bindEntityEvents: Marionette.proxyBindEntityEvents, // Proxy `unbindEntityEvents` to enable unbinding view's events from another entity. unbindEntityEvents: Marionette.proxyUnbindEntityEvents }); - // Ensure it can trigger events with Backbone.Events - _.extend(Marionette.Object.prototype, Backbone.Events); - - /* jshint maxcomplexity: 10, maxstatements: 29 */ + /* jshint maxcomplexity: 16, maxstatements: 45, maxlen: 120 */ // Region // ------ - // + // Manage the visual regions of your composite application. See // http://lostechies.com/derickbailey/2011/12/12/composite-js-apps-regions-and-region-managers/ - Marionette.Region = function(options) { - this.options = options || {}; - this.el = this.getOption('el'); - - // Handle when this.el is passed in as a $ wrapped element. - this.el = this.el instanceof Backbone.$ ? this.el[0] : this.el; - - if (!this.el) { - throw new Marionette.Error({ - name: 'NoElError', - message: 'An "el" must be specified for a region.' - }); - } - - this.$el = this.getEl(this.el); - - if (this.initialize) { - var args = slice.apply(arguments); - this.initialize.apply(this, args); - } - }; - - - // Region Class methods - // ------------------- - - _.extend(Marionette.Region, { - - // Build an instance of a region by passing in a configuration object - // and a default region class to use if none is specified in the config. - // - // The config object should either be a string as a jQuery DOM selector, - // a Region class directly, or an object literal that specifies both - // a selector and regionClass: - // - // ```js - // { - // selector: "#foo", - // regionClass: MyCustomRegion - // } - // ``` - // - buildRegion: function(regionConfig, DefaultRegionClass) { - if (_.isString(regionConfig)) { - return this._buildRegionFromSelector(regionConfig, DefaultRegionClass); - } - - if (regionConfig.selector || regionConfig.el || regionConfig.regionClass) { - return this._buildRegionFromObject(regionConfig, DefaultRegionClass); - } - - if (_.isFunction(regionConfig)) { - return this._buildRegionFromRegionClass(regionConfig); - } + Marionette.Region = Marionette.Object.extend({ + constructor: function (options) { - throw new Marionette.Error({ - message: 'Improper region configuration type.', - url: 'marionette.region.html#region-configuration-types' - }); - }, - - // Build the region from a string selector like '#foo-region' - _buildRegionFromSelector: function(selector, DefaultRegionClass) { - return new DefaultRegionClass({ el: selector }); - }, - - // Build the region from a configuration object - // ```js - // { selector: '#foo', regionClass: FooRegion } - // ``` - _buildRegionFromObject: function(regionConfig, DefaultRegionClass) { - var RegionClass = regionConfig.regionClass || DefaultRegionClass; - var options = _.omit(regionConfig, 'selector', 'regionClass'); - - if (regionConfig.selector && !options.el) { - options.el = regionConfig.selector; - } + // set options temporarily so that we can get `el`. + // options will be overriden by Object.constructor + this.options = options || {}; + this.el = this.getOption('el'); - var region = new RegionClass(options); + // Handle when this.el is passed in as a $ wrapped element. + this.el = this.el instanceof Backbone.$ ? this.el[0] : this.el; - // override the `getEl` function if we have a parentEl - // this must be overridden to ensure the selector is found - // on the first use of the region. if we try to assign the - // region's `el` to `parentEl.find(selector)` in the object - // literal to build the region, the element will not be - // guaranteed to be in the DOM already, and will cause problems - if (regionConfig.parentEl) { - region.getEl = function(el) { - if (_.isObject(el)) { - return Backbone.$(el); - } - var parentEl = regionConfig.parentEl; - if (_.isFunction(parentEl)) { - parentEl = parentEl(); - } - return parentEl.find(el); - }; + if (!this.el) { + throw new Marionette.Error({ + name: 'NoElError', + message: 'An "el" must be specified for a region.' + }); } - return region; + this.$el = this.getEl(this.el); + Marionette.Object.call(this, options); }, - // Build the region directly from a given `RegionClass` - _buildRegionFromRegionClass: function(RegionClass) { - return new RegionClass(); - } - - }); - - // Region Instance Methods - // ----------------------- - - _.extend(Marionette.Region.prototype, Backbone.Events, { - // Displays a backbone view instance inside of the region. // Handles calling the `render` method for you. Reads content // directly from the `el` attribute. Also calls an optional @@ -676,9 +595,12 @@ // the old view being destroyed on show. // The `forceShow` option can be used to force a view to be // re-rendered if it's already shown in the region. - show: function(view, options){ - this._ensureElement(); + if (!this._ensureElement()) { + return; + } + + this._ensureViewIsIntact(view); var showOptions = options || {}; var isDifferentView = view !== this.currentView; @@ -698,11 +620,21 @@ var _shouldShowView = isDifferentView || forceShow; if (isChangingView) { - this.triggerMethod('before:swapOut', this.currentView); + this.triggerMethod('before:swapOut', this.currentView, this, options); + } + + if (this.currentView) { + delete this.currentView._parent; } if (_shouldDestroyView) { this.empty(); + + // A `destroy` event is attached to the clean up manually removed views. + // We need to detach this event when a new view is going to be shown as it + // is no longer relevant. + } else if (isChangingView && _shouldShowView) { + this.currentView.off('destroy', this.empty, this); } if (_shouldShowView) { @@ -715,27 +647,49 @@ view.once('destroy', this.empty, this); view.render(); + view._parent = this; + if (isChangingView) { - this.triggerMethod('before:swap', view); + this.triggerMethod('before:swap', view, this, options); } - this.triggerMethod('before:show', view); - Marionette.triggerMethodOn(view, 'before:show'); - - this.attachHtml(view); + this.triggerMethod('before:show', view, this, options); + Marionette.triggerMethodOn(view, 'before:show', view, this, options); if (isChangingView) { - this.triggerMethod('swapOut', this.currentView); + this.triggerMethod('swapOut', this.currentView, this, options); } + // An array of views that we're about to display + var attachedRegion = Marionette.isNodeAttached(this.el); + + // The views that we're about to attach to the document + // It's important that we prevent _getNestedViews from being executed unnecessarily + // as it's a potentially-slow method + var displayedViews = []; + + var triggerBeforeAttach = showOptions.triggerBeforeAttach || this.triggerBeforeAttach; + var triggerAttach = showOptions.triggerAttach || this.triggerAttach; + + if (attachedRegion && triggerBeforeAttach) { + displayedViews = this._displayedViews(view); + this._triggerAttach(displayedViews, 'before:'); + } + + this.attachHtml(view); this.currentView = view; + if (attachedRegion && triggerAttach) { + displayedViews = this._displayedViews(view); + this._triggerAttach(displayedViews); + } + if (isChangingView) { - this.triggerMethod('swap', view); + this.triggerMethod('swap', view, this, options); } - this.triggerMethod('show', view); - Marionette.triggerMethodOn(view, 'show'); + this.triggerMethod('show', view, this, options); + Marionette.triggerMethodOn(view, 'show', view, this, options); return this; } @@ -743,6 +697,20 @@ return this; }, + triggerBeforeAttach: true, + triggerAttach: true, + + _triggerAttach: function(views, prefix) { + var eventName = (prefix || '') + 'attach'; + _.each(views, function(view) { + Marionette.triggerMethodOn(view, eventName, view, this); + }, this); + }, + + _displayedViews: function(view) { + return _.union([view], _.result(view, '_getNestedViews') || []); + }, + _ensureElement: function(){ if (!_.isObject(this.el)) { this.$el = this.getEl(this.el); @@ -750,7 +718,28 @@ } if (!this.$el || this.$el.length === 0) { - throw new Marionette.Error('An "el" ' + this.$el.selector + ' must exist in DOM'); + if (this.getOption('allowMissingEl')) { + return false; + } else { + throw new Marionette.Error('An "el" ' + this.$el.selector + ' must exist in DOM'); + } + } + return true; + }, + + _ensureViewIsIntact: function(view) { + if (!view) { + throw new Marionette.Error({ + name: 'ViewNotValid', + message: 'The view passed is undefined and therefore invalid. You must pass a view instance to show.' + }); + } + + if (view.isDestroyed) { + throw new Marionette.Error({ + name: 'ViewDestroyedError', + message: 'View (cid: "' + view.cid + '") has already been destroyed and cannot be used.' + }); } }, @@ -764,7 +753,14 @@ // appended to the `$el` that the region is managing attachHtml: function(view) { // empty the node and append new view - this.el.innerHTML=''; + // We can not use `.innerHTML` due to the fact that IE + // will not let us clear the html of tables and selects. + // We also do not want to use the more declarative `empty` method + // that jquery exposes since `.empty` loops over all of the children DOM + // nodes and unsets the listeners on each node. While this seems like + // a desirable thing, it comes at quite a high perf cost. For that reason + // we are simply clearing the html contents of the node. + this.$el.html(''); this.el.appendChild(view.el); }, @@ -796,6 +792,10 @@ view.destroy(); } else if (view.remove) { view.remove(); + + // appending isDestroyed to raw Backbone View allows regions + // to throw a ViewDestroyedError for this view + view.isDestroyed = true; } }, @@ -828,152 +828,224 @@ delete this.$el; return this; - }, + } - // Proxy `getOption` to enable getting options from this or this.options by name. - getOption: Marionette.proxyGetOption, + }, - // import the `triggerMethod` to trigger events with corresponding - // methods if the method exists - triggerMethod: Marionette.triggerMethod - }); + // Static Methods + { + + // Build an instance of a region by passing in a configuration object + // and a default region class to use if none is specified in the config. + // + // The config object should either be a string as a jQuery DOM selector, + // a Region class directly, or an object literal that specifies a selector, + // a custom regionClass, and any options to be supplied to the region: + // + // ```js + // { + // selector: "#foo", + // regionClass: MyCustomRegion, + // allowMissingEl: false + // } + // ``` + // + buildRegion: function(regionConfig, DefaultRegionClass) { + if (_.isString(regionConfig)) { + return this._buildRegionFromSelector(regionConfig, DefaultRegionClass); + } - // Copy the `extend` function used by Backbone's classes - Marionette.Region.extend = Marionette.extend; + if (regionConfig.selector || regionConfig.el || regionConfig.regionClass) { + return this._buildRegionFromObject(regionConfig, DefaultRegionClass); + } - // Marionette.RegionManager - // ------------------------ - // - // Manage one or more related `Marionette.Region` objects. - Marionette.RegionManager = (function(Marionette) { + if (_.isFunction(regionConfig)) { + return this._buildRegionFromRegionClass(regionConfig); + } - var RegionManager = Marionette.Controller.extend({ - constructor: function(options) { - this._regions = {}; - Marionette.Controller.call(this, options); - }, + throw new Marionette.Error({ + message: 'Improper region configuration type.', + url: 'marionette.region.html#region-configuration-types' + }); + }, - // Add multiple regions using an object literal or a - // function that returns an object literal, where - // each key becomes the region name, and each value is - // the region definition. - addRegions: function(regionDefinitions, defaults) { - if (_.isFunction(regionDefinitions)) { - regionDefinitions = regionDefinitions.apply(this, arguments); - } + // Build the region from a string selector like '#foo-region' + _buildRegionFromSelector: function(selector, DefaultRegionClass) { + return new DefaultRegionClass({ el: selector }); + }, + + // Build the region from a configuration object + // ```js + // { selector: '#foo', regionClass: FooRegion, allowMissingEl: false } + // ``` + _buildRegionFromObject: function(regionConfig, DefaultRegionClass) { + var RegionClass = regionConfig.regionClass || DefaultRegionClass; + var options = _.omit(regionConfig, 'selector', 'regionClass'); - var regions = {}; + if (regionConfig.selector && !options.el) { + options.el = regionConfig.selector; + } - _.each(regionDefinitions, function(definition, name) { - if (_.isString(definition)) { - definition = {selector: definition}; - } + var region = new RegionClass(options); - if (definition.selector) { - definition = _.defaults({}, definition, defaults); + // override the `getEl` function if we have a parentEl + // this must be overridden to ensure the selector is found + // on the first use of the region. if we try to assign the + // region's `el` to `parentEl.find(selector)` in the object + // literal to build the region, the element will not be + // guaranteed to be in the DOM already, and will cause problems + if (regionConfig.parentEl) { + region.getEl = function(el) { + if (_.isObject(el)) { + return Backbone.$(el); + } + var parentEl = regionConfig.parentEl; + if (_.isFunction(parentEl)) { + parentEl = parentEl(); } + return parentEl.find(el); + }; + } - var region = this.addRegion(name, definition); - regions[name] = region; - }, this); + return region; + }, - return regions; - }, + // Build the region directly from a given `RegionClass` + _buildRegionFromRegionClass: function(RegionClass) { + return new RegionClass(); + } + }); - // Add an individual region to the region manager, - // and return the region instance - addRegion: function(name, definition) { - var region; + // Region Manager + // -------------- - if (definition instanceof Marionette.Region) { - region = definition; - } else { - region = Marionette.Region.buildRegion(definition, Marionette.Region); + // Manage one or more related `Marionette.Region` objects. + Marionette.RegionManager = Marionette.Controller.extend({ + constructor: function(options) { + this._regions = {}; + + Marionette.Controller.call(this, options); + + this.addRegions(this.getOption('regions')); + }, + + // Add multiple regions using an object literal or a + // function that returns an object literal, where + // each key becomes the region name, and each value is + // the region definition. + addRegions: function(regionDefinitions, defaults) { + if (_.isFunction(regionDefinitions)) { + regionDefinitions = regionDefinitions.apply(this, arguments); + } + + var regions = {}; + + _.each(regionDefinitions, function(definition, name) { + if (_.isString(definition)) { + definition = {selector: definition}; } - this.triggerMethod('before:add:region', name, region); + if (definition.selector) { + definition = _.defaults({}, definition, defaults); + } - this._store(name, region); + var region = this.addRegion(name, definition); + regions[name] = region; + }, this); - this.triggerMethod('add:region', name, region); - return region; - }, + return regions; + }, - // Get a region by name - get: function(name) { - return this._regions[name]; - }, + // Add an individual region to the region manager, + // and return the region instance + addRegion: function(name, definition) { + var region; - // Gets all the regions contained within - // the `regionManager` instance. - getRegions: function(){ - return _.clone(this._regions); - }, + if (definition instanceof Marionette.Region) { + region = definition; + } else { + region = Marionette.Region.buildRegion(definition, Marionette.Region); + } - // Remove a region by name - removeRegion: function(name) { - var region = this._regions[name]; - this._remove(name, region); + this.triggerMethod('before:add:region', name, region); - return region; - }, + region._parent = this; + this._store(name, region); - // Empty all regions in the region manager, and - // remove them - removeRegions: function() { - var regions = this.getRegions(); - _.each(this._regions, function(region, name) { - this._remove(name, region); - }, this); + this.triggerMethod('add:region', name, region); + return region; + }, - return regions; - }, + // Get a region by name + get: function(name) { + return this._regions[name]; + }, - // Empty all regions in the region manager, but - // leave them attached - emptyRegions: function() { - var regions = this.getRegions(); - _.each(regions, function(region) { - region.empty(); - }, this); + // Gets all the regions contained within + // the `regionManager` instance. + getRegions: function(){ + return _.clone(this._regions); + }, - return regions; - }, + // Remove a region by name + removeRegion: function(name) { + var region = this._regions[name]; + this._remove(name, region); - // Destroy all regions and shut down the region - // manager entirely - destroy: function() { - this.removeRegions(); - return Marionette.Controller.prototype.destroy.apply(this, arguments); - }, + return region; + }, - // internal method to store regions - _store: function(name, region) { - this._regions[name] = region; - this._setLength(); - }, + // Empty all regions in the region manager, and + // remove them + removeRegions: function() { + var regions = this.getRegions(); + _.each(this._regions, function(region, name) { + this._remove(name, region); + }, this); - // internal method to remove a region - _remove: function(name, region) { - this.triggerMethod('before:remove:region', name, region); - region.empty(); - region.stopListening(); - delete this._regions[name]; - this._setLength(); - this.triggerMethod('remove:region', name, region); - }, + return regions; + }, - // set the number of regions current held - _setLength: function() { - this.length = _.size(this._regions); - } + // Empty all regions in the region manager, but + // leave them attached + emptyRegions: function() { + var regions = this.getRegions(); + _.invoke(regions, 'empty'); + return regions; + }, - }); + // Destroy all regions and shut down the region + // manager entirely + destroy: function() { + this.removeRegions(); + return Marionette.Controller.prototype.destroy.apply(this, arguments); + }, - Marionette.actAsCollection(RegionManager.prototype, '_regions'); + // internal method to store regions + _store: function(name, region) { + this._regions[name] = region; + this._setLength(); + }, - return RegionManager; - })(Marionette); + // internal method to remove a region + _remove: function(name, region) { + this.triggerMethod('before:remove:region', name, region); + region.empty(); + region.stopListening(); + + delete region._parent; + delete this._regions[name]; + this._setLength(); + this.triggerMethod('remove:region', name, region); + }, + + // set the number of regions current held + _setLength: function() { + this.length = _.size(this._regions); + } + }); + + Marionette.actAsCollection(Marionette.RegionManager.prototype, '_regions'); // Template Cache @@ -1014,7 +1086,7 @@ // `clear("#t1", "#t2", "...")` clear: function() { var i; - var args = slice.call(arguments); + var args = _.toArray(arguments); var length = args.length; if (length > 0) { @@ -1105,8 +1177,8 @@ /* jshint maxlen: 114, nonew: false */ - // Marionette.View - // --------------- + // View + // ---- // The core view class that other Marionette views extend from. Marionette.View = Backbone.View.extend({ @@ -1114,18 +1186,20 @@ constructor: function(options) { _.bindAll(this, 'render'); + options = _.isFunction(options) ? options.call(this) : options; + // this exposes view options to the view initializer // this is a backfill since backbone removed the assignment // of this.options // at some point however this may be removed - this.options = _.extend({}, _.result(this, 'options'), _.isFunction(options) ? options.call(this) : options); + this.options = _.extend({}, _.result(this, 'options'), options); this._behaviors = Marionette.Behaviors(this); Backbone.View.apply(this, arguments); Marionette.MonitorDOMRefresh(this); - this.listenTo(this, 'show', this.onShowCalled); + this.on('show', this.onShowCalled); }, // Get the template for this view @@ -1139,7 +1213,7 @@ // Serialize a model by returning its attributes. Clones // the attributes to allow modification. serializeModel: function(model){ - return model.toJSON.apply(model, slice.call(arguments, 1)); + return model.toJSON.apply(model, _.rest(arguments)); }, // Mix in template helper methods. Looks for a @@ -1159,9 +1233,8 @@ // normalize the keys of passed hash with the views `ui` selectors. // `{"@ui.foo": "bar"}` normalizeUIKeys: function(hash) { - var ui = _.result(this, 'ui'); var uiBindings = _.result(this, '_uiBindings'); - return Marionette.normalizeUIKeys(hash, uiBindings || ui); + return Marionette.normalizeUIKeys(hash, uiBindings || _.result(this, 'ui')); }, // normalize the values of passed hash with the views `ui` selectors. @@ -1177,18 +1250,15 @@ configureTriggers: function() { if (!this.triggers) { return; } - var triggerEvents = {}; - // Allow `triggers` to be configured as a function var triggers = this.normalizeUIKeys(_.result(this, 'triggers')); // Configure the triggers, prevent default // action and stop propagation of DOM events - _.each(triggers, function(value, key) { - triggerEvents[key] = this._buildViewTrigger(value); - }, this); - - return triggerEvents; + return _.reduce(triggers, function(events, value, key) { + events[key] = this._buildViewTrigger(value); + return events; + }, {}, this); }, // Overriding Backbone.View's delegateEvents to handle @@ -1231,8 +1301,7 @@ // Overriding Backbone.View's undelegateEvents to handle unbinding // the `triggers`, `modelEvents`, and `collectionEvents` config undelegateEvents: function() { - var args = slice.call(arguments); - Backbone.View.prototype.undelegateEvents.apply(this, args); + Backbone.View.prototype.undelegateEvents.apply(this, arguments); this.unbindEntityEvents(this.model, this.getOption('modelEvents')); this.unbindEntityEvents(this.collection, this.getOption('collectionEvents')); @@ -1265,7 +1334,7 @@ destroy: function() { if (this.isDestroyed) { return; } - var args = slice.call(arguments); + var args = _.toArray(arguments); this.triggerMethod.apply(this, ['before:destroy'].concat(args)); @@ -1385,17 +1454,35 @@ // import the `triggerMethod` to trigger events with corresponding // methods if the method exists triggerMethod: function() { - var args = arguments; - var triggerMethod = Marionette.triggerMethod; - - var ret = triggerMethod.apply(this, args); - _.each(this._behaviors, function(b) { - triggerMethod.apply(b, args); - }); + var triggerMethod = Marionette._triggerMethod; + var ret = triggerMethod(this, arguments); + var behaviors = this._behaviors; + // Use good ol' for as this is a very hot function + for (var i = 0, length = behaviors && behaviors.length; i < length; i++) { + triggerMethod(behaviors[i], arguments); + } return ret; }, + // This method returns any views that are immediate + // children of this view + _getImmediateChildren: function() { + return []; + }, + + // Returns an array of every nested view within this view + _getNestedViews: function() { + var children = this._getImmediateChildren(); + + if (!children.length) { return children; } + + return _.reduce(children, function(memo, view) { + if (!view._getNestedViews) { return memo; } + return memo.concat(view._getNestedViews()); + }, children); + }, + // Imports the "normalizeMethods" to transform hashes of // events=>function references/names to a hash of events=>function references normalizeMethods: Marionette.normalizeMethods, @@ -1403,7 +1490,7 @@ // Proxy `getOption` to enable getting options from this or this.options by name. getOption: Marionette.proxyGetOption, - // Proxy `unbindEntityEvents` to enable binding view's events from another entity. + // Proxy `bindEntityEvents` to enable binding view's events from another entity. bindEntityEvents: Marionette.proxyBindEntityEvents, // Proxy `unbindEntityEvents` to enable unbinding view's events from another entity. @@ -1432,21 +1519,27 @@ // You can override the `serializeData` method in your own view definition, // to provide custom serialization for your view's data. serializeData: function(){ - var data = {}; - - if (this.model) { - data = _.partial(this.serializeModel, this.model).apply(this, arguments); + if (!this.model && !this.collection) { + return {}; } - else if (this.collection) { - data = { items: _.partial(this.serializeCollection, this.collection).apply(this, arguments) }; + + var args = [this.model || this.collection]; + if (arguments.length) { + args.push.apply(args, arguments); } - return data; + if (this.model) { + return this.serializeModel.apply(this, args); + } else { + return { + items: this.serializeCollection.apply(this, args) + }; + } }, // Serialize a collection by serializing each of its models. serializeCollection: function(collection){ - return collection.toJSON.apply(collection, slice.call(arguments, 1)); + return collection.toJSON.apply(collection, _.rest(arguments)); }, // Render the view, defaulting to underscore.js templates. @@ -1513,14 +1606,6 @@ this.$el.html(html); return this; - }, - - // Override the default destroy event to add a few - // more events that are triggered. - destroy: function() { - if (this.isDestroyed) { return; } - - return Marionette.View.prototype.destroy.apply(this, arguments); } }); @@ -1543,7 +1628,9 @@ // This will fallback onto appending childView's to the end. constructor: function(options){ var initOptions = options || {}; - this.sort = _.isUndefined(initOptions.sort) ? true : initOptions.sort; + if (_.isUndefined(this.sort)){ + this.sort = _.isUndefined(initOptions.sort) ? true : initOptions.sort; + } this.once('render', this._initialEvents); this._initChildViewStorage(); @@ -1661,6 +1748,9 @@ } }, + // Internal reference to what index a `emptyView` is. + _emptyViewIndex: -1, + // Internal method. Separated so that CompositeView can have // more control over events being triggered, around the rendering // process @@ -1733,12 +1823,14 @@ this.getOption('childViewOptions'); if (_.isFunction(emptyViewOptions)){ - emptyViewOptions = emptyViewOptions.call(this); + emptyViewOptions = emptyViewOptions.call(this, child, this._emptyViewIndex); } // build the empty view var view = this.buildChildView(child, EmptyView, emptyViewOptions); + view._parent = this; + // Proxy emptyView events this.proxyChildEvents(view); @@ -1753,7 +1845,7 @@ this.children.add(view); // Render it and show it - this.renderChildView(view, -1); + this.renderChildView(view, this._emptyViewIndex); // call the 'show' method if the collection view // has already been shown @@ -1798,6 +1890,8 @@ this._addChildView(view, index); + view._parent = this; + return view; }, @@ -1875,6 +1969,7 @@ if (view.destroy) { view.destroy(); } else if (view.remove) { view.remove(); } + delete view._parent; this.stopListening(view); this.children.remove(view); this.triggerMethod('remove:child', view); @@ -1983,7 +2078,7 @@ // Forward all child view events through the parent, // prepending "childview:" to the event name this.listenTo(view, 'all', function() { - var args = slice.call(arguments); + var args = _.toArray(arguments); var rootEvent = args[0]; var childEvents = this.normalizeMethods(_.result(this, 'childEvents')); @@ -1997,6 +2092,10 @@ this.triggerMethod.apply(this, args); }, this); + }, + + _getImmediateChildren: function() { + return _.values(this.children._views); } }); @@ -2045,17 +2144,10 @@ getChildView: function(child) { var childView = this.getOption('childView') || this.constructor; - if (!childView) { - throw new Marionette.Error({ - name: 'NoChildViewError', - message: 'A "childView" must be specified' - }); - } - return childView; }, - // Serialize the collection for the view. + // Serialize the model for the view. // You can override the `serializeData` method in your own view // definition, to provide custom serialization for your view's data. serializeData: function() { @@ -2068,9 +2160,7 @@ return data; }, - // Renders the model once, and the collection once. Calling - // this again will tell the model's view to re-render itself - // but the collection will not re-render. + // Renders the model and the collection. render: function() { this._ensureViewIsIntact(); this.isRendered = true; @@ -2139,13 +2229,13 @@ // Overidden from CollectionView to ensure view is appended to // childViewContainer _insertAfter: function (childView) { - var $container = this.getChildViewContainer(this); + var $container = this.getChildViewContainer(this, childView); $container.append(childView.el); }, // Internal method to ensure an `$childViewContainer` exists, for the // `attachHtml` method to use. - getChildViewContainer: function(containerView) { + getChildViewContainer: function(containerView, childView) { if ('$childViewContainer' in containerView) { return containerView.$childViewContainer; } @@ -2185,8 +2275,8 @@ } }); - // LayoutView - // ---------- + // Layout View + // ----------- // Used for managing application layoutViews, nested layoutViews and // multiple regions within an application or sub-application. @@ -2269,11 +2359,9 @@ // internal method to build regions _buildRegions: function(regions) { - var that = this; - var defaults = { regionClass: this.getOption('regionClass'), - parentEl: function() { return that.$el; } + parentEl: _.partial(_.result, this, '$el') }; return this.regionManager.addRegions(regions, defaults); @@ -2311,7 +2399,6 @@ // Internal method to re-initialize all of the regions by updating the `el` that // they point to _reInitializeRegions: function() { - this.regionManager.emptyRegions(); this.regionManager.each(function(region) { region.reset(); }); @@ -2328,6 +2415,7 @@ // and all regions in it _initRegionManager: function() { this.regionManager = this.getRegionManager(); + this.regionManager._parent = this; this.listenTo(this.regionManager, 'before:add:region', function(name) { this.triggerMethod('before:add:region', name); @@ -2346,20 +2434,27 @@ delete this[name]; this.triggerMethod('remove:region', name, region); }); + }, + + _getImmediateChildren: function() { + return _.chain(this.regionManager.getRegions()) + .pluck('currentView') + .compact() + .value(); } }); // Behavior - // ----------- + // -------- // A Behavior is an isolated set of DOM / // user interactions that can be mixed into any View. // Behaviors allow you to blackbox View specific interactions // into portable logical chunks, keeping your views simple and your code DRY. - Marionette.Behavior = (function(_, Backbone) { - function Behavior(options, view) { + Marionette.Behavior = Marionette.Object.extend({ + constructor: function(options, view) { // Setup reference to the view. // this comes in handle when a behavior // wants to directly talk up the chain @@ -2368,57 +2463,31 @@ this.defaults = _.result(this, 'defaults') || {}; this.options = _.extend({}, this.defaults, options); - // proxy behavior $ method to the view - // this is useful for doing jquery DOM lookups - // scoped to behaviors view. - this.$ = function() { - return this.view.$.apply(this.view, arguments); - }; - - // Call the initialize method passing - // the arguments from the instance constructor - this.initialize.apply(this, arguments); - } - - _.extend(Behavior.prototype, Backbone.Events, { - initialize: function() {}, - - // stopListening to behavior `onListen` events. - destroy: function() { - this.stopListening(); - }, - - proxyViewProperties: function (view) { - this.$el = view.$el; - this.el = view.el; - }, - - // import the `triggerMethod` to trigger events with corresponding - // methods if the method exists - triggerMethod: Marionette.triggerMethod, - - // Proxy `getOption` to enable getting options from this or this.options by name. - getOption: Marionette.proxyGetOption, - - // Proxy `unbindEntityEvents` to enable binding view's events from another entity. - bindEntityEvents: Marionette.proxyBindEntityEvents, + Marionette.Object.apply(this, arguments); + }, - // Proxy `unbindEntityEvents` to enable unbinding view's events from another entity. - unbindEntityEvents: Marionette.proxyUnbindEntityEvents - }); + // proxy behavior $ method to the view + // this is useful for doing jquery DOM lookups + // scoped to behaviors view. + $: function() { + return this.view.$.apply(this.view, arguments); + }, - // Borrow Backbones extend implementation - // this allows us to setup a proper - // inheritance pattern that follows suit - // with the rest of Marionette views. - Behavior.extend = Marionette.extend; + // Stops the behavior from listening to events. + // Overrides Object#destroy to prevent additional events from being triggered. + destroy: function() { + this.stopListening(); + }, - return Behavior; - })(_, Backbone); + proxyViewProperties: function (view) { + this.$el = view.$el; + this.el = view.el; + } + }); /* jshint maxlen: 143 */ - // Marionette.Behaviors - // -------- + // Behaviors + // --------- // Behaviors is a utility class that takes care of // gluing your behavior instances to their given View. @@ -2591,8 +2660,8 @@ })(Marionette, _); - // AppRouter - // --------- + // App Router + // ---------- // Reduce the boilerplate code of handling route events // and then calling a single method on another object. @@ -2612,10 +2681,10 @@ Marionette.AppRouter = Backbone.Router.extend({ constructor: function(options) { - Backbone.Router.apply(this, arguments); - this.options = options || {}; + Backbone.Router.apply(this, arguments); + var appRoutes = this.getOption('appRoutes'); var controller = this._getController(); this.processAppRoutes(controller, appRoutes); @@ -2632,11 +2701,10 @@ // process the route event and trigger the onRoute // method call, if it exists _processOnRoute: function(routeName, routeArgs) { - // find the path that matched - var routePath = _.invert(this.getOption('appRoutes'))[routeName]; - - // make sure an onRoute is there, and call it + // make sure an onRoute before trying to call it if (_.isFunction(this.onRoute)) { + // find the path that matches the current route + var routePath = _.invert(this.getOption('appRoutes'))[routeName]; this.onRoute(routeName, routePath, routeArgs); } }, @@ -2669,7 +2737,13 @@ }, // Proxy `getOption` to enable getting options from this or this.options by name. - getOption: Marionette.proxyGetOption + getOption: Marionette.proxyGetOption, + + triggerMethod: Marionette.triggerMethod, + + bindEntityEvents: Marionette.proxyBindEntityEvents, + + unbindEntityEvents: Marionette.proxyUnbindEntityEvents }); // Application @@ -2678,20 +2752,15 @@ // Contain and manage the composite application as a whole. // Stores and starts up `Region` objects, includes an // event aggregator as `app.vent` - Marionette.Application = function(options) { - this.options = options; - this._initializeRegions(options); - this._initCallbacks = new Marionette.Callbacks(); - this.submodules = {}; - _.extend(this, options); - this._initChannel(); - this.initialize.apply(this, arguments); - }; - - _.extend(Marionette.Application.prototype, Backbone.Events, { - // Initialize is an empty function by default. Override it with your own - // initialization logic. - initialize: function() {}, + Marionette.Application = Marionette.Object.extend({ + constructor: function(options) { + this._initializeRegions(options); + this._initCallbacks = new Marionette.Callbacks(); + this.submodules = {}; + _.extend(this, options); + this._initChannel(); + Marionette.Object.call(this, options); + }, // Command execution, facilitated by Backbone.Wreqr.Commands execute: function() { @@ -2757,9 +2826,7 @@ // Overwrite the module class if the user specifies one var ModuleClass = Marionette.Module.getClass(moduleDefinition); - // slice the args, and add this application object as the - // first argument of the array - var args = slice.call(arguments); + var args = _.toArray(arguments); args.unshift(this); // see the Marionette.Module object for more information @@ -2799,23 +2866,24 @@ // Internal method to set up the region manager _initRegionManager: function() { this._regionManager = this.getRegionManager(); + this._regionManager._parent = this; - this.listenTo(this._regionManager, 'before:add:region', function(name) { - this.triggerMethod('before:add:region', name); + this.listenTo(this._regionManager, 'before:add:region', function() { + Marionette._triggerMethod(this, 'before:add:region', arguments); }); this.listenTo(this._regionManager, 'add:region', function(name, region) { this[name] = region; - this.triggerMethod('add:region', name, region); + Marionette._triggerMethod(this, 'add:region', arguments); }); - this.listenTo(this._regionManager, 'before:remove:region', function(name) { - this.triggerMethod('before:remove:region', name); + this.listenTo(this._regionManager, 'before:remove:region', function() { + Marionette._triggerMethod(this, 'before:remove:region', arguments); }); - this.listenTo(this._regionManager, 'remove:region', function(name, region) { + this.listenTo(this._regionManager, 'remove:region', function(name) { delete this[name]; - this.triggerMethod('remove:region', name, region); + Marionette._triggerMethod(this, 'remove:region', arguments); }); }, @@ -2826,19 +2894,9 @@ this.vent = _.result(this, 'vent') || this.channel.vent; this.commands = _.result(this, 'commands') || this.channel.commands; this.reqres = _.result(this, 'reqres') || this.channel.reqres; - }, - - // import the `triggerMethod` to trigger events with corresponding - // methods if the method exists - triggerMethod: Marionette.triggerMethod, - - // Proxy `getOption` to enable getting options from this or this.options by name. - getOption: Marionette.proxyGetOption + } }); - // Copy the `extend` function used by Backbone's classes - Marionette.Application.extend = Marionette.extend; - /* jshint maxparams: 9 */ // Module @@ -2926,7 +2984,7 @@ // stop the sub-modules; depth-first, to make sure the // sub-modules are stopped / finalized before parents - _.each(this.submodules, function(mod) { mod.stop(); }); + _.invoke(this.submodules, 'stop'); // run the finalizers this._finalizerCallbacks.run(undefined, this); @@ -2985,8 +3043,7 @@ // get the custom args passed in after the module definition and // get rid of the module name and definition function - var customArgs = slice.call(arguments); - customArgs.splice(0, 3); + var customArgs = _.rest(arguments, 3); // Split the module names and get the number of submodules. // i.e. an example module name of `Doge.Wow.Amaze` would diff --git a/lib/core/backbone.marionette.map b/lib/core/backbone.marionette.map index eb21870cee..97260f559f 100644 --- a/lib/core/backbone.marionette.map +++ b/lib/core/backbone.marionette.map @@ -1 +1 @@ -{"version":3,"file":"lib/core/backbone.marionette.min.js","sources":["core/backbone.marionette.js"],"names":["root","factory","define","amd","Backbone","_","Marionette","exports","require","module","this","previousMarionette","VERSION","noConflict","Deferred","$","slice","Array","prototype","extend","Model","getOption","target","optionName","value","options","undefined","proxyGetOption","normalizeMethods","hash","normalizedHash","each","method","name","isFunction","normalizeUIString","uiString","ui","replace","r","normalizeUIKeys","clone","keys","key","normalizedKey","normalizeUIValues","val","isString","actAsCollection","object","listProperty","methods","list","values","result","args","concat","toArray","arguments","apply","triggerMethod","event","getEventName","match","prefix","eventName","toUpperCase","splitter","methodName","tail","trigger","triggerMethodOn","context","fnc","MonitorDOMRefresh","documentElement","handleShow","view","_isShown","triggerDOMRefresh","handleRender","_isRendered","isInDOM","contains","el","listenTo","document","bindFromStrings","entity","evt","methodNames","split","Error","bindToFunction","unbindFromStrings","stopListening","unbindToFunction","iterateEvents","bindings","functionCallback","stringCallback","isObject","message","url","call","bindEntityEvents","unbindEntityEvents","proxyBindEntityEvents","proxyUnbindEntityEvents","errorProps","urlRoot","constructor","error","pick","captureStackTrace","toString","Callbacks","_deferred","_callbacks","add","callback","contextOverride","promise","push","cb","ctx","then","run","resolve","reset","callbacks","Controller","initialize","Events","destroy","off","Object","Region","$el","getEl","buildRegion","regionConfig","DefaultRegionClass","_buildRegionFromSelector","selector","regionClass","_buildRegionFromObject","_buildRegionFromRegionClass","RegionClass","omit","region","parentEl","find","show","_ensureElement","showOptions","isDifferentView","currentView","preventDestroy","forceShow","isChangingView","_shouldDestroyView","_shouldShowView","empty","once","render","attachHtml","length","innerHTML","appendChild","_destroyView","isDestroyed","remove","attachView","hasView","RegionManager","_regions","addRegions","regionDefinitions","defaults","regions","definition","addRegion","_store","get","getRegions","removeRegion","_remove","removeRegions","emptyRegions","_setLength","size","TemplateCache","templateId","templateCaches","cachedTemplate","load","clear","i","compiledTemplate","template","loadTemplate","compileTemplate","html","rawTemplate","Renderer","data","templateFunc","View","bindAll","_behaviors","Behaviors","onShowCalled","getTemplate","serializeModel","model","toJSON","mixinTemplateHelpers","templateHelpers","uiBindings","configureTriggers","triggers","triggerEvents","_buildViewTrigger","delegateEvents","events","_delegateDOMEvents","collection","behavior","eventsArg","isUndefined","combinedEvents","behaviorEvents","behaviorTriggers","undelegateEvents","_ensureViewIsIntact","cid","unbindUIElements","invoke","bindUIElements","_bindUIElements","_uiBindings","_unbindUIElements","triggerDef","hasOptions","preventDefault","stopPropagation","e","setElement","ret","b","ItemView","serializeData","partial","items","serializeCollection","_renderTemplate","attachElContent","CollectionView","childViewEventPrefix","initOptions","sort","_initialEvents","_initChildViewStorage","initRenderBuffer","elBuffer","createDocumentFragment","_bufferedChildren","startBuffering","isBuffering","endBuffering","_triggerBeforeShowBufferedChildren","attachBuffer","_triggerShowBufferedChildren","_triggerMethodOnChild","childView","_onCollectionAdd","_onCollectionRemove","_sortViews","child","destroyEmptyView","ChildView","getChildView","index","indexOf","addChild","children","findByModel","removeChildView","checkEmpty","_renderChildren","resortView","orderChanged","item","_index","destroyChildren","isEmpty","showEmptyView","showCollection","EmptyView","getEmptyView","_showingEmptyView","addEmptyView","emptyViewOptions","buildChildView","proxyChildEvents","renderChildView","childViewOptions","_updateIndices","_addChildView","increment","laterView","ChildViewClass","collectionView","buffer","append","_insertBefore","_insertAfter","findPosition","before","ChildViewContainer","childViews","map","identity","rootEvent","childEvents","splice","CompositeView","isRendered","resetChildViewContainer","compositeView","$container","getChildViewContainer","containerView","$childViewContainer","container","childViewContainer","charAt","substr","LayoutView","_firstRender","_initializeRegions","_reInitializeRegions","regionManager","_buildRegions","getRegion","that","_initRegionManager","regionOptions","getRegionManager","Behavior","proxyViewProperties","behaviors","parseBehaviors","wrap","BehaviorTriggersBuilder","_view","_viewUI","_triggers","triggerBuilder","buildBehaviorTriggers","_behaviorsEvents","viewUI","_events","behaviorUI","whitespace","join","eventKey","handler","bind","behaviorsLookup","getBehaviorClass","behaviorClass","chain","BehaviorClass","nestedBehaviors","flatten","_buildTriggerHandlersForBehavior","triggersHash","_setHandlerForBehavior","triggerKey","triggerName","AppRouter","Router","appRoutes","controller","_getController","processAppRoutes","on","_processOnRoute","appRoute","route","_addAppRoute","routeName","routeArgs","routePath","invert","onRoute","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,WAAaL,EAAQD,EAAMI,EAAUC,SAE/C,IAAuB,mBAAZE,SAAyB,CACzC,CAAA,GAAIH,GAAWI,QAAQ,YACnBH,EAA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\ No newline at end of file +{"version":3,"file":"lib/core/backbone.marionette.min.js","sources":["core/backbone.marionette.js"],"names":["root","factory","define","amd","Backbone","_","Marionette","Mn","exports","require","module","this","previousMarionette","previousMn","VERSION","noConflict","Deferred","$","extend","Model","isNodeAttached","el","contains","document","documentElement","getOption","target","optionName","options","undefined","proxyGetOption","normalizeMethods","hash","reduce","normalizedHash","method","name","isFunction","normalizeUIString","uiString","ui","replace","r","slice","normalizeUIKeys","memo","val","key","normalizedKey","normalizeUIValues","each","isString","actAsCollection","object","listProperty","methods","list","values","result","args","concat","toArray","arguments","apply","deprecate","message","test","isObject","prev","next","url","_cache","_warn","console","warn","log","_triggerMethod","getEventName","match","prefix","eventName","toUpperCase","splitter","context","event","noEventArg","length","methodName","rest","trigger","triggerMethod","triggerMethodOn","fnc","MonitorDOMRefresh","view","handleShow","_isShown","triggerDOMRefresh","handleRender","_isRendered","on","show","render","bindFromStrings","entity","evt","methodNames","split","Error","listenTo","bindToFunction","unbindFromStrings","stopListening","unbindToFunction","iterateEvents","bindings","functionCallback","stringCallback","call","bindEntityEvents","unbindEntityEvents","proxyBindEntityEvents","proxyUnbindEntityEvents","errorProps","urlRoot","constructor","error","pick","captureStackTrace","toString","Callbacks","_deferred","_callbacks","prototype","add","callback","contextOverride","promise","push","cb","ctx","then","run","resolve","reset","callbacks","Controller","initialize","Events","destroy","off","Object","Region","$el","getEl","_ensureElement","_ensureViewIsIntact","showOptions","isDifferentView","currentView","preventDestroy","forceShow","isChangingView","_shouldDestroyView","_shouldShowView","_parent","empty","once","attachedRegion","displayedViews","triggerBeforeAttach","triggerAttach","_displayedViews","_triggerAttach","attachHtml","views","union","selector","isDestroyed","cid","html","appendChild","_destroyView","remove","attachView","hasView","buildRegion","regionConfig","DefaultRegionClass","_buildRegionFromSelector","regionClass","_buildRegionFromObject","_buildRegionFromRegionClass","RegionClass","omit","region","parentEl","find","RegionManager","_regions","addRegions","regionDefinitions","defaults","regions","definition","addRegion","_store","get","getRegions","clone","removeRegion","_remove","removeRegions","emptyRegions","invoke","_setLength","size","TemplateCache","templateId","templateCaches","cachedTemplate","load","clear","i","compiledTemplate","template","loadTemplate","compileTemplate","rawTemplate","Renderer","data","templateFunc","View","bindAll","_behaviors","Behaviors","onShowCalled","getTemplate","serializeModel","model","toJSON","mixinTemplateHelpers","templateHelpers","uiBindings","configureTriggers","triggers","events","value","_buildViewTrigger","delegateEvents","_delegateDOMEvents","collection","behavior","eventsArg","isUndefined","combinedEvents","behaviorEvents","behaviorTriggers","undelegateEvents","unbindUIElements","bindUIElements","_bindUIElements","_uiBindings","keys","_unbindUIElements","triggerDef","hasOptions","preventDefault","stopPropagation","e","setElement","ret","behaviors","_getImmediateChildren","_getNestedViews","children","ItemView","serializeData","items","serializeCollection","_renderTemplate","attachElContent","CollectionView","childViewEventPrefix","initOptions","sort","_initialEvents","_initChildViewStorage","initRenderBuffer","elBuffer","createDocumentFragment","_bufferedChildren","startBuffering","isBuffering","endBuffering","_triggerBeforeShowBufferedChildren","attachBuffer","_triggerShowBufferedChildren","partial","_triggerMethodOnChild","childView","_onCollectionAdd","_onCollectionRemove","_sortViews","child","destroyEmptyView","ChildView","getChildView","index","indexOf","addChild","findByModel","removeChildView","checkEmpty","_renderChildren","resortView","orderChanged","item","_index","_emptyViewIndex","destroyChildren","isEmpty","showEmptyView","showCollection","EmptyView","getEmptyView","_showingEmptyView","addEmptyView","emptyViewOptions","buildChildView","proxyChildEvents","renderChildView","childViewOptions","_updateIndices","_addChildView","increment","laterView","ChildViewClass","collectionView","buffer","append","_insertBefore","_insertAfter","findPosition","before","ChildViewContainer","childViews","map","identity","rootEvent","childEvents","splice","_views","CompositeView","isRendered","resetChildViewContainer","compositeView","$container","getChildViewContainer","containerView","$childViewContainer","container","childViewContainer","charAt","substr","LayoutView","_firstRender","_initializeRegions","_reInitializeRegions","regionManager","_buildRegions","getRegion","_initRegionManager","regionOptions","getRegionManager","chain","pluck","compact","Behavior","proxyViewProperties","parseBehaviors","wrap","BehaviorTriggersBuilder","_view","_viewUI","_triggers","triggerBuilder","buildBehaviorTriggers","_behaviorsEvents","viewUI","b","_events","behaviorUI","whitespace","Array","join","eventKey","handler","bind","behaviorsLookup","getBehaviorClass","behaviorClass","BehaviorClass","nestedBehaviors","flatten","_buildTriggerHandlersForBehavior","triggersHash","_setHandlerForBehavior","triggerKey","triggerName","AppRouter","Router","appRoutes","controller","_getController","processAppRoutes","_processOnRoute","appRoute","route","_addAppRoute","routeName","routeArgs","onRoute","routePath","invert","routeNames","reverse","Application","_initCallbacks","submodules","_initChannel","execute","commands","request","reqres","addInitializer","initializer","start","_regionManager","moduleNames","moduleDefinition","ModuleClass","Module","getClass","unshift","create","optionRegions","channelName","channel","Wreqr","radio","vent","moduleName","app","_setupInitializersAndFinalizers","startWithParent","_initializerCallbacks","addFinalizer","_finalizerCallbacks","_isInitialized","mod","stop","addDefinition","customArgs","_runModuleDefinition","moduleDefinitions","parentModule","_getModule","_addModuleDefinition","def","moduleClass","fn","_getDefine","_getStartWithParent","_addStartWithParent","swp","startWithParentIsConfigured"],"mappings":"CASC,SAASA,EAAMC,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,YAErBR,EAAWS,WAAa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c,EAAarC,WAAWuB,GAAc1b,GAGjCA,GASTib,SAAU,SAASH,GACjB,GAAIC,GAAcnb,EAAWob,MAE7B,OAAKF,GAMDA,EAAiBnT,oBAAqBoT,GACjCD,EAGFA,EAAiB8B,aAAe7B,EAT9BA,GAeX2B,qBAAsB,SAASF,EAAcxc,EAAQ2c,EAAK1Z,GACxD,GAAI4Z,GAAK5c,KAAK6c,WAAWH,GACrBd,EAAkB5b,KAAK8c,oBAAoBJ,EAAK3c,EAEhD6c,IACF7c,EAAOoc,cAAcS,EAAI5Z,GAG3BhD,KAAK+c,oBAAoBR,EAAcxc,EAAQ6b,IAGjDkB,oBAAqB,SAASJ,EAAK3c,GACjC,GAAIid,EAEJ,OAAItd,GAAEgC,WAAWgb,IAASA,EAAIhV,oBAAqB/H,GAAWob,QAC5DiC,EAAMjd,EAAOmH,YAAYQ,UAAUkU,gBAC5Blc,EAAEyP,YAAY6N,IAAO,EAAOA,GAGjCtd,EAAE8D,SAASkZ,IACbM,EAAMN,EAAId,gBACHlc,EAAEyP,YAAY6N,IAAO,EAAOA,IAG9B,GAGTH,WAAY,SAASH,GACnB,OAAIhd,EAAEgC,WAAWgb,IAAUA,EAAIhV,oBAAqB/H,GAAWob,OAI3Drb,EAAE8D,SAASkZ,GACNA,EAAInd,OAGN,KAPEmd,GAUXK,oBAAqB,SAASR,EAAcxc,EAAQ6b,GAClD7b,EAAO6b,gBAAkB7b,EAAO6b,iBAAmBA,EAE9C7b,EAAO6b,kBAAqB7b,EAAOkd,8BAIxCld,EAAOkd,6BAA8B,EAErCV,EAAa/B,eAAe,SAASvZ,GAC/BlB,EAAO6b,iBACT7b,EAAO2a,MAAMzZ,SAOdtB"} \ No newline at end of file diff --git a/lib/core/backbone.marionette.min.js b/lib/core/backbone.marionette.min.js index cf1cb385d9..03847dc6e7 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=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=b(a,a.Backbone,a._)}(this,function(a,b,c){"use strict";var d=a.Marionette,e=b.Marionette={};e.VERSION="2.2.2",e.noConflict=function(){return a.Marionette=d,this},e.Deferred=b.$.Deferred;var f=Array.prototype.slice;e.extend=b.Model.extend,e.getOption=function(a,b){if(a&&b){var c;return c=a.options&&void 0!==a.options[b]?a.options[b]:a[b]}},e.proxyGetOption=function(a){return e.getOption(this,a)},e.normalizeMethods=function(a){var b={};return c.each(a,function(a,d){c.isFunction(a)||(a=this[a]),a&&(b[d]=a)},this),b},e.normalizeUIString=function(a,b){return a.replace(/@ui\.[a-zA-Z_$0-9]*/g,function(a){return b[a.slice(4)]})},e.normalizeUIKeys=function(a,b){return"undefined"!=typeof a?(a=c.clone(a),c.each(c.keys(a),function(c){var d=e.normalizeUIString(c,b);d!==c&&(a[d]=a[c],delete a[c])}),a):void 0},e.normalizeUIValues=function(a,b){return"undefined"!=typeof a?(c.each(a,function(d,f){c.isString(d)&&(a[f]=e.normalizeUIString(d,b))}),a):void 0},e.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)}})},e.triggerMethod=function(a){function b(a,b,c){return c.toUpperCase()}var d,e=/(^|:)(\w)/gi,f="on"+a.replace(e,b),g=this[f];return c.isFunction(g)&&(d=g.apply(this,c.tail(arguments))),c.isFunction(this.trigger)&&this.trigger.apply(this,arguments),d},e.triggerMethodOn=function(a,b){var d,f=c.tail(arguments,2);return d=c.isFunction(a.triggerMethod)?a.triggerMethod:e.triggerMethod,d.apply(a,[b].concat(f))},e.MonitorDOMRefresh=function(a){function d(a){a._isShown=!0,f(a)}function e(a){a._isRendered=!0,f(a)}function f(a){a._isShown&&a._isRendered&&g(a)&&c.isFunction(a.triggerMethod)&&a.triggerMethod("dom:refresh")}function g(c){return b.$.contains(a,c.el)}return function(a){a.listenTo(a,"show",function(){d(a)}),a.listenTo(a,"render",function(){e(a)})}}(document.documentElement),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.isFunction(e)&&!c.isObject(e))throw new a.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});c.isFunction(e)&&(e=e.call(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)}}(e);var g=["description","fileName","lineNumber","name","message","number"];return e.Error=e.extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+e.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,g),c.pick(b,g)),this.captureStackTrace(),b.url&&(this.url=this.urlRoot+b.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,e.Error)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}}),e.Error.extend=e.extend,e.Callbacks=function(){this._deferred=e.Deferred(),this._callbacks=[]},c.extend(e.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=e.Deferred(),this._callbacks=[],c.each(a,function(a){this.add(a.cb,a.ctx)},this)}}),e.Controller=function(a){this.options=a||{},c.isFunction(this.initialize)&&this.initialize(this.options)},e.Controller.extend=e.extend,c.extend(e.Controller.prototype,b.Events,{destroy:function(){var a=f.call(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(a)),this.triggerMethod.apply(this,["destroy"].concat(a)),this.stopListening(),this.off(),this},triggerMethod:e.triggerMethod,getOption:e.proxyGetOption}),e.Object=function(a){this.options=c.extend({},c.result(this,"options"),a),this.initialize.apply(this,arguments)},e.Object.extend=e.extend,c.extend(e.Object.prototype,{initialize:function(){},destroy:function(){this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening()},triggerMethod:e.triggerMethod,getOption:e.proxyGetOption,bindEntityEvents:e.proxyBindEntityEvents,unbindEntityEvents:e.proxyUnbindEntityEvents}),c.extend(e.Object.prototype,b.Events),e.Region=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 e.Error({name:"NoElError",message:'An "el" must be specified for a region.'});if(this.$el=this.getEl(this.el),this.initialize){var c=f.apply(arguments);this.initialize.apply(this,c)}},c.extend(e.Region,{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 e.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,d){var e=a.regionClass||d,f=c.omit(a,"selector","regionClass");a.selector&&!f.el&&(f.el=a.selector);var g=new e(f);return a.parentEl&&(g.getEl=function(d){if(c.isObject(d))return b.$(d);var e=a.parentEl;return c.isFunction(e)&&(e=e()),e.find(d)}),g},_buildRegionFromRegionClass:function(a){return new a}}),c.extend(e.Region.prototype,b.Events,{show:function(a,b){this._ensureElement();var c=b||{},d=a!==this.currentView,f=!!c.preventDestroy,g=!!c.forceShow,h=!!this.currentView,i=d&&!f,j=d||g;return h&&this.triggerMethod("before:swapOut",this.currentView),i&&this.empty(),j?(a.once("destroy",this.empty,this),a.render(),h&&this.triggerMethod("before:swap",a),this.triggerMethod("before:show",a),e.triggerMethodOn(a,"before:show"),this.attachHtml(a),h&&this.triggerMethod("swapOut",this.currentView),this.currentView=a,h&&this.triggerMethod("swap",a),this.triggerMethod("show",a),e.triggerMethodOn(a,"show"),this):this},_ensureElement:function(){if(c.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||0===this.$el.length)throw new e.Error('An "el" '+this.$el.selector+" must exist in DOM")},getEl:function(a){return b.$(a)},attachHtml:function(a){this.el.innerHTML="",this.el.appendChild(a.el)},empty:function(){var a=this.currentView;if(a)return a.off("destroy",this.empty,this),this.triggerMethod("before:empty",a),this._destroyView(),this.triggerMethod("empty",a),delete this.currentView,this},_destroyView:function(){var a=this.currentView;a.destroy&&!a.isDestroyed?a.destroy():a.remove&&a.remove()},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},getOption:e.proxyGetOption,triggerMethod:e.triggerMethod}),e.Region.extend=e.extend,e.RegionManager=function(a){var b=a.Controller.extend({constructor:function(b){this._regions={},a.Controller.call(this,b)},addRegions:function(a,b){c.isFunction(a)&&(a=a.apply(this,arguments));var d={};return c.each(a,function(a,e){c.isString(a)&&(a={selector:a}),a.selector&&(a=c.defaults({},a,b));var f=this.addRegion(e,a);d[e]=f},this),d},addRegion:function(b,c){var d;return d=c instanceof a.Region?c:a.Region.buildRegion(c,a.Region),this.triggerMethod("before:add:region",b,d),this._store(b,d),this.triggerMethod("add:region",b,d),d},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.each(a,function(a){a.empty()},this),a},destroy:function(){return this.removeRegions(),a.Controller.prototype.destroy.apply(this,arguments)},_store:function(a,b){this._regions[a]=b,this._setLength()},_remove:function(a,b){this.triggerMethod("before:remove:region",a,b),b.empty(),b.stopListening(),delete this._regions[a],this._setLength(),this.triggerMethod("remove:region",a,b)},_setLength:function(){this.length=c.size(this._regions)}});return a.actAsCollection(b.prototype,"_regions"),b}(e),e.TemplateCache=function(a){this.templateId=a},c.extend(e.TemplateCache,{templateCaches:{},get:function(a){var b=this.templateCaches[a];return b||(b=new e.TemplateCache(a),this.templateCaches[a]=b),b.load()},clear:function(){var a,b=f.call(arguments),c=b.length;if(c>0)for(a=0;c>a;a++)delete this.templateCaches[b[a]];else this.templateCaches={}}}),c.extend(e.TemplateCache.prototype,{load:function(){if(this.compiledTemplate)return this.compiledTemplate;var a=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(a),this.compiledTemplate},loadTemplate:function(a){var c=b.$(a).html();if(!c||0===c.length)throw new e.Error({name:"NoTemplateError",message:'Could not find template: "'+a+'"'});return c},compileTemplate:function(a){return c.template(a)}}),e.Renderer={render:function(a,b){if(!a)throw new e.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var c;return(c="function"==typeof a?a:e.TemplateCache.get(a))(b)}},e.View=b.View.extend({constructor:function(a){c.bindAll(this,"render"),this.options=c.extend({},c.result(this,"options"),c.isFunction(a)?a.call(this):a),this._behaviors=e.Behaviors(this),b.View.apply(this,arguments),e.MonitorDOMRefresh(this),this.listenTo(this,"show",this.onShowCalled)},getTemplate:function(){return this.getOption("template")},serializeModel:function(a){return a.toJSON.apply(a,f.call(arguments,1))},mixinTemplateHelpers:function(a){a=a||{};var b=this.getOption("templateHelpers");return c.isFunction(b)&&(b=b.call(this)),c.extend(a,b)},normalizeUIKeys:function(a){var b=c.result(this,"ui"),d=c.result(this,"_uiBindings");return e.normalizeUIKeys(a,d||b)},normalizeUIValues:function(a){var b=c.result(this,"ui"),d=c.result(this,"_uiBindings");return e.normalizeUIValues(a,d||b)},configureTriggers:function(){if(this.triggers){var a={},b=this.normalizeUIKeys(c.result(this,"triggers"));return c.each(b,function(b,c){a[c]=this._buildViewTrigger(b)},this),a}},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=a||this.events;c.isFunction(d)&&(d=d.call(this)),d=this.normalizeUIKeys(d),c.isUndefined(a)&&(this.events=d);var e={},f=c.result(this,"behaviorEvents")||{},g=this.configureTriggers(),h=c.result(this,"behaviorTriggers")||{};c.extend(e,f,d,g,h),b.View.prototype.delegateEvents.call(this,e)},undelegateEvents:function(){var a=f.call(arguments);return b.View.prototype.undelegateEvents.apply(this,a),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},onShowCalled:function(){},_ensureViewIsIntact:function(){if(this.isDestroyed)throw new e.Error({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'})},destroy:function(){if(!this.isDestroyed){var a=f.call(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(a)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(a)),this.unbindUIElements(),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(c.keys(a),function(b){var c=a[b];this.ui[b]=this.$(c)},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=arguments,b=e.triggerMethod,d=b.apply(this,a);return c.each(this._behaviors,function(c){b.apply(c,a)}),d},normalizeMethods:e.normalizeMethods,getOption:e.proxyGetOption,bindEntityEvents:e.proxyBindEntityEvents,unbindEntityEvents:e.proxyUnbindEntityEvents}),e.ItemView=e.View.extend({constructor:function(){e.View.apply(this,arguments)},serializeData:function(){var a={};return this.model?a=c.partial(this.serializeModel,this.model).apply(this,arguments):this.collection&&(a={items:c.partial(this.serializeCollection,this.collection).apply(this,arguments)}),a},serializeCollection:function(a){return a.toJSON.apply(a,f.call(arguments,1))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderTemplate(),this.bindUIElements(),this.triggerMethod("render",this),this},_renderTemplate:function(){var a=this.getTemplate();if(a!==!1){if(!a)throw new e.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});var b=this.serializeData();b=this.mixinTemplateHelpers(b);var c=e.Renderer.render(a,b,this);return this.attachElContent(c),this}},attachElContent:function(a){return this.$el.html(a),this},destroy:function(){return this.isDestroyed?void 0:e.View.prototype.destroy.apply(this,arguments)}}),e.CollectionView=e.View.extend({childViewEventPrefix:"childview",constructor:function(a){var b=a||{};this.sort=c.isUndefined(b.sort)?!0:b.sort,this.once("render",this._initialEvents),this._initChildViewStorage(),e.View.apply(this,arguments),this.initRenderBuffer()},initRenderBuffer:function(){this.elBuffer=document.createDocumentFragment(),this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){this.isBuffering=!1,this._triggerBeforeShowBufferedChildren(),this.attachBuffer(this,this.elBuffer),this._triggerShowBufferedChildren(),this.initRenderBuffer()},_triggerBeforeShowBufferedChildren:function(){this._isShown&&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){e.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.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(a){this.destroyEmptyView();var b=this.getChildView(a),c=this.collection.indexOf(a);this.addChild(a,b,c)},_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.triggerMethod("render",this),this},resortView:function(){this.render()},_sortViews:function(){var a=this.collection.find(function(a,b){var c=this.children.findByModel(a);return!c||c._index!==b},this);a&&this.resortView()},_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren(),this.isEmpty(this.collection)?this.showEmptyView():(this.triggerMethod("before:render:collection",this),this.startBuffering(),this.showCollection(),this.endBuffering(),this.triggerMethod("render:collection",this))},showCollection:function(){var a;this.collection.each(function(b,c){a=this.getChildView(b),this.addChild(b,a,c)},this)},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));var f=this.buildChildView(a,b,d);this.proxyChildEvents(f),this._isShown&&e.triggerMethodOn(f,"before:show"),this.children.add(f),this.renderChildView(f,-1),this._isShown&&e.triggerMethodOn(f,"show")},getChildView:function(){var a=this.getOption("childView");if(!a)throw new e.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return a},addChild:function(a,b,d){var e=this.getOption("childViewOptions");c.isFunction(e)&&(e=e.call(this,a,d));var f=this.buildChildView(a,b,e);return this._updateIndices(f,!0,d),this._addChildView(f,d),f},_updateIndices:function(a,b,c){this.sort&&(b?(a._index=c,this.children.each(function(b){b._index>=a._index&&b._index++})):this.children.each(function(b){b._index>=a._index&&b._index--}))},_addChildView:function(a,b){this.proxyChildEvents(a),this.triggerMethod("before:add:child",a),this.children.add(a),this.renderChildView(a,b),this._isShown&&!this.isBuffering&&e.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(),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,b){a.$el.append(b)},attachHtml:function(a,b,c){a.isBuffering?(a.elBuffer.appendChild(b.el),a._bufferedChildren.push(b)):a._insertBefore(b,c)||a._insertAfter(b)},_insertBefore:function(a,b){var c,d=this.sort&&b1?d.trigger.apply(d,g?f:[e].concat(c.rest(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.isFunction(e)&&!c.isObject(e))throw new a.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});c.isFunction(e)&&(e=e.call(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,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(){this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening()},triggerMethod:f.triggerMethod,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)},attachHtml:function(a){this.$el.html(""),this.el.appendChild(a.el)},empty:function(){var a=this.currentView;if(a)return a.off("destroy",this.empty,this),this.triggerMethod("before:empty",a),this._destroyView(),this.triggerMethod("empty",a),delete this.currentView,this},_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,d){var e=a.regionClass||d,f=c.omit(a,"selector","regionClass");a.selector&&!f.el&&(f.el=a.selector);var g=new e(f);return a.parentEl&&(g.getEl=function(d){if(c.isObject(d))return b.$(d);var e=a.parentEl;return c.isFunction(e)&&(e=e()),e.find(d)}),g},_buildRegionFromRegionClass:function(a){return new a}}),f.RegionManager=f.Controller.extend({constructor:function(a){this._regions={},f.Controller.call(this,a),this.addRegions(this.getOption("regions"))},addRegions:function(a,b){c.isFunction(a)&&(a=a.apply(this,arguments));var d={};return c.each(a,function(a,e){c.isString(a)&&(a={selector:a}),a.selector&&(a=c.defaults({},a,b));var f=this.addRegion(e,a);d[e]=f},this),d},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]=b,this._setLength()},_remove:function(a,b){this.triggerMethod("before:remove:region",a,b),b.empty(),b.stopListening(),delete b._parent,delete this._regions[a],this._setLength(),this.triggerMethod("remove:region",a,b)},_setLength:function(){this.length=c.size(this._regions)}}),f.actAsCollection(f.RegionManager.prototype,"_regions"),f.TemplateCache=function(a){this.templateId=a},c.extend(f.TemplateCache,{templateCaches:{},get:function(a){var b=this.templateCaches[a];return b||(b=new f.TemplateCache(a),this.templateCaches[a]=b),b.load()},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(){if(this.compiledTemplate)return this.compiledTemplate;var a=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(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){return c.template(a)}}),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 c;return(c="function"==typeof a?a:f.TemplateCache.get(a))(b)}},f.View=b.View.extend({constructor:function(a){c.bindAll(this,"render"),a=c.isFunction(a)?a.call(this):a,this.options=c.extend({},c.result(this,"options"),a),this._behaviors=f.Behaviors(this),b.View.apply(this,arguments),f.MonitorDOMRefresh(this),this.on("show",this.onShowCalled)},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 c.isFunction(b)&&(b=b.call(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){var b=c.result(this,"ui"),d=c.result(this,"_uiBindings");return f.normalizeUIValues(a,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=a||this.events;c.isFunction(d)&&(d=d.call(this)),d=this.normalizeUIKeys(d),c.isUndefined(a)&&(this.events=d);var e={},f=c.result(this,"behaviorEvents")||{},g=this.configureTriggers(),h=c.result(this,"behaviorTriggers")||{};c.extend(e,f,d,g,h),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},onShowCalled:function(){},_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){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.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(c.keys(a),function(b){var c=a[b];this.ui[b]=this.$(c)},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(){for(var a=f._triggerMethod,b=a(this,arguments),c=this._behaviors,d=0,e=c&&c.length;e>d;d++)a(c[d],arguments);return 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},normalizeMethods:f.normalizeMethods,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.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.serializeData();b=this.mixinTemplateHelpers(b);var 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",constructor:function(a){var b=a||{};c.isUndefined(this.sort)&&(this.sort=c.isUndefined(b.sort)?!0:b.sort),this.once("render",this._initialEvents),this._initChildViewStorage(),f.View.apply(this,arguments),this.initRenderBuffer()},initRenderBuffer:function(){this.elBuffer=document.createDocumentFragment(),this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){this.isBuffering=!1,this._triggerBeforeShowBufferedChildren(),this.attachBuffer(this,this.elBuffer),this._triggerShowBufferedChildren(),this.initRenderBuffer()},_triggerBeforeShowBufferedChildren:function(){this._isShown&&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.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(a){this.destroyEmptyView();var b=this.getChildView(a),c=this.collection.indexOf(a);this.addChild(a,b,c)},_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.triggerMethod("render",this),this},resortView:function(){this.render()},_sortViews:function(){var a=this.collection.find(function(a,b){var c=this.children.findByModel(a);return!c||c._index!==b},this);a&&this.resortView()},_emptyViewIndex:-1,_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren(),this.isEmpty(this.collection)?this.showEmptyView():(this.triggerMethod("before:render:collection",this),this.startBuffering(),this.showCollection(),this.endBuffering(),this.triggerMethod("render:collection",this))},showCollection:function(){var a;this.collection.each(function(b,c){a=this.getChildView(b),this.addChild(b,a,c)},this)},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,d){var e=this.getOption("childViewOptions");c.isFunction(e)&&(e=e.call(this,a,d));var f=this.buildChildView(a,b,e);return this._updateIndices(f,!0,d),this._addChildView(f,d),f._parent=this,f},_updateIndices:function(a,b,c){this.sort&&(b?(a._index=c,this.children.each(function(b){b._index>=a._index&&b._index++})):this.children.each(function(b){b._index>=a._index&&b._index--}))},_addChildView:function(a,b){this.proxyChildEvents(a),this.triggerMethod("before:add:child",a),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,b){a.$el.append(b)},attachHtml:function(a,b,c){a.isBuffering?(a.elBuffer.appendChild(b.el),a._bufferedChildren.push(b)):a._insertBefore(b,c)||a._insertAfter(b)},_insertBefore:function(a,b){var c,d=this.sort&&b