Skip to content

Commit

Permalink
v1.5.0 bump and build
Browse files Browse the repository at this point in the history
  • Loading branch information
samccone committed Jan 14, 2014
1 parent 98400a7 commit 3b1426f
Show file tree
Hide file tree
Showing 37 changed files with 560 additions and 396 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!",
"url" : "http://marionettejs.org",
"main" : "./lib/backbone.marionette.js",
"version" : "1.4.1",
"version" : "1.5.0",

"keywords" : [
"backbone",
Expand Down
26 changes: 26 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
### v1.5.0 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v1.4.1...v1.5.0)
* Views
* View `options` can now be a [function](https://github.com/marionettejs/backbone.marionette/pull/819)
* `onDomRefresh` is now only called when said `view` is in the [DOM](https://github.com/marionettejs/backbone.marionette/pull/855)

*CollectionView/CompositeView
* `itemViewContainer` is now called with the correct [context](https://github.com/marionettejs/backbone.marionette/pull/841)
* Fix bug where reseting a `collection` within a `collectionView` would cause `onShow` and `onDomRefresh` to be called [incorrectly](https://github.com/marionettejs/backbone.marionette/pull/849) on the itemViews.
* `addItemView` now returns the `view` that was [added](https://github.com/marionettejs/backbone.marionette/pull/851)
* You can now specify an `itemEvents` hash or method which allows you to capture all bubbling itemEvents without having to [manually set bindings](https://github.com/marionettejs/backbone.marionette/pull/861).

```js
itemEvents: {
"render": function() {
console.log("an itemView has been rendered");
}
}
```

* Regions
* Region `close` event now passes the `view` being closed with the [event](https://github.com/marionettejs/backbone.marionette/pull/834).

* General
* Updated bower ignore folder
* Added an editor config file

### v1.4.1 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v1.4.0...v1.4.1)
* Views
* fix for inital view class options. Now retains set options at class instantiation
Expand Down
65 changes: 44 additions & 21 deletions lib/backbone.marionette.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// MarionetteJS (Backbone.Marionette)
// ----------------------------------
// v1.4.1
// v1.5.0
//
// Copyright (c)2013 Derick Bailey, Muted Solutions, LLC.
// Copyright (c)2014 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
//
// http://marionettejs.com
Expand Down Expand Up @@ -496,11 +496,11 @@ Marionette.getOption = function(target, optionName){
// `this.triggerMethod("foo")` will trigger the "foo" event and
// call the "onFoo" method.
//
// `this.triggerMethod("foo:bar") will trigger the "foo:bar" event and
// `this.triggerMethod("foo:bar")` will trigger the "foo:bar" event and
// call the "onFooBar" method.
Marionette.triggerMethod = (function(){

// split the event name on the :
// split the event name on the ":"
var splitter = /(^|:)(\w)/gi;

// take the event section ("section1:section2:section3")
Expand All @@ -509,7 +509,7 @@ Marionette.triggerMethod = (function(){
return eventName.toUpperCase();
}

// actual triggerMethod name
// actual triggerMethod implementation
var triggerMethod = function(event) {
// get the method name from the event name
var methodName = 'on' + event.replace(splitter, getEventName);
Expand Down Expand Up @@ -537,7 +537,7 @@ Marionette.triggerMethod = (function(){
// in the DOM, trigger a "dom:refresh" event every time it is
// re-rendered.

Marionette.MonitorDOMRefresh = (function(){
Marionette.MonitorDOMRefresh = (function(documentElement){
// track when the view has been shown in the DOM,
// using a Marionette.Region (or by other means of triggering "show")
function handleShow(view){
Expand All @@ -553,13 +553,17 @@ Marionette.MonitorDOMRefresh = (function(){

// Trigger the "dom:refresh" event and corresponding "onDomRefresh" method
function triggerDOMRefresh(view){
if (view._isShown && view._isRendered){
if (view._isShown && view._isRendered && isInDOM(view)){
if (_.isFunction(view.triggerMethod)){
view.triggerMethod("dom:refresh");
}
}
}

function isInDOM(view) {
return documentElement.contains(view.el);
}

// Export public API
return function(view){
view.listenTo(view, "show", function(){
Expand All @@ -570,7 +574,7 @@ Marionette.MonitorDOMRefresh = (function(){
handleRender(view);
});
};
})();
})(document.documentElement);


// Marionette.bindEntityEvents & unbindEntityEvents
Expand Down Expand Up @@ -909,7 +913,7 @@ _.extend(Marionette.Region.prototype, Backbone.Events, {
if (view.close) { view.close(); }
else if (view.remove) { view.remove(); }

Marionette.triggerMethod.call(this, "close");
Marionette.triggerMethod.call(this, "close", view);

delete this.currentView;
},
Expand Down Expand Up @@ -1052,9 +1056,9 @@ Marionette.RegionManager = (function(Marionette){
//
// Mix in methods from Underscore, for iteration, and other
// collection related features.
var methods = ['forEach', 'each', 'map', 'find', 'detect', 'filter',
'select', 'reject', 'every', 'all', 'some', 'any', 'include',
'contains', 'invoke', 'toArray', 'first', 'initial', 'rest',
var methods = ['forEach', 'each', 'map', 'find', 'detect', 'filter',
'select', 'reject', 'every', 'all', 'some', 'any', 'include',
'contains', 'invoke', 'toArray', 'first', 'initial', 'rest',
'last', 'without', 'isEmpty', 'pluck'];

_.each(methods, function(method) {
Expand All @@ -1079,7 +1083,7 @@ Marionette.TemplateCache = function(templateId){
};

// TemplateCache object-level methods. Manage the template
// caches from these method calls instead of creating
// caches from these method calls instead of creating
// your own TemplateCache instances
_.extend(Marionette.TemplateCache, {
templateCaches: {},
Expand All @@ -1102,7 +1106,7 @@ _.extend(Marionette.TemplateCache, {
// are specified, clears all templates:
// `clear()`
//
// If arguments are specified, clears each of the
// If arguments are specified, clears each of the
// specified templates from the cache:
// `clear("#t1", "#t2", "...")`
clear: function(){
Expand Down Expand Up @@ -1142,7 +1146,7 @@ _.extend(Marionette.TemplateCache.prototype, {
// Load a template from the DOM, by default. Override
// this method to provide your own template retrieval
// For asynchronous loading with AMD/RequireJS, consider
// using a template-loader plugin as described here:
// using a template-loader plugin as described here:
// https://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs
loadTemplate: function(templateId){
var template = Marionette.$(templateId).html();
Expand Down Expand Up @@ -1211,7 +1215,7 @@ Marionette.View = Backbone.View.extend({
// this is a backfill since backbone removed the assignment
// of this.options
// at some point however this may be removed
this.options = _.extend({}, this.options, options);
this.options = _.extend({}, _.result(this, 'options'), _.isFunction(options) ? options.call(this) : options);

// parses out the @ui DSL for events
this.events = this.normalizeUIKeys(_.result(this, 'events'));
Expand Down Expand Up @@ -1671,12 +1675,14 @@ Marionette.CollectionView = Marionette.View.extend({

// call the "show" method if the collection view
// has already been shown
if (this._isShown){
if (this._isShown && !this.isBuffering){
Marionette.triggerMethod.call(view, "show");
}

// this view was added
this.triggerMethod("after:item:added", view);

return view;
},

// Set up the child view event forwarding. Uses an "itemview:"
Expand All @@ -1688,13 +1694,30 @@ Marionette.CollectionView = Marionette.View.extend({
// prepending "itemview:" to the event name
this.listenTo(view, "all", function(){
var args = slice(arguments);
args[0] = prefix + ":" + args[0];
var rootEvent = args[0];
var itemEvents = this.getItemEvents();

args[0] = prefix + ":" + rootEvent;
args.splice(1, 0, view);

// call collectionView itemEvent if defined
if (typeof itemEvents !== "undefined" && _.isFunction(itemEvents[rootEvent])) {
itemEvents[rootEvent].apply(this, args);
}

Marionette.triggerMethod.apply(this, args);
}, this);
},

// returns the value of itemEvents depending on if a function
getItemEvents: function() {
if (_.isFunction(this.itemEvents)) {
return this.itemEvents.call(this);
}

return this.itemEvents;
},

// render the item view
renderItemView: function(view, index) {
view.render();
Expand Down Expand Up @@ -1928,7 +1951,7 @@ Marionette.CompositeView = Marionette.CollectionView.extend({
var itemViewContainer = Marionette.getOption(containerView, "itemViewContainer");
if (itemViewContainer){

var selector = _.isFunction(itemViewContainer) ? itemViewContainer() : itemViewContainer;
var selector = _.isFunction(itemViewContainer) ? itemViewContainer.call(this) : itemViewContainer;
container = containerView.$(selector);
if (container.length <= 0) {
throwError("The specified `itemViewContainer` was not found: " + containerView.itemViewContainer, "ItemViewContainerMissingError");
Expand Down Expand Up @@ -2092,7 +2115,7 @@ Marionette.Layout = Marionette.ItemView.extend({
//
// Configure an AppRouter with `appRoutes`.
//
// App routers can only take one `controller` object.
// 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
Expand All @@ -2104,7 +2127,7 @@ Marionette.AppRouter = Backbone.Router.extend({

constructor: function(options){
Backbone.Router.prototype.constructor.apply(this, slice(arguments));

this.options = options || {};

var appRoutes = Marionette.getOption(this, "appRoutes");
Expand Down
2 changes: 1 addition & 1 deletion lib/backbone.marionette.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/backbone.marionette.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 3b1426f

Please sign in to comment.