Comparing version 1.3.6 to 1.3.7
{ | ||
"name": "domino-js", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"description": "A cascading controller for fast interactive Web interfaces prototyping.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://dominojs.org", |
@@ -1,2 +0,2 @@ | ||
/* domino.js - A cascading controller for fast interactive Web interfaces prototyping. - Version: 1.3.6 - Author: Alexis Jacomy, Linkfluence - License: MIT */ | ||
(function(a){"use strict";function b(){return!!m.xhr}function c(){m.strict?d.apply(this,arguments):e.apply(this,arguments)}function d(){throw new Error(Array.prototype.join.call(arguments," "))}function e(){m.verbose&&f.apply(this,arguments)}function f(){for(var a=[],b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);m.displayTime&&a.unshift(("00000000"+((new Date).getTime()-h)).substr(-8)),console&&console.log instanceof Function&&console.log.apply(console,a)}var g=/^[a-zA-Z_$-][a-zA-Z_$0-9-]*$/,h=new Date,i={},j=this;if(j.domino)throw new Error("domino already exists");var k=function(){function b(a){var b=a||{},c={getEvents:A,getLabel:z,expand:B,warn:H,log:J,die:I,get:v,abortCall:l};return b.full?(c.help=E,c.kill=F,c.update=s,c.request=x,c.settings=G,c.modules=q,c.addModule=p,c.killModule=r,c.getEvent=function(){M.getEvent.apply(M,arguments)},c.addEventListener=function(){M.addEventListener.apply(M,arguments)},c.removeEventListener=function(){M.removeEventListener.apply(M,arguments)},c.configuration=D,c.dispatchEvent=function(a,b){var c,d,e=N.array(a),f=[];for(c=0,d=e.length;d>c;c++)f.push(M.getEvent(e[c],b));return u({events:f}),this}):(b.request&&(Object.defineProperty(c,"_services",{value:[]}),c.request=function(a,b){var c,d;if(O.check("string",a)){d={service:a};for(c in b||{})d[c]=b[c];this._services.push(d)}else if(O.check("object",a))this._services.push(a);else if(O.check("array",a)){if(d={services:a},O.check("object",b))for(c in b)d[c]=b[c];this._services.push(d)}return this}),b.dispatchEvent&&(Object.defineProperty(c,"_events",{value:[]}),c.dispatchEvent=function(a,b){var c,d,e=N.array(a);for(c=0,d=e.length;d>c;c++)this._events.push(M.getEvent(e[c],b));return this}),b.update&&(Object.defineProperty(c,"_properties",{value:[]}),c.update=function(a,b){if("object"==typeof a)for(var c in a)this._properties.push({property:c,value:a[c]});else"string"==typeof a&&arguments.length>1&&this._properties.push({property:a,value:b});return this})),c}function c(b){b.request!==a&&(b.request=function(){return I("This method is no longer available."),this}),b.dispatchEvent!==a&&(b.dispatchEvent=function(){return I("This method is no longer available."),this}),b.update!==a&&(b.update=function(){return I("This method is no longer available."),this})}function e(b,c){var d,e,f=c||{};b===a&&I("Property name not specified"),"string"!==O.get(b)&&I("The property name must be a string"),W[b]!==a&&I('Property "'+b+'" already exists'),ob[b]!==a&&I('"'+b+'" can not be used to name a property'),b.match(g)||I("Property name not valid ("+g+")"),X[b]={};for(e in f)X[b][e]=f[e];if(R[b]=f.label||b,f.description&&(ab.properties[b]=f.description),f.type!==a&&(O.isValid(f.type)?Q[b]=f.type:H('Property "'+b+'": Type not valid')),f.setter!==a&&("function"!==O.get(f.setter)?H('Property "'+b+'": Setter is not a function'):(U[b]=f.setter,Z[b]=!0)),U[b]=U[b]||function(a){return O.deepScalar(Q[b])&&O.compare(a,W[b],Q[b])?!1:(Q[b]&&!O.check(Q[b],a)?H('Property "'+b+'": Wrong type error'):W[b]=a,!0)},f.getter!==a&&("function"!==O.get(f.getter)?H('Property "'+b+'": Getter is not a function'):(T[b]=f.getter,Y[b]=!0)),T[b]=T[b]||function(){return W[b]},(f.value!==a||Q[b])&&(f.value!==a?w(b,f.value):J('Property "'+b+'": Initial value is missing')),f.triggers!==a){!O.check("array|string",f.triggers)&&H('Property "'+b+'": Events ("triggers") must be specified in an array or separated by spaces in a string'),S[b]=N.array(f.triggers);for(d in S[b]||[])cb[S[b][d]]=cb[S[b][d]]||[],cb[S[b][d]].push(b)}return f.dispatch!==a&&(O.check("array|string",f.dispatch)?db[b]=N.array(f.dispatch):H('Property "'+b+'": Events ("dispatch") must be specified in an array or separated by spaces in a string')),M}function h(b){var c,d,e=b||{};e.triggers===a&&I("A hack requires at least one trigger to be bound"),e.description&&ib.push(e.description),c=N.array(e.triggers);for(d in c)jb[c[d]]=jb[c[d]]||[],hb[c[d]]=hb[c[d]]||[],gb[c[d]]=gb[c[d]]||[],e.description&&(jb[c[d]]=jb[c[d]].concat(e.description)),e.method&&gb[c[d]].push(e.method),e.dispatch&&(hb[c[d]]=hb[c[d]].concat(N.array(e.dispatch)));c=N.array(e.dispatch);for(d in c)kb[c[d]]=kb[c[d]]||[],e.description&&(kb[c[d]]=kb[c[d]].concat(e.description));return M}function j(d,e){var f=e||{};return"string"!==O.get(d)&&I("The service id is not specified."),O.check("function|string",f.url)||I("The service URL is not valid."),lb[d]!==a&&I('The service "'+d+'" already exists.'),f.description&&(ab.services[d]=f.description),lb[d]=function(e){J('Calling service "'+d+'".');var g,h,i,j,k,l=e||{},m=l.shortcuts||{},n={contentType:l.contentType||f.contentType,dataType:l.dataType||f.dataType,type:(l.type||f.type||"GET").toString().toUpperCase(),data:l.data!==a?l.data:"function"===O.get(f.data)?f.data.call(b(),l):f.data,url:"function"===O.get(f.url)?f.url.call(b(),l):f.url,error:function(a,b){M.dispatchEvent("domino.ajaxFailed");var c=l.error||f.error;J('Loading service "'+d+'" failed with message "'+a+'" and status '+b.status+"."),"function"===O.get(c)&&y(c,{parameters:[a,b,l],loop:l.loop||u,scope:{request:!0,dispatchEvent:!0,update:!0}})}},o=G("shortcutPrefix"),p=new RegExp(o+"(\\w+)","g"),q=new RegExp("^"+o+"(\\w+)$"),r=null;for("string"!==O.get(n.url)&&I('The URL is no more a string (typed "'+O.get(n.url)+'")');(k=n.url.match(p))&&n.url!==r;){r=n.url;for(g in k)h=B(k[g].match(q)[1],m),n.url=n.url.replace(new RegExp(k[g],"g"),h)}if(j=!0,"string"===O.get(n.data)&&n.data.match(q)&&(n.data=B(n.data.match(q)[1],m)),"object"===O.get(n.data))for(;j;){j=!1;for(i in n.data)"string"===O.get(n.data[i])&&n.data[i].match(q)&&(n.data[i]=B(n.data[i].match(q)[1],m),j=!0)}n.success=function(e,g){var h,j,k,o,p,r={},s=[],t=[],v={},w=!1,x=l.path||f.path,z=l.setter||f.setter,A=l.success||f.success,C=l.expect||f.expect||G("expect");if("function"===O.get(C)&&!C.call(b(),e,l,f))return J('"expect" test failed for service "'+d+'".'),n.error.call(this,"Unexpected data received.",g),void 0;if(J('Service "'+d+'" successfull.'),"string"===O.get(z)&&z.match(q)&&(z=B(z.match(q)[1],m)),"string"===O.get(x)&&x.match(q)&&(x=B(x.match(q)[1],m)),p=e,(x||"").match(/^(?:\w+\.)*\w+$/)?o=O.get(x,"string")?x.split("."):a:"string"===O.get(x)&&H('Path "'+x+'" does not match RegExp /^(?:\\w+\\.)*\\w+$/'),o)for(h in o)p=p[o[h]],p!==a||H('Wrong path "'+x+'" for service "'+d+'".');j=N.array(f.events);for(h in j)r[j[h]]=1,w=!0;j=N.array(l.events);for(h in j)r[j[h]]=1,w=!0;if(z&&U[z]&&p!==a&&(v[z]=p,w=!0),"function"===O.get(A)){var D=y(A,{parameters:[e,l],scope:{request:!0,dispatchEvent:!0,update:!0}});j=N.array(D.events);for(i in j)w=!0,r[j[i].type]=j[i];for(i in D.update)v[i]===a?(v[i]=D.update[i],w=!0):H('The key "'+i+'" is nor a method neither a property.');(D.services||[]).length&&(w=!0,s=s.concat(D.services)),c(D)}t=[];for(k in r)t.push(1===r[k]?M.getEvent(k):r[k]);(w||l.loop)&&(l.loop||u)({events:t,update:v,services:s})};var s=l.before||f.before;"function"==typeof s&&"function"===O.get(s)&&(n.beforeSend=function(a){return y(s,{parameters:[l,a],loop:!0,scope:{dispatchEvent:!0,update:!0}}).returned}),("abort"in l?l.abort:f.abort)&&mb[d]&&mb[d].abort(),mb[d]=N.ajax(n)},M}function l(a){mb[a]&&mb[a].abort()}function o(b,c){var d=c||{},e="function"==typeof d?d:d.method,f="object"==typeof d&&"description"in d?d.description:null;return b===a&&I("Shortcut ID not specified."),nb[b]&&I('Shortcut "'+b+'" already exists.'),e===a&&I("Shortcut method not specified."),f&&(ab.shortcuts[b]=f),nb[b]=e,M}function p(c,d,e){var f,g,h,i,j=new k.module,l=e||{},m={};c===a&&I("Module class not specified."),"function"!==O.get(c)&&I("First parameter must be a function."),"id"in l&&l.id in _&&I('The module with id "'+l.id+'" already exists.'),c.apply(j,(d||[]).concat(b())),g=j.triggers||{};for(i in g.events||{})eb[i]=eb[i]||[],eb[i].push(g.events[i]);for(h in g.properties||{}){for(f in db[h]||[])fb[h]=fb[h]||[],fb[h].push(g.properties[h]);if(T[h]!==a){var n={};n[h]=v(h),y(g.properties[h],{parameters:[b()]})}}for(i in cb||{})m[i]=1;for(i in gb||{})m[i]=1;for(i in hb||{})m[i]=1;for(i in jb||{})m[i]=1;for(i in m)j.addEventListener(i,t);return j.log="id"in l?N.partial(J,'[module "'+l.id+'"]'):N.partial(J,"[module]"),j.warn="id"in l?N.partial(H,'[module "'+l.id+'"]'):N.partial(H,"[module]"),j.die="id"in l?N.partial(I,'[module "'+l.id+'"]'):N.partial(I,"[module]"),"id"in l&&(_[l.id]=j),$.push(j),j}function q(a){return _[a]}function r(a){var b,c,d,e,f,g,h,i,j={};if(O.check("string",a)&&(a=_[a]),$.indexOf(a)<0)return M.warn("The module you try to kill is actually not referenced."),a;i=a.triggers||{};for(g in i.events){if(e=eb[g],f=i.events[g],e&&e.length)for(b=0,c=e.length;c>b;b++)e[b]===f&&e.splice(b,1);e&&!e.length&&delete eb[g]}for(h in i.properties){if(e=fb[h],f=i.properties[h],e&&e.length)for(b=0,c=e.length;c>b;b++)e[b]===f&&e.splice(b,1);e&&!e.length&&delete fb[h]}for(g in cb||{})j[g]=1;for(g in gb||{})j[g]=1;for(g in hb||{})j[g]=1;for(g in jb||{})j[g]=1;for(g in j)a.removeEventListener(g,t);$.splice($.indexOf(a),1);for(d in _)if(_[d]===a){delete _[d];break}return a}function s(a,b){var c="object"==typeof a&&1===arguments.length?a||{}:{};return"string"==typeof a&&(c[a]=b),u({update:c}),this}function t(a){u({events:[a],emitter:a.target})}function u(d){var e,f,g,h,i,j,k,l,m,n,o=!1,p=[],q=[],r=[],s=d||{},t={},v={};s.loop=(+s.loop||0)+1,s.loopId=s.loopId||++bb,G("maxDepth")&&s.loop>G("maxDepth")&&I("Loop "+s.loopId+" exceeds maximum depth ("+G("maxDepth")+")");var z=N.array(s.events),A=N.array(s.services),B=s.update||{};if(G("verbose")){if(J("Iteration "+s.loop+" (loop "+s.loopId+")"),z.length){n=[];for(f in z)n.push(z[f].type);J(" -> Events: ",n)}if(A.length){n=[];for(f in A)n.push("string"==typeof A[f]?A[f]:A[f].service);J(" -> Services: ",n)}n=[];for(f in B)n.push(f);n.length&&J(" -> Update: ",n)}for(m in B)if(U[m]===a)H('The property "'+m+'" is not referenced.');else if(l=w(m,B[m])||s.force||C(m,"force")){for(f in fb[m])y(fb[m][f],{parameters:[b(),{property:m,emitter:s.emitter}]});for(f in db[m]||[])i=db[m][f],t[i]=M.getEvent(i)}if(A.length)if(G("mergeRequests")){e=[];for(g in A)A[g].services?x(A[g].services,A[g]):e.push(A[g]),e.length&&x(e)}else for(g in A)A[g].services?x(A[g].services,A[g]):x(A[g]);for(f in z){if(j=z[f],k=j.data||{}){e=cb[j.type]||[];for(g in e)k[e[g]]!==a&&(o=!0,v[e[g]]=k[e[g]])}for(h in eb[j.type])y(eb[j.type][h],{parameters:[b(),j,s.emitter]});for(g in gb[j.type]||[])if(p.indexOf(gb[j.type][g])<0){p.push(gb[j.type][g]);var D=y(gb[j.type][g],{parameters:[j],scope:{request:!0,dispatchEvent:!0,update:!0}});e=N.array(D.events);for(h in e)t[e[h].type]=e[h];for(h in D.update)v[h]===a?(o=!0,v[h]=D.update[h]):H('The property "'+h+'" has already been updated in the current loop.');(D.services||[]).length&&(o=!0,r=r.concat(D.services)),c(D)}for(g in hb[j.type]||[])i=hb[j.type][g],t[i]=M.getEvent(i);if(G("logDescriptions"))for(g in jb[j.type]||[])J("[HACK]",jb[j.type][g])}for(j in t)M.dispatchEvent(j,t[j].data),q.push(t[j]),o=!0;o&&u({events:q,update:v,services:r,emitter:s.emitter,loopId:s.loopId,loop:s.loop})}function v(a){if(T[a]){if(Y[a]){for(var b,c=[],d={},e=1,f=arguments.length;f>e;e++)c.push(arguments[e]);return d[a]=W[a],b=y(T[a],{parameters:c,inputValues:d}),C(a,"clone")?N.clone(b.returned):b.returned}return C(a,"clone")?N.clone(T[a]()):T[a]()}H('Property "'+a+'" not referenced.')}function w(a,c){if(U[a]){if(Z[a]){var d,e,f=[],g={};C(a,"clone")&&(c=N.clone(c)),g[a]=v(a);for(var h=1,i=arguments.length;i>h;h++)f.push(arguments[h]);return e=y(U[a],{parameters:f,inputValues:g}),d="boolean"!==O.get(e.returned)||e.returned,d&&(W[a]=e.update[a]),d}return U[a].call(b(),C(a,"clone")?N.clone(c):c)}return H('Property "'+a+'" not referenced.'),!1}function x(b,c){if(O.check("string",b))lb[b]?lb[b](c):H('Service "'+b+'" not referenced.');else if(O.check("object",b))x(b.service,b);else if(O.check("array",b)){c=c||{};var d,e=b.length,f=c.merge!==a?!!c.merge:G("mergeRequests");if(f){var g,h,i=e,j=[],k=function(){var a,b,d,f={update:{},events:[],services:[]};for(b=0;e>b;b++){a=j[b]||{};for(d in a.update||{})f.update[d]=a.update[d];f.events=f.events.concat(a.events||[]),f.services=f.services.concat(a.services||[])}c.success&&y(c.success,{parameters:[j],loop:u,scope:{request:!0,dispatchEvent:!0,update:!0}})};for(d=0;e>d;d++){if("string"==typeof b[d])g={service:b[d]};else{g={};for(h in b[d])g[h]=b[d][h]}!function(a){g.loop=function(b){j[a]=b,u(b),--i||k()}}(d),x(g)}}else for(d=0,e=b.length;e>d;d++)x(b[d])}return this}function y(c,d){var e,f,g,h={},i=d||{},j=b(i.scope);"function"!==O.get(c)&&I("The first parameter must be a function");for(e in i.inputValues||{})j[e]=i.inputValues[e];g=c.apply(j,i.parameters||[]),f={returned:g,update:{},events:[],services:[]},null==j._events||O.check("array",j._events)?f.events=j._events:H("Events must be stored in an array.");for(e in j)h[e]=j[e];for(e in j._properties)h[j._properties[e].property]=j._properties[e].value;for(e in h)U[e]!==a?f.update[e]=h[e]:ob[e]===a&&H('The key "'+e+'" is not a method nor a property.');for(e in i.inputValues)f.update[e]=j[e];for(e in j._services)f.services[e]=j._services[e];if(i.loop){var k=(f.services||[]).length||(f.events||[]).length;if(!k)for(e in f.update)k=!0;k&&(O.check("function",i.loop)?i.loop:u)(f)}return f}function z(a){return R[a]}function A(a){return S[a]}function B(c){var d=c,e=G("shortcutPrefix"),f=(c||"").toString().match(new RegExp("^"+e+"(\\w+)$"));f&&f.length&&(H("Prefix in expand() calls is deprecated."),d=f[1]);for(var g=1,h=arguments.length;h>g;g++)if((arguments[g]||{})[d]!==a)return arguments[g][d];return"function"===O.get(T[d])?v(d):"function"===O.get(nb[d])?nb[d].call(b()):(H('The shortcut "',d,'" has not been recognized.'),e+d)}function C(b,c){var d=(X[b]||{})[c];return d!==a?!!d:G(c)}function D(a){return arguments.length?N.clone(L[a]):N.clone(L)}function E(a,b,c){var d,e={},f="[no description is specified]";switch(a){case"properties":if(1===arguments.length){for(d in W)e[d]=ab.properties[d]||f;return e}return ab.properties[b]||f;case"services":if(1===arguments.length){for(d in lb)e[d]=ab.services[d]||f;return e}return ab.services[b]||f;case"shortcuts":if(1===arguments.length){for(d in nb)e[d]=ab.shortcuts[d]||f;return e}return ab.shortcuts[b]||f;case"hacks":if(1===arguments.length)return ib;if(3===arguments.length)return e=[],"trigger"===b?e=jb[c]:"dispatch"===b&&(e=kb[c]),1===e.length?e[0]:e;case"full":return{properties:E("properties"),shortcuts:E("shortcuts"),services:E("services"),hacks:E("hacks")}}}function F(){var a;J('Killing instance "'+pb+'"');for(a in $)$[a].removeEventListener();$=null,Q=null,R=null,S=null,T=null,U=null,V=null,W=null,Y=null,Z=null,$=null,cb=null,db=null,eb=null,fb=null,gb=null,hb=null,lb=null,mb=null,nb=null;for(a in K)delete K[a];i[pb]&&delete i[pb]}function G(b,c){if("string"==typeof b&&1===arguments.length)return P[b]!==a?P[b]:m[b];var d="object"==typeof b&&1===arguments.length?b||{}:{};"string"==typeof b&&(d[b]=c);for(var e in d)d[e]!==a?P[e]=d[e]:delete P[e];return this}function H(){var a=["["+(pb||"domino")+"]"];G("strict")||a.push("WARNING");for(var b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);G("strict")?d.apply(this,a):G("verbose")&&f.apply(this,a)}function I(){for(var a=["["+(pb||"domino")+"]"],b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);d.apply(this,a)}function J(){var a=["["+(pb||"domino")+"]"];if(G("verbose")){for(var b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);f.apply(this,a)}}(function(){n.call(this);for(var a in n.prototype)this[a]=n.prototype[a]}).call(this);var K,L,M=this,N=k.utils,O=k.struct,P={},Q={},R={},S={},T={},U={},V={},W={},X={},Y={},Z={},$=[],_={},ab={properties:{},shortcuts:{},services:{}},bb=0,cb={},db={},eb={},fb={},gb={},hb={},ib=[],jb={},kb={},lb={},mb={},nb={},ob={events:1,services:1,hacks:1};!function(){var a;for(a in Object.prototype)ob[a]=1;for(a in b({full:!0}))ob[a]=1}(),K=b({full:!0});var pb,qb={};return"string"===O.get(arguments[0])?(qb=arguments[1],qb.name=arguments[0]):arguments[0]!==a&&"object"===O.get(arguments[0])?qb=arguments[0]:arguments[1]!==a&&"object"===O.get(arguments[1])&&(qb=arguments[1]),qb.name=pb||qb.name,pb=qb.name,pb&&(i[pb]?I('An instance named "'+pb+'" is already running.'):i[pb]=K),function(){var a;if("array"===O.get(qb.properties))for(a in qb.properties)e(qb.properties[a].id,qb.properties[a]);else if("object"===O.get(qb.properties))for(a in qb.properties)e(a,qb.properties[a]);for(a in qb.hacks||[])h(qb.hacks[a]);if("array"===O.get(qb.services))for(a in qb.services)j(qb.services[a].id,qb.services[a]);else if("object"===O.get(qb.services))for(a in qb.services)j(a,qb.services[a]);if("array"===O.get(qb.shortcuts))for(a in qb.shortcuts)o(qb.shortcuts[a].id,qb.shortcuts[a]);else if("object"===O.get(qb.shortcuts))for(a in qb.shortcuts)o(a,qb.shortcuts[a])}(),L=N.clone(qb),K};k.version="1.3.6","undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=k),exports.domino=k):j.domino=k,k.utils={array:function(a,b){var c="string"===k.struct.get(a)?a.split(b||" "):"array"===k.struct.get(a)?a:[a],d=[];for(var e in c)c[e]&&d.push(c[e]);return d},clone:function(a){if(!a)return a;var b,c,d;if("array"===l.get(a))for(b=[],c=0,d=a.length;d>c;c++)b.push(this.clone(a[c]));else if("date"===l.get(a))b=new Date(a.getTime());else if("object"===l.get(a))if(a.nodeType&&"function"==typeof a.cloneNode)b=a;else if(a.prototype)b=a;else{b={};for(c in a)b[c]=this.clone(a[c])}else b=a;return b},partial:function(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(this,b.concat(Array.prototype.slice.call(arguments)))}},ajax:function(a,c){b()||d('[domino.global] XMLHttpRequest not found. You can specify which XMLHttpRequest you want to use by using domino.settings("xhr", myXhr).'),"string"==typeof a?a={url:a,ok:c}:"object"!==l.get(a)&&d("[domino.global] Invalid parameter given to AJAX");var e,f,g,h=a.type||"GET",i=a.url||"",j=a.contentType||"application/x-www-form-urlencoded",k=a.dataType||"json",n=new m.xhr;if(a.data){if("string"==typeof a.data)f=a.data;else if(/json/.test(j))f=JSON.stringify(a.data);else{f=[];for(g in a.data)f.push(encodeURIComponent(g)+"="+encodeURIComponent(a.data[g]));f=f.join("&")}/GET|DEL/i.test(h)&&(i+=/\?/.test(i)?"&"+f:"?"+f,f="")}if(n.onreadystatechange=function(){if(4==n.readyState)if(e&&clearTimeout(e),/^2/.test(n.status)){if(f=n.responseText,/json/.test(k))try{f=JSON.parse(n.responseText)}catch(b){return a.error&&a.error("JSON parse error: "+b.message,n)}a.success&&a.success(f,n)}else{var c=+n.status?n.responseText:n.responseText.length?"Aborted: "+n.responseText:"Aborted";a.error&&a.error(c,n)}},n.open(h,i,!0),n.setRequestHeader("Content-Type",j),a.headers)for(g in a.headers)n.setRequestHeader(g,a.headers[g]);return"function"==typeof a.beforeSend&&a.beforeSend(n,a)===!1?n.abort():(a.timeout&&(e=setTimeout(function(){n.onreadystatechange=function(){},n.abort(),a.error&&a.error&&a.error("timeout",n)},1e3*a.timeout)),n.send(f),n)}},k.struct=function(){var b=["number","string","boolean","null","undefined"],e="Boolean Number String Function Array Date RegExp Object".split(" "),f={},g=["*"],h={};for(var i in e){var j=e[i];g.push(j.toLowerCase()),f["[object "+j+"]"]=j.toLowerCase()}return{add:function(b,c){var e,f,i,j,l,m;1===arguments.length?"object"===this.get(b)?(m=b,i=m.id,l=m.struct):d("[domino.global] If struct.add is called with one arguments, it has to be an object"):2===arguments.length?("string"===this.get(b)&&b?i=b:d("[domino.global] If struct.add is called with more than one arguments, the first one must be the string id"),l=c):d("[domino.global] struct.add has to be called with one or three arguments"),("string"!==this.get(i)||0===i.length)&&d("[domino.global] A structure requires an string id"),h[i]!==a&&"proto"!==h[i]&&d('[domino.global] The structure "'+i+'" already exists'),h[i]=1,f=k.utils.array((m||{}).proto),j={};for(e in f)h[f[e]]===a&&(h[f[e]]=1,j[f[e]]=1);if("function"===this.get(l)||this.isValid(l)||d('[domino.global] A structure requires a valid "structure" property describing the structure. It can be a valid structure or a function that test if an object matches the structure.'),~g.indexOf(i)&&(delete h[i],d('[domino.global] "'+i+'" is a reserved structure name')),h[i]=m===a?{id:i,struct:l}:{},m!==a)for(e in m)h[i][e]=m[e];for(e in j)e!==i&&delete h[e]},get:function(a){return null==a?String(a):f[Object.prototype.toString.call(a)]||"object"},existing:function(a){return"string"==typeof a?(h[a]||{}).struct:k.utils.clone(h)},check:function(b,d,e){var f,i,j=this.get(d),k=e||{};if("string"===this.get(b)){f=b.replace(/^\?/,"").split(/\|/);for(i in f)if(g.indexOf(f[i])<0&&h[f[i]]===a)return c("[domino.global] Invalid type"),!1;if(null==d)return!!b.match(/^\?/,"");b=b.replace(/^\?/,"");for(i in f)if(h[f[i]]&&("function"===this.get(h[f[i]].struct)?h[f[i]].struct(d)===!0:this.check(h[f[i]].struct,d,h[f[i]])))return!0;return!(!~f.indexOf("*")&&!~f.indexOf(j))}if("object"===this.get(b)){if("object"!==j)return!1;var l;for(l in b)if(!this.check(b[l],d[l]))return!1;if(!k.includes)for(l in d)if(b[l]===a)return!1;return!0}if("array"===this.get(b)){if("array"!==j)return!1;if(1!==b.length)return c("[domino.global] Invalid type"),!1;for(l in d)if(!this.check(b[0],d[l]))return!1;return!0}return!1},deepScalar:function(a){var c,d;if("string"===this.get(a)){c=a.replace(/^\?/,"").split(/\|/);for(d in c)if(b.indexOf(c[d])<0)return!1;return!0}if(this.check("object|array",a)){for(d in a)if(!this.deepScalar(a[d]))return!1;return!0}return!1},compare:function(a,b,c){{var d;this.get(a),this.get(b)}if(!this.deepScalar(c)||!this.check(c,a)||!this.check(c,b))return!1;if("string"===this.get(c))return a===b;if("object"===this.get(c)){for(d in c)if(!this.compare(a[d],b[d],c[d]))return!1;return!0}if("array"===this.get(c)){if(a.length!==b.length)return!1;var e=a.length;for(d=0;e>d;d++)if(!this.compare(a[d],b[d],c[0]))return!1;return!0}return!1},isValid:function(b){var c,d,e;if("string"===this.get(b)){c=b.replace(/^\?/,"").split(/\|/);for(e in c)if(g.indexOf(c[e])<0&&h[c[e]]===a)return!1;return!0}if("object"===this.get(b)){for(d in b)if(!this.isValid(b[d]))return!1;return!0}return"array"===this.get(b)?1===b.length?this.isValid(b[0]):!1:!1}}}();var l=(k.utils,k.struct),m={maxDepth:0,strict:!1,verbose:!1,displayTime:!1,shortcutPrefix:":",mergeRequests:!0,logDescriptions:!0,xhr:j.XMLHttpRequest,clone:!1};k.settings=function(b,c){if("string"==typeof b&&1===arguments.length)return m[b];var d="object"==typeof b&&1===arguments.length?b||{}:{};"string"==typeof b&&(d[b]=c);for(var e in d)d[e]!==a?m[e]=d[e]:delete m[e];return this},k.instances=function(a){return arguments.length?i[a]:(d("[domino.global] You need to indicate a name to get the instance."),void 0)},k.EventDispatcher=function(){Object.defineProperty(this,"_handlers",{value:{}})};var n=k.EventDispatcher;n.prototype.addEventListener=function(a,b){var c,d,e,f;if(1===arguments.length&&"object"==typeof arguments[0])for(a in arguments[0])this.addEventListener(a,arguments[0][a]);else{if(2!==arguments.length||"function"!=typeof arguments[1])throw"domino.EventDispatcher.addEventListener: Wrong arguments.";for(f="string"==typeof a?a.split(" "):a,c=0,d=f.length;c!==d;c+=1)e=f[c],e&&(this._handlers[e]||(this._handlers[e]=[]),this._handlers[e].push({handler:b}))}return this},n.prototype.removeEventListener=function(a,b){var c,d,e,f,g,h,i,j="string"==typeof a?a.split(" "):a;if(!arguments.length){for(g in this._handlers)delete this._handlers[g];return this}if(b)for(c=0,d=j.length;c!==d;c+=1){if(i=j[c],this._handlers[i]){for(h=[],e=0,f=this._handlers[i].length;e!==f;e+=1)this._handlers[i][e].handler!==b&&h.push(this._handlers[i][e]);this._handlers[i]=h}this._handlers[i]&&0===this._handlers[i].length&&delete this._handlers[i]}else for(c=0,d=j.length;c!==d;c+=1)delete this._handlers[j[c]];return this},n.prototype.dispatchEvent=function(b,c){var d,e,f,g,h,i,j,k,l=this,m="string"==typeof b?b.split(" "):b;for(c=c===a?{}:c,d=0,e=m.length;d!==e;d+=1)if(k=m[d],j=this._handlers[k],j&&j.length){for(i=l.getEvent(k,c),h=[],f=0,g=j.length;f!==g;f+=1)j[f].handler(i),j[f].one||h.push(j[f]);this._handlers[k]=h}return this},n.prototype.getEvent=function(a,b){return{type:a,data:b||{},target:this}},k.module=function(){if(!this._handlers){n.call(this);for(var a in n.prototype)this[a]=n.prototype[a];this.triggers={properties:{},events:{}},this.log=this.warn=this.die=function(){}}}}).call(this); | ||
/* domino.js - A cascading controller for fast interactive Web interfaces prototyping. - Version: 1.3.7 - Author: Alexis Jacomy, Linkfluence - License: MIT */ | ||
(function(a){"use strict";function b(){return!!m.xhr}function c(){m.strict?d.apply(this,arguments):e.apply(this,arguments)}function d(){throw new Error(Array.prototype.join.call(arguments," "))}function e(){m.verbose&&f.apply(this,arguments)}function f(){for(var a=[],b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);m.displayTime&&a.unshift(("00000000"+((new Date).getTime()-h)).substr(-8)),console&&console.log instanceof Function&&console.log.apply(console,a)}var g=/^[a-zA-Z_$-][a-zA-Z_$0-9-]*$/,h=new Date,i={},j=this;if(j.domino)throw new Error("domino already exists");var k=function(){function b(a){var b=a||{},c={getEvents:A,getLabel:z,expand:B,warn:H,log:J,die:I,get:v,abortCall:l};return b.full?(c.help=E,c.kill=F,c.update=s,c.request=x,c.settings=G,c.modules=q,c.addModule=p,c.killModule=r,c.getEvent=function(){M.getEvent.apply(M,arguments)},c.addEventListener=function(){M.addEventListener.apply(M,arguments)},c.removeEventListener=function(){M.removeEventListener.apply(M,arguments)},c.configuration=D,c.dispatchEvent=function(a,b){var c,d,e=N.array(a),f=[];for(c=0,d=e.length;d>c;c++)f.push(M.getEvent(e[c],b));return u({events:f}),this}):(b.request&&(Object.defineProperty(c,"_services",{value:[]}),c.request=function(a,b){var c,d;if(O.check("string",a)){d={service:a};for(c in b||{})d[c]=b[c];this._services.push(d)}else if(O.check("object",a))this._services.push(a);else if(O.check("array",a)){if(d={services:a},O.check("object",b))for(c in b)d[c]=b[c];this._services.push(d)}return this}),b.dispatchEvent&&(Object.defineProperty(c,"_events",{value:[]}),c.dispatchEvent=function(a,b){var c,d,e=N.array(a);for(c=0,d=e.length;d>c;c++)this._events.push(M.getEvent(e[c],b));return this}),b.update&&(Object.defineProperty(c,"_properties",{value:[]}),c.update=function(a,b){if("object"==typeof a)for(var c in a)this._properties.push({property:c,value:a[c]});else"string"==typeof a&&arguments.length>1&&this._properties.push({property:a,value:b});return this})),c}function c(b){b.request!==a&&(b.request=function(){return I("This method is no longer available."),this}),b.dispatchEvent!==a&&(b.dispatchEvent=function(){return I("This method is no longer available."),this}),b.update!==a&&(b.update=function(){return I("This method is no longer available."),this})}function e(b,c){var d,e,f=c||{};b===a&&I("Property name not specified"),"string"!==O.get(b)&&I("The property name must be a string"),W[b]!==a&&I('Property "'+b+'" already exists'),ob[b]!==a&&I('"'+b+'" can not be used to name a property'),b.match(g)||I("Property name not valid ("+g+")"),X[b]={};for(e in f)X[b][e]=f[e];if(R[b]=f.label||b,f.description&&(ab.properties[b]=f.description),f.type!==a&&(O.isValid(f.type)?Q[b]=f.type:H('Property "'+b+'": Type not valid')),f.setter!==a&&("function"!==O.get(f.setter)?H('Property "'+b+'": Setter is not a function'):(U[b]=f.setter,Z[b]=!0)),U[b]=U[b]||function(a){return O.deepScalar(Q[b])&&O.compare(a,W[b],Q[b])?!1:(Q[b]&&!O.check(Q[b],a)?H('Property "'+b+'": Wrong type error'):W[b]=a,!0)},f.getter!==a&&("function"!==O.get(f.getter)?H('Property "'+b+'": Getter is not a function'):(T[b]=f.getter,Y[b]=!0)),T[b]=T[b]||function(){return W[b]},(f.value!==a||Q[b])&&(f.value!==a?w(b,f.value):J('Property "'+b+'": Initial value is missing')),f.triggers!==a){!O.check("array|string",f.triggers)&&H('Property "'+b+'": Events ("triggers") must be specified in an array or separated by spaces in a string'),S[b]=N.array(f.triggers);for(d in S[b]||[])cb[S[b][d]]=cb[S[b][d]]||[],cb[S[b][d]].push(b)}return f.dispatch!==a&&(O.check("array|string",f.dispatch)?db[b]=N.array(f.dispatch):H('Property "'+b+'": Events ("dispatch") must be specified in an array or separated by spaces in a string')),M}function h(b){var c,d,e=b||{};e.triggers===a&&I("A hack requires at least one trigger to be bound"),e.description&&ib.push(e.description),c=N.array(e.triggers);for(d in c)jb[c[d]]=jb[c[d]]||[],hb[c[d]]=hb[c[d]]||[],gb[c[d]]=gb[c[d]]||[],e.description&&(jb[c[d]]=jb[c[d]].concat(e.description)),e.method&&gb[c[d]].push(e.method),e.dispatch&&(hb[c[d]]=hb[c[d]].concat(N.array(e.dispatch)));c=N.array(e.dispatch);for(d in c)kb[c[d]]=kb[c[d]]||[],e.description&&(kb[c[d]]=kb[c[d]].concat(e.description));return M}function j(d,e){var f=e||{};return"string"!==O.get(d)&&I("The service id is not specified."),O.check("function|string",f.url)||I("The service URL is not valid."),lb[d]!==a&&I('The service "'+d+'" already exists.'),f.description&&(ab.services[d]=f.description),lb[d]=function(e){J('Calling service "'+d+'".');var g,h,i,j,k,l=e||{},m=l.shortcuts||{},n={contentType:l.contentType||f.contentType,dataType:l.dataType||f.dataType,type:(l.type||f.type||"GET").toString().toUpperCase(),data:l.data!==a?l.data:"function"===O.get(f.data)?f.data.call(b(),l):f.data,url:"function"===O.get(f.url)?f.url.call(b(),l):f.url,error:function(a,b){M.dispatchEvent("domino.ajaxFailed");var c=l.error||f.error;J('Loading service "'+d+'" failed with message "'+a+'" and status '+b.status+"."),"function"===O.get(c)&&y(c,{parameters:[a,b,l],loop:l.loop||u,scope:{request:!0,dispatchEvent:!0,update:!0}})}},o=G("shortcutPrefix"),p=new RegExp(o+"(\\w+)","g"),q=new RegExp("^"+o+"(\\w+)$"),r=null;for("string"!==O.get(n.url)&&I('The URL is no more a string (typed "'+O.get(n.url)+'")');(k=n.url.match(p))&&n.url!==r;){r=n.url;for(g in k)h=B(k[g].match(q)[1],m),n.url=n.url.replace(new RegExp(k[g],"g"),h)}if(j=!0,"string"===O.get(n.data)&&n.data.match(q)&&(n.data=B(n.data.match(q)[1],m)),"object"===O.get(n.data))for(;j;){j=!1;for(i in n.data)"string"===O.get(n.data[i])&&n.data[i].match(q)&&(n.data[i]=B(n.data[i].match(q)[1],m),j=!0)}n.success=function(e,g){var h,j,k,o,p,r={},s=[],t=[],v={},w=!1,x=l.path||f.path,z=l.setter||f.setter,A=l.success||f.success,C=l.expect||f.expect||G("expect");if("function"===O.get(C)&&!C.call(b(),e,l,f))return J('"expect" test failed for service "'+d+'".'),n.error.call(this,"Unexpected data received.",g),void 0;if(J('Service "'+d+'" successfull.'),"string"===O.get(z)&&z.match(q)&&(z=B(z.match(q)[1],m)),"string"===O.get(x)&&x.match(q)&&(x=B(x.match(q)[1],m)),p=e,(x||"").match(/^(?:\w+\.)*\w+$/)?o=O.get(x,"string")?x.split("."):a:"string"===O.get(x)&&H('Path "'+x+'" does not match RegExp /^(?:\\w+\\.)*\\w+$/'),o)for(h in o)p=p[o[h]],p!==a||H('Wrong path "'+x+'" for service "'+d+'".');j=N.array(f.events);for(h in j)r[j[h]]=1,w=!0;j=N.array(l.events);for(h in j)r[j[h]]=1,w=!0;if(z&&U[z]&&p!==a&&(v[z]=p,w=!0),"function"===O.get(A)){var D=y(A,{parameters:[e,l],scope:{request:!0,dispatchEvent:!0,update:!0}});j=N.array(D.events);for(i in j)w=!0,r[j[i].type]=j[i];for(i in D.update)v[i]===a?(v[i]=D.update[i],w=!0):H('The key "'+i+'" is nor a method neither a property.');(D.services||[]).length&&(w=!0,s=s.concat(D.services)),c(D)}t=[];for(k in r)t.push(1===r[k]?M.getEvent(k):r[k]);(w||l.loop)&&(l.loop||u)({events:t,update:v,services:s})};var s=l.before||f.before;"function"==typeof s&&"function"===O.get(s)&&(n.beforeSend=function(a){return y(s,{parameters:[l,a],loop:!0,scope:{dispatchEvent:!0,update:!0}}).returned}),("abort"in l?l.abort:f.abort)&&mb[d]&&mb[d].abort(),mb[d]=N.ajax(n)},M}function l(a){mb[a]&&mb[a].abort()}function o(b,c){var d=c||{},e="function"==typeof d?d:d.method,f="object"==typeof d&&"description"in d?d.description:null;return b===a&&I("Shortcut ID not specified."),nb[b]&&I('Shortcut "'+b+'" already exists.'),e===a&&I("Shortcut method not specified."),f&&(ab.shortcuts[b]=f),nb[b]=e,M}function p(c,d,e){var f,g,h,i,j=new k.module,l=e||{},m={};c===a&&I("Module class not specified."),"function"!==O.get(c)&&I("First parameter must be a function."),"id"in l&&l.id in _&&I('The module with id "'+l.id+'" already exists.'),c.apply(j,(d||[]).concat(b())),g=j.triggers||{};for(i in g.events||{})eb[i]=eb[i]||[],eb[i].push(g.events[i]);for(h in g.properties||{}){for(f in db[h]||[])fb[h]=fb[h]||[],fb[h].push(g.properties[h]);if(T[h]!==a){var n={};n[h]=v(h),y(g.properties[h],{parameters:[b()]})}}for(i in cb||{})m[i]=1;for(i in gb||{})m[i]=1;for(i in hb||{})m[i]=1;for(i in jb||{})m[i]=1;for(i in m)j.addEventListener(i,t);return j.log="id"in l?N.partial(J,'[module "'+l.id+'"]'):N.partial(J,"[module]"),j.warn="id"in l?N.partial(H,'[module "'+l.id+'"]'):N.partial(H,"[module]"),j.die="id"in l?N.partial(I,'[module "'+l.id+'"]'):N.partial(I,"[module]"),"id"in l&&(_[l.id]=j),$.push(j),j}function q(a){return _[a]}function r(a){var b,c,d,e,f,g,h,i,j={};if(O.check("string",a)&&(a=_[a]),$.indexOf(a)<0)return M.warn("The module you try to kill is actually not referenced."),a;"function"==typeof a.kill&&a.kill(),i=a.triggers||{};for(g in i.events){if(e=eb[g],f=i.events[g],e&&e.length)for(b=0,c=e.length;c>b;b++)e[b]===f&&e.splice(b,1);e&&!e.length&&delete eb[g]}for(h in i.properties){if(e=fb[h],f=i.properties[h],e&&e.length)for(b=0,c=e.length;c>b;b++)e[b]===f&&e.splice(b,1);e&&!e.length&&delete fb[h]}for(g in cb||{})j[g]=1;for(g in gb||{})j[g]=1;for(g in hb||{})j[g]=1;for(g in jb||{})j[g]=1;for(g in j)a.removeEventListener(g,t);$.splice($.indexOf(a),1);for(d in _)if(_[d]===a){delete _[d];break}return a}function s(a,b){var c="object"==typeof a&&1===arguments.length?a||{}:{};return"string"==typeof a&&(c[a]=b),u({update:c}),this}function t(a){u({events:[a],emitter:a.target})}function u(d){var e,f,g,h,i,j,k,l,m,n,o=!1,p=[],q=[],r=[],s=d||{},t={},v={};s.loop=(+s.loop||0)+1,s.loopId=s.loopId||++bb,G("maxDepth")&&s.loop>G("maxDepth")&&I("Loop "+s.loopId+" exceeds maximum depth ("+G("maxDepth")+")");var z=N.array(s.events),A=N.array(s.services),B=s.update||{};if(G("verbose")){if(J("Iteration "+s.loop+" (loop "+s.loopId+")"),z.length){n=[];for(f in z)n.push(z[f].type);J(" -> Events: ",n)}if(A.length){n=[];for(f in A)n.push("string"==typeof A[f]?A[f]:A[f].service);J(" -> Services: ",n)}n=[];for(f in B)n.push(f);n.length&&J(" -> Update: ",n)}for(m in B)if(U[m]===a)H('The property "'+m+'" is not referenced.');else if(l=w(m,B[m])||s.force||C(m,"force")){for(f in fb[m])y(fb[m][f],{parameters:[b(),{property:m,emitter:s.emitter}]});for(f in db[m]||[])i=db[m][f],t[i]=M.getEvent(i)}if(A.length)if(G("mergeRequests")){e=[];for(g in A)A[g].services?x(A[g].services,A[g]):e.push(A[g]),e.length&&x(e)}else for(g in A)A[g].services?x(A[g].services,A[g]):x(A[g]);for(f in z){if(j=z[f],k=j.data||{}){e=cb[j.type]||[];for(g in e)k[e[g]]!==a&&(o=!0,v[e[g]]=k[e[g]])}for(h in eb[j.type])y(eb[j.type][h],{parameters:[b(),j,s.emitter]});for(g in gb[j.type]||[])if(p.indexOf(gb[j.type][g])<0){p.push(gb[j.type][g]);var D=y(gb[j.type][g],{parameters:[j],scope:{request:!0,dispatchEvent:!0,update:!0}});e=N.array(D.events);for(h in e)t[e[h].type]=e[h];for(h in D.update)v[h]===a?(o=!0,v[h]=D.update[h]):H('The property "'+h+'" has already been updated in the current loop.');(D.services||[]).length&&(o=!0,r=r.concat(D.services)),c(D)}for(g in hb[j.type]||[])i=hb[j.type][g],t[i]=M.getEvent(i);if(G("logDescriptions"))for(g in jb[j.type]||[])J("[HACK]",jb[j.type][g])}for(j in t)M.dispatchEvent(j,t[j].data),q.push(t[j]),o=!0;o&&u({events:q,update:v,services:r,emitter:s.emitter,loopId:s.loopId,loop:s.loop})}function v(a){if(T[a]){if(Y[a]){for(var b,c=[],d={},e=1,f=arguments.length;f>e;e++)c.push(arguments[e]);return d[a]=W[a],b=y(T[a],{parameters:c,inputValues:d}),C(a,"clone")?N.clone(b.returned):b.returned}return C(a,"clone")?N.clone(T[a]()):T[a]()}H('Property "'+a+'" not referenced.')}function w(a,c){if(U[a]){if(Z[a]){var d,e,f=[],g={};C(a,"clone")&&(c=N.clone(c)),g[a]=v(a);for(var h=1,i=arguments.length;i>h;h++)f.push(arguments[h]);return e=y(U[a],{parameters:f,inputValues:g}),d="boolean"!==O.get(e.returned)||e.returned,d&&(W[a]=e.update[a]),d}return U[a].call(b(),C(a,"clone")?N.clone(c):c)}return H('Property "'+a+'" not referenced.'),!1}function x(b,c){if(O.check("string",b))lb[b]?lb[b](c):H('Service "'+b+'" not referenced.');else if(O.check("object",b))x(b.service,b);else if(O.check("array",b)){c=c||{};var d,e=b.length,f=c.merge!==a?!!c.merge:G("mergeRequests");if(f){var g,h,i=e,j=[],k=function(){var a,b,d,f={update:{},events:[],services:[]};for(b=0;e>b;b++){a=j[b]||{};for(d in a.update||{})f.update[d]=a.update[d];f.events=f.events.concat(a.events||[]),f.services=f.services.concat(a.services||[])}c.success&&y(c.success,{parameters:[j],loop:u,scope:{request:!0,dispatchEvent:!0,update:!0}})};for(d=0;e>d;d++){if("string"==typeof b[d])g={service:b[d]};else{g={};for(h in b[d])g[h]=b[d][h]}!function(a){g.loop=function(b){j[a]=b,u(b),--i||k()}}(d),x(g)}}else for(d=0,e=b.length;e>d;d++)x(b[d])}return this}function y(c,d){var e,f,g,h={},i=d||{},j=b(i.scope);"function"!==O.get(c)&&I("The first parameter must be a function");for(e in i.inputValues||{})j[e]=i.inputValues[e];g=c.apply(j,i.parameters||[]),f={returned:g,update:{},events:[],services:[]},null==j._events||O.check("array",j._events)?f.events=j._events:H("Events must be stored in an array.");for(e in j)h[e]=j[e];for(e in j._properties)h[j._properties[e].property]=j._properties[e].value;for(e in h)U[e]!==a?f.update[e]=h[e]:ob[e]===a&&H('The key "'+e+'" is not a method nor a property.');for(e in i.inputValues)f.update[e]=j[e];for(e in j._services)f.services[e]=j._services[e];if(i.loop){var k=(f.services||[]).length||(f.events||[]).length;if(!k)for(e in f.update)k=!0;k&&(O.check("function",i.loop)?i.loop:u)(f)}return f}function z(a){return R[a]}function A(a){return S[a]}function B(c){var d=c,e=G("shortcutPrefix"),f=(c||"").toString().match(new RegExp("^"+e+"(\\w+)$"));f&&f.length&&(H("Prefix in expand() calls is deprecated."),d=f[1]);for(var g=1,h=arguments.length;h>g;g++)if((arguments[g]||{})[d]!==a)return arguments[g][d];return"function"===O.get(T[d])?v(d):"function"===O.get(nb[d])?nb[d].call(b()):(H('The shortcut "',d,'" has not been recognized.'),e+d)}function C(b,c){var d=(X[b]||{})[c];return d!==a?!!d:G(c)}function D(a){return arguments.length?N.clone(L[a]):N.clone(L)}function E(a,b,c){var d,e={},f="[no description is specified]";switch(a){case"properties":if(1===arguments.length){for(d in W)e[d]=ab.properties[d]||f;return e}return ab.properties[b]||f;case"services":if(1===arguments.length){for(d in lb)e[d]=ab.services[d]||f;return e}return ab.services[b]||f;case"shortcuts":if(1===arguments.length){for(d in nb)e[d]=ab.shortcuts[d]||f;return e}return ab.shortcuts[b]||f;case"hacks":if(1===arguments.length)return ib;if(3===arguments.length)return e=[],"trigger"===b?e=jb[c]:"dispatch"===b&&(e=kb[c]),1===e.length?e[0]:e;case"full":return{properties:E("properties"),shortcuts:E("shortcuts"),services:E("services"),hacks:E("hacks")}}}function F(){var a;J('Killing instance "'+pb+'"');for(a in $)$[a].removeEventListener();$=null,Q=null,R=null,S=null,T=null,U=null,V=null,W=null,Y=null,Z=null,$=null,cb=null,db=null,eb=null,fb=null,gb=null,hb=null,lb=null,mb=null,nb=null;for(a in K)delete K[a];i[pb]&&delete i[pb]}function G(b,c){if("string"==typeof b&&1===arguments.length)return P[b]!==a?P[b]:m[b];var d="object"==typeof b&&1===arguments.length?b||{}:{};"string"==typeof b&&(d[b]=c);for(var e in d)d[e]!==a?P[e]=d[e]:delete P[e];return this}function H(){var a=["["+(pb||"domino")+"]"];G("strict")||a.push("WARNING");for(var b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);G("strict")?d.apply(this,a):G("verbose")&&f.apply(this,a)}function I(){for(var a=["["+(pb||"domino")+"]"],b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);d.apply(this,a)}function J(){var a=["["+(pb||"domino")+"]"];if(G("verbose")){for(var b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);f.apply(this,a)}}(function(){n.call(this);for(var a in n.prototype)this[a]=n.prototype[a]}).call(this);var K,L,M=this,N=k.utils,O=k.struct,P={},Q={},R={},S={},T={},U={},V={},W={},X={},Y={},Z={},$=[],_={},ab={properties:{},shortcuts:{},services:{}},bb=0,cb={},db={},eb={},fb={},gb={},hb={},ib=[],jb={},kb={},lb={},mb={},nb={},ob={events:1,services:1,hacks:1};!function(){var a;for(a in Object.prototype)ob[a]=1;for(a in b({full:!0}))ob[a]=1}(),K=b({full:!0});var pb,qb={};return"string"===O.get(arguments[0])?(qb=arguments[1],qb.name=arguments[0]):arguments[0]!==a&&"object"===O.get(arguments[0])?qb=arguments[0]:arguments[1]!==a&&"object"===O.get(arguments[1])&&(qb=arguments[1]),qb.name=pb||qb.name,pb=qb.name,pb&&(i[pb]?I('An instance named "'+pb+'" is already running.'):i[pb]=K),function(){var a;if("array"===O.get(qb.properties))for(a in qb.properties)e(qb.properties[a].id,qb.properties[a]);else if("object"===O.get(qb.properties))for(a in qb.properties)e(a,qb.properties[a]);for(a in qb.hacks||[])h(qb.hacks[a]);if("array"===O.get(qb.services))for(a in qb.services)j(qb.services[a].id,qb.services[a]);else if("object"===O.get(qb.services))for(a in qb.services)j(a,qb.services[a]);if("array"===O.get(qb.shortcuts))for(a in qb.shortcuts)o(qb.shortcuts[a].id,qb.shortcuts[a]);else if("object"===O.get(qb.shortcuts))for(a in qb.shortcuts)o(a,qb.shortcuts[a])}(),L=N.clone(qb),K};k.version="1.3.7","undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=k),exports.domino=k):j.domino=k,k.utils={array:function(a,b){var c="string"===k.struct.get(a)?a.split(b||" "):"array"===k.struct.get(a)?a:[a],d=[];for(var e in c)c[e]&&d.push(c[e]);return d},clone:function(a){if(!a)return a;var b,c,d;if("array"===l.get(a))for(b=[],c=0,d=a.length;d>c;c++)b.push(this.clone(a[c]));else if("date"===l.get(a))b=new Date(a.getTime());else if("object"===l.get(a))if(a.nodeType&&"function"==typeof a.cloneNode)b=a;else if(a.prototype)b=a;else{b={};for(c in a)b[c]=this.clone(a[c])}else b=a;return b},partial:function(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(this,b.concat(Array.prototype.slice.call(arguments)))}},ajax:function(a,c){b()||d('[domino.global] XMLHttpRequest not found. You can specify which XMLHttpRequest you want to use by using domino.settings("xhr", myXhr).'),"string"==typeof a?a={url:a,ok:c}:"object"!==l.get(a)&&d("[domino.global] Invalid parameter given to AJAX");var e,f,g,h=a.type||"GET",i=a.url||"",j=a.contentType||"application/x-www-form-urlencoded",k=a.dataType||"json",n=new m.xhr;if(a.data){if("string"==typeof a.data)f=a.data;else if(/json/.test(j))f=JSON.stringify(a.data);else{f=[];for(g in a.data)f.push(encodeURIComponent(g)+"="+encodeURIComponent(a.data[g]));f=f.join("&")}/GET|DEL/i.test(h)&&(i+=/\?/.test(i)?"&"+f:"?"+f,f="")}if(n.onreadystatechange=function(){if(4==n.readyState)if(e&&clearTimeout(e),/^2/.test(n.status)){if(f=n.responseText,/json/.test(k))try{f=JSON.parse(n.responseText)}catch(b){return a.error&&a.error("JSON parse error: "+b.message,n)}a.success&&a.success(f,n)}else{var c=+n.status?n.responseText:n.responseText.length?"Aborted: "+n.responseText:"Aborted";a.error&&a.error(c,n)}},n.open(h,i,!0),n.setRequestHeader("Content-Type",j),a.headers)for(g in a.headers)n.setRequestHeader(g,a.headers[g]);return"function"==typeof a.beforeSend&&a.beforeSend(n,a)===!1?n.abort():(a.timeout&&(e=setTimeout(function(){n.onreadystatechange=function(){},n.abort(),a.error&&a.error&&a.error("timeout",n)},1e3*a.timeout)),n.send(f),n)}},k.struct=function(){var b=["number","string","boolean","null","undefined"],e="Boolean Number String Function Array Date RegExp Object".split(" "),f={},g=["*"],h={};for(var i in e){var j=e[i];g.push(j.toLowerCase()),f["[object "+j+"]"]=j.toLowerCase()}return{add:function(b,c){var e,f,i,j,l,m;1===arguments.length?"object"===this.get(b)?(m=b,i=m.id,l=m.struct):d("[domino.global] If struct.add is called with one arguments, it has to be an object"):2===arguments.length?("string"===this.get(b)&&b?i=b:d("[domino.global] If struct.add is called with more than one arguments, the first one must be the string id"),l=c):d("[domino.global] struct.add has to be called with one or three arguments"),("string"!==this.get(i)||0===i.length)&&d("[domino.global] A structure requires an string id"),h[i]!==a&&"proto"!==h[i]&&d('[domino.global] The structure "'+i+'" already exists'),h[i]=1,f=k.utils.array((m||{}).proto),j={};for(e in f)h[f[e]]===a&&(h[f[e]]=1,j[f[e]]=1);if("function"===this.get(l)||this.isValid(l)||d('[domino.global] A structure requires a valid "structure" property describing the structure. It can be a valid structure or a function that test if an object matches the structure.'),~g.indexOf(i)&&(delete h[i],d('[domino.global] "'+i+'" is a reserved structure name')),h[i]=m===a?{id:i,struct:l}:{},m!==a)for(e in m)h[i][e]=m[e];for(e in j)e!==i&&delete h[e]},get:function(a){return null==a?String(a):f[Object.prototype.toString.call(a)]||"object"},existing:function(a){return"string"==typeof a?(h[a]||{}).struct:k.utils.clone(h)},check:function(b,d,e){var f,i,j=this.get(d),k=e||{};if("string"===this.get(b)){f=b.replace(/^\?/,"").split(/\|/);for(i in f)if(g.indexOf(f[i])<0&&h[f[i]]===a)return c("[domino.global] Invalid type"),!1;if(null==d)return!!b.match(/^\?/,"");b=b.replace(/^\?/,"");for(i in f)if(h[f[i]]&&("function"===this.get(h[f[i]].struct)?h[f[i]].struct(d)===!0:this.check(h[f[i]].struct,d,h[f[i]])))return!0;return!(!~f.indexOf("*")&&!~f.indexOf(j))}if("object"===this.get(b)){if("object"!==j)return!1;var l;for(l in b)if(!this.check(b[l],d[l]))return!1;if(!k.includes)for(l in d)if(b[l]===a)return!1;return!0}if("array"===this.get(b)){if("array"!==j)return!1;if(1!==b.length)return c("[domino.global] Invalid type"),!1;for(l in d)if(!this.check(b[0],d[l]))return!1;return!0}return!1},deepScalar:function(a){var c,d;if("string"===this.get(a)){c=a.replace(/^\?/,"").split(/\|/);for(d in c)if(b.indexOf(c[d])<0)return!1;return!0}if(this.check("object|array",a)){for(d in a)if(!this.deepScalar(a[d]))return!1;return!0}return!1},compare:function(a,b,c){{var d;this.get(a),this.get(b)}if(!this.deepScalar(c)||!this.check(c,a)||!this.check(c,b))return!1;if("string"===this.get(c))return a===b;if("object"===this.get(c)){for(d in c)if(!this.compare(a[d],b[d],c[d]))return!1;return!0}if("array"===this.get(c)){if(a.length!==b.length)return!1;var e=a.length;for(d=0;e>d;d++)if(!this.compare(a[d],b[d],c[0]))return!1;return!0}return!1},isValid:function(b){var c,d,e;if("string"===this.get(b)){c=b.replace(/^\?/,"").split(/\|/);for(e in c)if(g.indexOf(c[e])<0&&h[c[e]]===a)return!1;return!0}if("object"===this.get(b)){for(d in b)if(!this.isValid(b[d]))return!1;return!0}return"array"===this.get(b)?1===b.length?this.isValid(b[0]):!1:!1}}}();var l=(k.utils,k.struct),m={maxDepth:0,strict:!1,verbose:!1,displayTime:!1,shortcutPrefix:":",mergeRequests:!0,logDescriptions:!0,xhr:j.XMLHttpRequest,clone:!1};k.settings=function(b,c){if("string"==typeof b&&1===arguments.length)return m[b];var d="object"==typeof b&&1===arguments.length?b||{}:{};"string"==typeof b&&(d[b]=c);for(var e in d)d[e]!==a?m[e]=d[e]:delete m[e];return this},k.instances=function(a){return arguments.length?i[a]:(d("[domino.global] You need to indicate a name to get the instance."),void 0)},k.EventDispatcher=function(){Object.defineProperty(this,"_handlers",{value:{}})};var n=k.EventDispatcher;n.prototype.addEventListener=function(a,b){var c,d,e,f;if(1===arguments.length&&"object"==typeof arguments[0])for(a in arguments[0])this.addEventListener(a,arguments[0][a]);else{if(2!==arguments.length||"function"!=typeof arguments[1])throw"domino.EventDispatcher.addEventListener: Wrong arguments.";for(f="string"==typeof a?a.split(" "):a,c=0,d=f.length;c!==d;c+=1)e=f[c],e&&(this._handlers[e]||(this._handlers[e]=[]),this._handlers[e].push({handler:b}))}return this},n.prototype.removeEventListener=function(a,b){var c,d,e,f,g,h,i,j="string"==typeof a?a.split(" "):a;if(!arguments.length){for(g in this._handlers)delete this._handlers[g];return this}if(b)for(c=0,d=j.length;c!==d;c+=1){if(i=j[c],this._handlers[i]){for(h=[],e=0,f=this._handlers[i].length;e!==f;e+=1)this._handlers[i][e].handler!==b&&h.push(this._handlers[i][e]);this._handlers[i]=h}this._handlers[i]&&0===this._handlers[i].length&&delete this._handlers[i]}else for(c=0,d=j.length;c!==d;c+=1)delete this._handlers[j[c]];return this},n.prototype.dispatchEvent=function(b,c){var d,e,f,g,h,i,j,k,l=this,m="string"==typeof b?b.split(" "):b;for(c=c===a?{}:c,d=0,e=m.length;d!==e;d+=1)if(k=m[d],j=this._handlers[k],j&&j.length){for(i=l.getEvent(k,c),h=[],f=0,g=j.length;f!==g;f+=1)j[f].handler(i),j[f].one||h.push(j[f]);this._handlers[k]=h}return this},n.prototype.getEvent=function(a,b){return{type:a,data:b||{},target:this}},k.module=function(){if(!this._handlers){n.call(this);for(var a in n.prototype)this[a]=n.prototype[a];this.triggers={properties:{},events:{}},this.log=this.warn=this.die=function(){}}}}).call(this); |
## domino.js - changelog: | ||
#### 1.3.7 (May 19, 2014) | ||
- Fixed [#58](https://github.com/jacomyal/domino.js/issues/58): module `kill` method support, added related unit tests | ||
#### 1.3.6 (April 22, 2014) | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "domino-js", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"description": "A cascading controller for fast interactive Web interfaces prototyping.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://dominojs.org", |
@@ -9,4 +9,6 @@ // Domino settings: | ||
QUnit.test('Modules management', function() { | ||
var module, | ||
var test, | ||
module, | ||
module2, | ||
module3, | ||
domInstance; | ||
@@ -130,2 +132,12 @@ | ||
QUnit.ok(module2, 'Reference a module with the ID of a previously killed module works.'); | ||
// Test the "kill" method: | ||
test = false; | ||
module3 = domInstance.addModule(function() { | ||
this.kill = function() { | ||
test = true; | ||
} | ||
}); | ||
domInstance.killModule(module3); | ||
QUnit.ok(test, 'The kill method of the module is called when the module is actually killed.'); | ||
}); | ||
@@ -132,0 +144,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
388002
7179