From a2786fb2187529113441ac756db46329ae24c852 Mon Sep 17 00:00:00 2001 From: Andrew Humphreys Date: Mon, 21 Mar 2016 21:32:33 +0000 Subject: [PATCH 01/11] Move deps to peerDeps --- package.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e0e3010..179debc 100644 --- a/package.json +++ b/package.json @@ -37,11 +37,12 @@ "url": "https://github.com/marionettejs/backbone.babysitter.git" }, "github": "https://github.com/marionettejs/backbone.babysitter", - "dependencies": { - "backbone": ">=0.9.9 <=1.3.x", + "peerDependencies": { + "backbone": ">=0.9.9 <=1.3.2", "underscore": ">=1.4.0 <=1.8.3" }, "devDependencies": { + "backbone": ">=0.9.9 <=1.3.2", "grunt": "0.4.4", "grunt-cli": "0.1.13", "grunt-contrib-concat": "0.1.2", @@ -51,6 +52,7 @@ "grunt-contrib-uglify": "1.0.1", "grunt-contrib-watch": "0.2.0", "grunt-preprocess": "4.0.0", - "grunt-template": "0.2.3" + "grunt-template": "0.2.3", + "underscore": ">=1.4.0 <=1.8.3" } } From 3f50fe5e0b7225039df363f5513f9d53da35ac99 Mon Sep 17 00:00:00 2001 From: Andrew Humphreys Date: Thu, 31 Mar 2016 23:31:04 +0100 Subject: [PATCH 02/11] Bump and Build 1.0.0-pre.1 --- lib/backbone.babysitter.js | 4 ++-- lib/backbone.babysitter.min.js | 4 ++-- lib/backbone.babysitter.min.js.map | 2 +- package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/backbone.babysitter.js b/lib/backbone.babysitter.js index 92db27b..6eb94c1 100644 --- a/lib/backbone.babysitter.js +++ b/lib/backbone.babysitter.js @@ -1,6 +1,6 @@ // Backbone.BabySitter // ------------------- -// v0.1.11 +// v1.0.0-pre.1 // // Copyright (c)2016 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license @@ -178,7 +178,7 @@ })(Backbone, _); - Backbone.ChildViewContainer.VERSION = '0.1.11'; + Backbone.ChildViewContainer.VERSION = '1.0.0-pre.1'; Backbone.ChildViewContainer.noConflict = function () { Backbone.ChildViewContainer = previousChildViewContainer; diff --git a/lib/backbone.babysitter.min.js b/lib/backbone.babysitter.min.js index d9db642..ffe8354 100644 --- a/lib/backbone.babysitter.min.js +++ b/lib/backbone.babysitter.min.js @@ -1,6 +1,6 @@ // Backbone.BabySitter // ------------------- -// v0.1.11 +// v1.0.0-pre.1 // // Copyright (c)2016 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license @@ -8,5 +8,5 @@ // http://github.com/marionettejs/backbone.babysitter -!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=a.ChildViewContainer;return a.ChildViewContainer=function(a,b){var c=function(a){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),b.each(a,this.add,this)};b.extend(c.prototype,{add:function(a,b){var c=a.cid;return this._views[c]=a,a.model&&(this._indexByModel[a.model.cid]=c),b&&(this._indexByCustom[b]=c),this._updateLength(),this},findByModel:function(a){return this.findByModelCid(a.cid)},findByModelCid:function(a){var b=this._indexByModel[a];return this.findByCid(b)},findByCustom:function(a){var b=this._indexByCustom[a];return this.findByCid(b)},findByIndex:function(a){return b.values(this._views)[a]},findByCid:function(a){return this._views[a]},remove:function(a){var c=a.cid;return a.model&&delete this._indexByModel[a.model.cid],b.any(this._indexByCustom,function(a,b){return a===c?(delete this._indexByCustom[b],!0):void 0},this),delete this._views[c],this._updateLength(),this},call:function(a){this.apply(a,b.tail(arguments))},apply:function(a,c){b.each(this._views,function(d){b.isFunction(d[a])&&d[a].apply(d,c||[])})},_updateLength:function(){this.length=b.size(this._views)}});var d=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"];return b.each(d,function(a){c.prototype[a]=function(){var c=b.values(this._views),d=[c].concat(b.toArray(arguments));return b[a].apply(b,d)}}),c}(a,b),a.ChildViewContainer.VERSION="0.1.11",a.ChildViewContainer.noConflict=function(){return a.ChildViewContainer=c,this},a.ChildViewContainer}); +!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=a.ChildViewContainer;return a.ChildViewContainer=function(a,b){var c=function(a){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),b.each(a,this.add,this)};b.extend(c.prototype,{add:function(a,b){var c=a.cid;return this._views[c]=a,a.model&&(this._indexByModel[a.model.cid]=c),b&&(this._indexByCustom[b]=c),this._updateLength(),this},findByModel:function(a){return this.findByModelCid(a.cid)},findByModelCid:function(a){var b=this._indexByModel[a];return this.findByCid(b)},findByCustom:function(a){var b=this._indexByCustom[a];return this.findByCid(b)},findByIndex:function(a){return b.values(this._views)[a]},findByCid:function(a){return this._views[a]},remove:function(a){var c=a.cid;return a.model&&delete this._indexByModel[a.model.cid],b.any(this._indexByCustom,function(a,b){return a===c?(delete this._indexByCustom[b],!0):void 0},this),delete this._views[c],this._updateLength(),this},call:function(a){this.apply(a,b.tail(arguments))},apply:function(a,c){b.each(this._views,function(d){b.isFunction(d[a])&&d[a].apply(d,c||[])})},_updateLength:function(){this.length=b.size(this._views)}});var d=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"];return b.each(d,function(a){c.prototype[a]=function(){var c=b.values(this._views),d=[c].concat(b.toArray(arguments));return b[a].apply(b,d)}}),c}(a,b),a.ChildViewContainer.VERSION="1.0.0-pre.1",a.ChildViewContainer.noConflict=function(){return a.ChildViewContainer=c,this},a.ChildViewContainer}); //# sourceMappingURL=backbone.babysitter.min.js.map \ No newline at end of file diff --git a/lib/backbone.babysitter.min.js.map b/lib/backbone.babysitter.min.js.map index 264d171..8751733 100644 --- a/lib/backbone.babysitter.min.js.map +++ b/lib/backbone.babysitter.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["backbone.babysitter.js"],"names":["root","factory","define","amd","Backbone","_","exports","require","module","this","previousChildViewContainer","ChildViewContainer","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","each","add","extend","prototype","view","customIndex","viewCid","cid","model","findByModel","findByModelCid","modelCid","findByCid","findByCustom","index","findByIndex","values","remove","any","key","call","method","apply","tail","arguments","args","isFunction","length","size","methods","concat","toArray","VERSION","noConflict"],"mappings":";;;;;;;;;;CASC,SAASA,EAAMC,GAEd,GAAsB,kBAAXC,SAAyBA,OAAOC,IACzCD,QAAQ,WAAY,cAAe,SAASE,EAAUC,GACpD,MAAOJ,GAAQG,EAAUC,SAEtB,IAAuB,mBAAZC,SAAyB,CACzC,GAAIF,GAAWG,QAAQ,YACnBF,EAAIE,QAAQ,aAChBC,QAAOF,QAAUL,EAAQG,EAAUC,OAEnCJ,GAAQD,EAAKI,SAAUJ,EAAKK,IAG9BI,KAAM,SAASL,EAAUC,GACzB,YAEA,IAAIK,GAA6BN,EAASO,kBAiK1C,OAzJAP,GAASO,mBAAqB,SAAWP,EAAUC,GAKjD,GAAIO,GAAY,SAASC,GACvBJ,KAAKK,UACLL,KAAKM,iBACLN,KAAKO,kBACLP,KAAKQ,gBAELZ,EAAEa,KAAKL,EAAOJ,KAAKU,IAAKV,MAM1BJ,GAAEe,OAAOR,EAAUS,WAMjBF,IAAK,SAASG,EAAMC,GAClB,GAAIC,GAAUF,EAAKG,GAgBnB,OAbAhB,MAAKK,OAAOU,GAAWF,EAGnBA,EAAKI,QACPjB,KAAKM,cAAcO,EAAKI,MAAMD,KAAOD,GAInCD,IACFd,KAAKO,eAAeO,GAAeC,GAGrCf,KAAKQ,gBACER,MAKTkB,YAAa,SAASD,GACpB,MAAOjB,MAAKmB,eAAeF,EAAMD,MAMnCG,eAAgB,SAASC,GACvB,GAAIL,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U,SAEtC9C,EAASO,mBAAmBwC,WAAa,WAEvC,MADA/C,GAASO,mBAAqBD,EACvBD,MAGFL,EAASO","file":"backbone.babysitter.min.js"} \ No newline at end of file +{"version":3,"sources":["backbone.babysitter.js"],"names":["root","factory","define","amd","Backbone","_","exports","require","module","this","previousChildViewContainer","ChildViewContainer","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","each","add","extend","prototype","view","customIndex","viewCid","cid","model","findByModel","findByModelCid","modelCid","findByCid","findByCustom","index","findByIndex","values","remove","any","key","call","method","apply","tail","arguments","args","isFunction","length","size","methods","concat","toArray","VERSION","noConflict"],"mappings":";;;;;;;;;;CASC,SAASA,EAAMC,GAEd,GAAsB,kBAAXC,SAAyBA,OAAOC,IACzCD,QAAQ,WAAY,cAAe,SAASE,EAAUC,GACpD,MAAOJ,GAAQG,EAAUC,SAEtB,IAAuB,mBAAZC,SAAyB,CACzC,GAAIF,GAAWG,QAAQ,YACnBF,EAAIE,QAAQ,aAChBC,QAAOF,QAAUL,EAAQG,EAAUC,OAEnCJ,GAAQD,EAAKI,SAAUJ,EAAKK,IAG9BI,KAAM,SAASL,EAAUC,GACzB,YAEA,IAAIK,GAA6BN,EAASO,kBAiK1C,OAzJAP,GAASO,mBAAqB,SAAWP,EAAUC,GAKjD,GAAIO,GAAY,SAASC,GACvBJ,KAAKK,UACLL,KAAKM,iBACLN,KAAKO,kBACLP,KAAKQ,gBAELZ,EAAEa,KAAKL,EAAOJ,KAAKU,IAAKV,MAM1BJ,GAAEe,OAAOR,EAAUS,WAMjBF,IAAK,SAASG,EAAMC,GAClB,GAAIC,GAAUF,EAAKG,GAgBnB,OAbAhB,MAAKK,OAAOU,GAAWF,EAGnBA,EAAKI,QACPjB,KAAKM,cAAcO,EAAKI,MAAMD,KAAOD,GAInCD,IACFd,KAAKO,eAAeO,GAAeC,GAGrCf,KAAKQ,gBACER,MAKTkB,YAAa,SAASD,GACpB,MAAOjB,MAAKmB,eAAeF,EAAMD,MAMnCG,eAAg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,EAASO,mBAAmBuC,QAAU,cAEtC9C,EAASO,mBAAmBwC,WAAa,WAEvC,MADA/C,GAASO,mBAAqBD,EACvBD,MAGFL,EAASO","file":"backbone.babysitter.min.js"} \ No newline at end of file diff --git a/package.json b/package.json index 179debc..5ec18bb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "backbone.babysitter", "description": "Manage child views in a Backbone.View", - "version": "0.1.12", + "version": "1.0.0-pre.1", "homepage": "https://github.com/marionettejs/backbone.babysitter", "main": "lib/backbone.babysitter.js", "keywords": [ From d0157994bae956989ef4d44081826f4412fc6765 Mon Sep 17 00:00:00 2001 From: Andrew Humphreys Date: Thu, 31 Mar 2016 23:35:07 +0100 Subject: [PATCH 03/11] Changelog update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc11ade..9afc7c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +### v1.0.0-pre.1 + +* Moved Backbone and Underscore to peerDependencies + ### v0.1.12 * Bump version range of backbone support. From ea8a1afd4c73c2b15381cdb7ed7d566522620bf3 Mon Sep 17 00:00:00 2001 From: Rafael De Leon Date: Wed, 13 Apr 2016 08:19:05 -0700 Subject: [PATCH 04/11] * spec clean up --- spec/javascripts/childviewContainer.spec.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/javascripts/childviewContainer.spec.js b/spec/javascripts/childviewContainer.spec.js index 9018440..eaa795d 100644 --- a/spec/javascripts/childviewContainer.spec.js +++ b/spec/javascripts/childviewContainer.spec.js @@ -8,7 +8,7 @@ describe("childview container", function(){ new Backbone.View(), new Backbone.View(), new Backbone.View() - ] + ]; container = new Backbone.ChildViewContainer(views); }); @@ -85,11 +85,11 @@ describe("childview container", function(){ }); describe("when removing a view", function(){ - var container, view, model, col, cust; + var container, view, model, cust; beforeEach(function(){ model = new Backbone.Model(); - cust = "custome indexer"; + cust = "custom indexer"; view = new Backbone.View({ model: model @@ -101,9 +101,9 @@ describe("childview container", function(){ container.remove(view); }); - it("should update the size of the chidren", function(){ + it("should update the size of the children", function(){ expect(container.length).toBe(0); - }) + }); it("should remove the index by model", function(){ var v = container.findByModel(model); @@ -230,7 +230,7 @@ describe("childview container", function(){ container = new Backbone.ChildViewContainer(); container.add(view); - container.each(function(v, k){ + container.each(function(v){ views.push(v); }); }); From 562189a07acd76a9dffc127c85c35755628bc1fd Mon Sep 17 00:00:00 2001 From: Rafael De Leon Date: Wed, 13 Apr 2016 08:25:11 -0700 Subject: [PATCH 05/11] Closes #66 * Lodash core update --- src/childviewcontainer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/childviewcontainer.js b/src/childviewcontainer.js index a72df18..28ae3dd 100644 --- a/src/childviewcontainer.js +++ b/src/childviewcontainer.js @@ -15,7 +15,7 @@ Backbone.ChildViewContainer = (function (Backbone, _) { this._indexByCustom = {}; this._updateLength(); - _.each(views, this.add, this); + _.each(views, _.bind(this.add, this)); }; // Container Methods @@ -88,12 +88,12 @@ Backbone.ChildViewContainer = (function (Backbone, _) { } // delete custom index - _.any(this._indexByCustom, function(cid, key) { + _.some(this._indexByCustom, _.bind(function(cid, key) { if (cid === viewCid) { delete this._indexByCustom[key]; return true; } - }, this); + }, this)); // remove the view from the container delete this._views[viewCid]; @@ -107,7 +107,7 @@ Backbone.ChildViewContainer = (function (Backbone, _) { // passing parameters to the call method one at a // time, like `function.call`. call: function(method){ - this.apply(method, _.tail(arguments)); + this.apply(method, _.toArray(arguments).slice(1)); }, // Apply a method on every view in the container, From c14c2f1cda26bd7ba5856e11b41b12a94d30949b Mon Sep 17 00:00:00 2001 From: Rafael De Leon Date: Wed, 13 Apr 2016 08:43:03 -0700 Subject: [PATCH 06/11] * Break up `add`and `_add`. Helps with adding views and updating length later --- src/childviewcontainer.js | 42 +++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/childviewcontainer.js b/src/childviewcontainer.js index 28ae3dd..024f7dd 100644 --- a/src/childviewcontainer.js +++ b/src/childviewcontainer.js @@ -28,23 +28,8 @@ Backbone.ChildViewContainer = (function (Backbone, _) { // cid (and model itself). Optionally specify // a custom key to store an retrieve the view. add: function(view, customIndex){ - var viewCid = view.cid; - - // store the view - this._views[viewCid] = view; - - // index it by model - if (view.model){ - this._indexByModel[view.model.cid] = viewCid; - } - - // index by custom - if (customIndex){ - this._indexByCustom[customIndex] = viewCid; - } - - this._updateLength(); - return this; + return this._add(view, customIndex) + ._updateLength(); }, // Find a view by the model that was attached to @@ -124,6 +109,29 @@ Backbone.ChildViewContainer = (function (Backbone, _) { // Update the `.length` attribute on this container _updateLength: function(){ this.length = _.size(this._views); + + return this; + }, + // To be used when avoiding call _updateLength + // When you are done adding all your new views + // call _updateLength + _add: function(view, customIndex){ + var viewCid = view.cid; + + // store the view + this._views[viewCid] = view; + + // index it by model + if (view.model){ + this._indexByModel[view.model.cid] = viewCid; + } + + // index by custom + if (customIndex){ + this._indexByCustom[customIndex] = viewCid; + } + + return this; } }); From bb4670cd30ca1fcc825e9043c5f52eb0d00bf154 Mon Sep 17 00:00:00 2001 From: Rafael De Leon Date: Wed, 13 Apr 2016 08:43:48 -0700 Subject: [PATCH 07/11] * Break up `remove` into `_remove`. Helps with removing views and updating length later --- src/childviewcontainer.js | 47 ++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/childviewcontainer.js b/src/childviewcontainer.js index 024f7dd..8ad1333 100644 --- a/src/childviewcontainer.js +++ b/src/childviewcontainer.js @@ -65,27 +65,8 @@ Backbone.ChildViewContainer = (function (Backbone, _) { // 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 - _.some(this._indexByCustom, _.bind(function(cid, key) { - if (cid === viewCid) { - delete this._indexByCustom[key]; - return true; - } - }, this)); - - // remove the view from the container - delete this._views[viewCid]; - - // update the length - this._updateLength(); - return this; + return this._remove(view) + ._updateLength(); }, // Call a method on every view in the container, @@ -131,6 +112,30 @@ Backbone.ChildViewContainer = (function (Backbone, _) { this._indexByCustom[customIndex] = viewCid; } + return this; + }, + // To be used when avoiding call _updateLength + // When you are done adding all your new views + // call _updateLength + _remove: function (view){ + var viewCid = view.cid; + + // delete model index + if (view.model){ + delete this._indexByModel[view.model.cid]; + } + + // delete custom index + _.some(this._indexByCustom, _.bind(function(cid, key) { + if (cid === viewCid) { + delete this._indexByCustom[key]; + return true; + } + }, this)); + + // remove the view from the container + delete this._views[viewCid]; + return this; } }); From 1bb7a597ea5c531ef76c7d2f801eb90496931c7f Mon Sep 17 00:00:00 2001 From: Rafael De Leon Date: Wed, 3 Aug 2016 15:01:00 -0700 Subject: [PATCH 08/11] Update devDependencies and peerDependencies to accepts Backbone 1.3.3. Sync lib with src. (#76) * * peerDependency accepts Backbone ^1.3.3 and underscore ^1.8.3 * devDependency accepts Backbone >=1.3.3 but <1.4.0 since we don't know if Backbone will introduce a breaking changes * * build to sync lib with source --- lib/backbone.babysitter.js | 93 +++++++++++++++++------------- lib/backbone.babysitter.min.js | 2 +- lib/backbone.babysitter.min.js.map | 2 +- package.json | 6 +- 4 files changed, 58 insertions(+), 45 deletions(-) diff --git a/lib/backbone.babysitter.js b/lib/backbone.babysitter.js index 6eb94c1..fe857d8 100644 --- a/lib/backbone.babysitter.js +++ b/lib/backbone.babysitter.js @@ -43,7 +43,7 @@ this._indexByCustom = {}; this._updateLength(); - _.each(views, this.add, this); + _.each(views, _.bind(this.add, this)); }; // Container Methods @@ -56,23 +56,8 @@ // cid (and model itself). Optionally specify // a custom key to store an retrieve the view. add: function(view, customIndex){ - var viewCid = view.cid; - - // store the view - this._views[viewCid] = view; - - // index it by model - if (view.model){ - this._indexByModel[view.model.cid] = viewCid; - } - - // index by custom - if (customIndex){ - this._indexByCustom[customIndex] = viewCid; - } - - this._updateLength(); - return this; + return this._add(view, customIndex) + ._updateLength(); }, // Find a view by the model that was attached to @@ -108,34 +93,15 @@ // 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); - - // remove the view from the container - delete this._views[viewCid]; - - // update the length - this._updateLength(); - return this; + return this._remove(view) + ._updateLength(); }, // 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)); + this.apply(method, _.toArray(arguments).slice(1)); }, // Apply a method on every view in the container, @@ -152,6 +118,53 @@ // Update the `.length` attribute on this container _updateLength: function(){ this.length = _.size(this._views); + + return this; + }, + // To be used when avoiding call _updateLength + // When you are done adding all your new views + // call _updateLength + _add: function(view, customIndex){ + var viewCid = view.cid; + + // store the view + this._views[viewCid] = view; + + // index it by model + if (view.model){ + this._indexByModel[view.model.cid] = viewCid; + } + + // index by custom + if (customIndex){ + this._indexByCustom[customIndex] = viewCid; + } + + return this; + }, + // To be used when avoiding call _updateLength + // When you are done adding all your new views + // call _updateLength + _remove: function (view){ + var viewCid = view.cid; + + // delete model index + if (view.model){ + delete this._indexByModel[view.model.cid]; + } + + // delete custom index + _.some(this._indexByCustom, _.bind(function(cid, key) { + if (cid === viewCid) { + delete this._indexByCustom[key]; + return true; + } + }, this)); + + // remove the view from the container + delete this._views[viewCid]; + + return this; } }); diff --git a/lib/backbone.babysitter.min.js b/lib/backbone.babysitter.min.js index ffe8354..28a82b0 100644 --- a/lib/backbone.babysitter.min.js +++ b/lib/backbone.babysitter.min.js @@ -8,5 +8,5 @@ // http://github.com/marionettejs/backbone.babysitter -!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=a.ChildViewContainer;return a.ChildViewContainer=function(a,b){var c=function(a){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),b.each(a,this.add,this)};b.extend(c.prototype,{add:function(a,b){var c=a.cid;return this._views[c]=a,a.model&&(this._indexByModel[a.model.cid]=c),b&&(this._indexByCustom[b]=c),this._updateLength(),this},findByModel:function(a){return this.findByModelCid(a.cid)},findByModelCid:function(a){var b=this._indexByModel[a];return this.findByCid(b)},findByCustom:function(a){var b=this._indexByCustom[a];return this.findByCid(b)},findByIndex:function(a){return b.values(this._views)[a]},findByCid:function(a){return this._views[a]},remove:function(a){var c=a.cid;return a.model&&delete this._indexByModel[a.model.cid],b.any(this._indexByCustom,function(a,b){return a===c?(delete this._indexByCustom[b],!0):void 0},this),delete this._views[c],this._updateLength(),this},call:function(a){this.apply(a,b.tail(arguments))},apply:function(a,c){b.each(this._views,function(d){b.isFunction(d[a])&&d[a].apply(d,c||[])})},_updateLength:function(){this.length=b.size(this._views)}});var d=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"];return b.each(d,function(a){c.prototype[a]=function(){var c=b.values(this._views),d=[c].concat(b.toArray(arguments));return b[a].apply(b,d)}}),c}(a,b),a.ChildViewContainer.VERSION="1.0.0-pre.1",a.ChildViewContainer.noConflict=function(){return a.ChildViewContainer=c,this},a.ChildViewContainer}); +!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=a.ChildViewContainer;return a.ChildViewContainer=function(a,b){var c=function(a){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),b.each(a,b.bind(this.add,this))};b.extend(c.prototype,{add:function(a,b){return this._add(a,b)._updateLength()},findByModel:function(a){return this.findByModelCid(a.cid)},findByModelCid:function(a){var b=this._indexByModel[a];return this.findByCid(b)},findByCustom:function(a){var b=this._indexByCustom[a];return this.findByCid(b)},findByIndex:function(a){return b.values(this._views)[a]},findByCid:function(a){return this._views[a]},remove:function(a){return this._remove(a)._updateLength()},call:function(a){this.apply(a,b.toArray(arguments).slice(1))},apply:function(a,c){b.each(this._views,function(d){b.isFunction(d[a])&&d[a].apply(d,c||[])})},_updateLength:function(){return this.length=b.size(this._views),this},_add:function(a,b){var c=a.cid;return this._views[c]=a,a.model&&(this._indexByModel[a.model.cid]=c),b&&(this._indexByCustom[b]=c),this},_remove:function(a){var c=a.cid;return a.model&&delete this._indexByModel[a.model.cid],b.some(this._indexByCustom,b.bind(function(a,b){return a===c?(delete this._indexByCustom[b],!0):void 0},this)),delete this._views[c],this}});var d=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"];return b.each(d,function(a){c.prototype[a]=function(){var c=b.values(this._views),d=[c].concat(b.toArray(arguments));return b[a].apply(b,d)}}),c}(a,b),a.ChildViewContainer.VERSION="1.0.0-pre.1",a.ChildViewContainer.noConflict=function(){return a.ChildViewContainer=c,this},a.ChildViewContainer}); //# sourceMappingURL=backbone.babysitter.min.js.map \ No newline at end of file diff --git a/lib/backbone.babysitter.min.js.map b/lib/backbone.babysitter.min.js.map index 8751733..3a85543 100644 --- a/lib/backbone.babysitter.min.js.map +++ b/lib/backbone.babysitter.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["backbone.babysitter.js"],"names":["root","factory","define","amd","Backbone","_","exports","require","module","this","previousChildViewContainer","ChildViewContainer","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","each","add","extend","prototype","view","customIndex","viewCid","cid","model","findByModel","findByModelCid","modelCid","findByCid","findByCustom","index","findByIndex","values","remove","any","key","call","method","apply","tail","arguments","args","isFunction","length","size","methods","concat","toArray","VERSION","noConflict"],"mappings":";;;;;;;;;;CASC,SAASA,EAAMC,GAEd,GAAsB,kBAAXC,SAAyBA,OAAOC,IACzCD,Q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,MAAKO,eAAeqB,IACpB,GAFT,QAIC5B,YAGIA,MAAKK,OAAOU,GAGnBf,KAAKQ,gBACER,MAMT6B,KAAM,SAASC,GACb9B,KAAK+B,MAAMD,EAAQlC,EAAEoC,KAAKC,aAM5BF,MAAO,SAASD,EAAQI,GACtBtC,EAAEa,KAAKT,KAAKK,OAAQ,SAASQ,GACvBjB,EAAEuC,WAAWtB,EAAKiB,KACpBjB,EAAKiB,GAAQC,MAAMlB,EAAMqB,UAM/B1B,cAAe,WACbR,KAAKoC,OAASxC,EAAEyC,KAAKrC,KAAKK,UAS9B,IAAIiC,IAAW,UAAW,OAAQ,MAAO,OAAQ,SAAU,SACzD,SAAU,SAAU,QAAS,MAAO,OAAQ,MAAO,UACnD,WAAY,SAAU,UAAW,QAAS,UAAW,OACrD,OAAQ,UAAW,UAAW,QAAS,SAWzC,OATA1C,GAAEa,KAAK6B,EAAS,SAASR,GACvB3B,EAAUS,UAAUkB,GAAU,WAC5B,GAAI1B,GAAQR,EAAE6B,OAAOzB,KAAKK,QACtB6B,GAAQ9B,GAAOmC,OAAO3C,EAAE4C,QAAQP,WACpC,OAAOrC,GAAEkC,GAAQC,MAAMnC,EAAGsC,MAKvB/B,GACNR,EAAUC,GAGbD,EAASO,mBAAmBuC,QAAU,cAEtC9C,EAASO,mBAAmBwC,WAAa,WAEvC,MADA/C,GAASO,mBAAqBD,EACvBD,MAGFL,EAASO","file":"backbone.babysitter.min.js"} \ No newline at end of file +{"version":3,"sources":["backbone.babysitter.js"],"names":["root","factory","define","amd","Backbone","_","exports","require","module","this","previousChildViewContainer","ChildViewContainer","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","each","bind","add","extend","prototype","view","customIndex","_add","findByModel","model","findByModelCid","cid","modelCid","viewCid","findByCid","findByCustom","index","findByIndex","values","remove","_remove","call","method","apply","toArray","arguments","slice","args","isFunction","length","size","some","key","methods","concat","VERSION","noConflict"],"mappings":";;;;;;;;;;CASC,SAASA,EAAMC,GAEd,GAAsB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B,UAM/B5B,cAAe,WAGb,MAFAR,MAAKsC,OAAS1C,EAAE2C,KAAKvC,KAAKK,QAEnBL,MAKTgB,KAAM,SAASF,EAAMC,GACnB,GAAIO,GAAUR,EAAKM,GAenB,OAZApB,MAAKK,OAAOiB,GAAWR,EAGnBA,EAAKI,QACPlB,KAAKM,cAAcQ,EAAKI,MAAME,KAAOE,GAInCP,IACFf,KAAKO,eAAeQ,GAAeO,GAG9BtB,MAKT6B,QAAS,SAAUf,GACjB,GAAIQ,GAAUR,EAAKM,GAkBnB,OAfIN,GAAKI,aACAlB,MAAKM,cAAcQ,EAAKI,MAAME,KAIvCxB,EAAE4C,KAAKxC,KAAKO,eAAgBX,EAAEc,KAAK,SAASU,EAAKqB,GAC/C,MAAIrB,KAAQE,SACHtB,MAAKO,eAAekC,IACpB,GAFT,QAICzC,aAGIA,MAAKK,OAAOiB,GAEZtB,OASX,IAAI0C,IAAW,UAAW,OAAQ,MAAO,OAAQ,SAAU,SACzD,SAAU,SAAU,QAAS,MAAO,OAAQ,MAAO,UACnD,WAAY,SAAU,UAAW,QAAS,UAAW,OACrD,OAAQ,UAAW,UAAW,QAAS,SAWzC,OATA9C,GAAEa,KAAKiC,EAAS,SAASX,GACvB5B,EAAUU,UAAUkB,GAAU,WAC5B,GAAI3B,GAAQR,EAAE+B,OAAO3B,KAAKK,QACtB+B,GAAQhC,GAAOuC,OAAO/C,EAAEqC,QAAQC,WACpC,OAAOtC,GAAEmC,GAAQC,MAAMpC,EAAGwC,MAKvBjC,GACNR,EAAUC,GAGbD,EAASO,mBAAmB0C,QAAU,cAEtCjD,EAASO,mBAAmB2C,WAAa,WAEvC,MADAlD,GAASO,mBAAqBD,EACvBD,MAGFL,EAASO","file":"backbone.babysitter.min.js"} \ No newline at end of file diff --git a/package.json b/package.json index 5ec18bb..ffa606d 100644 --- a/package.json +++ b/package.json @@ -38,11 +38,11 @@ }, "github": "https://github.com/marionettejs/backbone.babysitter", "peerDependencies": { - "backbone": ">=0.9.9 <=1.3.2", - "underscore": ">=1.4.0 <=1.8.3" + "backbone": "^1.3.3", + "underscore": "^1.8.3" }, "devDependencies": { - "backbone": ">=0.9.9 <=1.3.2", + "backbone": ">=1.3.3 <1.4.0", "grunt": "0.4.4", "grunt-cli": "0.1.13", "grunt-contrib-concat": "0.1.2", From 6de3c3a91b1f423c718901df9e4e74a5cbb029a1 Mon Sep 17 00:00:00 2001 From: Andrew Humphreys Date: Wed, 3 Aug 2016 23:48:49 +0100 Subject: [PATCH 09/11] Bump and build v1.0.0-pre.2 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9afc7c1..761ea98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +### v1.0.0-pre.2 + +* Updated Backbone and Underscore version ranges + ### v1.0.0-pre.1 * Moved Backbone and Underscore to peerDependencies From 301c550b82eda4f7fc8136b7f788ec453b1137e6 Mon Sep 17 00:00:00 2001 From: Andrew Humphreys Date: Wed, 3 Aug 2016 23:49:36 +0100 Subject: [PATCH 10/11] 1.0.0-pre.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ffa606d..4bd6e4d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "backbone.babysitter", "description": "Manage child views in a Backbone.View", - "version": "1.0.0-pre.1", + "version": "1.0.0-pre.2", "homepage": "https://github.com/marionettejs/backbone.babysitter", "main": "lib/backbone.babysitter.js", "keywords": [ From 5d5a70509e0ffc9ec9309470dc2b9b115183b5f4 Mon Sep 17 00:00:00 2001 From: Paul Falgout Date: Mon, 11 Mar 2019 15:43:57 +0900 Subject: [PATCH 11/11] Release v1.0.0 Long time coming --- CHANGELOG.md | 4 ++++ bower.json | 6 +++--- lib/backbone.babysitter.js | 6 +++--- lib/backbone.babysitter.map | 1 - lib/backbone.babysitter.min.js | 6 +++--- lib/backbone.babysitter.min.js.map | 2 +- package.json | 6 +++--- 7 files changed, 17 insertions(+), 14 deletions(-) delete mode 100644 lib/backbone.babysitter.map diff --git a/CHANGELOG.md b/CHANGELOG.md index 761ea98..c1ff740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +### v1.0.0 + +* Updated Backbone and Underscore version ranges again + ### v1.0.0-pre.2 * Updated Backbone and Underscore version ranges diff --git a/bower.json b/bower.json index 0d73887..52dd388 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "backbone.babysitter", - "version": "0.1.12", + "version": "1.0.0", "homepage": "https://github.com/marionettejs/backbone.babysitter", "authors": [ "Derick Bailey " @@ -17,8 +17,8 @@ "browser" ], "dependencies": { - "backbone": ">=0.9.9 <1.4", - "underscore": ">=1.4.0 <=1.8.3" + "backbone": ">=1.3.3", + "underscore": ">=1.8.3" }, "license": "MIT", "ignore": [ diff --git a/lib/backbone.babysitter.js b/lib/backbone.babysitter.js index fe857d8..fb0401d 100644 --- a/lib/backbone.babysitter.js +++ b/lib/backbone.babysitter.js @@ -1,8 +1,8 @@ // Backbone.BabySitter // ------------------- -// v1.0.0-pre.1 +// v1.0.0 // -// Copyright (c)2016 Derick Bailey, Muted Solutions, LLC. +// Copyright (c)2019 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license // // http://github.com/marionettejs/backbone.babysitter @@ -191,7 +191,7 @@ })(Backbone, _); - Backbone.ChildViewContainer.VERSION = '1.0.0-pre.1'; + Backbone.ChildViewContainer.VERSION = '1.0.0'; Backbone.ChildViewContainer.noConflict = function () { Backbone.ChildViewContainer = previousChildViewContainer; diff --git a/lib/backbone.babysitter.map b/lib/backbone.babysitter.map deleted file mode 100644 index cab6c38..0000000 --- a/lib/backbone.babysitter.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["?"],"names":["root","factory","define","amd","Backbone","_","exports","require","module","this","previousChildViewContainer","ChildViewContainer","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","each","add","extend","prototype","view","customIndex","viewCid","cid","model","findByModel","findByModelCid","modelCid","findByCid","findByCustom","index","findByIndex","values","remove","any","key","call","method","apply","tail","arguments","args","isFunction","length","size","methods","concat","toArray","VERSION","noConflict"],"mappings":"CASC,SAASA,EAAMC,GAEd,GAAsB,kBAAXC,SAAyBA,OAAOC,IACzCD,QAAQ,WAAY,cAAe,SAASE,EAAUC,GACpD,MAAOJ,GAAQG,EAAUC,SAEtB,IAAuB,mBAAZC,SAAyB,CACzC,GAAIF,GAAWG,QAAQ,YACnBF,EAAIE,QAAQ,aAChBC,QAAOF,QAAUL,EAAQG,EAAUC,OAEnCJ,GAAQD,EAAKI,SAAUJ,EAAKK,KAG9BI,KAAM,SAASL,EAAUC,GACzB,YAEA,IAAIK,GAA6BN,EAASO,kBAiK1C,OAzJAP,GAASO,mBAAqB,SAAWP,EAAUC,GAKjD,GAAIO,GAAY,SAASC,GACvBJ,KAAKK,UACLL,KAAKM,iBACLN,KAAKO,kBACLP,KAAKQ,gBAELZ,EAAEa,KAAKL,EAAOJ,KAAKU,IAAKV,MAM1BJ,GAAEe,OAAOR,EAAUS,WAMjBF,IAAK,SAASG,EAAMC,GAClB,GAAIC,GAAUF,EAAKG,GAgBnB,OAbAhB,MAAKK,OAAOU,GAAWF,EAGnBA,EAAKI,QACPjB,KAAKM,cAAcO,EAAKI,MAAMD,KAAOD,GAInCD,IACFd,KAAKO,eAAeO,GAAeC,GAGrCf,KAAKQ,gBACER,MAKTkB,YAAa,SAASD,GACpB,MAAOjB,MAAKmB,eAAeF,EAAMD,MAMnCG,eAAgB,SAASC,GACvB,GAAIL,GAAUf,KAAKM,cAAcc,EACjC,OAAOpB,MAAKqB,UAAUN,IAIxBO,aAAc,SAASC,GACrB,GAAIR,GAAUf,KAAKO,eAAegB,EAClC,OAAOvB,MAAKqB,UAAUN,IAKxBS,YAAa,SAASD,GACpB,MAAO3B,GAAE6B,OAAOzB,KAAKK,QAAQkB,IAI/BF,UAAW,SAASL,GAClB,MAAOhB,MAAKK,OAAOW,IAIrBU,OAAQ,SAASb,GACf,GAAIE,GAAUF,EAAKG,GAoBnB,OAjBIH,GAAKI,aACAjB,MAAKM,cAAcO,EAAKI,MAAMD,KAIvCpB,EAAE+B,IAAI3B,KAAKO,eAAgB,SAASS,EAAKY,GACvC,MAAIZ,KAAQD,SACHf,MAAKO,eAAeqB,IACpB,GAFT,QAIC5B,YAGIA,MAAKK,OAAOU,GAGnBf,KAAKQ,gBACER,MAMT6B,KAAM,SAASC,GACb9B,KAAK+B,MAAMD,EAAQlC,EAAEoC,KAAKC,aAM5BF,MAAO,SAASD,EAAQI,GACtBtC,EAAEa,KAAKT,KAAKK,OAAQ,SAASQ,GACvBjB,EAAEuC,WAAWtB,EAAKiB,KACpBjB,EAAKiB,GAAQC,MAAMlB,EAAMqB,UAM/B1B,cAAe,WACbR,KAAKoC,OAASxC,EAAEyC,KAAKrC,KAAKK,UAS9B,IAAIiC,IAAW,UAAW,OAAQ,MAAO,OAAQ,SAAU,SACzD,SAAU,SAAU,QAAS,MAAO,OAAQ,MAAO,UACnD,WAAY,SAAU,UAAW,QAAS,UAAW,OACrD,OAAQ,UAAW,UAAW,QAAS,SAWzC,OATA1C,GAAEa,KAAK6B,EAAS,SAASR,GACvB3B,EAAUS,UAAUkB,GAAU,WAC5B,GAAI1B,GAAQR,EAAE6B,OAAOzB,KAAKK,QACtB6B,GAAQ9B,GAAOmC,OAAO3C,EAAE4C,QAAQP,WACpC,OAAOrC,GAAEkC,GAAQC,MAAMnC,EAAGsC,MAKvB/B,GACNR,EAAUC,GAGbD,EAASO,mBAAmBuC,QAAU,SAEtC9C,EAASO,mBAAmBwC,WAAa,WAEvC,MADA/C,GAASO,mBAAqBD,EACvBD,MAGFL,EAASO","file":"lib/backbone.babysitter.min.js"} \ No newline at end of file diff --git a/lib/backbone.babysitter.min.js b/lib/backbone.babysitter.min.js index 28a82b0..b4ae39c 100644 --- a/lib/backbone.babysitter.min.js +++ b/lib/backbone.babysitter.min.js @@ -1,12 +1,12 @@ // Backbone.BabySitter // ------------------- -// v1.0.0-pre.1 +// v1.0.0 // -// Copyright (c)2016 Derick Bailey, Muted Solutions, LLC. +// Copyright (c)2019 Derick Bailey, Muted Solutions, LLC. // Distributed under MIT license // // http://github.com/marionettejs/backbone.babysitter -!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=a.ChildViewContainer;return a.ChildViewContainer=function(a,b){var c=function(a){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),b.each(a,b.bind(this.add,this))};b.extend(c.prototype,{add:function(a,b){return this._add(a,b)._updateLength()},findByModel:function(a){return this.findByModelCid(a.cid)},findByModelCid:function(a){var b=this._indexByModel[a];return this.findByCid(b)},findByCustom:function(a){var b=this._indexByCustom[a];return this.findByCid(b)},findByIndex:function(a){return b.values(this._views)[a]},findByCid:function(a){return this._views[a]},remove:function(a){return this._remove(a)._updateLength()},call:function(a){this.apply(a,b.toArray(arguments).slice(1))},apply:function(a,c){b.each(this._views,function(d){b.isFunction(d[a])&&d[a].apply(d,c||[])})},_updateLength:function(){return this.length=b.size(this._views),this},_add:function(a,b){var c=a.cid;return this._views[c]=a,a.model&&(this._indexByModel[a.model.cid]=c),b&&(this._indexByCustom[b]=c),this},_remove:function(a){var c=a.cid;return a.model&&delete this._indexByModel[a.model.cid],b.some(this._indexByCustom,b.bind(function(a,b){return a===c?(delete this._indexByCustom[b],!0):void 0},this)),delete this._views[c],this}});var d=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"];return b.each(d,function(a){c.prototype[a]=function(){var c=b.values(this._views),d=[c].concat(b.toArray(arguments));return b[a].apply(b,d)}}),c}(a,b),a.ChildViewContainer.VERSION="1.0.0-pre.1",a.ChildViewContainer.noConflict=function(){return a.ChildViewContainer=c,this},a.ChildViewContainer}); +!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=a.ChildViewContainer;return a.ChildViewContainer=function(a,b){var c=function(a){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),b.each(a,b.bind(this.add,this))};b.extend(c.prototype,{add:function(a,b){return this._add(a,b)._updateLength()},findByModel:function(a){return this.findByModelCid(a.cid)},findByModelCid:function(a){var b=this._indexByModel[a];return this.findByCid(b)},findByCustom:function(a){var b=this._indexByCustom[a];return this.findByCid(b)},findByIndex:function(a){return b.values(this._views)[a]},findByCid:function(a){return this._views[a]},remove:function(a){return this._remove(a)._updateLength()},call:function(a){this.apply(a,b.toArray(arguments).slice(1))},apply:function(a,c){b.each(this._views,function(d){b.isFunction(d[a])&&d[a].apply(d,c||[])})},_updateLength:function(){return this.length=b.size(this._views),this},_add:function(a,b){var c=a.cid;return this._views[c]=a,a.model&&(this._indexByModel[a.model.cid]=c),b&&(this._indexByCustom[b]=c),this},_remove:function(a){var c=a.cid;return a.model&&delete this._indexByModel[a.model.cid],b.some(this._indexByCustom,b.bind(function(a,b){if(a===c)return delete this._indexByCustom[b],!0},this)),delete this._views[c],this}});var d=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"];return b.each(d,function(a){c.prototype[a]=function(){var c=b.values(this._views),d=[c].concat(b.toArray(arguments));return b[a].apply(b,d)}}),c}(a,b),a.ChildViewContainer.VERSION="1.0.0",a.ChildViewContainer.noConflict=function(){return a.ChildViewContainer=c,this},a.ChildViewContainer}); //# sourceMappingURL=backbone.babysitter.min.js.map \ No newline at end of file diff --git a/lib/backbone.babysitter.min.js.map b/lib/backbone.babysitter.min.js.map index 3a85543..b680293 100644 --- a/lib/backbone.babysitter.min.js.map +++ b/lib/backbone.babysitter.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["backbone.babysitter.js"],"names":["root","factory","define","amd","Backbone","_","exports","require","module","this","previousChildViewContainer","ChildViewContainer","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","each","bind","add","extend","prototype","view","customIndex","_add","findByModel","model","findByModelCid","cid","modelCid","viewCid","findByCid","findByCustom","index","findByIndex","values","remove","_remove","call","method","apply","toArray","arguments","slice","args","isFunction","length","size","some","key","methods","concat","VERSION","noConflict"],"mappings":";;;;;;;;;;CASC,SAASA,EAAMC,GAEd,GAAsB,kBAAXC,SAAyBA,OAAOC,IACzCD,QAAQ,WAAY,cAAe,SAASE,EAAUC,GACpD,MAAOJ,GAAQG,EAAUC,SAEtB,IAAuB,mBAAZC,SAAyB,CACzC,GAAIF,GAAWG,QAAQ,YACnBF,EAAIE,QAAQ,aAChBC,QAAOF,QAAUL,EAAQG,EAAUC,OAEnCJ,GAAQD,EAAKI,SAAUJ,EAAKK,IAG9BI,KAAM,SAASL,EAAUC,GACzB,YAEA,IAAIK,GAA6BN,EAASO,kBA8K1C,OAtKAP,GAASO,mBAAqB,SAAWP,EAAUC,GAKjD,GAAIO,GAAY,SAASC,GACvBJ,KAAKK,UACLL,KAAKM,iBACLN,KAAKO,kBACLP,KAAKQ,gBAELZ,EAAEa,KAAKL,EAAOR,EAAEc,KAAKV,KAAKW,IAAKX,OAMjCJ,GAAEgB,OAAOT,EAAUU,WAMjBF,IAAK,SAASG,EAAMC,GAClB,MAAOf,MAAKgB,KAAKF,EAAMC,GACXP,iBAKdS,YAAa,SAASC,GACpB,MAAOlB,MAAKmB,eAAeD,EAAME,MAMnCD,eAAgB,SAASE,GACvB,GAAIC,GAAUtB,KAAKM,cAAce,EACjC,OAAOrB,MAAKuB,UAAUD,IAIxBE,aAAc,SAASC,GACrB,GAAIH,GAAUtB,KAAKO,eAAekB,EAClC,OAAOzB,MAAKuB,UAAUD,IAKx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B,GAAQhC,GAAOuC,OAAO/C,EAAEqC,QAAQC,WACpC,OAAOtC,GAAEmC,GAAQC,MAAMpC,EAAGwC,MAKvBjC,GACNR,EAAUC,GAGbD,EAASO,mBAAmB0C,QAAU,cAEtCjD,EAASO,mBAAmB2C,WAAa,WAEvC,MADAlD,GAASO,mBAAqBD,EACvBD,MAGFL,EAASO","file":"backbone.babysitter.min.js"} \ No newline at end of file +{"version":3,"sources":["backbone.babysitter.js"],"names":["root","factory","define","amd","Backbone","_","exports","require","module","this","previousChildViewContainer","ChildViewContainer","Container","views","_views","_indexByModel","_indexByCustom","_updateLength","each","bind","add","extend","prototype","view","customIndex","_add","findByModel","model","findByModelCid","cid","modelCid","viewCid","findByCid","findByCustom","index","findByIndex","values","remove","_remove","call","method","apply","toArray","arguments","slice","args","isFunction","length","size","some","key","methods","concat","VERSION","noConflict"],"mappings":";;;;;;;;;;CASC,SAASA,EAAMC,GAEd,GAAsB,kBAAXC,SAAyBA,OAAOC,IACzCD,QAAQ,WAAY,cAAe,SAASE,EAAUC,GACpD,MAAOJ,GAAQG,EAAUC,SAEtB,IAAuB,mBAAZC,SAAyB,CACzC,GAAIF,GAAWG,QAAQ,YACnBF,EAAIE,QAAQ,aAChBC,QAAOF,QAAUL,EAAQG,EAAUC,OAEnCJ,GAAQD,EAAKI,SAAUJ,EAAKK,IAG9BI,KAAM,SAASL,EAAUC,GACzB,YAEA,IAAIK,GAA6BN,EAASO,kBA8K1C,OAtKAP,GAASO,mBAAqB,SAAWP,EAAUC,GAKjD,GAAIO,GAAY,SAASC,GACvBJ,KAAKK,UACLL,KAAKM,iBACLN,KAAKO,kBACLP,KAAKQ,gBAELZ,EAAEa,KAAKL,EAAOR,EAAEc,KAAKV,KAAKW,IAAKX,OAMjCJ,GAAEgB,OAAOT,EAAUU,WAMjBF,IAAK,SAASG,EAAMC,GAClB,MAAOf,MAAKgB,KAAKF,EAAMC,GACXP,iBAKdS,YAAa,SAASC,GACpB,MAAOlB,MAAKmB,e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nD,WAAY,SAAU,UAAW,QAAS,UAAW,OACrD,OAAQ,UAAW,UAAW,QAAS,SAWzC,OATA9C,GAAEa,KAAKiC,EAAS,SAASX,GACvB5B,EAAUU,UAAUkB,GAAU,WAC5B,GAAI3B,GAAQR,EAAE+B,OAAO3B,KAAKK,QACtB+B,GAAQhC,GAAOuC,OAAO/C,EAAEqC,QAAQC,WACpC,OAAOtC,GAAEmC,GAAQC,MAAMpC,EAAGwC,MAKvBjC,GACNR,EAAUC,GAGbD,EAASO,mBAAmB0C,QAAU,QAEtCjD,EAASO,mBAAmB2C,WAAa,WAEvC,MADAlD,GAASO,mBAAqBD,EACvBD,MAGFL,EAASO","file":"backbone.babysitter.min.js"} \ No newline at end of file diff --git a/package.json b/package.json index 4bd6e4d..852d31f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "backbone.babysitter", "description": "Manage child views in a Backbone.View", - "version": "1.0.0-pre.2", + "version": "1.0.0", "homepage": "https://github.com/marionettejs/backbone.babysitter", "main": "lib/backbone.babysitter.js", "keywords": [ @@ -42,7 +42,7 @@ "underscore": "^1.8.3" }, "devDependencies": { - "backbone": ">=1.3.3 <1.4.0", + "backbone": ">=1.3.3", "grunt": "0.4.4", "grunt-cli": "0.1.13", "grunt-contrib-concat": "0.1.2", @@ -53,6 +53,6 @@ "grunt-contrib-watch": "0.2.0", "grunt-preprocess": "4.0.0", "grunt-template": "0.2.3", - "underscore": ">=1.4.0 <=1.8.3" + "underscore": ">=1.4.0 <=1.9.1" } }