diff --git a/ajax/libs/backbone.marionette/1.0.1-bundled/backbone.marionette.js b/ajax/libs/backbone.marionette/1.0.1-bundled/backbone.marionette.js new file mode 100644 index 00000000000000..6cf002e4f397e3 --- /dev/null +++ b/ajax/libs/backbone.marionette/1.0.1-bundled/backbone.marionette.js @@ -0,0 +1,2331 @@ +// MarionetteJS (Backbone.Marionette) +// ---------------------------------- +// v1.0.1 +// +// Copyright (c)2013 Derick Bailey, Muted Solutions, LLC. +// Distributed under MIT license +// +// http://marionettejs.com + + + +/*! + * Includes BabySitter + * https://github.com/marionettejs/backbone.babysitter/ + * + * Includes Wreqr + * https://github.com/marionettejs/backbone.wreqr/ + */ + +// Backbone.BabySitter, v0.0.4 +// Copyright (c)2012 Derick Bailey, Muted Solutions, LLC. +// Distributed under MIT license +// http://github.com/marionettejs/backbone.babysitter +// Backbone.ChildViewContainer +// --------------------------- +// +// Provide a container to store, retrieve and +// shut down child views. + +Backbone.ChildViewContainer = (function(Backbone, _){ + + // Container Constructor + // --------------------- + + var Container = function(initialViews){ + this._views = {}; + this._indexByModel = {}; + this._indexByCollection = {}; + this._indexByCustom = {}; + this._updateLength(); + + this._addInitialViews(initialViews); + }; + + // Container Methods + // ----------------- + + _.extend(Container.prototype, { + + // Add a view to this container. Stores the view + // by `cid` and makes it searchable by the model + // and/or collection of the view. Optionally specify + // a custom key to store an retrieve the view. + add: function(view, customIndex){ + var viewCid = view.cid; + + // store the view + this._views[viewCid] = view; + + // index it by model + if (view.model){ + this._indexByModel[view.model.cid] = viewCid; + } + + // index it by collection + if (view.collection){ + this._indexByCollection[view.collection.cid] = viewCid; + } + + // index by custom + if (customIndex){ + this._indexByCustom[customIndex] = viewCid; + } + + this._updateLength(); + }, + + // Find a view by the model that was attached to + // it. Uses the model's `cid` to find it, and + // retrieves the view by it's `cid` from the result + findByModel: function(model){ + var viewCid = this._indexByModel[model.cid]; + return this.findByCid(viewCid); + }, + + // Find a view by the collection that was attached to + // it. Uses the collection's `cid` to find it, and + // retrieves the view by it's `cid` from the result + findByCollection: function(col){ + var viewCid = this._indexByCollection[col.cid]; + return this.findByCid(viewCid); + }, + + // Find a view by a custom indexer. + findByCustom: function(index){ + var viewCid = this._indexByCustom[index]; + return this.findByCid(viewCid); + }, + + // Find by index. This is not guaranteed to be a + // stable index. + findByIndex: function(index){ + return _.values(this._views)[index]; + }, + + // retrieve a view by it's `cid` directly + findByCid: function(cid){ + return this._views[cid]; + }, + + // Remove a view + remove: function(view){ + var viewCid = view.cid; + + // delete model index + if (view.model){ + delete this._indexByModel[view.model.cid]; + } + + // delete collection index + if (view.collection){ + delete this._indexByCollection[view.collection.cid]; + } + + // delete custom index + var cust; + + for (var key in this._indexByCustom){ + if (this._indexByCustom.hasOwnProperty(key)){ + if (this._indexByCustom[key] === viewCid){ + cust = key; + break; + } + } + } + + if (cust){ + delete this._indexByCustom[cust]; + } + + // remove the view from the container + delete this._views[viewCid]; + + // update the length + this._updateLength(); + }, + + // Call a method on every view in the container, + // passing parameters to the call method one at a + // time, like `function.call`. + call: function(method, args){ + args = Array.prototype.slice.call(arguments, 1); + this.apply(method, args); + }, + + // Apply a method on every view in the container, + // passing parameters to the call method one at a + // time, like `function.apply`. + apply: function(method, args){ + var view; + + // fix for IE < 9 + args = args || []; + + _.each(this._views, function(view, key){ + if (_.isFunction(view[method])){ + view[method].apply(view, args); + } + }); + + }, + + // Update the `.length` attribute on this container + _updateLength: function(){ + this.length = _.size(this._views); + }, + + // set up an initial list of views + _addInitialViews: function(views){ + if (!views){ return; } + + var view, i, + length = views.length; + + for (i=0; i` blocks, +// caching them for faster access. +Marionette.TemplateCache = function(templateId){ + this.templateId = templateId; +}; + +// TemplateCache object-level methods. Manage the template +// caches from these method calls instead of creating +// your own TemplateCache instances +_.extend(Marionette.TemplateCache, { + templateCaches: {}, + + // Get the specified template by id. Either + // retrieves the cached version, or loads it + // from the DOM. + get: function(templateId){ + var cachedTemplate = this.templateCaches[templateId]; + + if (!cachedTemplate){ + cachedTemplate = new Marionette.TemplateCache(templateId); + this.templateCaches[templateId] = cachedTemplate; + } + + return cachedTemplate.load(); + }, + + // Clear templates from the cache. If no arguments + // are specified, clears all templates: + // `clear()` + // + // If arguments are specified, clears each of the + // specified templates from the cache: + // `clear("#t1", "#t2", "...")` + clear: function(){ + var i; + var args = slice(arguments); + var length = args.length; + + if (length > 0){ + for(i=0; i 0) { + this.showCollection(); + } else { + this.showEmptyView(); + } + }, + + // Internal method to loop through each item in the + // collection view and show it + showCollection: function(){ + var ItemView; + this.collection.each(function(item, index){ + ItemView = this.getItemView(item); + this.addItemView(item, ItemView, index); + }, this); + }, + + // Internal method to show an empty view in place of + // a collection of item views, when the collection is + // empty + showEmptyView: function(){ + var EmptyView = Marionette.getOption(this, "emptyView"); + + if (EmptyView && !this._showingEmptyView){ + this._showingEmptyView = true; + var model = new Backbone.Model(); + this.addItemView(model, EmptyView, 0); + } + }, + + // Internal method to close an existing emptyView instance + // if one exists. Called when a collection view has been + // rendered empty, and then an item is added to the collection. + closeEmptyView: function(){ + if (this._showingEmptyView){ + this.closeChildren(); + delete this._showingEmptyView; + } + }, + + // Retrieve the itemView type, either from `this.options.itemView` + // or from the `itemView` in the object definition. The "options" + // takes precedence. + getItemView: function(item){ + var itemView = Marionette.getOption(this, "itemView"); + + if (!itemView){ + throwError("An `itemView` must be specified", "NoItemViewError"); + } + + return itemView; + }, + + // Render the child item's view and add it to the + // HTML for the collection view. + addItemView: function(item, ItemView, index){ + // get the itemViewOptions if any were specified + var itemViewOptions = Marionette.getOption(this, "itemViewOptions"); + if (_.isFunction(itemViewOptions)){ + itemViewOptions = itemViewOptions.call(this, item, index); + } + + // build the view + var view = this.buildItemView(item, ItemView, itemViewOptions); + + // set up the child view event forwarding + this.addChildViewEventForwarding(view); + + // this view is about to be added + this.triggerMethod("before:item:added", view); + + // Store the child view itself so we can properly + // remove and/or close it later + this.children.add(view); + + // Render it and show it + this.renderItemView(view, index); + + // call the "show" method if the collection view + // has already been shown + if (this._isShown){ + Marionette.triggerMethod.call(view, "show"); + } + + // this view was added + this.triggerMethod("after:item:added", view); + }, + + // Set up the child view event forwarding. Uses an "itemview:" + // prefix in front of all forwarded events. + addChildViewEventForwarding: function(view){ + var prefix = Marionette.getOption(this, "itemViewEventPrefix"); + + // Forward all child item view events through the parent, + // prepending "itemview:" to the event name + this.listenTo(view, "all", function(){ + var args = slice(arguments); + args[0] = prefix + ":" + args[0]; + args.splice(1, 0, view); + + Marionette.triggerMethod.apply(this, args); + }, this); + }, + + // render the item view + renderItemView: function(view, index) { + view.render(); + this.appendHtml(this, view, index); + }, + + // Build an `itemView` for every model in the collection. + buildItemView: function(item, ItemViewType, itemViewOptions){ + var options = _.extend({model: item}, itemViewOptions); + return new ItemViewType(options); + }, + + // get the child view by item it holds, and remove it + removeItemView: function(item){ + var view = this.children.findByModel(item); + this.removeChildView(view); + this.checkEmpty(); + }, + + // Remove the child view and close it + removeChildView: function(view){ + + // shut down the child view properly, + // including events that the collection has from it + if (view){ + this.stopListening(view); + + // call 'close' or 'remove', depending on which is found + if (view.close) { view.close(); } + else if (view.remove) { view.remove(); } + + this.children.remove(view); + } + + this.triggerMethod("item:removed", view); + }, + + // helper to show the empty view if the collection is empty + checkEmpty: function() { + // check if we're empty now, and if we are, show the + // empty view + if (!this.collection || this.collection.length === 0){ + this.showEmptyView(); + } + }, + + // Append the HTML to the collection's `el`. + // Override this method to do something other + // then `.append`. + appendHtml: function(collectionView, itemView, index){ + collectionView.$el.append(itemView.el); + }, + + // Internal method to set up the `children` object for + // storing all of the child views + _initChildViewStorage: function(){ + this.children = new Backbone.ChildViewContainer(); + }, + + // Handle cleanup and other closing needs for + // the collection of views. + close: function(){ + if (this.isClosed){ return; } + + this.triggerMethod("collection:before:close"); + this.closeChildren(); + this.triggerMethod("collection:closed"); + + Marionette.View.prototype.close.apply(this, slice(arguments)); + }, + + // Close the child views that this collection view + // is holding on to, if any + closeChildren: function(){ + this.children.each(function(child){ + this.removeChildView(child); + }, this); + this.checkEmpty(); + } +}); + + +// Composite View +// -------------- + +// Used for rendering a branch-leaf, hierarchical structure. +// Extends directly from CollectionView and also renders an +// an item view as `modelView`, for the top leaf +Marionette.CompositeView = Marionette.CollectionView.extend({ + constructor: function(options){ + Marionette.CollectionView.apply(this, slice(arguments)); + + this.itemView = this.getItemView(); + }, + + // Configured the initial events that the composite view + // binds to. Override this method to prevent the initial + // events, or to add your own initial events. + _initialEvents: function(){ + if (this.collection){ + this.listenTo(this.collection, "add", this.addChildView, this); + this.listenTo(this.collection, "remove", this.removeItemView, this); + this.listenTo(this.collection, "reset", this._renderChildren, this); + } + }, + + // Retrieve the `itemView` to be used when rendering each of + // the items in the collection. The default is to return + // `this.itemView` or Marionette.CompositeView if no `itemView` + // has been defined + getItemView: function(item){ + var itemView = Marionette.getOption(this, "itemView") || this.constructor; + + if (!itemView){ + throwError("An `itemView` must be specified", "NoItemViewError"); + } + + return itemView; + }, + + // Serialize the collection 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(){ + var data = {}; + + if (this.model){ + data = this.model.toJSON(); + } + + 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. + render: function(){ + this.isRendered = true; + this.isClosed = false; + this.resetItemViewContainer(); + + this.triggerBeforeRender(); + var html = this.renderModel(); + this.$el.html(html); + // the ui bindings is done here and not at the end of render since they + // will not be available until after the model is rendered, but should be + // available before the collection is rendered. + this.bindUIElements(); + this.triggerMethod("composite:model:rendered"); + + this._renderChildren(); + + this.triggerMethod("composite:rendered"); + this.triggerRendered(); + return this; + }, + + _renderChildren: function(){ + if (this.isRendered){ + Marionette.CollectionView.prototype._renderChildren.call(this); + this.triggerMethod("composite:collection:rendered"); + } + }, + + // Render an individual model, if we have one, as + // part of a composite view (branch / leaf). For example: + // a treeview. + renderModel: function(){ + var data = {}; + data = this.serializeData(); + data = this.mixinTemplateHelpers(data); + + var template = this.getTemplate(); + return Marionette.Renderer.render(template, data); + }, + + // Appends the `el` of itemView instances to the specified + // `itemViewContainer` (a jQuery selector). Override this method to + // provide custom logic of how the child item view instances have their + // HTML appended to the composite view instance. + appendHtml: function(cv, iv){ + var $container = this.getItemViewContainer(cv); + $container.append(iv.el); + }, + + // Internal method to ensure an `$itemViewContainer` exists, for the + // `appendHtml` method to use. + getItemViewContainer: function(containerView){ + if ("$itemViewContainer" in containerView){ + return containerView.$itemViewContainer; + } + + var container; + if (containerView.itemViewContainer){ + + var selector = _.result(containerView, "itemViewContainer"); + container = containerView.$(selector); + if (container.length <= 0) { + throwError("The specified `itemViewContainer` was not found: " + containerView.itemViewContainer, "ItemViewContainerMissingError"); + } + + } else { + container = containerView.$el; + } + + containerView.$itemViewContainer = container; + return container; + }, + + // Internal method to reset the `$itemViewContainer` on render + resetItemViewContainer: function(){ + if (this.$itemViewContainer){ + delete this.$itemViewContainer; + } + } +}); + + +// Layout +// ------ + +// Used for managing application layouts, nested layouts and +// multiple regions within an application or sub-application. +// +// A specialized view type that renders an area of HTML and then +// attaches `Region` instances to the specified `regions`. +// Used for composite view management and sub-application areas. +Marionette.Layout = Marionette.ItemView.extend({ + regionType: Marionette.Region, + + // Ensure the regions are available when the `initialize` method + // is called. + constructor: function (options) { + options = options || {}; + + this._firstRender = true; + this._initializeRegions(options); + + Marionette.ItemView.call(this, options); + }, + + // Layout's render will use the existing region objects the + // first time it is called. Subsequent calls will close the + // views that the regions are showing and then reset the `el` + // for the regions to the newly rendered DOM elements. + render: function(){ + + if (this._firstRender){ + // if this is the first render, don't do anything to + // reset the regions + this._firstRender = false; + } else if (this.isClosed){ + // a previously closed layout means we need to + // completely re-initialize the regions + this._initializeRegions(); + } else { + // If this is not the first render call, then we need to + // re-initializing the `el` for each region + this._reInitializeRegions(); + } + + var args = Array.prototype.slice.apply(arguments); + var result = Marionette.ItemView.prototype.render.apply(this, args); + + return result; + }, + + // Handle closing regions, and then close the view itself. + close: function () { + if (this.isClosed){ return; } + this.regionManager.close(); + var args = Array.prototype.slice.apply(arguments); + Marionette.ItemView.prototype.close.apply(this, args); + }, + + // Add a single region, by name, to the layout + addRegion: function(name, definition){ + var regions = {}; + regions[name] = definition; + return this.addRegions(regions)[name]; + }, + + // Add multiple regions as a {name: definition, name2: def2} object literal + addRegions: function(regions){ + this.regions = _.extend(this.regions || {}, regions); + return this._buildRegions(regions); + }, + + // Remove a single region from the Layout, by name + removeRegion: function(name){ + return this.regionManager.removeRegion(name); + }, + + // internal method to build regions + _buildRegions: function(regions){ + var that = this; + + var defaults = { + parentEl: function(){ return that.$el; } + }; + + return this.regionManager.addRegions(regions, defaults); + }, + + // Internal method to initialize the regions that have been defined in a + // `regions` attribute on this layout. + _initializeRegions: function (options) { + var regions; + this._initRegionManager(); + + if (_.isFunction(this.regions)) { + regions = this.regions(options); + } else { + regions = this.regions || {}; + } + + this.addRegions(regions); + }, + + // Internal method to re-initialize all of the regions by updating the `el` that + // they point to + _reInitializeRegions: function(){ + this.regionManager.closeRegions(); + this.regionManager.each(function(region){ + region.reset(); + }); + }, + + // Internal method to initialize the region manager + // and all regions in it + _initRegionManager: function(){ + this.regionManager = new Marionette.RegionManager(); + + this.listenTo(this.regionManager, "region:add", function(name, region){ + this[name] = region; + this.trigger("region:add", name, region); + }); + + this.listenTo(this.regionManager, "region:remove", function(name, region){ + delete this[name]; + this.trigger("region:remove", name, region); + }); + } +}); + + +// AppRouter +// --------- + +// Reduce the boilerplate code of handling route events +// and then calling a single method on another object. +// Have your routers configured to call the method on +// your object, directly. +// +// Configure an AppRouter with `appRoutes`. +// +// App routers can only take one `controller` object. +// It is recommended that you divide your controller +// objects in to smaller pieces of related functionality +// and have multiple routers / controllers, instead of +// just one giant router and controller. +// +// You can also add standard routes to an AppRouter. + +Marionette.AppRouter = Backbone.Router.extend({ + + constructor: function(options){ + Backbone.Router.prototype.constructor.apply(this, slice(arguments)); + + this.options = options; + + if (this.appRoutes){ + var controller = Marionette.getOption(this, "controller"); + this.processAppRoutes(controller, this.appRoutes); + } + }, + + // Internal method to process the `appRoutes` for the + // router, and turn them in to routes that trigger the + // specified method on the specified `controller`. + processAppRoutes: function(controller, appRoutes){ + _.each(appRoutes, function(methodName, route) { + var method = controller[methodName]; + + if (!method) { + throw new Error("Method '" + methodName + "' was not found on the controller"); + } + + this.route(route, methodName, _.bind(method, controller)); + }, this); + } +}); + + +// Application +// ----------- + +// 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._initRegionManager(); + this._initCallbacks = new Marionette.Callbacks(); + this.vent = new Backbone.Wreqr.EventAggregator(); + this.commands = new Backbone.Wreqr.Commands(); + this.reqres = new Backbone.Wreqr.RequestResponse(); + this.submodules = {}; + + _.extend(this, options); + + this.triggerMethod = Marionette.triggerMethod; +}; + +_.extend(Marionette.Application.prototype, Backbone.Events, { + // Command execution, facilitated by Backbone.Wreqr.Commands + execute: function(){ + var args = Array.prototype.slice.apply(arguments); + this.commands.execute.apply(this.commands, args); + }, + + // Request/response, facilitated by Backbone.Wreqr.RequestResponse + request: function(){ + var args = Array.prototype.slice.apply(arguments); + return this.reqres.request.apply(this.reqres, args); + }, + + // Add an initializer that is either run at when the `start` + // method is called, or run immediately if added after `start` + // has already been called. + addInitializer: function(initializer){ + this._initCallbacks.add(initializer); + }, + + // kick off all of the application's processes. + // initializes all of the regions that have been added + // to the app, and runs all of the initializer functions + start: function(options){ + this.triggerMethod("initialize:before", options); + this._initCallbacks.run(options, this); + this.triggerMethod("initialize:after", options); + + this.triggerMethod("start", options); + }, + + // Add regions to your app. + // Accepts a hash of named strings or Region objects + // addRegions({something: "#someRegion"}) + // addRegions({something: Region.extend({el: "#someRegion"}) }); + addRegions: function(regions){ + return this._regionManager.addRegions(regions); + }, + + // Removes a region from your app. + // Accepts the regions name + // removeRegion('myRegion') + removeRegion: function(region) { + this._regionManager.removeRegion(region); + }, + + // Create a module, attached to the application + module: function(moduleNames, moduleDefinition){ + // slice the args, and add this application object as the + // first argument of the array + var args = slice(arguments); + args.unshift(this); + + // see the Marionette.Module object for more information + return Marionette.Module.create.apply(Marionette.Module, args); + }, + + // Internal method to set up the region manager + _initRegionManager: function(){ + this._regionManager = new Marionette.RegionManager(); + + this.listenTo(this._regionManager, "region:add", function(name, region){ + this[name] = region; + }); + + this.listenTo(this._regionManager, "region:remove", function(name, region){ + delete this[name]; + }); + } +}); + +// Copy the `extend` function used by Backbone's classes +Marionette.Application.extend = Marionette.extend; + +// Module +// ------ + +// A simple module system, used to create privacy and encapsulation in +// Marionette applications +Marionette.Module = function(moduleName, app){ + this.moduleName = moduleName; + + // store sub-modules + this.submodules = {}; + + this._setupInitializersAndFinalizers(); + + // store the configuration for this module + this.app = app; + this.startWithParent = true; + + this.triggerMethod = Marionette.triggerMethod; +}; + +// Extend the Module prototype with events / listenTo, so that the module +// can be used as an event aggregator or pub/sub. +_.extend(Marionette.Module.prototype, Backbone.Events, { + + // Initializer for a specific module. Initializers are run when the + // module's `start` method is called. + addInitializer: function(callback){ + this._initializerCallbacks.add(callback); + }, + + // Finalizers are run when a module is stopped. They are used to teardown + // and finalize any variables, references, events and other code that the + // module had set up. + addFinalizer: function(callback){ + this._finalizerCallbacks.add(callback); + }, + + // Start the module, and run all of its initializers + start: function(options){ + // Prevent re-starting a module that is already started + if (this._isInitialized){ return; } + + // start the sub-modules (depth-first hierarchy) + _.each(this.submodules, function(mod){ + // check to see if we should start the sub-module with this parent + if (mod.startWithParent){ + mod.start(options); + } + }); + + // run the callbacks to "start" the current module + this.triggerMethod("before:start", options); + + this._initializerCallbacks.run(options, this); + this._isInitialized = true; + + this.triggerMethod("start", options); + }, + + // Stop this module by running its finalizers and then stop all of + // the sub-modules for this module + stop: function(){ + // if we are not initialized, don't bother finalizing + if (!this._isInitialized){ return; } + this._isInitialized = false; + + Marionette.triggerMethod.call(this, "before:stop"); + + // stop the sub-modules; depth-first, to make sure the + // sub-modules are stopped / finalized before parents + _.each(this.submodules, function(mod){ mod.stop(); }); + + // run the finalizers + this._finalizerCallbacks.run(undefined,this); + + // reset the initializers and finalizers + this._initializerCallbacks.reset(); + this._finalizerCallbacks.reset(); + + Marionette.triggerMethod.call(this, "stop"); + }, + + // Configure the module with a definition function and any custom args + // that are to be passed in to the definition function + addDefinition: function(moduleDefinition, customArgs){ + this._runModuleDefinition(moduleDefinition, customArgs); + }, + + // Internal method: run the module definition function with the correct + // arguments + _runModuleDefinition: function(definition, customArgs){ + if (!definition){ return; } + + // build the correct list of arguments for the module definition + var args = _.flatten([ + this, + this.app, + Backbone, + Marionette, + Marionette.$, _, + customArgs + ]); + + definition.apply(this, args); + }, + + // Internal method: set up new copies of initializers and finalizers. + // Calling this method will wipe out all existing initializers and + // finalizers. + _setupInitializersAndFinalizers: function(){ + this._initializerCallbacks = new Marionette.Callbacks(); + this._finalizerCallbacks = new Marionette.Callbacks(); + } +}); + +// Type methods to create modules +_.extend(Marionette.Module, { + + // Create a module, hanging off the app parameter as the parent object. + create: function(app, moduleNames, moduleDefinition){ + var module = app; + + // get the custom args passed in after the module definition and + // get rid of the module name and definition function + var customArgs = slice(arguments); + customArgs.splice(0, 3); + + // split the module names and get the length + moduleNames = moduleNames.split("."); + var length = moduleNames.length; + + // store the module definition for the last module in the chain + var moduleDefinitions = []; + moduleDefinitions[length-1] = moduleDefinition; + + // Loop through all the parts of the module definition + _.each(moduleNames, function(moduleName, i){ + var parentModule = module; + module = this._getModule(parentModule, moduleName, app); + this._addModuleDefinition(parentModule, module, moduleDefinitions[i], customArgs); + }, this); + + // Return the last module in the definition chain + return module; + }, + + _getModule: function(parentModule, moduleName, app, def, args){ + // Get an existing module of this name if we have one + var module = parentModule[moduleName]; + + if (!module){ + // Create a new module if we don't have one + module = new Marionette.Module(moduleName, app); + parentModule[moduleName] = module; + // store the module on the parent + parentModule.submodules[moduleName] = module; + } + + return module; + }, + + _addModuleDefinition: function(parentModule, module, def, args){ + var fn; + var startWithParent; + + if (_.isFunction(def)){ + // if a function is supplied for the module definition + fn = def; + startWithParent = true; + + } else if (_.isObject(def)){ + // if an object is supplied + fn = def.define; + startWithParent = def.startWithParent; + + } else { + // if nothing is supplied + startWithParent = true; + } + + // add module definition if needed + if (fn){ + module.addDefinition(fn, args); + } + + // `and` the two together, ensuring a single `false` will prevent it + // from starting with the parent + module.startWithParent = module.startWithParent && startWithParent; + + // setup auto-start if needed + if (module.startWithParent && !module.startWithParentIsConfigured){ + + // only configure this once + module.startWithParentIsConfigured = true; + + // add the module initializer config + parentModule.addInitializer(function(options){ + if (module.startWithParent){ + module.start(options); + } + }); + + } + + } +}); + + + + return Marionette; +})(this, Backbone, _); diff --git a/ajax/libs/backbone.marionette/1.0.1-bundled/backbone.marionette.min.js b/ajax/libs/backbone.marionette/1.0.1-bundled/backbone.marionette.min.js new file mode 100644 index 00000000000000..421c5ed43ca36b --- /dev/null +++ b/ajax/libs/backbone.marionette/1.0.1-bundled/backbone.marionette.min.js @@ -0,0 +1,21 @@ +// MarionetteJS (Backbone.Marionette) +// ---------------------------------- +// v1.0.1 +// +// Copyright (c)2013 Derick Bailey, Muted Solutions, LLC. +// Distributed under MIT license +// +// http://marionettejs.com + + + +/*! + * Includes BabySitter + * https://github.com/marionettejs/backbone.babysitter/ + * + * Includes Wreqr + * https://github.com/marionettejs/backbone.wreqr/ + */ + +Backbone.ChildViewContainer=function(e,t){var i=function(e){this._views={},this._indexByModel={},this._indexByCollection={},this._indexByCustom={},this._updateLength(),this._addInitialViews(e)};t.extend(i.prototype,{add:function(e,t){var i=e.cid;this._views[i]=e,e.model&&(this._indexByModel[e.model.cid]=i),e.collection&&(this._indexByCollection[e.collection.cid]=i),t&&(this._indexByCustom[t]=i),this._updateLength()},findByModel:function(e){var t=this._indexByModel[e.cid];return this.findByCid(t)},findByCollection:function(e){var t=this._indexByCollection[e.cid];return this.findByCid(t)},findByCustom:function(e){var t=this._indexByCustom[e];return this.findByCid(t)},findByIndex:function(e){return t.values(this._views)[e]},findByCid:function(e){return this._views[e]},remove:function(e){var t=e.cid;e.model&&delete this._indexByModel[e.model.cid],e.collection&&delete this._indexByCollection[e.collection.cid];var i;for(var n in this._indexByCustom)if(this._indexByCustom.hasOwnProperty(n)&&this._indexByCustom[n]===t){i=n;break}i&&delete this._indexByCustom[i],delete this._views[t],this._updateLength()},call:function(e,t){t=Array.prototype.slice.call(arguments,1),this.apply(e,t)},apply:function(e,i){i=i||[],t.each(this._views,function(n){t.isFunction(n[e])&&n[e].apply(n,i)})},_updateLength:function(){this.length=t.size(this._views)},_addInitialViews:function(e){if(e){var t,i,n=e.length;for(i=0;n>i;i++)t=e[i],this.add(t)}}});var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];return t.each(n,function(e){i.prototype[e]=function(){var i=t.values(this._views),n=[i].concat(t.toArray(arguments));return t[e].apply(t,n)}}),i}(Backbone,_),Backbone.Wreqr=function(e,t,i){"use strict";var n={};return n.Handlers=function(e,t){var i=function(e){this.options=e,this._wreqrHandlers={},t.isFunction(this.initialize)&&this.initialize(e)};return i.extend=e.Model.extend,t.extend(i.prototype,e.Events,{setHandlers:function(e){t.each(e,function(e,i){var n=null;t.isObject(e)&&!t.isFunction(e)&&(n=e.context,e=e.callback),this.setHandler(i,e,n)},this)},setHandler:function(e,t,i){var n={callback:t,context:i};this._wreqrHandlers[e]=n,this.trigger("handler:add",e,t,i)},hasHandler:function(e){return!!this._wreqrHandlers[e]},getHandler:function(e){var t=this._wreqrHandlers[e];if(!t)throw Error("Handler not found for '"+e+"'");return function(){var e=Array.prototype.slice.apply(arguments);return t.callback.apply(t.context,e)}},removeHandler:function(e){delete this._wreqrHandlers[e]},removeAllHandlers:function(){this._wreqrHandlers={}}}),i}(e,i),n.CommandStorage=function(){var t=function(e){this.options=e,this._commands={},i.isFunction(this.initialize)&&this.initialize(e)};return i.extend(t.prototype,e.Events,{getCommands:function(e){var t=this._commands[e];return t||(t={command:e,instances:[]},this._commands[e]=t),t},addCommand:function(e,t){var i=this.getCommands(e);i.instances.push(t)},clearCommands:function(e){var t=this.getCommands(e);t.instances=[]}}),t}(),n.Commands=function(e){return e.Handlers.extend({storageType:e.CommandStorage,constructor:function(t){this.options=t||{},this._initializeStorage(this.options),this.on("handler:add",this._executeCommands,this);var i=Array.prototype.slice.call(arguments);e.Handlers.prototype.constructor.apply(this,i)},execute:function(e,t){e=arguments[0],t=Array.prototype.slice.call(arguments,1),this.hasHandler(e)?this.getHandler(e).apply(this,t):this.storage.addCommand(e,t)},_executeCommands:function(e,t,n){var r=this.storage.getCommands(e);i.each(r.instances,function(e){t.apply(n,e)}),this.storage.clearCommands(e)},_initializeStorage:function(e){var t,n=e.storageType||this.storageType;t=i.isFunction(n)?new n:n,this.storage=t}})}(n),n.RequestResponse=function(e){return e.Handlers.extend({request:function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1);return this.getHandler(e).apply(this,t)}})}(n),n.EventAggregator=function(e,t){var i=function(){};return i.extend=e.Model.extend,t.extend(i.prototype,e.Events),i}(e,i),n}(Backbone,Backbone.Marionette,_);var Marionette=function(e,t,i){"use strict";function n(e){return s.call(e)}function r(e,t){var i=Error(e);throw i.name=t||"Error",i}var o={};t.Marionette=o,o.$=t.$;var s=Array.prototype.slice;return o.extend=t.Model.extend,o.getOption=function(e,t){if(e&&t){var i;return i=e.options&&t in e.options&&void 0!==e.options[t]?e.options[t]:e[t]}},o.triggerMethod=function(){function e(e,t,i){return i.toUpperCase()}var t=/(^|:)(\w)/gi,n=function(n){var r="on"+n.replace(t,e),o=this[r];return this.trigger.apply(this,arguments),i.isFunction(o)?o.apply(this,i.tail(arguments)):void 0};return n}(),o.MonitorDOMRefresh=function(){function e(e){e._isShown=!0,n(e)}function t(e){e._isRendered=!0,n(e)}function n(e){e._isShown&&e._isRendered&&i.isFunction(e.triggerMethod)&&e.triggerMethod("dom:refresh")}return function(i){i.listenTo(i,"show",function(){e(i)}),i.listenTo(i,"render",function(){t(i)})}}(),function(e){function t(e,t,n,o){var s=o.split(/\s+/);i.each(s,function(i){var o=e[i];o||r("Method '"+i+"' was configured as an event handler, but does not exist."),e.listenTo(t,n,o,e)})}function n(e,t,i,n){e.listenTo(t,i,n,e)}function o(e,t,n,r){var o=r.split(/\s+/);i.each(o,function(){var i=e[i];e.stopListening(t,n,i,e)})}function s(e,t,i,n){e.stopListening(t,i,n,e)}function h(e,t,n,r,o){t&&n&&(i.isFunction(n)&&(n=n.call(e)),i.each(n,function(n,s){i.isFunction(n)?r(e,t,s,n):o(e,t,s,n)}))}e.bindEntityEvents=function(e,i,r){h(e,i,r,n,t)},e.unbindEntityEvents=function(e,t,i){h(e,t,i,s,o)}}(o),o.Callbacks=function(){this._deferred=o.$.Deferred(),this._callbacks=[]},i.extend(o.Callbacks.prototype,{add:function(e,t){this._callbacks.push({cb:e,ctx:t}),this._deferred.done(function(i,n){t&&(i=t),e.call(i,n)})},run:function(e,t){this._deferred.resolve(t,e)},reset:function(){var e=this._callbacks;this._deferred=o.$.Deferred(),this._callbacks=[],i.each(e,function(e){this.add(e.cb,e.ctx)},this)}}),o.Controller=function(e){this.triggerMethod=o.triggerMethod,this.options=e||{},i.isFunction(this.initialize)&&this.initialize(this.options)},o.Controller.extend=o.extend,i.extend(o.Controller.prototype,t.Events,{close:function(){this.stopListening(),this.triggerMethod("close"),this.unbind()}}),o.Region=function(e){if(this.options=e||{},this.el=o.getOption(this,"el"),!this.el){var t=Error("An 'el' must be specified for a region.");throw t.name="NoElError",t}if(this.initialize){var i=Array.prototype.slice.apply(arguments);this.initialize.apply(this,i)}},i.extend(o.Region,{buildRegion:function(e,t){var n="string"==typeof e,r="string"==typeof e.selector,o=e.regionType===void 0,s="function"==typeof e;if(!s&&!n&&!r)throw Error("Region must be specified as a Region type, a selector string or an object with selector property");var h,a;n&&(h=e),e.selector&&(h=e.selector),s&&(a=e),!s&&o&&(a=t),e.regionType&&(a=e.regionType);var l=new a({el:h});return e.parentEl&&(l.getEl=function(t){var n=e.parentEl;return i.isFunction(n)&&(n=n()),n.find(t)}),l}}),i.extend(o.Region.prototype,t.Events,{show:function(e){this.ensureEl(),e!==this.currentView?(this.close(),e.render(),this.open(e)):e.render(),o.triggerMethod.call(e,"show"),o.triggerMethod.call(this,"show",e),this.currentView=e},ensureEl:function(){this.$el&&0!==this.$el.length||(this.$el=this.getEl(this.el))},getEl:function(e){return o.$(e)},open:function(e){this.$el.empty().append(e.el)},close:function(){var e=this.currentView;e&&!e.isClosed&&(e.close?e.close():e.remove&&e.remove(),o.triggerMethod.call(this,"close"),delete this.currentView)},attachView:function(e){this.currentView=e},reset:function(){this.close(),delete this.$el}}),o.Region.extend=o.extend,o.RegionManager=function(e){var t=e.Controller.extend({constructor:function(t){this._regions={},e.Controller.prototype.constructor.call(this,t)},addRegions:function(e,t){var n={};return i.each(e,function(e,r){"string"==typeof e&&(e={selector:e}),e.selector&&(e=i.defaults({},e,t));var o=this.addRegion(r,e);n[r]=o},this),n},addRegion:function(t,n){var r,o=i.isObject(n),s=i.isString(n),h=!!n.selector;return r=s||o&&h?e.Region.buildRegion(n,e.Region):i.isFunction(n)?e.Region.buildRegion(n,e.Region):n,this._store(t,r),this.triggerMethod("region:add",t,r),r},get:function(e){return this._regions[e]},removeRegion:function(e){var t=this._regions[e];this._remove(e,t)},removeRegions:function(){i.each(this._regions,function(e,t){this._remove(t,e)},this)},closeRegions:function(){i.each(this._regions,function(e){e.close()},this)},close:function(){this.removeRegions();var t=Array.prototype.slice.call(arguments);e.Controller.prototype.close.apply(this,t)},_store:function(e,t){this._regions[e]=t,this.length=i.size(this._regions)},_remove:function(e,t){t.close(),delete this._regions[e],this.triggerMethod("region:remove",e,t)}}),n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];return i.each(n,function(e){t.prototype[e]=function(){var t=i.values(this._regions),n=[t].concat(i.toArray(arguments));return i[e].apply(i,n)}}),t}(o),o.TemplateCache=function(e){this.templateId=e},i.extend(o.TemplateCache,{templateCaches:{},get:function(e){var t=this.templateCaches[e];return t||(t=new o.TemplateCache(e),this.templateCaches[e]=t),t.load()},clear:function(){var e,t=n(arguments),i=t.length;if(i>0)for(e=0;i>e;e++)delete this.templateCaches[t[e]];else this.templateCaches={}}}),i.extend(o.TemplateCache.prototype,{load:function(){if(this.compiledTemplate)return this.compiledTemplate;var e=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(e),this.compiledTemplate},loadTemplate:function(e){var t=o.$(e).html();return t&&0!==t.length||r("Could not find template: '"+e+"'","NoTemplateError"),t},compileTemplate:function(e){return i.template(e)}}),o.Renderer={render:function(e,t){var i="function"==typeof e?e:o.TemplateCache.get(e);return i(t)}},o.View=t.View.extend({constructor:function(){i.bindAll(this,"render");var e=Array.prototype.slice.apply(arguments);t.View.prototype.constructor.apply(this,e),o.MonitorDOMRefresh(this),this.listenTo(this,"show",this.onShowCalled,this)},triggerMethod:o.triggerMethod,getTemplate:function(){return o.getOption(this,"template")},mixinTemplateHelpers:function(e){e=e||{};var t=this.templateHelpers;return i.isFunction(t)&&(t=t.call(this)),i.extend(e,t)},configureTriggers:function(){if(this.triggers){var e={},t=i.result(this,"triggers");return i.each(t,function(t,i){e[i]=function(e){e&&e.preventDefault&&e.preventDefault(),e&&e.stopPropagation&&e.stopPropagation();var i={view:this,model:this.model,collection:this.collection};this.triggerMethod(t,i)}},this),e}},delegateEvents:function(e){this._delegateDOMEvents(e),o.bindEntityEvents(this,this.model,o.getOption(this,"modelEvents")),o.bindEntityEvents(this,this.collection,o.getOption(this,"collectionEvents"))},_delegateDOMEvents:function(e){e=e||this.events,i.isFunction(e)&&(e=e.call(this));var n={},r=this.configureTriggers();i.extend(n,e,r),t.View.prototype.delegateEvents.call(this,n)},undelegateEvents:function(){var e=Array.prototype.slice.call(arguments);t.View.prototype.undelegateEvents.apply(this,e),o.unbindEntityEvents(this,this.model,o.getOption(this,"modelEvents")),o.unbindEntityEvents(this,this.collection,o.getOption(this,"collectionEvents"))},onShowCalled:function(){},close:function(){if(!this.isClosed){var e=this.triggerMethod("before:close");e!==!1&&(this.unbindUIElements(),this.isClosed=!0,this.triggerMethod("close"),this.remove())}},bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var e=i.result(this,"_uiBindings");this.ui={},i.each(i.keys(e),function(t){var i=e[t];this.ui[t]=this.$(i)},this)}},unbindUIElements:function(){this.ui&&(i.each(this.ui,function(e,t){delete this.ui[t]},this),this.ui=this._uiBindings,delete this._uiBindings)}}),o.ItemView=o.View.extend({constructor:function(){o.View.prototype.constructor.apply(this,n(arguments))},serializeData:function(){var e={};return this.model?e=this.model.toJSON():this.collection&&(e={items:this.collection.toJSON()}),e},render:function(){this.isClosed=!1,this.triggerMethod("before:render",this),this.triggerMethod("item:before:render",this);var e=this.serializeData();e=this.mixinTemplateHelpers(e);var t=this.getTemplate(),i=o.Renderer.render(t,e);return this.$el.html(i),this.bindUIElements(),this.triggerMethod("render",this),this.triggerMethod("item:rendered",this),this},close:function(){this.isClosed||(this.triggerMethod("item:before:close"),o.View.prototype.close.apply(this,n(arguments)),this.triggerMethod("item:closed"))}}),o.CollectionView=o.View.extend({itemViewEventPrefix:"itemview",constructor:function(){this._initChildViewStorage(),o.View.prototype.constructor.apply(this,n(arguments)),this._initialEvents()},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this.addChildView,this),this.listenTo(this.collection,"remove",this.removeItemView,this),this.listenTo(this.collection,"reset",this.render,this))},addChildView:function(e){this.closeEmptyView();var t=this.getItemView(e),i=this.collection.indexOf(e);this.addItemView(e,t,i)},onShowCalled:function(){this.children.each(function(e){o.triggerMethod.call(e,"show")})},triggerBeforeRender:function(){this.triggerMethod("before:render",this),this.triggerMethod("collection:before:render",this)},triggerRendered:function(){this.triggerMethod("render",this),this.triggerMethod("collection:rendered",this)},render:function(){return this.isClosed=!1,this.triggerBeforeRender(),this._renderChildren(),this.triggerRendered(),this},_renderChildren:function(){this.closeEmptyView(),this.closeChildren(),this.collection&&this.collection.length>0?this.showCollection():this.showEmptyView()},showCollection:function(){var e;this.collection.each(function(t,i){e=this.getItemView(t),this.addItemView(t,e,i)},this)},showEmptyView:function(){var e=o.getOption(this,"emptyView");if(e&&!this._showingEmptyView){this._showingEmptyView=!0;var i=new t.Model;this.addItemView(i,e,0)}},closeEmptyView:function(){this._showingEmptyView&&(this.closeChildren(),delete this._showingEmptyView)},getItemView:function(){var e=o.getOption(this,"itemView");return e||r("An `itemView` must be specified","NoItemViewError"),e},addItemView:function(e,t,n){var r=o.getOption(this,"itemViewOptions");i.isFunction(r)&&(r=r.call(this,e,n));var s=this.buildItemView(e,t,r);this.addChildViewEventForwarding(s),this.triggerMethod("before:item:added",s),this.children.add(s),this.renderItemView(s,n),this._isShown&&o.triggerMethod.call(s,"show"),this.triggerMethod("after:item:added",s)},addChildViewEventForwarding:function(e){var t=o.getOption(this,"itemViewEventPrefix");this.listenTo(e,"all",function(){var i=n(arguments);i[0]=t+":"+i[0],i.splice(1,0,e),o.triggerMethod.apply(this,i)},this)},renderItemView:function(e,t){e.render(),this.appendHtml(this,e,t)},buildItemView:function(e,t,n){var r=i.extend({model:e},n);return new t(r)},removeItemView:function(e){var t=this.children.findByModel(e);this.removeChildView(t),this.checkEmpty()},removeChildView:function(e){e&&(this.stopListening(e),e.close?e.close():e.remove&&e.remove(),this.children.remove(e)),this.triggerMethod("item:removed",e)},checkEmpty:function(){this.collection&&0!==this.collection.length||this.showEmptyView()},appendHtml:function(e,t){e.$el.append(t.el)},_initChildViewStorage:function(){this.children=new t.ChildViewContainer},close:function(){this.isClosed||(this.triggerMethod("collection:before:close"),this.closeChildren(),this.triggerMethod("collection:closed"),o.View.prototype.close.apply(this,n(arguments)))},closeChildren:function(){this.children.each(function(e){this.removeChildView(e)},this),this.checkEmpty()}}),o.CompositeView=o.CollectionView.extend({constructor:function(){o.CollectionView.apply(this,n(arguments)),this.itemView=this.getItemView()},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this.addChildView,this),this.listenTo(this.collection,"remove",this.removeItemView,this),this.listenTo(this.collection,"reset",this._renderChildren,this))},getItemView:function(){var e=o.getOption(this,"itemView")||this.constructor;return e||r("An `itemView` must be specified","NoItemViewError"),e},serializeData:function(){var e={};return this.model&&(e=this.model.toJSON()),e},render:function(){this.isRendered=!0,this.isClosed=!1,this.resetItemViewContainer(),this.triggerBeforeRender();var e=this.renderModel();return this.$el.html(e),this.bindUIElements(),this.triggerMethod("composite:model:rendered"),this._renderChildren(),this.triggerMethod("composite:rendered"),this.triggerRendered(),this},_renderChildren:function(){this.isRendered&&(o.CollectionView.prototype._renderChildren.call(this),this.triggerMethod("composite:collection:rendered"))},renderModel:function(){var e={};e=this.serializeData(),e=this.mixinTemplateHelpers(e);var t=this.getTemplate();return o.Renderer.render(t,e)},appendHtml:function(e,t){var i=this.getItemViewContainer(e);i.append(t.el)},getItemViewContainer:function(e){if("$itemViewContainer"in e)return e.$itemViewContainer;var t;if(e.itemViewContainer){var n=i.result(e,"itemViewContainer");t=e.$(n),0>=t.length&&r("The specified `itemViewContainer` was not found: "+e.itemViewContainer,"ItemViewContainerMissingError")}else t=e.$el;return e.$itemViewContainer=t,t},resetItemViewContainer:function(){this.$itemViewContainer&&delete this.$itemViewContainer}}),o.Layout=o.ItemView.extend({regionType:o.Region,constructor:function(e){e=e||{},this._firstRender=!0,this._initializeRegions(e),o.ItemView.call(this,e)},render:function(){this._firstRender?this._firstRender=!1:this.isClosed?this._initializeRegions():this._reInitializeRegions();var e=Array.prototype.slice.apply(arguments),t=o.ItemView.prototype.render.apply(this,e);return t},close:function(){if(!this.isClosed){this.regionManager.close();var e=Array.prototype.slice.apply(arguments);o.ItemView.prototype.close.apply(this,e)}},addRegion:function(e,t){var i={};return i[e]=t,this.addRegions(i)[e]},addRegions:function(e){return this.regions=i.extend(this.regions||{},e),this._buildRegions(e)},removeRegion:function(e){return this.regionManager.removeRegion(e)},_buildRegions:function(e){var t=this,i={parentEl:function(){return t.$el}};return this.regionManager.addRegions(e,i)},_initializeRegions:function(e){var t;this._initRegionManager(),t=i.isFunction(this.regions)?this.regions(e):this.regions||{},this.addRegions(t)},_reInitializeRegions:function(){this.regionManager.closeRegions(),this.regionManager.each(function(e){e.reset()})},_initRegionManager:function(){this.regionManager=new o.RegionManager,this.listenTo(this.regionManager,"region:add",function(e,t){this[e]=t,this.trigger("region:add",e,t)}),this.listenTo(this.regionManager,"region:remove",function(e,t){delete this[e],this.trigger("region:remove",e,t)})}}),o.AppRouter=t.Router.extend({constructor:function(e){if(t.Router.prototype.constructor.apply(this,n(arguments)),this.options=e,this.appRoutes){var i=o.getOption(this,"controller");this.processAppRoutes(i,this.appRoutes)}},processAppRoutes:function(e,t){i.each(t,function(t,n){var r=e[t];if(!r)throw Error("Method '"+t+"' was not found on the controller");this.route(n,t,i.bind(r,e))},this)}}),o.Application=function(e){this._initRegionManager(),this._initCallbacks=new o.Callbacks,this.vent=new t.Wreqr.EventAggregator,this.commands=new t.Wreqr.Commands,this.reqres=new t.Wreqr.RequestResponse,this.submodules={},i.extend(this,e),this.triggerMethod=o.triggerMethod},i.extend(o.Application.prototype,t.Events,{execute:function(){var e=Array.prototype.slice.apply(arguments);this.commands.execute.apply(this.commands,e)},request:function(){var e=Array.prototype.slice.apply(arguments);return this.reqres.request.apply(this.reqres,e)},addInitializer:function(e){this._initCallbacks.add(e)},start:function(e){this.triggerMethod("initialize:before",e),this._initCallbacks.run(e,this),this.triggerMethod("initialize:after",e),this.triggerMethod("start",e)},addRegions:function(e){return this._regionManager.addRegions(e)},removeRegion:function(e){this._regionManager.removeRegion(e)},module:function(){var e=n(arguments);return e.unshift(this),o.Module.create.apply(o.Module,e)},_initRegionManager:function(){this._regionManager=new o.RegionManager,this.listenTo(this._regionManager,"region:add",function(e,t){this[e]=t}),this.listenTo(this._regionManager,"region:remove",function(e){delete this[e]})}}),o.Application.extend=o.extend,o.Module=function(e,t){this.moduleName=e,this.submodules={},this._setupInitializersAndFinalizers(),this.app=t,this.startWithParent=!0,this.triggerMethod=o.triggerMethod},i.extend(o.Module.prototype,t.Events,{addInitializer:function(e){this._initializerCallbacks.add(e)},addFinalizer:function(e){this._finalizerCallbacks.add(e)},start:function(e){this._isInitialized||(i.each(this.submodules,function(t){t.startWithParent&&t.start(e)}),this.triggerMethod("before:start",e),this._initializerCallbacks.run(e,this),this._isInitialized=!0,this.triggerMethod("start",e))},stop:function(){this._isInitialized&&(this._isInitialized=!1,o.triggerMethod.call(this,"before:stop"),i.each(this.submodules,function(e){e.stop()}),this._finalizerCallbacks.run(void 0,this),this._initializerCallbacks.reset(),this._finalizerCallbacks.reset(),o.triggerMethod.call(this,"stop"))},addDefinition:function(e,t){this._runModuleDefinition(e,t)},_runModuleDefinition:function(e,n){if(e){var r=i.flatten([this,this.app,t,o,o.$,i,n]);e.apply(this,r)}},_setupInitializersAndFinalizers:function(){this._initializerCallbacks=new o.Callbacks,this._finalizerCallbacks=new o.Callbacks}}),i.extend(o.Module,{create:function(e,t,r){var o=e,s=n(arguments);s.splice(0,3),t=t.split(".");var h=t.length,a=[];return a[h-1]=r,i.each(t,function(t,i){var n=o;o=this._getModule(n,t,e),this._addModuleDefinition(n,o,a[i],s)},this),o},_getModule:function(e,t,i){var n=e[t];return n||(n=new o.Module(t,i),e[t]=n,e.submodules[t]=n),n},_addModuleDefinition:function(e,t,n,r){var o,s;i.isFunction(n)?(o=n,s=!0):i.isObject(n)?(o=n.define,s=n.startWithParent):s=!0,o&&t.addDefinition(o,r),t.startWithParent=t.startWithParent&&s,t.startWithParent&&!t.startWithParentIsConfigured&&(t.startWithParentIsConfigured=!0,e.addInitializer(function(e){t.startWithParent&&t.start(e)}))}}),o}(this,Backbone,_); +//@ sourceMappingURL=backbone.marionette.map \ No newline at end of file diff --git a/ajax/libs/backbone.marionette/package.json b/ajax/libs/backbone.marionette/package.json index 443b3b904b5694..cc1907a96581dc 100644 --- a/ajax/libs/backbone.marionette/package.json +++ b/ajax/libs/backbone.marionette/package.json @@ -1,7 +1,7 @@ { "name": "backbone.marionette", "filename": "backbone.marionette.min.js", - "version": "1.0.0-rc6-bundled", + "version": "1.0.1-bundled", "description": "Make your Backbone.js apps dance with a composite application architecture!", "homepage": "http://github.com/marionettejs/backbone.marionette", "keywords": [