backbone.babysitter
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "backbone.babysitter", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"homepage": "https://github.com/marionettejs/backbone.babysitter", | ||
@@ -5,0 +5,0 @@ "authors": [ |
# Change log | ||
### v0.1.4 | ||
* Update UMD Wrapper and build process | ||
### v0.1.2 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "backbone.babysitter", | ||
"description": "Manage child views in a Backbone.View", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"repo": "marionettejs/backbone.babysitter", | ||
@@ -6,0 +6,0 @@ "main": "lib/backbone.babysitter.js", |
@@ -26,4 +26,4 @@ /*global module:false*/ | ||
preprocess: { | ||
core_build: { | ||
src: 'src/childviewcontainer.js', | ||
umd: { | ||
src: 'src/build/backbone.babysitter.js', | ||
dest: 'lib/backbone.babysitter.js' | ||
@@ -39,5 +39,5 @@ } | ||
}, | ||
core: { | ||
src: '<%= preprocess.core_build.dest %>', | ||
dest: '<%= preprocess.core_build.dest %>' | ||
umd: { | ||
src: '<%= preprocess.umd.dest %>', | ||
dest: '<%= preprocess.umd.dest %>' | ||
} | ||
@@ -50,5 +50,5 @@ }, | ||
}, | ||
core: { | ||
src: 'lib/backbone.babysitter.js', | ||
dest: 'lib/backbone.babysitter.js' | ||
umd: { | ||
src: '<%= preprocess.umd.dest %>', | ||
dest: '<%= preprocess.umd.dest %>' | ||
} | ||
@@ -61,3 +61,3 @@ }, | ||
}, | ||
core : { | ||
umd : { | ||
src : 'lib/backbone.babysitter.js', | ||
@@ -64,0 +64,0 @@ dest : 'lib/backbone.babysitter.min.js', |
// Backbone.BabySitter | ||
// ------------------- | ||
// v0.1.3 | ||
// v0.1.4 | ||
// | ||
@@ -13,3 +13,3 @@ // Copyright (c)2014 Derick Bailey, Muted Solutions, LLC. | ||
if (typeof define === 'function' && define.amd) { | ||
define(['exports', 'backbone', 'underscore'], function(exports, Backbone, _) { | ||
define(['backbone', 'underscore'], function(Backbone, _) { | ||
return factory(Backbone, _); | ||
@@ -26,3 +26,3 @@ }); | ||
}(this, function(Backbone, _) { | ||
"use strict"; | ||
'use strict'; | ||
@@ -36,8 +36,8 @@ var previousChildViewContainer = Backbone.ChildViewContainer; | ||
// shut down child views. | ||
Backbone.ChildViewContainer = (function (Backbone, _) { | ||
// Container Constructor | ||
// --------------------- | ||
var Container = function(views){ | ||
@@ -48,11 +48,11 @@ this._views = {}; | ||
this._updateLength(); | ||
_.each(views, this.add, this); | ||
}; | ||
// Container Methods | ||
// ----------------- | ||
_.extend(Container.prototype, { | ||
// Add a view to this container. Stores the view | ||
@@ -64,6 +64,6 @@ // by `cid` and makes it searchable by the model | ||
var viewCid = view.cid; | ||
// store the view | ||
this._views[viewCid] = view; | ||
// index it by model | ||
@@ -73,3 +73,3 @@ if (view.model){ | ||
} | ||
// index by custom | ||
@@ -79,7 +79,7 @@ if (customIndex){ | ||
} | ||
this._updateLength(); | ||
return this; | ||
}, | ||
// Find a view by the model that was attached to | ||
@@ -90,3 +90,3 @@ // it. Uses the model's `cid` to find it. | ||
}, | ||
// Find a view by the `cid` of the model that was attached to | ||
@@ -99,3 +99,3 @@ // it. Uses the model's `cid` to find the view `cid` and | ||
}, | ||
// Find a view by a custom indexer. | ||
@@ -106,3 +106,3 @@ findByCustom: function(index){ | ||
}, | ||
// Find by index. This is not guaranteed to be a | ||
@@ -113,3 +113,3 @@ // stable index. | ||
}, | ||
// retrieve a view by its `cid` directly | ||
@@ -119,7 +119,7 @@ findByCid: function(cid){ | ||
}, | ||
// Remove a view | ||
remove: function(view){ | ||
var viewCid = view.cid; | ||
// delete model index | ||
@@ -129,3 +129,3 @@ if (view.model){ | ||
} | ||
// delete custom index | ||
@@ -138,6 +138,6 @@ _.any(this._indexByCustom, function(cid, key) { | ||
}, this); | ||
// remove the view from the container | ||
delete this._views[viewCid]; | ||
// update the length | ||
@@ -147,3 +147,3 @@ this._updateLength(); | ||
}, | ||
// Call a method on every view in the container, | ||
@@ -155,3 +155,3 @@ // passing parameters to the call method one at a | ||
}, | ||
// Apply a method on every view in the container, | ||
@@ -167,3 +167,3 @@ // passing parameters to the call method one at a | ||
}, | ||
// Update the `.length` attribute on this container | ||
@@ -174,3 +174,3 @@ _updateLength: function(){ | ||
}); | ||
// Borrowing this code from Backbone.Collection: | ||
@@ -185,3 +185,3 @@ // http://backbonejs.org/docs/backbone.html#section-106 | ||
'last', 'without', 'isEmpty', 'pluck']; | ||
_.each(methods, function(method) { | ||
@@ -194,8 +194,9 @@ Container.prototype[method] = function() { | ||
}); | ||
// return the public API | ||
return Container; | ||
})(Backbone, _); | ||
Backbone.ChildViewContainer.VERSION = '0.1.3'; | ||
Backbone.ChildViewContainer.VERSION = '0.1.4'; | ||
@@ -202,0 +203,0 @@ Backbone.ChildViewContainer.noConflict = function () { |
// Backbone.BabySitter | ||
// ------------------- | ||
// v0.1.3 | ||
// v0.1.4 | ||
// | ||
@@ -10,3 +10,3 @@ // Copyright (c)2014 Derick Bailey, Muted Solutions, LLC. | ||
(function(i,e){if("function"==typeof define&&define.amd)define(["exports","backbone","underscore"],function(i,t,n){return e(t,n)});else if("undefined"!=typeof exports){var t=require("backbone"),n=require("underscore");module.exports=e(t,n)}else e(i.Backbone,i._)})(this,function(i,e){"use strict";var t=i.ChildViewContainer;return i.ChildViewContainer=function(i,e){var t=function(i){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),e.each(i,this.add,this)};e.extend(t.prototype,{add:function(i,e){var t=i.cid;return this._views[t]=i,i.model&&(this._indexByModel[i.model.cid]=t),e&&(this._indexByCustom[e]=t),this._updateLength(),this},findByModel:function(i){return this.findByModelCid(i.cid)},findByModelCid:function(i){var e=this._indexByModel[i];return this.findByCid(e)},findByCustom:function(i){var e=this._indexByCustom[i];return this.findByCid(e)},findByIndex:function(i){return e.values(this._views)[i]},findByCid:function(i){return this._views[i]},remove:function(i){var t=i.cid;return i.model&&delete this._indexByModel[i.model.cid],e.any(this._indexByCustom,function(i,e){return i===t?(delete this._indexByCustom[e],!0):void 0},this),delete this._views[t],this._updateLength(),this},call:function(i){this.apply(i,e.tail(arguments))},apply:function(i,t){e.each(this._views,function(n){e.isFunction(n[i])&&n[i].apply(n,t||[])})},_updateLength:function(){this.length=e.size(this._views)}});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 e.each(n,function(i){t.prototype[i]=function(){var t=e.values(this._views),n=[t].concat(e.toArray(arguments));return e[i].apply(e,n)}}),t}(i,e),i.ChildViewContainer.VERSION="0.1.3",i.ChildViewContainer.noConflict=function(){return i.ChildViewContainer=t,this},i.ChildViewContainer}); | ||
(function(i,e){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(i,t){return e(i,t)});else if("undefined"!=typeof exports){var t=require("backbone"),n=require("underscore");module.exports=e(t,n)}else e(i.Backbone,i._)})(this,function(i,e){"use strict";var t=i.ChildViewContainer;return i.ChildViewContainer=function(i,e){var t=function(i){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),e.each(i,this.add,this)};e.extend(t.prototype,{add:function(i,e){var t=i.cid;return this._views[t]=i,i.model&&(this._indexByModel[i.model.cid]=t),e&&(this._indexByCustom[e]=t),this._updateLength(),this},findByModel:function(i){return this.findByModelCid(i.cid)},findByModelCid:function(i){var e=this._indexByModel[i];return this.findByCid(e)},findByCustom:function(i){var e=this._indexByCustom[i];return this.findByCid(e)},findByIndex:function(i){return e.values(this._views)[i]},findByCid:function(i){return this._views[i]},remove:function(i){var t=i.cid;return i.model&&delete this._indexByModel[i.model.cid],e.any(this._indexByCustom,function(i,e){return i===t?(delete this._indexByCustom[e],!0):void 0},this),delete this._views[t],this._updateLength(),this},call:function(i){this.apply(i,e.tail(arguments))},apply:function(i,t){e.each(this._views,function(n){e.isFunction(n[i])&&n[i].apply(n,t||[])})},_updateLength:function(){this.length=e.size(this._views)}});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 e.each(n,function(i){t.prototype[i]=function(){var t=e.values(this._views),n=[t].concat(e.toArray(arguments));return e[i].apply(e,n)}}),t}(i,e),i.ChildViewContainer.VERSION="0.1.4",i.ChildViewContainer.noConflict=function(){return i.ChildViewContainer=t,this},i.ChildViewContainer}); | ||
//@ sourceMappingURL=backbone.babysitter.map |
{ | ||
"name": "backbone.babysitter", | ||
"description": "Manage child views in a Backbone.View", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"homepage": "https://github.com/marionettejs/backbone.babysitter", | ||
@@ -6,0 +6,0 @@ "main": "lib/backbone.babysitter.js", |
@@ -1,180 +0,150 @@ | ||
(function(root, factory) { | ||
// BabySitter.ChildViewContainer | ||
// ----------------------------- | ||
// | ||
// Provide a container to store, retrieve and | ||
// shut down child views. | ||
if (typeof define === 'function' && define.amd) { | ||
define(['exports', 'backbone', 'underscore'], function(exports, Backbone, _) { | ||
return factory(Backbone, _); | ||
}); | ||
} else if (typeof exports !== 'undefined') { | ||
var Backbone = require('backbone'); | ||
var _ = require('underscore'); | ||
module.exports = factory(Backbone, _); | ||
} else { | ||
factory(root.Backbone, root._); | ||
} | ||
Backbone.ChildViewContainer = (function (Backbone, _) { | ||
}(this, function(Backbone, _) { | ||
"use strict"; | ||
// Container Constructor | ||
// --------------------- | ||
var previousChildViewContainer = Backbone.ChildViewContainer; | ||
var Container = function(views){ | ||
this._views = {}; | ||
this._indexByModel = {}; | ||
this._indexByCustom = {}; | ||
this._updateLength(); | ||
// BabySitter.ChildViewContainer | ||
// ----------------------------- | ||
// | ||
// Provide a container to store, retrieve and | ||
// shut down child views. | ||
_.each(views, this.add, this); | ||
}; | ||
Backbone.ChildViewContainer = (function (Backbone, _) { | ||
// Container Methods | ||
// ----------------- | ||
// Container Constructor | ||
// --------------------- | ||
_.extend(Container.prototype, { | ||
var Container = function(views){ | ||
this._views = {}; | ||
this._indexByModel = {}; | ||
this._indexByCustom = {}; | ||
this._updateLength(); | ||
// Add a view to this container. Stores the view | ||
// by `cid` and makes it searchable by the model | ||
// cid (and model itself). Optionally specify | ||
// a custom key to store an retrieve the view. | ||
add: function(view, customIndex){ | ||
var viewCid = view.cid; | ||
_.each(views, this.add, this); | ||
}; | ||
// store the view | ||
this._views[viewCid] = view; | ||
// Container Methods | ||
// ----------------- | ||
// index it by model | ||
if (view.model){ | ||
this._indexByModel[view.model.cid] = viewCid; | ||
} | ||
_.extend(Container.prototype, { | ||
// index by custom | ||
if (customIndex){ | ||
this._indexByCustom[customIndex] = viewCid; | ||
} | ||
// Add a view to this container. Stores the view | ||
// by `cid` and makes it searchable by the model | ||
// cid (and model itself). Optionally specify | ||
// a custom key to store an retrieve the view. | ||
add: function(view, customIndex){ | ||
var viewCid = view.cid; | ||
this._updateLength(); | ||
return this; | ||
}, | ||
// store the view | ||
this._views[viewCid] = view; | ||
// Find a view by the model that was attached to | ||
// it. Uses the model's `cid` to find it. | ||
findByModel: function(model){ | ||
return this.findByModelCid(model.cid); | ||
}, | ||
// index it by model | ||
if (view.model){ | ||
this._indexByModel[view.model.cid] = viewCid; | ||
} | ||
// Find a view by the `cid` of the model that was attached to | ||
// it. Uses the model's `cid` to find the view `cid` and | ||
// retrieve the view using it. | ||
findByModelCid: function(modelCid){ | ||
var viewCid = this._indexByModel[modelCid]; | ||
return this.findByCid(viewCid); | ||
}, | ||
// index by custom | ||
if (customIndex){ | ||
this._indexByCustom[customIndex] = viewCid; | ||
} | ||
// Find a view by a custom indexer. | ||
findByCustom: function(index){ | ||
var viewCid = this._indexByCustom[index]; | ||
return this.findByCid(viewCid); | ||
}, | ||
this._updateLength(); | ||
return this; | ||
}, | ||
// Find by index. This is not guaranteed to be a | ||
// stable index. | ||
findByIndex: function(index){ | ||
return _.values(this._views)[index]; | ||
}, | ||
// Find a view by the model that was attached to | ||
// it. Uses the model's `cid` to find it. | ||
findByModel: function(model){ | ||
return this.findByModelCid(model.cid); | ||
}, | ||
// retrieve a view by its `cid` directly | ||
findByCid: function(cid){ | ||
return this._views[cid]; | ||
}, | ||
// Find a view by the `cid` of the model that was attached to | ||
// it. Uses the model's `cid` to find the view `cid` and | ||
// retrieve the view using it. | ||
findByModelCid: function(modelCid){ | ||
var viewCid = this._indexByModel[modelCid]; | ||
return this.findByCid(viewCid); | ||
}, | ||
// Remove a view | ||
remove: function(view){ | ||
var viewCid = view.cid; | ||
// Find a view by a custom indexer. | ||
findByCustom: function(index){ | ||
var viewCid = this._indexByCustom[index]; | ||
return this.findByCid(viewCid); | ||
}, | ||
// delete model index | ||
if (view.model){ | ||
delete this._indexByModel[view.model.cid]; | ||
} | ||
// Find by index. This is not guaranteed to be a | ||
// stable index. | ||
findByIndex: function(index){ | ||
return _.values(this._views)[index]; | ||
}, | ||
// retrieve a view by its `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 custom index | ||
_.any(this._indexByCustom, function(cid, key) { | ||
if (cid === viewCid) { | ||
delete this._indexByCustom[key]; | ||
return true; | ||
} | ||
}, this); | ||
// delete custom index | ||
_.any(this._indexByCustom, function(cid, key) { | ||
if (cid === viewCid) { | ||
delete this._indexByCustom[key]; | ||
return true; | ||
} | ||
}, this); | ||
// remove the view from the container | ||
delete this._views[viewCid]; | ||
// remove the view from the container | ||
delete this._views[viewCid]; | ||
// update the length | ||
this._updateLength(); | ||
return this; | ||
}, | ||
// update the length | ||
this._updateLength(); | ||
return this; | ||
}, | ||
// 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){ | ||
this.apply(method, _.tail(arguments)); | ||
}, | ||
// 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){ | ||
this.apply(method, _.tail(arguments)); | ||
}, | ||
// 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){ | ||
_.each(this._views, function(view){ | ||
if (_.isFunction(view[method])){ | ||
view[method].apply(view, 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){ | ||
_.each(this._views, function(view){ | ||
if (_.isFunction(view[method])){ | ||
view[method].apply(view, args || []); | ||
} | ||
}); | ||
}, | ||
// Update the `.length` attribute on this container | ||
_updateLength: function(){ | ||
this.length = _.size(this._views); | ||
} | ||
}); | ||
// Update the `.length` attribute on this container | ||
_updateLength: function(){ | ||
this.length = _.size(this._views); | ||
} | ||
}); | ||
// Borrowing this code from Backbone.Collection: | ||
// http://backbonejs.org/docs/backbone.html#section-106 | ||
// | ||
// 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', | ||
'last', 'without', 'isEmpty', 'pluck']; | ||
// Borrowing this code from Backbone.Collection: | ||
// http://backbonejs.org/docs/backbone.html#section-106 | ||
// | ||
// 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', | ||
'last', 'without', 'isEmpty', 'pluck']; | ||
_.each(methods, function(method) { | ||
Container.prototype[method] = function() { | ||
var views = _.values(this._views); | ||
var args = [views].concat(_.toArray(arguments)); | ||
return _[method].apply(_, args); | ||
}; | ||
}); | ||
_.each(methods, function(method) { | ||
Container.prototype[method] = function() { | ||
var views = _.values(this._views); | ||
var args = [views].concat(_.toArray(arguments)); | ||
return _[method].apply(_, args); | ||
}; | ||
}); | ||
// return the public API | ||
return Container; | ||
})(Backbone, _); | ||
Backbone.ChildViewContainer.VERSION = '<%= version %>'; | ||
Backbone.ChildViewContainer.noConflict = function () { | ||
Backbone.ChildViewContainer = previousChildViewContainer; | ||
return this; | ||
}; | ||
return Backbone.ChildViewContainer; | ||
})); | ||
// return the public API | ||
return Container; | ||
})(Backbone, _); |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
28
11660
514231
1