Skip to content

Commit

Permalink
build v1.0.0-beta5
Browse files Browse the repository at this point in the history
  • Loading branch information
Derick Bailey committed Nov 7, 2012
1 parent 004db5b commit 9d735b7
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 100 deletions.
64 changes: 41 additions & 23 deletions lib/amd/backbone.marionette.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Backbone.Marionette, v1.0.0-beta4
* Backbone.Marionette, v1.0.0-beta5
* Copyright (c)2012 Derick Bailey, Muted Solutions, LLC.
* Distributed under MIT license
* http://github.com/marionettejs/backbone.marionette
Expand Down Expand Up @@ -1750,21 +1750,27 @@
var length = moduleNames.length;
_.each(moduleNames, function(moduleName, i){
var isLastModuleInChain = (i === length-1);

var isFirstModuleInChain = (i === 0);
var module = that._getModuleDefinition(parentModule, moduleName, app);
module.config.options = that._getModuleOptions(parentModule, moduleDefinition);

// if it's the first module in the chain, configure it
// for auto-start, as specified by the options
// if this is the last module in the chain, then set up
// all of the module options from the configuration
if (isLastModuleInChain){
that._configureAutoStart(app, module);
module.config.options = that._getModuleOptions(module, parentModule, moduleDefinition);

// Only add a module definition and initializer when this is the last
// module in a "parent.child.grandchild" hierarchy of module names and
// when the module call has a definition function supplied
if (module.config.options.hasDefinition){
module.addDefinition(module.config.options.definition, customArgs);
}
}

// Only add a module definition and initializer when this is
// the last module in a "parent.child.grandchild" hierarchy of
// module names
if (isLastModuleInChain && module.config.options.hasDefinition){
module.addDefinition(module.config.options.definition, customArgs);
// if it's a top level module, and this is the only
// module in the chain, then this one gets configured
// to start with the parent app.
if (isFirstModuleInChain && isLastModuleInChain ){
that._configureStartWithApp(app, module);
}

// Reset the parent module so that the next child
Expand All @@ -1776,20 +1782,26 @@
return parentModule;
},

_configureAutoStart: function(app, module){
// Only add the initializer if it's the first module, and
// if it is set to auto-start, and if it has not yet been added
if (module.config.options.startWithParent && !module.config.autoStartConfigured){
// start the module when the app starts
app.addInitializer(function(options){
module.start(options);
});
// Only add the initializer if it is set to start with parent (the app),
// and if it has not yet been added
_configureStartWithApp: function(app, module){
// skip this if we have already configured the module to start w/ the app
if (module.config.startWithAppIsConfigured){
return;
}

// start the module when the app starts
app.addInitializer(function(options){
// but only if the module is configured to start w/ parent
if (module.config.options.startWithParent){
module.start(options);
}
});

// prevent this module from being configured for
// auto start again. the first time the module
// is defined, determines it's auto-start
module.config.autoStartConfigured = true;
module.config.startWithAppIsConfigured = true;
},

_getModuleDefinition: function(parentModule, moduleName, app){
Expand All @@ -1807,10 +1819,16 @@
return module;
},

_getModuleOptions: function(parentModule, moduleDefinition){
// default to starting the module with the app
_getModuleOptions: function(module, parentModule, moduleDefinition){
// default to starting the module with it's parent to whatever the
var startWithParent = true;
if (module.config.options && !module.config.options.startWithParent){
startWithParent = false;
}

// set up initial options for the module
var options = {
startWithParent: true,
startWithParent: startWithParent,
hasDefinition: !!moduleDefinition
};

Expand Down
4 changes: 2 additions & 2 deletions lib/amd/backbone.marionette.min.js

Large diffs are not rendered by default.

64 changes: 41 additions & 23 deletions lib/backbone.marionette.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Backbone.Marionette, v1.0.0-beta4
* Backbone.Marionette, v1.0.0-beta5
* Copyright (c)2012 Derick Bailey, Muted Solutions, LLC.
* Distributed under MIT license
* http://github.com/marionettejs/backbone.marionette
Expand Down Expand Up @@ -1734,21 +1734,27 @@ _.extend(Marionette.Module, {
var length = moduleNames.length;
_.each(moduleNames, function(moduleName, i){
var isLastModuleInChain = (i === length-1);

var isFirstModuleInChain = (i === 0);
var module = that._getModuleDefinition(parentModule, moduleName, app);
module.config.options = that._getModuleOptions(parentModule, moduleDefinition);

// if it's the first module in the chain, configure it
// for auto-start, as specified by the options
// if this is the last module in the chain, then set up
// all of the module options from the configuration
if (isLastModuleInChain){
that._configureAutoStart(app, module);
module.config.options = that._getModuleOptions(module, parentModule, moduleDefinition);

// Only add a module definition and initializer when this is the last
// module in a "parent.child.grandchild" hierarchy of module names and
// when the module call has a definition function supplied
if (module.config.options.hasDefinition){
module.addDefinition(module.config.options.definition, customArgs);
}
}

// Only add a module definition and initializer when this is
// the last module in a "parent.child.grandchild" hierarchy of
// module names
if (isLastModuleInChain && module.config.options.hasDefinition){
module.addDefinition(module.config.options.definition, customArgs);
// if it's a top level module, and this is the only
// module in the chain, then this one gets configured
// to start with the parent app.
if (isFirstModuleInChain && isLastModuleInChain ){
that._configureStartWithApp(app, module);
}

// Reset the parent module so that the next child
Expand All @@ -1760,20 +1766,26 @@ _.extend(Marionette.Module, {
return parentModule;
},

_configureAutoStart: function(app, module){
// Only add the initializer if it's the first module, and
// if it is set to auto-start, and if it has not yet been added
if (module.config.options.startWithParent && !module.config.autoStartConfigured){
// start the module when the app starts
app.addInitializer(function(options){
module.start(options);
});
// Only add the initializer if it is set to start with parent (the app),
// and if it has not yet been added
_configureStartWithApp: function(app, module){
// skip this if we have already configured the module to start w/ the app
if (module.config.startWithAppIsConfigured){
return;
}

// start the module when the app starts
app.addInitializer(function(options){
// but only if the module is configured to start w/ parent
if (module.config.options.startWithParent){
module.start(options);
}
});

// prevent this module from being configured for
// auto start again. the first time the module
// is defined, determines it's auto-start
module.config.autoStartConfigured = true;
module.config.startWithAppIsConfigured = true;
},

_getModuleDefinition: function(parentModule, moduleName, app){
Expand All @@ -1791,10 +1803,16 @@ _.extend(Marionette.Module, {
return module;
},

_getModuleOptions: function(parentModule, moduleDefinition){
// default to starting the module with the app
_getModuleOptions: function(module, parentModule, moduleDefinition){
// default to starting the module with it's parent to whatever the
var startWithParent = true;
if (module.config.options && !module.config.options.startWithParent){
startWithParent = false;
}

// set up initial options for the module
var options = {
startWithParent: true,
startWithParent: startWithParent,
hasDefinition: !!moduleDefinition
};

Expand Down
4 changes: 2 additions & 2 deletions lib/backbone.marionette.min.js

Large diffs are not rendered by default.

64 changes: 41 additions & 23 deletions lib/core/amd/backbone.marionette.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Backbone.Marionette, v1.0.0-beta4
* Backbone.Marionette, v1.0.0-beta5
* Copyright (c)2012 Derick Bailey, Muted Solutions, LLC.
* Distributed under MIT license
* http://github.com/marionettejs/backbone.marionette
Expand Down Expand Up @@ -1521,21 +1521,27 @@
var length = moduleNames.length;
_.each(moduleNames, function(moduleName, i){
var isLastModuleInChain = (i === length-1);

var isFirstModuleInChain = (i === 0);
var module = that._getModuleDefinition(parentModule, moduleName, app);
module.config.options = that._getModuleOptions(parentModule, moduleDefinition);

// if it's the first module in the chain, configure it
// for auto-start, as specified by the options
// if this is the last module in the chain, then set up
// all of the module options from the configuration
if (isLastModuleInChain){
that._configureAutoStart(app, module);
module.config.options = that._getModuleOptions(module, parentModule, moduleDefinition);

// Only add a module definition and initializer when this is the last
// module in a "parent.child.grandchild" hierarchy of module names and
// when the module call has a definition function supplied
if (module.config.options.hasDefinition){
module.addDefinition(module.config.options.definition, customArgs);
}
}

// Only add a module definition and initializer when this is
// the last module in a "parent.child.grandchild" hierarchy of
// module names
if (isLastModuleInChain && module.config.options.hasDefinition){
module.addDefinition(module.config.options.definition, customArgs);
// if it's a top level module, and this is the only
// module in the chain, then this one gets configured
// to start with the parent app.
if (isFirstModuleInChain && isLastModuleInChain ){
that._configureStartWithApp(app, module);
}

// Reset the parent module so that the next child
Expand All @@ -1547,20 +1553,26 @@
return parentModule;
},

_configureAutoStart: function(app, module){
// Only add the initializer if it's the first module, and
// if it is set to auto-start, and if it has not yet been added
if (module.config.options.startWithParent && !module.config.autoStartConfigured){
// start the module when the app starts
app.addInitializer(function(options){
module.start(options);
});
// Only add the initializer if it is set to start with parent (the app),
// and if it has not yet been added
_configureStartWithApp: function(app, module){
// skip this if we have already configured the module to start w/ the app
if (module.config.startWithAppIsConfigured){
return;
}

// start the module when the app starts
app.addInitializer(function(options){
// but only if the module is configured to start w/ parent
if (module.config.options.startWithParent){
module.start(options);
}
});

// prevent this module from being configured for
// auto start again. the first time the module
// is defined, determines it's auto-start
module.config.autoStartConfigured = true;
module.config.startWithAppIsConfigured = true;
},

_getModuleDefinition: function(parentModule, moduleName, app){
Expand All @@ -1578,10 +1590,16 @@
return module;
},

_getModuleOptions: function(parentModule, moduleDefinition){
// default to starting the module with the app
_getModuleOptions: function(module, parentModule, moduleDefinition){
// default to starting the module with it's parent to whatever the
var startWithParent = true;
if (module.config.options && !module.config.options.startWithParent){
startWithParent = false;
}

// set up initial options for the module
var options = {
startWithParent: true,
startWithParent: startWithParent,
hasDefinition: !!moduleDefinition
};

Expand Down
4 changes: 2 additions & 2 deletions lib/core/amd/backbone.marionette.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 9d735b7

Please sign in to comment.