Skip to content

Commit

Permalink
Bump and build v2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
samccone committed Mar 1, 2015
1 parent 65f136b commit 2d37ba1
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 96 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/core/backbone.marionette.js",
"version": "2.4.0",
"version": "2.4.1",
"keywords": [
"backbone",
"framework",
Expand Down
14 changes: 14 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
### v2.4.1 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.4.0...v2.4.1)

#### Fixes

* Fixed a nasty bug where `reorderOnSort` when used on a `CompositeView` would not respect the `childViewContainer`.

#### General

* Add JSCS for style linting and consistency.

#### Docs

* Improve internal linking across docs, to make it easier for people to understand how pieces relate to each other.

### v2.4.0 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.3.2...v2.4.0)

#### 2.4 In Overview
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "backbone.marionette",
"description": "Make your Backbone.js apps dance!",
"version": "2.4.0",
"version": "2.4.1",
"repo": "marionettejs/backbone.marionette",
"main": "lib/core/backbone.marionette.js",
"keywords": [
Expand Down
96 changes: 54 additions & 42 deletions lib/backbone.marionette.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MarionetteJS (Backbone.Marionette)
// ----------------------------------
// v2.4.0
// v2.4.1
//
// Copyright (c)2015 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
Expand Down Expand Up @@ -494,7 +494,7 @@

var Marionette = Backbone.Marionette = {};

Marionette.VERSION = '2.4.0';
Marionette.VERSION = '2.4.1';

Marionette.noConflict = function() {
root.Marionette = previousMarionette;
Expand Down Expand Up @@ -606,8 +606,7 @@
_.each(hash, function(val, key) {
if (_.isString(val)) {
hash[key] = Marionette.normalizeUIString(val, ui);
}
else if (_.isObject(val) && _.isArray(properties)) {
} else if (_.isObject(val) && _.isArray(properties)) {
_.extend(val, Marionette.normalizeUIValues(_.pick(val, properties), ui));
/* Value is an object, and we got an array of embedded property names to normalize. */
_.each(properties, function(property) {
Expand Down Expand Up @@ -663,7 +662,6 @@
// Trigger Method
// --------------


Marionette._triggerMethod = (function() {
// split the event name on the ":"
var splitter = /(^|:)(\w)/gi;
Expand Down Expand Up @@ -823,7 +821,6 @@
target.stopListening(entity, evt, method);
}


// generic looping function
function iterateEvents(target, entity, bindings, functionCallback, stringCallback) {
if (!entity || !bindings) { return; }
Expand Down Expand Up @@ -935,7 +932,7 @@
this._callbacks.push({cb: callback, ctx: contextOverride});

promise.then(function(args) {
if (contextOverride){ args.context = contextOverride; }
if (contextOverride) { args.context = contextOverride; }
callback.call(args.context, args.options);
});
},
Expand Down Expand Up @@ -1061,7 +1058,7 @@
// http://lostechies.com/derickbailey/2011/12/12/composite-js-apps-regions-and-region-managers/

Marionette.Region = Marionette.Object.extend({
constructor: function (options) {
constructor: function(options) {

// set options temporarily so that we can get `el`.
// options will be overriden by Object.constructor
Expand Down Expand Up @@ -1091,7 +1088,7 @@
// 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){
show: function(view, options) {
if (!this._ensureElement()) {
return;
}
Expand Down Expand Up @@ -1207,7 +1204,7 @@
return _.union([view], _.result(view, '_getNestedViews') || []);
},

_ensureElement: function(){
_ensureElement: function() {
if (!_.isObject(this.el)) {
this.$el = this.getEl(this.el);
this.el = this.$el[0];
Expand Down Expand Up @@ -1369,7 +1366,7 @@

// Build the region from a string selector like '#foo-region'
_buildRegionFromSelector: function(selector, DefaultRegionClass) {
return new DefaultRegionClass({ el: selector });
return new DefaultRegionClass({el: selector});
},

// Build the region from a configuration object
Expand Down Expand Up @@ -1454,7 +1451,7 @@

// Gets all the regions contained within
// the `regionManager` instance.
getRegions: function(){
getRegions: function() {
return _.clone(this._regions);
},

Expand Down Expand Up @@ -1676,7 +1673,7 @@

// Serialize a model by returning its attributes. Clones
// the attributes to allow modification.
serializeModel: function(model){
serializeModel: function(model) {
return model.toJSON.apply(model, _.rest(arguments));
},

Expand Down Expand Up @@ -1744,7 +1741,7 @@

// normalize ui keys
events = this.normalizeUIKeys(events);
if(_.isUndefined(eventsArg)) {this.events = events;}
if (_.isUndefined(eventsArg)) {this.events = events;}

var combinedEvents = {};

Expand Down Expand Up @@ -2029,7 +2026,7 @@
// the resulting data. If both are found, defaults to the model.
// You can override the `serializeData` method in your own view definition,
// to provide custom serialization for your view's data.
serializeData: function(){
serializeData: function() {
if (!this.model && !this.collection) {
return {};
}
Expand All @@ -2049,7 +2046,7 @@
},

// Serialize a collection by serializing each of its models.
serializeCollection: function(collection){
serializeCollection: function(collection) {
return collection.toJSON.apply(collection, _.rest(arguments));
},

Expand Down Expand Up @@ -2143,7 +2140,7 @@
//
// option to pass `{comparator: compFunction()}` to allow the `CollectionView`
// to use a custom sort order for the collection.
constructor: function(options){
constructor: function(options) {

this.once('render', this._initialEvents);
this._initChildViewStorage();
Expand Down Expand Up @@ -2254,10 +2251,10 @@
// do not use their index, you can pass reorderOnSort: true
// to only reorder the DOM after a sort instead of rendering
// all the collectionView
reorder: function () {
reorder: function() {
var children = this.children;
var models = this._filteredSortedModels();
var modelsChanged = _.find(models, function (model) {
var modelsChanged = _.find(models, function(model) {
return !children.findByModel(model);
});

Expand All @@ -2268,14 +2265,14 @@
this.render();
} else {
// get the DOM nodes in the same order as the models
var els = _.map(models, function (model) {
var els = _.map(models, function(model) {
return children.findByModel(model).el;
});

// since append moves elements that are already in the DOM,
// appending the elements will effectively reorder them
this.triggerMethod('before:reorder');
this.$el.append(els);
this._appendReorderedChildren(els);
this.triggerMethod('reorder');
}
},
Expand All @@ -2298,7 +2295,7 @@
var models = this._filteredSortedModels();

// check for any changes in sort order of views
var orderChanged = _.find(models, function(item, index){
var orderChanged = _.find(models, function(item, index) {
var view = this.children.findByModel(item);
return !view || view._index !== index;
}, this);
Expand All @@ -2311,6 +2308,12 @@
// Internal reference to what index a `emptyView` is.
_emptyViewIndex: -1,

// Internal method. Separated so that CompositeView can append to the childViewContainer
// if necessary
_appendReorderedChildren: function(children) {
this.$el.append(children);
},

// Internal method. Separated so that CompositeView can have
// more control over events being triggered, around the rendering
// process
Expand Down Expand Up @@ -2363,7 +2366,7 @@

// Filter after sorting in case the filter uses the index
if (this.getOption('filter')) {
models = _.filter(models, function (model, index) {
models = _.filter(models, function(model, index) {
return this._shouldAddChild(model, index);
}, this);
}
Expand Down Expand Up @@ -2415,7 +2418,7 @@
var emptyViewOptions = this.getOption('emptyViewOptions') ||
this.getOption('childViewOptions');

if (_.isFunction(emptyViewOptions)){
if (_.isFunction(emptyViewOptions)) {
emptyViewOptions = emptyViewOptions.call(this, child, this._emptyViewIndex);
}

Expand Down Expand Up @@ -2499,14 +2502,13 @@
}

// update the indexes of views after this one
this.children.each(function (laterView) {
this.children.each(function(laterView) {
if (laterView._index >= view._index) {
laterView._index += increment ? 1 : -1;
}
});
},


// Internal Method. Add the view to children and render it at
// the given index.
_addChildView: function(view, index) {
Expand Down Expand Up @@ -2554,9 +2556,13 @@

if (view) {
this.triggerMethod('before:remove:child', view);

// call 'destroy' or 'remove', depending on which is found
if (view.destroy) { view.destroy(); }
else if (view.remove) { view.remove(); }
if (view.destroy) {
view.destroy();
} else if (view.remove) {
view.remove();
}

delete view._parent;
this.stopListening(view);
Expand Down Expand Up @@ -2605,12 +2611,11 @@
// in order to reduce the number of inserts into the
// document, which are expensive.
collectionView._bufferedChildren.splice(index, 0, childView);
}
else {
} else {
// If we've already rendered the main collection, append
// the new child into the correct order if we need to. Otherwise
// append to the end.
if (!collectionView._insertBefore(childView, index)){
if (!collectionView._insertBefore(childView, index)) {
collectionView._insertAfter(childView);
}
}
Expand All @@ -2623,7 +2628,7 @@
var findPosition = this.getOption('sort') && (index < this.children.length - 1);
if (findPosition) {
// Find the view after this one
currentView = this.children.find(function (view) {
currentView = this.children.find(function(view) {
return view._index === index + 1;
});
}
Expand Down Expand Up @@ -2674,7 +2679,7 @@
// 'child' is the given model
// 'index' is the index of that model in the collection
// 'collection' is the collection referenced by this CollectionView
_shouldAddChild: function (child, index) {
_shouldAddChild: function(child, index) {
var filter = this.getOption('filter');
return !_.isFunction(filter) || filter.call(this, child, index, this.collection);
},
Expand Down Expand Up @@ -2766,7 +2771,7 @@
serializeData: function() {
var data = {};

if (this.model){
if (this.model) {
data = _.partial(this.serializeModel, this.model).apply(this, arguments);
}

Expand Down Expand Up @@ -2843,11 +2848,19 @@
// Internal method. Append a view to the end of the $el.
// Overidden from CollectionView to ensure view is appended to
// childViewContainer
_insertAfter: function (childView) {
_insertAfter: function(childView) {
var $container = this.getChildViewContainer(this, childView);
$container.append(childView.el);
},

// Internal method. Append reordered childView'.
// Overidden from CollectionView to ensure reordered views
// are appended to childViewContainer
_appendReorderedChildren: function(children) {
var $container = this.getChildViewContainer(this);
$container.append(children);
},

// Internal method to ensure an `$childViewContainer` exists, for the
// `attachHtml` method to use.
getChildViewContainer: function(containerView, childView) {
Expand Down Expand Up @@ -2946,7 +2959,7 @@
if (this.isDestroyed) { return this; }
// #2134: remove parent element before destroying the child views, so
// removing the child views doesn't retrigger repaints
if(this.getOption('destroyImmediate') === true) {
if (this.getOption('destroyImmediate') === true) {
this.$el.remove();
}
this.regionManager.destroy();
Expand Down Expand Up @@ -2988,7 +3001,7 @@
},

// Get all regions
getRegions: function(){
getRegions: function() {
return this.regionManager.getRegions();
},

Expand Down Expand Up @@ -3114,7 +3127,7 @@
return this;
},

proxyViewProperties: function (view) {
proxyViewProperties: function(view) {
this.$el = view.$el;
this.el = view.el;
}
Expand Down Expand Up @@ -3164,7 +3177,6 @@
var _events = {};
var behaviorEvents = _.clone(_.result(b, 'events')) || {};


// Normalize behavior events hash to allow
// a user to use the @ui. syntax.
behaviorEvents = Marionette.normalizeUIKeys(behaviorEvents, getBehaviorsUI(b));
Expand All @@ -3177,8 +3189,8 @@
// the behavior index, and the behavior event index
// to generate a non colliding event namespace
// http://api.jquery.com/event.namespace/
var eventName = match[1] + '.' + [this.cid, i, j++, ' '].join(''),
selector = match[2];
var eventName = match[1] + '.' + [this.cid, i, j++, ' '].join('');
var selector = match[2];

var eventKey = eventName + selector;
var handler = _.isFunction(behaviour) ? behaviour : b[behaviour];
Expand Down Expand Up @@ -3453,7 +3465,7 @@
},

// Get all the regions from the region manager
getRegions: function(){
getRegions: function() {
return this._regionManager.getRegions();
},

Expand Down
1 change: 0 additions & 1 deletion lib/backbone.marionette.map

This file was deleted.

Loading

0 comments on commit 2d37ba1

Please sign in to comment.