This repository has been archived by the owner on Jul 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
z-jsoop.min.js
4 lines (4 loc) · 10.4 KB
/
z-jsoop.min.js
1
2
3
4
/**
* Z jSoop 1.2.8
*/
var Z=function(){};!function(){"undefined"!=typeof process&&process.constructor instanceof Object?(Z.global=global,Z.isBrowser=!1,Z.isNode=!0,Z.isDotNet=!1,Z.isPhoneGap=!1,module.exports=Z):"undefined"!=typeof window&&window.navigator&&(Z.global=window,Z.isBrowser=!0,Z.isNode=!1,Z.isDotNet=!1,Z.isPhoneGap=!1)}(),Z.defineApp=function(e){if(void 0===e.name)throw"Defina um namespace para seu projeto/alias no atributo 'name'";if(void 0===e.path)throw"Defina a pasta da aplicação em 'path'";if("string"==typeof e.path&&e.path.match(/.+[^\/\\]$/)&&(e.path+="/"),"string"!=typeof e.path&&"function"!=typeof e.path)throw"O argumento 'path' deve ser uma string ou uma função.";if(Z.exists(e.name))throw"Uma variavel com o nome {0} já existe no escopo global.".format(e.name);if(Z.global[e.name]={path:e.path,name:e.name,isZ:!0},e.main){void 0===e.onLaunch&&(e.onLaunch=function(){});var t=Z.declare(e.main);t.onLoad(function(){Z.create(e.main)}),t.onLoad(e.onLaunch),Z.Require([e.main])}},Z.exists=function(e){e=String(e),e=e.split(".");for(var t=Z.global,n=0;n<e.length;n++){if(!t[e[n]])return!1;t=t[e[n]]}return t},Z.declare=function(e){var t=Z.exists(e);if(t){if(t.isZ)return t;throw"Problema para declarar {0}, a variavel já existe.".format(e)}var n=function(e,t){t||this.constructor(e)};return n.prototype.constructor=function(){throw"{0} ainda não está carregado".format(e)},n.prototype.initConfig=function(){},n.prototype.origin=n,n.identification=n.prototype.identification=e,n.empty=!0,n.isZ=n.prototype.isZ=!0,n.onLoad=function(e){n.todo.push(e)},n.todo=[],Z.declare.setObjectOn(e,n)},Z.declare.setObjectOn=function(e,t){var n=e.split("."),o=Z.global,a={};Z.each(n,function(e){o[e]||(o[e]={}),a=o,o=o[e]});var r=n.pop();return a[r]=t,t},function(){var e=function(e,t){var n,o=["extend","mixins","singleton","statics","requires","config"],a=function(){var o=Z.exists(e);if(o&&!o.empty)throw"Uma classe com o nome {0} já foi definida".format(e);if(r(t),n=Z.declare(e),!n.empty)throw"Tentativa de declarar duas vezes a classe {0}".format(e);return n.empty=!1,p(function(){i(),s(),c()}),n},r=function(){if(void 0===t&&(t={}),!(t instanceof Object))throw"As definições da classe devem ser entregues em um objeto json";if(t.hasOwnProperty("extend")&&"string"!=typeof t.extend)throw"O parâmetro de configuração 'extend' deve conter uma string.";if(t.hasOwnProperty("singleton")&&"boolean"!=typeof t.singleton)throw"O parâmetro de configuração 'singleton' deve conter uma valor booleano.";if(t.hasOwnProperty("requires")){if(!t.requires instanceof Array)throw"O parâmetro de configuração 'requires' recebe um array de strings.";Z.each(t.requires,function(e){if("string"!=typeof e)throw"O parâmetro de configuração 'requires' recebe um array de strings."})}var e="O parâmetro de configuração '{0}' recebe um objeto json";if(t.hasOwnProperty("statics")&&!t.statics instanceof Object)throw e.format("statics");if(t.hasOwnProperty("config")&&!t.config instanceof Object)throw e.format("config");if(t.hasOwnProperty("mixins")){if(t.mixins.constructor!==Object&&t.mixins.constructor!==Array)throw e.format("mixins");Z.each(t.mixins,function(t,n){if("string"!=typeof t)throw e.format("mixins");if("string"!=typeof n&&"number"!=typeof n)throw e.format("mixins")})}},i=function(){var o=function(e){this.initConfig(e)};if(n.prototype.mixins={},d("constructor",o),d("callParent",f),d("initConfig",u),d("getParent",function(){return{constructor:o}}),t.singleton){n.singleton=!0,n.prototype.singleton=!0;var a=n.todo[0];n.todo[0]=function(){var t=e.split("."),o=Z.global,a={};Z.each(t,function(e){o[e]||(o[e]={}),a=o,o=o[e]});var r=t.pop();a[r]=new n},n.onLoad(a)}n.getDefinitions=function(){return t}},s=function(){t.extend&&g(),t.mixins&&Z.each(t.mixins,function(e,t){if("number"==typeof t)for(;void 0!==n.prototype.mixins[t];)t++;y(t,e)}),t.statics&&l(),t.config&&v(),Z.each(t,function(e,t){-1===o.indexOf(t)&&d(t,e)})},c=function(){Z.define.runClassCallbacks(n)},f=function(e){var t=this,n=f.caller,o=e||[];if(!(o instanceof Array||o instanceof arguments.constructor))throw"Argumento inválido para chamada de 'callParent', envie Array ou Arguments";var a=n.owner.prototype,r=a.getParent(),i=r[n.identification];if("function"==typeof i)return i.apply(t,o);throw"O método '{0}' não está sobrescrevendo nenhum método da classe pai para que callParent seja chamado.".format(i)},u=function(e){var t=this;e&&e.constructor===Object&&Z.each(e,function(e,n){var o=h("set",n);"function"==typeof t[o]?t[o](e):t[n]=e})},p=function(e){var n=[];n=n.concat(t.requires||[]),delete t.dependencias,t.extend&&n.push(t.extend),t.mixins&&Z.each(t.mixins,function(e){n.push(e)}),Z.Require(n,e)},l=function(){Z.each(t.statics,function(e,t){n[t]=e})},m=function(e){Z.each(e,function(e,t){n.hasOwnProperty(t)||(n[t]=e)})},d=function(t,o){if(o instanceof Object&&o.constructor!==Function){var a=o.constructor.name;a=a?" (Instância de {0})".format(a):"";var r="{0}{1}{2}{3}".format("Tentativa de criação de propriedade do tipo 'object'",a,", objeto não é aceito como valor padrão para propriedades."," {0}#{1}".format(e,t));throw r}o&&o.constructor===Function&&(o.identification=t,o.owner=n),n.prototype[t]=o},h=function(e,t){var n=t[0].toUpperCase();return t=t.replace(/^./,n),"{0}{1}".format(e,t)},v=function(){var e=t.config;e.constructor===Object&&Z.each(e,function(e,t){var o=h("get",t),a=h("set",t),r=h("apply",t),i=h("update",t),s="_{0}".format(t);d(o,function(){return this[s]}),d(r,function(e){return e}),d(i,function(){}),d(a,function(e){var t=this[s];e=this[r](e,t),this[s]=e,e!==t&&this[i](e,t)}),n.prototype[s]=e})},g=function(){var e=t.extend,o=Z.exists(e);if(!o||!o.isZ)throw"Impossível estender da classe {0}, a classe não foi declarada ou não é uma classe reconhecida".format(o);if(o.singleton)throw"Impossível estender da classe {0}, a classe é singleton.".format(nomeMix);var a=new o(null,!0),r=o.getDefinitions();if(r.statics){var i={};Z.apply(i,r.statics),Z.apply(i,t.statics),t.statics=i}w(o.prototype.mixins),n.prototype=new o(null,!0),d("getParent",function(){return a}),d("constructor",function(){this.callParent(arguments)}),n.prototype.identification=n.identification,n.prototype.origin=n},y=function(e,t){var o=Z.exists(t);if(!o||!o.isZ)throw"Impossível fazer mixin com a classe {0}, a classe não foi declarada ou não é uma classe reconhecida".format(t);if(o.singleton)throw"Impossível fazer mixin com a classe {0}, a classe é singleton.".format(t);var a=o.getDefinitions();m(a.statics);for(var r in o.prototype)void 0===n.prototype[r]&&(n.prototype[r]=o.prototype[r]);n.prototype.mixins[e]=o.prototype,w(o.prototype.mixins)},w=function(e){Z.each(e,function(e,t){var o=e.origin.getDefinitions();m(o.statics),n.prototype.mixins[t]||(n.prototype.mixins[t]=e)})};return a()};Z.define=function(t,n){return new e(t,n)},Z.define.runClassCallbacks=function(e){e.onLoad=function(t){Z.call(t,[e])},Z.each(e.todo,function(t){Z.call(t,[e])})}}(),Z.create=function(e,t){var n,o=Z.exists(e);return o&&o.isZ&&!o.empty?n=new o(t):Z.Require([e],function(){n=new o(t),console.warn("[{0}] carregada dinamicamente, operação de IO sincrona executada.".format(e))},!0),n},Z.Loader=function(name,sync){if("string"!=typeof name)throw"O nome da classe deve ser uma string";void 0===sync&&(sync=!1);var classe=Z.exists(name),arr=name.split("."),className=arr.pop(),namespace;if(arr.length&&(namespace=arr.shift()),namespace&&Z.global[namespace].path&&Z.global[namespace].path.constructor===Function)Z.global[namespace].path(name,function(e){var t=Z.declare(name);Z.define.runClassCallbacks(t),Z.declare.setObjectOn(name,e)});else if((!classe||!classe.isZ||classe.empty)&&Z.global[namespace].path){var path=arr.join("/");path&&(path="{0}/".format(path)),path="{0}{1}.js".format(path,className);var namespacePath="";namespace&&(namespacePath=Z.global[namespace].path||""),path="{0}{1}".format(namespacePath,path),Z.io({path:path,sync:sync,success:function(result){eval(result.content)},failure:function(){throw"Impossível carregar sistema, não foi possível carregar a classe {0}".format(name)}})}},Z.Require=function(e,t,n){if(!e.length)return void Z.call(t);void 0===n&&(n=!1);var o=[];Z.each(e,function(e){-1==o.indexOf(e)&&o.push(e)});var a=o.length,r=0,i=function(){r++,a==r&&Z.call(t)};Z.each(o,function(e){var t=Z.declare(e);t.onLoad(i),Z.Loader(e,n)})},Z.each=function(e,t){if(e)if("function"==typeof e.splice&&"number"==typeof e.length)for(var n=0;n<e.length;n++){var o=t(e[n],n);if(void 0!==o)return o}else for(var a in e)if(e.hasOwnProperty(a)){var o=t(e[a],a);if(void 0!==o)return o}},Z.clone=function(e){if(null===e||void 0===e)return e;if(e.constructor===Date)return new Date(e.getTime());if(e.constructor===Array){for(var t=e.length,n=new Array(t);t--;)n[t]=Z.clone(e);return n}if(e.constructor===Object){var o={};for(var a in e)e.hasOwnProperty(a)&&(o[a]=Z.clone(a));return e}return!e instanceof Object?e:(console.warn("Possível clonar apenas objetos simples"),e)},Z.apply=function(e,t){if(e||(e={}),t||(t={}),e.constructor!==Object)throw"Apply é executado apenas para objetos simples";if(t.constructor!==Object)throw"Apply é executado apenas para objetos simples";return Z.each(t,function(t,n){e[n]=t}),e},Z.call=function(e,t,n){return"function"==typeof e?e.apply(n,t):void 0},Z.io=function(e){if(void 0==e&&(e={}),void 0==e.path&&(e.path=location||""),void 0==e.method&&(e.method="get"),void 0==e.sync&&(e.sync=!1),void 0==e.params&&(e.params={}),void 0==e.headers&&(e.headers={}),void 0==e.encode&&(e.encode="utf8"),void 0==e.success&&(e.success=function(){}),void 0==e.failure&&(e.failure=function(){}),void 0==e.callback&&(e.callback=function(){}),Z.isBrowser){var t=new(XMLHttpRequest||ActiveXObject("MSXML2.XMLHTTP.3.0"));Z.each(e.headers,function(e,n){n||e||t.setRequestHeader(n,e)}),t.onreadystatechange=function(){if(4==t.readyState){var n={reader:t,content:t.responseText};200==t.status?(n.success=!0,e.success(n)):(n.success=!1,e.failure(n)),e.callback(n)}};var n=new FormData;Z.each(e.params,function(e,t){n.append(t,e)}),t.open(e.method.toUpperCase(),e.path,!e.sync),t.send(n)}else if(Z.isNode){var o=require("fs"),a=e.sync?o.readFileSync:o.readFile;a(e.path,e.encode,function(t,n){var o={reader:a};t?(o.success=!1,o.content=t,e.failure(o)):(o.success=!0,o.content=n,e.success(o)),e.callback(o)})}},Z.io.defaults={},String.prototype.format=function(){for(var e=this.valueOf(),t=0;t<arguments.length;t++)e=e.replace(new RegExp("[{]["+t+"][}]","g"),arguments[t]);return e},Array.prototype.format=function(e){return e.format.apply(this)};