From f490f9e1f92b0aa427caef43d3591fc79b2188d0 Mon Sep 17 00:00:00 2001 From: Bart Wood Date: Mon, 1 Jun 2015 15:58:48 -0600 Subject: [PATCH] Cut 1.1.0 release --- Backbone.CollectionBinder.js | 6 +++--- Backbone.CollectionBinder.min.js | 6 +++--- Backbone.ModelBinder.js | 6 +++--- Backbone.ModelBinder.min.js | 6 +++--- README.md | 8 ++++++++ package.json | 2 +- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Backbone.CollectionBinder.js b/Backbone.CollectionBinder.js index d53d5ef..41482c7 100644 --- a/Backbone.CollectionBinder.js +++ b/Backbone.CollectionBinder.js @@ -1,5 +1,5 @@ -// Backbone.CollectionBinder v1.0.6 -// (c) 2014 Bart Wood +// Backbone.CollectionBinder v1.1.0 +// (c) 2015 Bart Wood // Distributed Under MIT License (function (factory) { @@ -48,7 +48,7 @@ Backbone.CollectionBinder.options = options; }; - Backbone.CollectionBinder.VERSION = '1.0.6'; + Backbone.CollectionBinder.VERSION = '1.1.0'; _.extend(Backbone.CollectionBinder.prototype, Backbone.Events, { bind: function(collection, parentEl){ diff --git a/Backbone.CollectionBinder.min.js b/Backbone.CollectionBinder.min.js index b17b563..8911b14 100644 --- a/Backbone.CollectionBinder.min.js +++ b/Backbone.CollectionBinder.min.js @@ -1,5 +1,5 @@ -// Backbone.CollectionBinder v1.0.5 -// (c) 2013 Bart Wood +// Backbone.CollectionBinder v1.1.0 +// (c) 2015 Bart Wood // Distributed Under MIT License -(function(e){if(typeof define==="function"&&define.amd){define(["underscore","jquery","backbone","Backbone.ModelBinder"],e)}else if(typeof module!=="undefined"&&module.exports){module.exports=e(require("underscore"),require("jquery"),require("backbone"))}else{e(_,$,Backbone)}})(function(e,t,n){if(!n){throw"Please include Backbone.js before Backbone.ModelBinder.js"}if(!n.ModelBinder){throw"Please include Backbone.ModelBinder.js before Backbone.CollectionBinder.js"}n.CollectionBinder=function(t,r){e.bindAll.apply(e,[this].concat(e.functions(this)));this._elManagers={};this._elManagerFactory=t;if(!this._elManagerFactory)throw"elManagerFactory must be defined.";this._elManagerFactory.trigger=this.trigger;this._options=e.extend({},n.CollectionBinder.options,r)};n.CollectionBinder.SetOptions=function(e){n.CollectionBinder.options=e};n.CollectionBinder.VERSION="1.0.6";e.extend(n.CollectionBinder.prototype,n.Events,{bind:function(e,t){this.unbind();if(!e)throw"collection must be defined";if(!t)throw"parentEl must be defined";this._collection=e;this._elManagerFactory._setParentEl(t);this._onCollectionReset();this._collection.on("add",this._onCollectionAdd,this);this._collection.on("remove",this._onCollectionRemove,this);this._collection.on("reset",this._onCollectionReset,this);this._collection.on("sort",this._onCollectionSort,this)},unbind:function(){if(this._collection!==undefined){this._collection.off("add",this._onCollectionAdd);this._collection.off("remove",this._onCollectionRemove);this._collection.off("reset",this._onCollectionReset);this._collection.off("sort",this._onCollectionSort)}this._removeAllElManagers()},getManagerForEl:function(t){var n,r,i=e.values(this._elManagers);for(n=0;n0},getModel:function(){return this._model},getEl:function(){return this._el}};e.extend(i,this);return i}});n.CollectionBinder.ViewManagerFactory=function(t){e.bindAll.apply(e,[this].concat(e.functions(this)));this._viewCreator=t;if(!e.isFunction(this._viewCreator))throw"viewCreator must be a valid function that accepts a model and returns a backbone view"};e.extend(n.CollectionBinder.ViewManagerFactory.prototype,{_setParentEl:function(e){this._parentEl=e},_getParentEl:function(){return this._parentEl},makeElManager:function(n){var r={_model:n,createEl:function(){this._view=this._viewCreator(n);t(this._parentEl).append(this._view.render(this._model).el);this.trigger("elCreated",this._model,this._view)},removeEl:function(){if(this._view.close!==undefined){this._view.close()}else{this._view.$el.remove();console&&console.log&&console.log("warning, you should implement a close() function for your view, you might end up with zombies")}this.trigger("elRemoved",this._model,this._view)},isElContained:function(e){return this._view.el===e||this._view.$el.has(e).length>0},getModel:function(){return this._model},getView:function(){return this._view},getEl:function(){return this._view.$el}};e.extend(r,this);return r}})}) \ No newline at end of file +!function(e){"function"==typeof define&&define.amd?define(["underscore","jquery","backbone","Backbone.ModelBinder"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("underscore"),require("jquery"),require("backbone")):e(_,$,Backbone)}(function(e,t,i){if(!i)throw"Please include Backbone.js before Backbone.ModelBinder.js";if(!i.ModelBinder)throw"Please include Backbone.ModelBinder.js before Backbone.CollectionBinder.js";i.CollectionBinder=function(t,n){if(e.bindAll.apply(e,[this].concat(e.functions(this))),this._elManagers={},this._elManagerFactory=t,!this._elManagerFactory)throw"elManagerFactory must be defined.";this._elManagerFactory.trigger=this.trigger,this._options=e.extend({},i.CollectionBinder.options,n)},i.CollectionBinder.SetOptions=function(e){i.CollectionBinder.options=e},i.CollectionBinder.VERSION="1.1.0",e.extend(i.CollectionBinder.prototype,i.Events,{bind:function(e,t){if(this.unbind(),!e)throw"collection must be defined";if(!t)throw"parentEl must be defined";this._collection=e,this._elManagerFactory._setParentEl(t),this._onCollectionReset(),this._collection.on("add",this._onCollectionAdd,this),this._collection.on("remove",this._onCollectionRemove,this),this._collection.on("reset",this._onCollectionReset,this),this._collection.on("sort",this._onCollectionSort,this)},unbind:function(){void 0!==this._collection&&(this._collection.off("add",this._onCollectionAdd),this._collection.off("remove",this._onCollectionRemove),this._collection.off("reset",this._onCollectionReset),this._collection.off("sort",this._onCollectionSort)),this._removeAllElManagers()},getManagerForEl:function(t){var i,n,o=e.values(this._elManagers);for(i=0;i0},getModel:function(){return this._model},getEl:function(){return this._el}};return e.extend(o,this),o}}),i.CollectionBinder.ViewManagerFactory=function(t){if(e.bindAll.apply(e,[this].concat(e.functions(this))),this._viewCreator=t,!e.isFunction(this._viewCreator))throw"viewCreator must be a valid function that accepts a model and returns a backbone view"},e.extend(i.CollectionBinder.ViewManagerFactory.prototype,{_setParentEl:function(e){this._parentEl=e},_getParentEl:function(){return this._parentEl},makeElManager:function(i){var n={_model:i,createEl:function(){this._view=this._viewCreator(i),this._view.render(this._model),t(this._parentEl).append(this._view.el),this.trigger("elCreated",this._model,this._view)},removeEl:function(){void 0!==this._view.close?this._view.close():(this._view.$el.remove(),console&&console.log&&console.log("warning, you should implement a close() function for your view, you might end up with zombies")),this.trigger("elRemoved",this._model,this._view)},isElContained:function(e){return this._view.el===e||this._view.$el.has(e).length>0},getModel:function(){return this._model},getView:function(){return this._view},getEl:function(){return this._view.$el}};return e.extend(n,this),n}})}); \ No newline at end of file diff --git a/Backbone.ModelBinder.js b/Backbone.ModelBinder.js index fcca22d..46ccc4d 100644 --- a/Backbone.ModelBinder.js +++ b/Backbone.ModelBinder.js @@ -1,5 +1,5 @@ -// Backbone.ModelBinder v1.0.6 -// (c) 2013 Bart Wood +// Backbone.ModelBinder v1.1.0 +// (c) 2015 Bart Wood // Distributed Under MIT License (function (factory) { @@ -33,7 +33,7 @@ }; // Current version of the library. - Backbone.ModelBinder.VERSION = '1.0.6'; + Backbone.ModelBinder.VERSION = '1.1.0'; Backbone.ModelBinder.Constants = {}; Backbone.ModelBinder.Constants.ModelToView = 'ModelToView'; Backbone.ModelBinder.Constants.ViewToModel = 'ViewToModel'; diff --git a/Backbone.ModelBinder.min.js b/Backbone.ModelBinder.min.js index 093d661..348e508 100644 --- a/Backbone.ModelBinder.min.js +++ b/Backbone.ModelBinder.min.js @@ -1,5 +1,5 @@ -// Backbone.ModelBinder v1.0.6 -// (c) 2014 Bart Wood +// Backbone.ModelBinder v1.1.0 +// (c) 2015 Bart Wood // Distributed Under MIT License -(function(e){if(typeof define==="function"&&define.amd){define(["underscore","jquery","backbone"],e)}else if(typeof module!=="undefined"&&module.exports){module.exports=e(require("underscore"),require("jquery"),require("backbone"))}else{e(_,jQuery,Backbone)}})(function(e,t,n){if(!n){throw"Please include Backbone.js before Backbone.ModelBinder.js"}n.ModelBinder=function(){e.bindAll.apply(e,[this].concat(e.functions(this)))};n.ModelBinder.SetOptions=function(e){n.ModelBinder.options=e};n.ModelBinder.VERSION="1.0.6";n.ModelBinder.Constants={};n.ModelBinder.Constants.ModelToView="ModelToView";n.ModelBinder.Constants.ViewToModel="ViewToModel";e.extend(n.ModelBinder.prototype,{bind:function(e,n,r,i){this.unbind();this._model=e;this._rootEl=n;this._setOptions(i);if(!this._model)this._throwException("model must be specified");if(!this._rootEl)this._throwException("rootEl must be specified");if(r){this._attributeBindings=t.extend(true,{},r);this._initializeAttributeBindings();this._initializeElBindings()}else{this._initializeDefaultBindings()}this._bindModelToView();this._bindViewToModel()},bindCustomTriggers:function(e,t,n,r,i){this._triggers=n;this.bind(e,t,r,i)},unbind:function(){this._unbindModelToView();this._unbindViewToModel();if(this._attributeBindings){delete this._attributeBindings;this._attributeBindings=undefined}},_setOptions:function(t){this._options=e.extend({boundAttribute:"name"},n.ModelBinder.options,t);if(!this._options["modelSetOptions"]){this._options["modelSetOptions"]={}}this._options["modelSetOptions"].changeSource="ModelBinder";if(!this._options["changeTriggers"]){this._options["changeTriggers"]={"":"change","[contenteditable]":"blur"}}if(!this._options["initialCopyDirection"]){this._options["initialCopyDirection"]=n.ModelBinder.Constants.ModelToView}},_initializeAttributeBindings:function(){var t,n,r,i,s;for(t in this._attributeBindings){n=this._attributeBindings[t];if(e.isString(n)){r={elementBindings:[{selector:n}]}}else if(e.isArray(n)){r={elementBindings:n}}else if(e.isObject(n)){r={elementBindings:[n]}}else{this._throwException("Unsupported type passed to Model Binder "+r)}for(i=0;i0;for(n=0;n0;for(i=0;i ## Release Notes / Versions +### v 1.1.0 June 1, 2015 +* Fixed createEl code not to require that Backbone.View#render returns this +* Don't sort elements on add event (only do so on sort) +* Fixed package.json to make NPM publishing possible (fixes #195) +* Use jQuery .on instead of .delegate for event binding (to move off of deprecated .delegate function) +* Use .prop("checked") instead of .attr("checked") (fixes #199) +* Fixed autoSort behavior to actually work when the collection changes + ### v 1.0.6 November 5, 2014 * Made the CollectionBinder loadable via AMD diff --git a/package.json b/package.json index a9c80c7..bcac15d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "backbone.modelbinder", "description": "Simple, flexible and powerful Model-View binding for Backbone.", - "version": "0.1.6", + "version": "1.1.0", "author": "Bart Wood", "bugs": { "url": "https://github.com/theironcook/Backbone.ModelBinder/issues"