From 631b9b2d75fef2de435603566f06a2b02909cfa6 Mon Sep 17 00:00:00 2001 From: Joe Hudson Date: Tue, 11 Nov 2014 08:58:01 -0500 Subject: [PATCH] v0.11.0 --- backbone-reaction.js | 2 +- backbone-reaction.min.js | 4 ++-- bower.json | 2 +- package.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backbone-reaction.js b/backbone-reaction.js index 6edb475..bf1c3ab 100644 --- a/backbone-reaction.js +++ b/backbone-reaction.js @@ -1,5 +1,5 @@ /*! - * backbone-reaction v0.10.1 + * backbone-reaction v0.11.0 * https://github.com/jhudson8/backbone-reaction * * Copyright (c) 2014 Joe Hudson diff --git a/backbone-reaction.min.js b/backbone-reaction.min.js index 34ca68a..b69e90a 100644 --- a/backbone-reaction.min.js +++ b/backbone-reaction.min.js @@ -1,4 +1,4 @@ /*! - * https://github.com/jhudson8/backbone-reaction v0.10.1; MIT license; Joe Hudson + * https://github.com/jhudson8/backbone-reaction v0.11.0; MIT license; Joe Hudson */ -!function(e){"function"==typeof define&&define.amd?define(["react","backbone","underscore"],e):"undefined"!=typeof exports&&"undefined"!=typeof require?module.exports=function(t,n){e(t,n,require("underscore"))}:e(React,Backbone,_)}(function(React,Backbone,_){!function(){function e(e){e=e||"_all";var n=d[e];return n||(n=function(n,i){"_all"!==e&&(options=i,i=n,n=e),t(this,i.model,i.options,i.method)},d[e]=n),n}function t(e,t,r,l){function d(a){var o=r[a];r[a]=function(r,s,l){if(a!==c||h.stop||(h.trigger("data",r,s,l,h),r=h.response||r,!h.preventDefault)){o&&o.call(this,r,s,l);var d=u.indexOf(h);d>=0&&u.splice(d,1),0===u.length&&(e[i]=void 0,e.trigger(n,h));var f=a===c?[a,t,h]:[a,t,r,s,l,h];h.trigger.apply(h,f),f.splice(0,0,"complete"),h.trigger.apply(h,f)}}}var u=e[i]=e[i]||[],f=r&&r.event||l,h=_.extend({},Backbone.Events);h.method=l,h.options=r,h.model=t,u.push(h);var m=a+":"+f;return e.trigger(a,f,h),e.trigger(m,h),e===t&&(o.trigger(a,f,e,h),o.trigger(m,e,h)),d(c),d(s),h}var n=Backbone.xhrCompleteEventName=Backbone.xhrCompleteEventName||"xhr:complete",i=Backbone.xhrModelLoadingAttribute=Backbone.xhrModelLoadingAttribute||"xhrActivity",a=Backbone.xhrEventName=Backbone.xhrEventName||"xhr",r=Backbone.xhrGlobalAttribute=Backbone.xhrGlobalAttribute||"xhrEvents",o=Backbone[r]=_.extend({},Backbone.Events),c="success",s="error",l=Backbone.sync;Backbone.sync=function(e,n,i){i=i||{},i.url||(i.url=_.result(n,"url"));var a=t(n,n,i,e),r=a.intercept;if(r){if(_.isFunction(r))return r(i);throw new Error("intercept must be function(options)")}return a.xhr=l.call(this,e,n,i),a.xhr},o.on(a+":read",function(e,t){t.on(c,function(){e.hasBeenFetched=!0,e.hadFetchError=!1}),t.on(s,function(){e.hadFetchError=!0})}),Backbone.forwardXhrEvents=function(t,n,i){var r=e(!_.isFunction(i)&&i);if(_.isFunction(i))try{t.on(a,r,n),i.call(this)}finally{t.off(a,r,n)}else{var o=i?a+":"+i:a;t.on(o,r,n)}},Backbone.stopXhrForwarding=function(t,n,i){var r=e(i);t.off(a,r,n)};var d={}}(),function(){function get(values,index,initiatedOnce,rtn){function addTo(name){var indexName=name,match=name.match(/^([^\(]*)\s*\(([^\)]*)\)\s*/),params=match&&match[2];if(name=match&&match[1]||name,!index[indexName]){params&&(params=eval("["+params+"]"));var mixin=React.mixins._mixins[name],checkAgain=!1,skip=!1;if(!mixin)throw new Error('invalid mixin "'+name+'"');if("function"==typeof mixin)React.mixins._initiatedOnce[name]?(initiatedOnce[name]=initiatedOnce[name]||[],initiatedOnce[name].push(params),skip=!0):(mixin=mixin.apply(this,params||[]),checkAgain=!0);else if(params)throw new Error('the mixin "'+name+'" does not support parameters');get(React.mixins._dependsOn[name],index,initiatedOnce,rtn),get(React.mixins._dependsInjected[name],index,initiatedOnce,rtn),index[indexName]=!0,checkAgain?get([mixin],index,initiatedOnce,rtn):skip||rtn.push(mixin)}}function handleMixin(e){e&&(Array.isArray(e)?get(e,index,initiatedOnce,rtn):"string"==typeof e?addTo(e):rtn.push(e))}if(Array.isArray(values))for(var i=0;i=0,u=s[c]),!u)throw'no callback function exists for "'+c+'"';c=function(){return u.apply(s,d?[]:arguments)}}var f=o.match(a);if(f){var h=f[1],m=f[2].split(/\s*,\s*/),v=f[3],p=React.events.specials[h];if(p)return 1===m.length&&""===m[0]&&(m=[]),c=p.call(s,c,m),e(v,c,s,!0);throw new Error('invalid special event handler "'+h+"'")}var g=o.match(i),x=g[1];path=g[2],handler=t[x];for(var _=0;!handler&&_0?Array.prototype.slice.call(arguments,0):void 0;return{getInitialState:function(){t=a(t||"loadOn",this,c+":{key}",function(t){var n=this.getModel();e({loading:n[l]},this),t.on("complete",function(){e({loading:!1},this)},this)});var n=this.getModel();if(n){var i,r=n.loading;if(r)for(var o=function(){e({loading:!1},this)},s=0;s=0)return i=t[d],r[s].on("complete",o,this),{loading:n[l]}}}return{}},loadWhile:function(t){function n(n){var a=t[n];t[n]=function(){e({loading:!1},i),a&&a.apply(this,arguments)}}t=t||{};var i=this;return n("error"),n("success"),e({loading:!0},this),t}}},"modelEventAware"),React.mixins.add("modelUpdateOn",function(){var e=arguments.length>0?Array.prototype.slice.call(arguments,0):void 0;return{getInitialState:function(){a(e||"updateOn",this,"{key}",function(){this.deferUpdate()})}}},"modelEventAware","deferUpdate"),React.events){React.events.mixin=React.events.mixin||Backbone.Events;var d=/^model(\[.+\])?$/;React.events.handle(d,function(e,t){var n=e.key.match(d),i=n[1]&&n[1].substring(1,n[1].length-1),a=i&&(this.props[i]||this.refs[i]);if(!a&&i)throw new Error('no model found with "'+i+'"');var r={model:a,event:e.path,callback:t};return{on:function(){this.modelOn(r)},off:function(){}}});var u=React.events.specials;if(u){var f=["memoize","delay","defer","throttle","debounce","once"];_.each(f,function(e){u[e]=u[e]||function(t,n){return n=o(n),n.splice(0,0,t),_[e].apply(_,n)}})}}var h=function(e,t,n,i){return React.createClass(_.extend({mixins:["modelValueAware"],render:function(){var i={},a=this.getModelValue();return n?i.defaultChecked=a:i.defaultValue=a,React.DOM[e](_.extend(i,t,this.props),this.props.children)},getUIModelValue:function(){if(this.isMounted()){if(!n)return $(this.getDOMNode()).val();var e=this.getDOMNode();if(e.checked)return e.value||!0}}},i))};Backbone.input=Backbone.input||{},_.defaults(Backbone.input,{Text:h("input",{type:"text"}),TextArea:h("textarea"),Select:h("select",void 0,void 0),CheckBox:h("input",{type:"checkbox"},!0),RadioGroup:React.createClass({mixins:["modelValueAware"],render:function(){var e=this.props;return React.DOM[e.tag||"span"](e,e.children)},componentDidMount:function(){var e=this.getModelValue();if(e){var t='input[value="'+e.replace('"','\\"')+'"]',n=$(this.getDOMNode()).find(t);n.attr("checked","checked")}},getUIModelValue:function(){if(this.isMounted())for(var e='input[type="radio"]',t=$(this.getDOMNode()).find(e),n=0;n=0&&f.splice(l,1),0===f.length&&(t[i]=void 0,t.trigger(n,m));var d=e===s?[e,m]:[e,r,o,c,m];m.trigger.apply(m,d),d.splice(0,0,"complete"),m.trigger.apply(m,d)}}}var f=t[i]=t[i]||[],h=d&&d.event||e,m=new l(e,r,d),v=a+":"+h;t.trigger(a,h,m),t.trigger(v,m),t===r&&(o.trigger(a,h,t,m),o.trigger(v,t,m));var p=d.beforeSend;return d.beforeSend=function(e,t){if(m.xhr=e,m.settings=t,p){var n=p.call(this,e,t);if(n===!1)return n}return m.trigger("before-send",e,t,m),m.preventDefault?!1:void f.push(m)},u(s),u(c),m}var n=Backbone.xhrCompleteEventName=Backbone.xhrCompleteEventName||"xhr:complete",i=Backbone.xhrModelLoadingAttribute=Backbone.xhrModelLoadingAttribute||"xhrActivity",a=Backbone.xhrEventName=Backbone.xhrEventName||"xhr",r=Backbone.xhrGlobalAttribute=Backbone.xhrGlobalAttribute||"xhrEvents",o=Backbone[r]=_.extend({},Backbone.Events),s="success",c="error",l=function(e,t,n){this.method=e,this.model=t,this.options=n};l.prototype.abort=function(){this.aborted||(this.aborted=!0,this.preventDefault=!0,this.xhr&&this.xhr.abort())},_.extend(l.prototype,Backbone.Events);var d=Backbone.sync;Backbone.sync=function(e,n,i){i=i||{},i.url||(i.url=_.result(n,"url"));var a=t(e,n,n,i);if(!a.preventDefault){var r=d.call(this,e,n,i);return a.xhr=r,r}},o.on(a+":read",function(e,t){t.on(s,function(){e.hasBeenFetched=!0,e.hadFetchError=!1}),t.on(c,function(){e.hadFetchError=!0})}),Backbone.Model.prototype.whenFetched=Backbone.Collection.whenFetched=function(e,t){function n(){e(a)}var a=this;if(this.hasBeenFetched)return e(this);var r=_.find(this[i],function(e){return"read"===e.method});r?(r.on("success",n),t&&r.on("error",t)):this.fetch({success:n,error:t})},Backbone.forwardXhrEvents=function(t,n,i){var r=e(!_.isFunction(i)&&i);if(_.isFunction(i))try{t.on(a,r,n),i.call(this)}finally{t.off(a,r,n)}else{var o=i?a+":"+i:a;t.on(o,r,n)}},Backbone.stopXhrForwarding=function(t,n,i){var r=e(i);t.off(a,r,n)};var u={}}(),function(){function get(values,index,initiatedOnce,rtn){function addTo(name){var indexName=name,match=name.match(/^([^\(]*)\s*\(([^\)]*)\)\s*/),params=match&&match[2];if(name=match&&match[1]||name,!index[indexName]){params&&(params=eval("["+params+"]"));var mixin=React.mixins._mixins[name],checkAgain=!1,skip=!1;if(!mixin)throw new Error('invalid mixin "'+name+'"');if("function"==typeof mixin)React.mixins._initiatedOnce[name]?(initiatedOnce[name]=initiatedOnce[name]||[],initiatedOnce[name].push(params),skip=!0):(mixin=mixin.apply(this,params||[]),checkAgain=!0);else if(params)throw new Error('the mixin "'+name+'" does not support parameters');get(React.mixins._dependsOn[name],index,initiatedOnce,rtn),get(React.mixins._dependsInjected[name],index,initiatedOnce,rtn),index[indexName]=!0,checkAgain?get([mixin],index,initiatedOnce,rtn):skip||rtn.push(mixin)}}function handleMixin(e){e&&(Array.isArray(e)?get(e,index,initiatedOnce,rtn):"string"==typeof e?addTo(e):rtn.push(e))}if(Array.isArray(values))for(var i=0;i=0,u=c[s]),!u)throw'no callback function exists for "'+s+'"';s=function(){return u.apply(c,d?[]:arguments)}}var f=o.match(a);if(f){var h=f[1],m=f[2].split(/\s*,\s*/),v=f[3],p=React.events.specials[h];if(p)return 1===m.length&&""===m[0]&&(m=[]),s=p.call(c,s,m),e(v,s,c,!0);throw new Error('invalid special event handler "'+h+"'")}var g=o.match(i),x=g[1];path=g[2],handler=t[x];for(var _=0;!handler&&_0?Array.prototype.slice.call(arguments,0):void 0;return{getInitialState:function(){t=a(t||"loadOn",this,s+":{key}",function(t){var n=this.getModel();e({loading:n[l]},this),t.on("complete",function(){e({loading:!1},this)},this)});var n=this.getModel();if(n){var i,r=n.loading;if(r)for(var o=function(){e({loading:!1},this)},c=0;c=0)return i=t[d],r[c].on("complete",o,this),{loading:n[l]}}}return{}},loadWhile:function(t){function n(n){var a=t[n];t[n]=function(){e({loading:!1},i),a&&a.apply(this,arguments)}}t=t||{};var i=this;return n("error"),n("success"),e({loading:!0},this),t}}},"modelEventAware"),React.mixins.add("modelUpdateOn",function(){var e=arguments.length>0?Array.prototype.slice.call(arguments,0):void 0;return{getInitialState:function(){a(e||"updateOn",this,"{key}",function(){this.deferUpdate()})}}},"modelEventAware","deferUpdate"),React.events){React.events.mixin=React.events.mixin||Backbone.Events;var d=/^model(\[.+\])?$/;React.events.handle(d,function(e,t){var n=e.key.match(d),i=n[1]&&n[1].substring(1,n[1].length-1),a=i&&(this.props[i]||this.refs[i]);if(!a&&i)throw new Error('no model found with "'+i+'"');var r={model:a,event:e.path,callback:t};return{on:function(){this.modelOn(r)},off:function(){}}});var u=React.events.specials;if(u){var f=["memoize","delay","defer","throttle","debounce","once"];_.each(f,function(e){u[e]=u[e]||function(t,n){return n=o(n),n.splice(0,0,t),_[e].apply(_,n)}})}}var h=function(e,t,n,i){return React.createClass(_.extend({mixins:["modelValueAware"],render:function(){var i={},a=this.getModelValue();return n?i.defaultChecked=a:i.defaultValue=a,React.DOM[e](_.extend(i,t,this.props),this.props.children)},getUIModelValue:function(){if(this.isMounted()){if(!n)return $(this.getDOMNode()).val();var e=this.getDOMNode();if(e.checked)return e.value||!0}}},i))};Backbone.input=Backbone.input||{},_.defaults(Backbone.input,{Text:h("input",{type:"text"}),TextArea:h("textarea"),Select:h("select",void 0,void 0),CheckBox:h("input",{type:"checkbox"},!0),RadioGroup:React.createClass({mixins:["modelValueAware"],render:function(){var e=this.props;return React.DOM[e.tag||"span"](e,e.children)},componentDidMount:function(){var e=this.getModelValue();if(e){var t='input[value="'+e.replace('"','\\"')+'"]',n=$(this.getDOMNode()).find(t);n.attr("checked","checked")}},getUIModelValue:function(){if(this.isMounted())for(var e='input[type="radio"]',t=$(this.getDOMNode()).find(e),n=0;n" diff --git a/package.json b/package.json index 03c7d52..bad1c2b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "backbone-reaction", - "version": "0.10.1", + "version": "0.11.0", "author": "Joe Hudson ", "description": "multiple projects working together (backbone-xhr-events, react-events, react-backbone, react-mixin-manager)", "repository": {