Comparing version 0.1.7 to 0.1.8
@@ -1,2 +0,2 @@ | ||
!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore","jquery","exports"],function(c,d,e,f){a.B2=b(a,f,c,d,e)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");b(a,exports,c,d)}else a.B2=b(a,{},a.Backbone,a._,a.jQuery||a.Zepto||a.ender||a.$)}(this,function(a,b,c,d,e){var f=a.B2;b.VERSION="0.1.6",b.noConflict=function(){return a.B2=f,this};var g={};try{g=window.localStorage}catch(a){}b.localStorage=g,d.extend(b,c),b.rootViews={},b.getComponentByUniqueName=function(a){function c(a,b){var e;return d.each(a,function(a){return!e&&void(e=a._uuid+"_"+a._componentName===b?a:c(a._components,b))}),e}return c(b.rootViews,a)},b.View=c.View.extend({template:function(){return""},appEvents:{},broadcastEvents:{},broadcast:function(){var a=[].slice.apply(arguments);a.unshift("__broadcast__"),this.trigger.apply(this,a)},registerComponent:function(a,c,f,g){var h;if(this._parentView||(b.rootViews[this.cid]=this),this._components=this._components||{},this._components.hasOwnProperty(a)){var i=this._components[a];i.trigger&&i.trigger("beforeRemove"),this.stopListening(i,"all"),i.remove()}this._components[a]=c,c._parentView=this,c._componentName=a,c._uuid=d.uniqueId(),c.$el.attr("data-component-unique-name",c._uuid+"_"+a);var j=/^(\S+)\s*(\S+)$/;for(var k in this.appEvents)if(this.appEvents.hasOwnProperty(k)){var l=this.appEvents[k],m=k.match(j),n=m[1],o=m[2];if(m&&o){var p=/\/(.*?)\//.exec(o),q=p&&p[1];q&&(o=new RegExp(q.replace(/\\/g,"\\\\")))}if(o){var r=!1;if(d.isRegExp(o)&&o.test(a)?r=!0:o==a&&(r=!0),r){var s=n.split(/,/),t=this[l];for(h=0;h<s.length;h++)"all"!==s[h]&&this.listenTo(c,s[h],t)}}}return this.listenTo(c,"all",function(a){if("__broadcast__"!==a)if(this.appEvents.hasOwnProperty("all")){var b=this.appEvents.all;this[b].apply(this,[arguments[0],c].concat(d.toArray(arguments).slice(1)))}else c._events&&c._events[a]||this.trigger.apply(this,arguments)}),c.listenTo(this,"__broadcast__",function(){var a=[].slice.apply(arguments),b=a.shift();if(c.broadcastEvents.hasOwnProperty(b)){var e,f=c.broadcastEvents[b];e=d.isString(f)?c[f]:f,e.apply(c,a)}else c.broadcast.apply(c,arguments)}),f&&(d.isString(f)?this.$(f).append(c.el):e(f).append(c.el),g!==!0&&c.render()),c},getComponent:function(a){return this._components?this._components[a]:null},getComponents:function(){return this._components||{}},freeChildren:function(a){d.each(this._components,function(b,c){var e=!1;e=!a||(d.isRegExp(a)?a.test(c):a===c||a===b),e&&(this.stopListening(b,"all"),b.remove(),this._components[c]&&(delete this._components[c],delete b._parentView))},this)},_addFieldToFormParams:function(a,b,c){if(d.isObject(c)&&!d.isArray(c)){var e=c[a];if("undefined"==typeof e)c[a]=b;else if(d.isArray(e))d.isArray(e)&&e.push(b);else{var f=e;c[a]=[f],c[a].push(b)}}else d.isArray(c)&&c.push({name:a,value:b})},_parseSerializeOpts:function(a){var b={},c=(a||"").split(";"),f={false:!1,true:!0};return d.each(c,function(a){a=a.split(":");var c=e.trim(a[0]),g=e.trim(a[1]);b[c]=d.isUndefined(f[g])?g:f[g]}),d.defaults(b,{trim:!0})},serializeForm:function(a,b,c,f){var g=this;a=a||this.el;var h=e(a).find("input, select, textarea").filter(function(){var c=!1,d=e(this).closest("."+f);return 0===d.length?c=!0:e.contains(a,d[0])||(c=!0),c&&this.name&&this.name.indexOf(b||"ignore")===-1}),i={};return c&&(i=[]),h.each(function(){var a=e(this),b=a.attr("name"),c=g._parseSerializeOpts(a.attr("data-serialize-opts")),f=a.val();f=c.trim?e.trim(f):f;var h=a.attr("value2"),j=!0,k=a.attr("data-inverse-value"),l=a.data("dataTypeToParse");switch(a.prop("type")){case"radio":a.prop("checked")?b=a.attr("name"):j=!1;break;case"checkbox":a.prop("checked")?null!=f&&"on"!=f||(f=!0):f=null!=h&&h,k&&(f=!f)}if(d.isString(l))switch(l.toLowerCase()){case"int":var m=parseInt(f,10);f=isNaN(m)?f:m;break;case"float":var n=parseFloat(f);f=isNaN(n)?f:n}j&&g._addFieldToFormParams(b,f,i)}),i},serializeArray:function(a,b){return this.serializeForm(a,b,!0)},getParentView:function(){return this._parentView},remove:function(){this.freeChildren(),this.trigger("beforeRemove");var a=this._parentView;a?(a.stopListening(this),a._components&&delete a._components[this._componentName],delete this._parentView):delete b.rootViews[this.cid],c.View.prototype.remove.apply(this,arguments)},render:function(){this.$el.html(this.template())}}),b.Model=c.Model.extend({}),b.Collection=c.Collection.extend({}),b.Router=c.Router.extend({}),b.History=c.History.extend({});var h=function(a,b,c){c=c||[];var e,f=this,g=f.prototype;e=a&&d.has(a,"constructor")?a.constructor:function(){return f.apply(this,arguments)},d.extend(e,f,b);var h=function(){this.constructor=e};h.prototype=f.prototype;var i=e.prototype=new h,j=/xyz/.test(function(){return"xyz"})?/\b_super\b/:/.*/,k=/'manage ajax';/;for(var l in a)a.hasOwnProperty(l)&&(i[l]="function"==typeof a[l]&&(k.test(a[l])||"function"==typeof g[l]&&(j.test(a[l])||c.indexOf(l)>-1))?function(a,b){return function(){var c=this._super;k.test(b)&&(b.viewId="_"+this.cid+"_"),this._super=g[a];var d=b.apply(this,arguments);return this._super=c,d}}(l,a[l]):a[l]);return e.__super__=f.prototype,e};b.Model.extend=b.Collection.extend=b.Router.extend=b.View.extend=b.History.extend=h;var i=b.View.extend;b.View.extend=function(a,b){if(a.render){var c=a.render;a.render=function(){this.onRenderBegin&&this.onRenderBegin(),this.freeChildren&&this.freeChildren();var a=c.apply(this,arguments);return this.onRenderEnd&&this.onRenderEnd(),a}}var e=i.call(this,a,b,["render"]);return e.prototype.events=d.extend({},this.prototype.events,a.events),e.prototype.appEvents=d.extend({},this.prototype.appEvents,a.appEvents),e.prototype.broadcastEvents=d.extend({},this.prototype.broadcastEvents,a.broadcastEvents),e}}); | ||
!function(e,t){if("function"==typeof define&&define.amd)define(["backbone","underscore","jquery","exports"],function(n,r,i,s){e.B2=t(e,s,n,r,i)});else if("undefined"!=typeof exports){var n=require("backbone"),r=require("underscore");t(e,exports,n,r)}else e.B2=t(e,{},e.Backbone,e._,e.jQuery||e.Zepto||e.ender||e.$)}(this,function(e,t,n,r,i){var s=e.B2;t.VERSION="0.1.6",t.noConflict=function(){return e.B2=s,this};var o={};try{o=window.localStorage}catch(e){}t.localStorage=o,r.extend(t,n),t.rootViews={},t.getComponentByUniqueName=function(e){function n(e,t){var i;return r.each(e,function(e){if(i)return!1;i=e._uuid+"_"+e._componentName===t?e:n(e._components,t)}),i}return n(t.rootViews,e)},t.View=n.View.extend({template:function(){return""},appEvents:{},broadcastEvents:{},broadcast:function(){var e=[].slice.apply(arguments);e.unshift("__broadcast__"),this.trigger.apply(this,e)},registerComponent:function(e,n,s,o){var a;if(this._parentView||(t.rootViews[this.cid]=this),this._components=this._components||{},this._components.hasOwnProperty(e)){var p=this._components[e];p.trigger&&p.trigger("beforeRemove"),this.stopListening(p,"all"),p.remove()}this._components[e]=n,n._parentView=this,n._componentName=e,n._uuid=r.uniqueId(),n.$el.attr("data-component-unique-name",n._uuid+"_"+e);var c=/^(\S+)\s*(\S+)$/;for(var h in this.appEvents)if(this.appEvents.hasOwnProperty(h)){var l=this.appEvents[h],u=h.match(c),d=u[1],f=u[2];if(u&&f){var v=/\/(.*?)\//.exec(f),_=v&&v[1];_&&(f=new RegExp(_.replace(/\\/g,"\\\\")))}if(f){var m=!1;if(r.isRegExp(f)&&f.test(e)?m=!0:f==e&&(m=!0),m){var y=d.split(/,/),g=this[l];for(a=0;a<y.length;a++)"all"!==y[a]&&this.listenTo(n,y[a],g)}}}return this.listenTo(n,"all",function(e){"__broadcast__"!==e&&(this.appEvents.hasOwnProperty("all")?this[this.appEvents.all].apply(this,[arguments[0],n].concat(r.toArray(arguments).slice(1))):n._events&&n._events[e]||this.trigger.apply(this,arguments))}),n.listenTo(this,"__broadcast__",function(){var e=[].slice.apply(arguments),t=e.shift();if(n.broadcastEvents.hasOwnProperty(t)){var i=n.broadcastEvents[t];(r.isString(i)?n[i]:i).apply(n,e)}else n.broadcast.apply(n,arguments)}),s&&(r.isString(s)?this.$(s).append(n.el):i(s).append(n.el),!0!==o&&n.render()),n},getComponent:function(e){return this._components?this._components[e]:null},getComponents:function(){return this._components||{}},freeChildren:function(e){r.each(this._components,function(t,n){(!e||(r.isRegExp(e)?e.test(n):e===n||e===t))&&(this.stopListening(t,"all"),t.remove(),this._components[n]&&(delete this._components[n],delete t._parentView))},this)},_addFieldToFormParams:function(e,t,n){if(r.isObject(n)&&!r.isArray(n)){var i=n[e];if(void 0===i)n[e]=t;else if(r.isArray(i))r.isArray(i)&&i.push(t);else{var s=i;n[e]=[s],n[e].push(t)}}else r.isArray(n)&&n.push({name:e,value:t})},_parseSerializeOpts:function(e){var t={},n=(e||"").split(";"),s={false:!1,true:!0};return r.each(n,function(e){e=e.split(":");var n=i.trim(e[0]),o=i.trim(e[1]);t[n]=r.isUndefined(s[o])?o:s[o]}),r.defaults(t,{trim:!0})},serializeForm:function(e,t,n,s){var o=this;e=e||this.el;var a=i(e).find("input, select, textarea").filter(function(){var n=!1,r=i(this).closest("."+s);return 0===r.length?n=!0:i.contains(e,r[0])||(n=!0),n&&this.name&&-1===this.name.indexOf(t||"ignore")}),p={};return n&&(p=[]),a.each(function(){var e=i(this),t=e.attr("name"),n=o._parseSerializeOpts(e.attr("data-serialize-opts")),s=e.val();s=n.trim?i.trim(s):s;var a=e.attr("value2"),c=!0,h=e.attr("data-inverse-value"),l=e.data("dataTypeToParse");switch(e.prop("type")){case"radio":e.prop("checked")?t=e.attr("name"):c=!1;break;case"checkbox":e.prop("checked")?null!=s&&"on"!=s||(s=!0):s=null!=a&&a,h&&(s=!s)}if(r.isString(l))switch(l.toLowerCase()){case"int":var u=parseInt(s,10);s=isNaN(u)?s:u;break;case"float":var d=parseFloat(s);s=isNaN(d)?s:d}c&&o._addFieldToFormParams(t,s,p)}),p},serializeArray:function(e,t){return this.serializeForm(e,t,!0)},getParentView:function(){return this._parentView},remove:function(){this.freeChildren(),this.trigger("beforeRemove");var e=this._parentView;e?(e.stopListening(this),e._components&&delete e._components[this._componentName],delete this._parentView):delete t.rootViews[this.cid],n.View.prototype.remove.apply(this,arguments)},render:function(){this.$el.html(this.template())}}),t.Model=n.Model.extend({}),t.Collection=n.Collection.extend({}),t.Router=n.Router.extend({}),t.History=n.History.extend({});var a=function(e,t,n){n=n||[];var i,s=this,o=s.prototype;i=e&&r.has(e,"constructor")?e.constructor:function(){return s.apply(this,arguments)},r.extend(i,s,t);var a=function(){this.constructor=i};a.prototype=s.prototype;var p=i.prototype=new a,c=/xyz/.test(function(){return"xyz"})?/\b_super\b/:/.*/,h=/'manage ajax';/;for(var l in e)e.hasOwnProperty(l)&&(p[l]="function"==typeof e[l]&&(h.test(e[l])||"function"==typeof o[l]&&(c.test(e[l])||n.indexOf(l)>-1))?function(e,t){return function(){var n=this._super;h.test(t)&&(t.viewId="_"+this.cid+"_"),this._super=o[e];var r=t.apply(this,arguments);return this._super=n,r}}(l,e[l]):e[l]);return i.__super__=s.prototype,i};t.Model.extend=t.Collection.extend=t.Router.extend=t.View.extend=t.History.extend=a;var p=t.View.extend;t.View.extend=function(e,t){if(e.render){var n=e.render;e.render=function(){this.onRenderBegin&&this.onRenderBegin(),this.freeChildren&&this.freeChildren();var e=n.apply(this,arguments);return this.onRenderEnd&&this.onRenderEnd(),e}}var i=p.call(this,e,t,["render"]);return i.prototype.events=r.extend({},this.prototype.events,e.events),i.prototype.appEvents=r.extend({},this.prototype.appEvents,e.appEvents),i.prototype.broadcastEvents=r.extend({},this.prototype.broadcastEvents,e.broadcastEvents),i}}); | ||
//# sourceMappingURL=b2-min.js.map |
{ | ||
"name": "b2", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "A super lightweight framework based on backbone.js", | ||
@@ -20,4 +20,4 @@ "main": "b2.js", | ||
"chai": "^3.2.0", | ||
"grunt": "~0.4.5", | ||
"grunt-contrib-uglify": "~0.6.0", | ||
"grunt": "^1.0.1", | ||
"grunt-contrib-uglify": "^3.0.1", | ||
"jsdom": "^3.1.2", | ||
@@ -24,0 +24,0 @@ "underscore": "^1.8.3" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88828
14