Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "ClazzJS", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"ignore": [ | ||
@@ -5,0 +5,0 @@ "node_modules", |
@@ -1,2 +0,2 @@ | ||
!function(a,b,c,d){if("function"==typeof define&&define.amd)define(b,c,d);else if("object"==typeof exports&&exports){for(var e=0,f=c.length;f>e;++e){var g=c[e];"string"==typeof g&&(g=g.replace(/([A-Z]+)/g,function(a){return"-"+a.toLowerCase()}).replace(/^-/,""),c[e]=require(g))}var h=d.apply(a,c);for(var i in h)exports[i]=h[i]}else{for(var e=0,f=c.length;f>e;++e){var g=c[e];if("string"==typeof g){if(!(g in a))throw new Error('"'+b+'" dependent on non exited module "'+g+'"!');c[e]=a[g]}}a[b]=d.apply(a,c)}}(new Function("return this")(),"ClazzJS",[],function(a){var b=function(){var a={},b=Object.prototype.toString,c=Array.prototype.slice;a.isUndefined=function(a){return void 0===a},a.isObject=function(a){return a===Object(a)},a.isSimpleObject=function(a){return"[object Object]"===b.call(a)},a.isNull=function(a){return null===a};for(var d=["Function","String","Number","Date","RegExp","Array"],e=0,f=d.length;f>e;++e)!function(c){a["is"+c]=function(a){return b.call(a)==="[object "+c+"]"}}(d[e]);return a.toArray=function(a){return c.call(a)},a.extend=function(a){for(var b=c.call(arguments,1),d=0,e=b.length;e>d;++d){var f=b[d];if(f)for(var g in f)a[g]=f[g]}return a},a.last=function(a){return a[a.length-1]},a.construct=function(a,b){var c=function(){return a.apply(this,b)};return c.prototype=a.prototype,new c},a}(),c=function(){var a=function(c,d){var e=function(a){var c=e.getScope().getNamespace(e.adjustPath(a));return arguments.length>1&&c.space.apply(c,b.toArray(arguments).slice(1)),c};return b.extend(e,a.prototype),e._scope=c,e._path=d,e._spaces=[],e._objects={},e};b.extend(a.prototype,{getPath:function(){return this._path},getScope:function(){return this._scope},adjustPath:function(a){return this._scope.isAbsolutePath(a)?this._scope.adjustPath(a):this._scope.concatPaths(this.getPath(),a)},get:function(a){return a in this._objects||(this._objects[a]=this._scope.get(a).call(this)),this._objects[a]},has:function(a){return this._scope.has(a)},space:function(){var a=this,c=b.toArray(arguments).slice(0,-1),d=b.last(arguments),e=[];c.length||(c=this._scope.getDefaultInjects());for(var f=0,g=c.length;g>f;++f)e[f]=this.get(c[f]);return this._spaces.push(function(){d.apply(a,e)}),this},executeSpace:function(){return this._spaces.length?(this._spaces.pop()(),!0):!1}});var c=function(a){a=a||{},this._innerDelimiter=a.innerDelimiter||"/",this._delimiters=a.delimiters||["\\","/","."],this._defaultInjects=a.defaultInjects||[],this._namespaces={},this._factories={},this._search=[]};return b.extend(c.prototype,{getInnerDelimiter:function(){return this._innerDelimiter},setInnerDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not supported!');return this._innerDelimiter=a,this},getDelimiters:function(){return this._delimiters},addDelimiter:function(a){if(this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" is already exists!');return this},removeDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not exists!')},hasDelimiter:function(a){return-1!==this._delimiters.indexOf(a)},getNamespace:function(b){return b=this.adjustPath(b),b in this._namespaces||(this._namespaces[b]=a(this,b)),this._namespaces[b]},getRootNamespace:function(){return this.getNamespace(this.getRootPath())},getRootPath:function(){return this._innerDelimiter},adjustPath:function(a){var b=this.getInnerDelimiter(),c=this.getDelimiters();return a.replace(new RegExp("[\\"+c.join("\\")+"]","g"),b).replace(new RegExp(b+"+","g"),b).replace(new RegExp("(.+)"+b+"$"),function(a){return a})},isAbsolutePath:function(a){return 0===a.indexOf(this.getRootNamespace().getPath())},concatPaths:function(){return this.adjustPath(b.toArray(arguments).join(this.getInnerDelimiter()))},set:function(a,b){if(a in this._factories)throw new Error('Factory for object "'+a+'" is already exists!');return this._factories[a]=b,this},get:function(a){if(!(a in this._factories))throw new Error('Factory for object "'+a+'" does not exists!');return this._factories[a]},has:function(a){return a in this._factories},remove:function(a){return delete this._factories[a],this},getInSearchError:function(a){var b=new Error('Path "'+a+'" is in search state!');return b.inSearch=!0,b.path=a,b},isInSearchError:function(a){return a.inSearch},search:function(a,c){a=this.adjustPath(a);var d=c(a);if(!b.isUndefined(d))return d;for(var e=this.getInnerDelimiter(),f=a.split(e),g=f.pop();f.length;){var h=f.join(e);if(h in this._namespaces)for(var i=this._namespaces[h];i.executeSpace();)if(d=c(h+e+g),!b.isUndefined(d))return d;g=f.pop()}},getDefaultInjects:function(){return this._defaultInjects},addDefaultInject:function(a){if(-1!==this._defaultInjects.indexOf(a))throw new Error('Default inject "'+a+'" is already exists!');return this._defaultInjects.push(a),this},removeDefaultInject:function(a){var b=this._defaultInjects.indexOf(a);if(-1===b)throw new Error('Default inject "'+a+'" does not exists!');return this._defaultInjects.splice(b,1),this}}),{Namespace:a,Scope:c}}(),d=function(){var a=function(){this._processors={}};b.extend(a.prototype,{getProcessor:function(a){return this.checkProcessor(a),this._processors[a]},hasProcessor:function(a){return a in this._processors},setProcessor:function(a,c){return b.isFunction(c)&&(c={process:c}),this._processors[a]=c,this},removeProcessor:function(a){this.checkProcessor(a);var b=this._processors[a];return delete this._processors[a],b},getProcessors:function(){return this._processors},setProcessors:function(a){for(var b in a)this.setProcessor(b,a[b]);return this},checkProcessor:function(a){if(!this.hasProcessor(a))throw new Error('Meta processor "'+a+'" does not exists!')}});var c=function(a,d){var e=function(a,c){return b.isUndefined(c)?e.get(a):e.set(a,c)};return b.extend(e,c.prototype),e._manager=a,e._namespace=d,e};return b.extend(c.prototype,{getManager:function(){return this._manager},getNamespace:function(){return this._namespace},get:function(a){var b=this.getManager(),c=this.resolveProcessorName(a);if(!c)throw new Error('Meta processor "'+a+'" does not exist!');return b.getProcessor(c)},set:function(a,b){var c=this.getNamespace(),d=this.getManager();return d.setProcessor(c.adjustPath(a),b),this},resolveProcessorName:function(a){var b=this.getManager(),c=this.getNamespace();return c.getScope().search(c.adjustPath(a),function(a){return b.hasProcessor(a)?a:void 0})}}),{Meta:c,Manager:a}}(),e=function(){var c=function(a,d,e){var f=function(a,c,d){var e=b.last(arguments);return b.isFunction(e)&&!e.prototype.__clazz||"[object Object]"===Object.prototype.toString.call(e)?(f.set(a,c,d),void 0):f.get(a,c,d)};return b.extend(f,c.prototype),f._manager=a,f._factory=d,f._namespace=e,f};b.extend(c.prototype,{getManager:function(){return this._manager},getFactory:function(){return this._factory},getNamespace:function(){return this._namespace},has:function(a){return!!this.resolveName(a)},get:function(c,d,e){b.isUndefined(e)&&b.isArray(d)&&(e=d,d=a);var f=this.resolvePath(c);if(!f)throw new Error('Clazz "'+c+'" does not exists!');e=e||[];var g=this.getManager();if(!g.hasClazz(f,d,e)){var h=this.getFactory(),i=g.getClazzData(f);g.setClazz(f,h.create({name:i.name,parent:d,metaParent:i.parent,meta:i.meta,dependencies:e,clazz:i.clazz}),d,e)}return g.getClazz(f,d,e)},set:function(c,d,e){b.isUndefined(e)&&(e=d,d=a);var f=this.getNamespace(),g=this.getManager();return b.isUndefined(e)&&(e=d,d=null),c=f.adjustPath(c),b.isString(d)&&(d=f.adjustPath(d)),g.setClazzData(c,{name:c,parent:d,meta:e,clazz:this}),this},resolvePath:function(a){var b=this.getNamespace(),c=this.getManager();return b.getScope().search(b.adjustPath(a),function(a){return c.hasClazzData(a)?a:void 0})}});var d=function(a){a=a||{},this._clazzUID=0,this._metaProcessor=a.metaProcessor||null,this._baseClazz=a.baseClazz||null};b.extend(d.prototype,{CLAZZ_NAME:"Clazz{uid}",getBaseClazz:function(){return this._baseClazz},setBaseClazz:function(a){if(!b.isFunction(a))throw new Error("Base clazz must be a function!");return this._baseClazz=a,this},getMetaProcessor:function(){return this._metaProcessor},setMetaProcessor:function(a){if(!b.isFunction(a.process))throw new Error('Meta processor must have "process" method!');return this._metaProcessor=a,this},create:function(a){var c=a.name||this.generateName(),d=a.parent,e=a.metaParent,f=a.meta||{},g=a.dependencies||[],h=a.clazz,i=this.createClazz();return i.__name=c,i.__clazz=h,b.isFunction(f)&&(f=f.apply(i,[i].concat(g))||{}),!f.parent&&e&&(f.parent=e),d=d||f.parent,b.isString(d)&&(d=[d]),b.isArray(d)&&(d=h.get.apply(h,d)),this.applyParent(i,d),i.prototype.__clazz=i,i.prototype.__proto=i.prototype,this.applyMeta(i,f),i},createClazz:function(){return function a(){var c;return this instanceof a?(b.isFunction(a.__construct)&&(c=a.__construct.apply(this,b.toArray(arguments))),b.isUndefined(c)?void 0:c):b.construct(a,b.toArray(arguments))}},applyParent:function(c,d){if(d=d||this.getBaseClazz())for(var e in d)e in c||(b.isFunction(d[e])?c[e]=d[e]:"_"===e[0]&&(c[e]=a));return c.prototype=b.extend(Object.create(d?d.prototype:{}),c.prototype),c.__parent=d||null,c.prototype.constructor=c,c.prototype.__parent=d?d.prototype:null,c},applyMeta:function(a,b){return this.getMetaProcessor().process(a,b),a},generateName:function(){return this.CLAZZ_NAME.replace("{uid}",++this._clazzUID)}});var e=function(){this._clazz={},this._clazzData={}};return b.extend(e.prototype,{setClazzData:function(a,b){return this._clazzData[a]=b,this},hasClazzData:function(a){return a in this._clazzData},getClazzData:function(a){if(!this.hasClazzData(a))throw new Error('Data does not exists for clazz "'+a+'"!');return this._clazzData[a]},getClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return d[e][0]}throw new Error('Clazz "'+a+'" does not exists!')},hasClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return!0}return!1},setClazz:function(a,c,d,e){if(!b.isFunction(c))throw new Error("Clazz must be a function!");return a in this._clazz||(this._clazz[a]=[]),this._clazz[a].push([c,d,e||[]]),this}}),{Clazz:c,Factory:d,Manager:e}}(),f=new c.Scope({defaultInjects:["clazz","namespace"]}),g=f.getRootNamespace(),h=new d.Manager,i=new d.Meta(h,g),j=new e.Manager,k=new e.Factory,l=new e.Clazz(j,k,g);return f.set("namespace",function(){return this}),f.set("meta",function(){return new d.Meta(h,this)}),f.set("clazz",function(){return new e.Clazz(j,k,this)}),g("ClazzJS","clazz","meta","namespace",function(c,d,e){d("Base",{_processors:{constants:"Constants",properties:"Properties",methods:"Methods",events:"Events"},process:function(a,c){a.__isClazz||b.extend(a,this.clazz_interface),a.__interfaces||(a.__interfaces=[],a.prototype.__interfaces=[],b.extend(a,this.common_interface),b.extend(a.prototype,this.common_interface)),a.__metaProcessors=c.meta_processors||{};var d=c.parent;if(d&&!a.__isSubclazzOf(d))throw new Error('Clazz "'+a.__name+'" must be subclazz of "'+d.__isClazz?d.__name:d+'"!');var e=a.__getMetaProcessors();for(var f in e)e[f].process(a,c)},getProcessors:function(){var a=this._processors;for(var c in a)b.isString(a[c])&&(a[c]=d(a[c]));return a},setProcessors:function(a){for(var b in a)this.setProcessor(type,b,a[b]);return this},hasProcessor:function(a){return a in this._processors},setProcessor:function(a,b){if(a in this._processors)throw new Error('Processor "'+a+'" is already exists!');return this._processors[a]=b,this},removeProcessor:function(a){if(!(a in this._processors))throw new Error('Processor "'+a+'" does not exists!');return delete this._processors[a],this},clazz_interface:{__isClazz:!0,__isSubclazzOf:function(a){for(var b=this;b;){if(b===a||b.__name===a)return!0;b=b.__parent}return!1},__construct:function(){for(var a in this)0===a.indexOf("__init")&&b.isFunction(this[a])&&this[a]();b.isFunction(this.init)&&this.init.apply(this,b.toArray(arguments)),b.isFunction(this.__clazz.__emitEvent)&&this.__clazz.__emitEvent("instance.created",this)}},common_interface:{__isInterfaceImplemented:function(a){return-1!==this.__interfaces.indexOf(a)},__implementInterface:function(a,c){if(-1!==this.__interfaces.indexOf(a))throw new Error('Interface "'+a+'" is already implemented!');return this.__interfaces.push(a),b.extend(this,c),this},__collectAllPropertyValues:function(a,c){var d=[];this.hasOwnProperty(a)&&d.push(this[a]),this.__proto&&this.__proto.hasOwnProperty(a)&&d.push(this.__proto[a]);for(var e=this.__parent;e;)e.hasOwnProperty(a)&&d.push(e[a]),e=e.__parent;for(var f=b.toArray(arguments).slice(2),g={},h=0,i=d.length;i>h;++h)this.__collectValues(g,d[h],c||1,f);return g},__collectValues:function f(a,b,c,d,e){d=[].concat(d||[]);for(var g in b)d[0]&&g!==d[0]||(c>1&&"[object Object]"===Object.prototype.toString.call(b[g])?(g in a||(a[g]={}),f(a[g],b[g],c-1,d.slice(1))):!e&&g in a||(a[g]=b[g]));return a},__getMetaProcessors:function(){var a=this.__isClazz?this:this.__clazz;return this.__collectValues(a.__collectAllPropertyValues("__metaProcessors",1),d("Base").getProcessors())}}}),d("Constants",{process:function(a,b){this.applyConstants(a,b.constants||{})},applyConstants:function(a,b){a.__isInterfaceImplemented("constants")||a.__implementInterface("constants",this.interface),a.__constants={};for(var c in b)a.__constants[c]=b[c]},"interface":{__initConstants:function(){this.__constants={}},__getConstants:function(){return this.__collectAllPropertyValues("__constants",99)},__getConstant:function(){for(var a=b.toArray(arguments),c=this.__collectAllPropertyValues.apply(this,["__constants",99].concat(a)),d=0,e=a.length;e>d;++d){if(!(a[d]in c))throw new Error('Constant "'+a.splice(0,d).join(".")+'" does not exists!');c=c[a[d]]}return c}}}),d("Events",{process:function(a,b){this.applyEvents(a,b.clazz_events||{}),this.applyEvents(a.prototype,b.events||{})},applyEvents:function(a,b){a.__isInterfaceImplemented("events")||a.__implementInterface("events",this.interface),a.__events={};for(var c in b)for(var d in b[c])a.__addEventListener(c,d,b[c][d])},"interface":{__initEventsCallbacks:function(){this.__events={}},__emitEvent:function(a){var c=this.__getEventListeners(a);for(var d in c)c[d].apply(this,b.toArray(arguments).slice(1));return this},__addEventListener:function(a,b,c){if(this.__hasEventListener(a,b))throw new Error('Event listener for event "'+a+'" with name "'+b+'" is already exists!');return a in this.__events||(this.__events[a]={}),this.__events[a][b]=c,this},__removeEventListener:function(c,d){if(c in this.__events||(this.__events[c]={}),b.isUndefined(d)){var e=this.__getEventListeners(c);for(var d in e)this.__events[c][d]=a}else{if(!this.__hasEventListener(c,d))throw new Error('There is no "'+c+(d?'"::"'+d:"")+'" event callback!');this.__events[c][d]=a}return this},__hasEventListener:function(a,b){return b in this.__getEventListeners(a)},__getEventListener:function(a,b){var c=this.__getEventListeners(a);if(!(b in c))throw new Error('Event listener for event "'+a+'" with name "'+b+'" does not exists!');return c[a][b]},__getEventListeners:function(a){var c=this.__collectAllPropertyValues.apply(this,["__events",2].concat(a||[]));for(var d in c)for(var e in c[d])b.isUndefined(c[d][e])&&delete c[d][e];return a?c[a]||{}:c}}}),d("Methods",{process:function(a,b){this.applyMethods(a,b.clazz_methods||{}),this.applyMethods(a.prototype,b.methods||{})},applyMethods:function(a,c){for(var d in c){if(!b.isFunction(c[d]))throw new Error('Method "'+d+'" must be a function!');a[d]=c[d]}}}),d("Properties",{_propertyMetaProcessor:"Property",process:function(a,b){this.applyProperties(a,b.clazz_properties||{}),this.applyProperties(a.prototype,b.properties||{})},applyProperties:function(a,c){a.__isInterfaceImplemented("properties")||a.__implementInterface("properties",this.interface),a.__properties={},a.__setters={},a.__getters={};var d=this.getPropertyMetaProcessor();for(var e in c)d.process(a,c[e],e);var f=a.__getPropertiesParam();for(var e in f)if("default"in f[e]){var g=f[e].default;b.isFunction(g)&&(g=g.call(a)),a["_"+e]=g}},getPropertyMetaProcessor:function(){var a=this._propertyMetaProcessor;return b.isString(a)&&(this._propertyMetaProcessor=d(a)),a},setPropertyMetaProcessor:function(a){return this._propertyMetaProcessor=a,this},"interface":{__initProperties:function(){this.__properties={},this.__setters={},this.__getters={}},__setPropertiesParam:function(a){for(var b in a)this.__setPropertyParam(b,a[b]);return this},__getPropertiesParam:function(){return this.__collectAllPropertyValues("__properties",2)},__setPropertyParam:function(a,c,d){var e={};return b.isUndefined(d)?b.isObject(c)&&b.extend(e,c):e[c]=d,a in this.__properties||(this.__properties[a]={}),b.extend(this.__properties[a],e),this},__getPropertyParam:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__properties",2,a].concat(b||[]));return b?c[b]:c},__hasProperty:function(a){return"_"+a in this},__getPropertyValue:function(a){b.isString(a)&&(a=a.split("."));var c=a.shift();if(!this.__hasProperty(c))throw new Error('Property "'+c+'" does not exists!');for(var d=this.__applyGetters(c,this["_"+c]),e=0,f=a.length;f>e;++e){var g=a[e];if(!(g in d))throw new Error('Property "'+[c].concat(a.slice(0,e+1)).join(".")+'" does not exists!');d=this.__applyGetters(c,d[g],a.slice(0,e+1))}return d},__hasPropertyValue:function(a){b.isString(a)&&(a=a.split("."));var c=a.shift();if(!this.__hasProperty(c))throw new Error('Property "'+c+'" does not exists!');for(var d=this.__applyGetters(c,this["_"+c]),e=0,f=a.length;f>e;++e){var g=a[e];if(!(g in d))return!1;d=this.__applyGetters(c,d[g],a.slice(0,e+1))}return!b.isUndefined(d)&&!b.isNull(d)},__isPropertyValue:function(a,c){var d=this.__getPropertyValue(a);return b.isUndefined(c)?!!d:d===c},__clearPropertyValue:function(c){b.isString(c)&&(c=c.split("."));var d=c.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;if(c.length){if(e=b.last(c),f=this.__getPropertyValue([d].concat(c).slice(0,-1)),!(e in f))throw new Error('Property "'+[d].concat(c).join(".")+'" does not exists!')}else e="_"+d,f=this;var g=f[e];return f[e]=b.isSimpleObject(g)&&{}||b.isArray&&[]||a,this.__checkEmitEvent()&&this.__emitPropertyCleared([d].concat(c),g),this},__removePropertyValue:function(c){b.isString(c)&&(c=c.split("."));var d=c.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;if(c.length){if(e=b.last(c),f=this.__getPropertyValue([d].concat(c).slice(0,-1)),!(e in f))throw new Error('Property "'+[d].concat(c).join(".")+'" does not exists!')}else e="_"+d,f=this;var g=f[e];return c.length?delete f[e]:f[e]=a,this.__checkEmitEvent()&&this.__emitPropertyRemoved([d].concat(c),g),this},__setPropertyValue:function(a,c){b.isString(a)&&(a=a.split("."));var d=a.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;a.length?(e=b.last(a),f=this.__getPropertyValue([d].concat(a).slice(0,-1))):(e="_"+d,f=this);var g=e in f,h=f[e],i=this.__applySetters(d,c,a);return f[e]=i,this.__checkEmitEvent()&&this.__emitPropertySetted([d].concat(a),i,h,g),this},__emitPropertyRemoved:function(a,c){var d,e;return this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split(".")),a.length&&(d=a.slice(0,-1).join("."),e=b.last(a),this.__emitEvent("property."+d+".item_removed",e,c),this.__emitEvent("property.item_removed",d,e,c)),d=a.join("."),this.__emitEvent("property."+d+".removed",c),this.__emitEvent("property.removed",d,c),this},__emitPropertyCleared:function(a,c){var d,e,f,g;if(this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split(".")),b.isSimpleObject(c))for(e in c)this.__emitPropertyRemoved(a.concat(e),c[e]);else if(b.isArray(c))for(f=0,g=c.length;g>f;++f)this.__emitPropertyRemoved(a.concat(f),c[f]);return d=a.join("."),this.__emitEvent("property."+d+".cleared",c),this.__emitEvent("property.cleared",d,c),this},__emitPropertySetted:function(a,c,d,e){var f,g,h,i,j;this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split("."));var k=!0;if(b.isSimpleObject(c)&&b.isSimpleObject(d)){for(h in d)if(c[h]!==d[h]){k=!1;break}}else if(b.isArray(c)&&b.isArray(d)){for(i=0,j=d.length;j>i;++i)if(c[i]!==d[i]){k=!1;break}}else c!==d&&(k=!1);return k||(f=a.join("."),g=b.isUndefined(d)||b.isNull(d)?"setted":"changed",this.__emitEvent("property."+f+"."+g,c,d),this.__emitEvent("property."+g,f,c,d),a.length&&!e&&(f=a.slice(0,-1).join("."),h=b.last(a),this.__emitEvent("property."+f+".item_added",h,c),this.__emitEvent("property.item_added",f,h,c))),this},__checkEmitEvent:function(a){a=b.isUndefined(a)?!1:a;var c=b.isFunction(this.__emitEvent);if(a&&!c)throw new Error("__emitEvent method does not realized!");return c},__addSetter:function(a,c,d,e){if(b.isUndefined(e)&&(e=d,d=0),b.isArray(e))d=e[0],e=e[1];else if(!b.isFunction(e))throw new Error("Setter callback must be a function!");return a in this.__setters||(this.__setters[a]={}),this.__setters[a][c]=[d,e],this},__getSetters:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__setters",1].concat(a||[]));if(!a)return c;if(c=c[a],!b)return c[a];var d=[];for(var e in c)d.push(c[e]);d=d.sort(function(a,b){return b[0]-a[1]});for(var f=0,g=d.length;g>f;++f)d[f]=d[f][1];return d},__applySetters:function(a,c,d){d=d||[];for(var e=this.__getSetters(a,!0),f=0,g=e.length;g>f;++f){var h=e[f].call(this,c,d);b.isUndefined(h)||(c=h)}return c},__addGetter:function(a,c,d,e){if(b.isUndefined(e)&&(e=d,d=0),b.isArray(e))d=e[0],e=e[1];else if(!b.isFunction(e))throw new Error("Getter callback must be a function!");return a in this.__getters||(this.__getters[a]={}),this.__getters[a][c]=[d,e],this},__getGetters:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__getters",1].concat(a||[]));if(!a)return c;if(c=c[a],!b)return c[a];var d=[];for(var e in c)d.push(c[e]);d=d.sort(function(a,b){return b[0]-a[1]});for(var f=0,g=d.length;g>f;++f)d[f]=d[f][1];return d},__applyGetters:function(a,c,d){d=d||[];for(var e=this.__getGetters(a,!0),f=0,g=e.length;g>f;++f){var h=e[f].call(this,c,d);b.isUndefined(h)||(c=h)}return c},__setData:function(a){for(var b in a)this.__hasProperty(b)&&this.__setPropertyValue(b,a[b]);return this},__getData:function(){var a={},c=this.__getPropertiesMeta();for(var d in c){var e=this.__getPropertyValue(d);if(b.isArray(e))for(var f=0,g=e.length;g>f;++f)b.isFunction(e[f].__getData)&&(e[f]=e[f].__getData());else if(e.constructor==={}.constructor)for(var h in e)b.isFunction(e[h].__getData)&&(e[h]=e[h].__getData());else b.isFunction(e.__getData)&&(e=e.__getData());a[d]=e}return a}}}),d("Property",{process:function(c,e,f){c["_"+f]=a,b.isArray(e)?e=3!==e.length&&b.isSimpleObject(e[1])?{type:e}:{type:[e[0],e[2]||{}],"default":e[1]}:b.isSimpleObject(e)||(e={"default":e}),"methods"in e||(e.methods=["get","set","has","is","clear","remove"]);for(var g in e)if(g in this._options){var h=this._options[g];b.isString(h)&&(h=d(h)),h.process(c,e[g],f)}},addOption:function(a,b){if(a in this._options)throw new Error('Option "'+a+'" is already exists!');return this._options[a]=b,this},hasOption:function(a){return a in this._options},removeOption:function(a){if(!(a in this._options))throw new Error('Option "'+a+'" does not exists!');return delete this._options[a],this},_options:{type:"Property/Type","default":"Property/Default",methods:"Property/Methods",constraints:"Property/Constraints",converters:"Property/Converters",getters:"Property/Getters",setters:"Property/Setters"}}),e("Property","meta",function(c){c("Constraints",{SETTER_NAME:"__constraints__",SETTER_WEIGHT:-100,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(a,e){return d.apply(a,b,c,e,this)})},apply:function(a,b,c,d,e){for(var f in b)if(!b[f].call(e,a,c,d))throw new Error('Constraint "'+f+'" was failed!');return a}}),c("Converters",{SETTER_NAME:"__converters__",SETTER_WEIGHT:100,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(a,e){return d.apply(a,b,c,e,this)})},apply:function(a,b,c,d,e){for(var f in b)a=b[f].call(e,a,c,d);return a}}),c("Default",{process:function(a,c,d){b.isUndefined(c)||a.__setPropertyParam(d,"default",c)}}),c("Getters",{process:function(a,b,c){for(var d in b)a.__addGetter(c,d,b[d])}}),c("Methods",{process:function(a,b,c){for(var d=0,e=b.length;e>d;++d)this.addMethodToObject(b[d],a,c)},addMethodToObject:function(a,b,c){var d=this.createMethod(a,c);b[d.name]=d.body},createMethod:function(a,c){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');var d=this._methods[a](c);return b.isFunction(d)&&(d={name:this.getMethodName(c,a),body:d}),d},getMethodName:function(a,b){var c="";a=a.replace(/^(_+)/g,function(a){return c=a,""});var d="is"===b&&0===a.indexOf("is")?a:b+a[0].toUpperCase()+a.slice(1);return c+d},addMethod:function(a,b){if(a in this._methods)throw new Error('Method "'+a+'" is already exists!');return this._methods[a]=b,this},hasMethod:function(a){return a in this._methods},removeMethod:function(a){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');return delete this._methods[a],this},_methods:{get:function(a){return function(c){return this.__getPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},set:function(c){return function(d,e){return b.isUndefined(e)&&(e=d,d=a),this.__setPropertyValue([c].concat(b.isString(d)?d.split("."):d||[]),e)}},is:function(c){return function(d,e){return b.isUndefined(e)&&(e=d,d=a),this.__isPropertyValue([c].concat(b.isString(d)?d.split("."):d||[]),e)}},has:function(a){return function(c){return this.__hasPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},clear:function(a){return function(c){return this.__clearPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},remove:function(a){return function(c){return this.__removePropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}}}}),c("Setters",{process:function(a,b,c){for(var d in b)a.__addSetter(c,d,b[d])}}),c("Type",{SETTER_NAME:"__type__",SETTER_WEIGHT:-1e3,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(e,f){for(var g=b||{},h=0,i=f.length;i>h;++h){var j=g[1]||{};if(!("element"in j))return e;g=j.element}return d.apply(e,g,c,f,a)})},apply:function(a,c,d,e,f){if(b.isUndefined(a)||b.isNull(a))return a;var g={};if(b.isArray(c)&&(g=c[1]||{},c=c[0]),!(c in this._types))throw new Error('Property type "'+c+'" does not exists!');return this._types[c].call(this,a,g,d,e,f)},addType:function(a,b){if(a in this._types)throw new Error('Property type "'+a+'" is already exists!');return this._types[a]=b,this},hasType:function(a){return a in this._types},removeType:function(a){if(!(a in this._types))throw new Error('Property type "'+a+'" does not exists!');return delete this._types[a],this},setDefaultArrayDelimiter:function(a){if(!b.isString(a)&&!b.isRegExp(a))throw new Error("Delimiter must be a string or a regular expression!");return this._defaultArrayDelimiter=a,this},getDefaultArrayDelimiter:function(){return this._defaultArrayDelimiter},_defaultArrayDelimiter:/\s*,\s*/g,_types:{"boolean":function(a){return Boolean(a)},number:function(a,b,c){if(a=Number(a),"min"in b&&a<b.min)throw new Error('Value "'+a+'" of property "'+c+'" must not be less then "'+b.min+'"!');if("max"in b&&a>b.max)throw new Error('Value "'+a+'" of property "'+c+'" must not be greater then "'+b.max+'"!');return a},string:function(a,b,c){if(a=String(a),"pattern"in b&&!b.pattern.test(a))throw new Error('Value "'+a+'" of property "'+c+'" does not match pattern "'+b.pattern+'"!');if("variants"in b&&-1===b.variants.indexOf(a))throw new Error('Value "'+a+'" of property "'+c+'" must be one of "'+b.variants.join(", ")+'"!');return a},datetime:function(a,c,d){if(b.isNumber(a)&&!isNaN(a)?a=new Date(a):b.isString(a)&&(a=new Date(Date.parse(a))),!(a instanceof Date))throw new Error('Value of property "'+d+'" must have datetime type!');return a},array:function(a,c,d,e,f){if(b.isString(a)&&(a=a.split(c.delimiter||this._defaultArrayDelimiter)),"element"in c)for(var g=0,h=a.length;h>g;++g)a[g]=this.apply(a[g],c.element,d,e.concat(g),f);return a},hash:function(a,c,d,e,f){if(!b.isObject(a))throw new Error('Value of property "'+[d].concat(e).join(".")+'" must have object type!');if("keys"in c)for(var g in a)if(-1===c.keys.indexOf(g))throw new Error('Unsupported hash key "'+g+'" for property "'+[d].concat(e).join(".")+'"!');if("element"in c)for(var g in a)a[g]=this.apply.call(this,a[g],c.element,d,e.concat(g),f);return a},object:function(a,c,d,e,f){if(!b.isObject(a))throw new Error('Value of property "'+d+'" must have an object type!');if("instanceOf"in c){var g=c.instanceOf,h=f.__isClazz?f.__clazz:f.__clazz.__clazz;if(b.isString(g)&&(g=h.getNamespace().adjustPath(g),a.__clazz||(g=h(g))),a.__clazz?!a.__clazz.__isSubclazzOf(g):!(a instanceof g)){var i=g.__isClazz?g.__name:b.isString(g)?g:"another";throw new Error('Value of property "'+d+'" must be instance of '+i+" clazz!")}}return a},"function":function(a,c,d){if(!b.isFunction(a))throw new Error('Value of property "'+d+'" must have function type');return a}}})}),c("Base",function(){var a=0;return{clazz_methods:{create:function(){return b.construct(this,b.toArray(arguments))},parent:function(a,c,d){a=a||this;var e=a.__isClazz?this.__parent:this.__parent.prototype;if(!c)return e;if(!(c in e))throw new Error('Parent does not have property "'+c+'"!');return b.isFunction(e[c])?e[c].apply(a,d||[]):e[c]},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},on:function(a,b,c){return this.__addEventListener(a,b,c)},off:function(a,b){return this.__removeEventListener(a,b)},"const":function(){return this.__getConstant.apply(this,b.toArray(arguments))}},methods:{getUID:function(){return this.__uid},init:function(b){return this.__uid=++a,this.__setData(b)},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},on:function(a,b,c){return this.__addEventListener(a,b,c)},off:function(a,b){return this.__removeEventListener(a,b)},"const":function(){return this.__clazz.const.apply(this.__clazz,b.toArray(arguments))}}}})}),l.getFactory().setMetaProcessor(i("/ClazzJS/Base")).setBaseClazz(l("/ClazzJS/Base")),{Namespace:c,Clazz:e,Meta:d,namespace:g,clazz:l,meta:i,_:b}}); | ||
!function(a,b,c,d){if("function"==typeof define&&define.amd)define(b,c,d);else if("object"==typeof exports&&exports){for(var e=0,f=c.length;f>e;++e){var g=c[e];"string"==typeof g&&(g=g.replace(/([A-Z]+)/g,function(a){return"-"+a.toLowerCase()}).replace(/^-/,""),c[e]=require(g))}var h=d.apply(a,c);for(var i in h)exports[i]=h[i]}else{for(var e=0,f=c.length;f>e;++e){var g=c[e];if("string"==typeof g){if(!(g in a))throw new Error('"'+b+'" dependent on non exited module "'+g+'"!');c[e]=a[g]}}a[b]=d.apply(a,c)}}(new Function("return this")(),"ClazzJS",[],function(a){var b=function(){var a={},b=Object.prototype.toString,c=Array.prototype.slice;a.isUndefined=function(a){return void 0===a},a.isObject=function(a){return a===Object(a)},a.isSimpleObject=function(a){return"[object Object]"===b.call(a)},a.isNull=function(a){return null===a};for(var d=["Function","String","Number","Date","RegExp","Array"],e=0,f=d.length;f>e;++e)!function(c){a["is"+c]=function(a){return b.call(a)==="[object "+c+"]"}}(d[e]);return a.toArray=function(a){return c.call(a)},a.extend=function(a){for(var b=c.call(arguments,1),d=0,e=b.length;e>d;++d){var f=b[d];if(f)for(var g in f)a[g]=f[g]}return a},a.last=function(a){return a[a.length-1]},a.construct=function(a,b){var c=function(){return a.apply(this,b)};return c.prototype=a.prototype,new c},a}(),c=function(){var a=function(c,d){var e=function(a){var c=e.getScope().getNamespace(e.adjustPath(a));return arguments.length>1&&c.space.apply(c,b.toArray(arguments).slice(1)),c};return b.extend(e,a.prototype),e._scope=c,e._path=d,e._spaces=[],e._objects={},e};b.extend(a.prototype,{getPath:function(){return this._path},getScope:function(){return this._scope},adjustPath:function(a){return this._scope.isAbsolutePath(a)?this._scope.adjustPath(a):this._scope.concatPaths(this.getPath(),a)},get:function(a){return a in this._objects||(this._objects[a]=this._scope.get(a).call(this)),this._objects[a]},has:function(a){return this._scope.has(a)},space:function(){var a=this,c=b.toArray(arguments).slice(0,-1),d=b.last(arguments),e=[];c.length||(c=this._scope.getDefaultInjects());for(var f=0,g=c.length;g>f;++f)e[f]=this.get(c[f]);return this._spaces.push(function(){d.apply(a,e)}),this},executeSpace:function(){return this._spaces.length?(this._spaces.pop()(),!0):!1}});var c=function(a){a=a||{},this._innerDelimiter=a.innerDelimiter||"/",this._delimiters=a.delimiters||["\\","/","."],this._defaultInjects=a.defaultInjects||[],this._namespaces={},this._factories={},this._search=[]};return b.extend(c.prototype,{getInnerDelimiter:function(){return this._innerDelimiter},setInnerDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not supported!');return this._innerDelimiter=a,this},getDelimiters:function(){return this._delimiters},addDelimiter:function(a){if(this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" is already exists!');return this},removeDelimiter:function(a){if(!this.hasDelimiter(a))throw new Error('Delimiter "'+a+'" does not exists!')},hasDelimiter:function(a){return-1!==this._delimiters.indexOf(a)},getNamespace:function(b){return b=this.adjustPath(b),b in this._namespaces||(this._namespaces[b]=a(this,b)),this._namespaces[b]},getRootNamespace:function(){return this.getNamespace(this.getRootPath())},getRootPath:function(){return this._innerDelimiter},adjustPath:function(a){var b=this.getInnerDelimiter(),c=this.getDelimiters();return a.replace(new RegExp("[\\"+c.join("\\")+"]","g"),b).replace(new RegExp(b+"+","g"),b).replace(new RegExp("(.+)"+b+"$"),function(a){return a})},isAbsolutePath:function(a){return 0===a.indexOf(this.getRootNamespace().getPath())},concatPaths:function(){return this.adjustPath(b.toArray(arguments).join(this.getInnerDelimiter()))},set:function(a,b){if(a in this._factories)throw new Error('Factory for object "'+a+'" is already exists!');return this._factories[a]=b,this},get:function(a){if(!(a in this._factories))throw new Error('Factory for object "'+a+'" does not exists!');return this._factories[a]},has:function(a){return a in this._factories},remove:function(a){return delete this._factories[a],this},getInSearchError:function(a){var b=new Error('Path "'+a+'" is in search state!');return b.inSearch=!0,b.path=a,b},isInSearchError:function(a){return a.inSearch},search:function(a,c){a=this.adjustPath(a);var d=c(a);if(!b.isUndefined(d))return d;for(var e=this.getInnerDelimiter(),f=a.split(e),g=f.pop();f.length;){var h=f.join(e);if(h in this._namespaces)for(var i=this._namespaces[h];i.executeSpace();)if(d=c(h+e+g),!b.isUndefined(d))return d;g=f.pop()}},getDefaultInjects:function(){return this._defaultInjects},addDefaultInject:function(a){if(-1!==this._defaultInjects.indexOf(a))throw new Error('Default inject "'+a+'" is already exists!');return this._defaultInjects.push(a),this},removeDefaultInject:function(a){var b=this._defaultInjects.indexOf(a);if(-1===b)throw new Error('Default inject "'+a+'" does not exists!');return this._defaultInjects.splice(b,1),this}}),{Namespace:a,Scope:c}}(),d=function(){var a=function(){this._processors={}};b.extend(a.prototype,{getProcessor:function(a){return this.checkProcessor(a),this._processors[a]},hasProcessor:function(a){return a in this._processors},setProcessor:function(a,c){return b.isFunction(c)&&(c={process:c}),this._processors[a]=c,this},removeProcessor:function(a){this.checkProcessor(a);var b=this._processors[a];return delete this._processors[a],b},getProcessors:function(){return this._processors},setProcessors:function(a){for(var b in a)this.setProcessor(b,a[b]);return this},checkProcessor:function(a){if(!this.hasProcessor(a))throw new Error('Meta processor "'+a+'" does not exists!')}});var c=function(a,d){var e=function(a,c){return b.isUndefined(c)?e.get(a):e.set(a,c)};return b.extend(e,c.prototype),e._manager=a,e._namespace=d,e};return b.extend(c.prototype,{getManager:function(){return this._manager},getNamespace:function(){return this._namespace},get:function(a){var b=this.getManager(),c=this.resolveProcessorName(a);if(!c)throw new Error('Meta processor "'+a+'" does not exist!');return b.getProcessor(c)},set:function(a,b){var c=this.getNamespace(),d=this.getManager();return d.setProcessor(c.adjustPath(a),b),this},resolveProcessorName:function(a){var b=this.getManager(),c=this.getNamespace();return c.getScope().search(c.adjustPath(a),function(a){return b.hasProcessor(a)?a:void 0})}}),{Meta:c,Manager:a}}(),e=function(){var c=function(a,d,e){var f=function(a,c,d){var e=b.last(arguments);return b.isFunction(e)&&!e.prototype.__clazz||"[object Object]"===Object.prototype.toString.call(e)?(f.set(a,c,d),void 0):f.get(a,c,d)};return b.extend(f,c.prototype),f._manager=a,f._factory=d,f._namespace=e,f};b.extend(c.prototype,{getManager:function(){return this._manager},getFactory:function(){return this._factory},getNamespace:function(){return this._namespace},has:function(a){return!!this.resolveName(a)},get:function(c,d,e){b.isUndefined(e)&&b.isArray(d)&&(e=d,d=a);var f=this.resolvePath(c);if(!f)throw new Error('Clazz "'+c+'" does not exists!');e=e||[];var g=this.getManager();if(!g.hasClazz(f,d,e)){var h=this.getFactory(),i=g.getClazzData(f);g.setClazz(f,h.create({name:i.name,parent:d,metaParent:i.parent,meta:i.meta,dependencies:e,clazz:i.clazz}),d,e)}return g.getClazz(f,d,e)},set:function(c,d,e){b.isUndefined(e)&&(e=d,d=a);var f=this.getNamespace(),g=this.getManager();return b.isUndefined(e)&&(e=d,d=null),c=f.adjustPath(c),b.isString(d)&&(d=f.adjustPath(d)),g.setClazzData(c,{name:c,parent:d,meta:e,clazz:this}),this},resolvePath:function(a){var b=this.getNamespace(),c=this.getManager();return b.getScope().search(b.adjustPath(a),function(a){return c.hasClazzData(a)?a:void 0})}});var d=function(a){a=a||{},this._clazzUID=0,this._metaProcessor=a.metaProcessor||null,this._baseClazz=a.baseClazz||null};b.extend(d.prototype,{CLAZZ_NAME:"Clazz{uid}",getBaseClazz:function(){return this._baseClazz},setBaseClazz:function(a){if(!b.isFunction(a))throw new Error("Base clazz must be a function!");return this._baseClazz=a,this},getMetaProcessor:function(){return this._metaProcessor},setMetaProcessor:function(a){if(!b.isFunction(a.process))throw new Error('Meta processor must have "process" method!');return this._metaProcessor=a,this},create:function(a){var c=a.name||this.generateName(),d=a.parent,e=a.metaParent,f=a.meta||{},g=a.dependencies||[],h=a.clazz,i=this.createClazz();return i.__name=c,i.__clazz=h,b.isFunction(f)&&(f=f.apply(i,[i].concat(g))||{}),!f.parent&&e&&(f.parent=e),d=d||f.parent,b.isString(d)&&(d=[d]),b.isArray(d)&&(d=h.get.apply(h,d)),this.applyParent(i,d),i.prototype.__clazz=i,i.prototype.__proto=i.prototype,this.applyMeta(i,f),i},createClazz:function(){return function a(){var c;return this instanceof a?(b.isFunction(a.__construct)&&(c=a.__construct.apply(this,b.toArray(arguments))),b.isUndefined(c)?void 0:c):b.construct(a,b.toArray(arguments))}},applyParent:function(c,d){if(d=d||this.getBaseClazz())for(var e in d)e in c||(b.isFunction(d[e])?c[e]=d[e]:"_"===e[0]&&(c[e]=a));return c.prototype=b.extend(Object.create(d?d.prototype:{}),c.prototype),c.__parent=d||null,c.prototype.constructor=c,c.prototype.__parent=d?d.prototype:null,c},applyMeta:function(a,b){return this.getMetaProcessor().process(a,b),a},generateName:function(){return this.CLAZZ_NAME.replace("{uid}",++this._clazzUID)}});var e=function(){this._clazz={},this._clazzData={}};return b.extend(e.prototype,{setClazzData:function(a,b){return this._clazzData[a]=b,this},hasClazzData:function(a){return a in this._clazzData},getClazzData:function(a){if(!this.hasClazzData(a))throw new Error('Data does not exists for clazz "'+a+'"!');return this._clazzData[a]},getClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return d[e][0]}throw new Error('Clazz "'+a+'" does not exists!')},hasClazz:function(a,b,c){if(a in this._clazz)for(var d=this._clazz[a],e=0,f=d.length;f>e;++e)if(!b||d[e][1]===b){var g=!0;if(c)for(var h=0,i=d[e][2].length;i>h;++h)if(d[e][2][h]!==c[h]){g=!1;break}if(g)return!0}return!1},setClazz:function(a,c,d,e){if(!b.isFunction(c))throw new Error("Clazz must be a function!");return a in this._clazz||(this._clazz[a]=[]),this._clazz[a].push([c,d,e||[]]),this}}),{Clazz:c,Factory:d,Manager:e}}(),f=new c.Scope({defaultInjects:["clazz","namespace"]}),g=f.getRootNamespace(),h=new d.Manager,i=new d.Meta(h,g),j=new e.Manager,k=new e.Factory,l=new e.Clazz(j,k,g);return f.set("namespace",function(){return this}),f.set("meta",function(){return new d.Meta(h,this)}),f.set("clazz",function(){return new e.Clazz(j,k,this)}),g("ClazzJS","clazz","meta","namespace",function(c,d,e){d("Base",{_processors:{constants:"Constants",properties:"Properties",methods:"Methods",events:"Events"},process:function(a,c){a.__isClazz||b.extend(a,this.clazz_interface),a.__interfaces||(a.__interfaces=[],a.prototype.__interfaces=[],b.extend(a,this.common_interface),b.extend(a.prototype,this.common_interface)),a.__metaProcessors=c.meta_processors||{};var d=c.parent;if(d&&!a.__isSubclazzOf(d))throw new Error('Clazz "'+a.__name+'" must be subclazz of "'+d.__isClazz?d.__name:d+'"!');var e=a.__getMetaProcessors();for(var f in e)e[f].process(a,c);b.isFunction(this.__setDefaults)&&this.__setDefaults()},getProcessors:function(){var a=this._processors;for(var c in a)b.isString(a[c])&&(a[c]=d(a[c]));return a},setProcessors:function(a){for(var b in a)this.setProcessor(type,b,a[b]);return this},hasProcessor:function(a){return a in this._processors},setProcessor:function(a,b){if(a in this._processors)throw new Error('Processor "'+a+'" is already exists!');return this._processors[a]=b,this},removeProcessor:function(a){if(!(a in this._processors))throw new Error('Processor "'+a+'" does not exists!');return delete this._processors[a],this},clazz_interface:{__isClazz:!0,__isSubclazzOf:function(a){for(var b=this;b;){if(b===a||b.__name===a)return!0;b=b.__parent}return!1},__construct:function(){for(var a in this)0===a.indexOf("__init")&&b.isFunction(this[a])&&this[a]();b.isFunction(this.init)&&this.init.apply(this,b.toArray(arguments)),b.isFunction(this.__setDefaults)&&this.__setDefaults(),b.isFunction(this.__clazz.__emitEvent)&&this.__clazz.__emitEvent("instance.created",this)}},common_interface:{__isInterfaceImplemented:function(a){return-1!==this.__interfaces.indexOf(a)},__implementInterface:function(a,c){if(-1!==this.__interfaces.indexOf(a))throw new Error('Interface "'+a+'" is already implemented!');return this.__interfaces.push(a),b.extend(this,c),this},__collectAllPropertyValues:function(a,c){var d=[];this.hasOwnProperty(a)&&d.push(this[a]),this.__proto&&this.__proto.hasOwnProperty(a)&&d.push(this.__proto[a]);for(var e=this.__parent;e;)e.hasOwnProperty(a)&&d.push(e[a]),e=e.__parent;for(var f=b.toArray(arguments).slice(2),g={},h=0,i=d.length;i>h;++h)this.__collectValues(g,d[h],c||1,f);return g},__collectValues:function f(a,b,c,d,e){d=[].concat(d||[]);for(var g in b)d[0]&&g!==d[0]||(c>1&&"[object Object]"===Object.prototype.toString.call(b[g])?(g in a||(a[g]={}),f(a[g],b[g],c-1,d.slice(1))):!e&&g in a||(a[g]=b[g]));return a},__getMetaProcessors:function(){var a=this.__isClazz?this:this.__clazz;return this.__collectValues(a.__collectAllPropertyValues("__metaProcessors",1),d("Base").getProcessors())}}}),d("Constants",{process:function(a,b){this.applyConstants(a,b.constants||{})},applyConstants:function(a,b){a.__isInterfaceImplemented("constants")||a.__implementInterface("constants",this.interface),a.__initConstants();for(var c in b)a.__constants[c]=b[c]},"interface":{__initConstants:function(){this.__constants={}},__getConstants:function(){return this.__collectAllPropertyValues("__constants",99)},__getConstant:function(){for(var a=b.toArray(arguments),c=this.__collectAllPropertyValues.apply(this,["__constants",99].concat(a)),d=0,e=a.length;e>d;++d){if(!(a[d]in c))throw new Error('Constant "'+a.splice(0,d).join(".")+'" does not exists!');c=c[a[d]]}return c}}}),d("Events",{process:function(a,b){this.applyEvents(a,b.clazz_events||{}),this.applyEvents(a.prototype,b.events||{})},applyEvents:function(a,b){a.__isInterfaceImplemented("events")||a.__implementInterface("events",this.interface),a.__initEventsCallbacks();for(var c in b)for(var d in b[c])a.__addEventListener(c,d,b[c][d])},"interface":{__initEventsCallbacks:function(){this.__events={}},__emitEvent:function(a){var c=this.__getEventListeners(a);for(var d in c)c[d].apply(this,b.toArray(arguments).slice(1));return this},__addEventListener:function(a,b,c){if(this.__hasEventListener(a,b))throw new Error('Event listener for event "'+a+'" with name "'+b+'" is already exists!');return a in this.__events||(this.__events[a]={}),this.__events[a][b]=c,this},__removeEventListener:function(c,d){if(c in this.__events||(this.__events[c]={}),b.isUndefined(d)){var e=this.__getEventListeners(c);for(var d in e)this.__events[c][d]=a}else{if(!this.__hasEventListener(c,d))throw new Error('There is no "'+c+(d?'"::"'+d:"")+'" event callback!');this.__events[c][d]=a}return this},__hasEventListener:function(a,b){return b in this.__getEventListeners(a)},__getEventListener:function(a,b){var c=this.__getEventListeners(a);if(!(b in c))throw new Error('Event listener for event "'+a+'" with name "'+b+'" does not exists!');return c[a][b]},__getEventListeners:function(a){var c=this.__collectAllPropertyValues.apply(this,["__events",2].concat(a||[]));for(var d in c)for(var e in c[d])b.isUndefined(c[d][e])&&delete c[d][e];return a?c[a]||{}:c}}}),d("Methods",{process:function(a,b){this.applyMethods(a,b.clazz_methods||{}),this.applyMethods(a.prototype,b.methods||{})},applyMethods:function(a,c){for(var d in c){if(!b.isFunction(c[d]))throw new Error('Method "'+d+'" must be a function!');a[d]=c[d]}}}),d("Properties",{_propertyMetaProcessor:"Property",process:function(a,b){this.applyProperties(a,b.clazz_properties||{}),this.applyProperties(a.prototype,b.properties||{})},applyProperties:function(a,b){a.__isInterfaceImplemented("properties")||a.__implementInterface("properties",this.interface),a.__initProperties();var c=this.getPropertyMetaProcessor();for(var d in b)c.process(a,b[d],d)},getPropertyMetaProcessor:function(){var a=this._propertyMetaProcessor;return b.isString(a)&&(this._propertyMetaProcessor=d(a)),a},setPropertyMetaProcessor:function(a){return this._propertyMetaProcessor=a,this},"interface":{__initProperties:function(){this.__properties={},this.__setters={},this.__getters={}},__setDefaults:function(){var a=this.__getPropertiesParam();for(var c in a)if("default"in a[c]){var d=a[c].default;b.isFunction(d)&&(d=d.call(this)),this["_"+c]=d}},__setPropertiesParam:function(a){for(var b in a)this.__setPropertyParam(b,a[b]);return this},__getPropertiesParam:function(){return this.__collectAllPropertyValues("__properties",2)},__setPropertyParam:function(a,c,d){var e={};return b.isUndefined(d)?b.isObject(c)&&b.extend(e,c):e[c]=d,a in this.__properties||(this.__properties[a]={}),b.extend(this.__properties[a],e),this},__getPropertyParam:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__properties",2,a].concat(b||[]));return b?c[b]:c},__hasProperty:function(a){return"_"+a in this},__getPropertyValue:function(a){b.isString(a)&&(a=a.split("."));var c=a.shift();if(!this.__hasProperty(c))throw new Error('Property "'+c+'" does not exists!');for(var d=this.__applyGetters(c,this["_"+c]),e=0,f=a.length;f>e;++e){var g=a[e];if(!(g in d))throw new Error('Property "'+[c].concat(a.slice(0,e+1)).join(".")+'" does not exists!');d=this.__applyGetters(c,d[g],a.slice(0,e+1))}return d},__hasPropertyValue:function(a){b.isString(a)&&(a=a.split("."));var c=a.shift();if(!this.__hasProperty(c))throw new Error('Property "'+c+'" does not exists!');for(var d=this.__applyGetters(c,this["_"+c]),e=0,f=a.length;f>e;++e){var g=a[e];if(!(g in d))return!1;d=this.__applyGetters(c,d[g],a.slice(0,e+1))}return!b.isUndefined(d)&&!b.isNull(d)},__isPropertyValue:function(a,c){var d=this.__getPropertyValue(a);return b.isUndefined(c)?!!d:d===c},__clearPropertyValue:function(c){b.isString(c)&&(c=c.split("."));var d=c.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;if(c.length){if(e=b.last(c),f=this.__getPropertyValue([d].concat(c).slice(0,-1)),!(e in f))throw new Error('Property "'+[d].concat(c).join(".")+'" does not exists!')}else e="_"+d,f=this;var g=f[e];return f[e]=b.isSimpleObject(g)&&{}||b.isArray&&[]||a,this.__checkEmitEvent()&&this.__emitPropertyCleared([d].concat(c),g),this},__removePropertyValue:function(c){b.isString(c)&&(c=c.split("."));var d=c.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;if(c.length){if(e=b.last(c),f=this.__getPropertyValue([d].concat(c).slice(0,-1)),!(e in f))throw new Error('Property "'+[d].concat(c).join(".")+'" does not exists!')}else e="_"+d,f=this;var g=f[e];return c.length?delete f[e]:f[e]=a,this.__checkEmitEvent()&&this.__emitPropertyRemoved([d].concat(c),g),this},__setPropertyValue:function(a,c){b.isString(a)&&(a=a.split("."));var d=a.shift();if(!this.__hasProperty(d))throw new Error('Property "'+d+'" does not exists!');var e,f;a.length?(e=b.last(a),f=this.__getPropertyValue([d].concat(a).slice(0,-1))):(e="_"+d,f=this);var g=e in f,h=f[e],i=this.__applySetters(d,c,a);return f[e]=i,this.__checkEmitEvent()&&this.__emitPropertySetted([d].concat(a),i,h,g),this},__emitPropertyRemoved:function(a,c){var d,e;return this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split(".")),a.length&&(d=a.slice(0,-1).join("."),e=b.last(a),this.__emitEvent("property."+d+".item_removed",e,c),this.__emitEvent("property.item_removed",d,e,c)),d=a.join("."),this.__emitEvent("property."+d+".removed",c),this.__emitEvent("property.removed",d,c),this},__emitPropertyCleared:function(a,c){var d,e,f,g;if(this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split(".")),b.isSimpleObject(c))for(e in c)this.__emitPropertyRemoved(a.concat(e),c[e]);else if(b.isArray(c))for(f=0,g=c.length;g>f;++f)this.__emitPropertyRemoved(a.concat(f),c[f]);return d=a.join("."),this.__emitEvent("property."+d+".cleared",c),this.__emitEvent("property.cleared",d,c),this},__emitPropertySetted:function(a,c,d,e){var f,g,h,i,j;this.__checkEmitEvent(!0),b.isString(a)&&(a=a.split("."));var k=!0;if(b.isSimpleObject(c)&&b.isSimpleObject(d)){for(h in d)if(c[h]!==d[h]){k=!1;break}}else if(b.isArray(c)&&b.isArray(d)){for(i=0,j=d.length;j>i;++i)if(c[i]!==d[i]){k=!1;break}}else c!==d&&(k=!1);return k||(f=a.join("."),g=b.isUndefined(d)||b.isNull(d)?"setted":"changed",this.__emitEvent("property."+f+"."+g,c,d),this.__emitEvent("property."+g,f,c,d),a.length&&!e&&(f=a.slice(0,-1).join("."),h=b.last(a),this.__emitEvent("property."+f+".item_added",h,c),this.__emitEvent("property.item_added",f,h,c))),this},__checkEmitEvent:function(a){a=b.isUndefined(a)?!1:a;var c=b.isFunction(this.__emitEvent);if(a&&!c)throw new Error("__emitEvent method does not realized!");return c},__addSetter:function(a,c,d,e){if(b.isUndefined(e)&&(e=d,d=0),b.isArray(e))d=e[0],e=e[1];else if(!b.isFunction(e))throw new Error("Setter callback must be a function!");return a in this.__setters||(this.__setters[a]={}),this.__setters[a][c]=[d,e],this},__getSetters:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__setters",1].concat(a||[]));if(!a)return c;if(c=c[a],!b)return c[a];var d=[];for(var e in c)d.push(c[e]);d=d.sort(function(a,b){return b[0]-a[1]});for(var f=0,g=d.length;g>f;++f)d[f]=d[f][1];return d},__applySetters:function(a,c,d){d=d||[];for(var e=this.__getSetters(a,!0),f=0,g=e.length;g>f;++f){var h=e[f].call(this,c,d);b.isUndefined(h)||(c=h)}return c},__addGetter:function(a,c,d,e){if(b.isUndefined(e)&&(e=d,d=0),b.isArray(e))d=e[0],e=e[1];else if(!b.isFunction(e))throw new Error("Getter callback must be a function!");return a in this.__getters||(this.__getters[a]={}),this.__getters[a][c]=[d,e],this},__getGetters:function(a,b){var c=this.__collectAllPropertyValues.apply(this,["__getters",1].concat(a||[]));if(!a)return c;if(c=c[a],!b)return c[a];var d=[];for(var e in c)d.push(c[e]);d=d.sort(function(a,b){return b[0]-a[1]});for(var f=0,g=d.length;g>f;++f)d[f]=d[f][1];return d},__applyGetters:function(a,c,d){d=d||[];for(var e=this.__getGetters(a,!0),f=0,g=e.length;g>f;++f){var h=e[f].call(this,c,d);b.isUndefined(h)||(c=h)}return c},__setData:function(a){for(var b in a)this.__hasProperty(b)&&this.__setPropertyValue(b,a[b]);return this},__getData:function(){var a={},c=this.__getPropertiesParam();for(var d in c){var e=this.__getPropertyValue(d);if(b.isArray(e))for(var f=0,g=e.length;g>f;++f)b.isFunction(e[f].__getData)&&(e[f]=e[f].__getData());else if(e.constructor==={}.constructor)for(var h in e)b.isFunction(e[h].__getData)&&(e[h]=e[h].__getData());else b.isFunction(e.__getData)&&(e=e.__getData());a[d]=e}return a}}}),d("Property",{process:function(c,e,f){c["_"+f]=a,b.isArray(e)?e=3!==e.length&&b.isSimpleObject(e[1])?{type:e}:{type:[e[0],e[2]||{}],"default":e[1]}:b.isSimpleObject(e)||(e={"default":e}),"methods"in e||(e.methods=["get","set","has","is","clear","remove"]);for(var g in e)if(g in this._options){var h=this._options[g];b.isString(h)&&(h=d(h)),h.process(c,e[g],f)}},addOption:function(a,b){if(a in this._options)throw new Error('Option "'+a+'" is already exists!');return this._options[a]=b,this},hasOption:function(a){return a in this._options},removeOption:function(a){if(!(a in this._options))throw new Error('Option "'+a+'" does not exists!');return delete this._options[a],this},_options:{type:"Property/Type","default":"Property/Default",methods:"Property/Methods",constraints:"Property/Constraints",converters:"Property/Converters",getters:"Property/Getters",setters:"Property/Setters"}}),e("Property","meta",function(c){c("Constraints",{SETTER_NAME:"__constraints__",SETTER_WEIGHT:-100,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(a,e){return d.apply(a,b,c,e,this)})},apply:function(a,b,c,d,e){for(var f in b)if(!b[f].call(e,a,c,d))throw new Error('Constraint "'+f+'" was failed!');return a}}),c("Converters",{SETTER_NAME:"__converters__",SETTER_WEIGHT:100,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(a,e){return d.apply(a,b,c,e,this)})},apply:function(a,b,c,d,e){for(var f in b)a=b[f].call(e,a,c,d);return a}}),c("Default",{process:function(a,c,d){b.isUndefined(c)||a.__setPropertyParam(d,"default",c)}}),c("Getters",{process:function(a,b,c){for(var d in b)a.__addGetter(c,d,b[d])}}),c("Methods",{process:function(a,b,c){for(var d=0,e=b.length;e>d;++d)this.addMethodToObject(b[d],a,c)},addMethodToObject:function(a,b,c){var d=this.createMethod(a,c);b[d.name]=d.body},createMethod:function(a,c){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');var d=this._methods[a](c);return b.isFunction(d)&&(d={name:this.getMethodName(c,a),body:d}),d},getMethodName:function(a,b){var c="";a=a.replace(/^(_+)/g,function(a){return c=a,""});var d="is"===b&&0===a.indexOf("is")?a:b+a[0].toUpperCase()+a.slice(1);return c+d},addMethod:function(a,b){if(a in this._methods)throw new Error('Method "'+a+'" is already exists!');return this._methods[a]=b,this},hasMethod:function(a){return a in this._methods},removeMethod:function(a){if(!(a in this._methods))throw new Error('Method "'+a+'" does not exists!');return delete this._methods[a],this},_methods:{get:function(a){return function(c){return this.__getPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},set:function(c){return function(d,e){return b.isUndefined(e)&&(e=d,d=a),this.__setPropertyValue([c].concat(b.isString(d)?d.split("."):d||[]),e)}},is:function(c){return function(d,e){return b.isUndefined(e)&&(e=d,d=a),this.__isPropertyValue([c].concat(b.isString(d)?d.split("."):d||[]),e)}},has:function(a){return function(c){return this.__hasPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},clear:function(a){return function(c){return this.__clearPropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}},remove:function(a){return function(c){return this.__removePropertyValue([a].concat(b.isString(c)?c.split("."):c||[]))}}}}),c("Setters",{process:function(a,b,c){for(var d in b)a.__addSetter(c,d,b[d])}}),c("Type",{SETTER_NAME:"__type__",SETTER_WEIGHT:-1e3,process:function(a,b,c){var d=this;a.__addSetter(c,this.SETTER_NAME,this.SETTER_WEIGHT,function(e,f){for(var g=b||{},h=0,i=f.length;i>h;++h){var j=g[1]||{};if(!("element"in j))return e;g=j.element}return d.apply(e,g,c,f,a)})},apply:function(a,c,d,e,f){if(b.isUndefined(a)||b.isNull(a))return a;var g={};if(b.isArray(c)&&(g=c[1]||{},c=c[0]),!(c in this._types))throw new Error('Property type "'+c+'" does not exists!');return this._types[c].call(this,a,g,d,e,f)},addType:function(a,b){if(a in this._types)throw new Error('Property type "'+a+'" is already exists!');return this._types[a]=b,this},hasType:function(a){return a in this._types},removeType:function(a){if(!(a in this._types))throw new Error('Property type "'+a+'" does not exists!');return delete this._types[a],this},setDefaultArrayDelimiter:function(a){if(!b.isString(a)&&!b.isRegExp(a))throw new Error("Delimiter must be a string or a regular expression!");return this._defaultArrayDelimiter=a,this},getDefaultArrayDelimiter:function(){return this._defaultArrayDelimiter},_defaultArrayDelimiter:/\s*,\s*/g,_types:{"boolean":function(a){return Boolean(a)},number:function(a,b,c){if(a=Number(a),"min"in b&&a<b.min)throw new Error('Value "'+a+'" of property "'+c+'" must not be less then "'+b.min+'"!');if("max"in b&&a>b.max)throw new Error('Value "'+a+'" of property "'+c+'" must not be greater then "'+b.max+'"!');return a},string:function(a,b,c){if(a=String(a),"pattern"in b&&!b.pattern.test(a))throw new Error('Value "'+a+'" of property "'+c+'" does not match pattern "'+b.pattern+'"!');if("variants"in b&&-1===b.variants.indexOf(a))throw new Error('Value "'+a+'" of property "'+c+'" must be one of "'+b.variants.join(", ")+'"!');return a},datetime:function(a,c,d){if(b.isNumber(a)&&!isNaN(a)?a=new Date(a):b.isString(a)&&(a=new Date(Date.parse(a))),!(a instanceof Date))throw new Error('Value of property "'+d+'" must have datetime type!');return a},array:function(a,c,d,e,f){if(b.isString(a)&&(a=a.split(c.delimiter||this._defaultArrayDelimiter)),"element"in c)for(var g=0,h=a.length;h>g;++g)a[g]=this.apply(a[g],c.element,d,e.concat(g),f);return a},hash:function(a,c,d,e,f){if(!b.isObject(a))throw new Error('Value of property "'+[d].concat(e).join(".")+'" must have object type!');if("keys"in c)for(var g in a)if(-1===c.keys.indexOf(g))throw new Error('Unsupported hash key "'+g+'" for property "'+[d].concat(e).join(".")+'"!');if("element"in c)for(var g in a)a[g]=this.apply.call(this,a[g],c.element,d,e.concat(g),f);return a},object:function(a,c,d,e,f){if(!b.isObject(a))throw new Error('Value of property "'+d+'" must have an object type!');if("instanceOf"in c){var g=c.instanceOf,h=f.__isClazz?f.__clazz:f.__clazz.__clazz;if(b.isString(g)&&(g=h.getNamespace().adjustPath(g),a.__clazz||(g=h(g))),a.__clazz?!a.__clazz.__isSubclazzOf(g):!(a instanceof g)){var i=g.__isClazz?g.__name:b.isString(g)?g:"another";throw new Error('Value of property "'+d+'" must be instance of '+i+" clazz!")}}return a},"function":function(a,c,d){if(!b.isFunction(a))throw new Error('Value of property "'+d+'" must have function type');return a}}})}),c("Base",function(){var a=0;return{clazz_methods:{create:function(){return b.construct(this,b.toArray(arguments))},parent:function(a,c,d){a=a||this;var e=a.__isClazz?this.__parent:this.__parent.prototype;if(!c)return e;if(!(c in e))throw new Error('Parent does not have property "'+c+'"!');return b.isFunction(e[c])?e[c].apply(a,d||[]):e[c]},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},on:function(a,b,c){return this.__addEventListener(a,b,c)},off:function(a,b){return this.__removeEventListener(a,b)},"const":function(){return this.__getConstant.apply(this,b.toArray(arguments))}},methods:{getUID:function(){return this.__uid},init:function(b){return this.__uid=++a,this.__setData(b)},emit:function(){return this.__emitEvent.apply(this,b.toArray(arguments))},on:function(a,b,c){return this.__addEventListener(a,b,c)},off:function(a,b){return this.__removeEventListener(a,b)},"const":function(){return this.__clazz.const.apply(this.__clazz,b.toArray(arguments))}}}})}),l.getFactory().setMetaProcessor(i("/ClazzJS/Base")).setBaseClazz(l("/ClazzJS/Base")),{Namespace:c,Clazz:e,Meta:d,namespace:g,clazz:l,meta:i,_:b}}); | ||
//# sourceMappingURL=dist/ClazzJS.min.map |
{ | ||
"name": "clazz-js", | ||
"title": "ClazzJS", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Portable JavaScript library for class-style OOP programming", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -39,2 +39,6 @@ meta('Base', { | ||
} | ||
if (_.isFunction(this.__setDefaults)) { | ||
this.__setDefaults(); | ||
} | ||
}, | ||
@@ -108,2 +112,6 @@ | ||
if (_.isFunction(this.__setDefaults)) { | ||
this.__setDefaults(); | ||
} | ||
if (_.isFunction(this.__clazz.__emitEvent)) { | ||
@@ -110,0 +118,0 @@ this.__clazz.__emitEvent('instance.created', this); |
@@ -12,3 +12,3 @@ meta('Constants', { | ||
object.__constants = {}; | ||
object.__initConstants(); | ||
@@ -15,0 +15,0 @@ for (var constant in constants) { |
@@ -13,3 +13,3 @@ meta('Events', { | ||
object.__events = {}; | ||
object.__initEventsCallbacks(); | ||
@@ -16,0 +16,0 @@ for (var event in events) { |
@@ -15,5 +15,3 @@ meta('Properties', { | ||
object.__properties = {}; | ||
object.__setters = {}; | ||
object.__getters = {}; | ||
object.__initProperties(); | ||
@@ -25,17 +23,2 @@ var propertyMetaProcessor = this.getPropertyMetaProcessor(); | ||
} | ||
var propertiesParams = object.__getPropertiesParam(); | ||
for (var property in propertiesParams) { | ||
if ('default' in propertiesParams[property]) { | ||
var defaultValue = propertiesParams[property].default; | ||
if (_.isFunction(defaultValue)) { | ||
defaultValue = defaultValue.call(object); | ||
} | ||
object['_' + property] = defaultValue; | ||
} | ||
} | ||
}, | ||
@@ -65,2 +48,19 @@ | ||
__setDefaults: function() { | ||
var propertiesParams = this.__getPropertiesParam(); | ||
for (var property in propertiesParams) { | ||
if ('default' in propertiesParams[property]) { | ||
var defaultValue = propertiesParams[property].default; | ||
if (_.isFunction(defaultValue)) { | ||
defaultValue = defaultValue.call(this); | ||
} | ||
this['_' + property] = defaultValue; | ||
} | ||
} | ||
}, | ||
__setPropertiesParam: function(parameters) { | ||
@@ -536,3 +536,3 @@ for (var property in parameters) { | ||
var data = {}; | ||
var properties = this.__getPropertiesMeta(); | ||
var properties = this.__getPropertiesParam(); | ||
@@ -539,0 +539,0 @@ for (var property in properties) { |
Sorry, the diff of this file is too big to display
227335
3817