Skip to content

Commit

Permalink
bump and build v1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
samccone committed Jan 31, 2014
1 parent 74af236 commit 3f59281
Show file tree
Hide file tree
Showing 36 changed files with 601 additions and 432 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description" : "Make your Backbone.js apps dance with a composite application architecture!",
"homepage" : "http://marionettejs.org",
"main" : ["./lib/backbone.marionette.js", "./lib/core/amd/backbone.marionette.js"],
"version" : "1.5.1",
"version" : "1.6.0",

"keywords" : [
"backbone",
Expand Down
19 changes: 19 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
### v1.6.0 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v1.5.1...v1.6.0)
* CompositeView
* add a `composite:collection:before:render` event

* CollectionView
* `checkEmpty` can now be overridden

* Modules
* `Modules` can now be created using the extend method, and then attached to an [Application](https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.application.module.md#extending-modules).

* General
* add a component.json file
* update bower.json
* add AMD build in bower.json

* Tests
* general clean up
* add sinon.js for test spys

### v1.5.1 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v1.5.0...v1.5.1)
* CollectionView/CompositeView
* Fix bug where `show` and `onDomRefresh` was not called on `itemViews` in certain [conditions](https://github.com/marionettejs/backbone.marionette/pull/866)
Expand Down
57 changes: 41 additions & 16 deletions lib/backbone.marionette.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MarionetteJS (Backbone.Marionette)
// ----------------------------------
// v1.5.1
// v1.6.0
//
// Copyright (c)2014 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
Expand Down Expand Up @@ -752,7 +752,6 @@ _.extend(Marionette.Controller.prototype, Backbone.Events, {

Marionette.Region = function(options){
this.options = options || {};

this.el = Marionette.getOption(this, "el");

if (!this.el){
Expand Down Expand Up @@ -788,7 +787,6 @@ _.extend(Marionette.Region, {
// ```
//
buildRegion: function(regionConfig, defaultRegionType){

var regionIsString = (typeof regionConfig === "string");
var regionSelectorIsString = (typeof regionConfig.selector === "string");
var regionTypeIsUndefined = (typeof regionConfig.regionType === "undefined");
Expand Down Expand Up @@ -842,7 +840,6 @@ _.extend(Marionette.Region, {
// 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(selector) {
var parentEl = regionConfig.parentEl;
if (_.isFunction(parentEl)){
Expand All @@ -868,11 +865,9 @@ _.extend(Marionette.Region.prototype, Backbone.Events, {
// `onShow` and `close` method on your view, just after showing
// or just before closing the view, respectively.
show: function(view){

this.ensureEl();

var isViewClosed = view.isClosed || _.isUndefined(view.$el);

var isDifferentView = view !== this.currentView;

if (isDifferentView) {
Expand Down Expand Up @@ -1605,7 +1600,7 @@ Marionette.CollectionView = Marionette.View.extend({
this.closeEmptyView();
this.closeChildren();

if (this.collection && this.collection.length > 0) {
if (!this.isEmpty(this.collection)) {
this.showCollection();
} else {
this.showEmptyView();
Expand Down Expand Up @@ -1772,11 +1767,15 @@ Marionette.CollectionView = Marionette.View.extend({
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){
// helper to check if the collection is empty
isEmpty: function(collection){
// check if we're empty now
return !this.collection || this.collection.length === 0;
},

// If empty, show the empty view
checkEmpty: function (){
if (this.isEmpty(this.collection)){
this.showEmptyView();
}
},
Expand Down Expand Up @@ -1917,6 +1916,7 @@ Marionette.CompositeView = Marionette.CollectionView.extend({

_renderChildren: function(){
if (this.isRendered){
this.triggerMethod("composite:collection:before:render");
Marionette.CollectionView.prototype._renderChildren.call(this);
this.triggerMethod("composite:collection:rendered");
}
Expand Down Expand Up @@ -2269,13 +2269,20 @@ _.extend(Marionette.Application.prototype, Backbone.Events, {

// Create a module, attached to the application
module: function(moduleNames, moduleDefinition){
var ModuleClass = Marionette.Module;

// Overwrite the module class if the user specifies one
if (moduleDefinition) {
ModuleClass = moduleDefinition.moduleClass || ModuleClass;
}

// 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);
return ModuleClass.create.apply(ModuleClass, args);
},

// Internal method to set up the region manager
Expand All @@ -2300,8 +2307,10 @@ Marionette.Application.extend = Marionette.extend;

// A simple module system, used to create privacy and encapsulation in
// Marionette applications
Marionette.Module = function(moduleName, app){
Marionette.Module = function(moduleName, app, options){
this.moduleName = moduleName;
this.options = _.extend({}, this.options, options);
this.initialize = options.initialize || this.initialize;

// store sub-modules
this.submodules = {};
Expand All @@ -2313,12 +2322,22 @@ Marionette.Module = function(moduleName, app){
this.startWithParent = true;

this.triggerMethod = Marionette.triggerMethod;

if (_.isFunction(this.initialize)){
this.initialize(this.options);
}
};

Marionette.Module.extend = Marionette.extend;

// 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, {

// Initialize is an empty function by default. Override it with your own
// initialization logic when extending Marionette.Module.
initialize: function(){},

// Initializer for a specific module. Initializers are run when the
// module's `start` method is called.
addInitializer: function(callback){
Expand Down Expand Up @@ -2433,7 +2452,7 @@ _.extend(Marionette.Module, {
// Loop through all the parts of the module definition
_.each(moduleNames, function(moduleName, i){
var parentModule = module;
module = this._getModule(parentModule, moduleName, app);
module = this._getModule(parentModule, moduleName, app, moduleDefinition);
this._addModuleDefinition(parentModule, module, moduleDefinitions[i], customArgs);
}, this);

Expand All @@ -2442,12 +2461,18 @@ _.extend(Marionette.Module, {
},

_getModule: function(parentModule, moduleName, app, def, args){
var ModuleClass = Marionette.Module;
var options = _.extend({}, def);
if (def) {
ModuleClass = def.moduleClass || ModuleClass;
}

// 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);
module = new ModuleClass(moduleName, app, options);
parentModule[moduleName] = module;
// store the module on the parent
parentModule.submodules[moduleName] = module;
Expand Down
2 changes: 1 addition & 1 deletion lib/backbone.marionette.map

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

57 changes: 41 additions & 16 deletions lib/core/amd/backbone.marionette.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MarionetteJS (Backbone.Marionette)
// ----------------------------------
// v1.5.1
// v1.6.0
//
// Copyright (c)2014 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
Expand Down Expand Up @@ -344,7 +344,6 @@ _.extend(Marionette.Controller.prototype, Backbone.Events, {

Marionette.Region = function(options){
this.options = options || {};

this.el = Marionette.getOption(this, "el");

if (!this.el){
Expand Down Expand Up @@ -380,7 +379,6 @@ _.extend(Marionette.Region, {
// ```
//
buildRegion: function(regionConfig, defaultRegionType){

var regionIsString = (typeof regionConfig === "string");
var regionSelectorIsString = (typeof regionConfig.selector === "string");
var regionTypeIsUndefined = (typeof regionConfig.regionType === "undefined");
Expand Down Expand Up @@ -434,7 +432,6 @@ _.extend(Marionette.Region, {
// 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(selector) {
var parentEl = regionConfig.parentEl;
if (_.isFunction(parentEl)){
Expand All @@ -460,11 +457,9 @@ _.extend(Marionette.Region.prototype, Backbone.Events, {
// `onShow` and `close` method on your view, just after showing
// or just before closing the view, respectively.
show: function(view){

this.ensureEl();

var isViewClosed = view.isClosed || _.isUndefined(view.$el);

var isDifferentView = view !== this.currentView;

if (isDifferentView) {
Expand Down Expand Up @@ -1197,7 +1192,7 @@ Marionette.CollectionView = Marionette.View.extend({
this.closeEmptyView();
this.closeChildren();

if (this.collection && this.collection.length > 0) {
if (!this.isEmpty(this.collection)) {
this.showCollection();
} else {
this.showEmptyView();
Expand Down Expand Up @@ -1364,11 +1359,15 @@ Marionette.CollectionView = Marionette.View.extend({
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){
// helper to check if the collection is empty
isEmpty: function(collection){
// check if we're empty now
return !this.collection || this.collection.length === 0;
},

// If empty, show the empty view
checkEmpty: function (){
if (this.isEmpty(this.collection)){
this.showEmptyView();
}
},
Expand Down Expand Up @@ -1509,6 +1508,7 @@ Marionette.CompositeView = Marionette.CollectionView.extend({

_renderChildren: function(){
if (this.isRendered){
this.triggerMethod("composite:collection:before:render");
Marionette.CollectionView.prototype._renderChildren.call(this);
this.triggerMethod("composite:collection:rendered");
}
Expand Down Expand Up @@ -1861,13 +1861,20 @@ _.extend(Marionette.Application.prototype, Backbone.Events, {

// Create a module, attached to the application
module: function(moduleNames, moduleDefinition){
var ModuleClass = Marionette.Module;

// Overwrite the module class if the user specifies one
if (moduleDefinition) {
ModuleClass = moduleDefinition.moduleClass || ModuleClass;
}

// 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);
return ModuleClass.create.apply(ModuleClass, args);
},

// Internal method to set up the region manager
Expand All @@ -1892,8 +1899,10 @@ Marionette.Application.extend = Marionette.extend;

// A simple module system, used to create privacy and encapsulation in
// Marionette applications
Marionette.Module = function(moduleName, app){
Marionette.Module = function(moduleName, app, options){
this.moduleName = moduleName;
this.options = _.extend({}, this.options, options);
this.initialize = options.initialize || this.initialize;

// store sub-modules
this.submodules = {};
Expand All @@ -1905,12 +1914,22 @@ Marionette.Module = function(moduleName, app){
this.startWithParent = true;

this.triggerMethod = Marionette.triggerMethod;

if (_.isFunction(this.initialize)){
this.initialize(this.options);
}
};

Marionette.Module.extend = Marionette.extend;

// 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, {

// Initialize is an empty function by default. Override it with your own
// initialization logic when extending Marionette.Module.
initialize: function(){},

// Initializer for a specific module. Initializers are run when the
// module's `start` method is called.
addInitializer: function(callback){
Expand Down Expand Up @@ -2025,7 +2044,7 @@ _.extend(Marionette.Module, {
// Loop through all the parts of the module definition
_.each(moduleNames, function(moduleName, i){
var parentModule = module;
module = this._getModule(parentModule, moduleName, app);
module = this._getModule(parentModule, moduleName, app, moduleDefinition);
this._addModuleDefinition(parentModule, module, moduleDefinitions[i], customArgs);
}, this);

Expand All @@ -2034,12 +2053,18 @@ _.extend(Marionette.Module, {
},

_getModule: function(parentModule, moduleName, app, def, args){
var ModuleClass = Marionette.Module;
var options = _.extend({}, def);
if (def) {
ModuleClass = def.moduleClass || ModuleClass;
}

// 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);
module = new ModuleClass(moduleName, app, options);
parentModule[moduleName] = module;
// store the module on the parent
parentModule.submodules[moduleName] = module;
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 3f59281

Please sign in to comment.