diff --git a/lib/zebra/canvas.js b/lib/zebra/canvas.js index fddf704d..16e59f31 100755 --- a/lib/zebra/canvas.js +++ b/lib/zebra/canvas.js @@ -2773,6 +2773,7 @@ pkg.Manager = Class([ */ pkg.PaintManager = Class(pkg.Manager, [ function $prototype() { + var $painting = {}; var $timers = {}; /** @@ -2834,62 +2835,66 @@ pkg.PaintManager = Class(pkg.Manager, [ if (h + y > y2) h = y2 - y; if (w > 0 && h > 0) { + if ($painting[canvas] != null) { + //!!! Perhaps a better policy is to honor + // the repaint request anyway, but still + // emit a warning + zebra.warn('repaint called synchronously from paint, update, or paintOnTop ignored!'); + return; + } + var da = canvas.$da; - if (da.width > 0) { - if (x >= da.x && - y >= da.y && - x + w <= da.x + da.width && - y + h <= da.y + da.height ) - { - return; + if ($timers[canvas] != null) { + // paint is already scheduled, just need + // to update the dirty area + + if (x < da.x || + y < da.y || + x + w > da.x + da.width || + y + h > da.y + da.height ) + { + MB.unite(da.x, da.y, da.width, da.height, x, y, w, h, da); } - MB.unite(da.x, da.y, da.width, da.height, x, y, w, h, da); - } - else { - MB.intersection(0, 0, canvas.width, canvas.height, x, y, w, h, da); + return; } - if (da.width > 0 && $timers[canvas] == null) { - var $this = this; - $timers[canvas] = setTimeout(function() { - $timers[canvas] = null; - - // prevent double painting, sometimes - // width can be -1 what cause clearRect - // clean incorrectly - if (canvas.$da.width <= 0) { - return ; + MB.intersection(0, 0, canvas.width, canvas.height, x, y, w, h, da); + + var $this = this; + $timers[canvas] = setTimeout(function() { + $timers[canvas] = null; + + var context = canvas.$context; + // record that we are painting to warn + // if repaint is called recursively + $painting[canvas] = true; + try { + canvas.validate(); + context.save(); + context.translate(canvas.x, canvas.y); + + //!!!! debug + // zebra.print(" ============== DA = " + canvas.$da.y ); + // var dg = canvas.canvas.getContext("2d"); + // dg.strokeStyle = 'red'; + // dg.beginPath(); + // dg.rect(da.x, da.y, da.width, da.height); + // dg.stroke(); + + context.clipRect(canvas.$da.x, canvas.$da.y, + canvas.$da.width, canvas.$da.height); + if (canvas.bg == null) { + context.clearRect(canvas.$da.x, canvas.$da.y, + canvas.$da.width, canvas.$da.height); } - var context = canvas.$context; - try { - canvas.validate(); - context.save(); - context.translate(canvas.x, canvas.y); - - //!!!! debug - // zebra.print(" ============== DA = " + canvas.$da.y ); - // var dg = canvas.canvas.getContext("2d"); - // dg.strokeStyle = 'red'; - // dg.beginPath(); - // dg.rect(da.x, da.y, da.width, da.height); - // dg.stroke(); - - context.clipRect(canvas.$da.x, canvas.$da.y, - canvas.$da.width, canvas.$da.height); - if (canvas.bg == null) { - context.clearRect(canvas.$da.x, canvas.$da.y, - canvas.$da.width, canvas.$da.height); - } - - $this.paint(context, canvas); - - context.restore(); - canvas.$da.width = -1; //!!! - } - catch(e) { zebra.print(e); } - }, 50); - } + $this.paint(context, canvas); + + context.restore(); + } + catch(e) { zebra.print(e); } + $painting[canvas] = null; + }, 50); // !!! not sure the code below is redundant, but it looks redundantly // if (da.width > 0) { diff --git a/lib/zebra/zebra.canvas.js b/lib/zebra/zebra.canvas.js index 0451b310..e43cbff3 100644 --- a/lib/zebra/zebra.canvas.js +++ b/lib/zebra/zebra.canvas.js @@ -8251,6 +8251,7 @@ pkg.Manager = Class([ */ pkg.PaintManager = Class(pkg.Manager, [ function $prototype() { + var $painting = {}; var $timers = {}; /** @@ -8312,62 +8313,66 @@ pkg.PaintManager = Class(pkg.Manager, [ if (h + y > y2) h = y2 - y; if (w > 0 && h > 0) { + if ($painting[canvas] != null) { + //!!! Perhaps a better policy is to honor + // the repaint request anyway, but still + // emit a warning + zebra.warn('repaint called synchronously from paint, update, or paintOnTop ignored!'); + return; + } + var da = canvas.$da; - if (da.width > 0) { - if (x >= da.x && - y >= da.y && - x + w <= da.x + da.width && - y + h <= da.y + da.height ) - { - return; + if ($timers[canvas] != null) { + // paint is already scheduled, just need + // to update the dirty area + + if (x < da.x || + y < da.y || + x + w > da.x + da.width || + y + h > da.y + da.height ) + { + MB.unite(da.x, da.y, da.width, da.height, x, y, w, h, da); } - MB.unite(da.x, da.y, da.width, da.height, x, y, w, h, da); - } - else { - MB.intersection(0, 0, canvas.width, canvas.height, x, y, w, h, da); + return; } - if (da.width > 0 && $timers[canvas] == null) { - var $this = this; - $timers[canvas] = setTimeout(function() { - $timers[canvas] = null; - - // prevent double painting, sometimes - // width can be -1 what cause clearRect - // clean incorrectly - if (canvas.$da.width <= 0) { - return ; + MB.intersection(0, 0, canvas.width, canvas.height, x, y, w, h, da); + + var $this = this; + $timers[canvas] = setTimeout(function() { + $timers[canvas] = null; + + var context = canvas.$context; + // record that we are painting to warn + // if repaint is called recursively + $painting[canvas] = true; + try { + canvas.validate(); + context.save(); + context.translate(canvas.x, canvas.y); + + //!!!! debug + // zebra.print(" ============== DA = " + canvas.$da.y ); + // var dg = canvas.canvas.getContext("2d"); + // dg.strokeStyle = 'red'; + // dg.beginPath(); + // dg.rect(da.x, da.y, da.width, da.height); + // dg.stroke(); + + context.clipRect(canvas.$da.x, canvas.$da.y, + canvas.$da.width, canvas.$da.height); + if (canvas.bg == null) { + context.clearRect(canvas.$da.x, canvas.$da.y, + canvas.$da.width, canvas.$da.height); } - var context = canvas.$context; - try { - canvas.validate(); - context.save(); - context.translate(canvas.x, canvas.y); - - //!!!! debug - // zebra.print(" ============== DA = " + canvas.$da.y ); - // var dg = canvas.canvas.getContext("2d"); - // dg.strokeStyle = 'red'; - // dg.beginPath(); - // dg.rect(da.x, da.y, da.width, da.height); - // dg.stroke(); - - context.clipRect(canvas.$da.x, canvas.$da.y, - canvas.$da.width, canvas.$da.height); - if (canvas.bg == null) { - context.clearRect(canvas.$da.x, canvas.$da.y, - canvas.$da.width, canvas.$da.height); - } - - $this.paint(context, canvas); + $this.paint(context, canvas); - context.restore(); - canvas.$da.width = -1; //!!! - } - catch(e) { zebra.print(e); } - }, 50); - } + context.restore(); + } + catch(e) { zebra.print(e); } + $painting[canvas] = null; + }, 50); // !!! not sure the code below is redundant, but it looks redundantly // if (da.width > 0) { diff --git a/lib/zebra/zebra.canvas.min.js b/lib/zebra/zebra.canvas.min.js index 6766b203..9878da9b 100644 --- a/lib/zebra/zebra.canvas.min.js +++ b/lib/zebra/zebra.canvas.min.js @@ -1 +1 @@ -(function(){(function(){function isString(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="string"||o.constructor===String)}function isNumber(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="number"||o.constructor===Number)}function isBoolean(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="boolean"||o.constructor===Boolean)}if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(searchElement){if(this==null){throw new TypeError()}var t=Object(this),len=t.length>>>0;if(len===0){return -1}var n=0;if(arguments.length>0){n=Number(arguments[1]);if(n!=n){n=0}else{if(n!==0&&n!=Infinity&&n!=-Infinity){n=(n>0||-1)*~~Math.abs(n)}}}if(n>=len){return -1}var k=n>=0?n:Math.max(len-Math.abs(n),0);for(;k0)?new zebra.URL(ss.substring(0,i+1)):new zebra.URL(document.location.toString()).getParentURL()}}if(namespaces.hasOwnProperty(nsname)){throw new Error("Name space '"+nsname+"' already exists")}var f=function(name){if(arguments.length===0){return f.$env}if(typeof name==="function"){for(var k in f){if(f[k] instanceof Package){name(k,f[k])}}return null}var b=Array.isArray(name);if(isString(name)===false&&b===false){for(var k in name){if(name.hasOwnProperty(k)){f.$env[k]=name[k]}}return}if(b){for(var i=0;i=0){for(var k in p){if(k[0]!="$"&&k[0]!="_"&&(p[k] instanceof Package)===false&&p.hasOwnProperty(k)){code.push([k,ns,n,".",k].join(""))}}if(packages!=null){packages.splice(packages.indexOf(n),1)}}});if(packages!=null&&packages.length!==0){throw new Error("Unknown package(s): "+packages.join(","))}return code.length>0?["var ",code.join(","),";"].join(""):null};f.$env={};namespaces[nsname]=f;return f};zebra=namespace("zebra");var pkg=zebra,FN=pkg.$FN=(typeof namespace.name==="undefined")?(function(f){var mt=f.toString().match(/^function\s+([^\s(]+)/);return(mt==null)?"":mt[1]}):(function(f){return f.name});pkg.namespaces=namespaces;pkg.namespace=namespace;pkg.$global=this;pkg.isString=isString;pkg.isNumber=isNumber;pkg.isBoolean=isBoolean;pkg.version="1.2.0";pkg.$caller=null;function mnf(name,params){var cln=this.$clazz&&this.$clazz.$name?this.$clazz.$name+".":"";throw new ReferenceError("Method '"+cln+(name===""?"constructor":name)+"("+params+")' not found")}function $toString(){return this._hash_}function $equals(o){return this==o}function make_template(pt,tf,p){tf._hash_=["$zebra_",$$$++].join("");tf.toString=$toString;if(pt!=null){tf.prototype.$clazz=tf}tf.$clazz=pt;tf.prototype.toString=$toString;tf.prototype.equals=$equals;tf.prototype.constructor=tf;if(p&&p.length>0){tf.$parents={};for(var i=0;i0){return new (pkg.Class($Interface,arguments[0]))()}},arguments);return $Interface});pkg.$Extended=pkg.Interface();function ProxyMethod(name,f){if(isString(name)===false){throw new TypeError("Method name has not been defined")}var a=null;if(arguments.length==1){a=function(){var nm=a.methods[arguments.length];if(nm){var cm=pkg.$caller;pkg.$caller=nm;try{return nm.apply(this,arguments)}catch(e){throw e}finally{pkg.$caller=cm}}mnf.call(this,a.methodName,arguments.length)};a.methods={}}else{a=function(){var cm=pkg.$caller;pkg.$caller=f;try{return f.apply(this,arguments)}catch(e){throw e}finally{pkg.$caller=cm}};a.f=f}a.$clone$=function(){if(a.methodName===""){return null}if(a.f){return ProxyMethod(a.methodName,a.f)}var m=ProxyMethod(a.methodName);for(var k in a.methods){m.methods[k]=a.methods[k]}return m};a.methodName=name;return a}pkg.Class=make_template(null,function(){if(arguments.length===0){throw new Error("No class definition was found")}if(Array.isArray(arguments[arguments.length-1])===false){throw new Error("Invalid class definition was found")}if(arguments.length>1&&typeof arguments[0]!=="function"){throw new ReferenceError("Invalid parent class '"+arguments[0]+"'")}var df=arguments[arguments.length-1],$parent=null,args=Array.prototype.slice.call(arguments,0,arguments.length-1);if(args.length>0&&(args[0]==null||args[0].$clazz==pkg.Class)){$parent=args[0]}var $template=make_template(pkg.Class,function(){this._hash_=["$zObj_",$$$++].join("");if(arguments.length>0){var a=arguments[arguments.length-1];if(Array.isArray(a)===true&&typeof a[0]==="function"){a=a[0];var args=[$template],k=arguments.length-2;for(;k>=0&&pkg.instanceOf(arguments[k],pkg.Interface);k--){args.push(arguments[k])}args.push(arguments[arguments.length-1]);var cl=pkg.Class.apply(null,args),f=function(){};cl.$name=$template.$name;f.prototype=cl.prototype;var o=new f();cl.apply(o,Array.prototype.slice.call(arguments,0,k+1));o.constructor=cl;return o}}this[""]&&this[""].apply(this,arguments)},args);$template.$parent=$parent;if($parent!=null){for(var k in $parent.prototype){var f=$parent.prototype[k];if(f&&f.$clone$){f=f.$clone$();if(f==null){continue}}$template.prototype[k]=f}}$template.$propertyInfo={};$template.prototype.extend=function(){var c=this.$clazz,l=arguments.length,f=arguments[l-1];if(pkg.instanceOf(this,pkg.$Extended)===false){var cn=c.$name;c=Class(c,pkg.$Extended,[]);c.$name=cn;this.$clazz=c}if(Array.isArray(f)){for(var i=0;i0&&typeof arguments[0]==="function"){name=arguments[0].methodName;args=Array.prototype.slice.call(arguments,1)}var params=args.length;while($s!=null){var m=$s.prototype[name];if(m&&(typeof m.methods==="undefined"||m.methods[params])){return m.apply(this,args)}$s=$s.$parent}mnf.call(this,name,params)}throw new Error("$super is called outside of class context")};$template.prototype.$clazz=$template;$template.prototype.$this=function(){return pkg.$caller.boundTo.prototype[""].apply(this,arguments)};$template.constructor.prototype.getMethods=function(name){var m=[];for(var n in this.prototype){var f=this.prototype[n];if(arguments.length>0&&name!=n){continue}if(typeof f==="function"){if(f.$clone$){for(var mk in f.methods){m.push(f.methods[mk])}}else{m.push(f)}}}return m};$template.constructor.prototype.getMethod=function(name,params){var m=this.prototype[name];if(typeof m==="function"){if(m.$clone$){if(typeof params==="undefined"){if(m.methods[0]){return m.methods[0]}for(var k in m.methods){return m.methods[k]}return null}m=m.methods[params]}if(m){return m}}return null};$template.extend=function(df){if(Array.isArray(df)===false){throw new Error("Wrong class definition format "+df+", array is expected")}for(var i=0;i0){$busy--}}else{if(arguments.length==1&&$busy===0&&$f.length===0){arguments[0]();return}}for(var i=0;i0){$f.shift()()}};pkg.busy=function(){$busy++};pkg.Output=Class([function $prototype(){this.print=function print(o){this._p(0,o)};this.error=function error(o){this._p(2,o)};this.warn=function warn(o){this._p(1,o)};this._p=function(l,o){o=this.format(o);if(pkg.isInBrowser){if(typeof console==="undefined"||!console.log){alert(o)}else{if(l===0){console.log(o)}else{if(l==1){console.warn(o)}else{console.error(o)}}}}else{pkg.$global.print(o)}};this.format=function(o){if(o&&o.stack){return[o.toString(),":",o.stack.toString()].join("\n")}if(o===null){return""}if(typeof o==="undefined"){return""}if(isString(o)||isNumber(o)||isBoolean(o)){return o}var d=[o.toString()+" "+(o.$clazz?o.$clazz.$name:""),"{"];for(var k in o){if(o.hasOwnProperty(k)){d.push(" "+k+" = "+o[k])}}return d.join("\n")+"\n}"}}]);pkg.Dummy=Class([]);pkg.HtmlOutput=Class(pkg.Output,[function(){this.$this(null)},function(element){element=element||"zebra.out";if(pkg.isString(element)){this.el=document.getElementById(element);if(this.el==null){this.el=document.createElement("div");this.el.setAttribute("id",element);document.body.appendChild(this.el)}}else{if(element==null){throw new Error("Unknown HTML output element")}this.el=element}},function print(s){this.out("black",s)},function error(s){this.out("red",s)},function warn(s){this.out("orange",s)},function out(color,msg){var t=["
",this.format(msg),"
"];this.el.innerHTML+=t.join("")}]);pkg.isInBrowser=typeof navigator!=="undefined";pkg.isIE=pkg.isInBrowser&&(Object.hasOwnProperty.call(window,"ActiveXObject")||!!window.ActiveXObject);pkg.isFF=pkg.isInBrowser&&window.mozInnerScreenX!=null;pkg.isMobile=pkg.isInBrowser&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|windows mobile|windows phone|IEMobile/i.test(navigator.userAgent);pkg.isTouchable=pkg.isInBrowser&&((pkg.isIE===false&&(!!("ontouchstart" in window)||!!("onmsgesturechange" in window)))||(!!window.navigator.msPointerEnabled&&!!window.navigator.msMaxTouchPoints>0));pkg.out=new pkg.Output();pkg.isMacOS=pkg.isInBrowser&&navigator.platform.toUpperCase().indexOf("MAC")!==-1;pkg.print=function(){pkg.out.print.apply(pkg.out,arguments)};pkg.error=function(){pkg.out.error.apply(pkg.out,arguments)};pkg.warn=function(){pkg.out.warn.apply(pkg.out,arguments)};function complete(){pkg(function(n,p){function collect(pp,p){for(var k in p){if(k[0]!="$"&&p.hasOwnProperty(k)&&zebra.instanceOf(p[k],Class)){p[k].$name=pp?[pp,k].join("."):k;collect(k,p[k])}}}collect(null,p)});pkg.ready()}if(pkg.isInBrowser){var m=window.location.search.match(/[?&][a-zA-Z0-9_.]+=[^?&=]+/g),env={};for(var i=0;m&&i0?"&":"?")+t,false);r.send(null)};var b64str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";pkg.b64encode=function(input){var out=[],i=0,len=input.length,c1,c2,c3;if(typeof ArrayBuffer!=="undefined"){if(input instanceof ArrayBuffer){input=new Uint8Array(input)}input.charCodeAt=function(i){return this[i]}}if(Array.isArray(input)){input.charCodeAt=function(i){return this[i]}}while(i>2));if(i==len){out.push(b64str.charAt((c1&3)<<4),"==");break}c2=input.charCodeAt(i++);out.push(b64str.charAt(((c1&3)<<4)|((c2&240)>>4)));if(i==len){out.push(b64str.charAt((c2&15)<<2),"=");break}c3=input.charCodeAt(i++);out.push(b64str.charAt(((c2&15)<<2)|((c3&192)>>6)),b64str.charAt(c3&63))}return out.join("")};pkg.b64decode=function(input){var output=[],chr1,chr2,chr3,enc1,enc2,enc3,enc4;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while((input.length%4)!==0){input+="="}for(var i=0;i>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output.push(String.fromCharCode(chr1));if(enc3!=64){output.push(String.fromCharCode(chr2))}if(enc4!=64){output.push(String.fromCharCode(chr3))}}return output.join("")};pkg.dateToISO8601=function(d){function pad(n){return n<10?"0"+n:n}return[d.getUTCFullYear(),"-",pad(d.getUTCMonth()+1),"-",pad(d.getUTCDate()),"T",pad(d.getUTCHours()),":",pad(d.getUTCMinutes()),":",pad(d.getUTCSeconds()),"Z"].join("")};pkg.ISO8601toDate=function(v){var regexp=["([0-9]{4})(-([0-9]{2})(-([0-9]{2})","(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?","(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?"].join(""),d=v.match(new RegExp(regexp)),offset=0,date=new Date(d[1],0,1);if(d[3]){date.setMonth(d[3]-1)}if(d[5]){date.setDate(d[5])}if(d[7]){date.setHours(d[7])}if(d[8]){date.setMinutes(d[8])}if(d[10]){date.setSeconds(d[10])}if(d[12]){date.setMilliseconds(Number("0."+d[12])*1000)}if(d[14]){offset=(Number(d[16])*60)+Number(d[17]);offset*=((d[15]=="-")?1:-1)}offset-=date.getTimezoneOffset();date.setTime(Number(date)+(offset*60*1000));return date};pkg.parseXML=function(s){function rmws(node){if(node.childNodes!==null){for(var i=node.childNodes.length;i-->0;){var child=node.childNodes[i];if(child.nodeType===3&&child.data.match(/^\s*$/)){node.removeChild(child)}if(child.nodeType===1){rmws(child)}}}return node}if(typeof DOMParser!=="undefined"){return rmws((new DOMParser()).parseFromString(s,"text/xml"))}else{for(var n in {"Microsoft.XMLDOM":0,"MSXML2.DOMDocument":1,"MSXML.DOMDocument":2}){var p=null;try{p=new ActiveXObject(n);p.async=false}catch(e){continue}if(p===null){throw new Error("XML parser is not available")}p.loadXML(s);return p}}throw new Error("No XML parser is available")};pkg.QS=Class([function $clazz(){this.append=function(url,obj){return url+((obj===null)?"":((url.indexOf("?")>0)?"&":"?")+pkg.QS.toQS(obj,true))};this.parse=function(url){var m=window.location.search.match(/[?&][a-zA-Z0-9_.]+=[^?&=]+/g),r={};for(var i=0;m&&i0?this.data.charCodeAt(this.pos++)&255:-1}])}else{if(Array.isArray(container)===false){throw new Error("Wrong type: "+typeof(container))}}this.data=container}this.marked=-1;this.pos=0},function mark(){if(this.available()<=0){throw new Error()}this.marked=this.pos},function reset(){if(this.available()<=0||this.marked<0){throw new Error()}this.pos=this.marked;this.marked=-1},function close(){this.pos=this.data.length},function read(){return this.available()>0?this.data[this.pos++]:-1},function read(buf){return this.read(buf,0,buf.length)},function read(buf,off,len){for(var i=0;i191&&c<224){return String.fromCharCode(((c&31)<<6)|(c2&63))}else{var c3=this.read();if(c3<0){throw new Error()}return String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63))}},function readLine(){if(this.available()>0){var line=[],b;while((b=this.readChar())!=-1&&b!="\n"){line.push(b)}var r=line.join("");line.length=0;return r}return null},function available(){return this.data===null?-1:this.data.length-this.pos},function toBase64(){return pkg.b64encode(this.data)}]);pkg.URLInputStream=Class(pkg.InputStream,[function(url){this.$this(url,null)},function(url,f){var r=pkg.getRequest(),$this=this;r.open("GET",url,f!==null);if(f===null||isBA===false){if(!r.overrideMimeType){throw new Error("Binary mode is not supported")}r.overrideMimeType("text/plain; charset=x-user-defined")}if(f!==null){if(isBA){r.responseType="arraybuffer"}r.onreadystatechange=function(){if(r.readyState==4){if(r.status!=200){throw new Error(url)}$this.$clazz.$parent.getMethod("",1).call($this,isBA?r.response:r.responseText);f($this.data,r)}};r.send(null)}else{r.send(null);if(r.status!=200){throw new Error(url)}this.$super(r.responseText)}},function close(){this.$super();if(this.data){this.data.length=0;this.data=null}}]);pkg.Service=Class([function(url,methods){var $this=this;this.url=url;if(Array.isArray(methods)===false){methods=[methods]}for(var i=0;i0&&typeof args[args.length-1]=="function"){var callback=args.pop();return this.send(url,this.encode(name,args),function(request){var r=null;try{if(request.status==200){r=$this.decode(request.responseText)}else{r=new Error("Status: "+request.status+", '"+request.statusText+"'")}}catch(e){r=e}callback(r)})}return this.decode(this.send(url,this.encode(name,args),null))}})()}},function send(url,data,callback){var http=new pkg.HTTP(url);if(this.contentType!=null){http.header["Content-Type"]=this.contentType}return http.POST(data,callback)}]);pkg.Service.invoke=function(clazz,url,method){var rpc=new clazz(url,method);return function(){return rpc[method].apply(rpc,arguments)}};pkg.JRPC=Class(pkg.Service,[function(url,methods){this.$super(url,methods);this.version="2.0";this.contentType="application/json"},function encode(name,args){return JSON.stringify({jsonrpc:this.version,method:name,params:args,id:pkg.ID()})},function decode(r){if(r===null||r.length===0){throw new Error("Empty JSON result string")}r=JSON.parse(r);if(typeof(r.error)!=="undefined"){throw new Error(r.error.message)}if(typeof r.result==="undefined"||typeof r.id==="undefined"){throw new Error("Wrong JSON response format")}return r.result}]);pkg.Base64=function(s){if(arguments.length>0){this.encoded=pkg.b64encode(s)}};pkg.Base64.prototype.toString=function(){return this.encoded};pkg.Base64.prototype.decode=function(){return pkg.b64decode(this.encoded)};pkg.XRPC=Class(pkg.Service,[function(url,methods){this.$super(url,methods);this.contentType="text/xml"},function encode(name,args){var p=['\n',name,""];for(var i=0;i");this.encodeValue(args[i],p);p.push("")}p.push("");return p.join("")},function encodeValue(v,p){if(v===null){throw new Error("Null is not allowed")}if(zebra.isString(v)){v=v.replace("<","<");v=v.replace("&","&");p.push("",v,"")}else{if(zebra.isNumber(v)){if(Math.round(v)==v){p.push("",v.toString(),"")}else{p.push("",v.toString(),"")}}else{if(zebra.isBoolean(v)){p.push("",v?"1":"0","")}else{if(v instanceof Date){p.push("",pkg.dateToISO8601(v),"")}else{if(Array.isArray(v)){p.push("");for(var i=0;i");this.encodeValue(v[i],p);p.push("")}p.push("")}else{if(v instanceof pkg.Base64){p.push("",v.toString(),"")}else{p.push("");for(var k in v){if(v.hasOwnProperty(k)){p.push("",k,"");this.encodeValue(v[k],p);p.push("")}}p.push("")}}}}}}},function decodeValue(node){var tag=node.tagName.toLowerCase();if(tag=="struct"){var p={};for(var i=0;i0){var err=this.decodeValue(c[0].getElementsByTagName("struct")[0]);throw new Error(err.faultString)}c=p.getElementsByTagName("methodResponse")[0];c=c.childNodes[0].childNodes[0];if(c.tagName.toLowerCase()==="param"){return this.decodeValue(c.childNodes[0].childNodes[0])}throw new Error("incorrect XML-RPC response")}]);pkg.XRPC.invoke=function(url,method){return pkg.Service.invoke(pkg.XRPC,url,method)};pkg.JRPC.invoke=function(url,method){return pkg.Service.invoke(pkg.JRPC,url,method)}})(zebra("io"),zebra.Class);(function(pkg,Class,Interface){pkg.newInstance=function(clazz,args){if(args&&args.length>0){var f=function(){};f.prototype=clazz.prototype;var o=new f();o.constructor=clazz;clazz.apply(o,args);return o}return new clazz()};function hex(v){return(v<16)?["0",v.toString(16)].join(""):v.toString(16)}pkg.findInTree=function(root,path,eq,cb){var findRE=/(\/\/|\/)?([^\[\/]+)(\[\s*(\@[a-zA-Z_][a-zA-Z0-9_\.]*)\s*\=\s*([0-9]+|true|false|\'[^']*\')\s*\])?/g,m=null,res=[];function _find(root,ms,idx,cb){function list_child(r,name,deep,cb){if(r.kids){for(var i=0;i=ms.length){return cb(root)}var m=ms[idx];return list_child(root,m[2],m[1]=="//",function(child){if(m[3]&&child[m[4].substring(1)]!=m[5]){return false}return _find(child,ms,idx+1,cb)})}var c=0;while(m=findRE.exec(path)){if(m[1]==null||m[2]==null||m[2].trim().length===0){break}c+=m[0].length;if(m[3]&&m[5][0]=="'"){m[5]=m[5].substring(1,m[5].length-1)}res.push(m)}if(res.length==0||c3){this.a=parseInt(p[3].trim(),10)}return}}}this.r=r>>16;this.g=(r>>8)&255;this.b=(r&255)}else{this.r=r;this.g=g;this.b=b;if(arguments.length>3){this.a=a}}if(this.s==null){this.s=(typeof this.a!=="undefined")?["rgba(",this.r,",",this.g,",",this.b,",",this.a,")"].join(""):["#",hex(this.r),hex(this.g),hex(this.b)].join("")}};var rgb=pkg.rgb;rgb.prototype.toString=function(){return this.s};rgb.black=new rgb(0);rgb.white=new rgb(16777215);rgb.red=new rgb(255,0,0);rgb.blue=new rgb(0,0,255);rgb.green=new rgb(0,255,0);rgb.gray=new rgb(128,128,128);rgb.lightGray=new rgb(211,211,211);rgb.darkGray=new rgb(169,169,169);rgb.orange=new rgb(255,165,0);rgb.yellow=new rgb(255,255,0);rgb.pink=new rgb(255,192,203);rgb.cyan=new rgb(0,255,255);rgb.magenta=new rgb(255,0,255);rgb.darkBlue=new rgb(0,0,140);rgb.transparent=new rgb(0,0,0,1);pkg.Actionable=Interface();pkg.index2point=function(offset,cols){return[~~(offset/cols),(offset%cols)]};pkg.indexByPoint=function(row,col,cols){return(cols<=0)?-1:(row*cols)+col};pkg.intersection=function(x1,y1,w1,h1,x2,y2,w2,h2,r){r.x=x1>x2?x1:x2;r.width=Math.min(x1+w1,x2+w2)-r.x;r.y=y1>y2?y1:y2;r.height=Math.min(y1+h1,y2+h2)-r.y};pkg.isIntersect=function(x1,y1,w1,h1,x2,y2,w2,h2){return(Math.min(x1+w1,x2+w2)-(x1>x2?x1:x2))>0&&(Math.min(y1+h1,y2+h2)-(y1>y2?y1:y2))>0};pkg.unite=function(x1,y1,w1,h1,x2,y2,w2,h2,r){r.x=x1>8)&255);ar.push(code&255)}return ar};var digitRE=/[0-9]/;pkg.isDigit=function(ch){if(ch.length!=1){throw new Error("Incorrect character")}return digitRE.test(ch)};var letterRE=/[A-Za-z]/;pkg.isLetter=function(ch){if(ch.length!=1){throw new Error("Incorrect character")}return letterRE.test(ch)};var $NewListener=function(){if(arguments.length===0){arguments=["fired"]}var clazz=function(){};if(arguments.length==1){var name=arguments[0];clazz.prototype.add=function(l){if(this.v==null){this.v=[]}var ctx=this;if(typeof l!=="function"){ctx=l;l=l[name];if(l==null||typeof l!=="function"){throw new Error("Instance doesn't declare '"+names+"' listener method")}}this.v.push(ctx,l);return l};clazz.prototype.remove=function(l){if(this.v!=null){var i=0;while((i=this.v.indexOf(l))>=0){if(i%2>0){i--}this.v.splice(i,2)}}};clazz.prototype.removeAll=function(){if(this.v!=null){this.v.length=0}};clazz.prototype[name]=function(){if(this.v!=null){for(var i=0;i=0){if(i%2>0){i--}v.splice(i,2)}if(v.length===0){delete this.methods[k]}}}};clazz.prototype.removeAll=function(){if(this.methods!=null){for(var k in this.methods){if(this.methods.hasOwnProperty(k)){this.methods[k].length=0}}this.methods={}}}}return clazz};pkg.Listeners=$NewListener();pkg.Listeners.Class=$NewListener;var PosListeners=pkg.Listeners.Class("posChanged"),Position=pkg.Position=Class([function $clazz(){this.Metric=Interface();this.DOWN=1;this.UP=2;this.BEG=3;this.END=4},function $prototype(){this.clearPos=function(){if(this.offset>=0){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol;this.offset=this.currentLine=this.currentCol=-1;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.setOffset=function(o){if(o<0){o=0}else{var max=this.metrics.getMaxOffset();if(o>=max){o=max}}if(o!=this.offset){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol,p=this.getPointByOffset(o);this.offset=o;if(p!=null){this.currentLine=p[0];this.currentCol=p[1]}this.isValid=true;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.seek=function(off){this.setOffset(this.offset+off)};this.setRowCol=function(r,c){if(r!=this.currentLine||c!=this.currentCol){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol;this.offset=this.getOffsetByPoint(r,c);this.currentLine=r;this.currentCol=c;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.inserted=function(off,size){if(this.offset>=0&&off<=this.offset){this.isValid=false;this.setOffset(this.offset+size)}};this.removed=function(off,size){if(this.offset>=0&&this.offset>=off){this.isValid=false;if(this.offset>=(off+size)){this.setOffset(this.offset-size)}else{this.setOffset(off)}}};this.getPointByOffset=function(off){if(off==-1){return[-1,-1]}var m=this.metrics,max=m.getMaxOffset();if(off>max){throw new Error("Out of bounds:"+off)}if(max===0){return[(m.getLines()>0?0:-1),0]}if(off===0){return[0,0]}var d=0,sl=0,so=0;if(this.isValid&&this.offset!=-1){sl=this.currentLine;so=this.offset-this.currentCol;if(off>this.offset){d=1}else{if(off=0;sl+=d){var ls=m.getLineSize(sl);if(off>=so&&off0?ls:-m.getLineSize(sl-1)}return[-1,-1]};this.getOffsetByPoint=function(row,col){var startOffset=0,startLine=0,m=this.metrics;if(row>=m.getLines()||col>=m.getLineSize(row)){throw new Error()}if(this.isValid&&this.offset!=-1){startOffset=this.offset-this.currentCol;startLine=this.currentLine}if(startLine<=row){for(var i=startLine;i=row;i--){startOffset-=m.getLineSize(i)}}return startOffset+col};this.calcMaxOffset=function(){var max=0,m=this.metrics;for(var i=0;i0){this.offset-=this.currentCol;this.currentCol=0;this._.posChanged(this,prevOffset,prevLine,prevCol)}break;case Position.END:var maxCol=this.metrics.getLineSize(this.currentLine);if(this.currentCol<(maxCol-1)){this.offset+=(maxCol-this.currentCol-1);this.currentCol=maxCol-1;this._.posChanged(this,prevOffset,prevLine,prevCol)}break;case Position.UP:if(this.currentLine>0){this.offset-=(this.currentCol+1);this.currentLine--;for(var i=0;this.currentLine>0&&i<(num-1);i++,this.currentLine--){this.offset-=this.metrics.getLineSize(this.currentLine)}var maxCol=this.metrics.getLineSize(this.currentLine);if(this.currentCol0){for(var i=0;i=0){window.clearInterval(this.pid);this.pid=-1}};this.clear=function(l){var c=this.get(l);c.si=c.ri}})();pkg.Bag=zebra.Class([function $prototype(){this.concatArrays=false;this.usePropertySetters=true;this.ignoreNonExistentKeys=false;this.get=function(key){if(key==null){throw new Error("Null key")}var n=key.split("."),v=this.objects;for(var i=0;i1){m.apply(v,nv)}else{m.call(v,nv)}continue}}v[k]=nv}}if(inh!==null){this.inherit(v,inh)}return v};this.resolveClass=function(className){return this.aliases.hasOwnProperty(className)?this.aliases[className]:zebra.Class.forName(className)};this.inherit=function(o,pp){for(var i=0;i0?"&":"?")+(new Date()).getTime().toString();return this.load(zebra.io.GET(p),b)}])})(zebra("util"),zebra.Class,zebra.Interface);(function(pkg,Class){pkg.NONE=0;pkg.LEFT=1;pkg.RIGHT=2;pkg.TOP=4;pkg.BOTTOM=8;pkg.CENTER=16;pkg.HORIZONTAL=32;pkg.VERTICAL=64;pkg.TEMPORARY=128;pkg.USE_PS_SIZE=512;pkg.STRETCH=256;pkg.TLEFT=pkg.LEFT|pkg.TOP;pkg.TRIGHT=pkg.RIGHT|pkg.TOP;pkg.BLEFT=pkg.LEFT|pkg.BOTTOM;pkg.BRIGHT=pkg.RIGHT|pkg.BOTTOM;var $ctrs={};for(var k in pkg){if(pkg.hasOwnProperty(k)&&/^\d+$/.test(pkg[k])){$ctrs[k.toUpperCase()]=pkg[k]}}var $c=pkg.$constraints=function(v){return zebra.isString(v)?$ctrs[v.toUpperCase()]:v};var L=pkg.Layout=new zebra.Interface();pkg.getDirectChild=function(parent,child){for(;child!=null&&child.parent!=parent;child=child.parent){}return child};pkg.getDirectAt=function(x,y,p){for(var i=0;ix&&c.y+c.height>y){return i}}return -1};pkg.getTopParent=function(c){for(;c!=null&&c.parent!=null;c=c.parent){}return c};pkg.getAbsLocation=function(x,y,c){if(arguments.length==1){c=x;x=y=0}while(c.parent!=null){x+=c.x;y+=c.y;c=c.parent}return{x:x,y:y}};pkg.getRelLocation=function(x,y,p,c){while(c!=p){x-=c.x;y-=c.y;c=c.parent}return{x:x,y:y}};pkg.xAlignment=function(aow,alignX,aw){if(alignX==pkg.RIGHT){return aw-aow}if(alignX==pkg.CENTER){return ~~((aw-aow)/2)}if(alignX==pkg.LEFT||alignX==pkg.NONE){return 0}throw new Error("Invalid alignment "+alignX)};pkg.yAlignment=function(aoh,alignY,ah){if(alignY==pkg.BOTTOM){return ah-aoh}if(alignY==pkg.CENTER){return ~~((ah-aoh)/2)}if(alignY==pkg.TOP||alignY==pkg.NONE){return 0}throw new Error("Invalid alignment "+alignY)};pkg.getMaxPreferredSize=function(target){var maxWidth=0,maxHeight=0;for(var i=0;imaxWidth){maxWidth=ps.width}if(ps.height>maxHeight){maxHeight=ps.height}}}return{width:maxWidth,height:maxHeight}};pkg.isAncestorOf=function(p,c){for(;c!=null&&c!=p;c=c.parent){}return c!=null};pkg.Layoutable=Class(L,[function $prototype(){this.x=this.y=this.height=this.width=this.cachedHeight=0;this.psWidth=this.psHeight=this.cachedWidth=-1;this.isLayoutValid=this.isValid=false;this.constraints=this.parent=null;this.isVisible=true;this.find=function(path){var res=null;zebra.util.findInTree(this,path,function(node,name){return node.$clazz.$name==name},function(kid){res=kid;return true});return res};this.findAll=function(path,callback){var res=[];if(callback==null){callback=function(kid){res.push(kid);return false}}zebra.util.findInTree(this,path,function(node,name){return node.$clazz.$name==name},callback);return res};this.validateMetric=function(){if(this.isValid===false){if(this.recalc){this.recalc()}this.isValid=true}};this.invalidateLayout=function(){this.isLayoutValid=false;if(this.parent!=null){this.parent.invalidateLayout()}};this.invalidate=function(){this.isValid=this.isLayoutValid=false;this.cachedWidth=-1;if(this.parent!=null){this.parent.invalidate()}};this.validate=function(){this.validateMetric();if(this.width>0&&this.height>0&&this.isLayoutValid===false&&this.isVisible){this.layout.doLayout(this);for(var i=0;i=0?this.psWidth:ps.width+this.getLeft()+this.getRight();ps.height=this.psHeight>=0?this.psHeight:ps.height+this.getTop()+this.getBottom();this.cachedWidth=ps.width;this.cachedHeight=ps.height;return ps}return{width:this.cachedWidth,height:this.cachedHeight}};this.getTop=function(){return 0};this.getLeft=function(){return 0};this.getBottom=function(){return 0};this.getRight=function(){return 0};this.setParent=function(o){if(o!=this.parent){this.parent=o;this.invalidate()}};this.setLayout=function(m){if(m==null){throw new Error("Null layout")}if(this.layout!=m){var pl=this.layout;this.layout=m;this.invalidate()}};this.calcPreferredSize=function(target){return{width:10,height:10}};this.doLayout=function(target){};this.indexOf=function(c){return this.kids.indexOf(c)};this.insert=function(i,constr,d){if(d.constraints){constr=d.constraints}else{d.constraints=constr}if(i==this.kids.length){this.kids.push(d)}else{this.kids.splice(i,0,d)}d.setParent(this);if(this.kidAdded){this.kidAdded(i,constr,d)}this.invalidate();return d};this.setLocation=function(xx,yy){if(xx!=this.x||this.y!=yy){var px=this.x,py=this.y;this.x=xx;this.y=yy;if(this.relocated){this.relocated(px,py)}}};this.setBounds=function(x,y,w,h){this.setLocation(x,y);this.setSize(w,h)};this.setSize=function(w,h){if(w!=this.width||h!=this.height){var pw=this.width,ph=this.height;this.width=w;this.height=h;this.isLayoutValid=false;if(this.resized){this.resized(pw,ph)}}};this.getByConstraints=function(c){if(this.kids.length>0){for(var i=0;i0){if(arguments.length==1){this.hgap=this.vgap=hgap}else{this.hgap=hgap;this.vgap=vgap}}};this.calcPreferredSize=function(target){var center=null,west=null,east=null,north=null,south=null,d=null;for(var i=0;idim.height?d.height:dim.height)}if(west!=null){d=west.getPreferredSize();dim.width+=d.width+this.hgap;dim.height=d.height>dim.height?d.height:dim.height}if(center!=null){d=center.getPreferredSize();dim.width+=d.width;dim.height=d.height>dim.height?d.height:dim.height}if(north!=null){d=north.getPreferredSize();dim.width=d.width>dim.width?d.width:dim.width;dim.height+=d.height+this.vgap}if(south!=null){d=south.getPreferredSize();dim.width=d.width>dim.width?d.width:dim.width;dim.height+=d.height+this.vgap}return dim};this.doLayout=function(t){var top=t.getTop(),bottom=t.height-t.getBottom(),left=t.getLeft(),right=t.width-t.getRight(),center=null,west=null,east=null;for(var i=0;i0;for(var i=0;im.width){m.width=px}if(py>m.height){m.height=py}}}return m};this.doLayout=function(c){var r=c.width-c.getRight(),b=c.height-c.getBottom(),usePsSize=(this.flag&pkg.USE_PS_SIZE)>0;for(var i=0;i0){ww=r-el.x}if((this.flag&pkg.VERTICAL)>0){hh=b-el.y}el.setSize(ww,hh);if(el.constraints){var x=el.x,y=el.y;if(el.constraints==pkg.CENTER){x=(c.width-ww)/2;y=(c.height-hh)/2}else{if((el.constraints&pkg.TOP)>0){y=0}else{if((el.constraints&pkg.BOTTOM)>0){y=c.height-hh}}if((el.constraints&pkg.LEFT)>0){x=0}else{if((el.constraints&pkg.RIGHT)>0){x=c.width-ww}}}el.setLocation(x,y)}}}};this[""]=function(f){this.flag=f?f:0}}]);pkg.FlowLayout=Class(L,[function $prototype(){this.gap=0;this.ax=pkg.LEFT;this.ay=pkg.TOP;this.direction=pkg.HORIZONTAL;this[""]=function(ax,ay,dir,g){if(arguments.length==1){this.gap=ax}else{if(arguments.length>=2){this.ax=pkg.$constraints(ax);this.ay=pkg.$constraints(ay)}if(arguments.length>2){dir=pkg.$constraints(dir);if(dir!=pkg.HORIZONTAL&&dir!=pkg.VERTICAL){throw new Error("Invalid direction "+dir)}this.direction=dir}if(arguments.length>3){this.gap=g}}};this.calcPreferredSize=function(c){var m={width:0,height:0},cc=0;for(var i=0;im.height?d.height:m.height}else{m.width=d.width>m.width?d.width:m.width;m.height+=d.height}cc++}}var add=this.gap*(cc>0?cc-1:0);if(this.direction==pkg.HORIZONTAL){m.width+=add}else{m.height+=add}return m};this.doLayout=function(c){var psSize=this.calcPreferredSize(c),t=c.getTop(),l=c.getLeft(),lastOne=null,px=pkg.xAlignment(psSize.width,this.ax,c.width-l-c.getRight())+l,py=pkg.yAlignment(psSize.height,this.ay,c.height-t-c.getBottom())+t;for(var i=0;i0?this.gap:0));c++;if(wmax){max=d.height}as+=d.width}else{if(d.width>max){max=d.width}as+=d.height}}return(this.direction==pkg.HORIZONTAL)?{width:as,height:max}:{width:max,height:as}}}]);pkg.Constraints=Class([function $prototype(){this.top=this.bottom=this.left=this.right=0;this.ay=this.ax=pkg.STRETCH;this.rowSpan=this.colSpan=1;this[""]=function(ax,ay){if(arguments.length>0){this.ax=ax;if(arguments.length>1){this.ay=ay}}};this.setPadding=function(p){this.top=this.bottom=this.left=this.right=p};this.setPaddings=function(t,l,b,r){this.top=t;this.bottom=b;this.left=l;this.right=r}}]);pkg.GridLayout=Class(L,[function(r,c){this.$this(r,c,0)},function(r,c,m){this.rows=r;this.cols=c;this.mask=m;this.colSizes=Array(c+1);this.rowSizes=Array(r+1)},function $prototype(){var DEF_CONSTR=new pkg.Constraints();this.getSizes=function(c,isRow){var max=isRow?this.rows:this.cols,res=isRow?this.rowSizes:this.colSizes;res[max]=0;for(var i=0;imax?d:max)}}return max};this.calcColSize=function(col,c){var max=0,r=0,i=0;while((i=zebra.util.indexByPoint(r,col,this.cols))max?d:max)}r++}return max};this.calcPreferredSize=function(c){return{width:this.getSizes(c,false)[this.cols],height:this.getSizes(c,true)[this.rows]}};this.doLayout=function(c){var rows=this.rows,cols=this.cols,colSizes=this.getSizes(c,false),rowSizes=this.getSizes(c,true),top=c.getTop(),left=c.getLeft();if((this.mask&pkg.HORIZONTAL)>0){var dw=c.width-left-c.getRight()-colSizes[cols];for(var i=0;i0){var dh=c.height-top-c.getBottom()-rowSizes[rows];for(var i=0;ie.touches.length){return}if(this.timer==null){var $this=this;this.timer=setTimeout(function(){$this.Q();$this.timer=null},25)}var t=e.touches;for(var i=0;i1){for(var i=0;i0){for(var i=0;i0&&t.dx>0),dys=(dy<0&&t.dy<0)||(dy>0&&t.dy>0);t.pageX=nmt.pageX;t.pageY=nmt.pageY;if($abs(dx)>2||$abs(dy)>2){gamma=$atan2(dy,dx);if(gamma>-PI4){d=(gamma-PI4_3)?L.TOP:L.LEFT}if(t.direction!=d){if(t.dc<3){t.direction=d}t.dc=0}else{t.dc++}t.gamma=gamma}if($this.timer==null){t.dx=dx;t.dy=dy;$this.moved(t)}else{$this.dc=0}}}}e.preventDefault()},false)}}])})(zebra("ui"),zebra.Class);(function(pkg,Class,Interface){var instanceOf=zebra.instanceOf,L=zebra.layout,MB=zebra.util,$configurators=[],rgb=zebra.util.rgb,temporary={x:0,y:0,width:0,height:0},MS=Math.sin,MC=Math.cos,$fmCanvas=null,$fmText=null,$fmImage=null,$clipboard=null,$clipboardCanvas,$canvases=[],$ratio=typeof window.devicePixelRatio!=="undefined"?window.devicePixelRatio:(typeof window.screen.deviceXDPI!=="undefined"?window.screen.deviceXDPI/window.screen.logicalXDPI:1);pkg.clipboardTriggerKey=0;function $meX(e,d){return d.$context.tX(e.pageX-d.offx,e.pageY-d.offy)}function $meY(e,d){return d.$context.tY(e.pageX-d.offx,e.pageY-d.offy)}function elBoundsUpdated(){for(var i=$canvases.length-1;i>=0;i--){var c=$canvases[i];if(c.isFullScreen){c.setLocation(0,0);c.setSize(window.innerWidth,window.innerHeight)}c.recalcOffset()}}pkg.$view=function(v){if(v==null){return null}if(v.paint){return v}if(zebra.isString(v)){return rgb.hasOwnProperty(v)?rgb[v]:(pkg.borders&&pkg.borders.hasOwnProperty(v)?pkg.borders[v]:new rgb(v))}if(Array.isArray(v)){return new pkg.CompositeView(v)}if(typeof v!=="function"){return new pkg.ViewSet(v)}v=new pkg.View();v.paint=f;return v};pkg.$detectZCanvas=function(canvas){if(zebra.isString(canvas)){canvas=document.getElementById(canvas)}for(var i=0;canvas!=null&&i<$canvases.length;i++){if($canvases[i].canvas==canvas){return $canvases[i]}}return null};pkg.View=Class([function $prototype(){this.gap=2;this.getRight=this.getLeft=this.getBottom=this.getTop=function(){return this.gap};this.getPreferredSize=function(){return{width:0,height:0}};this.paint=function(g,x,y,w,h,c){}}]);pkg.Render=Class(pkg.View,[function $prototype(){this[""]=function(target){this.setTarget(target)};this.setTarget=function(o){if(this.target!=o){var old=this.target;this.target=o;if(this.targetWasChanged){this.targetWasChanged(old,o)}}}}]);pkg.Raised=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor)},function(brightest,middle){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.brightest);g.drawLine(x1,y1,x2,y1);g.drawLine(x1,y1,x1,y2);g.setColor(this.middle);g.drawLine(x2,y1,x2,y2+1);g.drawLine(x1,y2,x2,y2)}}]);pkg.Sunken=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor,pkg.darkBrColor)},function(brightest,middle,darkest){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle;this.darkest=darkest==null?"black":darkest},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.middle);g.drawLine(x1,y1,x2-1,y1);g.drawLine(x1,y1,x1,y2-1);g.setColor(this.brightest);g.drawLine(x2,y1,x2,y2+1);g.drawLine(x1,y2,x2,y2);g.setColor(this.darkest);g.drawLine(x1+1,y1+1,x1+1,y2);g.drawLine(x1+1,y1+1,x2,y1+1)}}]);pkg.Etched=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor)},function(brightest,middle){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.middle);g.drawLine(x1,y1,x1,y2-1);g.drawLine(x2-1,y1,x2-1,y2);g.drawLine(x1,y1,x2,y1);g.drawLine(x1,y2-1,x2-1,y2-1);g.setColor(this.brightest);g.drawLine(x2,y1,x2,y2);g.drawLine(x1+1,y1+1,x1+1,y2-1);g.drawLine(x1+1,y1+1,x2-1,y1+1);g.drawLine(x1,y2,x2+1,y2)}}]);pkg.Dotted=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){g.setColor(this.color);g.drawDottedRect(x,y,w,h)};this[""]=function(c){this.color=(c==null)?"black":c}}]);pkg.Border=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.color==null){return}var ps=g.lineWidth;g.lineWidth=this.width;if(this.radius>0){this.outline(g,x,y,w,h,d)}else{var dt=this.width/2;g.beginPath();g.rect(x+dt,y+dt,w-this.width,h-this.width)}g.setColor(this.color);g.stroke();g.lineWidth=ps};this.outline=function(g,x,y,w,h,d){if(this.radius<=0){return false}var r=this.radius,dt=this.width/2,xx=x+w-dt,yy=y+h-dt;x+=dt;y+=dt;g.beginPath();g.moveTo(x-1+r,y);g.lineTo(xx-r,y);g.quadraticCurveTo(xx,y,xx,y+r);g.lineTo(xx,yy-r);g.quadraticCurveTo(xx,yy,xx-r,yy);g.lineTo(x+r,yy);g.quadraticCurveTo(x,yy,x,yy-r);g.lineTo(x,y+r);g.quadraticCurveTo(x,y,x+r,y);return true};this[""]=function(c,w,r){this.color=(arguments.length===0)?"gray":c;this.width=(w==null)?1:w;this.radius=(r==null)?0:r;this.gap=this.width+Math.round(this.radius/4)}}]);pkg.RoundBorder=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.color!=null&&this.width>0){this.outline(g,x,y,w,h,d);g.setColor(this.color);g.stroke()}};this.outline=function(g,x,y,w,h,d){g.beginPath();g.lineWidth=this.width;g.arc(x+w/2,y+h/2,w/2,0,2*Math.PI,false);return true};this[""]=function(col,width){this.color=null;this.width=1;if(arguments.length>0){if(zebra.isNumber(col)){this.width=col}else{this.color=col;if(zebra.isNumber(width)){this.width=width}}}this.gap=this.width}}]);pkg.Gradient=Class(pkg.View,[function $prototype(){this[""]=function(){this.colors=Array.prototype.slice.call(arguments,0);if(zebra.isNumber(arguments[arguments.length-1])){this.orientation=arguments[arguments.length-1];this.colors.pop()}else{this.orientation=L.VERTICAL}};this.paint=function(g,x,y,w,h,dd){var d=(this.orientation==L.HORIZONTAL?[0,1]:[1,0]),x1=x*d[1],y1=y*d[0],x2=(x+w-1)*d[1],y2=(y+h-1)*d[0];if(this.gradient==null||this.gx1!=x1||this.gx2!=x2||this.gy1!=y1||this.gy2!=y2){this.gx1=x1;this.gx2=x2;this.gy1=y1;this.gy2=y2;this.gradient=g.createLinearGradient(x1,y1,x2,y2);for(var i=0;i4){this.x=x;this.y=y;this.width=w;this.height=h}else{this.x=this.y=this.width=this.height=0}if(zebra.isBoolean(arguments[arguments.length-1])===false){ub=w>0&&h>0&&w<64&&h<64}if(ub===true){this.buffer=document.createElement("canvas");this.buffer.width=0}};this.paint=function(g,x,y,w,h,d){if(this.target!=null&&w>0&&h>0){var img=this.target;if(this.buffer){img=this.buffer;if(img.width<=0){var ctx=img.getContext("2d");if(this.width>0){img.width=this.width;img.height=this.height;ctx.drawImage(this.target,this.x,this.y,this.width,this.height,0,0,this.width,this.height)}else{img.width=this.target.width;img.height=this.target.height;ctx.drawImage(this.target,0,0)}}}if(this.width>0&&!this.buffer){g.drawImage(img,this.x,this.y,this.width,this.height,x,y,w,h)}else{g.drawImage(img,x,y,w,h)}}};this.targetWasChanged=function(o,n){if(this.buffer){delete this.buffer}};this.getPreferredSize=function(){var img=this.target;return img==null?{width:0,height:0}:(this.width>0)?{width:this.width,height:this.height}:{width:img.width,height:img.height}}}]);pkg.Pattern=Class(pkg.Render,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.pattern==null){this.pattern=g.createPattern(this.target,"repeat")}g.rect(x,y,w,h);g.fillStyle=this.pattern;g.fill()}}]);pkg.CompositeView=Class(pkg.View,[function $prototype(){this.left=this.right=this.bottom=this.top=this.height=this.width=0;this.getTop=function(){return this.top};this.getLeft=function(){return this.left};this.getBottom=function(){return this.bottom};this.getRight=function(){return this.right};this.getPreferredSize=function(){return{width:this.width,height:this.height}};this.$recalc=function(v){var b=0,ps=v.getPreferredSize();if(v.getLeft){b=v.getLeft();if(b>this.left){this.left=b}}if(v.getRight){b=v.getRight();if(b>this.right){this.right=b}}if(v.getTop){b=v.getTop();if(b>this.top){this.top=b}}if(v.getBottom){b=v.getBottom();if(b>this.bottom){this.bottom=b}}if(ps.width>this.width){this.width=ps.width}if(ps.height>this.height){this.height=ps.height}if(this.voutline==null&&v.outline){this.voutline=v}};this.paint=function(g,x,y,w,h,d){for(var i=0;i1&&id[0]!="*"&&id[id.length-1]!="*"){var i=id.indexOf(".");if(i>0){var k=id.substring(0,i+1).concat("*");if(this.views.hasOwnProperty(k)){return(this.activeView=this.views[k])!=old}else{k="*"+id.substring(i);if(this.views.hasOwnProperty(k)){return(this.activeView=this.views[k])!=old}}}}}if(this.views.hasOwnProperty("*")){return(this.activeView=this.views["*"])!=old}return false};this[""]=function(args){if(args==null){throw new Error("Invalid null view set")}this.views={};this.activeView=null;for(var k in args){this.views[k]=pkg.$view(args[k]);if(this.views[k]){this.$recalc(this.views[k])}}this.activate("*")}}]);pkg.Bag=Class(zebra.util.Bag,[function $prototype(){this.usePropertySetters=true;this.contentLoaded=function(v){if(v==null||zebra.isNumber(v)||zebra.isBoolean(v)){return v}if(zebra.isString(v)){if(this.root&&v[0]=="%"&&v[1]=="r"){var s="%root%/";if(v.indexOf(s)===0){return this.root.join(v.substring(s.length))}}return v}if(Array.isArray(v)){for(var i=0;i0&&c.height>0&&c.isVisible){var p=c.parent,px=-c.x,py=-c.y;if(r==null){r={x:0,y:0,width:0,height:0}}else{r.x=r.y=0}r.width=c.width;r.height=c.height;while(p!=null&&r.width>0&&r.height>0){var xx=r.x>px?r.x:px,yy=r.y>py?r.y:py,w1=r.x+r.width,w2=px+p.width,h1=r.y+r.height,h2=py+p.height;r.width=(w10&&r.height>0?r:null}return null};pkg.configure=function(c){if(zebra.isString(c)){var path=c;c=function(conf){conf.loadByUrl(path,false)}}$configurators.push(c)};pkg.Font=function(name,style,size){if(arguments.length==1){name=name.replace(/[ ]+/," ");this.s=name.trim()}else{if(arguments.length==2){size=style;style=""}style=style.trim();this.s=[style,(style!==""?" ":""),size,"px ",name].join("")}$fmText.style.font=this.s;this.height=$fmText.offsetHeight;if(this.height===0){this.height=$fmText.offsetHeight}this.ascent=$fmImage.offsetTop-$fmText.offsetTop+1};pkg.Font.prototype.stringWidth=function(s){if(s.length===0){return 0}if($fmCanvas.font!=this.s){$fmCanvas.font=this.s}return($fmCanvas.measureText(s).width+0.5)|0};pkg.Font.prototype.charsWidth=function(s,off,len){if($fmCanvas.font!=this.s){$fmCanvas.font=this.s}return($fmCanvas.measureText(len==1?s[off]:s.substring(off,off+len)).width+0.5)|0};pkg.Font.prototype.toString=function(){return this.s};pkg.Cursor={DEFAULT:"default",MOVE:"move",WAIT:"wait",TEXT:"text",HAND:"pointer",NE_RESIZE:"ne-resize",SW_RESIZE:"sw-resize",SE_RESIZE:"se-resize",NW_RESIZE:"nw-resize",S_RESIZE:"s-resize",W_RESIZE:"w-resize",N_RESIZE:"n-resize",E_RESIZE:"e-resize",COL_RESIZE:"col-resize",HELP:"help"};var MouseListener=pkg.MouseListener=Interface(),FocusListener=pkg.FocusListener=Interface(),KeyListener=pkg.KeyListener=Interface(),Composite=pkg.Composite=Interface(),ChildrenListener=pkg.ChildrenListener=Interface(),CopyCutPaste=pkg.CopyCutPaste=Interface(),CL=pkg.ComponentListener=Interface();CL.ENABLED=1;CL.SHOWN=2;CL.MOVED=3;CL.SIZED=4;CL.ADDED=5;CL.REMOVED=6;var IE=pkg.InputEvent=Class([function $clazz(){this.MOUSE_UID=1;this.KEY_UID=2;this.FOCUS_UID=3;this.FOCUS_LOST=10;this.FOCUS_GAINED=11},function(target,id,uid){this.source=target;this.ID=id;this.UID=uid}]);var KE=pkg.KeyEvent=Class(IE,[function $clazz(){this.TYPED=15;this.RELEASED=16;this.PRESSED=17;this.M_CTRL=1;this.M_SHIFT=2;this.M_ALT=4;this.M_CMD=8},function $prototype(){this.reset=function(target,id,code,ch,mask){this.source=target;this.ID=id;this.code=code;this.mask=mask;this.ch=ch};this.isControlPressed=function(){return(this.mask&KE.M_CTRL)>0};this.isShiftPressed=function(){return(this.mask&KE.M_SHIFT)>0};this.isAltPressed=function(){return(this.mask&KE.M_ALT)>0};this.isCmdPressed=function(){return(this.mask&KE.M_CMD)>0}},function(target,id,code,ch,mask){this.$super(target,id,IE.KEY_UID);this.reset(target,id,code,ch,mask)}]);var ME=pkg.MouseEvent=Class(IE,[function $clazz(){this.CLICKED=21;this.PRESSED=22;this.RELEASED=23;this.ENTERED=24;this.EXITED=25;this.DRAGGED=26;this.DRAGSTARTED=27;this.DRAGENDED=28;this.MOVED=29;this.LEFT_BUTTON=128;this.RIGHT_BUTTON=512},function $prototype(){this.touchCounter=1;this.reset=function(target,id,ax,ay,mask,clicks){this.source=target;this.ID=id;this.absX=ax;this.absY=ay;this.mask=mask;this.clicks=clicks;var p=L.getTopParent(target);while(target!=p){ax-=target.x;ay-=target.y;target=target.parent}this.x=ax;this.y=ay};this.isActionMask=function(){return this.mask==ME.LEFT_BUTTON}},function(target,id,ax,ay,mask,clicks){this.$super(target,id,IE.MOUSE_UID);this.reset(target,id,ax,ay,mask,clicks)}]);var MDRAGGED=ME.DRAGGED,EM=null,MMOVED=ME.MOVED,MEXITED=ME.EXITED,KPRESSED=KE.PRESSED,MENTERED=ME.ENTERED,context=Object.getPrototypeOf(document.createElement("canvas").getContext("2d")),$mousePressedEvents={},$keyPressedCode=-1,$keyPressedOwner=null,$keyPressedModifiers=0,KE_STUB=new KE(null,KPRESSED,0,"x",0),ME_STUB=new ME(null,ME.PRESSED,0,0,0,1);pkg.paintManager=pkg.events=pkg.$mouseMoveOwner=null;document.addEventListener("mouseup",function(e){for(var k in $mousePressedEvents){var mp=$mousePressedEvents[k];if(mp.canvas!=null){mp.canvas.mouseReleased(k,mp)}}},false);var $alert=(function(){return this.alert}());window.alert=function(){if($keyPressedCode>0){KE_STUB.reset($keyPressedOwner,KE.RELEASED,$keyPressedCode,"",$keyPressedModifiers);EM.performInput(KE_STUB);$keyPressedCode=-1}$alert.apply(window,arguments);for(var k in $mousePressedEvents){var mp=$mousePressedEvents[k];if(mp.canvas!=null){mp.canvas.mouseReleased(k,mp)}}};context.setFont=function(f){f=(f.s!=null?f.s:f.toString());if(f!=this.font){this.font=f}};context.setColor=function(c){if(c==null){throw new Error("Null color")}c=(c.s?c.s:c.toString());if(c!=this.fillStyle){this.fillStyle=c}if(c!=this.strokeStyle){this.strokeStyle=c}};context.drawLine=function(x1,y1,x2,y2,w){if(arguments.length<5){w=1}var pw=this.lineWidth;this.beginPath();this.lineWidth=w;if(x1==x2){x1+=w/2;x2=x1}else{if(y1==y2){y1+=w/2;y2=y1}}this.moveTo(x1,y1);this.lineTo(x2,y2);this.stroke();this.lineWidth=pw};context.ovalPath=function(x,y,w,h){this.beginPath();x+=this.lineWidth;y+=this.lineWidth;w-=2*this.lineWidth;h-=2*this.lineWidth;var kappa=0.5522848,ox=(w/2)*kappa,oy=(h/2)*kappa,xe=x+w,ye=y+h,xm=x+w/2,ym=y+h/2;this.moveTo(x,ym);this.bezierCurveTo(x,ym-oy,xm-ox,y,xm,y);this.bezierCurveTo(xm+ox,y,xe,ym-oy,xe,ym);this.bezierCurveTo(xe,ym+oy,xm+ox,ye,xm,ye);this.bezierCurveTo(xm-ox,ye,x,ym+oy,x,ym)};context.polylinePath=function(xPoints,yPoints,nPoints){this.beginPath();this.moveTo(xPoints[0],yPoints[0]);for(var i=1;iMath.abs(dy)),slope=b?dy/dx:dx/dy,sign=b?(dx<0?-1:1):(dy<0?-1:1);if(b){compute=function(step){x+=step;y+=slope*step}}else{compute=function(step){x+=slope*step;y+=step}}ctx.moveTo(x,y);var dist=Math.sqrt(dx*dx+dy*dy),i=0;while(dist>=0.1){var idx=i%count;dl=distd.width-right){xx=d.width+right-ww}if(yy+hh>d.height-bottom){yy=d.height+bottom-hh}c.setLocation(xx,yy)};pkg.calcOrigin=function(x,y,w,h,px,py,t,tt,ll,bb,rr){if(arguments.length<8){tt=t.getTop();ll=t.getLeft();bb=t.getBottom();rr=t.getRight()}var dw=t.width,dh=t.height;if(dw>0&&dh>0){if(dw-ll-rr>w){var xx=x+px;if(xxdw-rr){px-=(xx-dw+rr)}}}if(dh-tt-bb>h){var yy=y+py;if(yydh-bb){py-=(yy-dh+bb)}}}return[px,py]}return[0,0]};pkg.loadImage=function(path,ready){var i=new Image();i.crossOrigin="";i.crossOrigin="anonymous";zebra.busy();if(arguments.length>1){i.onerror=function(){zebra.ready();ready(path,false,i)};i.onload=function(){zebra.ready();ready(path,true,i)}}else{i.onload=i.onerror=function(){zebra.ready()}}i.src=path;return i};pkg.Panel=Class(L.Layoutable,[function $prototype(){this.top=this.left=this.right=this.bottom=0;this.isEnabled=true;this.getCanvas=function(){var c=this;for(;c!=null&&c.$isMasterCanvas!==true;c=c.parent){}return c};this.notifyRender=function(o,n){if(o!=null&&o.ownerChanged){o.ownerChanged(null)}if(n!=null&&n.ownerChanged){n.ownerChanged(this)}};this.properties=function(p){for(var k in p){if(p.hasOwnProperty(k)){var v=p[k],m=zebra.getPropertySetter(this,k);if(v&&v.$new){v=v.$new()}if(m==null){this[k]=v}else{if(Array.isArray(v)){m.apply(this,v)}else{m.call(this,v)}}}}return this};this.load=function(jsonPath){new pkg.Bag(this).loadByUrl(jsonPath);return this};this.getComponentAt=function(x,y){var r=$cvp(this,temporary);if(r==null||(x=r.x+r.width||y>=r.y+r.height)){return null}var k=this.kids;if(k.length>0){for(var i=k.length;--i>=0;){var d=k[i];d=d.getComponentAt(x-d.x,y-d.y);if(d!=null){return d}}}return this.contains==null||this.contains(x,y)?this:null};this.vrp=function(){this.invalidate();if(this.isVisible&&this.parent!=null){this.repaint()}};this.getTop=function(){return this.border!=null?this.top+this.border.getTop():this.top};this.getLeft=function(){return this.border!=null?this.left+this.border.getLeft():this.left};this.getBottom=function(){return this.border!=null?this.bottom+this.border.getBottom():this.bottom};this.getRight=function(){return this.border!=null?this.right+this.border.getRight():this.right};this.isInvalidatedByChild=function(c){return true};this.kidAdded=function(index,constr,l){pkg.events.performComp(CL.ADDED,this,constr,l);if(l.width>0&&l.height>0){l.repaint()}else{this.repaint(l.x,l.y,1,1)}};this.kidRemoved=function(i,l){pkg.events.performComp(CL.REMOVED,this,null,l);if(l.isVisible){this.repaint(l.x,l.y,l.width,l.height)}};this.relocated=function(px,py){pkg.events.performComp(CL.MOVED,this,px,py);var p=this.parent,w=this.width,h=this.height;if(p!=null&&w>0&&h>0){var x=this.x,y=this.y,nx=xpx?x-px:px-x),h1=p.height-ny,h2=h+(y>py?y-py:py-y);pkg.paintManager.repaint(p,nx,ny,(w1pw)?this.width:pw,(this.height>ph)?this.height:ph)}};this.hasFocus=function(){return pkg.focusManager.hasFocus(this)};this.requestFocus=function(){pkg.focusManager.requestFocus(this)};this.requestFocusIn=function(timeout){if(arguments.length===0){timeout=50}var $this=this;setTimeout(function(){$this.requestFocus()},timeout)};this.setVisible=function(b){if(this.isVisible!=b){this.isVisible=b;this.invalidate();pkg.events.performComp(CL.SHOWN,this,-1,-1);if(this.parent!=null){if(b){this.repaint()}else{this.parent.repaint(this.x,this.y,this.width,this.height)}}}};this.setEnabled=function(b){if(this.isEnabled!=b){this.isEnabled=b;pkg.events.performComp(CL.ENABLED,this,-1,-1);if(this.kids.length>0){for(var i=0;i1){for(var i=0;i0&&this.height>0&&pkg.paintManager!=null){pkg.paintManager.repaint(this,x,y,w,h)}};this.removeAll=function(){if(this.kids.length>0){var size=this.kids.length,mx1=Number.MAX_VALUE,my1=mx1,mx2=0,my2=0;for(;size>0;size--){var child=this.kids[size-1];if(child.isVisible){var xx=child.x,yy=child.y;mx1=mx10){if(instanceOf(l,L.Layout)){this.setLayout(l)}else{this.properties(l)}}}}]);pkg.BaseLayer=Class(pkg.Panel,[function $prototype(){this.getFocusRoot=function(){return this};this.activate=function(b){var fo=pkg.focusManager.focusOwner;if(L.isAncestorOf(this,fo)===false){fo=null}if(b){pkg.focusManager.requestFocus(fo!=null?fo:this.pfo)}else{this.pfo=fo;pkg.focusManager.requestFocus(null)}}},function(id){if(id==null){throw new Error("Invalid layer id: "+id)}this.pfo=null;this.$super();this.id=id}]);pkg.RootLayer=Class(pkg.BaseLayer,[function $prototype(){this.layerMousePressed=function(x,y,m){return true};this.layerKeyPressed=function(code,m){return true}}]);pkg.ViewPan=Class(pkg.Panel,[function $prototype(){this.paint=function(g){if(this.view!=null){var l=this.getLeft(),t=this.getTop();this.view.paint(g,l,t,this.width-l-this.getRight(),this.height-t-this.getBottom(),this)}};this.setView=function(v){var old=this.view;v=pkg.$view(v);if(v!=old){this.view=v;this.notifyRender(old,v);this.vrp()}};this.calcPreferredSize=function(t){return this.view?this.view.getPreferredSize():{width:0,height:0}}}]);pkg.ImagePan=Class(pkg.ViewPan,[function(){this.$this(null)},function(img){this.setImage(img);this.$super()},function setImage(img){if(img&&zebra.isString(img)){var $this=this;pkg.loadImage(img,function(p,b,i){if(b){$this.setView(new pkg.Picture(i))}});return}this.setView(instanceOf(img,pkg.Picture)?img:new pkg.Picture(img))}]);pkg.Manager=Class([function(){if(pkg.events!=null&&pkg.events.addListener!=null){pkg.events.addListener(this)}}]);pkg.PaintManager=Class(pkg.Manager,[function $prototype(){var $timers={};this.repaint=function(c,x,y,w,h){if(arguments.length==1){x=y=0;w=c.width;h=c.height}if(w>0&&h>0&&c.isVisible===true){var r=$cvp(c,temporary);if(r==null){return}MB.intersection(r.x,r.y,r.width,r.height,x,y,w,h,r);if(r.width<=0||r.height<=0){return}x=r.x;y=r.y;w=r.width;h=r.height;var canvas=c;for(;canvas!=null&&canvas.$context==null;canvas=canvas.parent){}if(canvas!=null){var x2=canvas.width,y2=canvas.height;var cc=c;while(cc!=canvas){x+=cc.x;y+=cc.y;cc=cc.parent}if(x<0){w+=x;x=0}if(y<0){h+=y;y=0}if(w+x>x2){w=x2-x}if(h+y>y2){h=y2-y}if(w>0&&h>0){var da=canvas.$da;if(da.width>0){if(x>=da.x&&y>=da.y&&x+w<=da.x+da.width&&y+h<=da.y+da.height){return}MB.unite(da.x,da.y,da.width,da.height,x,y,w,h,da)}else{MB.intersection(0,0,canvas.width,canvas.height,x,y,w,h,da)}if(da.width>0&&$timers[canvas]==null){var $this=this;$timers[canvas]=setTimeout(function(){$timers[canvas]=null;if(canvas.$da.width<=0){return}var context=canvas.$context;try{canvas.validate();context.save();context.translate(canvas.x,canvas.y);context.clipRect(canvas.$da.x,canvas.$da.y,canvas.$da.width,canvas.$da.height);if(canvas.bg==null){context.clearRect(canvas.$da.x,canvas.$da.y,canvas.$da.width,canvas.$da.height)}$this.paint(context,canvas);context.restore();canvas.$da.width=-1}catch(e){zebra.print(e)}},50)}}}}};this.paint=function(g,c){var dw=c.width,dh=c.height,ts=g.stack[g.counter];if(dw!==0&&dh!==0&&ts.width>0&&ts.height>0&&c.isVisible){c.validate();g.save();g.translate(c.x,c.y);g.clipRect(0,0,dw,dh);ts=g.stack[g.counter];var c_w=ts.width,c_h=ts.height;if(c_w>0&&c_h>0){this.paintComponent(g,c);var count=c.kids.length,c_x=ts.x,c_y=ts.y;for(var i=0;ic_x?kidX:c_x),ih=(kidYHc_y?kidY:c_y);if(iw>0&&ih>0){this.paint(g,kid)}}}if(c.paintOnTop!=null){c.paintOnTop(g)}}g.restore()}}}]);pkg.PaintManImpl=Class(pkg.PaintManager,[function $prototype(){this.paintComponent=function(g,c){var b=c.bg!=null&&(c.parent==null||c.bg!=c.parent.bg);if((c.border!=null&&c.border.outline!=null)&&(b||c.update!=null)&&c.border.outline(g,0,0,c.width,c.height,c)){g.save();g.clip();if(b){c.bg.paint(g,0,0,c.width,c.height,c)}if(c.update!=null){c.update(g)}g.restore()}else{if(b){c.bg.paint(g,0,0,c.width,c.height,c)}if(c.update!=null){c.update(g)}}if(c.border!=null){c.border.paint(g,0,0,c.width,c.height,c)}if(c.paint!=null){var left=c.getLeft(),top=c.getTop(),bottom=c.getBottom(),right=c.getRight();if(left+right+top+bottom>0){var ts=g.stack[g.counter];if(ts.width>0&&ts.height>0){var cx=ts.x,cy=ts.y,x1=(cx>left?cx:left),y1=(cy>top?cy:top),cxcw=cx+ts.width,cych=cy+ts.height,cright=c.width-right,cbottom=c.height-bottom;g.save();g.clipRect(x1,y1,(cxcw0){var isNComposite=(instanceOf(t,Composite)===false);for(var i=index;i>=0&&i0&&cc.height>0&&(isNComposite||(t.catchInput&&t.catchInput(cc)===false))&&((cc.canHaveFocus&&cc.canHaveFocus())||(cc=this.fd(cc,d>0?0:cc.kids.length-1,d))!=null)){return cc}}}return null};this.ff=function(c,d){var top=c;while(top&&top.getFocusRoot==null){top=top.parent}top=top.getFocusRoot();for(var index=(d>0)?0:c.kids.length-1;c!=top.parent;){var cc=this.fd(c,index,d);if(cc!=null){return cc}cc=c;c=c.parent;if(c!=null){index=d+c.indexOf(cc)}}return this.fd(top,d>0?0:top.kids.length-1,d)};this.requestFocus=function(c){if(c!=this.focusOwner&&(c==null||this.isFocusable(c))){if(c!=null){var canvas=c.getCanvas();if(canvas.$focusGainedCounter===0){canvas.$prevFocusOwner=c;if(zebra.instanceOf(canvas.$prevFocusOwner,pkg.HtmlElement)==false){canvas.requestFocus();return}}}var oldFocusOwner=this.focusOwner;if(c!=null){var nf=EM.getEventDestination(c);if(nf==null||oldFocusOwner==nf){return}this.focusOwner=nf}else{this.focusOwner=c}if(oldFocusOwner!=null){var ofc=oldFocusOwner.getCanvas();if(ofc!=null){ofc.$prevFocusOwner=oldFocusOwner}}if(oldFocusOwner!=null){pkg.events.performInput(new IE(oldFocusOwner,IE.FOCUS_LOST,IE.FOCUS_UID))}if(this.focusOwner!=null){pkg.events.performInput(new IE(this.focusOwner,IE.FOCUS_GAINED,IE.FOCUS_UID))}return this.focusOwner}return null};this.mousePressed=function(e){if(e.isActionMask()){this.requestFocus(e.source)}}}]);pkg.CommandManager=Class(pkg.Manager,KeyListener,[function $prototype(){this.keyPressed=function(e){var fo=pkg.focusManager.focusOwner;if(fo!=null&&this.keyCommands[e.code]){var c=this.keyCommands[e.code];if(c&&c[e.mask]!=null){c=c[e.mask];this._.fired(c);if(fo[c.command]){if(c.args&&c.args.length>0){fo[c.command].apply(fo,c.args)}else{fo[c.command]()}}}}};this.parseKey=function(k){var m=0,c=0,r=k.split("+");for(var i=0;i25){for(var i=0;i=0)||c.push(l)};this.r_=function(c,l){(c.indexOf(l)<0)||c.splice(i,1)}},function(){this.m_l=[];this.k_l=[];this.f_l=[];this.c_l=[];this.$super()}]);pkg.$createContext=function(canvas,w,h){var ctx=canvas.getContext("2d");var $save=ctx.save,$restore=ctx.restore,$rotate=ctx.rotate,$scale=ctx.$scale=ctx.scale,$translate=ctx.translate,$getImageData=ctx.getImageData;ctx.$ratio=$ratio/(ctx.webkitBackingStorePixelRatio||ctx.mozBackingStorePixelRatio||ctx.msBackingStorePixelRatio||ctx.backingStorePixelRatio||1);ctx.counter=0;ctx.stack=Array(50);for(var i=0;ixx?x:xx;c.width=(xwyy?y:yy;c.height=(yh0){var fo=pkg.focusManager.focusOwner;if(fo!=null){KE_STUB.reset(fo,KE.TYPED,e.keyCode,String.fromCharCode(e.charCode),km(e));if(EM.performInput(KE_STUB)){e.preventDefault()}}}if(e.keyCode<47){e.preventDefault()}};this.keyPressed=function(e){$keyPressedCode=e.keyCode;var code=e.keyCode,m=km(e),b=false;for(var i=this.kids.length-1;i>=0;i--){var l=this.kids[i];if(l.layerKeyPressed&&l.layerKeyPressed(code,m)){break}}var focusOwner=pkg.focusManager.focusOwner;if(pkg.clipboardTriggerKey>0&&e.keyCode==pkg.clipboardTriggerKey&&focusOwner!=null&&instanceOf(focusOwner,CopyCutPaste)){$clipboardCanvas=this;$clipboard.style.display="block";this.canvas.onfocus=this.canvas.onblur=null;$clipboard.value="1";$clipboard.select();$clipboard.focus();return}$keyPressedOwner=focusOwner;$keyPressedModifiers=m;if(focusOwner!=null){KE_STUB.reset(focusOwner,KPRESSED,code,code<47?KE.CHAR_UNDEFINED:"?",m);b=EM.performInput(KE_STUB);if(code==KE.ENTER){KE_STUB.reset(focusOwner,KE.TYPED,code,"\n",m);b=EM.performInput(KE_STUB)||b}}if((code<47&&code!=32)||b){e.preventDefault()}};this.keyReleased=function(e){$keyPressedCode=-1;var fo=pkg.focusManager.focusOwner;if(fo!=null){KE_STUB.reset(fo,KE.RELEASED,e.keyCode,KE.CHAR_UNDEFINED,km(e));if(EM.performInput(KE_STUB)){e.preventDefault()}}};this.mouseEntered=function(id,e){var mp=$mousePressedEvents[id];this.recalcOffset();if(mp==null||mp.canvas==null){var x=$meX(e,this),y=$meY(e,this),d=this.getComponentAt(x,y);if(pkg.$mouseMoveOwner!=null&&d!=pkg.$mouseMoveOwner){var prev=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(prev,MEXITED,x,y,-1,0);EM.performInput(ME_STUB)}if(d!=null&&d.isEnabled){pkg.$mouseMoveOwner=d;ME_STUB.reset(d,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}};this.mouseExited=function(id,e){var mp=$mousePressedEvents[id];if((mp==null||mp.canvas==null)&&pkg.$mouseMoveOwner!=null){var p=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(p,MEXITED,$meX(e,this),$meY(e,this),-1,0);EM.performInput(ME_STUB)}};this.mouseMoved=function(id,e){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){if(mp.component!=null&&mp.canvas.canvas==e.target){var x=this.$context.tX(e.pageX-this.offx,e.pageY-this.offy),y=this.$context.tY(e.pageX-this.offx,e.pageY-this.offy),m=mp.button;if(mp.draggedComponent==null){var xx=this.$context.tX(mp.pageX-this.offx,mp.pageY-this.offy),yy=this.$context.tY(mp.pageX-this.offx,mp.pageY-this.offy),d=(pkg.$mouseMoveOwner==null)?this.getComponentAt(xx,yy):pkg.$mouseMoveOwner;if(d!=null&&d.isEnabled===true){mp.draggedComponent=d;ME_STUB.reset(d,ME.DRAGSTARTED,xx,yy,m,0);EM.performInput(ME_STUB);if(xx!=x||yy!=y){ME_STUB.reset(d,MDRAGGED,x,y,m,0);EM.performInput(ME_STUB)}}}else{ME_STUB.reset(mp.draggedComponent,MDRAGGED,x,y,m,0);EM.performInput(ME_STUB)}}}else{var x=this.$context.tX(e.pageX-this.offx,e.pageY-this.offy),y=this.$context.tY(e.pageX-this.offx,e.pageY-this.offy),d=this.getComponentAt(x,y);if(pkg.$mouseMoveOwner!=null){if(d!=pkg.$mouseMoveOwner){var old=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(old,MEXITED,x,y,-1,0);EM.performInput(ME_STUB);if(d!=null&&d.isEnabled===true){pkg.$mouseMoveOwner=d;ME_STUB.reset(pkg.$mouseMoveOwner,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}else{if(d!=null&&d.isEnabled){ME_STUB.reset(d,MMOVED,x,y,-1,0);EM.performInput(ME_STUB)}}}else{if(d!=null&&d.isEnabled===true){pkg.$mouseMoveOwner=d;ME_STUB.reset(d,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}}};this.mouseReleased=function(id,e){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){var x=$meX(e,this),y=$meY(e,this),po=mp.component;if(mp.draggedComponent!=null){ME_STUB.reset(mp.draggedComponent,ME.DRAGENDED,x,y,mp.button,0);EM.performInput(ME_STUB)}if(po!=null){if(mp.draggedComponent==null&&(e.touch==null||e.touch.group==null)){ME_STUB.reset(po,ME.CLICKED,x,y,mp.button,mp.clicks);EM.performInput(ME_STUB)}ME_STUB.reset(po,ME.RELEASED,x,y,mp.button,mp.clicks);EM.performInput(ME_STUB)}if(zebra.isTouchable===false){var mo=pkg.$mouseMoveOwner;if(mp.draggedComponent!=null||(po!=null&&po!=mo)){var nd=this.getComponentAt(x,y);if(nd!=mo){if(mo!=null){ME_STUB.reset(mo,MEXITED,x,y,-1,0);EM.performInput(ME_STUB)}if(nd!=null&&nd.isEnabled===true){pkg.$mouseMoveOwner=nd;ME_STUB.reset(nd,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}}}$mousePressedEvents[id].canvas=null}};this.mousePressed=function(id,e,button){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){this.mouseReleased(id,mp)}var clicks=mp!=null&&(new Date().getTime()-mp.time)<=pkg.doubleClickDelta?2:1;mp=$mousePressedEvents[id]={pageX:e.pageX,pageY:e.pageY,identifier:id,target:e.target,canvas:this,button:button,component:null,mouseDragged:null,time:(new Date()).getTime(),clicks:clicks};var x=$meX(e,this),y=$meY(e,this);mp.x=x;mp.y=y;for(var i=this.kids.length-1;i>=0;i--){var l=this.kids[i];if(l.layerMousePressed!=null&&l.layerMousePressed(x,y,button)){break}}var d=this.getComponentAt(x,y);if(d!=null&&d.isEnabled===true){mp.component=d;ME_STUB.reset(d,ME.PRESSED,x,y,button,clicks);EM.performInput(ME_STUB)}if(document.activeElement!=this.canvas){this.canvas.focus()}};this.getComponentAt=function(x,y){for(var i=this.kids.length;--i>=0;){var tl=this.kids[i];if(tl.isLayerActiveAt==null||tl.isLayerActiveAt(x,y)){return EM.getEventDestination(tl.getComponentAt(x,y))}}return null};this.recalcOffset=function(){var poffx=this.offx,poffy=this.offy,ba=this.canvas.getBoundingClientRect();this.offx=((ba.left+0.5)|0)+measure(this.canvas,"padding-left")+window.pageXOffset;this.offy=((ba.top+0.5)|0)+measure(this.canvas,"padding-top")+window.pageYOffset;if(this.offx!=poffx||this.offy!=poffy){this.relocated(this,poffx,poffy)}};this.getLayer=function(id){return this[id]};this.setStyles=function(styles){for(var k in styles){this.canvas.style[k]=styles[k]}};this.setAttribute=function(name,value){this.canvas.setAttribute(name,value)};this.relocated=function(px,py){pkg.events.performComp(CL.MOVED,this,px,py)};this.resized=function(pw,ph){pkg.events.performComp(CL.SIZED,this,pw,ph)};this.repaint=function(x,y,w,h){if((document.contains!=null&&document.contains(this.canvas)===false)||this.canvas.style.visibility=="hidden"){return}if(arguments.length===0){x=y=0;w=this.width;h=this.height}if(w>0&&h>0&&pkg.paintManager!=null){pkg.paintManager.repaint(this,x,y,w,h)}}},function(){this.$this(400,400)},function(w,h){this.$this(this.toString(),w,h)},function(canvas){this.$this(canvas,-1,-1)},function(canvas,w,h){this.$focusGainedCounter=0;var pc=canvas,$this=this;this.nativeListeners={onmousemove:null,onmousedown:null,onmouseup:null,onmouseover:null,onmouseout:null,onkeydown:null,onkeyup:null,onkeypress:null};var addToBody=true;if(zebra.isBoolean(canvas)){addToBody=canvas;canvas=null}else{if(zebra.isString(canvas)){canvas=document.getElementById(canvas);if(canvas!=null&&pkg.$detectZCanvas(canvas)){throw new Error("Canvas id='"+pc+"'' is already in use")}}}if(canvas==null){canvas=document.createElement("canvas");canvas.setAttribute("class","zebcanvas");canvas.setAttribute("width",w<=0?"400":""+w);canvas.setAttribute("height",h<=0?"400":""+h);canvas.setAttribute("id",pc);if(addToBody){document.body.appendChild(canvas)}}if(canvas.getAttribute("tabindex")===null){canvas.setAttribute("tabindex","1")}this.$da={x:0,y:0,width:-1,height:0};this.canvas=canvas;this.$super(new pkg.zCanvas.Layout());for(var i=0;i0){e.preventDefault();return}if(pkg.focusManager.canvasFocusGained){pkg.focusManager.canvasFocusGained($this)}};this.canvas.onblur=function(e){if(document.activeElement==$this.canvas){e.preventDefault();return}if($this.$focusGainedCounter!==0){$this.$focusGainedCounter=0;if(pkg.focusManager.canvasFocusLost){pkg.focusManager.canvasFocusLost($this)}}};var addons=pkg.zCanvas.addons;if(addons){for(var i=0;i0){$configurators.shift()(pkg.$configuration)}pkg.$configuration.end();EM=pkg.events;if(pkg.clipboardTriggerKey>0){$clipboard=document.createElement("textarea");$clipboard.setAttribute("style","display:none; position: absolute; left: -99em; top:-99em;");$clipboard.onkeydown=function(ee){$clipboardCanvas.keyPressed(ee);$clipboard.value="1";$clipboard.select()};$clipboard.onkeyup=function(ee){if(ee.keyCode==pkg.clipboardTriggerKey){$clipboard.style.display="none";$clipboardCanvas.canvas.focus();$clipboardCanvas.canvas.onblur=$clipboardCanvas.focusLost;$clipboardCanvas.canvas.onfocus=$clipboardCanvas.focusGained}$clipboardCanvas.keyReleased(ee)};$clipboard.onblur=function(){this.value="";this.style.display="none";$clipboardCanvas.canvas.focus()};$clipboard.oncopy=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.copy){var v=pkg.focusManager.focusOwner.copy();$clipboard.value=v==null?"":v;$clipboard.select()}};$clipboard.oncut=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.cut){$clipboard.value=pkg.focusManager.focusOwner.cut();$clipboard.select()}};if(zebra.isFF){$clipboard.addEventListener("input",function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.paste){pkg.focusManager.focusOwner.paste($clipboard.value)}},false)}else{$clipboard.onpaste=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.paste){var txt=(typeof ee.clipboardData=="undefined")?window.clipboardData.getData("Text"):ee.clipboardData.getData("text/plain");pkg.focusManager.focusOwner.paste(txt)}$clipboard.value=""}}document.body.appendChild($clipboard)}document.addEventListener("DOMNodeInserted",function(e){elBoundsUpdated()},false);document.addEventListener("DOMNodeRemoved",function(e){elBoundsUpdated();for(var i=$canvases.length-1;i>=0;i--){var canvas=$canvases[i];if(e.target==canvas.canvas){$canvases.splice(i,1);if(canvas.saveBeforeLeave){canvas.saveBeforeLeave()}break}}},false);window.addEventListener("resize",function(e){elBoundsUpdated()},false);window.onbeforeunload=function(e){var msgs=[];for(var i=$canvases.length-1;i>=0;i--){if($canvases[i].saveBeforeLeave){var m=$canvases[i].saveBeforeLeave();if(m!=null){msgs.push(m)}}}if(msgs.length>0){var message=msgs.join(" ");if(typeof e==="undefined"){e=window.event}if(e){e.returnValue=message}return message}};if(zebra.isIE){window.focus()}}catch(e){zebra.error(e.toString());throw e}finally{zebra.ready()}})})(zebra("ui"),zebra.Class,zebra.Interface)})(); \ No newline at end of file +(function(){(function(){function isString(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="string"||o.constructor===String)}function isNumber(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="number"||o.constructor===Number)}function isBoolean(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="boolean"||o.constructor===Boolean)}if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(searchElement){if(this==null){throw new TypeError()}var t=Object(this),len=t.length>>>0;if(len===0){return -1}var n=0;if(arguments.length>0){n=Number(arguments[1]);if(n!=n){n=0}else{if(n!==0&&n!=Infinity&&n!=-Infinity){n=(n>0||-1)*~~Math.abs(n)}}}if(n>=len){return -1}var k=n>=0?n:Math.max(len-Math.abs(n),0);for(;k0)?new zebra.URL(ss.substring(0,i+1)):new zebra.URL(document.location.toString()).getParentURL()}}if(namespaces.hasOwnProperty(nsname)){throw new Error("Name space '"+nsname+"' already exists")}var f=function(name){if(arguments.length===0){return f.$env}if(typeof name==="function"){for(var k in f){if(f[k] instanceof Package){name(k,f[k])}}return null}var b=Array.isArray(name);if(isString(name)===false&&b===false){for(var k in name){if(name.hasOwnProperty(k)){f.$env[k]=name[k]}}return}if(b){for(var i=0;i=0){for(var k in p){if(k[0]!="$"&&k[0]!="_"&&(p[k] instanceof Package)===false&&p.hasOwnProperty(k)){code.push([k,ns,n,".",k].join(""))}}if(packages!=null){packages.splice(packages.indexOf(n),1)}}});if(packages!=null&&packages.length!==0){throw new Error("Unknown package(s): "+packages.join(","))}return code.length>0?["var ",code.join(","),";"].join(""):null};f.$env={};namespaces[nsname]=f;return f};zebra=namespace("zebra");var pkg=zebra,FN=pkg.$FN=(typeof namespace.name==="undefined")?(function(f){var mt=f.toString().match(/^function\s+([^\s(]+)/);return(mt==null)?"":mt[1]}):(function(f){return f.name});pkg.namespaces=namespaces;pkg.namespace=namespace;pkg.$global=this;pkg.isString=isString;pkg.isNumber=isNumber;pkg.isBoolean=isBoolean;pkg.version="1.2.0";pkg.$caller=null;function mnf(name,params){var cln=this.$clazz&&this.$clazz.$name?this.$clazz.$name+".":"";throw new ReferenceError("Method '"+cln+(name===""?"constructor":name)+"("+params+")' not found")}function $toString(){return this._hash_}function $equals(o){return this==o}function make_template(pt,tf,p){tf._hash_=["$zebra_",$$$++].join("");tf.toString=$toString;if(pt!=null){tf.prototype.$clazz=tf}tf.$clazz=pt;tf.prototype.toString=$toString;tf.prototype.equals=$equals;tf.prototype.constructor=tf;if(p&&p.length>0){tf.$parents={};for(var i=0;i0){return new (pkg.Class($Interface,arguments[0]))()}},arguments);return $Interface});pkg.$Extended=pkg.Interface();function ProxyMethod(name,f){if(isString(name)===false){throw new TypeError("Method name has not been defined")}var a=null;if(arguments.length==1){a=function(){var nm=a.methods[arguments.length];if(nm){var cm=pkg.$caller;pkg.$caller=nm;try{return nm.apply(this,arguments)}catch(e){throw e}finally{pkg.$caller=cm}}mnf.call(this,a.methodName,arguments.length)};a.methods={}}else{a=function(){var cm=pkg.$caller;pkg.$caller=f;try{return f.apply(this,arguments)}catch(e){throw e}finally{pkg.$caller=cm}};a.f=f}a.$clone$=function(){if(a.methodName===""){return null}if(a.f){return ProxyMethod(a.methodName,a.f)}var m=ProxyMethod(a.methodName);for(var k in a.methods){m.methods[k]=a.methods[k]}return m};a.methodName=name;return a}pkg.Class=make_template(null,function(){if(arguments.length===0){throw new Error("No class definition was found")}if(Array.isArray(arguments[arguments.length-1])===false){throw new Error("Invalid class definition was found")}if(arguments.length>1&&typeof arguments[0]!=="function"){throw new ReferenceError("Invalid parent class '"+arguments[0]+"'")}var df=arguments[arguments.length-1],$parent=null,args=Array.prototype.slice.call(arguments,0,arguments.length-1);if(args.length>0&&(args[0]==null||args[0].$clazz==pkg.Class)){$parent=args[0]}var $template=make_template(pkg.Class,function(){this._hash_=["$zObj_",$$$++].join("");if(arguments.length>0){var a=arguments[arguments.length-1];if(Array.isArray(a)===true&&typeof a[0]==="function"){a=a[0];var args=[$template],k=arguments.length-2;for(;k>=0&&pkg.instanceOf(arguments[k],pkg.Interface);k--){args.push(arguments[k])}args.push(arguments[arguments.length-1]);var cl=pkg.Class.apply(null,args),f=function(){};cl.$name=$template.$name;f.prototype=cl.prototype;var o=new f();cl.apply(o,Array.prototype.slice.call(arguments,0,k+1));o.constructor=cl;return o}}this[""]&&this[""].apply(this,arguments)},args);$template.$parent=$parent;if($parent!=null){for(var k in $parent.prototype){var f=$parent.prototype[k];if(f&&f.$clone$){f=f.$clone$();if(f==null){continue}}$template.prototype[k]=f}}$template.$propertyInfo={};$template.prototype.extend=function(){var c=this.$clazz,l=arguments.length,f=arguments[l-1];if(pkg.instanceOf(this,pkg.$Extended)===false){var cn=c.$name;c=Class(c,pkg.$Extended,[]);c.$name=cn;this.$clazz=c}if(Array.isArray(f)){for(var i=0;i0&&typeof arguments[0]==="function"){name=arguments[0].methodName;args=Array.prototype.slice.call(arguments,1)}var params=args.length;while($s!=null){var m=$s.prototype[name];if(m&&(typeof m.methods==="undefined"||m.methods[params])){return m.apply(this,args)}$s=$s.$parent}mnf.call(this,name,params)}throw new Error("$super is called outside of class context")};$template.prototype.$clazz=$template;$template.prototype.$this=function(){return pkg.$caller.boundTo.prototype[""].apply(this,arguments)};$template.constructor.prototype.getMethods=function(name){var m=[];for(var n in this.prototype){var f=this.prototype[n];if(arguments.length>0&&name!=n){continue}if(typeof f==="function"){if(f.$clone$){for(var mk in f.methods){m.push(f.methods[mk])}}else{m.push(f)}}}return m};$template.constructor.prototype.getMethod=function(name,params){var m=this.prototype[name];if(typeof m==="function"){if(m.$clone$){if(typeof params==="undefined"){if(m.methods[0]){return m.methods[0]}for(var k in m.methods){return m.methods[k]}return null}m=m.methods[params]}if(m){return m}}return null};$template.extend=function(df){if(Array.isArray(df)===false){throw new Error("Wrong class definition format "+df+", array is expected")}for(var i=0;i0){$busy--}}else{if(arguments.length==1&&$busy===0&&$f.length===0){arguments[0]();return}}for(var i=0;i0){$f.shift()()}};pkg.busy=function(){$busy++};pkg.Output=Class([function $prototype(){this.print=function print(o){this._p(0,o)};this.error=function error(o){this._p(2,o)};this.warn=function warn(o){this._p(1,o)};this._p=function(l,o){o=this.format(o);if(pkg.isInBrowser){if(typeof console==="undefined"||!console.log){alert(o)}else{if(l===0){console.log(o)}else{if(l==1){console.warn(o)}else{console.error(o)}}}}else{pkg.$global.print(o)}};this.format=function(o){if(o&&o.stack){return[o.toString(),":",o.stack.toString()].join("\n")}if(o===null){return""}if(typeof o==="undefined"){return""}if(isString(o)||isNumber(o)||isBoolean(o)){return o}var d=[o.toString()+" "+(o.$clazz?o.$clazz.$name:""),"{"];for(var k in o){if(o.hasOwnProperty(k)){d.push(" "+k+" = "+o[k])}}return d.join("\n")+"\n}"}}]);pkg.Dummy=Class([]);pkg.HtmlOutput=Class(pkg.Output,[function(){this.$this(null)},function(element){element=element||"zebra.out";if(pkg.isString(element)){this.el=document.getElementById(element);if(this.el==null){this.el=document.createElement("div");this.el.setAttribute("id",element);document.body.appendChild(this.el)}}else{if(element==null){throw new Error("Unknown HTML output element")}this.el=element}},function print(s){this.out("black",s)},function error(s){this.out("red",s)},function warn(s){this.out("orange",s)},function out(color,msg){var t=["
",this.format(msg),"
"];this.el.innerHTML+=t.join("")}]);pkg.isInBrowser=typeof navigator!=="undefined";pkg.isIE=pkg.isInBrowser&&(Object.hasOwnProperty.call(window,"ActiveXObject")||!!window.ActiveXObject);pkg.isFF=pkg.isInBrowser&&window.mozInnerScreenX!=null;pkg.isMobile=pkg.isInBrowser&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|windows mobile|windows phone|IEMobile/i.test(navigator.userAgent);pkg.isTouchable=pkg.isInBrowser&&((pkg.isIE===false&&(!!("ontouchstart" in window)||!!("onmsgesturechange" in window)))||(!!window.navigator.msPointerEnabled&&!!window.navigator.msMaxTouchPoints>0));pkg.out=new pkg.Output();pkg.isMacOS=pkg.isInBrowser&&navigator.platform.toUpperCase().indexOf("MAC")!==-1;pkg.print=function(){pkg.out.print.apply(pkg.out,arguments)};pkg.error=function(){pkg.out.error.apply(pkg.out,arguments)};pkg.warn=function(){pkg.out.warn.apply(pkg.out,arguments)};function complete(){pkg(function(n,p){function collect(pp,p){for(var k in p){if(k[0]!="$"&&p.hasOwnProperty(k)&&zebra.instanceOf(p[k],Class)){p[k].$name=pp?[pp,k].join("."):k;collect(k,p[k])}}}collect(null,p)});pkg.ready()}if(pkg.isInBrowser){var m=window.location.search.match(/[?&][a-zA-Z0-9_.]+=[^?&=]+/g),env={};for(var i=0;m&&i0?"&":"?")+t,false);r.send(null)};var b64str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";pkg.b64encode=function(input){var out=[],i=0,len=input.length,c1,c2,c3;if(typeof ArrayBuffer!=="undefined"){if(input instanceof ArrayBuffer){input=new Uint8Array(input)}input.charCodeAt=function(i){return this[i]}}if(Array.isArray(input)){input.charCodeAt=function(i){return this[i]}}while(i>2));if(i==len){out.push(b64str.charAt((c1&3)<<4),"==");break}c2=input.charCodeAt(i++);out.push(b64str.charAt(((c1&3)<<4)|((c2&240)>>4)));if(i==len){out.push(b64str.charAt((c2&15)<<2),"=");break}c3=input.charCodeAt(i++);out.push(b64str.charAt(((c2&15)<<2)|((c3&192)>>6)),b64str.charAt(c3&63))}return out.join("")};pkg.b64decode=function(input){var output=[],chr1,chr2,chr3,enc1,enc2,enc3,enc4;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while((input.length%4)!==0){input+="="}for(var i=0;i>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output.push(String.fromCharCode(chr1));if(enc3!=64){output.push(String.fromCharCode(chr2))}if(enc4!=64){output.push(String.fromCharCode(chr3))}}return output.join("")};pkg.dateToISO8601=function(d){function pad(n){return n<10?"0"+n:n}return[d.getUTCFullYear(),"-",pad(d.getUTCMonth()+1),"-",pad(d.getUTCDate()),"T",pad(d.getUTCHours()),":",pad(d.getUTCMinutes()),":",pad(d.getUTCSeconds()),"Z"].join("")};pkg.ISO8601toDate=function(v){var regexp=["([0-9]{4})(-([0-9]{2})(-([0-9]{2})","(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?","(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?"].join(""),d=v.match(new RegExp(regexp)),offset=0,date=new Date(d[1],0,1);if(d[3]){date.setMonth(d[3]-1)}if(d[5]){date.setDate(d[5])}if(d[7]){date.setHours(d[7])}if(d[8]){date.setMinutes(d[8])}if(d[10]){date.setSeconds(d[10])}if(d[12]){date.setMilliseconds(Number("0."+d[12])*1000)}if(d[14]){offset=(Number(d[16])*60)+Number(d[17]);offset*=((d[15]=="-")?1:-1)}offset-=date.getTimezoneOffset();date.setTime(Number(date)+(offset*60*1000));return date};pkg.parseXML=function(s){function rmws(node){if(node.childNodes!==null){for(var i=node.childNodes.length;i-->0;){var child=node.childNodes[i];if(child.nodeType===3&&child.data.match(/^\s*$/)){node.removeChild(child)}if(child.nodeType===1){rmws(child)}}}return node}if(typeof DOMParser!=="undefined"){return rmws((new DOMParser()).parseFromString(s,"text/xml"))}else{for(var n in {"Microsoft.XMLDOM":0,"MSXML2.DOMDocument":1,"MSXML.DOMDocument":2}){var p=null;try{p=new ActiveXObject(n);p.async=false}catch(e){continue}if(p===null){throw new Error("XML parser is not available")}p.loadXML(s);return p}}throw new Error("No XML parser is available")};pkg.QS=Class([function $clazz(){this.append=function(url,obj){return url+((obj===null)?"":((url.indexOf("?")>0)?"&":"?")+pkg.QS.toQS(obj,true))};this.parse=function(url){var m=window.location.search.match(/[?&][a-zA-Z0-9_.]+=[^?&=]+/g),r={};for(var i=0;m&&i0?this.data.charCodeAt(this.pos++)&255:-1}])}else{if(Array.isArray(container)===false){throw new Error("Wrong type: "+typeof(container))}}this.data=container}this.marked=-1;this.pos=0},function mark(){if(this.available()<=0){throw new Error()}this.marked=this.pos},function reset(){if(this.available()<=0||this.marked<0){throw new Error()}this.pos=this.marked;this.marked=-1},function close(){this.pos=this.data.length},function read(){return this.available()>0?this.data[this.pos++]:-1},function read(buf){return this.read(buf,0,buf.length)},function read(buf,off,len){for(var i=0;i191&&c<224){return String.fromCharCode(((c&31)<<6)|(c2&63))}else{var c3=this.read();if(c3<0){throw new Error()}return String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63))}},function readLine(){if(this.available()>0){var line=[],b;while((b=this.readChar())!=-1&&b!="\n"){line.push(b)}var r=line.join("");line.length=0;return r}return null},function available(){return this.data===null?-1:this.data.length-this.pos},function toBase64(){return pkg.b64encode(this.data)}]);pkg.URLInputStream=Class(pkg.InputStream,[function(url){this.$this(url,null)},function(url,f){var r=pkg.getRequest(),$this=this;r.open("GET",url,f!==null);if(f===null||isBA===false){if(!r.overrideMimeType){throw new Error("Binary mode is not supported")}r.overrideMimeType("text/plain; charset=x-user-defined")}if(f!==null){if(isBA){r.responseType="arraybuffer"}r.onreadystatechange=function(){if(r.readyState==4){if(r.status!=200){throw new Error(url)}$this.$clazz.$parent.getMethod("",1).call($this,isBA?r.response:r.responseText);f($this.data,r)}};r.send(null)}else{r.send(null);if(r.status!=200){throw new Error(url)}this.$super(r.responseText)}},function close(){this.$super();if(this.data){this.data.length=0;this.data=null}}]);pkg.Service=Class([function(url,methods){var $this=this;this.url=url;if(Array.isArray(methods)===false){methods=[methods]}for(var i=0;i0&&typeof args[args.length-1]=="function"){var callback=args.pop();return this.send(url,this.encode(name,args),function(request){var r=null;try{if(request.status==200){r=$this.decode(request.responseText)}else{r=new Error("Status: "+request.status+", '"+request.statusText+"'")}}catch(e){r=e}callback(r)})}return this.decode(this.send(url,this.encode(name,args),null))}})()}},function send(url,data,callback){var http=new pkg.HTTP(url);if(this.contentType!=null){http.header["Content-Type"]=this.contentType}return http.POST(data,callback)}]);pkg.Service.invoke=function(clazz,url,method){var rpc=new clazz(url,method);return function(){return rpc[method].apply(rpc,arguments)}};pkg.JRPC=Class(pkg.Service,[function(url,methods){this.$super(url,methods);this.version="2.0";this.contentType="application/json"},function encode(name,args){return JSON.stringify({jsonrpc:this.version,method:name,params:args,id:pkg.ID()})},function decode(r){if(r===null||r.length===0){throw new Error("Empty JSON result string")}r=JSON.parse(r);if(typeof(r.error)!=="undefined"){throw new Error(r.error.message)}if(typeof r.result==="undefined"||typeof r.id==="undefined"){throw new Error("Wrong JSON response format")}return r.result}]);pkg.Base64=function(s){if(arguments.length>0){this.encoded=pkg.b64encode(s)}};pkg.Base64.prototype.toString=function(){return this.encoded};pkg.Base64.prototype.decode=function(){return pkg.b64decode(this.encoded)};pkg.XRPC=Class(pkg.Service,[function(url,methods){this.$super(url,methods);this.contentType="text/xml"},function encode(name,args){var p=['\n',name,""];for(var i=0;i");this.encodeValue(args[i],p);p.push("")}p.push("");return p.join("")},function encodeValue(v,p){if(v===null){throw new Error("Null is not allowed")}if(zebra.isString(v)){v=v.replace("<","<");v=v.replace("&","&");p.push("",v,"")}else{if(zebra.isNumber(v)){if(Math.round(v)==v){p.push("",v.toString(),"")}else{p.push("",v.toString(),"")}}else{if(zebra.isBoolean(v)){p.push("",v?"1":"0","")}else{if(v instanceof Date){p.push("",pkg.dateToISO8601(v),"")}else{if(Array.isArray(v)){p.push("");for(var i=0;i");this.encodeValue(v[i],p);p.push("")}p.push("")}else{if(v instanceof pkg.Base64){p.push("",v.toString(),"")}else{p.push("");for(var k in v){if(v.hasOwnProperty(k)){p.push("",k,"");this.encodeValue(v[k],p);p.push("")}}p.push("")}}}}}}},function decodeValue(node){var tag=node.tagName.toLowerCase();if(tag=="struct"){var p={};for(var i=0;i0){var err=this.decodeValue(c[0].getElementsByTagName("struct")[0]);throw new Error(err.faultString)}c=p.getElementsByTagName("methodResponse")[0];c=c.childNodes[0].childNodes[0];if(c.tagName.toLowerCase()==="param"){return this.decodeValue(c.childNodes[0].childNodes[0])}throw new Error("incorrect XML-RPC response")}]);pkg.XRPC.invoke=function(url,method){return pkg.Service.invoke(pkg.XRPC,url,method)};pkg.JRPC.invoke=function(url,method){return pkg.Service.invoke(pkg.JRPC,url,method)}})(zebra("io"),zebra.Class);(function(pkg,Class,Interface){pkg.newInstance=function(clazz,args){if(args&&args.length>0){var f=function(){};f.prototype=clazz.prototype;var o=new f();o.constructor=clazz;clazz.apply(o,args);return o}return new clazz()};function hex(v){return(v<16)?["0",v.toString(16)].join(""):v.toString(16)}pkg.findInTree=function(root,path,eq,cb){var findRE=/(\/\/|\/)?([^\[\/]+)(\[\s*(\@[a-zA-Z_][a-zA-Z0-9_\.]*)\s*\=\s*([0-9]+|true|false|\'[^']*\')\s*\])?/g,m=null,res=[];function _find(root,ms,idx,cb){function list_child(r,name,deep,cb){if(r.kids){for(var i=0;i=ms.length){return cb(root)}var m=ms[idx];return list_child(root,m[2],m[1]=="//",function(child){if(m[3]&&child[m[4].substring(1)]!=m[5]){return false}return _find(child,ms,idx+1,cb)})}var c=0;while(m=findRE.exec(path)){if(m[1]==null||m[2]==null||m[2].trim().length===0){break}c+=m[0].length;if(m[3]&&m[5][0]=="'"){m[5]=m[5].substring(1,m[5].length-1)}res.push(m)}if(res.length==0||c3){this.a=parseInt(p[3].trim(),10)}return}}}this.r=r>>16;this.g=(r>>8)&255;this.b=(r&255)}else{this.r=r;this.g=g;this.b=b;if(arguments.length>3){this.a=a}}if(this.s==null){this.s=(typeof this.a!=="undefined")?["rgba(",this.r,",",this.g,",",this.b,",",this.a,")"].join(""):["#",hex(this.r),hex(this.g),hex(this.b)].join("")}};var rgb=pkg.rgb;rgb.prototype.toString=function(){return this.s};rgb.black=new rgb(0);rgb.white=new rgb(16777215);rgb.red=new rgb(255,0,0);rgb.blue=new rgb(0,0,255);rgb.green=new rgb(0,255,0);rgb.gray=new rgb(128,128,128);rgb.lightGray=new rgb(211,211,211);rgb.darkGray=new rgb(169,169,169);rgb.orange=new rgb(255,165,0);rgb.yellow=new rgb(255,255,0);rgb.pink=new rgb(255,192,203);rgb.cyan=new rgb(0,255,255);rgb.magenta=new rgb(255,0,255);rgb.darkBlue=new rgb(0,0,140);rgb.transparent=new rgb(0,0,0,1);pkg.Actionable=Interface();pkg.index2point=function(offset,cols){return[~~(offset/cols),(offset%cols)]};pkg.indexByPoint=function(row,col,cols){return(cols<=0)?-1:(row*cols)+col};pkg.intersection=function(x1,y1,w1,h1,x2,y2,w2,h2,r){r.x=x1>x2?x1:x2;r.width=Math.min(x1+w1,x2+w2)-r.x;r.y=y1>y2?y1:y2;r.height=Math.min(y1+h1,y2+h2)-r.y};pkg.isIntersect=function(x1,y1,w1,h1,x2,y2,w2,h2){return(Math.min(x1+w1,x2+w2)-(x1>x2?x1:x2))>0&&(Math.min(y1+h1,y2+h2)-(y1>y2?y1:y2))>0};pkg.unite=function(x1,y1,w1,h1,x2,y2,w2,h2,r){r.x=x1>8)&255);ar.push(code&255)}return ar};var digitRE=/[0-9]/;pkg.isDigit=function(ch){if(ch.length!=1){throw new Error("Incorrect character")}return digitRE.test(ch)};var letterRE=/[A-Za-z]/;pkg.isLetter=function(ch){if(ch.length!=1){throw new Error("Incorrect character")}return letterRE.test(ch)};var $NewListener=function(){if(arguments.length===0){arguments=["fired"]}var clazz=function(){};if(arguments.length==1){var name=arguments[0];clazz.prototype.add=function(l){if(this.v==null){this.v=[]}var ctx=this;if(typeof l!=="function"){ctx=l;l=l[name];if(l==null||typeof l!=="function"){throw new Error("Instance doesn't declare '"+names+"' listener method")}}this.v.push(ctx,l);return l};clazz.prototype.remove=function(l){if(this.v!=null){var i=0;while((i=this.v.indexOf(l))>=0){if(i%2>0){i--}this.v.splice(i,2)}}};clazz.prototype.removeAll=function(){if(this.v!=null){this.v.length=0}};clazz.prototype[name]=function(){if(this.v!=null){for(var i=0;i=0){if(i%2>0){i--}v.splice(i,2)}if(v.length===0){delete this.methods[k]}}}};clazz.prototype.removeAll=function(){if(this.methods!=null){for(var k in this.methods){if(this.methods.hasOwnProperty(k)){this.methods[k].length=0}}this.methods={}}}}return clazz};pkg.Listeners=$NewListener();pkg.Listeners.Class=$NewListener;var PosListeners=pkg.Listeners.Class("posChanged"),Position=pkg.Position=Class([function $clazz(){this.Metric=Interface();this.DOWN=1;this.UP=2;this.BEG=3;this.END=4},function $prototype(){this.clearPos=function(){if(this.offset>=0){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol;this.offset=this.currentLine=this.currentCol=-1;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.setOffset=function(o){if(o<0){o=0}else{var max=this.metrics.getMaxOffset();if(o>=max){o=max}}if(o!=this.offset){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol,p=this.getPointByOffset(o);this.offset=o;if(p!=null){this.currentLine=p[0];this.currentCol=p[1]}this.isValid=true;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.seek=function(off){this.setOffset(this.offset+off)};this.setRowCol=function(r,c){if(r!=this.currentLine||c!=this.currentCol){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol;this.offset=this.getOffsetByPoint(r,c);this.currentLine=r;this.currentCol=c;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.inserted=function(off,size){if(this.offset>=0&&off<=this.offset){this.isValid=false;this.setOffset(this.offset+size)}};this.removed=function(off,size){if(this.offset>=0&&this.offset>=off){this.isValid=false;if(this.offset>=(off+size)){this.setOffset(this.offset-size)}else{this.setOffset(off)}}};this.getPointByOffset=function(off){if(off==-1){return[-1,-1]}var m=this.metrics,max=m.getMaxOffset();if(off>max){throw new Error("Out of bounds:"+off)}if(max===0){return[(m.getLines()>0?0:-1),0]}if(off===0){return[0,0]}var d=0,sl=0,so=0;if(this.isValid&&this.offset!=-1){sl=this.currentLine;so=this.offset-this.currentCol;if(off>this.offset){d=1}else{if(off=0;sl+=d){var ls=m.getLineSize(sl);if(off>=so&&off0?ls:-m.getLineSize(sl-1)}return[-1,-1]};this.getOffsetByPoint=function(row,col){var startOffset=0,startLine=0,m=this.metrics;if(row>=m.getLines()||col>=m.getLineSize(row)){throw new Error()}if(this.isValid&&this.offset!=-1){startOffset=this.offset-this.currentCol;startLine=this.currentLine}if(startLine<=row){for(var i=startLine;i=row;i--){startOffset-=m.getLineSize(i)}}return startOffset+col};this.calcMaxOffset=function(){var max=0,m=this.metrics;for(var i=0;i0){this.offset-=this.currentCol;this.currentCol=0;this._.posChanged(this,prevOffset,prevLine,prevCol)}break;case Position.END:var maxCol=this.metrics.getLineSize(this.currentLine);if(this.currentCol<(maxCol-1)){this.offset+=(maxCol-this.currentCol-1);this.currentCol=maxCol-1;this._.posChanged(this,prevOffset,prevLine,prevCol)}break;case Position.UP:if(this.currentLine>0){this.offset-=(this.currentCol+1);this.currentLine--;for(var i=0;this.currentLine>0&&i<(num-1);i++,this.currentLine--){this.offset-=this.metrics.getLineSize(this.currentLine)}var maxCol=this.metrics.getLineSize(this.currentLine);if(this.currentCol0){for(var i=0;i=0){window.clearInterval(this.pid);this.pid=-1}};this.clear=function(l){var c=this.get(l);c.si=c.ri}})();pkg.Bag=zebra.Class([function $prototype(){this.concatArrays=false;this.usePropertySetters=true;this.ignoreNonExistentKeys=false;this.get=function(key){if(key==null){throw new Error("Null key")}var n=key.split("."),v=this.objects;for(var i=0;i1){m.apply(v,nv)}else{m.call(v,nv)}continue}}v[k]=nv}}if(inh!==null){this.inherit(v,inh)}return v};this.resolveClass=function(className){return this.aliases.hasOwnProperty(className)?this.aliases[className]:zebra.Class.forName(className)};this.inherit=function(o,pp){for(var i=0;i0?"&":"?")+(new Date()).getTime().toString();return this.load(zebra.io.GET(p),b)}])})(zebra("util"),zebra.Class,zebra.Interface);(function(pkg,Class){pkg.NONE=0;pkg.LEFT=1;pkg.RIGHT=2;pkg.TOP=4;pkg.BOTTOM=8;pkg.CENTER=16;pkg.HORIZONTAL=32;pkg.VERTICAL=64;pkg.TEMPORARY=128;pkg.USE_PS_SIZE=512;pkg.STRETCH=256;pkg.TLEFT=pkg.LEFT|pkg.TOP;pkg.TRIGHT=pkg.RIGHT|pkg.TOP;pkg.BLEFT=pkg.LEFT|pkg.BOTTOM;pkg.BRIGHT=pkg.RIGHT|pkg.BOTTOM;var $ctrs={};for(var k in pkg){if(pkg.hasOwnProperty(k)&&/^\d+$/.test(pkg[k])){$ctrs[k.toUpperCase()]=pkg[k]}}var $c=pkg.$constraints=function(v){return zebra.isString(v)?$ctrs[v.toUpperCase()]:v};var L=pkg.Layout=new zebra.Interface();pkg.getDirectChild=function(parent,child){for(;child!=null&&child.parent!=parent;child=child.parent){}return child};pkg.getDirectAt=function(x,y,p){for(var i=0;ix&&c.y+c.height>y){return i}}return -1};pkg.getTopParent=function(c){for(;c!=null&&c.parent!=null;c=c.parent){}return c};pkg.getAbsLocation=function(x,y,c){if(arguments.length==1){c=x;x=y=0}while(c.parent!=null){x+=c.x;y+=c.y;c=c.parent}return{x:x,y:y}};pkg.getRelLocation=function(x,y,p,c){while(c!=p){x-=c.x;y-=c.y;c=c.parent}return{x:x,y:y}};pkg.xAlignment=function(aow,alignX,aw){if(alignX==pkg.RIGHT){return aw-aow}if(alignX==pkg.CENTER){return ~~((aw-aow)/2)}if(alignX==pkg.LEFT||alignX==pkg.NONE){return 0}throw new Error("Invalid alignment "+alignX)};pkg.yAlignment=function(aoh,alignY,ah){if(alignY==pkg.BOTTOM){return ah-aoh}if(alignY==pkg.CENTER){return ~~((ah-aoh)/2)}if(alignY==pkg.TOP||alignY==pkg.NONE){return 0}throw new Error("Invalid alignment "+alignY)};pkg.getMaxPreferredSize=function(target){var maxWidth=0,maxHeight=0;for(var i=0;imaxWidth){maxWidth=ps.width}if(ps.height>maxHeight){maxHeight=ps.height}}}return{width:maxWidth,height:maxHeight}};pkg.isAncestorOf=function(p,c){for(;c!=null&&c!=p;c=c.parent){}return c!=null};pkg.Layoutable=Class(L,[function $prototype(){this.x=this.y=this.height=this.width=this.cachedHeight=0;this.psWidth=this.psHeight=this.cachedWidth=-1;this.isLayoutValid=this.isValid=false;this.constraints=this.parent=null;this.isVisible=true;this.find=function(path){var res=null;zebra.util.findInTree(this,path,function(node,name){return node.$clazz.$name==name},function(kid){res=kid;return true});return res};this.findAll=function(path,callback){var res=[];if(callback==null){callback=function(kid){res.push(kid);return false}}zebra.util.findInTree(this,path,function(node,name){return node.$clazz.$name==name},callback);return res};this.validateMetric=function(){if(this.isValid===false){if(this.recalc){this.recalc()}this.isValid=true}};this.invalidateLayout=function(){this.isLayoutValid=false;if(this.parent!=null){this.parent.invalidateLayout()}};this.invalidate=function(){this.isValid=this.isLayoutValid=false;this.cachedWidth=-1;if(this.parent!=null){this.parent.invalidate()}};this.validate=function(){this.validateMetric();if(this.width>0&&this.height>0&&this.isLayoutValid===false&&this.isVisible){this.layout.doLayout(this);for(var i=0;i=0?this.psWidth:ps.width+this.getLeft()+this.getRight();ps.height=this.psHeight>=0?this.psHeight:ps.height+this.getTop()+this.getBottom();this.cachedWidth=ps.width;this.cachedHeight=ps.height;return ps}return{width:this.cachedWidth,height:this.cachedHeight}};this.getTop=function(){return 0};this.getLeft=function(){return 0};this.getBottom=function(){return 0};this.getRight=function(){return 0};this.setParent=function(o){if(o!=this.parent){this.parent=o;this.invalidate()}};this.setLayout=function(m){if(m==null){throw new Error("Null layout")}if(this.layout!=m){var pl=this.layout;this.layout=m;this.invalidate()}};this.calcPreferredSize=function(target){return{width:10,height:10}};this.doLayout=function(target){};this.indexOf=function(c){return this.kids.indexOf(c)};this.insert=function(i,constr,d){if(d.constraints){constr=d.constraints}else{d.constraints=constr}if(i==this.kids.length){this.kids.push(d)}else{this.kids.splice(i,0,d)}d.setParent(this);if(this.kidAdded){this.kidAdded(i,constr,d)}this.invalidate();return d};this.setLocation=function(xx,yy){if(xx!=this.x||this.y!=yy){var px=this.x,py=this.y;this.x=xx;this.y=yy;if(this.relocated){this.relocated(px,py)}}};this.setBounds=function(x,y,w,h){this.setLocation(x,y);this.setSize(w,h)};this.setSize=function(w,h){if(w!=this.width||h!=this.height){var pw=this.width,ph=this.height;this.width=w;this.height=h;this.isLayoutValid=false;if(this.resized){this.resized(pw,ph)}}};this.getByConstraints=function(c){if(this.kids.length>0){for(var i=0;i0){if(arguments.length==1){this.hgap=this.vgap=hgap}else{this.hgap=hgap;this.vgap=vgap}}};this.calcPreferredSize=function(target){var center=null,west=null,east=null,north=null,south=null,d=null;for(var i=0;idim.height?d.height:dim.height)}if(west!=null){d=west.getPreferredSize();dim.width+=d.width+this.hgap;dim.height=d.height>dim.height?d.height:dim.height}if(center!=null){d=center.getPreferredSize();dim.width+=d.width;dim.height=d.height>dim.height?d.height:dim.height}if(north!=null){d=north.getPreferredSize();dim.width=d.width>dim.width?d.width:dim.width;dim.height+=d.height+this.vgap}if(south!=null){d=south.getPreferredSize();dim.width=d.width>dim.width?d.width:dim.width;dim.height+=d.height+this.vgap}return dim};this.doLayout=function(t){var top=t.getTop(),bottom=t.height-t.getBottom(),left=t.getLeft(),right=t.width-t.getRight(),center=null,west=null,east=null;for(var i=0;i0;for(var i=0;im.width){m.width=px}if(py>m.height){m.height=py}}}return m};this.doLayout=function(c){var r=c.width-c.getRight(),b=c.height-c.getBottom(),usePsSize=(this.flag&pkg.USE_PS_SIZE)>0;for(var i=0;i0){ww=r-el.x}if((this.flag&pkg.VERTICAL)>0){hh=b-el.y}el.setSize(ww,hh);if(el.constraints){var x=el.x,y=el.y;if(el.constraints==pkg.CENTER){x=(c.width-ww)/2;y=(c.height-hh)/2}else{if((el.constraints&pkg.TOP)>0){y=0}else{if((el.constraints&pkg.BOTTOM)>0){y=c.height-hh}}if((el.constraints&pkg.LEFT)>0){x=0}else{if((el.constraints&pkg.RIGHT)>0){x=c.width-ww}}}el.setLocation(x,y)}}}};this[""]=function(f){this.flag=f?f:0}}]);pkg.FlowLayout=Class(L,[function $prototype(){this.gap=0;this.ax=pkg.LEFT;this.ay=pkg.TOP;this.direction=pkg.HORIZONTAL;this[""]=function(ax,ay,dir,g){if(arguments.length==1){this.gap=ax}else{if(arguments.length>=2){this.ax=pkg.$constraints(ax);this.ay=pkg.$constraints(ay)}if(arguments.length>2){dir=pkg.$constraints(dir);if(dir!=pkg.HORIZONTAL&&dir!=pkg.VERTICAL){throw new Error("Invalid direction "+dir)}this.direction=dir}if(arguments.length>3){this.gap=g}}};this.calcPreferredSize=function(c){var m={width:0,height:0},cc=0;for(var i=0;im.height?d.height:m.height}else{m.width=d.width>m.width?d.width:m.width;m.height+=d.height}cc++}}var add=this.gap*(cc>0?cc-1:0);if(this.direction==pkg.HORIZONTAL){m.width+=add}else{m.height+=add}return m};this.doLayout=function(c){var psSize=this.calcPreferredSize(c),t=c.getTop(),l=c.getLeft(),lastOne=null,px=pkg.xAlignment(psSize.width,this.ax,c.width-l-c.getRight())+l,py=pkg.yAlignment(psSize.height,this.ay,c.height-t-c.getBottom())+t;for(var i=0;i0?this.gap:0));c++;if(wmax){max=d.height}as+=d.width}else{if(d.width>max){max=d.width}as+=d.height}}return(this.direction==pkg.HORIZONTAL)?{width:as,height:max}:{width:max,height:as}}}]);pkg.Constraints=Class([function $prototype(){this.top=this.bottom=this.left=this.right=0;this.ay=this.ax=pkg.STRETCH;this.rowSpan=this.colSpan=1;this[""]=function(ax,ay){if(arguments.length>0){this.ax=ax;if(arguments.length>1){this.ay=ay}}};this.setPadding=function(p){this.top=this.bottom=this.left=this.right=p};this.setPaddings=function(t,l,b,r){this.top=t;this.bottom=b;this.left=l;this.right=r}}]);pkg.GridLayout=Class(L,[function(r,c){this.$this(r,c,0)},function(r,c,m){this.rows=r;this.cols=c;this.mask=m;this.colSizes=Array(c+1);this.rowSizes=Array(r+1)},function $prototype(){var DEF_CONSTR=new pkg.Constraints();this.getSizes=function(c,isRow){var max=isRow?this.rows:this.cols,res=isRow?this.rowSizes:this.colSizes;res[max]=0;for(var i=0;imax?d:max)}}return max};this.calcColSize=function(col,c){var max=0,r=0,i=0;while((i=zebra.util.indexByPoint(r,col,this.cols))max?d:max)}r++}return max};this.calcPreferredSize=function(c){return{width:this.getSizes(c,false)[this.cols],height:this.getSizes(c,true)[this.rows]}};this.doLayout=function(c){var rows=this.rows,cols=this.cols,colSizes=this.getSizes(c,false),rowSizes=this.getSizes(c,true),top=c.getTop(),left=c.getLeft();if((this.mask&pkg.HORIZONTAL)>0){var dw=c.width-left-c.getRight()-colSizes[cols];for(var i=0;i0){var dh=c.height-top-c.getBottom()-rowSizes[rows];for(var i=0;ie.touches.length){return}if(this.timer==null){var $this=this;this.timer=setTimeout(function(){$this.Q();$this.timer=null},25)}var t=e.touches;for(var i=0;i1){for(var i=0;i0){for(var i=0;i0&&t.dx>0),dys=(dy<0&&t.dy<0)||(dy>0&&t.dy>0);t.pageX=nmt.pageX;t.pageY=nmt.pageY;if($abs(dx)>2||$abs(dy)>2){gamma=$atan2(dy,dx);if(gamma>-PI4){d=(gamma-PI4_3)?L.TOP:L.LEFT}if(t.direction!=d){if(t.dc<3){t.direction=d}t.dc=0}else{t.dc++}t.gamma=gamma}if($this.timer==null){t.dx=dx;t.dy=dy;$this.moved(t)}else{$this.dc=0}}}}e.preventDefault()},false)}}])})(zebra("ui"),zebra.Class);(function(pkg,Class,Interface){var instanceOf=zebra.instanceOf,L=zebra.layout,MB=zebra.util,$configurators=[],rgb=zebra.util.rgb,temporary={x:0,y:0,width:0,height:0},MS=Math.sin,MC=Math.cos,$fmCanvas=null,$fmText=null,$fmImage=null,$clipboard=null,$clipboardCanvas,$canvases=[],$ratio=typeof window.devicePixelRatio!=="undefined"?window.devicePixelRatio:(typeof window.screen.deviceXDPI!=="undefined"?window.screen.deviceXDPI/window.screen.logicalXDPI:1);pkg.clipboardTriggerKey=0;function $meX(e,d){return d.$context.tX(e.pageX-d.offx,e.pageY-d.offy)}function $meY(e,d){return d.$context.tY(e.pageX-d.offx,e.pageY-d.offy)}function elBoundsUpdated(){for(var i=$canvases.length-1;i>=0;i--){var c=$canvases[i];if(c.isFullScreen){c.setLocation(0,0);c.setSize(window.innerWidth,window.innerHeight)}c.recalcOffset()}}pkg.$view=function(v){if(v==null){return null}if(v.paint){return v}if(zebra.isString(v)){return rgb.hasOwnProperty(v)?rgb[v]:(pkg.borders&&pkg.borders.hasOwnProperty(v)?pkg.borders[v]:new rgb(v))}if(Array.isArray(v)){return new pkg.CompositeView(v)}if(typeof v!=="function"){return new pkg.ViewSet(v)}v=new pkg.View();v.paint=f;return v};pkg.$detectZCanvas=function(canvas){if(zebra.isString(canvas)){canvas=document.getElementById(canvas)}for(var i=0;canvas!=null&&i<$canvases.length;i++){if($canvases[i].canvas==canvas){return $canvases[i]}}return null};pkg.View=Class([function $prototype(){this.gap=2;this.getRight=this.getLeft=this.getBottom=this.getTop=function(){return this.gap};this.getPreferredSize=function(){return{width:0,height:0}};this.paint=function(g,x,y,w,h,c){}}]);pkg.Render=Class(pkg.View,[function $prototype(){this[""]=function(target){this.setTarget(target)};this.setTarget=function(o){if(this.target!=o){var old=this.target;this.target=o;if(this.targetWasChanged){this.targetWasChanged(old,o)}}}}]);pkg.Raised=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor)},function(brightest,middle){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.brightest);g.drawLine(x1,y1,x2,y1);g.drawLine(x1,y1,x1,y2);g.setColor(this.middle);g.drawLine(x2,y1,x2,y2+1);g.drawLine(x1,y2,x2,y2)}}]);pkg.Sunken=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor,pkg.darkBrColor)},function(brightest,middle,darkest){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle;this.darkest=darkest==null?"black":darkest},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.middle);g.drawLine(x1,y1,x2-1,y1);g.drawLine(x1,y1,x1,y2-1);g.setColor(this.brightest);g.drawLine(x2,y1,x2,y2+1);g.drawLine(x1,y2,x2,y2);g.setColor(this.darkest);g.drawLine(x1+1,y1+1,x1+1,y2);g.drawLine(x1+1,y1+1,x2,y1+1)}}]);pkg.Etched=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor)},function(brightest,middle){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.middle);g.drawLine(x1,y1,x1,y2-1);g.drawLine(x2-1,y1,x2-1,y2);g.drawLine(x1,y1,x2,y1);g.drawLine(x1,y2-1,x2-1,y2-1);g.setColor(this.brightest);g.drawLine(x2,y1,x2,y2);g.drawLine(x1+1,y1+1,x1+1,y2-1);g.drawLine(x1+1,y1+1,x2-1,y1+1);g.drawLine(x1,y2,x2+1,y2)}}]);pkg.Dotted=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){g.setColor(this.color);g.drawDottedRect(x,y,w,h)};this[""]=function(c){this.color=(c==null)?"black":c}}]);pkg.Border=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.color==null){return}var ps=g.lineWidth;g.lineWidth=this.width;if(this.radius>0){this.outline(g,x,y,w,h,d)}else{var dt=this.width/2;g.beginPath();g.rect(x+dt,y+dt,w-this.width,h-this.width)}g.setColor(this.color);g.stroke();g.lineWidth=ps};this.outline=function(g,x,y,w,h,d){if(this.radius<=0){return false}var r=this.radius,dt=this.width/2,xx=x+w-dt,yy=y+h-dt;x+=dt;y+=dt;g.beginPath();g.moveTo(x-1+r,y);g.lineTo(xx-r,y);g.quadraticCurveTo(xx,y,xx,y+r);g.lineTo(xx,yy-r);g.quadraticCurveTo(xx,yy,xx-r,yy);g.lineTo(x+r,yy);g.quadraticCurveTo(x,yy,x,yy-r);g.lineTo(x,y+r);g.quadraticCurveTo(x,y,x+r,y);return true};this[""]=function(c,w,r){this.color=(arguments.length===0)?"gray":c;this.width=(w==null)?1:w;this.radius=(r==null)?0:r;this.gap=this.width+Math.round(this.radius/4)}}]);pkg.RoundBorder=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.color!=null&&this.width>0){this.outline(g,x,y,w,h,d);g.setColor(this.color);g.stroke()}};this.outline=function(g,x,y,w,h,d){g.beginPath();g.lineWidth=this.width;g.arc(x+w/2,y+h/2,w/2,0,2*Math.PI,false);return true};this[""]=function(col,width){this.color=null;this.width=1;if(arguments.length>0){if(zebra.isNumber(col)){this.width=col}else{this.color=col;if(zebra.isNumber(width)){this.width=width}}}this.gap=this.width}}]);pkg.Gradient=Class(pkg.View,[function $prototype(){this[""]=function(){this.colors=Array.prototype.slice.call(arguments,0);if(zebra.isNumber(arguments[arguments.length-1])){this.orientation=arguments[arguments.length-1];this.colors.pop()}else{this.orientation=L.VERTICAL}};this.paint=function(g,x,y,w,h,dd){var d=(this.orientation==L.HORIZONTAL?[0,1]:[1,0]),x1=x*d[1],y1=y*d[0],x2=(x+w-1)*d[1],y2=(y+h-1)*d[0];if(this.gradient==null||this.gx1!=x1||this.gx2!=x2||this.gy1!=y1||this.gy2!=y2){this.gx1=x1;this.gx2=x2;this.gy1=y1;this.gy2=y2;this.gradient=g.createLinearGradient(x1,y1,x2,y2);for(var i=0;i4){this.x=x;this.y=y;this.width=w;this.height=h}else{this.x=this.y=this.width=this.height=0}if(zebra.isBoolean(arguments[arguments.length-1])===false){ub=w>0&&h>0&&w<64&&h<64}if(ub===true){this.buffer=document.createElement("canvas");this.buffer.width=0}};this.paint=function(g,x,y,w,h,d){if(this.target!=null&&w>0&&h>0){var img=this.target;if(this.buffer){img=this.buffer;if(img.width<=0){var ctx=img.getContext("2d");if(this.width>0){img.width=this.width;img.height=this.height;ctx.drawImage(this.target,this.x,this.y,this.width,this.height,0,0,this.width,this.height)}else{img.width=this.target.width;img.height=this.target.height;ctx.drawImage(this.target,0,0)}}}if(this.width>0&&!this.buffer){g.drawImage(img,this.x,this.y,this.width,this.height,x,y,w,h)}else{g.drawImage(img,x,y,w,h)}}};this.targetWasChanged=function(o,n){if(this.buffer){delete this.buffer}};this.getPreferredSize=function(){var img=this.target;return img==null?{width:0,height:0}:(this.width>0)?{width:this.width,height:this.height}:{width:img.width,height:img.height}}}]);pkg.Pattern=Class(pkg.Render,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.pattern==null){this.pattern=g.createPattern(this.target,"repeat")}g.rect(x,y,w,h);g.fillStyle=this.pattern;g.fill()}}]);pkg.CompositeView=Class(pkg.View,[function $prototype(){this.left=this.right=this.bottom=this.top=this.height=this.width=0;this.getTop=function(){return this.top};this.getLeft=function(){return this.left};this.getBottom=function(){return this.bottom};this.getRight=function(){return this.right};this.getPreferredSize=function(){return{width:this.width,height:this.height}};this.$recalc=function(v){var b=0,ps=v.getPreferredSize();if(v.getLeft){b=v.getLeft();if(b>this.left){this.left=b}}if(v.getRight){b=v.getRight();if(b>this.right){this.right=b}}if(v.getTop){b=v.getTop();if(b>this.top){this.top=b}}if(v.getBottom){b=v.getBottom();if(b>this.bottom){this.bottom=b}}if(ps.width>this.width){this.width=ps.width}if(ps.height>this.height){this.height=ps.height}if(this.voutline==null&&v.outline){this.voutline=v}};this.paint=function(g,x,y,w,h,d){for(var i=0;i1&&id[0]!="*"&&id[id.length-1]!="*"){var i=id.indexOf(".");if(i>0){var k=id.substring(0,i+1).concat("*");if(this.views.hasOwnProperty(k)){return(this.activeView=this.views[k])!=old}else{k="*"+id.substring(i);if(this.views.hasOwnProperty(k)){return(this.activeView=this.views[k])!=old}}}}}if(this.views.hasOwnProperty("*")){return(this.activeView=this.views["*"])!=old}return false};this[""]=function(args){if(args==null){throw new Error("Invalid null view set")}this.views={};this.activeView=null;for(var k in args){this.views[k]=pkg.$view(args[k]);if(this.views[k]){this.$recalc(this.views[k])}}this.activate("*")}}]);pkg.Bag=Class(zebra.util.Bag,[function $prototype(){this.usePropertySetters=true;this.contentLoaded=function(v){if(v==null||zebra.isNumber(v)||zebra.isBoolean(v)){return v}if(zebra.isString(v)){if(this.root&&v[0]=="%"&&v[1]=="r"){var s="%root%/";if(v.indexOf(s)===0){return this.root.join(v.substring(s.length))}}return v}if(Array.isArray(v)){for(var i=0;i0&&c.height>0&&c.isVisible){var p=c.parent,px=-c.x,py=-c.y;if(r==null){r={x:0,y:0,width:0,height:0}}else{r.x=r.y=0}r.width=c.width;r.height=c.height;while(p!=null&&r.width>0&&r.height>0){var xx=r.x>px?r.x:px,yy=r.y>py?r.y:py,w1=r.x+r.width,w2=px+p.width,h1=r.y+r.height,h2=py+p.height;r.width=(w10&&r.height>0?r:null}return null};pkg.configure=function(c){if(zebra.isString(c)){var path=c;c=function(conf){conf.loadByUrl(path,false)}}$configurators.push(c)};pkg.Font=function(name,style,size){if(arguments.length==1){name=name.replace(/[ ]+/," ");this.s=name.trim()}else{if(arguments.length==2){size=style;style=""}style=style.trim();this.s=[style,(style!==""?" ":""),size,"px ",name].join("")}$fmText.style.font=this.s;this.height=$fmText.offsetHeight;if(this.height===0){this.height=$fmText.offsetHeight}this.ascent=$fmImage.offsetTop-$fmText.offsetTop+1};pkg.Font.prototype.stringWidth=function(s){if(s.length===0){return 0}if($fmCanvas.font!=this.s){$fmCanvas.font=this.s}return($fmCanvas.measureText(s).width+0.5)|0};pkg.Font.prototype.charsWidth=function(s,off,len){if($fmCanvas.font!=this.s){$fmCanvas.font=this.s}return($fmCanvas.measureText(len==1?s[off]:s.substring(off,off+len)).width+0.5)|0};pkg.Font.prototype.toString=function(){return this.s};pkg.Cursor={DEFAULT:"default",MOVE:"move",WAIT:"wait",TEXT:"text",HAND:"pointer",NE_RESIZE:"ne-resize",SW_RESIZE:"sw-resize",SE_RESIZE:"se-resize",NW_RESIZE:"nw-resize",S_RESIZE:"s-resize",W_RESIZE:"w-resize",N_RESIZE:"n-resize",E_RESIZE:"e-resize",COL_RESIZE:"col-resize",HELP:"help"};var MouseListener=pkg.MouseListener=Interface(),FocusListener=pkg.FocusListener=Interface(),KeyListener=pkg.KeyListener=Interface(),Composite=pkg.Composite=Interface(),ChildrenListener=pkg.ChildrenListener=Interface(),CopyCutPaste=pkg.CopyCutPaste=Interface(),CL=pkg.ComponentListener=Interface();CL.ENABLED=1;CL.SHOWN=2;CL.MOVED=3;CL.SIZED=4;CL.ADDED=5;CL.REMOVED=6;var IE=pkg.InputEvent=Class([function $clazz(){this.MOUSE_UID=1;this.KEY_UID=2;this.FOCUS_UID=3;this.FOCUS_LOST=10;this.FOCUS_GAINED=11},function(target,id,uid){this.source=target;this.ID=id;this.UID=uid}]);var KE=pkg.KeyEvent=Class(IE,[function $clazz(){this.TYPED=15;this.RELEASED=16;this.PRESSED=17;this.M_CTRL=1;this.M_SHIFT=2;this.M_ALT=4;this.M_CMD=8},function $prototype(){this.reset=function(target,id,code,ch,mask){this.source=target;this.ID=id;this.code=code;this.mask=mask;this.ch=ch};this.isControlPressed=function(){return(this.mask&KE.M_CTRL)>0};this.isShiftPressed=function(){return(this.mask&KE.M_SHIFT)>0};this.isAltPressed=function(){return(this.mask&KE.M_ALT)>0};this.isCmdPressed=function(){return(this.mask&KE.M_CMD)>0}},function(target,id,code,ch,mask){this.$super(target,id,IE.KEY_UID);this.reset(target,id,code,ch,mask)}]);var ME=pkg.MouseEvent=Class(IE,[function $clazz(){this.CLICKED=21;this.PRESSED=22;this.RELEASED=23;this.ENTERED=24;this.EXITED=25;this.DRAGGED=26;this.DRAGSTARTED=27;this.DRAGENDED=28;this.MOVED=29;this.LEFT_BUTTON=128;this.RIGHT_BUTTON=512},function $prototype(){this.touchCounter=1;this.reset=function(target,id,ax,ay,mask,clicks){this.source=target;this.ID=id;this.absX=ax;this.absY=ay;this.mask=mask;this.clicks=clicks;var p=L.getTopParent(target);while(target!=p){ax-=target.x;ay-=target.y;target=target.parent}this.x=ax;this.y=ay};this.isActionMask=function(){return this.mask==ME.LEFT_BUTTON}},function(target,id,ax,ay,mask,clicks){this.$super(target,id,IE.MOUSE_UID);this.reset(target,id,ax,ay,mask,clicks)}]);var MDRAGGED=ME.DRAGGED,EM=null,MMOVED=ME.MOVED,MEXITED=ME.EXITED,KPRESSED=KE.PRESSED,MENTERED=ME.ENTERED,context=Object.getPrototypeOf(document.createElement("canvas").getContext("2d")),$mousePressedEvents={},$keyPressedCode=-1,$keyPressedOwner=null,$keyPressedModifiers=0,KE_STUB=new KE(null,KPRESSED,0,"x",0),ME_STUB=new ME(null,ME.PRESSED,0,0,0,1);pkg.paintManager=pkg.events=pkg.$mouseMoveOwner=null;document.addEventListener("mouseup",function(e){for(var k in $mousePressedEvents){var mp=$mousePressedEvents[k];if(mp.canvas!=null){mp.canvas.mouseReleased(k,mp)}}},false);var $alert=(function(){return this.alert}());window.alert=function(){if($keyPressedCode>0){KE_STUB.reset($keyPressedOwner,KE.RELEASED,$keyPressedCode,"",$keyPressedModifiers);EM.performInput(KE_STUB);$keyPressedCode=-1}$alert.apply(window,arguments);for(var k in $mousePressedEvents){var mp=$mousePressedEvents[k];if(mp.canvas!=null){mp.canvas.mouseReleased(k,mp)}}};context.setFont=function(f){f=(f.s!=null?f.s:f.toString());if(f!=this.font){this.font=f}};context.setColor=function(c){if(c==null){throw new Error("Null color")}c=(c.s?c.s:c.toString());if(c!=this.fillStyle){this.fillStyle=c}if(c!=this.strokeStyle){this.strokeStyle=c}};context.drawLine=function(x1,y1,x2,y2,w){if(arguments.length<5){w=1}var pw=this.lineWidth;this.beginPath();this.lineWidth=w;if(x1==x2){x1+=w/2;x2=x1}else{if(y1==y2){y1+=w/2;y2=y1}}this.moveTo(x1,y1);this.lineTo(x2,y2);this.stroke();this.lineWidth=pw};context.ovalPath=function(x,y,w,h){this.beginPath();x+=this.lineWidth;y+=this.lineWidth;w-=2*this.lineWidth;h-=2*this.lineWidth;var kappa=0.5522848,ox=(w/2)*kappa,oy=(h/2)*kappa,xe=x+w,ye=y+h,xm=x+w/2,ym=y+h/2;this.moveTo(x,ym);this.bezierCurveTo(x,ym-oy,xm-ox,y,xm,y);this.bezierCurveTo(xm+ox,y,xe,ym-oy,xe,ym);this.bezierCurveTo(xe,ym+oy,xm+ox,ye,xm,ye);this.bezierCurveTo(xm-ox,ye,x,ym+oy,x,ym)};context.polylinePath=function(xPoints,yPoints,nPoints){this.beginPath();this.moveTo(xPoints[0],yPoints[0]);for(var i=1;iMath.abs(dy)),slope=b?dy/dx:dx/dy,sign=b?(dx<0?-1:1):(dy<0?-1:1);if(b){compute=function(step){x+=step;y+=slope*step}}else{compute=function(step){x+=slope*step;y+=step}}ctx.moveTo(x,y);var dist=Math.sqrt(dx*dx+dy*dy),i=0;while(dist>=0.1){var idx=i%count;dl=distd.width-right){xx=d.width+right-ww}if(yy+hh>d.height-bottom){yy=d.height+bottom-hh}c.setLocation(xx,yy)};pkg.calcOrigin=function(x,y,w,h,px,py,t,tt,ll,bb,rr){if(arguments.length<8){tt=t.getTop();ll=t.getLeft();bb=t.getBottom();rr=t.getRight()}var dw=t.width,dh=t.height;if(dw>0&&dh>0){if(dw-ll-rr>w){var xx=x+px;if(xxdw-rr){px-=(xx-dw+rr)}}}if(dh-tt-bb>h){var yy=y+py;if(yydh-bb){py-=(yy-dh+bb)}}}return[px,py]}return[0,0]};pkg.loadImage=function(path,ready){var i=new Image();i.crossOrigin="";i.crossOrigin="anonymous";zebra.busy();if(arguments.length>1){i.onerror=function(){zebra.ready();ready(path,false,i)};i.onload=function(){zebra.ready();ready(path,true,i)}}else{i.onload=i.onerror=function(){zebra.ready()}}i.src=path;return i};pkg.Panel=Class(L.Layoutable,[function $prototype(){this.top=this.left=this.right=this.bottom=0;this.isEnabled=true;this.getCanvas=function(){var c=this;for(;c!=null&&c.$isMasterCanvas!==true;c=c.parent){}return c};this.notifyRender=function(o,n){if(o!=null&&o.ownerChanged){o.ownerChanged(null)}if(n!=null&&n.ownerChanged){n.ownerChanged(this)}};this.properties=function(p){for(var k in p){if(p.hasOwnProperty(k)){var v=p[k],m=zebra.getPropertySetter(this,k);if(v&&v.$new){v=v.$new()}if(m==null){this[k]=v}else{if(Array.isArray(v)){m.apply(this,v)}else{m.call(this,v)}}}}return this};this.load=function(jsonPath){new pkg.Bag(this).loadByUrl(jsonPath);return this};this.getComponentAt=function(x,y){var r=$cvp(this,temporary);if(r==null||(x=r.x+r.width||y>=r.y+r.height)){return null}var k=this.kids;if(k.length>0){for(var i=k.length;--i>=0;){var d=k[i];d=d.getComponentAt(x-d.x,y-d.y);if(d!=null){return d}}}return this.contains==null||this.contains(x,y)?this:null};this.vrp=function(){this.invalidate();if(this.isVisible&&this.parent!=null){this.repaint()}};this.getTop=function(){return this.border!=null?this.top+this.border.getTop():this.top};this.getLeft=function(){return this.border!=null?this.left+this.border.getLeft():this.left};this.getBottom=function(){return this.border!=null?this.bottom+this.border.getBottom():this.bottom};this.getRight=function(){return this.border!=null?this.right+this.border.getRight():this.right};this.isInvalidatedByChild=function(c){return true};this.kidAdded=function(index,constr,l){pkg.events.performComp(CL.ADDED,this,constr,l);if(l.width>0&&l.height>0){l.repaint()}else{this.repaint(l.x,l.y,1,1)}};this.kidRemoved=function(i,l){pkg.events.performComp(CL.REMOVED,this,null,l);if(l.isVisible){this.repaint(l.x,l.y,l.width,l.height)}};this.relocated=function(px,py){pkg.events.performComp(CL.MOVED,this,px,py);var p=this.parent,w=this.width,h=this.height;if(p!=null&&w>0&&h>0){var x=this.x,y=this.y,nx=xpx?x-px:px-x),h1=p.height-ny,h2=h+(y>py?y-py:py-y);pkg.paintManager.repaint(p,nx,ny,(w1pw)?this.width:pw,(this.height>ph)?this.height:ph)}};this.hasFocus=function(){return pkg.focusManager.hasFocus(this)};this.requestFocus=function(){pkg.focusManager.requestFocus(this)};this.requestFocusIn=function(timeout){if(arguments.length===0){timeout=50}var $this=this;setTimeout(function(){$this.requestFocus()},timeout)};this.setVisible=function(b){if(this.isVisible!=b){this.isVisible=b;this.invalidate();pkg.events.performComp(CL.SHOWN,this,-1,-1);if(this.parent!=null){if(b){this.repaint()}else{this.parent.repaint(this.x,this.y,this.width,this.height)}}}};this.setEnabled=function(b){if(this.isEnabled!=b){this.isEnabled=b;pkg.events.performComp(CL.ENABLED,this,-1,-1);if(this.kids.length>0){for(var i=0;i1){for(var i=0;i0&&this.height>0&&pkg.paintManager!=null){pkg.paintManager.repaint(this,x,y,w,h)}};this.removeAll=function(){if(this.kids.length>0){var size=this.kids.length,mx1=Number.MAX_VALUE,my1=mx1,mx2=0,my2=0;for(;size>0;size--){var child=this.kids[size-1];if(child.isVisible){var xx=child.x,yy=child.y;mx1=mx10){if(instanceOf(l,L.Layout)){this.setLayout(l)}else{this.properties(l)}}}}]);pkg.BaseLayer=Class(pkg.Panel,[function $prototype(){this.getFocusRoot=function(){return this};this.activate=function(b){var fo=pkg.focusManager.focusOwner;if(L.isAncestorOf(this,fo)===false){fo=null}if(b){pkg.focusManager.requestFocus(fo!=null?fo:this.pfo)}else{this.pfo=fo;pkg.focusManager.requestFocus(null)}}},function(id){if(id==null){throw new Error("Invalid layer id: "+id)}this.pfo=null;this.$super();this.id=id}]);pkg.RootLayer=Class(pkg.BaseLayer,[function $prototype(){this.layerMousePressed=function(x,y,m){return true};this.layerKeyPressed=function(code,m){return true}}]);pkg.ViewPan=Class(pkg.Panel,[function $prototype(){this.paint=function(g){if(this.view!=null){var l=this.getLeft(),t=this.getTop();this.view.paint(g,l,t,this.width-l-this.getRight(),this.height-t-this.getBottom(),this)}};this.setView=function(v){var old=this.view;v=pkg.$view(v);if(v!=old){this.view=v;this.notifyRender(old,v);this.vrp()}};this.calcPreferredSize=function(t){return this.view?this.view.getPreferredSize():{width:0,height:0}}}]);pkg.ImagePan=Class(pkg.ViewPan,[function(){this.$this(null)},function(img){this.setImage(img);this.$super()},function setImage(img){if(img&&zebra.isString(img)){var $this=this;pkg.loadImage(img,function(p,b,i){if(b){$this.setView(new pkg.Picture(i))}});return}this.setView(instanceOf(img,pkg.Picture)?img:new pkg.Picture(img))}]);pkg.Manager=Class([function(){if(pkg.events!=null&&pkg.events.addListener!=null){pkg.events.addListener(this)}}]);pkg.PaintManager=Class(pkg.Manager,[function $prototype(){var $painting={};var $timers={};this.repaint=function(c,x,y,w,h){if(arguments.length==1){x=y=0;w=c.width;h=c.height}if(w>0&&h>0&&c.isVisible===true){var r=$cvp(c,temporary);if(r==null){return}MB.intersection(r.x,r.y,r.width,r.height,x,y,w,h,r);if(r.width<=0||r.height<=0){return}x=r.x;y=r.y;w=r.width;h=r.height;var canvas=c;for(;canvas!=null&&canvas.$context==null;canvas=canvas.parent){}if(canvas!=null){var x2=canvas.width,y2=canvas.height;var cc=c;while(cc!=canvas){x+=cc.x;y+=cc.y;cc=cc.parent}if(x<0){w+=x;x=0}if(y<0){h+=y;y=0}if(w+x>x2){w=x2-x}if(h+y>y2){h=y2-y}if(w>0&&h>0){if($painting[canvas]!=null){zebra.warn("repaint called synchronously from paint, update, or paintOnTop ignored!");return}var da=canvas.$da;if($timers[canvas]!=null){if(xda.x+da.width||y+h>da.y+da.height){MB.unite(da.x,da.y,da.width,da.height,x,y,w,h,da)}return}MB.intersection(0,0,canvas.width,canvas.height,x,y,w,h,da);var $this=this;$timers[canvas]=setTimeout(function(){$timers[canvas]=null;var context=canvas.$context;$painting[canvas]=true;try{canvas.validate();context.save();context.translate(canvas.x,canvas.y);context.clipRect(canvas.$da.x,canvas.$da.y,canvas.$da.width,canvas.$da.height);if(canvas.bg==null){context.clearRect(canvas.$da.x,canvas.$da.y,canvas.$da.width,canvas.$da.height)}$this.paint(context,canvas);context.restore()}catch(e){zebra.print(e)}$painting[canvas]=null},50)}}}};this.paint=function(g,c){var dw=c.width,dh=c.height,ts=g.stack[g.counter];if(dw!==0&&dh!==0&&ts.width>0&&ts.height>0&&c.isVisible){c.validate();g.save();g.translate(c.x,c.y);g.clipRect(0,0,dw,dh);ts=g.stack[g.counter];var c_w=ts.width,c_h=ts.height;if(c_w>0&&c_h>0){this.paintComponent(g,c);var count=c.kids.length,c_x=ts.x,c_y=ts.y;for(var i=0;ic_x?kidX:c_x),ih=(kidYHc_y?kidY:c_y);if(iw>0&&ih>0){this.paint(g,kid)}}}if(c.paintOnTop!=null){c.paintOnTop(g)}}g.restore()}}}]);pkg.PaintManImpl=Class(pkg.PaintManager,[function $prototype(){this.paintComponent=function(g,c){var b=c.bg!=null&&(c.parent==null||c.bg!=c.parent.bg);if((c.border!=null&&c.border.outline!=null)&&(b||c.update!=null)&&c.border.outline(g,0,0,c.width,c.height,c)){g.save();g.clip();if(b){c.bg.paint(g,0,0,c.width,c.height,c)}if(c.update!=null){c.update(g)}g.restore()}else{if(b){c.bg.paint(g,0,0,c.width,c.height,c)}if(c.update!=null){c.update(g)}}if(c.border!=null){c.border.paint(g,0,0,c.width,c.height,c)}if(c.paint!=null){var left=c.getLeft(),top=c.getTop(),bottom=c.getBottom(),right=c.getRight();if(left+right+top+bottom>0){var ts=g.stack[g.counter];if(ts.width>0&&ts.height>0){var cx=ts.x,cy=ts.y,x1=(cx>left?cx:left),y1=(cy>top?cy:top),cxcw=cx+ts.width,cych=cy+ts.height,cright=c.width-right,cbottom=c.height-bottom;g.save();g.clipRect(x1,y1,(cxcw0){var isNComposite=(instanceOf(t,Composite)===false);for(var i=index;i>=0&&i0&&cc.height>0&&(isNComposite||(t.catchInput&&t.catchInput(cc)===false))&&((cc.canHaveFocus&&cc.canHaveFocus())||(cc=this.fd(cc,d>0?0:cc.kids.length-1,d))!=null)){return cc}}}return null};this.ff=function(c,d){var top=c;while(top&&top.getFocusRoot==null){top=top.parent}top=top.getFocusRoot();for(var index=(d>0)?0:c.kids.length-1;c!=top.parent;){var cc=this.fd(c,index,d);if(cc!=null){return cc}cc=c;c=c.parent;if(c!=null){index=d+c.indexOf(cc)}}return this.fd(top,d>0?0:top.kids.length-1,d)};this.requestFocus=function(c){if(c!=this.focusOwner&&(c==null||this.isFocusable(c))){if(c!=null){var canvas=c.getCanvas();if(canvas.$focusGainedCounter===0){canvas.$prevFocusOwner=c;if(zebra.instanceOf(canvas.$prevFocusOwner,pkg.HtmlElement)==false){canvas.requestFocus();return}}}var oldFocusOwner=this.focusOwner;if(c!=null){var nf=EM.getEventDestination(c);if(nf==null||oldFocusOwner==nf){return}this.focusOwner=nf}else{this.focusOwner=c}if(oldFocusOwner!=null){var ofc=oldFocusOwner.getCanvas();if(ofc!=null){ofc.$prevFocusOwner=oldFocusOwner}}if(oldFocusOwner!=null){pkg.events.performInput(new IE(oldFocusOwner,IE.FOCUS_LOST,IE.FOCUS_UID))}if(this.focusOwner!=null){pkg.events.performInput(new IE(this.focusOwner,IE.FOCUS_GAINED,IE.FOCUS_UID))}return this.focusOwner}return null};this.mousePressed=function(e){if(e.isActionMask()){this.requestFocus(e.source)}}}]);pkg.CommandManager=Class(pkg.Manager,KeyListener,[function $prototype(){this.keyPressed=function(e){var fo=pkg.focusManager.focusOwner;if(fo!=null&&this.keyCommands[e.code]){var c=this.keyCommands[e.code];if(c&&c[e.mask]!=null){c=c[e.mask];this._.fired(c);if(fo[c.command]){if(c.args&&c.args.length>0){fo[c.command].apply(fo,c.args)}else{fo[c.command]()}}}}};this.parseKey=function(k){var m=0,c=0,r=k.split("+");for(var i=0;i25){for(var i=0;i=0)||c.push(l)};this.r_=function(c,l){(c.indexOf(l)<0)||c.splice(i,1)}},function(){this.m_l=[];this.k_l=[];this.f_l=[];this.c_l=[];this.$super()}]);pkg.$createContext=function(canvas,w,h){var ctx=canvas.getContext("2d");var $save=ctx.save,$restore=ctx.restore,$rotate=ctx.rotate,$scale=ctx.$scale=ctx.scale,$translate=ctx.translate,$getImageData=ctx.getImageData;ctx.$ratio=$ratio/(ctx.webkitBackingStorePixelRatio||ctx.mozBackingStorePixelRatio||ctx.msBackingStorePixelRatio||ctx.backingStorePixelRatio||1);ctx.counter=0;ctx.stack=Array(50);for(var i=0;ixx?x:xx;c.width=(xwyy?y:yy;c.height=(yh0){var fo=pkg.focusManager.focusOwner;if(fo!=null){KE_STUB.reset(fo,KE.TYPED,e.keyCode,String.fromCharCode(e.charCode),km(e));if(EM.performInput(KE_STUB)){e.preventDefault()}}}if(e.keyCode<47){e.preventDefault()}};this.keyPressed=function(e){$keyPressedCode=e.keyCode;var code=e.keyCode,m=km(e),b=false;for(var i=this.kids.length-1;i>=0;i--){var l=this.kids[i];if(l.layerKeyPressed&&l.layerKeyPressed(code,m)){break}}var focusOwner=pkg.focusManager.focusOwner;if(pkg.clipboardTriggerKey>0&&e.keyCode==pkg.clipboardTriggerKey&&focusOwner!=null&&instanceOf(focusOwner,CopyCutPaste)){$clipboardCanvas=this;$clipboard.style.display="block";this.canvas.onfocus=this.canvas.onblur=null;$clipboard.value="1";$clipboard.select();$clipboard.focus();return}$keyPressedOwner=focusOwner;$keyPressedModifiers=m;if(focusOwner!=null){KE_STUB.reset(focusOwner,KPRESSED,code,code<47?KE.CHAR_UNDEFINED:"?",m);b=EM.performInput(KE_STUB);if(code==KE.ENTER){KE_STUB.reset(focusOwner,KE.TYPED,code,"\n",m);b=EM.performInput(KE_STUB)||b}}if((code<47&&code!=32)||b){e.preventDefault()}};this.keyReleased=function(e){$keyPressedCode=-1;var fo=pkg.focusManager.focusOwner;if(fo!=null){KE_STUB.reset(fo,KE.RELEASED,e.keyCode,KE.CHAR_UNDEFINED,km(e));if(EM.performInput(KE_STUB)){e.preventDefault()}}};this.mouseEntered=function(id,e){var mp=$mousePressedEvents[id];this.recalcOffset();if(mp==null||mp.canvas==null){var x=$meX(e,this),y=$meY(e,this),d=this.getComponentAt(x,y);if(pkg.$mouseMoveOwner!=null&&d!=pkg.$mouseMoveOwner){var prev=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(prev,MEXITED,x,y,-1,0);EM.performInput(ME_STUB)}if(d!=null&&d.isEnabled){pkg.$mouseMoveOwner=d;ME_STUB.reset(d,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}};this.mouseExited=function(id,e){var mp=$mousePressedEvents[id];if((mp==null||mp.canvas==null)&&pkg.$mouseMoveOwner!=null){var p=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(p,MEXITED,$meX(e,this),$meY(e,this),-1,0);EM.performInput(ME_STUB)}};this.mouseMoved=function(id,e){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){if(mp.component!=null&&mp.canvas.canvas==e.target){var x=this.$context.tX(e.pageX-this.offx,e.pageY-this.offy),y=this.$context.tY(e.pageX-this.offx,e.pageY-this.offy),m=mp.button;if(mp.draggedComponent==null){var xx=this.$context.tX(mp.pageX-this.offx,mp.pageY-this.offy),yy=this.$context.tY(mp.pageX-this.offx,mp.pageY-this.offy),d=(pkg.$mouseMoveOwner==null)?this.getComponentAt(xx,yy):pkg.$mouseMoveOwner;if(d!=null&&d.isEnabled===true){mp.draggedComponent=d;ME_STUB.reset(d,ME.DRAGSTARTED,xx,yy,m,0);EM.performInput(ME_STUB);if(xx!=x||yy!=y){ME_STUB.reset(d,MDRAGGED,x,y,m,0);EM.performInput(ME_STUB)}}}else{ME_STUB.reset(mp.draggedComponent,MDRAGGED,x,y,m,0);EM.performInput(ME_STUB)}}}else{var x=this.$context.tX(e.pageX-this.offx,e.pageY-this.offy),y=this.$context.tY(e.pageX-this.offx,e.pageY-this.offy),d=this.getComponentAt(x,y);if(pkg.$mouseMoveOwner!=null){if(d!=pkg.$mouseMoveOwner){var old=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(old,MEXITED,x,y,-1,0);EM.performInput(ME_STUB);if(d!=null&&d.isEnabled===true){pkg.$mouseMoveOwner=d;ME_STUB.reset(pkg.$mouseMoveOwner,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}else{if(d!=null&&d.isEnabled){ME_STUB.reset(d,MMOVED,x,y,-1,0);EM.performInput(ME_STUB)}}}else{if(d!=null&&d.isEnabled===true){pkg.$mouseMoveOwner=d;ME_STUB.reset(d,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}}};this.mouseReleased=function(id,e){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){var x=$meX(e,this),y=$meY(e,this),po=mp.component;if(mp.draggedComponent!=null){ME_STUB.reset(mp.draggedComponent,ME.DRAGENDED,x,y,mp.button,0);EM.performInput(ME_STUB)}if(po!=null){if(mp.draggedComponent==null&&(e.touch==null||e.touch.group==null)){ME_STUB.reset(po,ME.CLICKED,x,y,mp.button,mp.clicks);EM.performInput(ME_STUB)}ME_STUB.reset(po,ME.RELEASED,x,y,mp.button,mp.clicks);EM.performInput(ME_STUB)}if(zebra.isTouchable===false){var mo=pkg.$mouseMoveOwner;if(mp.draggedComponent!=null||(po!=null&&po!=mo)){var nd=this.getComponentAt(x,y);if(nd!=mo){if(mo!=null){ME_STUB.reset(mo,MEXITED,x,y,-1,0);EM.performInput(ME_STUB)}if(nd!=null&&nd.isEnabled===true){pkg.$mouseMoveOwner=nd;ME_STUB.reset(nd,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}}}$mousePressedEvents[id].canvas=null}};this.mousePressed=function(id,e,button){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){this.mouseReleased(id,mp)}var clicks=mp!=null&&(new Date().getTime()-mp.time)<=pkg.doubleClickDelta?2:1;mp=$mousePressedEvents[id]={pageX:e.pageX,pageY:e.pageY,identifier:id,target:e.target,canvas:this,button:button,component:null,mouseDragged:null,time:(new Date()).getTime(),clicks:clicks};var x=$meX(e,this),y=$meY(e,this);mp.x=x;mp.y=y;for(var i=this.kids.length-1;i>=0;i--){var l=this.kids[i];if(l.layerMousePressed!=null&&l.layerMousePressed(x,y,button)){break}}var d=this.getComponentAt(x,y);if(d!=null&&d.isEnabled===true){mp.component=d;ME_STUB.reset(d,ME.PRESSED,x,y,button,clicks);EM.performInput(ME_STUB)}if(document.activeElement!=this.canvas){this.canvas.focus()}};this.getComponentAt=function(x,y){for(var i=this.kids.length;--i>=0;){var tl=this.kids[i];if(tl.isLayerActiveAt==null||tl.isLayerActiveAt(x,y)){return EM.getEventDestination(tl.getComponentAt(x,y))}}return null};this.recalcOffset=function(){var poffx=this.offx,poffy=this.offy,ba=this.canvas.getBoundingClientRect();this.offx=((ba.left+0.5)|0)+measure(this.canvas,"padding-left")+window.pageXOffset;this.offy=((ba.top+0.5)|0)+measure(this.canvas,"padding-top")+window.pageYOffset;if(this.offx!=poffx||this.offy!=poffy){this.relocated(this,poffx,poffy)}};this.getLayer=function(id){return this[id]};this.setStyles=function(styles){for(var k in styles){this.canvas.style[k]=styles[k]}};this.setAttribute=function(name,value){this.canvas.setAttribute(name,value)};this.relocated=function(px,py){pkg.events.performComp(CL.MOVED,this,px,py)};this.resized=function(pw,ph){pkg.events.performComp(CL.SIZED,this,pw,ph)};this.repaint=function(x,y,w,h){if((document.contains!=null&&document.contains(this.canvas)===false)||this.canvas.style.visibility=="hidden"){return}if(arguments.length===0){x=y=0;w=this.width;h=this.height}if(w>0&&h>0&&pkg.paintManager!=null){pkg.paintManager.repaint(this,x,y,w,h)}}},function(){this.$this(400,400)},function(w,h){this.$this(this.toString(),w,h)},function(canvas){this.$this(canvas,-1,-1)},function(canvas,w,h){this.$focusGainedCounter=0;var pc=canvas,$this=this;this.nativeListeners={onmousemove:null,onmousedown:null,onmouseup:null,onmouseover:null,onmouseout:null,onkeydown:null,onkeyup:null,onkeypress:null};var addToBody=true;if(zebra.isBoolean(canvas)){addToBody=canvas;canvas=null}else{if(zebra.isString(canvas)){canvas=document.getElementById(canvas);if(canvas!=null&&pkg.$detectZCanvas(canvas)){throw new Error("Canvas id='"+pc+"'' is already in use")}}}if(canvas==null){canvas=document.createElement("canvas");canvas.setAttribute("class","zebcanvas");canvas.setAttribute("width",w<=0?"400":""+w);canvas.setAttribute("height",h<=0?"400":""+h);canvas.setAttribute("id",pc);if(addToBody){document.body.appendChild(canvas)}}if(canvas.getAttribute("tabindex")===null){canvas.setAttribute("tabindex","1")}this.$da={x:0,y:0,width:-1,height:0};this.canvas=canvas;this.$super(new pkg.zCanvas.Layout());for(var i=0;i0){e.preventDefault();return}if(pkg.focusManager.canvasFocusGained){pkg.focusManager.canvasFocusGained($this)}};this.canvas.onblur=function(e){if(document.activeElement==$this.canvas){e.preventDefault();return}if($this.$focusGainedCounter!==0){$this.$focusGainedCounter=0;if(pkg.focusManager.canvasFocusLost){pkg.focusManager.canvasFocusLost($this)}}};var addons=pkg.zCanvas.addons;if(addons){for(var i=0;i0){$configurators.shift()(pkg.$configuration)}pkg.$configuration.end();EM=pkg.events;if(pkg.clipboardTriggerKey>0){$clipboard=document.createElement("textarea");$clipboard.setAttribute("style","display:none; position: absolute; left: -99em; top:-99em;");$clipboard.onkeydown=function(ee){$clipboardCanvas.keyPressed(ee);$clipboard.value="1";$clipboard.select()};$clipboard.onkeyup=function(ee){if(ee.keyCode==pkg.clipboardTriggerKey){$clipboard.style.display="none";$clipboardCanvas.canvas.focus();$clipboardCanvas.canvas.onblur=$clipboardCanvas.focusLost;$clipboardCanvas.canvas.onfocus=$clipboardCanvas.focusGained}$clipboardCanvas.keyReleased(ee)};$clipboard.onblur=function(){this.value="";this.style.display="none";$clipboardCanvas.canvas.focus()};$clipboard.oncopy=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.copy){var v=pkg.focusManager.focusOwner.copy();$clipboard.value=v==null?"":v;$clipboard.select()}};$clipboard.oncut=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.cut){$clipboard.value=pkg.focusManager.focusOwner.cut();$clipboard.select()}};if(zebra.isFF){$clipboard.addEventListener("input",function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.paste){pkg.focusManager.focusOwner.paste($clipboard.value)}},false)}else{$clipboard.onpaste=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.paste){var txt=(typeof ee.clipboardData=="undefined")?window.clipboardData.getData("Text"):ee.clipboardData.getData("text/plain");pkg.focusManager.focusOwner.paste(txt)}$clipboard.value=""}}document.body.appendChild($clipboard)}document.addEventListener("DOMNodeInserted",function(e){elBoundsUpdated()},false);document.addEventListener("DOMNodeRemoved",function(e){elBoundsUpdated();for(var i=$canvases.length-1;i>=0;i--){var canvas=$canvases[i];if(e.target==canvas.canvas){$canvases.splice(i,1);if(canvas.saveBeforeLeave){canvas.saveBeforeLeave()}break}}},false);window.addEventListener("resize",function(e){elBoundsUpdated()},false);window.onbeforeunload=function(e){var msgs=[];for(var i=$canvases.length-1;i>=0;i--){if($canvases[i].saveBeforeLeave){var m=$canvases[i].saveBeforeLeave();if(m!=null){msgs.push(m)}}}if(msgs.length>0){var message=msgs.join(" ");if(typeof e==="undefined"){e=window.event}if(e){e.returnValue=message}return message}};if(zebra.isIE){window.focus()}}catch(e){zebra.error(e.toString());throw e}finally{zebra.ready()}})})(zebra("ui"),zebra.Class,zebra.Interface)})(); \ No newline at end of file diff --git a/lib/zebra/zebra.js b/lib/zebra/zebra.js index 1cfb7b57..ff6721fa 100644 --- a/lib/zebra/zebra.js +++ b/lib/zebra/zebra.js @@ -9047,6 +9047,7 @@ pkg.Manager = Class([ */ pkg.PaintManager = Class(pkg.Manager, [ function $prototype() { + var $painting = {}; var $timers = {}; /** @@ -9108,62 +9109,66 @@ pkg.PaintManager = Class(pkg.Manager, [ if (h + y > y2) h = y2 - y; if (w > 0 && h > 0) { + if ($painting[canvas] != null) { + //!!! Perhaps a better policy is to honor + // the repaint request anyway, but still + // emit a warning + zebra.warn('repaint called synchronously from paint, update, or paintOnTop ignored!'); + return; + } + var da = canvas.$da; - if (da.width > 0) { - if (x >= da.x && - y >= da.y && - x + w <= da.x + da.width && - y + h <= da.y + da.height ) - { - return; + if ($timers[canvas] != null) { + // paint is already scheduled, just need + // to update the dirty area + + if (x < da.x || + y < da.y || + x + w > da.x + da.width || + y + h > da.y + da.height ) + { + MB.unite(da.x, da.y, da.width, da.height, x, y, w, h, da); } - MB.unite(da.x, da.y, da.width, da.height, x, y, w, h, da); - } - else { - MB.intersection(0, 0, canvas.width, canvas.height, x, y, w, h, da); + return; } - if (da.width > 0 && $timers[canvas] == null) { - var $this = this; - $timers[canvas] = setTimeout(function() { - $timers[canvas] = null; + MB.intersection(0, 0, canvas.width, canvas.height, x, y, w, h, da); - // prevent double painting, sometimes - // width can be -1 what cause clearRect - // clean incorrectly - if (canvas.$da.width <= 0) { - return ; + var $this = this; + $timers[canvas] = setTimeout(function() { + $timers[canvas] = null; + + var context = canvas.$context; + // record that we are painting to warn + // if repaint is called recursively + $painting[canvas] = true; + try { + canvas.validate(); + context.save(); + context.translate(canvas.x, canvas.y); + + //!!!! debug + // zebra.print(" ============== DA = " + canvas.$da.y ); + // var dg = canvas.canvas.getContext("2d"); + // dg.strokeStyle = 'red'; + // dg.beginPath(); + // dg.rect(da.x, da.y, da.width, da.height); + // dg.stroke(); + + context.clipRect(canvas.$da.x, canvas.$da.y, + canvas.$da.width, canvas.$da.height); + if (canvas.bg == null) { + context.clearRect(canvas.$da.x, canvas.$da.y, + canvas.$da.width, canvas.$da.height); } - var context = canvas.$context; - try { - canvas.validate(); - context.save(); - context.translate(canvas.x, canvas.y); - - //!!!! debug - // zebra.print(" ============== DA = " + canvas.$da.y ); - // var dg = canvas.canvas.getContext("2d"); - // dg.strokeStyle = 'red'; - // dg.beginPath(); - // dg.rect(da.x, da.y, da.width, da.height); - // dg.stroke(); - - context.clipRect(canvas.$da.x, canvas.$da.y, - canvas.$da.width, canvas.$da.height); - if (canvas.bg == null) { - context.clearRect(canvas.$da.x, canvas.$da.y, - canvas.$da.width, canvas.$da.height); - } - - $this.paint(context, canvas); + $this.paint(context, canvas); - context.restore(); - canvas.$da.width = -1; //!!! - } - catch(e) { zebra.print(e); } - }, 50); - } + context.restore(); + } + catch(e) { zebra.print(e); } + $painting[canvas] = null; + }, 50); // !!! not sure the code below is redundant, but it looks redundantly // if (da.width > 0) { diff --git a/lib/zebra/zebra.min.js b/lib/zebra/zebra.min.js index 9960874d..8f977a37 100644 --- a/lib/zebra/zebra.min.js +++ b/lib/zebra/zebra.min.js @@ -1 +1 @@ -(function(){(function(){function isString(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="string"||o.constructor===String)}function isNumber(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="number"||o.constructor===Number)}function isBoolean(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="boolean"||o.constructor===Boolean)}if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(searchElement){if(this==null){throw new TypeError()}var t=Object(this),len=t.length>>>0;if(len===0){return -1}var n=0;if(arguments.length>0){n=Number(arguments[1]);if(n!=n){n=0}else{if(n!==0&&n!=Infinity&&n!=-Infinity){n=(n>0||-1)*~~Math.abs(n)}}}if(n>=len){return -1}var k=n>=0?n:Math.max(len-Math.abs(n),0);for(;k0)?new zebra.URL(ss.substring(0,i+1)):new zebra.URL(document.location.toString()).getParentURL()}}if(namespaces.hasOwnProperty(nsname)){throw new Error("Name space '"+nsname+"' already exists")}var f=function(name){if(arguments.length===0){return f.$env}if(typeof name==="function"){for(var k in f){if(f[k] instanceof Package){name(k,f[k])}}return null}var b=Array.isArray(name);if(isString(name)===false&&b===false){for(var k in name){if(name.hasOwnProperty(k)){f.$env[k]=name[k]}}return}if(b){for(var i=0;i=0){for(var k in p){if(k[0]!="$"&&k[0]!="_"&&(p[k] instanceof Package)===false&&p.hasOwnProperty(k)){code.push([k,ns,n,".",k].join(""))}}if(packages!=null){packages.splice(packages.indexOf(n),1)}}});if(packages!=null&&packages.length!==0){throw new Error("Unknown package(s): "+packages.join(","))}return code.length>0?["var ",code.join(","),";"].join(""):null};f.$env={};namespaces[nsname]=f;return f};zebra=namespace("zebra");var pkg=zebra,FN=pkg.$FN=(typeof namespace.name==="undefined")?(function(f){var mt=f.toString().match(/^function\s+([^\s(]+)/);return(mt==null)?"":mt[1]}):(function(f){return f.name});pkg.namespaces=namespaces;pkg.namespace=namespace;pkg.$global=this;pkg.isString=isString;pkg.isNumber=isNumber;pkg.isBoolean=isBoolean;pkg.version="1.2.0";pkg.$caller=null;function mnf(name,params){var cln=this.$clazz&&this.$clazz.$name?this.$clazz.$name+".":"";throw new ReferenceError("Method '"+cln+(name===""?"constructor":name)+"("+params+")' not found")}function $toString(){return this._hash_}function $equals(o){return this==o}function make_template(pt,tf,p){tf._hash_=["$zebra_",$$$++].join("");tf.toString=$toString;if(pt!=null){tf.prototype.$clazz=tf}tf.$clazz=pt;tf.prototype.toString=$toString;tf.prototype.equals=$equals;tf.prototype.constructor=tf;if(p&&p.length>0){tf.$parents={};for(var i=0;i0){return new (pkg.Class($Interface,arguments[0]))()}},arguments);return $Interface});pkg.$Extended=pkg.Interface();function ProxyMethod(name,f){if(isString(name)===false){throw new TypeError("Method name has not been defined")}var a=null;if(arguments.length==1){a=function(){var nm=a.methods[arguments.length];if(nm){var cm=pkg.$caller;pkg.$caller=nm;try{return nm.apply(this,arguments)}catch(e){throw e}finally{pkg.$caller=cm}}mnf.call(this,a.methodName,arguments.length)};a.methods={}}else{a=function(){var cm=pkg.$caller;pkg.$caller=f;try{return f.apply(this,arguments)}catch(e){throw e}finally{pkg.$caller=cm}};a.f=f}a.$clone$=function(){if(a.methodName===""){return null}if(a.f){return ProxyMethod(a.methodName,a.f)}var m=ProxyMethod(a.methodName);for(var k in a.methods){m.methods[k]=a.methods[k]}return m};a.methodName=name;return a}pkg.Class=make_template(null,function(){if(arguments.length===0){throw new Error("No class definition was found")}if(Array.isArray(arguments[arguments.length-1])===false){throw new Error("Invalid class definition was found")}if(arguments.length>1&&typeof arguments[0]!=="function"){throw new ReferenceError("Invalid parent class '"+arguments[0]+"'")}var df=arguments[arguments.length-1],$parent=null,args=Array.prototype.slice.call(arguments,0,arguments.length-1);if(args.length>0&&(args[0]==null||args[0].$clazz==pkg.Class)){$parent=args[0]}var $template=make_template(pkg.Class,function(){this._hash_=["$zObj_",$$$++].join("");if(arguments.length>0){var a=arguments[arguments.length-1];if(Array.isArray(a)===true&&typeof a[0]==="function"){a=a[0];var args=[$template],k=arguments.length-2;for(;k>=0&&pkg.instanceOf(arguments[k],pkg.Interface);k--){args.push(arguments[k])}args.push(arguments[arguments.length-1]);var cl=pkg.Class.apply(null,args),f=function(){};cl.$name=$template.$name;f.prototype=cl.prototype;var o=new f();cl.apply(o,Array.prototype.slice.call(arguments,0,k+1));o.constructor=cl;return o}}this[""]&&this[""].apply(this,arguments)},args);$template.$parent=$parent;if($parent!=null){for(var k in $parent.prototype){var f=$parent.prototype[k];if(f&&f.$clone$){f=f.$clone$();if(f==null){continue}}$template.prototype[k]=f}}$template.$propertyInfo={};$template.prototype.extend=function(){var c=this.$clazz,l=arguments.length,f=arguments[l-1];if(pkg.instanceOf(this,pkg.$Extended)===false){var cn=c.$name;c=Class(c,pkg.$Extended,[]);c.$name=cn;this.$clazz=c}if(Array.isArray(f)){for(var i=0;i0&&typeof arguments[0]==="function"){name=arguments[0].methodName;args=Array.prototype.slice.call(arguments,1)}var params=args.length;while($s!=null){var m=$s.prototype[name];if(m&&(typeof m.methods==="undefined"||m.methods[params])){return m.apply(this,args)}$s=$s.$parent}mnf.call(this,name,params)}throw new Error("$super is called outside of class context")};$template.prototype.$clazz=$template;$template.prototype.$this=function(){return pkg.$caller.boundTo.prototype[""].apply(this,arguments)};$template.constructor.prototype.getMethods=function(name){var m=[];for(var n in this.prototype){var f=this.prototype[n];if(arguments.length>0&&name!=n){continue}if(typeof f==="function"){if(f.$clone$){for(var mk in f.methods){m.push(f.methods[mk])}}else{m.push(f)}}}return m};$template.constructor.prototype.getMethod=function(name,params){var m=this.prototype[name];if(typeof m==="function"){if(m.$clone$){if(typeof params==="undefined"){if(m.methods[0]){return m.methods[0]}for(var k in m.methods){return m.methods[k]}return null}m=m.methods[params]}if(m){return m}}return null};$template.extend=function(df){if(Array.isArray(df)===false){throw new Error("Wrong class definition format "+df+", array is expected")}for(var i=0;i0){$busy--}}else{if(arguments.length==1&&$busy===0&&$f.length===0){arguments[0]();return}}for(var i=0;i0){$f.shift()()}};pkg.busy=function(){$busy++};pkg.Output=Class([function $prototype(){this.print=function print(o){this._p(0,o)};this.error=function error(o){this._p(2,o)};this.warn=function warn(o){this._p(1,o)};this._p=function(l,o){o=this.format(o);if(pkg.isInBrowser){if(typeof console==="undefined"||!console.log){alert(o)}else{if(l===0){console.log(o)}else{if(l==1){console.warn(o)}else{console.error(o)}}}}else{pkg.$global.print(o)}};this.format=function(o){if(o&&o.stack){return[o.toString(),":",o.stack.toString()].join("\n")}if(o===null){return""}if(typeof o==="undefined"){return""}if(isString(o)||isNumber(o)||isBoolean(o)){return o}var d=[o.toString()+" "+(o.$clazz?o.$clazz.$name:""),"{"];for(var k in o){if(o.hasOwnProperty(k)){d.push(" "+k+" = "+o[k])}}return d.join("\n")+"\n}"}}]);pkg.Dummy=Class([]);pkg.HtmlOutput=Class(pkg.Output,[function(){this.$this(null)},function(element){element=element||"zebra.out";if(pkg.isString(element)){this.el=document.getElementById(element);if(this.el==null){this.el=document.createElement("div");this.el.setAttribute("id",element);document.body.appendChild(this.el)}}else{if(element==null){throw new Error("Unknown HTML output element")}this.el=element}},function print(s){this.out("black",s)},function error(s){this.out("red",s)},function warn(s){this.out("orange",s)},function out(color,msg){var t=["
",this.format(msg),"
"];this.el.innerHTML+=t.join("")}]);pkg.isInBrowser=typeof navigator!=="undefined";pkg.isIE=pkg.isInBrowser&&(Object.hasOwnProperty.call(window,"ActiveXObject")||!!window.ActiveXObject);pkg.isFF=pkg.isInBrowser&&window.mozInnerScreenX!=null;pkg.isMobile=pkg.isInBrowser&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|windows mobile|windows phone|IEMobile/i.test(navigator.userAgent);pkg.isTouchable=pkg.isInBrowser&&((pkg.isIE===false&&(!!("ontouchstart" in window)||!!("onmsgesturechange" in window)))||(!!window.navigator.msPointerEnabled&&!!window.navigator.msMaxTouchPoints>0));pkg.out=new pkg.Output();pkg.isMacOS=pkg.isInBrowser&&navigator.platform.toUpperCase().indexOf("MAC")!==-1;pkg.print=function(){pkg.out.print.apply(pkg.out,arguments)};pkg.error=function(){pkg.out.error.apply(pkg.out,arguments)};pkg.warn=function(){pkg.out.warn.apply(pkg.out,arguments)};function complete(){pkg(function(n,p){function collect(pp,p){for(var k in p){if(k[0]!="$"&&p.hasOwnProperty(k)&&zebra.instanceOf(p[k],Class)){p[k].$name=pp?[pp,k].join("."):k;collect(k,p[k])}}}collect(null,p)});pkg.ready()}if(pkg.isInBrowser){var m=window.location.search.match(/[?&][a-zA-Z0-9_.]+=[^?&=]+/g),env={};for(var i=0;m&&i0){var f=function(){};f.prototype=clazz.prototype;var o=new f();o.constructor=clazz;clazz.apply(o,args);return o}return new clazz()};function hex(v){return(v<16)?["0",v.toString(16)].join(""):v.toString(16)}pkg.findInTree=function(root,path,eq,cb){var findRE=/(\/\/|\/)?([^\[\/]+)(\[\s*(\@[a-zA-Z_][a-zA-Z0-9_\.]*)\s*\=\s*([0-9]+|true|false|\'[^']*\')\s*\])?/g,m=null,res=[];function _find(root,ms,idx,cb){function list_child(r,name,deep,cb){if(r.kids){for(var i=0;i=ms.length){return cb(root)}var m=ms[idx];return list_child(root,m[2],m[1]=="//",function(child){if(m[3]&&child[m[4].substring(1)]!=m[5]){return false}return _find(child,ms,idx+1,cb)})}var c=0;while(m=findRE.exec(path)){if(m[1]==null||m[2]==null||m[2].trim().length===0){break}c+=m[0].length;if(m[3]&&m[5][0]=="'"){m[5]=m[5].substring(1,m[5].length-1)}res.push(m)}if(res.length==0||c3){this.a=parseInt(p[3].trim(),10)}return}}}this.r=r>>16;this.g=(r>>8)&255;this.b=(r&255)}else{this.r=r;this.g=g;this.b=b;if(arguments.length>3){this.a=a}}if(this.s==null){this.s=(typeof this.a!=="undefined")?["rgba(",this.r,",",this.g,",",this.b,",",this.a,")"].join(""):["#",hex(this.r),hex(this.g),hex(this.b)].join("")}};var rgb=pkg.rgb;rgb.prototype.toString=function(){return this.s};rgb.black=new rgb(0);rgb.white=new rgb(16777215);rgb.red=new rgb(255,0,0);rgb.blue=new rgb(0,0,255);rgb.green=new rgb(0,255,0);rgb.gray=new rgb(128,128,128);rgb.lightGray=new rgb(211,211,211);rgb.darkGray=new rgb(169,169,169);rgb.orange=new rgb(255,165,0);rgb.yellow=new rgb(255,255,0);rgb.pink=new rgb(255,192,203);rgb.cyan=new rgb(0,255,255);rgb.magenta=new rgb(255,0,255);rgb.darkBlue=new rgb(0,0,140);rgb.transparent=new rgb(0,0,0,1);pkg.Actionable=Interface();pkg.index2point=function(offset,cols){return[~~(offset/cols),(offset%cols)]};pkg.indexByPoint=function(row,col,cols){return(cols<=0)?-1:(row*cols)+col};pkg.intersection=function(x1,y1,w1,h1,x2,y2,w2,h2,r){r.x=x1>x2?x1:x2;r.width=Math.min(x1+w1,x2+w2)-r.x;r.y=y1>y2?y1:y2;r.height=Math.min(y1+h1,y2+h2)-r.y};pkg.isIntersect=function(x1,y1,w1,h1,x2,y2,w2,h2){return(Math.min(x1+w1,x2+w2)-(x1>x2?x1:x2))>0&&(Math.min(y1+h1,y2+h2)-(y1>y2?y1:y2))>0};pkg.unite=function(x1,y1,w1,h1,x2,y2,w2,h2,r){r.x=x1>8)&255);ar.push(code&255)}return ar};var digitRE=/[0-9]/;pkg.isDigit=function(ch){if(ch.length!=1){throw new Error("Incorrect character")}return digitRE.test(ch)};var letterRE=/[A-Za-z]/;pkg.isLetter=function(ch){if(ch.length!=1){throw new Error("Incorrect character")}return letterRE.test(ch)};var $NewListener=function(){if(arguments.length===0){arguments=["fired"]}var clazz=function(){};if(arguments.length==1){var name=arguments[0];clazz.prototype.add=function(l){if(this.v==null){this.v=[]}var ctx=this;if(typeof l!=="function"){ctx=l;l=l[name];if(l==null||typeof l!=="function"){throw new Error("Instance doesn't declare '"+names+"' listener method")}}this.v.push(ctx,l);return l};clazz.prototype.remove=function(l){if(this.v!=null){var i=0;while((i=this.v.indexOf(l))>=0){if(i%2>0){i--}this.v.splice(i,2)}}};clazz.prototype.removeAll=function(){if(this.v!=null){this.v.length=0}};clazz.prototype[name]=function(){if(this.v!=null){for(var i=0;i=0){if(i%2>0){i--}v.splice(i,2)}if(v.length===0){delete this.methods[k]}}}};clazz.prototype.removeAll=function(){if(this.methods!=null){for(var k in this.methods){if(this.methods.hasOwnProperty(k)){this.methods[k].length=0}}this.methods={}}}}return clazz};pkg.Listeners=$NewListener();pkg.Listeners.Class=$NewListener;var PosListeners=pkg.Listeners.Class("posChanged"),Position=pkg.Position=Class([function $clazz(){this.Metric=Interface();this.DOWN=1;this.UP=2;this.BEG=3;this.END=4},function $prototype(){this.clearPos=function(){if(this.offset>=0){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol;this.offset=this.currentLine=this.currentCol=-1;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.setOffset=function(o){if(o<0){o=0}else{var max=this.metrics.getMaxOffset();if(o>=max){o=max}}if(o!=this.offset){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol,p=this.getPointByOffset(o);this.offset=o;if(p!=null){this.currentLine=p[0];this.currentCol=p[1]}this.isValid=true;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.seek=function(off){this.setOffset(this.offset+off)};this.setRowCol=function(r,c){if(r!=this.currentLine||c!=this.currentCol){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol;this.offset=this.getOffsetByPoint(r,c);this.currentLine=r;this.currentCol=c;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.inserted=function(off,size){if(this.offset>=0&&off<=this.offset){this.isValid=false;this.setOffset(this.offset+size)}};this.removed=function(off,size){if(this.offset>=0&&this.offset>=off){this.isValid=false;if(this.offset>=(off+size)){this.setOffset(this.offset-size)}else{this.setOffset(off)}}};this.getPointByOffset=function(off){if(off==-1){return[-1,-1]}var m=this.metrics,max=m.getMaxOffset();if(off>max){throw new Error("Out of bounds:"+off)}if(max===0){return[(m.getLines()>0?0:-1),0]}if(off===0){return[0,0]}var d=0,sl=0,so=0;if(this.isValid&&this.offset!=-1){sl=this.currentLine;so=this.offset-this.currentCol;if(off>this.offset){d=1}else{if(off=0;sl+=d){var ls=m.getLineSize(sl);if(off>=so&&off0?ls:-m.getLineSize(sl-1)}return[-1,-1]};this.getOffsetByPoint=function(row,col){var startOffset=0,startLine=0,m=this.metrics;if(row>=m.getLines()||col>=m.getLineSize(row)){throw new Error()}if(this.isValid&&this.offset!=-1){startOffset=this.offset-this.currentCol;startLine=this.currentLine}if(startLine<=row){for(var i=startLine;i=row;i--){startOffset-=m.getLineSize(i)}}return startOffset+col};this.calcMaxOffset=function(){var max=0,m=this.metrics;for(var i=0;i0){this.offset-=this.currentCol;this.currentCol=0;this._.posChanged(this,prevOffset,prevLine,prevCol)}break;case Position.END:var maxCol=this.metrics.getLineSize(this.currentLine);if(this.currentCol<(maxCol-1)){this.offset+=(maxCol-this.currentCol-1);this.currentCol=maxCol-1;this._.posChanged(this,prevOffset,prevLine,prevCol)}break;case Position.UP:if(this.currentLine>0){this.offset-=(this.currentCol+1);this.currentLine--;for(var i=0;this.currentLine>0&&i<(num-1);i++,this.currentLine--){this.offset-=this.metrics.getLineSize(this.currentLine)}var maxCol=this.metrics.getLineSize(this.currentLine);if(this.currentCol0){for(var i=0;i=0){window.clearInterval(this.pid);this.pid=-1}};this.clear=function(l){var c=this.get(l);c.si=c.ri}})();pkg.Bag=zebra.Class([function $prototype(){this.concatArrays=false;this.usePropertySetters=true;this.ignoreNonExistentKeys=false;this.get=function(key){if(key==null){throw new Error("Null key")}var n=key.split("."),v=this.objects;for(var i=0;i1){m.apply(v,nv)}else{m.call(v,nv)}continue}}v[k]=nv}}if(inh!==null){this.inherit(v,inh)}return v};this.resolveClass=function(className){return this.aliases.hasOwnProperty(className)?this.aliases[className]:zebra.Class.forName(className)};this.inherit=function(o,pp){for(var i=0;i0?"&":"?")+(new Date()).getTime().toString();return this.load(zebra.io.GET(p),b)}])})(zebra("util"),zebra.Class,zebra.Interface);(function(pkg,Class,Interface){pkg.descent=function descent(a,b){if(a==null){return 1}return(zebra.isString(a))?a.localeCompare(b):a-b};pkg.ascent=function ascent(a,b){if(b==null){return 1}return(zebra.isString(b))?b.localeCompare(a):b-a};pkg.TextModel=Interface();var MB=zebra.util,oobi="Index is out of bounds: ";function Line(s){this.s=s;this.l=0}Line.prototype.toString=function(){return this.s};pkg.TextModelListeners=MB.Listeners.Class("textUpdated");pkg.Text=Class(pkg.TextModel,[function $prototype(){this.textLength=0;this.getLnInfo=function(lines,start,startOffset,o){for(;start=startOffset&&o<=startOffset+line.length){return[start,startOffset]}startOffset+=(line.length+1)}return[]};this.setExtraChar=function(i,ch){this.lines[i].l=ch};this.getExtraChar=function(i){return this.lines[i].l};this.getLine=function(line){return this.lines[line].s};this.getValue=function(){return this.lines.join("\n")};this.getLines=function(){return this.lines.length};this.getTextLength=function(){return this.textLength};this.write=function(s,offset){var slen=s.length,info=this.getLnInfo(this.lines,0,0,offset),line=this.lines[info[0]].s,j=0,lineOff=offset-info[1],tmp=[line.substring(0,lineOff),s,line.substring(lineOff)].join("");for(;j=slen){this.lines[info[0]].s=tmp;j=1}else{this.lines.splice(info[0],1);j=this.parse(info[0],tmp,this.lines)}this.textLength+=slen;this._.textUpdated(this,true,offset,slen,info[0],j)};this.remove=function(offset,size){var i1=this.getLnInfo(this.lines,0,0,offset),i2=this.getLnInfo(this.lines,i1[0],i1[1],offset+size),l2=this.lines[i2[0]].s,l1=this.lines[i1[0]].s,off1=offset-i1[1],off2=offset+size-i2[1],buf=[l1.substring(0,off1),l2.substring(off2)].join("");if(i2[0]==i1[0]){this.lines.splice(i1[0],1,new Line(buf))}else{this.lines.splice(i1[0],i2[0]-i1[0]+1);this.lines.splice(i1[0],0,new Line(buf))}this.textLength-=size;this._.textUpdated(this,false,offset,size,i1[0],i2[0]-i1[0]+1)};this.parse=function(startLine,text,lines){var size=text.length,prevIndex=0,prevStartLine=startLine;for(var index=0;index<=size;prevIndex=index,startLine++){var fi=text.indexOf("\n",index);index=(fi<0?size:fi);this.lines.splice(startLine,0,new Line(text.substring(prevIndex,index)));index++}return startLine-prevStartLine};this.setValue=function(text){if(text==null){throw new Error("Invalid null string")}var old=this.getValue();if(old!==text){if(old.length>0){var numLines=this.getLines(),txtLen=this.getTextLength();this.lines.length=0;this.lines=[new Line("")];this._.textUpdated(this,false,0,txtLen,0,numLines)}this.lines=[];this.parse(0,text,this.lines);this.textLength=text.length;this._.textUpdated(this,true,0,this.textLength,0,this.getLines())}};this[""]=function(s){this.lines=[new Line("")];this._=new pkg.TextModelListeners();this.setValue(s==null?"":s)}}]);pkg.SingleLineTxt=Class(pkg.TextModel,[function $prototype(){this.setExtraChar=function(i,ch){this.extra=ch};this.getExtraChar=function(i){return this.extra};this.getValue=function(){return this.buf};this.getLines=function(){return 1};this.getTextLength=function(){return this.buf.length};this.getLine=function(line){if(line!=0){throw new Error(oobi+line)}return this.buf};this.write=function(s,offset){var buf=this.buf,j=s.indexOf("\n");if(j>=0){s=s.substring(0,j)}var l=(this.maxLen>0&&(buf.length+s.length)>=this.maxLen)?this.maxLen-buf.length:s.length;if(l!==0){this.buf=[buf.substring(0,offset),s.substring(0,l),buf.substring(offset)].join("");if(l>0){this._.textUpdated(this,true,offset,l,0,1)}}};this.remove=function(offset,size){this.buf=[this.buf.substring(0,offset),this.buf.substring(offset+size)].join("");this._.textUpdated(this,false,offset,size,0,1)};this.setValue=function(text){if(text==null){throw new Error("Invalid null string")}var i=text.indexOf("\n");if(i>=0){text=text.substring(0,i)}if(this.buf==null||this.buf!==text){if(this.buf!=null&&this.buf.length>0){this._.textUpdated(this,false,0,this.buf.length,0,1)}if(this.maxLen>0&&text.length>this.maxLen){text=text.substring(0,this.maxLen)}this.buf=text;this._.textUpdated(this,true,0,text.length,0,1)}};this.setMaxLength=function(max){if(max!=this.maxLen){this.maxLen=max;this.setValue("")}};this[""]=function(s,max){this.maxLen=max==null?-1:max;this.buf=null;this.extra=0;this._=new pkg.TextModelListeners();this.setValue(s==null?"":s)}}]);pkg.ListModelListeners=MB.Listeners.Class("elementInserted","elementRemoved","elementSet");pkg.ListModel=Class([function $prototype(){this.get=function(i){if(i<0||i>=this.d.length){throw new Error(oobi+i)}return this.d[i]};this.add=function(o){this.d.push(o);this._.elementInserted(this,o,this.d.length-1)};this.removeAll=function(){var size=this.d.length;for(var i=size-1;i>=0;i--){this.removeAt(i)}};this.removeAt=function(i){var re=this.d[i];this.d.splice(i,1);this._.elementRemoved(this,re,i)};this.remove=function(o){for(var i=0;i=this.d.length){throw new Error(oobi+i)}this.d.splice(i,0,o);this._.elementInserted(this,o,i)};this.count=function(){return this.d.length};this.set=function(o,i){if(i<0||i>=this.d.length){throw new Error(oobi+i)}var pe=this.d[i];this.d[i]=o;this._.elementSet(this,o,pe,i);return pe};this.contains=function(o){return this.indexOf(o)>=0};this.indexOf=function(o){return this.d.indexOf(o)};this[""]=function(){this._=new pkg.ListModelListeners();this.d=(arguments.length===0)?[]:arguments[0]}}]);var Item=pkg.Item=Class([function $prototype(){this[""]=function(v){this.kids=[];this.value=v}}]);pkg.TreeModelListeners=MB.Listeners.Class("itemModified","itemRemoved","itemInserted");pkg.TreeModel=Class([function $clazz(){this.create=function(r,p){var item=new Item(r.hasOwnProperty("value")?r.value:r);item.parent=p;if(r.hasOwnProperty("kids")){for(var i=0;i=this.rows||col<0||col>=this.cols){throw new Error("Row of col is out of bounds: "+row+","+col)}return this.objs[row][col]};this.put=function(row,col,obj){var nr=this.rows,nc=this.cols;if(row>=nr){nr+=(row-nr+1)}if(col>=nc){nc+=(col-nc+1)}this.setRowsCols(nr,nc);var old=this.objs[row]?this.objs[row][col]:undefined;if(obj!=old){this.objs[row][col]=obj;this._.cellModified(this,row,col,old)}};this.puti=function(i,obj){var p=zebra.util.index2point(i,this.cols);this.put(p[0],p[1],obj)};this.setRowsCols=function(rows,cols){if(rows!=this.rows||cols!=this.cols){var pc=this.cols,pr=this.rows;this.rellocate(rows,cols);this.cols=cols;this.rows=rows;this._.matrixResized(this,pr,pc)}};this.rellocate=function(r,c){if(r>=this.rows){for(var i=this.rows;ithis.rows){throw new Error()}for(var i=(begrow+count);ithis.cols){throw new Error()}for(var i=(begcol+count);i0)?this.objs[0].length:0;this.rows=this.objs.length}else{this.objs=[];this.rows=this.cols=0;if(arguments.length>1){this.setRowsCols(arguments[0],arguments[1])}}}}])})(zebra("data"),zebra.Class,zebra.Interface);(function(pkg,Class){var HEX="0123456789ABCDEF";pkg.ID=function UUID(size){if(typeof size==="undefined"){size=16}var id=[];for(var i=0;i<36;i++){id[i]=HEX[~~(Math.random()*16)]}return id.join("")};pkg.sleep=function(){var r=new XMLHttpRequest(),t=(new Date()).getTime().toString(),i=window.location.toString().lastIndexOf("?");r.open("GET",window.location+(i>0?"&":"?")+t,false);r.send(null)};var b64str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";pkg.b64encode=function(input){var out=[],i=0,len=input.length,c1,c2,c3;if(typeof ArrayBuffer!=="undefined"){if(input instanceof ArrayBuffer){input=new Uint8Array(input)}input.charCodeAt=function(i){return this[i]}}if(Array.isArray(input)){input.charCodeAt=function(i){return this[i]}}while(i>2));if(i==len){out.push(b64str.charAt((c1&3)<<4),"==");break}c2=input.charCodeAt(i++);out.push(b64str.charAt(((c1&3)<<4)|((c2&240)>>4)));if(i==len){out.push(b64str.charAt((c2&15)<<2),"=");break}c3=input.charCodeAt(i++);out.push(b64str.charAt(((c2&15)<<2)|((c3&192)>>6)),b64str.charAt(c3&63))}return out.join("")};pkg.b64decode=function(input){var output=[],chr1,chr2,chr3,enc1,enc2,enc3,enc4;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while((input.length%4)!==0){input+="="}for(var i=0;i>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output.push(String.fromCharCode(chr1));if(enc3!=64){output.push(String.fromCharCode(chr2))}if(enc4!=64){output.push(String.fromCharCode(chr3))}}return output.join("")};pkg.dateToISO8601=function(d){function pad(n){return n<10?"0"+n:n}return[d.getUTCFullYear(),"-",pad(d.getUTCMonth()+1),"-",pad(d.getUTCDate()),"T",pad(d.getUTCHours()),":",pad(d.getUTCMinutes()),":",pad(d.getUTCSeconds()),"Z"].join("")};pkg.ISO8601toDate=function(v){var regexp=["([0-9]{4})(-([0-9]{2})(-([0-9]{2})","(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?","(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?"].join(""),d=v.match(new RegExp(regexp)),offset=0,date=new Date(d[1],0,1);if(d[3]){date.setMonth(d[3]-1)}if(d[5]){date.setDate(d[5])}if(d[7]){date.setHours(d[7])}if(d[8]){date.setMinutes(d[8])}if(d[10]){date.setSeconds(d[10])}if(d[12]){date.setMilliseconds(Number("0."+d[12])*1000)}if(d[14]){offset=(Number(d[16])*60)+Number(d[17]);offset*=((d[15]=="-")?1:-1)}offset-=date.getTimezoneOffset();date.setTime(Number(date)+(offset*60*1000));return date};pkg.parseXML=function(s){function rmws(node){if(node.childNodes!==null){for(var i=node.childNodes.length;i-->0;){var child=node.childNodes[i];if(child.nodeType===3&&child.data.match(/^\s*$/)){node.removeChild(child)}if(child.nodeType===1){rmws(child)}}}return node}if(typeof DOMParser!=="undefined"){return rmws((new DOMParser()).parseFromString(s,"text/xml"))}else{for(var n in {"Microsoft.XMLDOM":0,"MSXML2.DOMDocument":1,"MSXML.DOMDocument":2}){var p=null;try{p=new ActiveXObject(n);p.async=false}catch(e){continue}if(p===null){throw new Error("XML parser is not available")}p.loadXML(s);return p}}throw new Error("No XML parser is available")};pkg.QS=Class([function $clazz(){this.append=function(url,obj){return url+((obj===null)?"":((url.indexOf("?")>0)?"&":"?")+pkg.QS.toQS(obj,true))};this.parse=function(url){var m=window.location.search.match(/[?&][a-zA-Z0-9_.]+=[^?&=]+/g),r={};for(var i=0;m&&i0?this.data.charCodeAt(this.pos++)&255:-1}])}else{if(Array.isArray(container)===false){throw new Error("Wrong type: "+typeof(container))}}this.data=container}this.marked=-1;this.pos=0},function mark(){if(this.available()<=0){throw new Error()}this.marked=this.pos},function reset(){if(this.available()<=0||this.marked<0){throw new Error()}this.pos=this.marked;this.marked=-1},function close(){this.pos=this.data.length},function read(){return this.available()>0?this.data[this.pos++]:-1},function read(buf){return this.read(buf,0,buf.length)},function read(buf,off,len){for(var i=0;i191&&c<224){return String.fromCharCode(((c&31)<<6)|(c2&63))}else{var c3=this.read();if(c3<0){throw new Error()}return String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63))}},function readLine(){if(this.available()>0){var line=[],b;while((b=this.readChar())!=-1&&b!="\n"){line.push(b)}var r=line.join("");line.length=0;return r}return null},function available(){return this.data===null?-1:this.data.length-this.pos},function toBase64(){return pkg.b64encode(this.data)}]);pkg.URLInputStream=Class(pkg.InputStream,[function(url){this.$this(url,null)},function(url,f){var r=pkg.getRequest(),$this=this;r.open("GET",url,f!==null);if(f===null||isBA===false){if(!r.overrideMimeType){throw new Error("Binary mode is not supported")}r.overrideMimeType("text/plain; charset=x-user-defined")}if(f!==null){if(isBA){r.responseType="arraybuffer"}r.onreadystatechange=function(){if(r.readyState==4){if(r.status!=200){throw new Error(url)}$this.$clazz.$parent.getMethod("",1).call($this,isBA?r.response:r.responseText);f($this.data,r)}};r.send(null)}else{r.send(null);if(r.status!=200){throw new Error(url)}this.$super(r.responseText)}},function close(){this.$super();if(this.data){this.data.length=0;this.data=null}}]);pkg.Service=Class([function(url,methods){var $this=this;this.url=url;if(Array.isArray(methods)===false){methods=[methods]}for(var i=0;i0&&typeof args[args.length-1]=="function"){var callback=args.pop();return this.send(url,this.encode(name,args),function(request){var r=null;try{if(request.status==200){r=$this.decode(request.responseText)}else{r=new Error("Status: "+request.status+", '"+request.statusText+"'")}}catch(e){r=e}callback(r)})}return this.decode(this.send(url,this.encode(name,args),null))}})()}},function send(url,data,callback){var http=new pkg.HTTP(url);if(this.contentType!=null){http.header["Content-Type"]=this.contentType}return http.POST(data,callback)}]);pkg.Service.invoke=function(clazz,url,method){var rpc=new clazz(url,method);return function(){return rpc[method].apply(rpc,arguments)}};pkg.JRPC=Class(pkg.Service,[function(url,methods){this.$super(url,methods);this.version="2.0";this.contentType="application/json"},function encode(name,args){return JSON.stringify({jsonrpc:this.version,method:name,params:args,id:pkg.ID()})},function decode(r){if(r===null||r.length===0){throw new Error("Empty JSON result string")}r=JSON.parse(r);if(typeof(r.error)!=="undefined"){throw new Error(r.error.message)}if(typeof r.result==="undefined"||typeof r.id==="undefined"){throw new Error("Wrong JSON response format")}return r.result}]);pkg.Base64=function(s){if(arguments.length>0){this.encoded=pkg.b64encode(s)}};pkg.Base64.prototype.toString=function(){return this.encoded};pkg.Base64.prototype.decode=function(){return pkg.b64decode(this.encoded)};pkg.XRPC=Class(pkg.Service,[function(url,methods){this.$super(url,methods);this.contentType="text/xml"},function encode(name,args){var p=['\n',name,""];for(var i=0;i");this.encodeValue(args[i],p);p.push("")}p.push("");return p.join("")},function encodeValue(v,p){if(v===null){throw new Error("Null is not allowed")}if(zebra.isString(v)){v=v.replace("<","<");v=v.replace("&","&");p.push("",v,"")}else{if(zebra.isNumber(v)){if(Math.round(v)==v){p.push("",v.toString(),"")}else{p.push("",v.toString(),"")}}else{if(zebra.isBoolean(v)){p.push("",v?"1":"0","")}else{if(v instanceof Date){p.push("",pkg.dateToISO8601(v),"")}else{if(Array.isArray(v)){p.push("");for(var i=0;i");this.encodeValue(v[i],p);p.push("")}p.push("")}else{if(v instanceof pkg.Base64){p.push("",v.toString(),"")}else{p.push("");for(var k in v){if(v.hasOwnProperty(k)){p.push("",k,"");this.encodeValue(v[k],p);p.push("")}}p.push("")}}}}}}},function decodeValue(node){var tag=node.tagName.toLowerCase();if(tag=="struct"){var p={};for(var i=0;i0){var err=this.decodeValue(c[0].getElementsByTagName("struct")[0]);throw new Error(err.faultString)}c=p.getElementsByTagName("methodResponse")[0];c=c.childNodes[0].childNodes[0];if(c.tagName.toLowerCase()==="param"){return this.decodeValue(c.childNodes[0].childNodes[0])}throw new Error("incorrect XML-RPC response")}]);pkg.XRPC.invoke=function(url,method){return pkg.Service.invoke(pkg.XRPC,url,method)};pkg.JRPC.invoke=function(url,method){return pkg.Service.invoke(pkg.JRPC,url,method)}})(zebra("io"),zebra.Class);(function(pkg,Class){pkg.NONE=0;pkg.LEFT=1;pkg.RIGHT=2;pkg.TOP=4;pkg.BOTTOM=8;pkg.CENTER=16;pkg.HORIZONTAL=32;pkg.VERTICAL=64;pkg.TEMPORARY=128;pkg.USE_PS_SIZE=512;pkg.STRETCH=256;pkg.TLEFT=pkg.LEFT|pkg.TOP;pkg.TRIGHT=pkg.RIGHT|pkg.TOP;pkg.BLEFT=pkg.LEFT|pkg.BOTTOM;pkg.BRIGHT=pkg.RIGHT|pkg.BOTTOM;var $ctrs={};for(var k in pkg){if(pkg.hasOwnProperty(k)&&/^\d+$/.test(pkg[k])){$ctrs[k.toUpperCase()]=pkg[k]}}var $c=pkg.$constraints=function(v){return zebra.isString(v)?$ctrs[v.toUpperCase()]:v};var L=pkg.Layout=new zebra.Interface();pkg.getDirectChild=function(parent,child){for(;child!=null&&child.parent!=parent;child=child.parent){}return child};pkg.getDirectAt=function(x,y,p){for(var i=0;ix&&c.y+c.height>y){return i}}return -1};pkg.getTopParent=function(c){for(;c!=null&&c.parent!=null;c=c.parent){}return c};pkg.getAbsLocation=function(x,y,c){if(arguments.length==1){c=x;x=y=0}while(c.parent!=null){x+=c.x;y+=c.y;c=c.parent}return{x:x,y:y}};pkg.getRelLocation=function(x,y,p,c){while(c!=p){x-=c.x;y-=c.y;c=c.parent}return{x:x,y:y}};pkg.xAlignment=function(aow,alignX,aw){if(alignX==pkg.RIGHT){return aw-aow}if(alignX==pkg.CENTER){return ~~((aw-aow)/2)}if(alignX==pkg.LEFT||alignX==pkg.NONE){return 0}throw new Error("Invalid alignment "+alignX)};pkg.yAlignment=function(aoh,alignY,ah){if(alignY==pkg.BOTTOM){return ah-aoh}if(alignY==pkg.CENTER){return ~~((ah-aoh)/2)}if(alignY==pkg.TOP||alignY==pkg.NONE){return 0}throw new Error("Invalid alignment "+alignY)};pkg.getMaxPreferredSize=function(target){var maxWidth=0,maxHeight=0;for(var i=0;imaxWidth){maxWidth=ps.width}if(ps.height>maxHeight){maxHeight=ps.height}}}return{width:maxWidth,height:maxHeight}};pkg.isAncestorOf=function(p,c){for(;c!=null&&c!=p;c=c.parent){}return c!=null};pkg.Layoutable=Class(L,[function $prototype(){this.x=this.y=this.height=this.width=this.cachedHeight=0;this.psWidth=this.psHeight=this.cachedWidth=-1;this.isLayoutValid=this.isValid=false;this.constraints=this.parent=null;this.isVisible=true;this.find=function(path){var res=null;zebra.util.findInTree(this,path,function(node,name){return node.$clazz.$name==name},function(kid){res=kid;return true});return res};this.findAll=function(path,callback){var res=[];if(callback==null){callback=function(kid){res.push(kid);return false}}zebra.util.findInTree(this,path,function(node,name){return node.$clazz.$name==name},callback);return res};this.validateMetric=function(){if(this.isValid===false){if(this.recalc){this.recalc()}this.isValid=true}};this.invalidateLayout=function(){this.isLayoutValid=false;if(this.parent!=null){this.parent.invalidateLayout()}};this.invalidate=function(){this.isValid=this.isLayoutValid=false;this.cachedWidth=-1;if(this.parent!=null){this.parent.invalidate()}};this.validate=function(){this.validateMetric();if(this.width>0&&this.height>0&&this.isLayoutValid===false&&this.isVisible){this.layout.doLayout(this);for(var i=0;i=0?this.psWidth:ps.width+this.getLeft()+this.getRight();ps.height=this.psHeight>=0?this.psHeight:ps.height+this.getTop()+this.getBottom();this.cachedWidth=ps.width;this.cachedHeight=ps.height;return ps}return{width:this.cachedWidth,height:this.cachedHeight}};this.getTop=function(){return 0};this.getLeft=function(){return 0};this.getBottom=function(){return 0};this.getRight=function(){return 0};this.setParent=function(o){if(o!=this.parent){this.parent=o;this.invalidate()}};this.setLayout=function(m){if(m==null){throw new Error("Null layout")}if(this.layout!=m){var pl=this.layout;this.layout=m;this.invalidate()}};this.calcPreferredSize=function(target){return{width:10,height:10}};this.doLayout=function(target){};this.indexOf=function(c){return this.kids.indexOf(c)};this.insert=function(i,constr,d){if(d.constraints){constr=d.constraints}else{d.constraints=constr}if(i==this.kids.length){this.kids.push(d)}else{this.kids.splice(i,0,d)}d.setParent(this);if(this.kidAdded){this.kidAdded(i,constr,d)}this.invalidate();return d};this.setLocation=function(xx,yy){if(xx!=this.x||this.y!=yy){var px=this.x,py=this.y;this.x=xx;this.y=yy;if(this.relocated){this.relocated(px,py)}}};this.setBounds=function(x,y,w,h){this.setLocation(x,y);this.setSize(w,h)};this.setSize=function(w,h){if(w!=this.width||h!=this.height){var pw=this.width,ph=this.height;this.width=w;this.height=h;this.isLayoutValid=false;if(this.resized){this.resized(pw,ph)}}};this.getByConstraints=function(c){if(this.kids.length>0){for(var i=0;i0){if(arguments.length==1){this.hgap=this.vgap=hgap}else{this.hgap=hgap;this.vgap=vgap}}};this.calcPreferredSize=function(target){var center=null,west=null,east=null,north=null,south=null,d=null;for(var i=0;idim.height?d.height:dim.height)}if(west!=null){d=west.getPreferredSize();dim.width+=d.width+this.hgap;dim.height=d.height>dim.height?d.height:dim.height}if(center!=null){d=center.getPreferredSize();dim.width+=d.width;dim.height=d.height>dim.height?d.height:dim.height}if(north!=null){d=north.getPreferredSize();dim.width=d.width>dim.width?d.width:dim.width;dim.height+=d.height+this.vgap}if(south!=null){d=south.getPreferredSize();dim.width=d.width>dim.width?d.width:dim.width;dim.height+=d.height+this.vgap}return dim};this.doLayout=function(t){var top=t.getTop(),bottom=t.height-t.getBottom(),left=t.getLeft(),right=t.width-t.getRight(),center=null,west=null,east=null;for(var i=0;i0;for(var i=0;im.width){m.width=px}if(py>m.height){m.height=py}}}return m};this.doLayout=function(c){var r=c.width-c.getRight(),b=c.height-c.getBottom(),usePsSize=(this.flag&pkg.USE_PS_SIZE)>0;for(var i=0;i0){ww=r-el.x}if((this.flag&pkg.VERTICAL)>0){hh=b-el.y}el.setSize(ww,hh);if(el.constraints){var x=el.x,y=el.y;if(el.constraints==pkg.CENTER){x=(c.width-ww)/2;y=(c.height-hh)/2}else{if((el.constraints&pkg.TOP)>0){y=0}else{if((el.constraints&pkg.BOTTOM)>0){y=c.height-hh}}if((el.constraints&pkg.LEFT)>0){x=0}else{if((el.constraints&pkg.RIGHT)>0){x=c.width-ww}}}el.setLocation(x,y)}}}};this[""]=function(f){this.flag=f?f:0}}]);pkg.FlowLayout=Class(L,[function $prototype(){this.gap=0;this.ax=pkg.LEFT;this.ay=pkg.TOP;this.direction=pkg.HORIZONTAL;this[""]=function(ax,ay,dir,g){if(arguments.length==1){this.gap=ax}else{if(arguments.length>=2){this.ax=pkg.$constraints(ax);this.ay=pkg.$constraints(ay)}if(arguments.length>2){dir=pkg.$constraints(dir);if(dir!=pkg.HORIZONTAL&&dir!=pkg.VERTICAL){throw new Error("Invalid direction "+dir)}this.direction=dir}if(arguments.length>3){this.gap=g}}};this.calcPreferredSize=function(c){var m={width:0,height:0},cc=0;for(var i=0;im.height?d.height:m.height}else{m.width=d.width>m.width?d.width:m.width;m.height+=d.height}cc++}}var add=this.gap*(cc>0?cc-1:0);if(this.direction==pkg.HORIZONTAL){m.width+=add}else{m.height+=add}return m};this.doLayout=function(c){var psSize=this.calcPreferredSize(c),t=c.getTop(),l=c.getLeft(),lastOne=null,px=pkg.xAlignment(psSize.width,this.ax,c.width-l-c.getRight())+l,py=pkg.yAlignment(psSize.height,this.ay,c.height-t-c.getBottom())+t;for(var i=0;i0?this.gap:0));c++;if(wmax){max=d.height}as+=d.width}else{if(d.width>max){max=d.width}as+=d.height}}return(this.direction==pkg.HORIZONTAL)?{width:as,height:max}:{width:max,height:as}}}]);pkg.Constraints=Class([function $prototype(){this.top=this.bottom=this.left=this.right=0;this.ay=this.ax=pkg.STRETCH;this.rowSpan=this.colSpan=1;this[""]=function(ax,ay){if(arguments.length>0){this.ax=ax;if(arguments.length>1){this.ay=ay}}};this.setPadding=function(p){this.top=this.bottom=this.left=this.right=p};this.setPaddings=function(t,l,b,r){this.top=t;this.bottom=b;this.left=l;this.right=r}}]);pkg.GridLayout=Class(L,[function(r,c){this.$this(r,c,0)},function(r,c,m){this.rows=r;this.cols=c;this.mask=m;this.colSizes=Array(c+1);this.rowSizes=Array(r+1)},function $prototype(){var DEF_CONSTR=new pkg.Constraints();this.getSizes=function(c,isRow){var max=isRow?this.rows:this.cols,res=isRow?this.rowSizes:this.colSizes;res[max]=0;for(var i=0;imax?d:max)}}return max};this.calcColSize=function(col,c){var max=0,r=0,i=0;while((i=zebra.util.indexByPoint(r,col,this.cols))max?d:max)}r++}return max};this.calcPreferredSize=function(c){return{width:this.getSizes(c,false)[this.cols],height:this.getSizes(c,true)[this.rows]}};this.doLayout=function(c){var rows=this.rows,cols=this.cols,colSizes=this.getSizes(c,false),rowSizes=this.getSizes(c,true),top=c.getTop(),left=c.getLeft();if((this.mask&pkg.HORIZONTAL)>0){var dw=c.width-left-c.getRight()-colSizes[cols];for(var i=0;i0){var dh=c.height-top-c.getBottom()-rowSizes[rows];for(var i=0;i=0;i--){var c=$canvases[i];if(c.isFullScreen){c.setLocation(0,0);c.setSize(window.innerWidth,window.innerHeight)}c.recalcOffset()}}pkg.$view=function(v){if(v==null){return null}if(v.paint){return v}if(zebra.isString(v)){return rgb.hasOwnProperty(v)?rgb[v]:(pkg.borders&&pkg.borders.hasOwnProperty(v)?pkg.borders[v]:new rgb(v))}if(Array.isArray(v)){return new pkg.CompositeView(v)}if(typeof v!=="function"){return new pkg.ViewSet(v)}v=new pkg.View();v.paint=f;return v};pkg.$detectZCanvas=function(canvas){if(zebra.isString(canvas)){canvas=document.getElementById(canvas)}for(var i=0;canvas!=null&&i<$canvases.length;i++){if($canvases[i].canvas==canvas){return $canvases[i]}}return null};pkg.View=Class([function $prototype(){this.gap=2;this.getRight=this.getLeft=this.getBottom=this.getTop=function(){return this.gap};this.getPreferredSize=function(){return{width:0,height:0}};this.paint=function(g,x,y,w,h,c){}}]);pkg.Render=Class(pkg.View,[function $prototype(){this[""]=function(target){this.setTarget(target)};this.setTarget=function(o){if(this.target!=o){var old=this.target;this.target=o;if(this.targetWasChanged){this.targetWasChanged(old,o)}}}}]);pkg.Raised=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor)},function(brightest,middle){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.brightest);g.drawLine(x1,y1,x2,y1);g.drawLine(x1,y1,x1,y2);g.setColor(this.middle);g.drawLine(x2,y1,x2,y2+1);g.drawLine(x1,y2,x2,y2)}}]);pkg.Sunken=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor,pkg.darkBrColor)},function(brightest,middle,darkest){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle;this.darkest=darkest==null?"black":darkest},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.middle);g.drawLine(x1,y1,x2-1,y1);g.drawLine(x1,y1,x1,y2-1);g.setColor(this.brightest);g.drawLine(x2,y1,x2,y2+1);g.drawLine(x1,y2,x2,y2);g.setColor(this.darkest);g.drawLine(x1+1,y1+1,x1+1,y2);g.drawLine(x1+1,y1+1,x2,y1+1)}}]);pkg.Etched=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor)},function(brightest,middle){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.middle);g.drawLine(x1,y1,x1,y2-1);g.drawLine(x2-1,y1,x2-1,y2);g.drawLine(x1,y1,x2,y1);g.drawLine(x1,y2-1,x2-1,y2-1);g.setColor(this.brightest);g.drawLine(x2,y1,x2,y2);g.drawLine(x1+1,y1+1,x1+1,y2-1);g.drawLine(x1+1,y1+1,x2-1,y1+1);g.drawLine(x1,y2,x2+1,y2)}}]);pkg.Dotted=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){g.setColor(this.color);g.drawDottedRect(x,y,w,h)};this[""]=function(c){this.color=(c==null)?"black":c}}]);pkg.Border=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.color==null){return}var ps=g.lineWidth;g.lineWidth=this.width;if(this.radius>0){this.outline(g,x,y,w,h,d)}else{var dt=this.width/2;g.beginPath();g.rect(x+dt,y+dt,w-this.width,h-this.width)}g.setColor(this.color);g.stroke();g.lineWidth=ps};this.outline=function(g,x,y,w,h,d){if(this.radius<=0){return false}var r=this.radius,dt=this.width/2,xx=x+w-dt,yy=y+h-dt;x+=dt;y+=dt;g.beginPath();g.moveTo(x-1+r,y);g.lineTo(xx-r,y);g.quadraticCurveTo(xx,y,xx,y+r);g.lineTo(xx,yy-r);g.quadraticCurveTo(xx,yy,xx-r,yy);g.lineTo(x+r,yy);g.quadraticCurveTo(x,yy,x,yy-r);g.lineTo(x,y+r);g.quadraticCurveTo(x,y,x+r,y);return true};this[""]=function(c,w,r){this.color=(arguments.length===0)?"gray":c;this.width=(w==null)?1:w;this.radius=(r==null)?0:r;this.gap=this.width+Math.round(this.radius/4)}}]);pkg.RoundBorder=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.color!=null&&this.width>0){this.outline(g,x,y,w,h,d);g.setColor(this.color);g.stroke()}};this.outline=function(g,x,y,w,h,d){g.beginPath();g.lineWidth=this.width;g.arc(x+w/2,y+h/2,w/2,0,2*Math.PI,false);return true};this[""]=function(col,width){this.color=null;this.width=1;if(arguments.length>0){if(zebra.isNumber(col)){this.width=col}else{this.color=col;if(zebra.isNumber(width)){this.width=width}}}this.gap=this.width}}]);pkg.Gradient=Class(pkg.View,[function $prototype(){this[""]=function(){this.colors=Array.prototype.slice.call(arguments,0);if(zebra.isNumber(arguments[arguments.length-1])){this.orientation=arguments[arguments.length-1];this.colors.pop()}else{this.orientation=L.VERTICAL}};this.paint=function(g,x,y,w,h,dd){var d=(this.orientation==L.HORIZONTAL?[0,1]:[1,0]),x1=x*d[1],y1=y*d[0],x2=(x+w-1)*d[1],y2=(y+h-1)*d[0];if(this.gradient==null||this.gx1!=x1||this.gx2!=x2||this.gy1!=y1||this.gy2!=y2){this.gx1=x1;this.gx2=x2;this.gy1=y1;this.gy2=y2;this.gradient=g.createLinearGradient(x1,y1,x2,y2);for(var i=0;i4){this.x=x;this.y=y;this.width=w;this.height=h}else{this.x=this.y=this.width=this.height=0}if(zebra.isBoolean(arguments[arguments.length-1])===false){ub=w>0&&h>0&&w<64&&h<64}if(ub===true){this.buffer=document.createElement("canvas");this.buffer.width=0}};this.paint=function(g,x,y,w,h,d){if(this.target!=null&&w>0&&h>0){var img=this.target;if(this.buffer){img=this.buffer;if(img.width<=0){var ctx=img.getContext("2d");if(this.width>0){img.width=this.width;img.height=this.height;ctx.drawImage(this.target,this.x,this.y,this.width,this.height,0,0,this.width,this.height)}else{img.width=this.target.width;img.height=this.target.height;ctx.drawImage(this.target,0,0)}}}if(this.width>0&&!this.buffer){g.drawImage(img,this.x,this.y,this.width,this.height,x,y,w,h)}else{g.drawImage(img,x,y,w,h)}}};this.targetWasChanged=function(o,n){if(this.buffer){delete this.buffer}};this.getPreferredSize=function(){var img=this.target;return img==null?{width:0,height:0}:(this.width>0)?{width:this.width,height:this.height}:{width:img.width,height:img.height}}}]);pkg.Pattern=Class(pkg.Render,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.pattern==null){this.pattern=g.createPattern(this.target,"repeat")}g.rect(x,y,w,h);g.fillStyle=this.pattern;g.fill()}}]);pkg.CompositeView=Class(pkg.View,[function $prototype(){this.left=this.right=this.bottom=this.top=this.height=this.width=0;this.getTop=function(){return this.top};this.getLeft=function(){return this.left};this.getBottom=function(){return this.bottom};this.getRight=function(){return this.right};this.getPreferredSize=function(){return{width:this.width,height:this.height}};this.$recalc=function(v){var b=0,ps=v.getPreferredSize();if(v.getLeft){b=v.getLeft();if(b>this.left){this.left=b}}if(v.getRight){b=v.getRight();if(b>this.right){this.right=b}}if(v.getTop){b=v.getTop();if(b>this.top){this.top=b}}if(v.getBottom){b=v.getBottom();if(b>this.bottom){this.bottom=b}}if(ps.width>this.width){this.width=ps.width}if(ps.height>this.height){this.height=ps.height}if(this.voutline==null&&v.outline){this.voutline=v}};this.paint=function(g,x,y,w,h,d){for(var i=0;i1&&id[0]!="*"&&id[id.length-1]!="*"){var i=id.indexOf(".");if(i>0){var k=id.substring(0,i+1).concat("*");if(this.views.hasOwnProperty(k)){return(this.activeView=this.views[k])!=old}else{k="*"+id.substring(i);if(this.views.hasOwnProperty(k)){return(this.activeView=this.views[k])!=old}}}}}if(this.views.hasOwnProperty("*")){return(this.activeView=this.views["*"])!=old}return false};this[""]=function(args){if(args==null){throw new Error("Invalid null view set")}this.views={};this.activeView=null;for(var k in args){this.views[k]=pkg.$view(args[k]);if(this.views[k]){this.$recalc(this.views[k])}}this.activate("*")}}]);pkg.Bag=Class(zebra.util.Bag,[function $prototype(){this.usePropertySetters=true;this.contentLoaded=function(v){if(v==null||zebra.isNumber(v)||zebra.isBoolean(v)){return v}if(zebra.isString(v)){if(this.root&&v[0]=="%"&&v[1]=="r"){var s="%root%/";if(v.indexOf(s)===0){return this.root.join(v.substring(s.length))}}return v}if(Array.isArray(v)){for(var i=0;i0&&c.height>0&&c.isVisible){var p=c.parent,px=-c.x,py=-c.y;if(r==null){r={x:0,y:0,width:0,height:0}}else{r.x=r.y=0}r.width=c.width;r.height=c.height;while(p!=null&&r.width>0&&r.height>0){var xx=r.x>px?r.x:px,yy=r.y>py?r.y:py,w1=r.x+r.width,w2=px+p.width,h1=r.y+r.height,h2=py+p.height;r.width=(w10&&r.height>0?r:null}return null};pkg.configure=function(c){if(zebra.isString(c)){var path=c;c=function(conf){conf.loadByUrl(path,false)}}$configurators.push(c)};pkg.Font=function(name,style,size){if(arguments.length==1){name=name.replace(/[ ]+/," ");this.s=name.trim()}else{if(arguments.length==2){size=style;style=""}style=style.trim();this.s=[style,(style!==""?" ":""),size,"px ",name].join("")}$fmText.style.font=this.s;this.height=$fmText.offsetHeight;if(this.height===0){this.height=$fmText.offsetHeight}this.ascent=$fmImage.offsetTop-$fmText.offsetTop+1};pkg.Font.prototype.stringWidth=function(s){if(s.length===0){return 0}if($fmCanvas.font!=this.s){$fmCanvas.font=this.s}return($fmCanvas.measureText(s).width+0.5)|0};pkg.Font.prototype.charsWidth=function(s,off,len){if($fmCanvas.font!=this.s){$fmCanvas.font=this.s}return($fmCanvas.measureText(len==1?s[off]:s.substring(off,off+len)).width+0.5)|0};pkg.Font.prototype.toString=function(){return this.s};pkg.Cursor={DEFAULT:"default",MOVE:"move",WAIT:"wait",TEXT:"text",HAND:"pointer",NE_RESIZE:"ne-resize",SW_RESIZE:"sw-resize",SE_RESIZE:"se-resize",NW_RESIZE:"nw-resize",S_RESIZE:"s-resize",W_RESIZE:"w-resize",N_RESIZE:"n-resize",E_RESIZE:"e-resize",COL_RESIZE:"col-resize",HELP:"help"};var MouseListener=pkg.MouseListener=Interface(),FocusListener=pkg.FocusListener=Interface(),KeyListener=pkg.KeyListener=Interface(),Composite=pkg.Composite=Interface(),ChildrenListener=pkg.ChildrenListener=Interface(),CopyCutPaste=pkg.CopyCutPaste=Interface(),CL=pkg.ComponentListener=Interface();CL.ENABLED=1;CL.SHOWN=2;CL.MOVED=3;CL.SIZED=4;CL.ADDED=5;CL.REMOVED=6;var IE=pkg.InputEvent=Class([function $clazz(){this.MOUSE_UID=1;this.KEY_UID=2;this.FOCUS_UID=3;this.FOCUS_LOST=10;this.FOCUS_GAINED=11},function(target,id,uid){this.source=target;this.ID=id;this.UID=uid}]);var KE=pkg.KeyEvent=Class(IE,[function $clazz(){this.TYPED=15;this.RELEASED=16;this.PRESSED=17;this.M_CTRL=1;this.M_SHIFT=2;this.M_ALT=4;this.M_CMD=8},function $prototype(){this.reset=function(target,id,code,ch,mask){this.source=target;this.ID=id;this.code=code;this.mask=mask;this.ch=ch};this.isControlPressed=function(){return(this.mask&KE.M_CTRL)>0};this.isShiftPressed=function(){return(this.mask&KE.M_SHIFT)>0};this.isAltPressed=function(){return(this.mask&KE.M_ALT)>0};this.isCmdPressed=function(){return(this.mask&KE.M_CMD)>0}},function(target,id,code,ch,mask){this.$super(target,id,IE.KEY_UID);this.reset(target,id,code,ch,mask)}]);var ME=pkg.MouseEvent=Class(IE,[function $clazz(){this.CLICKED=21;this.PRESSED=22;this.RELEASED=23;this.ENTERED=24;this.EXITED=25;this.DRAGGED=26;this.DRAGSTARTED=27;this.DRAGENDED=28;this.MOVED=29;this.LEFT_BUTTON=128;this.RIGHT_BUTTON=512},function $prototype(){this.touchCounter=1;this.reset=function(target,id,ax,ay,mask,clicks){this.source=target;this.ID=id;this.absX=ax;this.absY=ay;this.mask=mask;this.clicks=clicks;var p=L.getTopParent(target);while(target!=p){ax-=target.x;ay-=target.y;target=target.parent}this.x=ax;this.y=ay};this.isActionMask=function(){return this.mask==ME.LEFT_BUTTON}},function(target,id,ax,ay,mask,clicks){this.$super(target,id,IE.MOUSE_UID);this.reset(target,id,ax,ay,mask,clicks)}]);var MDRAGGED=ME.DRAGGED,EM=null,MMOVED=ME.MOVED,MEXITED=ME.EXITED,KPRESSED=KE.PRESSED,MENTERED=ME.ENTERED,context=Object.getPrototypeOf(document.createElement("canvas").getContext("2d")),$mousePressedEvents={},$keyPressedCode=-1,$keyPressedOwner=null,$keyPressedModifiers=0,KE_STUB=new KE(null,KPRESSED,0,"x",0),ME_STUB=new ME(null,ME.PRESSED,0,0,0,1);pkg.paintManager=pkg.events=pkg.$mouseMoveOwner=null;document.addEventListener("mouseup",function(e){for(var k in $mousePressedEvents){var mp=$mousePressedEvents[k];if(mp.canvas!=null){mp.canvas.mouseReleased(k,mp)}}},false);var $alert=(function(){return this.alert}());window.alert=function(){if($keyPressedCode>0){KE_STUB.reset($keyPressedOwner,KE.RELEASED,$keyPressedCode,"",$keyPressedModifiers);EM.performInput(KE_STUB);$keyPressedCode=-1}$alert.apply(window,arguments);for(var k in $mousePressedEvents){var mp=$mousePressedEvents[k];if(mp.canvas!=null){mp.canvas.mouseReleased(k,mp)}}};context.setFont=function(f){f=(f.s!=null?f.s:f.toString());if(f!=this.font){this.font=f}};context.setColor=function(c){if(c==null){throw new Error("Null color")}c=(c.s?c.s:c.toString());if(c!=this.fillStyle){this.fillStyle=c}if(c!=this.strokeStyle){this.strokeStyle=c}};context.drawLine=function(x1,y1,x2,y2,w){if(arguments.length<5){w=1}var pw=this.lineWidth;this.beginPath();this.lineWidth=w;if(x1==x2){x1+=w/2;x2=x1}else{if(y1==y2){y1+=w/2;y2=y1}}this.moveTo(x1,y1);this.lineTo(x2,y2);this.stroke();this.lineWidth=pw};context.ovalPath=function(x,y,w,h){this.beginPath();x+=this.lineWidth;y+=this.lineWidth;w-=2*this.lineWidth;h-=2*this.lineWidth;var kappa=0.5522848,ox=(w/2)*kappa,oy=(h/2)*kappa,xe=x+w,ye=y+h,xm=x+w/2,ym=y+h/2;this.moveTo(x,ym);this.bezierCurveTo(x,ym-oy,xm-ox,y,xm,y);this.bezierCurveTo(xm+ox,y,xe,ym-oy,xe,ym);this.bezierCurveTo(xe,ym+oy,xm+ox,ye,xm,ye);this.bezierCurveTo(xm-ox,ye,x,ym+oy,x,ym)};context.polylinePath=function(xPoints,yPoints,nPoints){this.beginPath();this.moveTo(xPoints[0],yPoints[0]);for(var i=1;iMath.abs(dy)),slope=b?dy/dx:dx/dy,sign=b?(dx<0?-1:1):(dy<0?-1:1);if(b){compute=function(step){x+=step;y+=slope*step}}else{compute=function(step){x+=slope*step;y+=step}}ctx.moveTo(x,y);var dist=Math.sqrt(dx*dx+dy*dy),i=0;while(dist>=0.1){var idx=i%count;dl=distd.width-right){xx=d.width+right-ww}if(yy+hh>d.height-bottom){yy=d.height+bottom-hh}c.setLocation(xx,yy)};pkg.calcOrigin=function(x,y,w,h,px,py,t,tt,ll,bb,rr){if(arguments.length<8){tt=t.getTop();ll=t.getLeft();bb=t.getBottom();rr=t.getRight()}var dw=t.width,dh=t.height;if(dw>0&&dh>0){if(dw-ll-rr>w){var xx=x+px;if(xxdw-rr){px-=(xx-dw+rr)}}}if(dh-tt-bb>h){var yy=y+py;if(yydh-bb){py-=(yy-dh+bb)}}}return[px,py]}return[0,0]};pkg.loadImage=function(path,ready){var i=new Image();i.crossOrigin="";i.crossOrigin="anonymous";zebra.busy();if(arguments.length>1){i.onerror=function(){zebra.ready();ready(path,false,i)};i.onload=function(){zebra.ready();ready(path,true,i)}}else{i.onload=i.onerror=function(){zebra.ready()}}i.src=path;return i};pkg.Panel=Class(L.Layoutable,[function $prototype(){this.top=this.left=this.right=this.bottom=0;this.isEnabled=true;this.getCanvas=function(){var c=this;for(;c!=null&&c.$isMasterCanvas!==true;c=c.parent){}return c};this.notifyRender=function(o,n){if(o!=null&&o.ownerChanged){o.ownerChanged(null)}if(n!=null&&n.ownerChanged){n.ownerChanged(this)}};this.properties=function(p){for(var k in p){if(p.hasOwnProperty(k)){var v=p[k],m=zebra.getPropertySetter(this,k);if(v&&v.$new){v=v.$new()}if(m==null){this[k]=v}else{if(Array.isArray(v)){m.apply(this,v)}else{m.call(this,v)}}}}return this};this.load=function(jsonPath){new pkg.Bag(this).loadByUrl(jsonPath);return this};this.getComponentAt=function(x,y){var r=$cvp(this,temporary);if(r==null||(x=r.x+r.width||y>=r.y+r.height)){return null}var k=this.kids;if(k.length>0){for(var i=k.length;--i>=0;){var d=k[i];d=d.getComponentAt(x-d.x,y-d.y);if(d!=null){return d}}}return this.contains==null||this.contains(x,y)?this:null};this.vrp=function(){this.invalidate();if(this.isVisible&&this.parent!=null){this.repaint()}};this.getTop=function(){return this.border!=null?this.top+this.border.getTop():this.top};this.getLeft=function(){return this.border!=null?this.left+this.border.getLeft():this.left};this.getBottom=function(){return this.border!=null?this.bottom+this.border.getBottom():this.bottom};this.getRight=function(){return this.border!=null?this.right+this.border.getRight():this.right};this.isInvalidatedByChild=function(c){return true};this.kidAdded=function(index,constr,l){pkg.events.performComp(CL.ADDED,this,constr,l);if(l.width>0&&l.height>0){l.repaint()}else{this.repaint(l.x,l.y,1,1)}};this.kidRemoved=function(i,l){pkg.events.performComp(CL.REMOVED,this,null,l);if(l.isVisible){this.repaint(l.x,l.y,l.width,l.height)}};this.relocated=function(px,py){pkg.events.performComp(CL.MOVED,this,px,py);var p=this.parent,w=this.width,h=this.height;if(p!=null&&w>0&&h>0){var x=this.x,y=this.y,nx=xpx?x-px:px-x),h1=p.height-ny,h2=h+(y>py?y-py:py-y);pkg.paintManager.repaint(p,nx,ny,(w1pw)?this.width:pw,(this.height>ph)?this.height:ph)}};this.hasFocus=function(){return pkg.focusManager.hasFocus(this)};this.requestFocus=function(){pkg.focusManager.requestFocus(this)};this.requestFocusIn=function(timeout){if(arguments.length===0){timeout=50}var $this=this;setTimeout(function(){$this.requestFocus()},timeout)};this.setVisible=function(b){if(this.isVisible!=b){this.isVisible=b;this.invalidate();pkg.events.performComp(CL.SHOWN,this,-1,-1);if(this.parent!=null){if(b){this.repaint()}else{this.parent.repaint(this.x,this.y,this.width,this.height)}}}};this.setEnabled=function(b){if(this.isEnabled!=b){this.isEnabled=b;pkg.events.performComp(CL.ENABLED,this,-1,-1);if(this.kids.length>0){for(var i=0;i1){for(var i=0;i0&&this.height>0&&pkg.paintManager!=null){pkg.paintManager.repaint(this,x,y,w,h)}};this.removeAll=function(){if(this.kids.length>0){var size=this.kids.length,mx1=Number.MAX_VALUE,my1=mx1,mx2=0,my2=0;for(;size>0;size--){var child=this.kids[size-1];if(child.isVisible){var xx=child.x,yy=child.y;mx1=mx10){if(instanceOf(l,L.Layout)){this.setLayout(l)}else{this.properties(l)}}}}]);pkg.BaseLayer=Class(pkg.Panel,[function $prototype(){this.getFocusRoot=function(){return this};this.activate=function(b){var fo=pkg.focusManager.focusOwner;if(L.isAncestorOf(this,fo)===false){fo=null}if(b){pkg.focusManager.requestFocus(fo!=null?fo:this.pfo)}else{this.pfo=fo;pkg.focusManager.requestFocus(null)}}},function(id){if(id==null){throw new Error("Invalid layer id: "+id)}this.pfo=null;this.$super();this.id=id}]);pkg.RootLayer=Class(pkg.BaseLayer,[function $prototype(){this.layerMousePressed=function(x,y,m){return true};this.layerKeyPressed=function(code,m){return true}}]);pkg.ViewPan=Class(pkg.Panel,[function $prototype(){this.paint=function(g){if(this.view!=null){var l=this.getLeft(),t=this.getTop();this.view.paint(g,l,t,this.width-l-this.getRight(),this.height-t-this.getBottom(),this)}};this.setView=function(v){var old=this.view;v=pkg.$view(v);if(v!=old){this.view=v;this.notifyRender(old,v);this.vrp()}};this.calcPreferredSize=function(t){return this.view?this.view.getPreferredSize():{width:0,height:0}}}]);pkg.ImagePan=Class(pkg.ViewPan,[function(){this.$this(null)},function(img){this.setImage(img);this.$super()},function setImage(img){if(img&&zebra.isString(img)){var $this=this;pkg.loadImage(img,function(p,b,i){if(b){$this.setView(new pkg.Picture(i))}});return}this.setView(instanceOf(img,pkg.Picture)?img:new pkg.Picture(img))}]);pkg.Manager=Class([function(){if(pkg.events!=null&&pkg.events.addListener!=null){pkg.events.addListener(this)}}]);pkg.PaintManager=Class(pkg.Manager,[function $prototype(){var $timers={};this.repaint=function(c,x,y,w,h){if(arguments.length==1){x=y=0;w=c.width;h=c.height}if(w>0&&h>0&&c.isVisible===true){var r=$cvp(c,temporary);if(r==null){return}MB.intersection(r.x,r.y,r.width,r.height,x,y,w,h,r);if(r.width<=0||r.height<=0){return}x=r.x;y=r.y;w=r.width;h=r.height;var canvas=c;for(;canvas!=null&&canvas.$context==null;canvas=canvas.parent){}if(canvas!=null){var x2=canvas.width,y2=canvas.height;var cc=c;while(cc!=canvas){x+=cc.x;y+=cc.y;cc=cc.parent}if(x<0){w+=x;x=0}if(y<0){h+=y;y=0}if(w+x>x2){w=x2-x}if(h+y>y2){h=y2-y}if(w>0&&h>0){var da=canvas.$da;if(da.width>0){if(x>=da.x&&y>=da.y&&x+w<=da.x+da.width&&y+h<=da.y+da.height){return}MB.unite(da.x,da.y,da.width,da.height,x,y,w,h,da)}else{MB.intersection(0,0,canvas.width,canvas.height,x,y,w,h,da)}if(da.width>0&&$timers[canvas]==null){var $this=this;$timers[canvas]=setTimeout(function(){$timers[canvas]=null;if(canvas.$da.width<=0){return}var context=canvas.$context;try{canvas.validate();context.save();context.translate(canvas.x,canvas.y);context.clipRect(canvas.$da.x,canvas.$da.y,canvas.$da.width,canvas.$da.height);if(canvas.bg==null){context.clearRect(canvas.$da.x,canvas.$da.y,canvas.$da.width,canvas.$da.height)}$this.paint(context,canvas);context.restore();canvas.$da.width=-1}catch(e){zebra.print(e)}},50)}}}}};this.paint=function(g,c){var dw=c.width,dh=c.height,ts=g.stack[g.counter];if(dw!==0&&dh!==0&&ts.width>0&&ts.height>0&&c.isVisible){c.validate();g.save();g.translate(c.x,c.y);g.clipRect(0,0,dw,dh);ts=g.stack[g.counter];var c_w=ts.width,c_h=ts.height;if(c_w>0&&c_h>0){this.paintComponent(g,c);var count=c.kids.length,c_x=ts.x,c_y=ts.y;for(var i=0;ic_x?kidX:c_x),ih=(kidYHc_y?kidY:c_y);if(iw>0&&ih>0){this.paint(g,kid)}}}if(c.paintOnTop!=null){c.paintOnTop(g)}}g.restore()}}}]);pkg.PaintManImpl=Class(pkg.PaintManager,[function $prototype(){this.paintComponent=function(g,c){var b=c.bg!=null&&(c.parent==null||c.bg!=c.parent.bg);if((c.border!=null&&c.border.outline!=null)&&(b||c.update!=null)&&c.border.outline(g,0,0,c.width,c.height,c)){g.save();g.clip();if(b){c.bg.paint(g,0,0,c.width,c.height,c)}if(c.update!=null){c.update(g)}g.restore()}else{if(b){c.bg.paint(g,0,0,c.width,c.height,c)}if(c.update!=null){c.update(g)}}if(c.border!=null){c.border.paint(g,0,0,c.width,c.height,c)}if(c.paint!=null){var left=c.getLeft(),top=c.getTop(),bottom=c.getBottom(),right=c.getRight();if(left+right+top+bottom>0){var ts=g.stack[g.counter];if(ts.width>0&&ts.height>0){var cx=ts.x,cy=ts.y,x1=(cx>left?cx:left),y1=(cy>top?cy:top),cxcw=cx+ts.width,cych=cy+ts.height,cright=c.width-right,cbottom=c.height-bottom;g.save();g.clipRect(x1,y1,(cxcw0){var isNComposite=(instanceOf(t,Composite)===false);for(var i=index;i>=0&&i0&&cc.height>0&&(isNComposite||(t.catchInput&&t.catchInput(cc)===false))&&((cc.canHaveFocus&&cc.canHaveFocus())||(cc=this.fd(cc,d>0?0:cc.kids.length-1,d))!=null)){return cc}}}return null};this.ff=function(c,d){var top=c;while(top&&top.getFocusRoot==null){top=top.parent}top=top.getFocusRoot();for(var index=(d>0)?0:c.kids.length-1;c!=top.parent;){var cc=this.fd(c,index,d);if(cc!=null){return cc}cc=c;c=c.parent;if(c!=null){index=d+c.indexOf(cc)}}return this.fd(top,d>0?0:top.kids.length-1,d)};this.requestFocus=function(c){if(c!=this.focusOwner&&(c==null||this.isFocusable(c))){if(c!=null){var canvas=c.getCanvas();if(canvas.$focusGainedCounter===0){canvas.$prevFocusOwner=c;if(zebra.instanceOf(canvas.$prevFocusOwner,pkg.HtmlElement)==false){canvas.requestFocus();return}}}var oldFocusOwner=this.focusOwner;if(c!=null){var nf=EM.getEventDestination(c);if(nf==null||oldFocusOwner==nf){return}this.focusOwner=nf}else{this.focusOwner=c}if(oldFocusOwner!=null){var ofc=oldFocusOwner.getCanvas();if(ofc!=null){ofc.$prevFocusOwner=oldFocusOwner}}if(oldFocusOwner!=null){pkg.events.performInput(new IE(oldFocusOwner,IE.FOCUS_LOST,IE.FOCUS_UID))}if(this.focusOwner!=null){pkg.events.performInput(new IE(this.focusOwner,IE.FOCUS_GAINED,IE.FOCUS_UID))}return this.focusOwner}return null};this.mousePressed=function(e){if(e.isActionMask()){this.requestFocus(e.source)}}}]);pkg.CommandManager=Class(pkg.Manager,KeyListener,[function $prototype(){this.keyPressed=function(e){var fo=pkg.focusManager.focusOwner;if(fo!=null&&this.keyCommands[e.code]){var c=this.keyCommands[e.code];if(c&&c[e.mask]!=null){c=c[e.mask];this._.fired(c);if(fo[c.command]){if(c.args&&c.args.length>0){fo[c.command].apply(fo,c.args)}else{fo[c.command]()}}}}};this.parseKey=function(k){var m=0,c=0,r=k.split("+");for(var i=0;i25){for(var i=0;i=0)||c.push(l)};this.r_=function(c,l){(c.indexOf(l)<0)||c.splice(i,1)}},function(){this.m_l=[];this.k_l=[];this.f_l=[];this.c_l=[];this.$super()}]);pkg.$createContext=function(canvas,w,h){var ctx=canvas.getContext("2d");var $save=ctx.save,$restore=ctx.restore,$rotate=ctx.rotate,$scale=ctx.$scale=ctx.scale,$translate=ctx.translate,$getImageData=ctx.getImageData;ctx.$ratio=$ratio/(ctx.webkitBackingStorePixelRatio||ctx.mozBackingStorePixelRatio||ctx.msBackingStorePixelRatio||ctx.backingStorePixelRatio||1);ctx.counter=0;ctx.stack=Array(50);for(var i=0;ixx?x:xx;c.width=(xwyy?y:yy;c.height=(yh0){var fo=pkg.focusManager.focusOwner;if(fo!=null){KE_STUB.reset(fo,KE.TYPED,e.keyCode,String.fromCharCode(e.charCode),km(e));if(EM.performInput(KE_STUB)){e.preventDefault()}}}if(e.keyCode<47){e.preventDefault()}};this.keyPressed=function(e){$keyPressedCode=e.keyCode;var code=e.keyCode,m=km(e),b=false;for(var i=this.kids.length-1;i>=0;i--){var l=this.kids[i];if(l.layerKeyPressed&&l.layerKeyPressed(code,m)){break}}var focusOwner=pkg.focusManager.focusOwner;if(pkg.clipboardTriggerKey>0&&e.keyCode==pkg.clipboardTriggerKey&&focusOwner!=null&&instanceOf(focusOwner,CopyCutPaste)){$clipboardCanvas=this;$clipboard.style.display="block";this.canvas.onfocus=this.canvas.onblur=null;$clipboard.value="1";$clipboard.select();$clipboard.focus();return}$keyPressedOwner=focusOwner;$keyPressedModifiers=m;if(focusOwner!=null){KE_STUB.reset(focusOwner,KPRESSED,code,code<47?KE.CHAR_UNDEFINED:"?",m);b=EM.performInput(KE_STUB);if(code==KE.ENTER){KE_STUB.reset(focusOwner,KE.TYPED,code,"\n",m);b=EM.performInput(KE_STUB)||b}}if((code<47&&code!=32)||b){e.preventDefault()}};this.keyReleased=function(e){$keyPressedCode=-1;var fo=pkg.focusManager.focusOwner;if(fo!=null){KE_STUB.reset(fo,KE.RELEASED,e.keyCode,KE.CHAR_UNDEFINED,km(e));if(EM.performInput(KE_STUB)){e.preventDefault()}}};this.mouseEntered=function(id,e){var mp=$mousePressedEvents[id];this.recalcOffset();if(mp==null||mp.canvas==null){var x=$meX(e,this),y=$meY(e,this),d=this.getComponentAt(x,y);if(pkg.$mouseMoveOwner!=null&&d!=pkg.$mouseMoveOwner){var prev=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(prev,MEXITED,x,y,-1,0);EM.performInput(ME_STUB)}if(d!=null&&d.isEnabled){pkg.$mouseMoveOwner=d;ME_STUB.reset(d,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}};this.mouseExited=function(id,e){var mp=$mousePressedEvents[id];if((mp==null||mp.canvas==null)&&pkg.$mouseMoveOwner!=null){var p=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(p,MEXITED,$meX(e,this),$meY(e,this),-1,0);EM.performInput(ME_STUB)}};this.mouseMoved=function(id,e){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){if(mp.component!=null&&mp.canvas.canvas==e.target){var x=this.$context.tX(e.pageX-this.offx,e.pageY-this.offy),y=this.$context.tY(e.pageX-this.offx,e.pageY-this.offy),m=mp.button;if(mp.draggedComponent==null){var xx=this.$context.tX(mp.pageX-this.offx,mp.pageY-this.offy),yy=this.$context.tY(mp.pageX-this.offx,mp.pageY-this.offy),d=(pkg.$mouseMoveOwner==null)?this.getComponentAt(xx,yy):pkg.$mouseMoveOwner;if(d!=null&&d.isEnabled===true){mp.draggedComponent=d;ME_STUB.reset(d,ME.DRAGSTARTED,xx,yy,m,0);EM.performInput(ME_STUB);if(xx!=x||yy!=y){ME_STUB.reset(d,MDRAGGED,x,y,m,0);EM.performInput(ME_STUB)}}}else{ME_STUB.reset(mp.draggedComponent,MDRAGGED,x,y,m,0);EM.performInput(ME_STUB)}}}else{var x=this.$context.tX(e.pageX-this.offx,e.pageY-this.offy),y=this.$context.tY(e.pageX-this.offx,e.pageY-this.offy),d=this.getComponentAt(x,y);if(pkg.$mouseMoveOwner!=null){if(d!=pkg.$mouseMoveOwner){var old=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(old,MEXITED,x,y,-1,0);EM.performInput(ME_STUB);if(d!=null&&d.isEnabled===true){pkg.$mouseMoveOwner=d;ME_STUB.reset(pkg.$mouseMoveOwner,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}else{if(d!=null&&d.isEnabled){ME_STUB.reset(d,MMOVED,x,y,-1,0);EM.performInput(ME_STUB)}}}else{if(d!=null&&d.isEnabled===true){pkg.$mouseMoveOwner=d;ME_STUB.reset(d,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}}};this.mouseReleased=function(id,e){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){var x=$meX(e,this),y=$meY(e,this),po=mp.component;if(mp.draggedComponent!=null){ME_STUB.reset(mp.draggedComponent,ME.DRAGENDED,x,y,mp.button,0);EM.performInput(ME_STUB)}if(po!=null){if(mp.draggedComponent==null&&(e.touch==null||e.touch.group==null)){ME_STUB.reset(po,ME.CLICKED,x,y,mp.button,mp.clicks);EM.performInput(ME_STUB)}ME_STUB.reset(po,ME.RELEASED,x,y,mp.button,mp.clicks);EM.performInput(ME_STUB)}if(zebra.isTouchable===false){var mo=pkg.$mouseMoveOwner;if(mp.draggedComponent!=null||(po!=null&&po!=mo)){var nd=this.getComponentAt(x,y);if(nd!=mo){if(mo!=null){ME_STUB.reset(mo,MEXITED,x,y,-1,0);EM.performInput(ME_STUB)}if(nd!=null&&nd.isEnabled===true){pkg.$mouseMoveOwner=nd;ME_STUB.reset(nd,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}}}$mousePressedEvents[id].canvas=null}};this.mousePressed=function(id,e,button){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){this.mouseReleased(id,mp)}var clicks=mp!=null&&(new Date().getTime()-mp.time)<=pkg.doubleClickDelta?2:1;mp=$mousePressedEvents[id]={pageX:e.pageX,pageY:e.pageY,identifier:id,target:e.target,canvas:this,button:button,component:null,mouseDragged:null,time:(new Date()).getTime(),clicks:clicks};var x=$meX(e,this),y=$meY(e,this);mp.x=x;mp.y=y;for(var i=this.kids.length-1;i>=0;i--){var l=this.kids[i];if(l.layerMousePressed!=null&&l.layerMousePressed(x,y,button)){break}}var d=this.getComponentAt(x,y);if(d!=null&&d.isEnabled===true){mp.component=d;ME_STUB.reset(d,ME.PRESSED,x,y,button,clicks);EM.performInput(ME_STUB)}if(document.activeElement!=this.canvas){this.canvas.focus()}};this.getComponentAt=function(x,y){for(var i=this.kids.length;--i>=0;){var tl=this.kids[i];if(tl.isLayerActiveAt==null||tl.isLayerActiveAt(x,y)){return EM.getEventDestination(tl.getComponentAt(x,y))}}return null};this.recalcOffset=function(){var poffx=this.offx,poffy=this.offy,ba=this.canvas.getBoundingClientRect();this.offx=((ba.left+0.5)|0)+measure(this.canvas,"padding-left")+window.pageXOffset;this.offy=((ba.top+0.5)|0)+measure(this.canvas,"padding-top")+window.pageYOffset;if(this.offx!=poffx||this.offy!=poffy){this.relocated(this,poffx,poffy)}};this.getLayer=function(id){return this[id]};this.setStyles=function(styles){for(var k in styles){this.canvas.style[k]=styles[k]}};this.setAttribute=function(name,value){this.canvas.setAttribute(name,value)};this.relocated=function(px,py){pkg.events.performComp(CL.MOVED,this,px,py)};this.resized=function(pw,ph){pkg.events.performComp(CL.SIZED,this,pw,ph)};this.repaint=function(x,y,w,h){if((document.contains!=null&&document.contains(this.canvas)===false)||this.canvas.style.visibility=="hidden"){return}if(arguments.length===0){x=y=0;w=this.width;h=this.height}if(w>0&&h>0&&pkg.paintManager!=null){pkg.paintManager.repaint(this,x,y,w,h)}}},function(){this.$this(400,400)},function(w,h){this.$this(this.toString(),w,h)},function(canvas){this.$this(canvas,-1,-1)},function(canvas,w,h){this.$focusGainedCounter=0;var pc=canvas,$this=this;this.nativeListeners={onmousemove:null,onmousedown:null,onmouseup:null,onmouseover:null,onmouseout:null,onkeydown:null,onkeyup:null,onkeypress:null};var addToBody=true;if(zebra.isBoolean(canvas)){addToBody=canvas;canvas=null}else{if(zebra.isString(canvas)){canvas=document.getElementById(canvas);if(canvas!=null&&pkg.$detectZCanvas(canvas)){throw new Error("Canvas id='"+pc+"'' is already in use")}}}if(canvas==null){canvas=document.createElement("canvas");canvas.setAttribute("class","zebcanvas");canvas.setAttribute("width",w<=0?"400":""+w);canvas.setAttribute("height",h<=0?"400":""+h);canvas.setAttribute("id",pc);if(addToBody){document.body.appendChild(canvas)}}if(canvas.getAttribute("tabindex")===null){canvas.setAttribute("tabindex","1")}this.$da={x:0,y:0,width:-1,height:0};this.canvas=canvas;this.$super(new pkg.zCanvas.Layout());for(var i=0;i0){e.preventDefault();return}if(pkg.focusManager.canvasFocusGained){pkg.focusManager.canvasFocusGained($this)}};this.canvas.onblur=function(e){if(document.activeElement==$this.canvas){e.preventDefault();return}if($this.$focusGainedCounter!==0){$this.$focusGainedCounter=0;if(pkg.focusManager.canvasFocusLost){pkg.focusManager.canvasFocusLost($this)}}};var addons=pkg.zCanvas.addons;if(addons){for(var i=0;i0){$configurators.shift()(pkg.$configuration)}pkg.$configuration.end();EM=pkg.events;if(pkg.clipboardTriggerKey>0){$clipboard=document.createElement("textarea");$clipboard.setAttribute("style","display:none; position: absolute; left: -99em; top:-99em;");$clipboard.onkeydown=function(ee){$clipboardCanvas.keyPressed(ee);$clipboard.value="1";$clipboard.select()};$clipboard.onkeyup=function(ee){if(ee.keyCode==pkg.clipboardTriggerKey){$clipboard.style.display="none";$clipboardCanvas.canvas.focus();$clipboardCanvas.canvas.onblur=$clipboardCanvas.focusLost;$clipboardCanvas.canvas.onfocus=$clipboardCanvas.focusGained}$clipboardCanvas.keyReleased(ee)};$clipboard.onblur=function(){this.value="";this.style.display="none";$clipboardCanvas.canvas.focus()};$clipboard.oncopy=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.copy){var v=pkg.focusManager.focusOwner.copy();$clipboard.value=v==null?"":v;$clipboard.select()}};$clipboard.oncut=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.cut){$clipboard.value=pkg.focusManager.focusOwner.cut();$clipboard.select()}};if(zebra.isFF){$clipboard.addEventListener("input",function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.paste){pkg.focusManager.focusOwner.paste($clipboard.value)}},false)}else{$clipboard.onpaste=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.paste){var txt=(typeof ee.clipboardData=="undefined")?window.clipboardData.getData("Text"):ee.clipboardData.getData("text/plain");pkg.focusManager.focusOwner.paste(txt)}$clipboard.value=""}}document.body.appendChild($clipboard)}document.addEventListener("DOMNodeInserted",function(e){elBoundsUpdated()},false);document.addEventListener("DOMNodeRemoved",function(e){elBoundsUpdated();for(var i=$canvases.length-1;i>=0;i--){var canvas=$canvases[i];if(e.target==canvas.canvas){$canvases.splice(i,1);if(canvas.saveBeforeLeave){canvas.saveBeforeLeave()}break}}},false);window.addEventListener("resize",function(e){elBoundsUpdated()},false);window.onbeforeunload=function(e){var msgs=[];for(var i=$canvases.length-1;i>=0;i--){if($canvases[i].saveBeforeLeave){var m=$canvases[i].saveBeforeLeave();if(m!=null){msgs.push(m)}}}if(msgs.length>0){var message=msgs.join(" ");if(typeof e==="undefined"){e=window.event}if(e){e.returnValue=message}return message}};if(zebra.isIE){window.focus()}}catch(e){zebra.error(e.toString());throw e}finally{zebra.ready()}})})(zebra("ui"),zebra.Class,zebra.Interface);(function(pkg,Class){var PI4=Math.PI/4,PI4_3=PI4*3,$abs=Math.abs,$atan2=Math.atan2,L=zebra.layout;pkg.TouchHandler=Class([function $prototype(){this.touchCounter=0;this.start=function(e){if(this.touchCounter>e.touches.length){return}if(this.timer==null){var $this=this;this.timer=setTimeout(function(){$this.Q();$this.timer=null},25)}var t=e.touches;for(var i=0;i1){for(var i=0;i0){for(var i=0;i0&&t.dx>0),dys=(dy<0&&t.dy<0)||(dy>0&&t.dy>0);t.pageX=nmt.pageX;t.pageY=nmt.pageY;if($abs(dx)>2||$abs(dy)>2){gamma=$atan2(dy,dx);if(gamma>-PI4){d=(gamma-PI4_3)?L.TOP:L.LEFT}if(t.direction!=d){if(t.dc<3){t.direction=d}t.dc=0}else{t.dc++}t.gamma=gamma}if($this.timer==null){t.dx=dx;t.dy=dy;$this.moved(t)}else{$this.dc=0}}}}e.preventDefault()},false)}}])})(zebra("ui"),zebra.Class);(function(pkg,Class,Interface){pkg.ExternalEditor=Interface();var MB=zebra.util,Composite=pkg.Composite,ME=pkg.MouseEvent,MouseListener=pkg.MouseListener,Cursor=pkg.Cursor,TextModel=zebra.data.TextModel,View=pkg.View,Listeners=zebra.util.Listeners,Actionable=zebra.util.Actionable,KE=pkg.KeyEvent,L=zebra.layout,instanceOf=zebra.instanceOf,timer=zebra.util.timer,KeyListener=pkg.KeyListener,ChildrenListener=pkg.ChildrenListener,$invalidA="Invalid alignment",$invalidO="Invalid orientation",$invalidC="Invalid constraints";pkg.$ViewsSetter=function(v){this.views={};for(var k in v){if(v.hasOwnProperty(k)){this.views[k]=pkg.$view(v[k])}}this.vrp()};pkg.MouseWheelSupport=Class([function $prototype(){this.mouseWheelMoved=function(e){var owner=pkg.$mouseMoveOwner;while(owner!=null&&instanceOf(owner,pkg.ScrollPan)===false){owner=owner.parent}if(owner!=null){var d=[0,0];d[0]=(e.detail?e.detail:e.wheelDelta/120);if(e.axis){if(e.axis===e.HORIZONTAL_AXIS){d[1]=d[0];d[0]=0}}if(d[0]>1){d[0]=~~(d[0]/3)}if(!e.detail){d[0]=-d[0]}for(var i=0;i<2;i++){if(d[i]!==0){var bar=i===0?owner.vBar:owner.hBar;if(bar&&bar.isVisible){bar.position.setOffset(bar.position.offset+d[i]*bar.pageIncrement)}}}e.preventDefault?e.preventDefault():e.returnValue=false}}},function setup(canvas){if(canvas==null){throw new Error("Null canvas")}var $this=this;canvas.canvas.addEventListener("mousewheel",function(e){$this.mouseWheelMoved(e)},false);canvas.canvas.addEventListener("DOMMouseScroll",function(e){$this.mouseWheelMoved(e)},false)}]);pkg.CompRender=Class(pkg.Render,[function $prototype(){this.getPreferredSize=function(){return this.target==null?{width:0,height:0}:this.target.getPreferredSize()};this.paint=function(g,x,y,w,h,d){var c=this.target;if(c!=null){c.validate();var prevW=-1,prevH=0,cx=x-c.x,cy=y-c.y;if(c.getCanvas()==null){prevW=c.width;prevH=c.height;c.setSize(w,h)}g.translate(cx,cy);pkg.paintManager.paint(g,c);g.translate(-cx,-cy);if(prevW>=0){c.setSize(prevW,prevH);c.validate()}}}}]);pkg.Line=Class(pkg.Panel,[function(){this.$this(L.VERTICAL)},function(orient){orient=L.$constraints(orient);if(orient!=L.HORIZONTAL&&orient!=L.VERTICAL){throw new Error($invalidO)}this.orient=orient;this.$super()},function $prototype(){this.lineWidth=1;this.lineColor="black";this.paint=function(g){g.setColor(this.lineColor);if(this.orient==L.HORIZONTAL){var yy=this.top+~~((this.height-this.top-this.bottom-1)/2);g.drawLine(this.left,yy,this.width-this.right-this.left,yy,this.lineWidth)}else{var xx=this.left+~~((this.width-this.left-this.right-1)/2);g.drawLine(xx,this.top,xx,this.height-this.top-this.bottom,this.lineWidth)}};this.getPreferredSize=function(){return{width:this.lineWidth,height:this.lineWidth}}}]);pkg.TextRender=Class(pkg.Render,zebra.util.Position.Metric,[function $prototype(){this.owner=null;this.getLineIndent=function(){return 1};this.getLines=function(){return this.target.getLines()};this.getLineSize=function(l){return this.target.getLine(l).length+1};this.getLineHeight=function(l){return this.font.height};this.getMaxOffset=function(){return this.target.getTextLength()};this.ownerChanged=function(v){this.owner=v};this.paintLine=function(g,x,y,line,d){g.fillText(this.getLine(line),x,y+this.font.ascent)};this.getLine=function(r){return this.target.getLine(r)};this.targetWasChanged=function(o,n){if(o!=null){o._.remove(this)}if(n!=null){n._.add(this);this.invalidate(0,this.getLines())}else{this.lines=0}};this.getValue=function(){var text=this.target;return text==null?null:text.getValue()};this.lineWidth=function(line){this.recalc();return this.target.getExtraChar(line)};this.recalc=function(){if(this.lines>0&&this.target!=null){var text=this.target;if(text!=null){if(this.lines>0){for(var i=this.startLine+this.lines-1;i>=this.startLine;i--){text.setExtraChar(i,this.font.stringWidth(this.getLine(i)))}this.startLine=this.lines=0}this.textWidth=0;var size=text.getLines();for(var i=0;ithis.textWidth){this.textWidth=len}}this.textHeight=this.getLineHeight()*size+(size-1)*this.getLineIndent()}}};this.textUpdated=function(src,b,off,size,ful,updatedLines){if(b===false){if(this.lines>0){var p1=ful-this.startLine,p2=this.startLine+this.lines-ful-updatedLines;this.lines=((p1>0)?p1:0)+((p2>0)?p2:0)+1;this.startLine=this.startLine0){if(ful<=this.startLine){this.startLine+=(updatedLines-1)}else{if(ful<(this.startLine+size)){size+=(updatedLines-1)}}}this.invalidate(ful,updatedLines)}};this.invalidate=function(start,size){if(size>0&&(this.startLine!=start||size!=this.lines)){if(this.lines===0){this.startLine=start;this.lines=size}else{var e=this.startLine+this.lines;this.startLine=start0&&ts.height>0){var lineIndent=this.getLineIndent(),lineHeight=this.getLineHeight(),lilh=lineHeight+lineIndent,startLine=0;w=ts.width(ts.y+ts.height)){return}}var size=this.target.getLines();if(startLinelineIndent)?1:0);if(startLine+lines>size){lines=size-startLine}y+=startLine*lilh;g.setFont(this.font);if(d==null||d.isEnabled===true){g.setColor(this.color);for(var i=0;i=p1[0]&&line<=p2[0]){var s=this.getLine(line),lw=this.lineWidth(line),xx=x;if(line==p1[0]){var ww=this.font.charsWidth(s,0,p1[1]);xx+=ww;lw-=ww;if(p1[0]==p2[0]){lw-=this.font.charsWidth(s,p2[1],s.length-p2[1])}}else{if(line==p2[0]){lw=this.font.charsWidth(s,0,p2[1])}}this.paintSelection(g,xx,y,lw===0?1:lw,lilh,line,d);g.setColor(this.color)}}}this.paintLine(g,x,y,i+startLine,d);y+=lilh}}else{for(var i=0;i0){buf[ln.length-1]=ln[ln.length-1]}return buf.join("")}]);pkg.TabBorder=Class(View,[function(t){this.$this(t,1)},function(t,w){this.type=t;this.gap=4+w;this.width=w;this.onColor1=pkg.palette.black;this.onColor2=pkg.palette.gray5;this.offColor=pkg.palette.gray1;this.fillColor1="#DCF0F7";this.fillColor2=pkg.palette.white;this.fillColor3=pkg.palette.gray7},function $prototype(){this.paint=function(g,x,y,w,h,d){var xx=x+w-1,yy=y+h-1,o=d.parent.orient,t=this.type,s=this.width,dt=s/2;if(d.isEnabled){g.setColor(t==2?this.fillColor1:this.fillColor2);g.fillRect(x+1,y,w-3,h);g.setColor(this.fillColor3);g.fillRect(x+1,y+2,w-3,~~((h-6)/2))}g.setColor((t===0||t==2)?this.onColor1:this.offColor);switch(o){case L.LEFT:g.drawLine(x+2,y,xx+1,y);g.drawLine(x,y+2,x,yy-2);g.drawLine(x,y+2,x+2,y);g.drawLine(x+2,yy,xx+1,yy);g.drawLine(x,yy-2,x+2,yy);if(t==1){g.setColor(this.onColor2);g.drawLine(x+2,yy-1,xx,yy-1);g.drawLine(x+2,yy,xx,yy)}break;case L.RIGHT:g.drawLine(x,y,xx-2,y);g.drawLine(xx-2,y,xx,y+2);g.drawLine(xx,y+2,xx,yy-2);g.drawLine(xx,yy-2,xx-2,yy);g.drawLine(x,yy,xx-2,yy);if(t==1){g.setColor(this.onColor2);g.drawLine(xx-2,yy-1,x,yy-1);g.drawLine(xx-2,yy,x,yy)}break;case L.TOP:g.lineWidth=s;g.beginPath();g.moveTo(x+dt,yy+1);g.lineTo(x+dt,y+dt+2);g.lineTo(x+dt+2,y+dt);g.lineTo(xx-dt-1,y+dt);g.lineTo(xx-dt+1,y+dt+2);g.lineTo(xx-dt+1,yy+1);g.stroke();if(t===0){g.setColor(this.onColor2);g.beginPath();g.moveTo(xx-dt-2,y+dt+1);g.lineTo(xx-dt,y+dt+3);g.lineTo(xx-dt,yy-dt+1);g.stroke()}g.lineWidth=1;break;case L.BOTTOM:g.drawLine(x+2,yy,xx-2,yy);g.drawLine(x,yy-2,x,y-2);g.drawLine(xx,yy-2,xx,y-2);g.drawLine(x,yy-2,x+2,yy);g.drawLine(xx,yy-2,xx-2,yy);if(t==1){g.setColor(this.onColor2);g.drawLine(xx-1,yy-2,xx-1,y-2);g.drawLine(xx,yy-2,xx,y-2)}break;default:throw new Error("Invalid tab orientation")}};this.getTop=function(){return 3};this.getBottom=function(){return 2}}]);pkg.TitledBorder=Class(pkg.Render,[function $prototype(){this.getTop=function(){return this.target.getTop()};this.getLeft=function(){return this.target.getLeft()};this.getRight=function(){return this.target.getRight()};this.getBottom=function(){return this.target.getBottom()};this.outline=function(g,x,y,w,h,d){var xx=x+w,yy=y+h;if(d.getTitleInfo){var r=d.getTitleInfo();if(r!=null){var o=r.orient,cx=x,cy=y;if(o==L.BOTTOM||o==L.TOP){switch(this.lineAlignment){case L.CENTER:cy=r.y+~~(r.height/2);break;case L.TOP:cy=r.y+(o==L.BOTTOM?1:0)*(r.height-1);break;case L.BOTTOM:cy=r.y+(o==L.BOTTOM?0:1)*(r.height-1);break}if(o==L.BOTTOM){yy=cy}else{y=cy}}else{switch(this.lineAlignment){case L.CENTER:cx=r.x+~~(r.width/2);break;case L.TOP:cx=r.x+((o==L.RIGHT)?1:0)*(r.width-1);break;case L.BOTTOM:cx=r.x+((o==L.RIGHT)?0:1)*(r.width-1);break}if(o==L.RIGHT){xx=cx}else{x=cx}}}}if(this.target&&this.target.outline){return this.target.outline(g,x,y,xx-x,yy-y,d)}g.rect(x,y,xx-x,yy-y);return true};this.paint=function(g,x,y,w,h,d){if(d.getTitleInfo){var r=d.getTitleInfo();if(r!=null){var xx=x+w,yy=y+h,o=r.orient;g.save();g.beginPath();var br=(o==L.RIGHT),bb=(o==L.BOTTOM),dt=(bb||br)?-1:1;if(bb||o==L.TOP){var sy=y,syy=yy,cy=0;switch(this.lineAlignment){case L.CENTER:cy=r.y+~~(r.height/2);break;case L.TOP:cy=r.y+(bb?1:0)*(r.height-1);break;case L.BOTTOM:cy=r.y+(bb?0:1)*(r.height-1);break}if(bb){sy=yy;syy=y}g.moveTo(r.x+1,sy);g.lineTo(r.x+1,r.y+dt*(r.height));g.lineTo(r.x+r.width-1,r.y+dt*(r.height));g.lineTo(r.x+r.width-1,sy);g.lineTo(xx,sy);g.lineTo(xx,syy);g.lineTo(x,syy);g.lineTo(x,sy);g.lineTo(r.x,sy);if(bb){yy=cy}else{y=cy}}else{var sx=x,sxx=xx,cx=0;if(br){sx=xx;sxx=x}switch(this.lineAlignment){case L.CENTER:cx=r.x+~~(r.width/2);break;case L.TOP:cx=r.x+(br?1:0)*(r.width-1);break;case L.BOTTOM:cx=r.x+(br?0:1)*(r.width-1);break}g.moveTo(sx,r.y);g.lineTo(r.x+dt*(r.width),r.y);g.lineTo(r.x+dt*(r.width),r.y+r.height-1);g.lineTo(sx,r.y+r.height-1);g.lineTo(sx,yy);g.lineTo(sxx,yy);g.lineTo(sxx,y);g.lineTo(sx,y);g.lineTo(sx,r.y);if(br){xx=cx}else{x=cx}}g.clip();this.target.paint(g,x,y,xx-x,yy-y,d);g.restore()}}else{this.target.paint(g,x,y,w,h,d)}}},function(border){this.$this(border,L.BOTTOM)},function(b,a){a=L.$constraints(a);if(b==null&&a!=L.BOTTOM&&a!=L.TOP&&a!=L.CENTER){throw new Error($invalidA)}this.$super(b);this.lineAlignment=a}]);pkg.Label=Class(pkg.ViewPan,[function $prototype(){this.getValue=function(){return this.view.getValue()};this.getColor=function(){return this.view.color};this.setModel=function(m){this.setView(new pkg.TextRender(m))};this.getFont=function(){return this.view.font};this.setText=function(s){this.setValue(s)};this.getText=function(){return this.getValue()};this.setValue=function(s){this.view.setValue(s);this.repaint()};this.setColor=function(c){if(this.view.setColor(c)){this.repaint()}return this};this.setFont=function(f){if(f==null){throw new Error("Null font")}if(this.view.font!=f){this.view.setFont(f);this.repaint()}return this}},function(){this.$this("")},function(r){if(zebra.isString(r)){r=new zebra.data.SingleLineTxt(r)}this.setView(instanceOf(r,TextModel)?new pkg.TextRender(r):r);this.$super()}]);pkg.MLabel=Class(pkg.Label,[function(){this.$this("")},function(t){this.$super(new zebra.data.Text(t))}]);pkg.BoldLabel=Class(pkg.Label,[]);pkg.ImageLabel=Class(pkg.Panel,[function(txt,img){this.$super(new L.FlowLayout(L.LEFT,L.CENTER,L.HORIZONTAL,6));this.add(new pkg.ImagePan(img));this.add(new pkg.Label(txt))}]);var OVER=0,PRESSED_OVER=1,OUT=2,PRESSED_OUT=3,DISABLED=4;pkg.StatePan=Class(pkg.ViewPan,Composite,MouseListener,KeyListener,[function $clazz(){this.OVER=OVER;this.PRESSED_OVER=PRESSED_OVER;this.OUT=OUT;this.PRESSED_OUT=PRESSED_OUT;this.DISABLED=DISABLED},function $prototype(){var IDS=["over","pressed.over","out","pressed.out","disabled"];this.state=OUT;this.isCanHaveFocus=false;this.focusComponent=null;this.focusMarkerView=null;this.$isIn=false;this.idByState=function(s){return IDS[s]};this.updateState=function(s){if(s!=this.state){var prev=this.state;this.state=s;this.stateUpdated(prev,s)}};this.stateUpdated=function(o,n){var id=this.idByState(n),b=false;for(var i=0;i=0&&e.y>=0&&e.x0&&e.y>0&&e.x0){timer.start(this,400,this.firePeriod)}}}else{if(this.firePeriod>0&&timer.get(this)!=null){timer.stop(this)}if(n==OVER&&(o==PRESSED_OVER&&this.isFireByPress===false)){this.fire()}}}]);pkg.BorderPan=Class(pkg.Panel,[function $clazz(){this.Label=Class(pkg.Label,[])},function $prototype(){this.vGap=this.hGap=0;this.indent=4;this.getTitleInfo=function(){return(this.label!=null)?{x:this.label.x,y:this.label.y,width:this.label.width,height:this.label.height,orient:this.label.constraints&(L.TOP|L.BOTTOM)}:null};this.calcPreferredSize=function(target){var ps=this.center!=null&&this.center.isVisible?this.center.getPreferredSize():{width:0,height:0};if(this.label!=null&&this.label.isVisible){var lps=this.label.getPreferredSize();ps.height+=lps.height;ps.width=Math.max(ps.width,lps.width+this.indent)}ps.width+=(this.hGap*2);ps.height+=(this.vGap*2);return ps};this.doLayout=function(target){var h=0,right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),xa=this.label?this.label.constraints&(L.LEFT|L.CENTER|L.RIGHT):0,ya=this.label?this.label.constraints&(L.BOTTOM|L.TOP):0;if(this.label!=null&&this.label.isVisible){var ps=this.label.getPreferredSize();h=ps.height;this.label.setSize(ps.width,h);this.label.setLocation((xa==L.LEFT)?left+this.indent:((xa==L.RIGHT)?this.width-right-ps.width-this.indent:~~((this.width-ps.width)/2)),(ya==L.BOTTOM)?(this.height-bottom-ps.height):top)}if(this.center!=null&&this.center.isVisible){this.center.setLocation(left+this.hGap,(ya==L.BOTTOM?top:top+h)+this.vGap);this.center.setSize(this.width-right-left-2*this.hGap,this.height-top-bottom-h-2*this.vGap)}};this.setGaps=function(vg,hg){if(this.vGap!=vg||hg!=this.hGap){this.vGap=vg;this.hGap=hg;this.vrp()}}},function(title){this.$this(title,null)},function(){this.$this(null)},function(title,center){this.$this(title,center,L.TOP|L.LEFT)},function(title,center,ctr){if(zebra.isString(title)){title=new pkg.BorderPan.Label(title)}this.label=this.center=null;this.$super();if(title!=null){this.add(L.$constraints(ctr),title)}if(center!=null){this.add(L.CENTER,center)}},function kidAdded(index,id,lw){this.$super(index,id,lw);if(L.CENTER==id){this.center=lw}else{this.label=lw}},function kidRemoved(index,lw){this.$super(index,lw);if(lw==this.label){this.label=null}else{this.center=null}}]);pkg.SwitchManager=Class([function $prototype(){this.getState=function(o){return this.state};this.setState=function(o,b){if(this.getState(o)!=b){this.state=b;this.updated(o,b)}};this.updated=function(o,b){if(o!=null){o.switched(b)}this._.fired(this,o)};this.install=function(o){o.switched(this.getState(o))};this.uninstall=function(o){};this[""]=function(){this.state=false;this._=new Listeners()}}]);pkg.Group=Class(pkg.SwitchManager,[function(){this.$super();this.state=null},function $prototype(){this.getState=function(o){return o==this.state};this.setState=function(o,b){if(this.getState(o)!=b){this.clearSelected();this.state=o;this.updated(o,true)}};this.clearSelected=function(){if(this.state!=null){var old=this.state;this.state=null;this.updated(old,false)}}}]);pkg.Checkbox=Class(pkg.StatePan,[function $clazz(){var IDS=["on.out","off.out","don","doff","on.over","off.over"];this.Box=Class(pkg.ViewPan,[function parentStateUpdated(o,n,id){this.view.activate(id);this.repaint()}]);this.Label=Class(pkg.Label,[])},function $prototype(){this.setValue=function(b){return this.setState(b)};this.getValue=function(){return this.getState()};this.setState=function(b){this.manager.setState(this,b);return this};this.getState=function(){return this.manager?this.manager.getState(this):false};this.switched=function(b){this.stateUpdated(this.state,this.state)};this.idByState=function(state){if(this.isEnabled){if(this.getState()){return(this.state==OVER)?"on.over":"on.out"}return(this.state==OVER)?"off.over":"off.out"}return this.getState()?"don":"doff"}},function(){this.$this(null)},function(c){this.$this(c,new pkg.SwitchManager())},function(c,m){var clazz=this.$clazz;if(zebra.isString(c)){c=clazz.Label?new clazz.Label(c):new pkg.Checkbox.Label(c)}this.$super();this.box=clazz.Box?new clazz.Box():new pkg.Checkbox.Box();this.add(this.box);if(c!=null){this.add(c);this.setFocusAnchorComponent(c)}this.setSwitchManager(m)},function keyPressed(e){if(instanceOf(this.manager,pkg.Group)&&this.getState()){var code=e.code,d=0;if(code==KE.LEFT||code==KE.UP){d=-1}else{if(code==KE.RIGHT||code==KE.DOWN){d=1}}if(d!==0){var p=this.parent,idx=p.indexOf(this);for(var i=idx+d;i=0;i+=d){var l=p.kids[i];if(l.isVisible&&l.isEnabled&&instanceOf(l,pkg.Checkbox)&&l.manager==this.manager){l.requestFocus();l.setState(true);break}}return}}this.$super(e)},function setSwitchManager(m){if(m==null){throw new Error("Null switch manager")}if(this.manager!=m){if(this.manager!=null){this.manager.uninstall(this)}this.manager=m;this.manager.install(this)}},function stateUpdated(o,n){if(o==PRESSED_OVER&&n==OVER){this.setState(!this.getState())}this.$super(o,n)},function kidRemoved(index,c){if(this.box==c){this.box=null}this.$super(index,c)}]);pkg.Radiobox=Class(pkg.Checkbox,[function $clazz(){this.Box=Class(pkg.Checkbox.Box,[]);this.Label=Class(pkg.Checkbox.Label,[])},function(c){this.$this(c,new pkg.Group())},function(c,group){this.$super(c,group)}]);pkg.SplitPan=Class(pkg.Panel,[function $clazz(){this.Bar=Class(pkg.StatePan,MouseListener,[function $prototype(){this.mouseDragged=function(e){var x=this.x+e.x,y=this.y+e.y;if(this.target.orientation==L.VERTICAL){if(this.prevLoc!=x){x=this.target.normalizeBarLoc(x);if(x>0){this.prevLoc=x;this.target.setGripperLoc(x)}}}else{if(this.prevLoc!=y){y=this.target.normalizeBarLoc(y);if(y>0){this.prevLoc=y;this.target.setGripperLoc(y)}}}};this.mouseDragStarted=function(e){var x=this.x+e.x,y=this.y+e.y;if(e.isActionMask()){if(this.target.orientation==L.VERTICAL){x=this.target.normalizeBarLoc(x);if(x>0){this.prevLoc=x}}else{y=this.target.normalizeBarLoc(y);if(y>0){this.prevLoc=y}}}};this.mouseDragEnded=function(e){var xy=this.target.normalizeBarLoc(this.target.orientation==L.VERTICAL?this.x+e.x:this.y+e.y);if(xy>0){this.target.setGripperLoc(xy)}};this.getCursorType=function(t,x,y){return this.target.orientation==L.VERTICAL?Cursor.W_RESIZE:Cursor.N_RESIZE}},function(target){this.prevLoc=0;this.target=target;this.$super()}])},function $prototype(){this.leftMinSize=this.rightMinSize=50;this.isMoveable=true;this.gap=1;this.normalizeBarLoc=function(xy){if(xythis.maxXY){xy=this.maxXY}}return(xy>this.maxXY||xysSize.width)?fSize.width:sSize.width),bSize.width);bSize.height=fSize.height+sSize.height+bSize.height+2*this.gap}else{bSize.width=fSize.width+sSize.width+bSize.width+2*this.gap;bSize.height=Math.max(((fSize.height>sSize.height)?fSize.height:sSize.height),bSize.height)}return bSize};this.doLayout=function(target){var right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),bSize=pkg.getPreferredSize(this.gripper);if(this.orientation==L.HORIZONTAL){var w=this.width-left-right;if(this.barLocationthis.height-bottom-bSize.height){this.barLocation=this.height-bottom-bSize.height}}if(this.gripper!=null){if(this.isMoveable){this.gripper.setLocation(left,this.barLocation);this.gripper.setSize(w,bSize.height)}else{this.gripper.setSize(bSize.width,bSize.height);this.gripper.toPreferredSize();this.gripper.setLocation(~~((w-bSize.width)/2),this.barLocation)}}if(this.leftComp!=null){this.leftComp.setLocation(left,top);this.leftComp.setSize(w,this.barLocation-this.gap-top)}if(this.rightComp!=null){this.rightComp.setLocation(left,this.barLocation+bSize.height+this.gap);this.rightComp.setSize(w,this.height-this.rightComp.y-bottom)}}else{var h=this.height-top-bottom;if(this.barLocationthis.width-right-bSize.width){this.barLocation=this.width-right-bSize.width}}if(this.gripper!=null){if(this.isMoveable){this.gripper.setLocation(this.barLocation,top);this.gripper.setSize(bSize.width,h)}else{this.gripper.setSize(bSize.width,bSize.height);this.gripper.setLocation(this.barLocation,~~((h-bSize.height)/2))}}if(this.leftComp!=null){this.leftComp.setLocation(left,top);this.leftComp.setSize(this.barLocation-left-this.gap,h)}if(this.rightComp!=null){this.rightComp.setLocation(this.barLocation+bSize.width+this.gap,top);this.rightComp.setSize(this.width-this.rightComp.x-right,h)}}};this.setGap=function(g){if(this.gap!=g){this.gap=g;this.vrp()}};this.setLeftMinSize=function(m){if(this.leftMinSize!=m){this.leftMinSize=m;this.vrp()}};this.setRightMinSize=function(m){if(this.rightMinSize!=m){this.rightMinSize=m;this.vrp()}};this.setGripperMovable=function(b){if(b!=this.isMoveable){this.isMoveable=b;this.vrp()}}},function(){this.$this(null,null,L.VERTICAL)},function(f,s){this.$this(f,s,L.VERTICAL)},function(f,s,o){this.minXY=this.maxXY=0;this.barLocation=70;this.leftComp=this.rightComp=this.gripper=null;this.orientation=L.$constraints(o);this.$super();if(f!=null){this.add(L.LEFT,f)}if(s!=null){this.add(L.RIGHT,s)}this.add(L.CENTER,new pkg.SplitPan.Bar(this))},function kidAdded(index,id,c){this.$super(index,id,c);if(L.LEFT==id){this.leftComp=c}else{if(L.RIGHT==id){this.rightComp=c}else{if(L.CENTER==id){this.gripper=c}else{throw new Error($invalidC)}}}},function kidRemoved(index,c){this.$super(index,c);if(c==this.leftComp){this.leftComp=null}else{if(c==this.rightComp){this.rightComp=null}else{if(c==this.gripper){this.gripper=null}}}},function resized(pw,ph){var ps=this.gripper.getPreferredSize();if(this.orientation==L.VERTICAL){this.minXY=this.getLeft()+this.gap+this.leftMinSize;this.maxXY=this.width-this.gap-this.rightMinSize-ps.width-this.getRight()}else{this.minXY=this.getTop()+this.gap+this.leftMinSize;this.maxXY=this.height-this.gap-this.rightMinSize-ps.height-this.getBottom()}this.$super(pw,ph)}]);pkg.Progress=Class(pkg.Panel,Actionable,[function $prototype(){this.gap=2;this.orientation=L.HORIZONTAL;this.paint=function(g){var left=this.getLeft(),right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),rs=(this.orientation==L.HORIZONTAL)?this.width-left-right:this.height-top-bottom,bundleSize=(this.orientation==L.HORIZONTAL)?this.bundleWidth:this.bundleHeight;if(rs>=bundleSize){var vLoc=~~((rs*this.value)/this.maxValue),x=left,y=this.height-bottom,bundle=this.bundleView,wh=this.orientation==L.HORIZONTAL?this.height-top-bottom:this.width-left-right;while(x<(vLoc+left)&&this.height-vLoc-bottom=0?this.bundleHeight:ps.height)}:{width:(this.bundleWidth>=0?this.bundleWidth:ps.width),height:v1};if(this.titleView!=null){var tp=this.titleView.getPreferredSize();ps.width=Math.max(ps.width,tp.width);ps.height=Math.max(ps.height,tp.height)}return ps}},function(){this.value=0;this.setBundleView("darkBlue");this.bundleWidth=this.bundleHeight=6;this.maxValue=20;this._=new Listeners();this.$super()},function setOrientation(o){o=L.$constraints(o);if(o!=L.HORIZONTAL&&o!=L.VERTICAL){throw new Error($invalidO)}if(o!=this.orientation){this.orientation=o;this.vrp()}},function setMaxValue(m){if(m!=this.maxValue){this.maxValue=m;this.setValue(this.value);this.vrp()}},function setValue(p){p=p%(this.maxValue+1);if(this.value!=p){var old=this.value;this.value=p;this._.fired(this,old);this.repaint()}},function setGap(g){if(this.gap!=g){this.gap=g;this.vrp()}},function setBundleView(v){if(this.bundleView!=v){this.bundleView=pkg.$view(v);this.vrp()}},function setBundleSize(w,h){if(w!=this.bundleWidth&&h!=this.bundleHeight){this.bundleWidth=w;this.bundleHeight=h;this.vrp()}}]);pkg.Link=Class(pkg.Button,[function $prototype(){this.cursorType=Cursor.HAND},function(s){this.$super(null);var font=this.$clazz.font;if(font==null){font=pkg.Link.font}this.setView(new pkg.TextRender(s));this.view.setFont(font);this.stateUpdated(this.state,this.state)},function setColor(state,c){if(this.colors[state]!=c){this.colors[state]=c;this.stateUpdated(state,state)}},function stateUpdated(o,n){this.$super(o,n);var r=this.view;if(r&&r.color!=this.colors[n]){r.setColor(this.colors[n]);this.repaint()}}]);pkg.Extender=Class(pkg.Panel,[function $prototype(){this.toggle=function(){this.isCollapsed=this.isCollapsed?false:true;this.contentPan.setVisible(!this.isCollapsed);this.togglePan.view.activate(this.isCollapsed?"off":"on");this.repaint();if(this._){this._.fired(this,this.isCollapsed)}}},function $clazz(){this.Label=Class(pkg.Label,[]);this.TitlePan=Class(pkg.Panel,[]);this.TogglePan=Class(pkg.ViewPan,MouseListener,[function $prototype(){this.mousePressed=function(e){if(e.isActionMask()){this.parent.parent.toggle()}};this.setViews=function(v){this.setView(new pkg.ViewSet(v))};this.cursorType=Cursor.HAND}])},function(content,lab){this.isCollapsed=true;this.$super();if(zebra.isString(lab)){lab=new pkg.Extender.Label(lab)}this.label=lab;this.titlePan=new pkg.Extender.TitlePan();this.add(L.TOP,this.titlePan);this.togglePan=new pkg.Extender.TogglePan();this.titlePan.add(this.togglePan);this.titlePan.add(this.label);this.contentPan=content;this.contentPan.setVisible(!this.isCollapsed);this.add(L.CENTER,this.contentPan);this.toggle();this._=new Listeners()}]);var ScrollManagerListeners=Listeners.Class("scrolled");pkg.ScrollManager=Class([function $prototype(){this.getSX=function(){return this.sx};this.getSY=function(){return this.sy};this.scrollXTo=function(v){this.scrollTo(v,this.getSY())};this.scrollYTo=function(v){this.scrollTo(this.getSX(),v)};this.scrollTo=function(x,y){var psx=this.getSX(),psy=this.getSY();if(psx!=x||psy!=y){this.sx=x;this.sy=y;if(this.updated){this.updated(x,y,psx,psy)}if(this.target.catchScrolled){this.target.catchScrolled(psx,psy)}this._.scrolled(psx,psy)}};this.makeVisible=function(x,y,w,h){var p=pkg.calcOrigin(x,y,w,h,this.getSX(),this.getSY(),this.target);this.scrollTo(p[0],p[1])}},function(c){this.sx=this.sy=0;this._=new ScrollManagerListeners();this.target=c}]);pkg.Scroll=Class(pkg.Panel,MouseListener,zebra.util.Position.Metric,Composite,[function $clazz(){var SB=Class(pkg.Button,[function $prototype(){this.isDragable=this.isFireByPress=true;this.firePeriod=20}]);this.VIncButton=Class(SB,[]);this.VDecButton=Class(SB,[]);this.HIncButton=Class(SB,[]);this.HDecButton=Class(SB,[]);this.VBundle=Class(pkg.Panel,[]);this.HBundle=Class(pkg.Panel,[]);this.MIN_BUNDLE_SIZE=16},function $prototype(){this.extra=this.max=100;this.pageIncrement=20;this.unitIncrement=5;this.isInBundle=function(x,y){var bn=this.bundle;return(bn!=null&&bn.isVisible&&bn.x<=x&&bn.y<=y&&bn.x+bn.width>x&&bn.y+bn.height>y)};this.amount=function(){var db=this.decBt,ib=this.incBt;return(this.type==L.VERTICAL)?ib.y-db.y-db.height:ib.x-db.x-db.width};this.pixel2value=function(p){var db=this.decBt;return(this.type==L.VERTICAL)?~~((this.max*(p-db.y-db.height))/(this.amount()-this.bundle.height)):~~((this.max*(p-db.x-db.width))/(this.amount()-this.bundle.width))};this.value2pixel=function(){var db=this.decBt,bn=this.bundle,off=this.position.offset;return(this.type==L.VERTICAL)?db.y+db.height+~~(((this.amount()-bn.height)*off)/this.max):db.x+db.width+~~(((this.amount()-bn.width)*off)/this.max)};this.catchInput=function(child){return child==this.bundle||(this.bundle.kids.length>0&&L.isAncestorOf(this.bundle,child))};this.posChanged=function(target,po,pl,pc){if(this.bundle!=null){if(this.type==L.HORIZONTAL){this.bundle.setLocation(this.value2pixel(),this.getTop())}else{this.bundle.setLocation(this.getLeft(),this.value2pixel())}}};this.getLines=function(){return this.max};this.getLineSize=function(line){return 1};this.getMaxOffset=function(){return this.max};this.fired=function(src){this.position.setOffset(this.position.offset+((src==this.incBt)?this.unitIncrement:-this.unitIncrement))};this.mouseDragged=function(e){if(Number.MAX_VALUE!=this.startDragLoc){this.position.setOffset(this.pixel2value(this.bundleLoc-this.startDragLoc+((this.type==L.HORIZONTAL)?e.x:e.y)))}};this.mouseDragStarted=function(e){this.startDragLoc=this.type==L.HORIZONTAL?e.x:e.y;this.bundleLoc=this.type==L.HORIZONTAL?this.bundle.x:this.bundle.y};this.mouseDragEnded=function(e){this.startDragLoc=Number.MAX_VALUE};this.mouseClicked=function(e){if(this.isInBundle(e.x,e.y)===false&&e.isActionMask()){var d=this.pageIncrement;if(this.type==L.VERTICAL){if(e.y<(this.bundle!=null?this.bundle.y:~~(this.height/2))){d=-d}}else{if(e.x<(this.bundle!=null?this.bundle.x:~~(this.width/2))){d=-d}}this.position.setOffset(this.position.offset+d)}};this.calcPreferredSize=function(target){var ps1=pkg.getPreferredSize(this.incBt),ps2=pkg.getPreferredSize(this.decBt),ps3=pkg.getPreferredSize(this.bundle);if(this.type==L.HORIZONTAL){ps1.width+=(ps2.width+ps3.width);ps1.height=Math.max((ps1.height>ps2.height?ps1.height:ps2.height),ps3.height)}else{ps1.height+=(ps2.height+ps3.height);ps1.width=Math.max((ps1.width>ps2.width?ps1.width:ps2.width),ps3.width)}return ps1};this.doLayout=function(target){var right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),ew=this.width-left-right,eh=this.height-top-bottom,b=(this.type==L.HORIZONTAL),ps1=pkg.getPreferredSize(this.decBt),ps2=pkg.getPreferredSize(this.incBt),minbs=pkg.Scroll.MIN_BUNDLE_SIZE;this.decBt.setSize(b?ps1.width:ew,b?eh:ps1.height);this.decBt.setLocation(left,top);this.incBt.setSize(b?ps2.width:ew,b?eh:ps2.height);this.incBt.setLocation(b?this.width-right-ps2.width:left,b?top:this.height-bottom-ps2.height);if(this.bundle!=null&&this.bundle.isVisible){var am=this.amount();if(am>minbs){var bsize=Math.max(Math.min(~~((this.extra*am)/this.max),am-minbs),minbs);this.bundle.setSize(b?bsize:ew,b?eh:bsize);this.bundle.setLocation(b?this.value2pixel():left,b?top:this.value2pixel())}else{this.bundle.setSize(0,0)}}};this.setMaximum=function(m){if(m!=this.max){this.max=m;if(this.position.offset>this.max){this.position.setOffset(this.max)}this.vrp()}};this.setPosition=function(p){if(p!=this.position){if(this.position!=null){this.position._.remove(this)}this.position=p;if(this.position!=null){this.position._.add(this);this.position.setMetric(this);this.position.setOffset(0)}}};this.setExtraSize=function(e){if(e!=this.extra){this.extra=e;this.vrp()}}},function(t){if(t!=L.VERTICAL&&t!=L.HORIZONTAL){throw new Error($invalidA)}this.incBt=this.decBt=this.bundle=this.position=null;this.bundleLoc=this.type=0;this.startDragLoc=Number.MAX_VALUE;this.$super(this);this.add(L.CENTER,t==L.VERTICAL?new pkg.Scroll.VBundle():new pkg.Scroll.HBundle());this.add(L.TOP,t==L.VERTICAL?new pkg.Scroll.VDecButton():new pkg.Scroll.HDecButton());this.add(L.BOTTOM,t==L.VERTICAL?new pkg.Scroll.VIncButton():new pkg.Scroll.HIncButton());this.type=t;this.setPosition(new zebra.util.Position(this))},function kidAdded(index,id,lw){this.$super(index,id,lw);if(L.CENTER==id){this.bundle=lw}else{if(L.BOTTOM==id){this.incBt=lw;this.incBt._.add(this)}else{if(L.TOP==id){this.decBt=lw;this.decBt._.add(this)}else{throw new Error($invalidC)}}}},function kidRemoved(index,lw){this.$super(index,lw);if(lw==this.bundle){this.bundle=null}else{if(lw==this.incBt){this.incBt._.remove(this);this.incBt=null}else{if(lw==this.decBt){this.decBt._.remove(this);this.decBt=null}}}}]);pkg.ScrollPan=Class(pkg.Panel,[function $clazz(){this.ContentPan=Class(pkg.Panel,[function(c){this.$super(new L.RasterLayout(L.USE_PS_SIZE));this.scrollManager=new pkg.ScrollManager(c,[function $prototype(){this.getSX=function(){return this.target.x};this.getSY=function(){return this.target.y};this.updated=function(sx,sy,psx,psy){this.target.setLocation(sx,sy)}}]);this.add(c)}])},function $prototype(){this.autoHide=false;this.$interval=0;this.setAutoHide=function(b){if(this.autoHide!=b){this.autoHide=b;if(this.hBar!=null){if(this.hBar.incBt!=null){this.hBar.incBt.setVisible(!b)}if(this.hBar.decBt!=null){this.hBar.decBt.setVisible(!b)}}if(this.vBar!=null){if(this.vBar.incBt!=null){this.vBar.incBt.setVisible(!b)}if(this.vBar.decBt!=null){this.vBar.decBt.setVisible(!b)}}if(this.$interval!=0){clearInterval(this.$interval);$this.$interval=0}this.vrp()}};this.scrolled=function(psx,psy){try{this.validate();this.isPosChangedLocked=true;if(this.hBar!=null){this.hBar.position.setOffset(-this.scrollObj.scrollManager.getSX())}if(this.vBar!=null){this.vBar.position.setOffset(-this.scrollObj.scrollManager.getSY())}if(this.scrollObj.scrollManager==null){this.invalidate()}}catch(e){throw e}finally{this.isPosChangedLocked=false}};this.calcPreferredSize=function(target){return pkg.getPreferredSize(this.scrollObj)};this.doLayout=function(target){var sman=(this.scrollObj==null)?null:this.scrollObj.scrollManager,right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),ww=this.width-left-right,maxH=ww,hh=this.height-top-bottom,maxV=hh,so=this.scrollObj.getPreferredSize(),vps=this.vBar==null?{width:0,height:0}:this.vBar.getPreferredSize(),hps=this.hBar==null?{width:0,height:0}:this.hBar.getPreferredSize();if(this.hBar!=null&&this.autoHide===false&&(so.width>ww||(so.height>hh&&so.width>(ww-vps.width)))){maxV-=hps.height}maxV=so.height>maxV?(so.height-maxV):-1;if(this.vBar!=null&&this.autoHide===false&&(so.height>hh||(so.width>ww&&so.height>(hh-hps.height)))){maxH-=vps.width}maxH=so.width>maxH?(so.width-maxH):-1;var sy=sman.getSY(),sx=sman.getSX();if(this.vBar!=null){if(maxV<0){if(this.vBar.isVisible){this.vBar.setVisible(false);sman.scrollTo(sx,0);this.vBar.position.setOffset(0)}sy=0}else{this.vBar.setVisible(true)}}if(this.hBar!=null){if(maxH<0){if(this.hBar.isVisible){this.hBar.setVisible(false);sman.scrollTo(0,sy);this.hBar.position.setOffset(0)}}else{this.hBar.setVisible(true)}}if(this.scrollObj.isVisible){this.scrollObj.setLocation(left,top);this.scrollObj.setSize(ww-(this.autoHide===false&&this.vBar!=null&&this.vBar.isVisible?vps.width:0),hh-(this.autoHide===false&&this.hBar!=null&&this.hBar.isVisible?hps.height:0))}if(this.$interval===0&&this.autoHide){hps.height=vps.width=1}if(this.hBar!=null&&this.hBar.isVisible){this.hBar.setLocation(left,this.height-bottom-hps.height);this.hBar.setSize(ww-(this.vBar!=null&&this.vBar.isVisible?vps.width:0),hps.height);this.hBar.setMaximum(maxH)}if(this.vBar!=null&&this.vBar.isVisible){this.vBar.setLocation(this.width-right-vps.width,top);this.vBar.setSize(vps.width,hh-(this.hBar!=null&&this.hBar.isVisible?hps.height:0));this.vBar.setMaximum(maxV)}};this.posChanged=function(target,prevOffset,prevLine,prevCol){if(this.isPosChangedLocked===false){if(this.autoHide){this.$dontHide=true;if(this.$interval===0&&((this.vBar!=null&&this.vBar.isVisible)||(this.hBar!=null&&this.hBar.isVisible))){var $this=this;if(this.vBar){this.vBar.toFront()}if(this.hBar){this.hBar.toFront()}this.vrp();this.$interval=setInterval(function(){if($this.$dontHide||($this.vBar!=null&&pkg.$mouseMoveOwner==$this.vBar)||($this.hBar!=null&&pkg.$mouseMoveOwner==$this.hBar)){$this.$dontHide=false}else{clearInterval($this.$interval);$this.$interval=0;$this.doLayout()}},500)}}if(this.vBar!=null&&this.vBar.position==target){this.scrollObj.scrollManager.scrollYTo(-this.vBar.position.offset)}else{if(this.hBar!=null){this.scrollObj.scrollManager.scrollXTo(-this.hBar.position.offset)}}}}},function(){this.$this(null,L.HORIZONTAL|L.VERTICAL)},function(c){this.$this(c,L.HORIZONTAL|L.VERTICAL)},function(c,barMask){this.hBar=this.vBar=this.scrollObj=null;this.isPosChangedLocked=false;this.$super();if((L.HORIZONTAL&barMask)>0){this.add(L.BOTTOM,new pkg.Scroll(L.HORIZONTAL))}if((L.VERTICAL&barMask)>0){this.add(L.RIGHT,new pkg.Scroll(L.VERTICAL))}if(c!=null){this.add(L.CENTER,c)}},function setIncrements(hUnit,hPage,vUnit,vPage){if(this.hBar!=null){if(hUnit!=-1){this.hBar.unitIncrement=hUnit}if(hPage!=-1){this.hBar.pageIncrement=hPage}}if(this.vBar!=null){if(vUnit!=-1){this.vBar.unitIncrement=vUnit}if(vPage!=-1){this.vBar.pageIncrement=vPage}}},function insert(i,ctr,c){if(L.CENTER==ctr&&c.scrollManager==null){c=new pkg.ScrollPan.ContentPan(c)}return this.$super(i,ctr,c)},function kidAdded(index,id,comp){this.$super(index,id,comp);if(L.CENTER==id){this.scrollObj=comp;this.scrollObj.scrollManager._.add(this)}if(L.BOTTOM==id||L.TOP==id){this.hBar=comp;this.hBar.position._.add(this)}else{if(L.LEFT==id||L.RIGHT==id){this.vBar=comp;this.vBar.position._.add(this)}}},function kidRemoved(index,comp){this.$super(index,comp);if(comp==this.scrollObj){this.scrollObj.scrollManager._.remove(this);this.scrollObj=null}else{if(comp==this.hBar){this.hBar.position._.remove(this);this.hBar=null}else{if(comp==this.vBar){this.vBar.position._.remove(this);this.vBar=null}}}}]);pkg.Tabs=Class(pkg.Panel,MouseListener,KeyListener,[function $prototype(){this.mouseMoved=function(e){var i=this.getTabAt(e.x,e.y);if(this.overTab!=i){this.overTab=i;if(this.views.tabover!=null){this.repaint(this.tabAreaX,this.tabAreaY,this.tabAreaWidth,this.tabAreaHeight)}}};this.mouseDragEnded=function(e){var i=this.getTabAt(e.x,e.y);if(this.overTab!=i){this.overTab=i;if(this.views.tabover!=null){this.repaint(this.tabAreaX,this.tabAreaY,this.tabAreaWidth,this.tabAreaHeight)}}};this.mouseExited=function(e){if(this.overTab>=0){this.overTab=-1;if(this.views.tabover!=null){this.repaint(this.tabAreaX,this.tabAreaY,this.tabAreaWidth,this.tabAreaHeight)}}};this.next=function(page,d){for(;page>=0&&page<~~(this.pages.length/2);page+=d){if(this.isTabEnabled(page)){return page}}return -1};this.getTitleInfo=function(){var b=(this.orient==L.LEFT||this.orient==L.RIGHT),res=b?{x:this.tabAreaX,y:0,width:this.tabAreaWidth,height:0,orient:this.orient}:{x:0,y:this.tabAreaY,width:0,height:this.tabAreaHeight,orient:this.orient};if(this.selectedIndex>=0){var r=this.getTabBounds(this.selectedIndex);if(b){res[1]=r.y;res[3]=r.height}else{res[0]=r.x;res[2]=r.width}}return res};this.canHaveFocus=function(){return true};this.getTabView=function(index){var data=this.pages[2*index];if(data.paint){return data}this.render.target.setValue(data.toString());return this.render};this.isTabEnabled=function(index){return this.kids[index].isEnabled};this.paint=function(g){if(this.selectedIndex>0){var r=this.getTabBounds(this.selectedIndex)}for(var i=0;i=0){var r=this.getTabBounds(this.selectedIndex)}for(var i=this.selectedIndex+1;i<~~(this.pages.length/2);i++){this.paintTab(g,i)}if(this.selectedIndex>=0){this.paintTab(g,this.selectedIndex);if(this.hasFocus()){this.drawMarker(g,this.getTabBounds(this.selectedIndex))}}};this.drawMarker=function(g,r){var marker=this.views.marker;if(marker!=null){var bv=this.views.tab;marker.paint(g,r.x+bv.getLeft(),r.y+bv.getTop(),r.width-bv.getLeft()-bv.getRight(),r.height-bv.getTop()-bv.getBottom(),this)}};this.paintTab=function(g,pageIndex){var b=this.getTabBounds(pageIndex),page=this.kids[pageIndex],vs=this.views,tab=vs.tab,tabover=vs.tabover,tabon=vs.tabon;if(this.selectedIndex==pageIndex&&tabon!=null){tabon.paint(g,b.x,b.y,b.width,b.height,page)}else{tab.paint(g,b.x,b.y,b.width,b.height,page)}if(this.overTab>=0&&this.overTab==pageIndex&&tabover!=null){tabover.paint(g,b.x,b.y,b.width,b.height,page)}var v=this.getTabView(pageIndex),ps=v.getPreferredSize(),px=b.x+L.xAlignment(ps.width,L.CENTER,b.width),py=b.y+L.yAlignment(ps.height,L.CENTER,b.height);v.paint(g,px,py,ps.width,ps.height,page);if(this.selectedIndex==pageIndex){v.paint(g,px+1,py,ps.width,ps.height,page)}};this.getTabBounds=function(i){return this.pages[2*i+1]};this.calcPreferredSize=function(target){var max=L.getMaxPreferredSize(target);if(this.orient==L.BOTTOM||this.orient==L.TOP){max.width=Math.max(2*this.sideSpace+max.width,this.tabAreaWidth);max.height+=this.tabAreaHeight}else{max.width+=this.tabAreaWidth;max.height=Math.max(2*this.sideSpace+max.height,this.tabAreaHeight)}max.width+=(this.hgap*2);max.height+=(this.vgap*2);return max};this.doLayout=function(target){var right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),b=(this.orient==L.TOP||this.orient==L.BOTTOM);if(b){this.tabAreaX=left;this.tabAreaY=(this.orient==L.TOP)?top:this.height-bottom-this.tabAreaHeight}else{this.tabAreaX=(this.orient==L.LEFT)?left:this.width-right-this.tabAreaWidth;this.tabAreaY=top}var count=~~(this.pages.length/2),sp=2*this.sideSpace,xx=b?(this.tabAreaX+this.sideSpace):((this.orient==L.LEFT)?(this.tabAreaX+this.upperSpace):this.tabAreaX+1),yy=b?(this.orient==L.TOP?this.tabAreaY+this.upperSpace:this.tabAreaY+1):(this.tabAreaY+this.sideSpace);for(var i=0;i=0){var r=this.getTabBounds(this.selectedIndex),dt=0;if(b){r.x-=this.sideSpace;r.y-=(this.orient==L.TOP)?this.upperSpace:this.brSpace;dt=(r.xthis.width-right)?this.width-right-r.x-r.width:0}else{r.x-=(this.orient==L.LEFT)?this.upperSpace:this.brSpace;r.y-=this.sideSpace;dt=(r.ythis.height-bottom)?this.height-bottom-r.y-r.height:0}for(var i=0;i0){this.tabAreaHeight=this.tabAreaWidth=0;var bv=this.views.tab,b=(this.orient==L.LEFT||this.orient==L.RIGHT),max=0,hadd=2*this.hTabGap+bv.getLeft()+bv.getRight(),vadd=2*this.vTabGap+bv.getTop()+bv.getBottom();for(var i=0;imax){max=ps.width+hadd}this.tabAreaHeight+=r.height}else{r.width=ps.width+hadd;if(ps.height+vadd>max){max=ps.height+vadd}this.tabAreaWidth+=r.width}}for(var i=0;i=0){var r=this.getTabBounds(this.selectedIndex);if(b){r.height+=2*this.sideSpace;r.width+=(this.brSpace+this.upperSpace)}else{r.height+=(this.brSpace+this.upperSpace);r.width+=2*this.sideSpace}}}};this.getTabAt=function(x,y){this.validate();if(x>=this.tabAreaX&&y>=this.tabAreaY&&x=tb.x&&y>=tb.y&&x0){switch(e.code){case KE.UP:case KE.LEFT:var nxt=this.next(this.selectedIndex-1,-1);if(nxt>=0){this.select(nxt)}break;case KE.DOWN:case KE.RIGHT:var nxt=this.next(this.selectedIndex+1,1);if(nxt>=0){this.select(nxt)}break}}};this.mouseClicked=function(e){if(e.isActionMask()){var index=this.getTabAt(e.x,e.y);if(index>=0&&this.isTabEnabled(index)){this.select(index)}}};this.select=function(index){if(this.selectedIndex!=index){this.selectedIndex=index;this._.fired(this,this.selectedIndex);this.vrp()}};this.setTitle=function(pageIndex,data){if(this.pages[2*pageIndex]!=data){this.pages[pageIndex*2]=data;this.vrp()}};this.setTabSpaces=function(vg,hg,sideSpace,upperSpace,brSpace){if(this.vTabGap!=vg||this.hTabGap!=hg||sideSpace!=this.sideSpace||upperSpace!=this.upperSpace||brSpace!=this.brSpace){this.vTabGap=vg;this.hTabGap=hg;this.sideSpace=sideSpace;this.upperSpace=upperSpace;this.brSpace=brSpace;this.vrp()}};this.setGaps=function(vg,hg){if(this.vgap!=vg||hg!=this.hgap){this.vgap=vg;this.hgap=hg;this.vrp()}};this.setTitleAlignment=function(o){o=L.$constraints(o);if(o!=L.TOP&&o!=L.BOTTOM&&o!=L.LEFT&&o!=L.RIGHT){throw new Error($invalidA)}if(this.orient!=o){this.orient=o;this.vrp()}};this.enableTab=function(i,b){var c=this.kids[i];if(c.isEnabled!=b){c.setEnabled(b);if(b===false&&this.selectedIndex==i){this.select(-1)}this.repaint()}}},function(){this.$this(L.TOP)},function(o){this.brSpace=this.upperSpace=this.vgap=this.hgap=this.tabAreaX=0;this.hTabGap=this.vTabGap=this.sideSpace=1;this.tabAreaY=this.tabAreaWidth=this.tabAreaHeight=0;this.overTab=this.selectedIndex=-1;this.orient=L.$constraints(o);this._=new Listeners();this.pages=[];this.views={};this.render=new pkg.TextRender(new zebra.data.SingleLineTxt(""));if(pkg.Tabs.font!=null){this.render.setFont(pkg.Tabs.font)}if(pkg.Tabs.fontColor!=null){this.render.setColor(pkg.Tabs.fontColor)}this.$super();this.setTitleAlignment(o)},function focused(){this.$super();if(this.selectedIndex>=0){var r=this.getTabBounds(this.selectedIndex);this.repaint(r.x,r.y,r.width,r.height)}else{if(!this.hasFocus()){this.select(this.next(0,1))}}},function insert(index,constr,c){this.pages.splice(index*2,0,constr==null?"Page "+index:constr,{x:0,y:0,width:0,height:0});var r=this.$super(index,constr,c);if(this.selectedIndex<0){this.select(this.next(0,1))}return r},function removeAt(i){if(this.selectedIndex==i){this.select(-1)}this.pages.splice(i*2,2);this.$super(i)},function removeAll(){if(this.selectedIndex>=0){this.select(-1)}this.pages.splice(0,this.pages.length);this.pages.length=0;this.$super()},function setSize(w,h){if(this.width!=w||this.height!=h){if(this.orient==L.RIGHT||this.orient==L.BOTTOM){this.tabAreaX=-1}this.$super(w,h)}}]);pkg.Tabs.prototype.setViews=pkg.$ViewsSetter;pkg.Slider=Class(pkg.Panel,KeyListener,MouseListener,Actionable,[function $prototype(){this.max=this.min=this.value=this.roughStep=this.exactStep=0;this.netSize=this.gap=3;this.correctDt=this.scaleStep=this.psW=this.psH=0;this.intervals=this.pl=null;this.paintNums=function(g,loc){if(this.isShowTitle){for(var i=0;ithis.max){v=this.max}else{if(vsl+ss){xy=sl+ss}}return this.min+~~(((this.max-this.min)*(xy-sl))/ss)};this.nextValue=function(value,s,d){if(this.isIntervalMode){return this.getNeighborPoint(value,d)}var v=value+(d*s);if(v>this.max){v=this.max}else{if(vright){return right}}if(d>0){var start=this.min;for(var i=0;iv){return start}}return right}else{var start=right;for(var i=this.intervals.length-1;i>=0;i--){if(start0){for(var i=0;ihMax){hMax=d.height}if(d.width>wMax){wMax=d.width}}}if(this.orient==L.HORIZONTAL){this.psW=dt*2+ps.width;this.psH=ps.height+ns+hMax}else{this.psW=ps.width+ns+wMax;this.psH=dt*2+ps.height}};this.setValue=function(v){if(vthis.max){throw new Error("Value is out of bounds: "+v)}var prev=this.value;if(this.value!=v){this.value=v;this._.fired(this,prev);this.repaint()}};this.getPointValue=function(i){var v=this.min+this.intervals[0];for(var j=0;j=this.min){this.setValue(v)}break;case KE.DOWN:case KE.RIGHT:var v=this.nextValue(this.value,this.exactStep,1);if(v<=this.max){this.setValue(v)}break;case KE.HOME:this.setValue(b?this.getPointValue(0):this.min);break;case KE.END:this.setValue(b?this.getPointValue(this.intervals.length-1):this.max);break}};this.mousePressed=function(e){if(e.isActionMask()){var x=e.x,y=e.y,bb=this.getBundleBounds(this.value);if(x=bb.x+bb.width||y>=bb.y+bb.height){var l=((this.orient==L.HORIZONTAL)?x:y),v=this.loc2value(l);if(this.value!=v){this.setValue(this.isJumpOnPress?v:this.nextValue(this.value,this.roughStep,v=r.x&&e.y>=r.y&&e.x=max||min+roughStep>max||min+exactStep>max){throw new Error("Invalid values")}for(var i=0,start=min;imax||intervals[i]<0){throw new Error()}}this.min=min;this.max=max;this.roughStep=roughStep;this.exactStep=exactStep;this.intervals=Array(intervals.length);for(var i=0;imax){this.setValue(this.isIntervalMode?min+intervals[0]:min)}this.vrp()},function invalidate(){this.pl=null;this.$super()}]);pkg.Slider.prototype.setViews=pkg.$ViewsSetter;pkg.StatusBar=Class(pkg.Panel,[function(){this.$this(2)},function(gap){this.setPaddings(gap,0,0,0);this.$super(new L.PercentLayout(Layout.HORIZONTAL,gap))},function setBorderView(v){if(v!=this.borderView){this.borderView=v;for(var i=0;i0?isDec:false;this.stretched=arguments.length>1?str:false}},function $prototype(){var OVER="over",OUT="out",PRESSED="pressed";this.isDecorative=function(c){return c.constraints.isDecorative};this.childInputEvent=function(e){if(e.UID==pkg.InputEvent.MOUSE_UID){var dc=L.getDirectChild(this,e.source);if(this.isDecorative(dc)===false){switch(e.ID){case ME.ENTERED:this.select(dc,true);break;case ME.EXITED:if(this.selected!=null&&L.isAncestorOf(this.selected,e.source)){this.select(null,true)}break;case ME.PRESSED:this.select(this.selected,false);break;case ME.RELEASED:this.select(this.selected,true);break}}}};this.recalc=function(){var v=this.views,vover=v[OVER],vpressed=v[PRESSED];this.leftShift=Math.max(vover!=null&&vover.getLeft?vover.getLeft():0,vpressed!=null&&vpressed.getLeft?vpressed.getLeft():0);this.rightShift=Math.max(vover!=null&&vover.getRight?vover.getRight():0,vpressed!=null&&vpressed.getRight?vpressed.getRight():0);this.topShift=Math.max(vover!=null&&vover.getTop?vover.getTop():0,vpressed!=null&&vpressed.getTop?vpressed.getTop():0);this.bottomShift=Math.max(vover!=null&&vover.getBottom?vover.getBottom():0,vpressed!=null&&vpressed.getBottom?vpressed.getBottom():0)};this.paint=function(g){for(var i=0;i0?this.gap:0));h=ps.height>h?ps.height:h}else{w=ps.width>w?ps.width:w;h+=(ps.height+(c>0?this.gap:0))}c++}}return{width:(b?w+c*(this.leftShift+this.rightShift):w+this.topShift+this.bottomShift),height:(b?h+this.leftShift+this.rightShift:h+c*(this.topShift+this.bottomShift))}};this.doLayout=function(t){var b=(this.orient==L.HORIZONTAL),x=t.getLeft(),y=t.getTop(),av=this.topShift+this.bottomShift,ah=this.leftShift+this.rightShift,hw=b?t.height-y-t.getBottom():t.width-x-t.getRight();for(var i=0;i=-1&&$this.$dt<=1)){clearInterval($this.timer);$this.timer=$this.target=null}},40)}};this.mousePressed=function(e){if(this.timer!=null){clearInterval(this.timer);this.timer=null}this.target=null}}]);pkg.configure(function(conf){var p=zebra()["ui.json"];conf.loadByUrl(p?p:pkg.$url.join("ui.json"),false)})})(zebra("ui"),zebra.Class,zebra.Interface);(function(pkg,Class){var ME=pkg.MouseEvent,KE=pkg.KeyEvent,PO=zebra.util.Position;pkg.TextField=Class(pkg.Label,pkg.KeyListener,pkg.MouseListener,pkg.FocusListener,pkg.CopyCutPaste,[function $clazz(){this.TextPosition=Class(PO,[function(render){this.$super(render);render.target._.add(this)},function $prototype(){this.textUpdated=function(src,b,off,size,startLine,lines){if(b===true){this.inserted(off,size)}else{this.removed(off,size)}}},function destroy(){this.metrics.target._.remove(this)}])},function $prototype(){this.selectionColor=this.curView=this.position=null;this.blinkingPeriod=-1;this.blinkMe=true;this.blinkMeCounter=0;this.cursorType=pkg.Cursor.TEXT;this.isEditable=true;this.setBlinking=function(period){if(period!=this.blinkingPeriod){this.blinkingPeriod=period;this.repaintCursor()}};this.getTextRowColAt=function(x,y){var size=this.view.target.getLines();if(size===0){return null}var lh=this.view.getLineHeight(),li=this.view.getLineIndent(),ln=(y<0)?0:~~((y+li)/(lh+li))+((y+li)%(lh+li)>li?1:0)-1;if(ln>=size){return[size-1,this.view.getLine(size-1).length]}else{if(ln<0){return[0,0]}}if(x<0){return[ln,0]}var x1=0,x2=0,s=this.view.getLine(ln);for(var c=0;c=x1&&x=t.getLines()){return null}var ln=t.getLine(line);col+=d;if(col<0&&line>0){return[line-1,t.getLine(line-1).length]}else{if(col>ln.length&&line=0&&col0){if(zebra.util.isLetter(ln[col])){return[line,col]}}else{if(!zebra.util.isLetter(ln[col])){return[line,col+1]}}}else{b=d>0?!zebra.util.isLetter(ln[col]):zebra.util.isLetter(ln[col])}}return(d>0?[line,ln.length]:[line,0])};this.getSubString=function(r,start,end){var res=[],sr=start[0],er=end[0],sc=start[1],ec=end[1];for(var i=sr;ithis.endOff?this.startOff:this.endOff)-start);this.clearSelection()}};this.startSelection=function(){if(this.startOff<0){var pos=this.position;this.endLine=this.startLine=pos.currentLine;this.endCol=this.startCol=pos.currentCol;this.endOff=this.startOff=pos.offset}};this.keyTyped=function(e){if(e.isControlPressed()||e.isCmdPressed()||this.isEditable===false||(e.ch=="\n"&&zebra.instanceOf(this.view.target,zebra.data.SingleLineTxt))){return}this.removeSelected();this.write(this.position.offset,e.ch)};this.selectAll_command=function(){this.select(0,this.position.metrics.getMaxOffset())};this.nextWord_command=function(b,d){if(b){this.startSelection()}var p=this.findNextWord(this.view.target,this.position.currentLine,this.position.currentCol,d);if(p!=null){this.position.setRowCol(p[0],p[1])}};this.nextPage_command=function(b,d){if(b){this.startSelection()}this.position.seekLineTo(d==1?PO.DOWN:PO.UP,this.pageSize())};this.keyPressed=function(e){if(this.isFiltered(e)){return}var position=this.position,col=position.currentCol,isShiftDown=e.isShiftPressed(),line=position.currentLine,foff=1;if(isShiftDown&&e.ch==KE.CHAR_UNDEFINED){this.startSelection()}switch(e.code){case KE.DOWN:position.seekLineTo(PO.DOWN);break;case KE.UP:position.seekLineTo(PO.UP);break;case KE.LEFT:foff=-1;case KE.RIGHT:if(e.isControlPressed()===false&&e.isCmdPressed()===false){position.seek(foff)}break;case KE.END:if(e.isControlPressed()){position.seekLineTo(PO.DOWN,position.metrics.getLines()-line-1)}else{position.seekLineTo(PO.END)}break;case KE.HOME:if(e.isControlPressed()){position.seekLineTo(PO.UP,line)}else{position.seekLineTo(PO.BEG)}break;case KE.DELETE:if(this.hasSelection()&&this.isEditable){this.removeSelected()}else{if(this.isEditable){this.remove(position.offset,1)}}break;case KE.BSPACE:if(this.isEditable){if(this.hasSelection()){this.removeSelected()}else{if(this.isEditable&&position.offset>0){position.seek(-1);this.remove(position.offset,1)}}}break;default:return}if(isShiftDown===false){this.clearSelection()}};this.isFiltered=function(e){var code=e.code;return code==KE.SHIFT||code==KE.CTRL||code==KE.TAB||code==KE.ALT||(e.mask&KE.M_ALT)>0};this.remove=function(pos,size){if(this.isEditable){var position=this.position;if(pos>=0&&(pos+size)<=position.metrics.getMaxOffset()){if(size<10000){this.historyPos=(this.historyPos+1)%this.history.length;this.history[this.historyPos]=[-1,pos,this.getValue().substring(pos,pos+size)];if(this.undoCounter=0){var cl=p.currentLine;this.curX=r.font.charsWidth(r.getLine(cl),0,p.currentCol)+this.getLeft();this.curY=cl*(r.getLineHeight()+r.getLineIndent())+this.getTop()}this.curH=r.getLineHeight()-1};this.catchScrolled=function(psx,psy){this.repaint()};this.canHaveFocus=function(){return true};this.drawCursor=function(g){if(this.position.offset>=0&&this.curView!=null&&this.blinkMe&&this.hasFocus()){this.curView.paint(g,this.curX,this.curY,this.curW,this.curH,this)}};this.mouseDragStarted=function(e){if(e.mask==ME.LEFT_BUTTON&&this.position.metrics.getMaxOffset()>0){this.startSelection()}};this.mouseDragEnded=function(e){if(e.mask==ME.LEFT_BUTTON&&this.hasSelection()===false){this.clearSelection()}};this.mouseDragged=function(e){if(e.mask==ME.LEFT_BUTTON){var p=this.getTextRowColAt(e.x-this.scrollManager.getSX(),e.y-this.scrollManager.getSY());if(p!=null){this.position.setRowCol(p[0],p[1])}}};this.select=function(startOffset,endOffset){if(endOffsetthis.position.metrics.getMaxOffset()){throw new Error("Invalid selection offsets")}if(this.startOff!=startOffset||endOffset!=this.endOff){if(startOffset==endOffset){this.clearSelection()}else{this.startOff=startOffset;var p=this.position.getPointByOffset(startOffset);this.startLine=p[0];this.startCol=p[1];this.endOff=endOffset;p=this.position.getPointByOffset(endOffset);this.endLine=p[0];this.endCol=p[1];this.repaint()}}};this.hasSelection=function(){return this.startOff!=this.endOff};this.posChanged=function(target,po,pl,pc){this.recalc();var position=this.position;if(position.offset>=0){this.blinkMeCounter=0;this.blinkMe=true;var lineHeight=this.view.getLineHeight(),top=this.getTop();this.scrollManager.makeVisible(this.curX,this.curY,this.curW,lineHeight);if(pl>=0){if(this.startOff>=0){this.endLine=position.currentLine;this.endCol=position.currentCol;this.endOff=position.offset}var minUpdatedLine=plposition.currentLine)?pl:position.currentLine)-minUpdatedLine+1)*(lineHeight+li);if(y1+h>this.height-bottom){h=this.height-bottom-y1}this.repaint(left,y1,this.width-left-this.getRight(),h)}}else{this.repaint()}}};this.paintOnTop=function(g){if(this.hint&&this.hasFocus()===false&&this.getValue()==""){this.hint.paint(g,this.getLeft(),this.height-this.getBottom()-this.hint.getLineHeight(),this.width,this.height,this)}};this.setHint=function(hint,font,color){this.hint=hint;if(hint!=null&&zebra.instanceOf(hint,pkg.View)===false){this.hint=new pkg.TextRender(hint);font=font?font:pkg.TextField.hintFont;color=color?color:pkg.TextField.hintColor;this.hint.setColor(color);this.hint.setFont(font)}this.repaint();return this.hint};this.undo_command=function(){if(this.undoCounter>0){var h=this.history[this.historyPos];this.historyPos--;if(h[0]==1){this.remove(h[1],h[2])}else{this.write(h[1],h[2])}this.undoCounter-=2;this.redoCounter++;this.historyPos--;if(this.historyPos<0){this.historyPos=this.history.length-1}this.repaint()}};this.redo_command=function(){if(this.redoCounter>0){var h=this.history[(this.historyPos+1)%this.history.length];if(h[0]==1){this.remove(h[1],h[2])}else{this.write(h[1],h[2])}this.redoCounter--;this.repaint()}};this.getStartSelection=function(){return this.startOff!=this.endOff?((this.startOff0){this.blinkMeCounter=0;this.blinkMe=true;zebra.util.timer.start(this,Math.floor(this.blinkingPeriod/3),Math.floor(this.blinkingPeriod/3))}};this.focusLost=function(e){if(this.isEditable){if(this.hint){this.repaint()}else{this.repaintCursor()}if(this.blinkingPeriod>0){zebra.util.timer.stop(this);this.blinkMe=true}}};this.repaintCursor=function(){if(this.curX>0&&this.curW>0&&this.curH>0){this.repaint(this.curX+this.scrollManager.getSX(),this.curY+this.scrollManager.getSY(),this.curW,this.curH)}};this.run=function(){this.blinkMeCounter=(this.blinkMeCounter+1)%3;if(this.blinkMeCounter===0){this.blinkMe=!this.blinkMe;this.repaintCursor()}};this.clearSelection=function(){if(this.startOff>=0){var b=this.hasSelection();this.endOff=this.startOff=-1;if(b){this.repaint()}}};this.pageSize=function(){var height=this.height-this.getTop()-this.getBottom(),indent=this.view.getLineIndent(),textHeight=this.view.getLineHeight();return(((height+indent)/(textHeight+indent)+0.5)|0)+(((height+indent)%(textHeight+indent)>indent)?1:0)};this.createPosition=function(r){return new pkg.TextField.TextPosition(r)};this.paste=function(txt){if(txt!=null){this.removeSelected();this.write(this.position.offset,txt)}};this.copy=function(){return this.getSelectedText()};this.cut=function(){var t=this.getSelectedText();if(this.isEditable){this.removeSelected()}return t};this.setPosition=function(p){if(this.position!=p){if(this.position!=null){this.position._.remove(this);if(this.position.destroy){this.position.destroy()}}this.position=p;this.position._.add(this);this.invalidate()}};this.setCursorView=function(v){this.curW=1;this.curView=pkg.$view(v);this.vrp()};this.setPSByRowsCols=function(r,c){var tr=this.view,w=(c>0)?(tr.font.stringWidth("W")*c):this.psWidth,h=(r>0)?(r*tr.getLineHeight()+(r-1)*tr.getLineIndent()):this.psHeight;this.setPreferredSize(w,h)};this.setEditable=function(b){if(b!=this.isEditable){this.isEditable=b;if(b&&this.blinkingPeriod>0&&this.hasFocus()){zebra.util.timer.stop(this);this.blinkMe=true}this.vrp()}};this.mousePressed=function(e){if(e.isActionMask()){if(e.clicks>1){this.select(0,this.position.metrics.getMaxOffset())}else{if((e.mask&KE.M_SHIFT)>0){this.startSelection()}else{this.clearSelection()}var p=this.getTextRowColAt(e.x-this.scrollManager.getSX()-this.getLeft(),e.y-this.scrollManager.getSY()-this.getTop());if(p!=null){this.position.setRowCol(p[0],p[1])}}}};this.setSelectionColor=function(c){if(c!=this.selectionColor){this.selectionColor=c;if(this.hasSelection()){this.repaint()}}};this.calcPreferredSize=function(t){return this.view.getPreferredSize()};this.paint=function(g){var sx=this.scrollManager.getSX(),sy=this.scrollManager.getSY();try{g.translate(sx,sy);var l=this.getLeft(),t=this.getTop();this.view.paint(g,l,t,this.width-l-this.getRight(),this.height-t-this.getBottom(),this);this.drawCursor(g)}catch(e){throw e}finally{g.translate(-sx,-sy)}}},function(){this.$this("")},function(s,maxCol){var b=zebra.isNumber(maxCol);this.$this(b?new zebra.data.SingleLineTxt(s,maxCol):(maxCol?new zebra.data.Text(s):s));if(b&&maxCol>0){this.setPSByRowsCols(-1,maxCol)}},function(render){if(zebra.isString(render)){render=new pkg.TextRender(new zebra.data.SingleLineTxt(render))}else{if(zebra.instanceOf(render,zebra.data.TextModel)){render=new pkg.TextRender(render)}}this.startLine=this.startCol=this.endLine=this.endCol=this.curX=0;this.startOff=this.endOff=-1;this.history=Array(100);this.historyPos=-1;this.redoCounter=this.undoCounter=this.curY=this.curW=this.curH=0;this.$super(render);this.scrollManager=new pkg.ScrollManager(this)},function setView(v){if(v!=this.view){this.$super(v);this.setPosition(this.createPosition(this.view))}},function setValue(s){var txt=this.getValue();if(txt!=s){this.position.setOffset(0);this.scrollManager.scrollTo(0,0);this.$super(s)}},function setEnabled(b){this.clearSelection();this.$super(b)}]);pkg.TextArea=Class(pkg.TextField,[function(){this.$this("")},function(txt){this.$super(new zebra.data.Text(txt))}]);pkg.PassTextField=Class(pkg.TextField,[function(txt){this.$this(txt,-1)},function(txt,size){this.$this(txt,size,false)},function(txt,size,showLast){var pt=new pkg.PasswordText(new zebra.data.SingleLineTxt(txt,size));pt.showLast=showLast;this.$super(pt)}])})(zebra("ui"),zebra.Class);(function(pkg,Class){var L=zebra.layout,Position=zebra.util.Position,KE=pkg.KeyEvent,Listeners=zebra.util.Listeners;pkg.BaseList=Class(pkg.Panel,pkg.MouseListener,pkg.KeyListener,Position.Metric,[function $prototype(){this.gap=2;this.setValue=function(v){if(v==null){this.select(-1);return}for(var i=0;i0){var index=this.selectedIndex<0?0:this.selectedIndex+1;ch=ch.toLowerCase();for(var i=0;i0&&item[0].toLowerCase()==ch){return idx}}}return -1};this.isSelected=function(i){return i==this.selectedIndex};this.correctPM=function(x,y){if(this.isComboMode){var index=this.getItemIdxAt(x,y);if(index>=0&&index!=this.position.offset){this.position.setOffset(index);this.notifyScrollMan(index)}}};this.getItemLocation=function(i){this.validate();var gap=this.getItemGap(),y=this.getTop()+this.scrollManager.getSY()+gap;for(var i=0;imaxH){maxH=is.height}if(is.width>maxW){maxW=is.width}}}return{width:maxW,height:maxH}};this.repaintByOffsets=function(p,n){this.validate();var xx=this.width-this.getRight(),gap=this.getItemGap(),count=this.model==null?0:this.model.count();if(p>=0&&p=0&&n=0&&this.views.select!=null){var gap=this.getItemGap(),is=this.getItemSize(this.selectedIndex),l=this.getItemLocation(this.selectedIndex);this.drawSelMarker(g,l.x-gap,l.y-gap,is.width+2*gap,is.height+2*gap)}};this.paintOnTop=function(g){if(this.views.marker!=null&&(this.isComboMode||this.hasFocus())){var offset=this.position.offset;if(offset>=0){var gap=this.getItemGap(),is=this.getItemSize(offset),l=this.getItemLocation(offset);this.drawPosMarker(g,l.x-gap,l.y-gap,is.width+2*gap,is.height+2*gap)}}};this.select=function(index){if(this.model!=null&&index>=this.model.count()){throw new Error("index="+index+",max="+this.model.count())}if(this.selectedIndex!=index){var prev=this.selectedIndex;this.selectedIndex=index;this.notifyScrollMan(index);this.repaintByOffsets(prev,this.selectedIndex);this._.fired(this,prev)}else{this._.fired(this,null)}};this.mouseClicked=function(e){if(this.model!=null&&e.isActionMask()&&this.model.count()>0){this.select(this.position.offset<0?0:this.position.offset)}};this.mouseReleased=function(e){if(this.model!=null&&this.model.count()>0&&e.isActionMask()&&this.position.offset!=this.selectedIndex){this.position.setOffset(this.selectedIndex)}};this.mousePressed=function(e){if(e.isActionMask()&&this.model!=null&&this.model.count()>0){var index=this.getItemIdxAt(e.x,e.y);if(index>=0&&this.position.offset!=index){this.position.setOffset(index)}}};this.mouseEntered=function(e){this.correctPM(e.x,e.y)};this.keyPressed=function(e){if(this.model!=null&&this.model.count()>0){var po=this.position.offset;switch(e.code){case KE.END:if(e.isControlPressed()){this.position.setOffset(this.position.metrics.getMaxOffset())}else{this.position.seekLineTo(Position.END)}break;case KE.HOME:if(e.isControlPressed()){this.position.setOffset(0)}else{this.position.seekLineTo(Position.BEG)}break;case KE.RIGHT:this.position.seek(1);break;case KE.DOWN:this.position.seekLineTo(Position.DOWN);break;case KE.LEFT:this.position.seek(-1);break;case KE.UP:this.position.seekLineTo(Position.UP);break;case KE.PAGEUP:this.position.seek(this.pageSize(-1));break;case KE.PAGEDOWN:this.position.seek(this.pageSize(1));break;case KE.SPACE:case KE.ENTER:this.select(this.position.offset);break}if(po!=this.position.offset){if(this.isComboMode){this.notifyScrollMan(this.position.offset)}else{this.select(this.position.offset)}}}};this.keyTyped=function(e){var i=this.lookupItem(e.ch);if(i>=0){this.select(i)}};this.elementInserted=function(target,e,index){this.invalidate();if(this.selectedIndex>=0&&this.selectedIndex>=index){this.selectedIndex++}this.position.inserted(index,1);this.repaint()};this.elementRemoved=function(target,e,index){this.invalidate();if(this.selectedIndex==index||this.model.count()===0){this.select(-1)}else{if(this.selectedIndex>index){this.selectedIndex--}}this.position.removed(index,1);this.repaint()};this.elementSet=function(target,e,pe,index){this.invalidate();this.repaint()};this.posChanged=function(target,prevOffset,prevLine,prevCol){var off=this.position.offset;this.repaintByOffsets(prevOffset,off)};this.drawSelMarker=function(g,x,y,w,h){if(this.views.select){this.views.select.paint(g,x,y,w,h,this)}};this.drawPosMarker=function(g,x,y,w,h){if(this.views.marker){this.views.marker.paint(g,x,y,w,h,this)}};this.setItemGap=function(g){if(this.gap!=g){this.gap=g;this.vrp()}};this.setModel=function(m){if(m!=this.model){if(m!=null&&Array.isArray(m)){m=new zebra.data.ListModel(m)}if(this.model!=null&&this.model._){this.model._.remove(this)}this.model=m;if(this.model!=null&&this.model._){this.model._.add(this)}this.vrp()}};this.setPosition=function(c){if(c!=this.position){if(this.position!=null){this.position._.remove(this)}this.position=c;this.position._.add(this);this.position.setMetric(this);this.repaint()}};this.setViewProvider=function(v){if(this.provider!=v){if(typeof v=="function"){var o=new zebra.Dummy();o.getView=v;v=o}this.provider=v;this.vrp()}};this.notifyScrollMan=function(index){if(index>=0&&this.scrollManager!=null){this.validate();var gap=this.getItemGap(),dx=this.scrollManager.getSX(),dy=this.scrollManager.getSY(),is=this.getItemSize(index),l=this.getItemLocation(index);this.scrollManager.makeVisible(l.x-dx-gap,l.y-dy-gap,is.width+2*gap,is.height+2*gap)}};this.pageSize=function(d){var offset=this.position.offset;if(offset>=0){var vp=pkg.$cvp(this,{});if(vp!=null){var sum=0,i=offset,gap=2*this.getItemGap();for(;i>=0&&i<=this.position.metrics.getMaxOffset()&&sum":value.toString());return this.text}}])},function $prototype(){this.paint=function(g){this.vVisibility();if(this.firstVisible>=0){var sx=this.scrollManager.getSX(),sy=this.scrollManager.getSY();try{g.translate(sx,sy);var gap=this.getItemGap(),y=this.firstVisibleY,x=this.getLeft()+gap,yy=this.vArea.y+this.vArea.height-sy,count=this.model.count(),provider=this.provider;for(var i=this.firstVisible;iyy){break}}}catch(e){throw e}finally{g.translate(-sx,-sy)}}};this.recalc=function(){this.psWidth_=this.psHeight_=0;if(this.model!=null){var count=this.model.count();if(this.heights==null||this.heights.length!=count){this.heights=Array(count)}if(this.widths==null||this.widths.length!=count){this.widths=Array(count)}var provider=this.provider;if(provider!=null){for(var i=0;ithis.psWidth_){this.psWidth_=this.widths[i]}this.psHeight_+=this.heights[i]}}}};this.calcPreferredSize=function(l){var gap=2*this.getItemGap();return{width:gap+this.psWidth_,height:this.model==null?0:gap*this.model.count()+this.psHeight_}};this.vVisibility=function(){this.validate();var prev=this.vArea;this.vArea=pkg.$cvp(this,{});if(this.vArea==null){this.firstVisible=-1;return}if(this.visValid===false||(prev==null||prev.x!=this.vArea.x||prev.y!=this.vArea.y||prev.width!=this.vArea.width||prev.height!=this.vArea.height)){var top=this.getTop(),gap=this.getItemGap();if(this.firstVisible>=0){var dy=this.scrollManager.getSY();while(this.firstVisibleY+dy>=top&&this.firstVisible>0){this.firstVisible--;this.firstVisibleY-=(this.heights[this.firstVisible]+2*gap)}}else{this.firstVisible=0;this.firstVisibleY=top+gap}if(this.firstVisible>=0){var count=this.model==null?0:this.model.count(),hh=this.height-this.getBottom();for(;this.firstVisible=top&&y1=top&&y2=hh)){break}this.firstVisibleY+=(this.heights[this.firstVisible]+2*gap)}if(this.firstVisible>=count){this.firstVisible=-1}}this.visValid=true}};this.getItemLocation=function(index){this.validate();var gap=this.getItemGap(),y=this.getTop()+this.scrollManager.getSY()+gap;for(var i=0;i=0){var yy=this.firstVisibleY+this.scrollManager.getSY(),hh=this.height-this.getBottom(),count=this.model.count(),gap=this.getItemGap(),dgap=gap*2;for(var i=this.firstVisible;i=yy-gap&&yhh){break}}}return -1}},function(){this.$this(false)},function(m){if(zebra.isBoolean(m)){this.$this([],m)}else{this.$this(m,false)}},function(m,b){this.firstVisible=-1;this.firstVisibleY=this.psWidth_=this.psHeight_=0;this.heights=this.widths=this.vArea=null;this.visValid=false;this.setViewProvider(new pkg.List.ViewProvider());this.$super(m,b)},function invalidate(){this.visValid=false;this.firstVisible=-1;this.$super()},function drawSelMarker(g,x,y,w,h){this.$super(g,x,y,this.width-this.getRight()-x,h)},function drawPosMarker(g,x,y,w,h){this.$super(g,x,y,this.width-this.getRight()-x,h)},function catchScrolled(psx,psy){this.firstVisible=-1;this.visValid=false;this.$super(psx,psy)}]);pkg.CompList=Class(pkg.BaseList,pkg.Composite,[function $clazz(){this.Label=Class(pkg.Label,[]);this.ImageLabel=Class(pkg.ImageLabel,[]);var CompListModelListeners=Listeners.Class("elementInserted","elementRemoved");this.CompListModel=Class([function $prototype(){this.get=function(i){return this.src.kids[i]};this.set=function(item,i){this.src.removeAt(i);this.src.insert(i,null,item)};this.add=function(o){this.src.add(o)};this.removeAt=function(i){this.src.removeAt(i)};this.insert=function(item,i){this.src.insert(i,null,item)};this.count=function(){return this.src.kids.length};this.removeAll=function(){this.src.removeAll()}},function(src){this.src=src;this._=new CompListModelListeners()}])},function $prototype(){this.catchScrolled=function(px,py){};this.getItemLocation=function(i){var gap=this.getItemGap();return{x:this.kids[i].x+gap,y:this.kids[i].y+gap}};this.getItemSize=function(i){var gap=this.getItemGap();return{width:this.kids[i].width-2*gap,height:this.kids[i].height-2*gap}};this.recalc=function(){var gap=this.getItemGap();this.max=L.getMaxPreferredSize(this);this.max.width-=2*gap;this.max.height-=2*gap};this.calcMaxItemSize=function(){this.validate();return{width:this.max.width,height:this.max.height}};this.getItemIdxAt=function(x,y){return L.getDirectAt(x,y,this)};this.catchInput=function(child){if(this.isComboMode){return true}var b=this.input!=null&&L.isAncestorOf(this.input,child);if(b&&this.input!=null&&L.isAncestorOf(this.input,pkg.focusManager.focusOwner)&&this.hasFocus()===false){this.input=null}return(this.input==null||b===false)}},function(){this.$this([],false)},function(b){if(zebra.isBoolean(b)){this.$this([],b)}else{this.$this(b,false)}},function(d,b){this.input=this.max=null;this.setViewProvider(new zebra.Dummy([function getView(target,obj,i){return new pkg.CompRender(obj)}]));this.$super(d,b)},function setModel(m){var a=[];if(Array.isArray(m)){a=m;m=new pkg.CompList.CompListModel(this)}if(zebra.instanceOf(m,pkg.CompList.CompListModel)===false){throw new Error("Invalid model")}this.$super(m);for(var i=0;i=0&&o==this.selectedIndex)?this.model.get(this.position.offset):null;this.$super()},function drawSelMarker(g,x,y,w,h){if(this.input==null||L.isAncestorOf(this.input,pkg.focusManager.focusOwner)===false){this.$super(g,x,y,w,h)}},function posChanged(target,prevOffset,prevLine,prevCol){this.$super(target,prevOffset,prevLine,prevCol);if(this.isComboMode===false){this.input=(this.position.offset>=0)?this.model.get(this.position.offset):null}},function insert(index,constr,e){var c=zebra.isString(e)?new pkg.CompList.Label(e):e,g=this.getItemGap();c.setPaddings(c.top+g,c.left+g,c.bottom+g,c.right+g);return this.$super(index,constr,c)},function kidAdded(index,constr,e){this.$super(index,constr,e);this.model._.elementInserted(this,e,index)},function kidRemoved(index,e){var g=this.getItemGap();e.setPaddings(c.top-g,c.left-g,c.bottom-g,c.right-g);this.model._.elementRemoved(this,e,index)}]);var ContentListeners=Listeners.Class("contentUpdated");pkg.Combo=Class(pkg.Panel,pkg.MouseListener,pkg.KeyListener,pkg.Composite,[function $clazz(){this.ContentPan=Class(pkg.Panel,[function $prototype(){this.updateValue=function(combo,value){};this.getCombo=function(){var p=this;while((p=p.parent)&&zebra.instanceOf(p,pkg.Combo)==false){}return p}}]);this.ComboPadPan=Class(pkg.ScrollPan,[function $prototype(){this.closeTime=0},function setParent(l){this.$super(l);if(l==null&&this.owner){this.owner.requestFocus()}this.closeTime=l==null?new Date().getTime():0}]);this.ReadonlyContentPan=Class(this.ContentPan,[function $prototype(){this.calcPreferredSize=function(l){var p=this.getCombo();return p?p.list.calcMaxItemSize():{width:0,height:0}};this.paintOnTop=function(g){var list=this.getCombo().list,selected=list.getSelected(),v=selected!=null?list.provider.getView(list,selected,list.selectedIndex):null;if(v!=null){var ps=v.getPreferredSize();v.paint(g,this.getLeft(),this.getTop()+~~((this.height-this.getTop()-this.getBottom()-ps.height)/2),this.width,ps.height,this)}}}]);this.EditableContentPan=Class(this.ContentPan,[function $clazz(){this.TextField=Class(pkg.TextField,[])},function(){this.$super(new L.BorderLayout());this._=new ContentListeners();this.isEditable=true;this.dontGenerateUpdateEvent=false;this.textField=new pkg.Combo.EditableContentPan.TextField("",-1);this.textField.view.target._.add(this);this.add(L.CENTER,this.textField)},function focused(){this.$super();this.textField.requestFocus()},function $prototype(){this.textUpdated=function(src,b,off,size,startLine,lines){if(this.dontGenerateUpdateEvent===false){this._.contentUpdated(this,this.textField.getValue())}};this.canHaveFocus=function(){return true};this.updateValue=function(combo,v){this.dontGenerateUpdateEvent=true;try{var txt=(v==null?"":v.toString());this.textField.setValue(txt);this.textField.select(0,txt.length)}finally{this.dontGenerateUpdateEvent=false}}}]);this.Button=Class(pkg.Button,[function(){this.setFireParams(true,-1);this.setCanHaveFocus(false);this.$super()}]);this.List=Class(pkg.List,[])},function $prototype(){this.paint=function(g){if(this.content!=null&&this.selectionView!=null&&this.hasFocus()){this.selectionView.paint(g,this.content.x,this.content.y,this.content.width,this.content.height,this)}};this.catchInput=function(child){return child!=this.button&&(this.content==null||!this.content.isEditable)};this.canHaveFocus=function(){return this.winpad.parent==null&&(this.content!=null||!this.content.isEditable)};this.contentUpdated=function(src,text){if(src==this.content){try{this.lockListSelEvent=true;if(text==null){this.list.select(-1)}else{var m=this.list.model;for(var i=0;i100&&e.x>this.content.x&&e.y>this.content.y&&e.xthis.width){ps.height+=this.winpad.hbar.getPreferredSize().height}if(this.maxPadHeight>0&&ps.height>this.maxPadHeight){ps.height=this.maxPadHeight}if(py+this.height+ps.height>canvas.height){if(py-ps.height>=0){py-=(ps.height+this.height)}else{var hAbove=canvas.height-py-this.height;if(py>hAbove){ps.height=py;py-=(ps.height+this.height)}else{ps.height=hAbove}}}this.winpad.setSize(this.width,ps.height);this.winpad.setLocation(px,py+this.height);this.list.notifyScrollMan(this.list.selectedIndex);winlayer.add(this,this.winpad);this.list.requestFocus()}};this.setList=function(l){if(this.list!=l){this.hidePad();if(this.list!=null){this.list._.remove(this)}this.list=l;if(this.list._){this.list._.add(this)}this.winpad=new pkg.Combo.ComboPadPan(this.list);this.winpad.owner=this;if(this.content!=null){this.content.updateValue(this,this.list.getSelected())}this.vrp()}};this.keyPressed=function(e){if(this.list.model!=null){var index=this.list.selectedIndex;switch(e.code){case KE.LEFT:case KE.UP:if(index>0){this.list.select(index-1)}break;case KE.DOWN:case KE.RIGHT:if(this.list.model.count()-1>index){this.list.select(index+1)}break}}};this.keyTyped=function(e){this.list.keyTyped(e)};this.setSelectionView=function(c){if(c!=this.selectionView){this.selectionView=pkg.$view(c);this.repaint()}};this.setMaxPadHeight=function(h){if(this.maxPadHeight!=h){this.hidePad();this.maxPadHeight=h}}},function(){this.$this(new pkg.Combo.List(true))},function(list){if(zebra.isBoolean(list)){this.$this(new pkg.Combo.List(true),list)}else{this.$this(list,false)}},function(list,editable){if(zebra.instanceOf(list,pkg.BaseList)===false){list=new pkg.Combo.List(list,true)}this.button=this.content=this.winpad=null;this.maxPadHeight=0;this.lockListSelEvent=false;this._=new Listeners();this.setList(list);this.$super();this.add(L.CENTER,editable?new pkg.Combo.EditableContentPan():new pkg.Combo.ReadonlyContentPan());this.add(L.RIGHT,new pkg.Combo.Button())},function focused(){this.$super();this.repaint()},function kidAdded(index,s,c){if(zebra.instanceOf(c,pkg.Combo.ContentPan)){if(this.content!=null){throw new Error("Content panel is set")}if(c._){c._.add(this)}this.content=c;if(this.list!=null){c.updateValue(this,this.list.getSelected())}}this.$super(index,s,c);if(this.button==null&&zebra.instanceOf(c,zebra.util.Actionable)){this.button=c;this.button._.add(this)}},function kidRemoved(index,l){if(this.content==l){if(l._){l._.remove(this)}this.content=null}this.$super(index,l);if(this.button==l){this.button._.remove(this);this.button=null}},function fired(src){if((new Date().getTime()-this.winpad.closeTime)>100){this.showPad()}},function fired(src,data){if(this.lockListSelEvent===false){this.hidePad();if(this.content!=null){this.content.updateValue(this,this.list.getSelected());if(this.content.isEditable){pkg.focusManager.requestFocus(this.content)}this.repaint()}}}]);pkg.ComboArrowView=Class(pkg.View,[function $prototype(){this[""]=function(col,state){this.color=col==null?"black":col;this.state=state==null?false:state;this.gap=4};this.paint=function(g,x,y,w,h,d){if(this.state){g.setColor("#CCCCCC");g.drawLine(x,y,x,y+h);g.setColor("gray");g.drawLine(x+1,y,x+1,y+h)}else{g.setColor("#CCCCCC");g.drawLine(x,y,x,y+h);g.setColor("#EEEEEE");g.drawLine(x+1,y,x+1,y+h)}x+=this.gap+1;y+=this.gap+1;w-=this.gap*2;h-=this.gap*2;var s=Math.min(w,h);x=x+(w-s)/2+1;y=y+(h-s)/2;g.setColor(this.color);g.beginPath();g.moveTo(x,y);g.lineTo(x+s,y);g.lineTo(x+s/2,y+s);g.lineTo(x,y);g.fill()};this.getPreferredSize=function(){return{width:2*this.gap+6,height:2*this.gap+6}}}])})(zebra("ui"),zebra.Class);(function(pkg,Class,Interface){pkg.WinListener=Interface();var KE=pkg.KeyEvent,timer=zebra.util.timer,L=zebra.layout,MouseEvent=pkg.MouseEvent,WIN_OPENED=1,WIN_CLOSED=2,WIN_ACTIVATED=3,WIN_DEACTIVATED=4,VIS_PART_SIZE=30,WinListeners=zebra.util.Listeners.Class("winOpened","winActivated");pkg.showModalWindow=function(context,win,listener){pkg.showWindow(context,"modal",win,listener)};pkg.showWindow=function(context,type,win,listener){if(arguments.length<3){win=type;type="info"}return context.getCanvas().getLayer("win").addWin(type,win,listener)};pkg.hideWindow=function(win){if(win.parent&&win.parent.indexOf(win)>=0){win.parent.remove(win)}};pkg.WinLayer=Class(pkg.BaseLayer,pkg.ChildrenListener,[function $clazz(){this.ID="win";this.activate=function(c){c.getCanvas().getLayer("win").activate(c)}},function $prototype(){this.isLayerActiveAt=function(x,y){return this.activeWin!=null};this.layerMousePressed=function(x,y,mask){var cnt=this.kids.length;if(cnt>0){if(this.activeWin!=null&&this.indexOf(this.activeWin)==cnt-1){var x1=this.activeWin.x,y1=this.activeWin.y,x2=x1+this.activeWin.width,y2=y1+this.activeWin.height;if(x>=x1&&y>=y1&&x=0&&i>=this.topModalIndex;i--){var d=this.kids[i];if(d.isVisible&&d.isEnabled&&this.winType(d)!="info"&&x>=d.x&&y>=d.y&&x0&&keyCode==KE.TAB&&(mask&KE.M_SHIFT)>0){if(this.activeWin==null){this.activate(this.kids[this.kids.length-1])}else{var winIndex=this.winsStack.indexOf(this.activeWin)-1;if(winIndex=0;this.topModalIndex--){if(this.winType(this.winsStack[this.topModalIndex])=="modal"){break}}}}this.fire(WIN_CLOSED,lw,l);if(this.topModalIndex>=0){var aindex=this.winsStack.length-1;while(this.winType(this.winsStack[aindex])=="info"){aindex--}this.activate(this.winsStack[aindex])}}]);var $StatePan=Class(pkg.Panel,[function $prototype(){this.setState=function(s){if(this.state!=s){var old=this.state;this.state=s;this.updateState(old,s)}};this.updateState=function(olds,news){var b=false;if(this.bg&&this.bg.activate){b=this.bg.activate(news)}if(this.border&&this.border.activate){b=this.border.activate(news)||b}if(b){this.repaint()}}},function(){this.state="inactive";this.$super()},function setBorder(v){this.$super(v);this.updateState(this.state,this.state)},function setBackground(v){this.$super(v);this.updateState(this.state,this.state)}]);pkg.Window=Class($StatePan,pkg.WinListener,pkg.MouseListener,pkg.Composite,pkg.ExternalEditor,[function $prototype(){var MOVE_ACTION=1,SIZE_ACTION=2;this.minSize=40;this.isSizeable=true;this.isActive=function(){var c=this.getCanvas();return c!=null&&c.getLayer("win").activeWin==this};this.mouseDragStarted=function(e){this.px=e.x;this.py=e.y;this.psw=this.width;this.psh=this.height;this.action=this.insideCorner(this.px,this.py)?(this.isSizeable?SIZE_ACTION:-1):MOVE_ACTION;if(this.action>0){this.dy=this.dx=0}};this.mouseDragged=function(e){if(this.action>0){if(this.action!=MOVE_ACTION){var nw=this.psw+this.dx,nh=this.psh+this.dy;if(nw>this.minSize&&nh>this.minSize){this.setSize(nw,nh)}}this.dx=(e.x-this.px);this.dy=(e.y-this.py);if(this.action==MOVE_ACTION){this.invalidate();this.setLocation(this.x+this.dx,this.y+this.dy)}}};this.mouseDragEnded=function(e){if(this.action>0){if(this.action==MOVE_ACTION){this.invalidate();this.setLocation(this.x+this.dx,this.y+this.dy)}this.action=-1}};this.insideCorner=function(px,py){return this.getComponentAt(px,py)==this.sizer};this.getCursorType=function(target,x,y){return(this.isSizeable&&this.insideCorner(x,y))?pkg.Cursor.SE_RESIZE:null};this.catchInput=function(c){var tp=this.caption;return c==tp||(L.isAncestorOf(tp,c)&&zebra.instanceOf(c,pkg.Button)===false)||this.sizer==c};this.winOpened=function(winLayer,target,b){var state=this.isActive()?"active":"inactive";if(this.caption!=null&&this.caption.setState){this.caption.setState(state)}this.setState(state)};this.winActivated=function(winLayer,target,b){this.winOpened(winLayer,target,b)};this.mouseClicked=function(e){var x=e.x,y=e.y,cc=this.caption;if(e.clicks==2&&this.isSizeable&&x>cc.x&&xcc.y&&y=0){this.setLocation(this.prevX,this.prevY);this.setSize(this.prevW,this.prevH);this.prevW=-1}},function close(){if(this.parent){this.parent.remove(this)}},function setButtons(buttons){for(var i=0;i0&&this.isDecorative(i-1)){this.kids[i-1].setVisible(src.isVisible)}break}}}};this.hasVisibleItems=function(){for(var i=0;i=0&&!this.isDecorative(offset)){var is=this.getItemSize(offset),l=this.getItemLocation(offset);this.views.marker.paint(g,l.x-gap,l.y-gap,is.width+2*gap,is.height+2*gap,this)}}};this.mouseExited=function(e){var offset=this.position.offset;if(offset>=0&&this.getMenuAt(offset)==null){this.position.clearPos()}};this.drawPosMarker=function(g,x,y,w,h){};this.keyPressed=function(e){var position=this.position;if(position.metrics.getMaxOffset()>=0){var code=e.code,offset=position.offset;if(code==KE.DOWN){var ccc=this.kids.length;do{offset=(offset+1)%ccc}while(this.isDecorative(offset));position.setOffset(offset)}else{if(code==KE.UP){var ccc=this.kids.length;do{offset=(ccc+offset-1)%ccc}while(this.isDecorative(offset));position.setOffset(offset)}else{if(e.code==KE.ENTER||e.code==KE.SPACE){this.select(offset)}}}}};this.getMenuAt=function(index){return this.menus[this.kids[index]]};this.setMenuAt=function(i,m){if(m==this||this.isDecorative(i)){throw new Error()}var p=this.kids[i],sub=this.menus[p];this.menus[p]=m;if(m!=null){if(sub==null){p.set(L.RIGHT,new pkg.Menu.SubImage())}}else{if(sub!=null){p.set(L.RIGHT,null)}}}},function $clazz(){this.Label=Class(pkg.Label,[]);this.CheckStatePan=Class(pkg.ViewPan,[]);this.ItemPan=Class(pkg.Panel,[function $prototype(){this.gap=8;this.selected=function(){if(this.content.setState){this.content.setState(!this.content.getState())}};this.calcPreferredSize=function(target){var cc=0,pw=0,ph=0;for(var i=0;i0?this.gap:0);if(ps.height>ph){ph=ps.height}cc++}}return{width:pw,height:ph}};this.doLayout=function(target){var mw=-1;for(var i=0;imw){mw=ps.width}}}}var left=target.getByConstraints(L.LEFT),right=target.getByConstraints(L.RIGHT),content=target.getByConstraints(L.CENTER),t=target.getTop(),eh=target.height-t-target.getBottom();if(left&&left.isVisible){left.toPreferredSize();left.setLocation(this.getLeft(),t+(eh-left.height)/2)}if(content&&content.isVisible){content.toPreferredSize();content.setLocation(target.getLeft()+(mw>=0?mw+this.gap:0),t+(eh-content.height)/2)}if(right&&right.isVisible){right.toPreferredSize();right.setLocation(target.width-target.getLeft()-right.width,t+(eh-right.height)/2)}}},function(c){this.$super();this.content=c;this.add(L.CENTER,c);this.setEnabled(c.isEnabled);this.setVisible(c.isVisible)}]);this.ChItemPan=Class(this.ItemPan,[function(c,state){this.$super(c);this.add(L.LEFT,new pkg.Menu.CheckStatePan());this.state=state},function selected(){this.$super();this.state=!this.state;this.getByConstraints(L.LEFT).view.activate(this.state?"on":"off")}]);this.Line=Class(pkg.Line,[]);this.SubImage=Class(pkg.ImagePan,[])},function(){this.menus={};this.$super(true)},function(d){this.$this();for(var k in d){if(d.hasOwnProperty(k)){this.add(k);if(d[k]){this.setMenuAt(this.kids.length-1,new pkg.Menu(d[k]))}}}},function insert(i,ctr,c){if(zebra.isString(c)){if(c=="-"){return this.$super(i,ctr,new pkg.Menu.Line())}else{var m=c.match(/(\[\s*\]|\[x\]|\(x\)|\(\s*\))?\s*(.*)/);if(m!=null&&m[1]!=null){return this.$super(i,ctr,new pkg.Menu.ChItemPan(new pkg.Menu.Label(m[2]),m[1].indexOf("x")>0))}c=new pkg.Menu.Label(c)}}return this.$super(i,ctr,new pkg.Menu.ItemPan(c))},function addDecorative(c){this.$super(this.insert,this.kids.length,null,c)},function kidRemoved(i,c){this.setMenuAt(i,null);this.$super(i,c)},function posChanged(target,prevOffset,prevLine,prevCol){var off=this.position.offset;if(off<0||(this.kids.length>0&&this.kids[off].isVisible)){this.$super(target,prevOffset,prevLine,prevCol)}else{var d=(prevOffset0&&(this.kids[off].isVisible===false||this.isDecorative(off));cc--){off+=d;if(off<0){off=ccc-1}if(off>=ccc){off=0}}if(cc>0){this.position.setOffset(off);this.repaint()}}},function select(i){if(i<0||this.isDecorative(i)===false){if(i>=0){if(this.kids[i].content.isEnabled===false){return}this.kids[i].selected()}this.$super(i)}}]);pkg.Menubar=Class(pkg.Panel,pkg.ChildrenListener,pkg.KeyListener,[function $prototype(){this.childInputEvent=function(e){var target=L.getDirectChild(this,e.source);switch(e.ID){case MouseEvent.ENTERED:if(this.over!=target){var prev=this.over;this.over=target;if(this.selected!=null){this.$select(this.over)}else{this.repaint2(prev,this.over)}}break;case MouseEvent.EXITED:var p=L.getRelLocation(e.absX,e.absY,this.getCanvas(),this.over);if(p.x<0||p.y<0||p.x>=this.over.width||p.y>=this.over.height){var prev=this.over;this.over=null;if(this.selected==null){this.repaint2(prev,this.over)}}break;case MouseEvent.CLICKED:this.over=target;this.$select(this.selected==target?null:target);break}};this.activated=function(b){if(b===false){this.$select(null)}};this.$select=function(b){if(this.selected!=b){var prev=this.selected,d=this.getCanvas();this.selected=b;if(d!=null){var pop=d.getLayer(pkg.PopupLayer.ID);pop.removeAll();if(this.selected!=null){pop.setMenubar(this);var menu=this.getMenu(this.selected);if(menu!=null&&menu.hasVisibleItems()){var abs=L.getAbsLocation(0,0,this.selected);menu.setLocation(abs.x,abs.y+this.selected.height+1);pop.add(menu)}}else{pop.setMenubar(null)}}this.repaint2(prev,this.selected);this._.fired(this,this.selected==null?-1:this.indexOf(this.selected),prev==null?-1:this.indexOf(prev))}};this.repaint2=function(i1,i2){if(i1!=null){i1.repaint()}if(i2!=null){i2.repaint()}};this.paint=function(g){if(this.views!=null){var target=(this.selected!=null)?this.selected:this.over;if(target!=null){var v=(this.selected!=null)?this.views.on:this.views.off;if(v!=null){v.paint(g,target.x,target.y,target.width,target.height,this)}}}};this.keyPressed=function(e){if(this.selected!=null){var idx=this.indexOf(this.selected),pidx=idx,c=null;if(e.code==KE.LEFT){var ccc=this.kids.length;do{idx=(ccc+idx-1)%ccc;c=this.kids[idx]}while(c.isEnabled===false||c.isVisible===false)}else{if(e.code==KE.RIGHT){var ccc=this.kids.length;do{idx=(idx+1)%ccc;c=this.kids[idx]}while(c.isEnabled===false||c.isVisible===false)}}if(idx!=pidx){this.$select(this.kids[idx])}}};this.addMenu=function(c,m){this.add(c);this.setMenuAt(this.kids.length-1,m)};this.setMenuAt=function(i,m){if(i>=this.kids.length){throw new Error("Invalid kid index:"+i)}var c=this.kids[i];if(m==null){var pm=this.menus.hasOwnProperty(c)?this.menus[c]:null;if(pm!=null){delete this.menus[c]}}else{this.menus[c]=m}};this.getMenuAt=function(i){return this.getMenu(this.kids[i])};this.getMenu=function(c){return this.menus.hasOwnProperty(c)?this.menus[c]:null}},function $clazz(){this.Label=Class(pkg.Label,[])},function(){this.menus={};this.over=this.selected=null;this.$super();this._=new zebra.util.Listeners()},function(d){this.$this();for(var k in d){if(d.hasOwnProperty(k)){if(d[k]){this.addMenu(k,new pkg.Menu(d[k]))}else{this.add(k)}}}},function insert(i,constr,c){if(zebra.isString(c)){c=new pkg.Menubar.Label(c)}this.$super(i,constr,c)},function kidRemoved(i,c){this.setMenuAt(i,null);this.$super(i)},function removeAll(){this.$super();this.menus={}}]);pkg.Menubar.prototype.setViews=pkg.$ViewsSetter;pkg.PopupLayer=Class(pkg.BaseLayer,pkg.ChildrenListener,[function $clazz(){this.ID="pop"},function $prototype(){this.mTop=this.mLeft=this.mBottom=this.mRight=0;this.layerMousePressed=function(x,y,mask){if(this.isLayerActiveAt(x,y)===false||this.getComponentAt(x,y)==this){if(this.kids.length>0){this.removeAll()}if(this.mbar!=null){this.setMenubar(null)}return false}return true};this.isLayerActiveAt=function(x,y){return this.kids.length>0&&(this.mbar==null||y>this.mBottom||ythis.mRight)};this.childInputEvent=function(e){if(e.UID==pkg.InputEvent.KEY_UID){if(e.ID==KE.PRESSED&&e.code==KE.ESCAPE){this.remove(L.getDirectChild(this,e.source));if(this.kids===0){this.setMenubar(null)}}if(zebra.instanceOf(this.mbar,pkg.KeyListener)){pkg.events.performInput(new KE(this.mbar,e.ID,e.code,e.ch,e.mask))}}};this.calcPreferredSize=function(target){return{width:0,height:0}};this.setMenubar=function(mb){if(this.mbar!=mb){this.removeAll();if(this.mbar&&this.mbar.activated){this.mbar.activated(false)}this.mbar=mb;if(this.mbar!=null){var abs=L.getAbsLocation(0,0,this.mbar);this.mLeft=abs.x;this.mRight=this.mLeft+this.mbar.width-1;this.mTop=abs.y;this.mBottom=this.mTop+this.mbar.height-1}if(this.mbar&&this.mbar.activated){this.mbar.activated(true)}}};this.posChanged=function(target,prevOffset,prevLine,prevCol){if(timer.get(this)){timer.stop(this)}var selectedIndex=target.offset;if(selectedIndex>=0){var index=this.pcMap.indexOf(target),sub=this.kids[index].getMenuAt(selectedIndex);if(index+1=0){var sub=src.getMenuAt(index);if(sub!=null){if(sub.parent==null){sub.setLocation(src.x+src.width-10,src.y+src.kids[index].y);this.add(sub)}else{pkg.focusManager.requestFocus(this.kids[this.kids.length-1])}}else{this.removeAll();this.setMenubar(null)}}else{if(src.selectedIndex>=0){var sub=src.getMenuAt(src.selectedIndex);if(sub!=null){this.remove(sub)}}}};this.run=function(){timer.stop(this);if(this.kids.length>0){var menu=this.kids[this.kids.length-1];menu.select(menu.position.offset)}};this.doLayout=function(target){var cnt=this.kids.length;for(var i=0;ithis.width)?this.width-ps.width:m.x,yy=(m.y+ps.height>this.height)?this.height-ps.height:m.y;m.setSize(ps.width,ps.height);if(xx<0){xx=0}if(yy<0){yy=0}m.setLocation(xx,yy)}}}},function(){this.mbar=null;this.pcMap=[];this.showIn=250;this.$super(pkg.PopupLayer.ID)},function removeAt(index){for(var i=this.kids.length-1;i>=index;i--){this.$super(index)}},function kidAdded(index,id,lw){this.$super(index,id,lw);if(zebra.instanceOf(lw,pkg.Menu)){lw.position.clearPos();lw.select(-1);this.pcMap.splice(index,0,lw.position);lw._.add(this);lw.position._.add(this);lw.requestFocus()}},function kidRemoved(index,lw){this.$super(index,lw);if(zebra.instanceOf(lw,pkg.Menu)){lw._.remove(this);lw.position._.remove(this);this.pcMap.splice(index,1);if(this.kids.length>0){this.kids[this.kids.length-1].select(-1);this.kids[this.kids.length-1].requestFocus()}}}]);pkg.Tooltip=Class(pkg.Panel,[function $clazz(){this.borderColor="black";this.borderWidth=1;this.Label=Class(pkg.Label,[]);this.TooltipBorder=Class(pkg.View,[function $prototype(){this[""]=function(col,size){this.color=col!=null?col:"black";this.size=size==null?4:size;this.gap=2*this.size};this.paint=function(g,x,y,w,h,d){if(this.color!=null){var old=g.lineWidth;this.outline(g,x,y,w,h,d);g.setColor(this.color);g.lineWidth=this.size;g.stroke();g.lineWidth=old}};this.outline=function(g,x,y,w,h,d){g.beginPath();h-=2*this.size;w-=2*this.size;x+=this.size;y+=this.size;var w2=(w/2+0.5)|0,h3=(h/3+0.5)|0,w3_8=((3*w)/8+0.5)|0,h2_3=((2*h)/3+0.5)|0,h3=(h/3+0.5)|0,w4=(w/4+0.5)|0;g.moveTo(x+w2,y);g.quadraticCurveTo(x,y,x,y+h3);g.quadraticCurveTo(x,y+h2_3,x+w4,y+h2_3);g.quadraticCurveTo(x+w4,y+h,x,y+h);g.quadraticCurveTo(x+w3_8,y+h,x+w2,y+h2_3);g.quadraticCurveTo(x+w,y+h2_3,x+w,y+h3);g.quadraticCurveTo(x+w,y,x+w2,y);return true}}])},function(content){this.$super();this.setBorder(new pkg.Tooltip.TooltipBorder(pkg.Tooltip.borderColor,pkg.Tooltip.borderWidth));this.add(zebra.instanceOf(content,pkg.Panel)?content:new pkg.Tooltip.Label(content));this.toPreferredSize()},function recalc(){this.$contentPs=(this.kids.length===0?this.$super():this.kids[0].getPreferredSize())},function getBottom(){return this.$super()+this.$contentPs.height},function getTop(){return this.$super()+((this.$contentPs.height/6+0.5)|0)},function getLeft(){return this.$super()+((this.$contentPs.height/6+0.5)|0)},function getRight(){return this.$super()+((this.$contentPs.height/6+0.5)|0)}]);pkg.PopupManager=Class(pkg.Manager,pkg.MouseListener,[function $prototype(){this.mouseClicked=function(e){this.popupMenuX=e.absX;this.popupManuY=e.absY;if((e.mask&MouseEvent.RIGHT_BUTTON)>0){var popup=null;if(e.source.popup!=null){popup=e.source.popup}else{if(e.source.getPopup!=null){popup=e.source.getPopup(e.source,e.x,e.y)}}if(popup!=null){popup.setLocation(this.popupMenuX,this.popupManuY);e.source.getCanvas().getLayer(pkg.PopupLayer.ID).add(popup);popup.requestFocus()}}};this.hideTooltipByPress=true;this.mouseEntered=function(e){var c=e.source;if(c.getTooltip!=null||c.tooltip!=null){this.target=c;this.targetTooltipLayer=c.getCanvas().getLayer(pkg.WinLayer.ID);this.tooltipX=e.x;this.tooltipY=e.y;timer.start(this,this.showTooltipIn,this.showTooltipIn)}};this.mouseExited=function(e){if(this.target!=null){timer.stop(this);this.target=null;this.hideTooltip()}};this.mouseMoved=function(e){if(this.target!=null){timer.clear(this);this.tooltipX=e.x;this.tooltipY=e.y;this.hideTooltip()}};this.run=function(){if(this.tooltip==null){this.tooltip=this.target.tooltip!=null?this.target.tooltip:this.target.getTooltip(this.target,this.tooltipX,this.tooltipY);if(this.tooltip!=null){var p=L.getAbsLocation(this.tooltipX,this.tooltipY,this.target);this.tooltip.toPreferredSize();var tx=p.x,ty=p.y-this.tooltip.height,dw=this.targetTooltipLayer.width;if(tx+this.tooltip.width>dw){tx=dw-this.tooltip.width-1}this.tooltip.setLocation(tx<0?0:tx,ty<0?0:ty);this.targetTooltipLayer.addWin("info",this.tooltip,null)}}};this.hideTooltip=function(){if(this.tooltip!=null){this.targetTooltipLayer.remove(this.tooltip);this.tooltip=null}};this.mousePressed=function(e){if(this.hideTooltipByPress&&this.target!=null){timer.stop(this);this.target=null;this.hideTooltip()}};this.mouseReleased=function(e){if(this.hideTooltipByPress&&this.target!=null){this.x=e.x;this.y=e.y;timer.start(this,this.showTooltipIn,this.showTooltipIn)}}},function(){this.$super();this.popupMenuX=this.popupManuY=0;this.tooltipX=this.tooltipY=0;this.targetTooltipLayer=this.tooltip=this.target=null;this.showTooltipIn=400}]);pkg.WindowTitleView=Class(pkg.View,[function $prototype(){this[""]=function(bg){this.radius=6;this.gap=this.radius;this.bg=bg?bg:"#66CCFF"};this.paint=function(g,x,y,w,h,d){this.outline(g,x,y,w,h,d);g.setColor(this.bg);g.fill()};this.outline=function(g,x,y,w,h,d){g.beginPath();g.moveTo(x+this.radius,y);g.lineTo(x+w-this.radius*2,y);g.quadraticCurveTo(x+w,y,x+w,y+this.radius);g.lineTo(x+w,y+h);g.lineTo(x,y+h);g.lineTo(x,y+this.radius);g.quadraticCurveTo(x,y,x+this.radius,y);return true}}])})(zebra("ui"),zebra.Class,zebra.Interface);(function(pkg,Class,ui){var L=zebra.layout,Cursor=ui.Cursor,KeyEvent=ui.KeyEvent,CURSORS=[];CURSORS[L.LEFT]=Cursor.W_RESIZE;CURSORS[L.RIGHT]=Cursor.E_RESIZE;CURSORS[L.TOP]=Cursor.N_RESIZE;CURSORS[L.BOTTOM]=Cursor.S_RESIZE;CURSORS[L.TLEFT]=Cursor.NW_RESIZE;CURSORS[L.TRIGHT]=Cursor.NE_RESIZE;CURSORS[L.BLEFT]=Cursor.SW_RESIZE;CURSORS[L.BRIGHT]=Cursor.SE_RESIZE;CURSORS[L.CENTER]=Cursor.MOVE;CURSORS[L.NONE]=Cursor.DEFAULT;pkg.ShaperBorder=Class(ui.View,[function $prototype(){this.color="blue";this.gap=7;function contains(x,y,gx,gy,ww,hh){return gx<=x&&(gx+ww)>x&&gy<=y&&(gy+hh)>y}this.paint=function(g,x,y,w,h,d){var cx=~~((w-this.gap)/2),cy=~~((h-this.gap)/2);g.setColor(this.color);g.beginPath();g.rect(x,y,this.gap,this.gap);g.rect(x+cx,y,this.gap,this.gap);g.rect(x,y+cy,this.gap,this.gap);g.rect(x+w-this.gap,y,this.gap,this.gap);g.rect(x,y+h-this.gap,this.gap,this.gap);g.rect(x+cx,y+h-this.gap,this.gap,this.gap);g.rect(x+w-this.gap,y+cy,this.gap,this.gap);g.rect(x+w-this.gap,y+h-this.gap,this.gap,this.gap);g.fill();g.beginPath();g.rect(x+~~(this.gap/2),y+~~(this.gap/2),w-this.gap,h-this.gap);g.stroke()};this.detectAt=function(target,x,y){var gap=this.gap,gap2=gap*2,w=target.width,h=target.height;if(contains(x,y,gap,gap,w-gap2,h-gap2)){return L.CENTER}if(contains(x,y,0,0,gap,gap)){return L.TLEFT}if(contains(x,y,0,h-gap,gap,gap)){return L.BLEFT}if(contains(x,y,w-gap,0,gap,gap)){return L.TRIGHT}if(contains(x,y,w-gap,h-gap,gap,gap)){return L.BRIGHT}var mx=~~((w-gap)/2);if(contains(x,y,mx,0,gap,gap)){return L.TOP}if(contains(x,y,mx,h-gap,gap,gap)){return L.BOTTOM}var my=~~((h-gap)/2);if(contains(x,y,0,my,gap,gap)){return L.LEFT}return contains(x,y,w-gap,my,gap,gap)?L.RIGHT:L.NONE}}]);pkg.InsetsArea=Class([function $prototype(){this.top=this.right=this.left=this.bottom=6;this.detectAt=function(c,x,y){var t=0,b1=false,b2=false;if(x(c.width-this.right)){t+=L.RIGHT}else{b1=true}}if(y(c.height-this.bottom)){t+=L.BOTTOM}else{b2=true}}return b1&&b2?L.CENTER:t}}]);pkg.ShaperPan=Class(ui.Panel,ui.Composite,ui.KeyListener,ui.MouseListener,[function $prototype(){this.minHeight=this.minWidth=12;this.isResizeEnabled=this.isMoveEnabled=true;this.state=null;this.getCursorType=function(t,x,y){return this.kids.length>0?CURSORS[this.shaperBr.detectAt(t,x,y)]:null};this.canHaveFocus=function(){return true};this.keyPressed=function(e){if(this.kids.length>0){var b=(e.mask&KeyEvent.M_SHIFT)>0,c=e.code,dx=(c==KeyEvent.LEFT?-1:(c==KeyEvent.RIGHT?1:0)),dy=(c==KeyEvent.UP?-1:(c==KeyEvent.DOWN?1:0)),w=this.width+dx,h=this.height+dy,x=this.x+dx,y=this.y+dy;if(b){if(this.isResizeEnabled&&w>this.shaperBr.gap*2&&h>this.shaperBr.gap*2){this.setSize(w,h)}}else{if(this.isMoveEnabled){var ww=this.width,hh=this.height,p=this.parent;if(x+ww/2>0&&y+hh/2>0&&x0?1:0),left:((t&L.LEFT)>0?1:0),right:((t&L.RIGHT)>0?1:0),bottom:((t&L.BOTTOM)>0?1:0)};if(this.state!=null){this.px=e.absX;this.py=e.absY}}};this.mouseDragged=function(e){if(this.state!=null){var dy=(e.absY-this.py),dx=(e.absX-this.px),s=this.state,nw=this.width-dx*s.left+dx*s.right,nh=this.height-dy*s.top+dy*s.bottom;if(nw>=this.minWidth&&nh>=this.minHeight){this.px=e.absX;this.py=e.absY;if((s.top+s.right+s.bottom+s.left)===0){this.setLocation(this.x+dx,this.y+dy)}else{this.setSize(nw,nh);this.setLocation(this.x+dx*s.left,this.y+dy*s.top)}}}};this.setColor=function(b,color){this.colors[b?1:0]=color;this.shaperBr.color=this.colors[this.hasFocus()?1:0];this.repaint()}},function(t){this.$super(new L.BorderLayout());this.px=this.py=0;this.shaperBr=new pkg.ShaperBorder();this.colors=["lightGray","blue"];this.shaperBr.color=this.colors[0];this.setBorder(this.shaperBr);if(t!=null){this.add(t)}},function insert(i,constr,d){if(this.kids.length>0){this.removeAll()}var top=this.getTop(),left=this.getLeft();if(d.width===0||d.height===0){d.toPreferredSize()}this.setLocation(d.x-left,d.y-top);this.setSize(d.width+left+this.getRight(),d.height+top+this.getBottom());this.$super(i,L.CENTER,d)},function focused(){this.$super();this.shaperBr.color=this.colors[this.hasFocus()?1:0];this.repaint()}]);pkg.FormTreeModel=Class(zebra.data.TreeModel,[function $prototype(){this.buildModel=function(comp,root){var b=this.exclude&&this.exclude(comp),item=b?root:this.createItem(comp);for(var i=0;i0?name.substring(index+1):name);item.comp=comp;return item}},function(target){this.$super(this.buildModel(target,null))}])})(zebra("ui.designer"),zebra.Class,zebra("ui"));(function(pkg,Class){pkg.HtmlElement=Class(pkg.Panel,pkg.FocusListener,[function $prototype(){this.isLocAdjusted=false;this.canvas=null;this.ePsW=this.ePsH=0;this.setFont=function(f){this.element.style.font=f.toString();this.vrp()};this.setColor=function(c){this.element.style.color=c.toString()};this.adjustLocation=function(){if(this.isLocAdjusted===false&&this.canvas!=null){var visibility=this.element.style.visibility;this.element.style.visibility="hidden";if(zebra.instanceOf(this.parent,pkg.HtmlElement)){this.element.style.top=""+this.y+"px";this.element.style.left=""+this.x+"px"}else{var a=zebra.layout.getAbsLocation(0,0,this);this.element.style.top=""+(this.canvas.offy+a.y)+"px";this.element.style.left=""+(this.canvas.offx+a.x)+"px"}this.isLocAdjusted=true;this.element.style.visibility=visibility}};this.calcPreferredSize=function(target){return{width:this.ePsW,height:this.ePsH}};var $store=["visibility","paddingTop","paddingLeft","paddingBottom","paddingRight","border","borderStyle","borderWidth","borderTopStyle","borderTopWidth","borderBottomStyle","borderBottomWidth","borderLeftStyle","borderLeftWidth","borderRightStyle","borderRightWidth","width","height"];this.recalc=function(){var e=this.element,vars={};for(var i=0;i<$store.length;i++){var k=$store[i];vars[k]=e.style[k]}e.style.visibility="hidden";e.style.padding="0px";e.style.border="none";e.style.width="auto";e.style.height="auto";this.ePsW=e.offsetWidth;this.ePsH=e.offsetHeight;for(var k in vars){var v=vars[k];if(v!=null){e.style[k]=v}}this.setSize(this.width,this.height)};this.setContent=function(content){this.element.innerHTML=content;this.vrp()};this.setStyles=function(styles){for(var k in styles){this.setStyle(k,styles[k])}};this.setStyle=function(name,value){name=name.trim();var i=name.indexOf(":");if(i>0){if(zebra[name.substring(0,i)]==null){return}name=name.substring(i+1)}this.element.style[name]=value;this.vrp()};this.setAttribute=function(name,value){this.element.setAttribute(name,value)};this.isInInvisibleState=function(){if(this.width<=0||this.height<=0||this.getCanvas()==null){return true}var p=this.parent;while(p!=null&&p.isVisible&&p.width>0&&p.height>0){p=p.parent}return p!=null};this.paint=function(g){if(this.element.style.visibility=="hidden"){this.element.style.visibility="visible"}}},function(e){e=this.element=zebra.isString(e)?document.createElement(e):e;e.setAttribute("id",this.toString());e.style.visibility="hidden";this.$super();var $this=this;this.globalCompListener=new pkg.ComponentListener([function $prototype(){this.compShown=function(c){if(c!=$this&&c.isVisible===false&&zebra.layout.isAncestorOf(c,$this)){$this.element.style.visibility="hidden"}};this.compMoved=function(c,px,py){if($this.canvas==c){$this.isLocAdjusted=false;$this.adjustLocation()}};this.compRemoved=function(p,c){if(c!=$this&&zebra.layout.isAncestorOf(c,$this)){$this.element.style.visibility="hidden"}};this.compSized=function(c,pw,ph){if(c!=$this&&zebra.layout.isAncestorOf(c,$this)&&$this.isInInvisibleState()){$this.element.style.visibility="hidden"}}}]);if(zebra.isTouchable===false){e.onmousemove=function(ee){if($this.canvas!=null){$this.canvas.mouseMoved(1,{target:$this.canvas.canvas,pageX:ee.pageX,pageY:ee.pageY})}};e.onmousedown=function(ee){if($this.canvas!=null){$this.canvas.mousePressed(1,{target:$this.canvas.canvas,pageX:ee.pageX,pageY:ee.pageY})}};e.onmouseup=function(ee){if($this.canvas!=null){$this.canvas.mouseReleased(1,{target:$this.canvas.canvas,pageX:ee.pageX,pageY:ee.pageY},ee.button===0?pkg.MouseEvent.LEFT_BUTTON:(ee.button==2?pkg.MouseEvent.RIGHT_BUTTON:0))}}}e.addEventListener("focus",function(ee){$this.element.canvas=$this.canvas;zebra.ui.focusManager.requestFocus($this)},false);e.addEventListener("blur",function(ee){$this.element.canvas=null;if($this.canvas!=null){setTimeout(function(){var fo=zebra.ui.focusManager.focusOwner;if((document.activeElement!=$this.canvas.canvas)&&(document.activeElement!=null&&$this.canvas!=document.activeElement.canvas)){zebra.ui.focusManager.requestFocus(null)}},100)}},false);e.onkeydown=function(ee){if($this.canvas!=null){var pfo=zebra.ui.focusManager.focusOwner;$this.canvas.keyPressed({keyCode:ee.keyCode,target:ee.target,altKey:ee.altKey,shiftKey:ee.shiftKey,ctrlKey:ee.ctrlKey,metaKey:ee.metaKey,preventDefault:function(){}});var nfo=zebra.ui.focusManager.focusOwner;if(nfo!=pfo){ee.preventDefault();if(nfo!=null&&zebra.instanceOf(nfo,pkg.HtmlElement)&&document.activeElement!=nfo.element){nfo.element.focus()}else{$this.canvas.canvas.focus()}}}};e.onkeyup=function(ee){if($this.canvas!=null){$this.canvas.keyReleased(ee)}};e.onkeypress=function(ee){if($this.canvas!=null){$this.canvas.keyTyped({keyCode:ee.keyCode,target:ee.target,altKey:ee.altKey,shiftKey:ee.shiftKey,ctrlKey:ee.ctrlKey,metaKey:ee.metaKey,preventDefault:function(){}})}}},function focused(){if(this.hasFocus()){var canvas=this.getCanvas();var pfo=canvas.$prevFocusOwner;if(pfo==null||zebra.instanceOf(pfo,pkg.HtmlElement)===false){this.element.focus()}}this.$super()},function setBorder(b){if(b==null){this.element.style.border="none"}else{var e=this.element;e.style.border="0px solid transparent";e.style.borderTopStyle="solid";e.style.borderTopColor="transparent";e.style.borderTopWidth=""+b.getTop()+"px";e.style.borderLeftStyle="solid";e.style.borderLeftColor="transparent";e.style.borderLeftWidth=""+b.getLeft()+"px";e.style.borderBottomStyle="solid";e.style.borderBottomColor="transparent";e.style.borderBottomWidth=""+b.getBottom()+"px";e.style.borderRightStyle="solid";e.style.borderRightColor="transparent";e.style.borderRightWidth=""+b.getRight()+"px"}this.$super(b)},function setPaddings(t,l,b,r){var e=this.element;e.style.paddingTop=""+t+"px";e.style.paddingLeft=""+l+"px";e.style.paddingRight=""+r+"px";e.style.paddingBottom=""+b+"px";this.$super(t,l,b,r)},function setVisible(b){if(this.isInInvisibleState()){this.element.style.visibility="hidden"}else{this.element.style.visibility=b?"visible":"hidden"}this.$super(b)},function setEnabled(b){this.$super(b);this.element.disabled=!b},function setSize(w,h){this.$super(w,h);var visibility=this.element.style.visibility;this.element.style.visibility="hidden";this.element.style.width=""+w+"px";this.element.style.height=""+h+"px";var dx=this.element.offsetWidth-w,dy=this.element.offsetHeight-h;this.element.style.width=""+(w-dx)+"px";this.element.style.height=""+(h-dy)+"px";if(this.isInInvisibleState()){this.element.style.visibility="hidden"}else{this.element.style.visibility=visibility}},function setLocation(x,y){this.$super(x,y);this.isLocAdjusted=false},function validate(){if(this.canvas==null&&this.parent!=null){this.canvas=this.getCanvas()}if(this.canvas!=null&&this.isLocAdjusted===false){this.adjustLocation()}this.$super()},function setParent(p){this.$super(p);if(p==null){if(this.element.parentNode!=null){this.element.parentNode.removeChild(this.element)}this.element.style.visibility="hidden";pkg.events.removeComponentListener(this.globalCompListener)}else{if(zebra.instanceOf(p,pkg.HtmlElement)){p.element.appendChild(this.element)}else{document.body.appendChild(this.element)}if(this.isInInvisibleState()){this.element.style.visibility="hidden"}else{this.element.style.visibility=this.isVisible?"visible":"hidden"}pkg.events.addComponentListener(this.globalCompListener)}this.isLocAdjusted=false;this.canvas=p!=null?this.getCanvas():null}]);pkg.HtmlTextInput=Class(pkg.HtmlElement,[function $prototype(){this.canHaveFocus=function(){return true};this.getText=function(){return this.element.value.toString()};this.setText=function(t){if(this.element.value!=t){this.element.value=t;this.vrp()}}},function(text,elementName){this.$super(elementName);this.element.setAttribute("tabindex",0);this.setText(text)}]);pkg.HtmlContent=Class(pkg.HtmlElement,[function(){this.$super("div");this.setStyle("overflow","hidden")},function loadContent(url){var c=zebra.io.GET(url);this.setContent(c);this.vrp()}]);pkg.HtmlTextField=Class(pkg.HtmlTextInput,[function(){this.$this("")},function(text){this.$super(text,"input");this.element.setAttribute("type","text")}]);pkg.HtmlTextArea=Class(pkg.HtmlTextInput,[function(){this.$this("")},function(text){this.$super(text,"textarea");this.element.setAttribute("rows",10)}])})(zebra("ui"),zebra.Class);(function(pkg,Class,ui){var KE=ui.KeyEvent,IM=function(b){this.width=this.height=this.x=this.y=this.viewHeight=0;this.viewWidth=-1;this.isOpen=b},TreeListeners=zebra.util.Listeners.Class("toggled","selected");pkg.DefEditors=Class([function(){this.tf=new ui.TextField(new zebra.data.SingleLineTxt(""));this.tf.setBackground("white");this.tf.setBorder(null);this.tf.setPadding(0)},function $prototype(){this.getEditor=function(src,item){var o=item.value;this.tf.setValue((o==null)?"":o.toString());return this.tf};this.fetchEditedValue=function(src,editor){return editor.view.target.getValue()};this.shouldStartEdit=function(src,e){return(e.ID==ui.MouseEvent.CLICKED&&e.clicks>1)||(e.ID==KE.PRESSED&&e.code==KE.ENTER)}}]);pkg.DefViews=Class([function $prototype(){this.getView=function(d,obj){if(obj.value&&obj.value.paint){return obj.value}this.render.target.setValue(obj.value==null?"":obj.value);return this.render};this[""]=function(color,font){if(color==null){color=pkg.Tree.fontColor}if(font==null){font=pkg.Tree.font}this.render=new ui.TextRender("");this.render.setFont(font);this.render.setColor(color)}}]);pkg.Tree=Class(ui.Panel,ui.MouseListener,ui.KeyListener,ui.ChildrenListener,[function $prototype(){this.itemGapY=this.gapx=this.gapy=2;this.itemGapX=4;this.canHaveFocus=function(){return true};this.childInputEvent=function(e){if(e.ID==KE.PRESSED){if(e.code==KE.ESCAPE){this.stopEditing(false)}else{if(e.code==KE.ENTER){if((zebra.instanceOf(e.source,ui.TextField)===false)||(zebra.instanceOf(e.source.view.target,zebra.data.SingleLineTxt))){this.stopEditing(true)}}}}};this.isInvalidatedByChild=function(c){return false};this.catchScrolled=function(psx,psy){this.stopEditing(true);if(this.firstVisible==null){this.firstVisible=this.model.root}this.firstVisible=(this.y~~(this.maxh/2))?this.prevVisible(this.findLast(this.model.root)):this.nextVisible(this.model.root)}}}}this._isVal=true};this.recalc=function(){this.maxh=this.maxw=0;if(this.model!=null&&this.model.root!=null){this.recalc_(this.getLeft(),this.getTop(),null,this.model.root,true);this.maxw-=this.getLeft();this.maxh-=this.gapy}};this.getViewBounds=function(root){var metrics=this.getIM(root),toggle=this.getToggleBounds(root),image=this.getImageBounds(root);toggle.x=image.x+image.width+(image.width>0||toggle.width>0?this.gapx:0);toggle.y=metrics.y+~~((metrics.height-metrics.viewHeight)/2);toggle.width=metrics.viewWidth;toggle.height=metrics.viewHeight;return toggle};this.getToggleBounds=function(root){var node=this.getIM(root),d=this.getToggleSize(root);return{x:node.x,y:node.y+~~((node.height-d.height)/2),width:d.width,height:d.height}};this.getToggleView=function(i){return i.kids.length>0?(this.getIM(i).isOpen?this.views.on:this.views.off):null};this.recalc_=function(x,y,parent,root,isVis){var node=this.getIM(root);if(isVis===true){if(node.viewWidth<0){var viewSize=this.provider.getView(this,root).getPreferredSize();node.viewWidth=viewSize.width===0?5:viewSize.width+this.itemGapX*2;node.viewHeight=viewSize.height+this.itemGapY*2}var imageSize=this.getImageSize(root),toggleSize=this.getToggleSize(root);if(parent!=null){var pImg=this.getImageBounds(parent);x=pImg.x+~~((pImg.width-toggleSize.width)/2)}node.x=x;node.y=y;node.width=toggleSize.width+imageSize.width+node.viewWidth+(toggleSize.width>0?this.gapx:0)+(imageSize.width>0?this.gapx:0);node.height=Math.max(((toggleSize.height>imageSize.height)?toggleSize.height:imageSize.height),node.viewHeight);if(node.x+node.width>this.maxw){this.maxw=node.x+node.width}this.maxh+=(node.height+this.gapy);x=node.x+toggleSize.width+(toggleSize.width>0?this.gapx:0);y+=(node.height+this.gapy)}var b=node.isOpen&&isVis;if(b){var count=root.kids.length;for(var i=0;i0&&this.getIM(i).isOpen&&this.isOpen_(i.parent))};this.getIM=function(i){var node=this.nodes[i];if(typeof node==="undefined"){node=new IM(this.isOpenVal);this.nodes[i]=node}return node};this.getItemAt=function(root,x,y){this.validate();if(arguments.length<3){root=this.model.root}if(this.firstVisible!=null&&y>=this.visibleArea.y&&y=node.x&&y>=node.y&&x0?(this.getIM(i).isOpen?this.views.open:this.views.close):this.views.leaf};this.getImageSize=function(i){var v=i.kids.length>0?(this.getIM(i).isOpen?this.viewSizes.open:this.viewSizes.close):this.viewSizes.leaf;return v?v:{width:0,height:0}};this.getImageBounds=function(root){var node=this.getIM(root),id=this.getImageSize(root),td=this.getToggleSize(root);return{x:node.x+td.width+(td.width>0?this.gapx:0),y:node.y+~~((node.height-id.height)/2),width:id.width,height:id.height}};this.getImageY=function(root){var node=this.getIM(root);return node.y+~~((node.height-this.getImageSize(root).height)/2)};this.getToggleY=function(root){var node=this.getIM(root);return node.y+~~((node.height-this.getToggleSize(root).height)/2)};this.getToggleSize=function(i){return this.isOpen_(i)?this.viewSizes.on:this.viewSizes.off};this.isAbove=function(i){var node=this.getIM(i);return node.y+node.height+this.scrollManager.getSY()0&&this.isOpen_(item)){return item.kids[0]}var parent=null;while((parent=item.parent)!=null){var index=parent.kids.indexOf(item);if(index+1=0)?this.findLast(parent.kids[index-1]):parent}}return null};this.findLast=function(item){return this.isOpen_(item)&&item.kids.length>0?this.findLast(item.kids[item.kids.length-1]):item};this.prevVisible=function(item){if(item==null||this.isAbove(item)){return this.nextVisible(item)}var parent=null;while((parent=item.parent)!=null){for(var i=parent.kids.indexOf(item)-1;i>=0;i--){var child=parent.kids[i];if(this.isAbove(child)){return this.nextVisible(child)}}item=parent}return item};this.isVerVisible=function(item){if(this.visibleArea==null){return false}var node=this.getIM(item),yy1=node.y+this.scrollManager.getSY(),yy2=yy1+node.height-1,by=this.visibleArea.y+this.visibleArea.height;return((this.visibleArea.y<=yy1&&yy1yy1&&yy2>=by))};this.nextVisible=function(item){if(item==null||this.isVerVisible(item)){return item}var res=this.nextVisibleInBranch(item),parent=null;if(res!=null){return res}while((parent=item.parent)!=null){var count=parent.kids.length;for(var i=parent.kids.indexOf(item)+1;i0){this.getImageView(root).paint(g,image.x,image.y,image.width,image.height,this)}var vx=image.x+image.width+(image.width>0||toggle.width>0?this.gapx:0),vy=node.y+~~((node.height-node.viewHeight)/2);if(this.selected==root&&root!=this.editedItem){var selectView=this.views[this.hasFocus()?"aselect":"iselect"];if(selectView!=null){selectView.paint(g,vx,vy,node.viewWidth,node.viewHeight,this)}}if(root!=this.editedItem){var vvv=this.provider.getView(this,root),vvvps=vvv.getPreferredSize();vvv.paint(g,vx+this.itemGapX,vy+this.itemGapY,vvvps.width,vvvps.height,this)}if(this.lnColor!=null){g.setColor(this.lnColor);var x1=toggle.x+(toggleView==null?~~(toggle.width/2)+1:toggle.width),yy=toggle.y+~~(toggle.height/2)+0.5;g.beginPath();g.moveTo(x1-1,yy);g.lineTo(image.x,yy);g.stroke()}}else{if(node.y+dy>this.visibleArea.y+this.visibleArea.height||node.x+dx>this.visibleArea.x+this.visibleArea.width){return false}}return this.paintChild(g,root,0)};this.y_=function(item,isStart){var ty=this.getToggleY(item),th=this.getToggleSize(item).height,dy=this.scrollManager.getSY(),y=(item.kids.length>0)?(isStart?ty+th:ty-1):ty+~~(th/2);if(y+dy<0){y=-dy-1}else{if(y+dy>this.height){y=this.height-dy}}return y};this.paintChild=function(g,root,index){var b=this.isOpen_(root),vs=this.viewSizes;if(root==this.firstVisible&&this.lnColor!=null){g.setColor(this.lnColor);var y1=this.getTop(),y2=this.y_(root,false),xx=this.getIM(root).x+~~((b?vs.on.width:vs.off.width)/2);g.beginPath();g.moveTo(xx+0.5,y1);g.lineTo(xx+0.5,y2);g.stroke()}if(b&&root.kids.length>0){var firstChild=root.kids[0];if(firstChild==null){return true}var x=this.getIM(firstChild).x+~~((this.isOpen_(firstChild)?vs.on.width:vs.off.width)/2);var count=root.kids.length;if(index0)?this.y_(root.kids[index-1],true):this.getImageY(root)+this.getImageSize(root).height;for(var i=index;i1&&e.isActionMask()&&this.getItemAt(this.firstVisible,e.x,e.y)==this.selected){this.toggle(this.selected)}}};this.mouseReleased=function(e){if(this.se(this.pressedItem,e)){this.pressedItem=null}};this.keyTyped=function(e){if(this.selected!=null){switch(e.ch){case"+":if(this.isOpen(this.selected)===false){this.toggle(this.selected)}break;case"-":if(this.isOpen(this.selected)){this.toggle(this.selected)}break}}};this.keyPressed=function(e){var newSelection=null;switch(e.code){case KE.DOWN:case KE.RIGHT:newSelection=this.findNext(this.selected);break;case KE.UP:case KE.LEFT:newSelection=this.findPrev(this.selected);break;case KE.HOME:if(e.isControlPressed()){this.select(this.model.root)}break;case KE.END:if(e.isControlPressed()){this.select(this.findLast(this.model.root))}break;case KE.PAGEDOWN:if(this.selected!=null){this.select(this.nextPage(this.selected,1))}break;case KE.PAGEUP:if(this.selected!=null){this.select(this.nextPage(this.selected,-1))}break}if(newSelection!=null){this.select(newSelection)}this.se(this.selected,e)};this.mousePressed=function(e){this.pressedItem=null;this.stopEditing(true);if(this.firstVisible!=null&&e.isActionMask()){var x=e.x,y=e.y,root=this.getItemAt(this.firstVisible,x,y);if(root!=null){x-=this.scrollManager.getSX();y-=this.scrollManager.getSY();var r=this.getToggleBounds(root);if(x>=r.x&&x=r.y&&y0){this.toggle(root)}}else{if(x>r.x+r.width){this.select(root)}if(this.se(root,e)===false){this.pressedItem=root}}}}};this.toggleAll=function(root,b){var model=this.model;if(root.kids.length>0){if(this.getItemMetrics(root).isOpen!=b){this.toggle(root)}for(var i=0;i0){this.stopEditing(true);this.validate();var node=this.getIM(item);node.isOpen=(node.isOpen?false:true);this.invalidate();this._.toggled(this,item);if(!node.isOpen&&this.selected!=null){var parent=this.selected;do{parent=parent.parent}while(parent!=item&&parent!=null);if(parent==item){this.select(item)}}this.repaint()}};this.itemInserted=function(target,item){this.stopEditing(false);this.vrp()};this.itemRemoved=function(target,item){if(item==this.firstVisible){this.firstVisible=null}this.stopEditing(false);if(item==this.selected){this.select(null)}delete this.nodes[item];this.vrp()};this.itemModified=function(target,item){var node=this.getIM(item);if(node!=null){node.viewWidth=-1}this.vrp()};this.startEditing=function(item){this.stopEditing(true);if(this.editors!=null){var editor=this.editors.getEditor(this,item);if(editor!=null){this.editedItem=item;var b=this.getViewBounds(this.editedItem),ps=editor.getPreferredSize();editor.setLocation(b.x+this.scrollManager.getSX(),b.y-~~((ps.height-b.height)/2)+this.scrollManager.getSY());editor.setSize(ps.width,ps.height);this.add(editor);ui.focusManager.requestFocus(editor)}}};this.stopEditing=function(applyData){if(this.editors!=null&&this.editedItem!=null){try{if(applyData){this.model.setValue(this.editedItem,this.editors.fetchEditedValue(this.editedItem,this.kids[0]))}}finally{this.editedItem=null;this.removeAt(0);this.requestFocus()}}};this.calcPreferredSize=function(target){return this.model==null?{width:0,height:0}:{width:this.maxw,height:this.maxh}}},function(){this.$this(null)},function(d){this.$this(d,true)},function(d,b){this.provider=this.selected=this.firstVisible=this.editedItem=this.pressedItem=null;this.maxw=this.maxh=0;this.visibleArea=this.lnColor=this.editors=null;this.views={};this.viewSizes={};this._isVal=false;this.nodes={};this._=new TreeListeners();this.setLineColor("gray");this.isOpenVal=b;this.setModel(d);this.setViewProvider(new pkg.DefViews());this.setSelectable(true);this.$super();this.scrollManager=new ui.ScrollManager(this)},function focused(){this.$super();if(this.selected!=null){var m=this.getItemMetrics(this.selected);this.repaint(m.x+this.scrollManager.getSX(),m.y+this.scrollManager.getSY(),m.width,m.height)}},function setEditorProvider(p){if(p!=this.editors){this.stopEditing(false);this.editors=p}},function setSelectable(b){if(this.isSelectable!=b){if(b===false&&this.selected!=null){this.select(null)}this.isSelectable=b;this.repaint()}},function setLineColor(c){this.lnColor=c;this.repaint()},function setGaps(gx,gy){if(gx!=this.gapx||gy!=this.gapy){this.gapx=gx;this.gapy=gy;this.vrp()}},function setViewProvider(p){if(p==null){p=this}if(this.provider!=p){this.stopEditing(false);this.provider=p;delete this.nodes;this.nodes={};this.vrp()}},function setViews(v){for(var k in v){if(v.hasOwnProperty(k)){var vv=ui.$view(v[k]);this.views[k]=vv;if(k!="aselect"&&k!="iselect"){this.stopEditing(false);this.viewSizes[k]=vv?vv.getPreferredSize():null;this.vrp()}}}},function setModel(d){if(this.model!=d){if(zebra.instanceOf(d,zebra.data.TreeModel)===false){d=new zebra.data.TreeModel(d)}this.stopEditing(false);this.select(null);if(this.model!=null&&this.model._){this.model._.remove(this)}this.model=d;if(this.model!=null&&this.model._){this.model._.add(this)}this.firstVisible=null;delete this.nodes;this.nodes={};this.vrp()}},function invalidate(){if(this.isValid){this._isVal=false;this.$super()}}]);pkg.TreeSignView=Class(ui.View,[function $prototype(){this[""]=function(plus,color,bg){this.color=color==null?"white":color;this.bg=bg==null?"lightGray":bg;this.plus=plus==null?false:plus;this.br=new ui.Border("rgb(65, 131, 215)",1,3);this.width=this.height=12};this.paint=function(g,x,y,w,h,d){this.br.outline(g,x,y,w,h,d);g.setColor(this.bg);g.fill();this.br.paint(g,x,y,w,h,d);g.setColor(this.color);g.lineWidth=2;x+=2;w-=4;h-=4;y+=2;g.beginPath();g.moveTo(x,y+h/2);g.lineTo(x+w,y+h/2);if(this.plus){g.moveTo(x+w/2,y);g.lineTo(x+w/2,y+h)}g.stroke();g.lineWidth=1};this.getPreferredSize=function(){return{width:this.width,height:this.height}}}])})(zebra("ui.tree"),zebra.Class,zebra.ui);(function(pkg,Class,ui){var Matrix=zebra.data.Matrix,L=zebra.layout,WinLayer=ui.WinLayer,MB=zebra.util,Cursor=ui.Cursor,Position=zebra.util.Position,KE=ui.KeyEvent,Listeners=zebra.util.Listeners;function arr(l,v){var a=Array(l);for(var i=0;i=0&&this.isResizable&&this.metrics.isUsePsMetric===false?((this.orient==L.HORIZONTAL)?Cursor.W_RESIZE:Cursor.S_RESIZE):null};this.mouseDragged=function(e){if(this.pxy!=null){var b=(this.orient==L.HORIZONTAL),rc=this.selectedColRow,ns=(b?this.metrics.getColWidth(rc)+e.x:this.metrics.getRowHeight(rc)+e.y)-this.pxy;this.captionResized(rc,ns);if(ns>this.minSize){this.pxy=b?e.x:e.y}}};this.mouseDragStarted=function(e){if(this.metrics!=null&&this.isResizable&&this.metrics.isUsePsMetric===false){this.calcRowColAt(e.x,e.y);if(this.selectedColRow>=0){this.pxy=(this.orient==L.HORIZONTAL)?e.x:e.y}}};this.mouseDragEnded=function(e){if(this.pxy!=null){this.pxy=null}if(this.metrics!=null){this.calcRowColAt(e.x,e.y)}};this.mouseMoved=function(e){if(this.metrics!=null){this.calcRowColAt(e.x,e.y)}};this.mouseClicked=function(e){if(this.pxy==null&&this.metrics!=null&&e.clicks>1&&this.selectedColRow>=0&&this.isAutoFit){var size=this.getCaptionPS(this.selectedColRow);if(this.orient==L.HORIZONTAL){this.metrics.setColWidth(this.selectedColRow,size)}else{this.metrics.setRowHeight(this.selectedColRow,size)}this.captionResized(this.selectedColRow,size)}};this.getCaptionPS=function(rowcol){return(this.orient==L.HORIZONTAL)?this.metrics.getColPSWidth(this.selectedColRow):this.metrics.getRowPSHeight(this.selectedColRow)};this.captionResized=function(rowcol,ns){if(ns>this.minSize){if(this.orient==L.HORIZONTAL){var pw=this.metrics.getColWidth(rowcol);this.metrics.setColWidth(rowcol,ns);this._.captionResized(this,rowcol,pw)}else{var ph=this.metrics.getRowHeight(rowcol);this.metrics.setRowHeight(rowcol,ns);this._.captionResized(this,rowcol,ph)}}};this.calcRowColAt=function(x,y){var isHor=(this.orient==L.HORIZONTAL),cv=this.metrics.getCellsVisibility();if((isHor&&cv.fc!=null)||(isHor===false&&cv.fr!=null)){var m=this.metrics,xy=isHor?x:y,xxyy=isHor?cv.fc[1]-this.x+m.getXOrigin()-m.lineSize:cv.fr[1]-this.y+m.getYOrigin()-m.lineSize;for(var i=(isHor?cv.fc[0]:cv.fr[0]);i<=(isHor?cv.lc[0]:cv.lr[0]);i++){var wh=isHor?m.getColWidth(i):m.getRowHeight(i);xxyy+=(wh+m.lineSize);if(xyxxyy-this.activeAreaSize){this.selectedColRow=i;return}}}this.selectedColRow=-1};this.getCaptionAt=function(x,y){if(this.metrics!=null&&x>=0&&y>=0&&xxxyy&&xythis.psH){this.psH=ps.height}this.psW+=ps.width}else{if(ps.width>this.psW){this.psW=ps.width}this.psH+=ps.height}}}if(this.psH===0){this.psH=pkg.Grid.DEF_ROWHEIGHT}if(this.psW===0){this.psW=pkg.Grid.DEF_COLWIDTH}if(this.borderView!=null){this.psW+=(this.borderView.getLeft()+this.borderView.getRight())*(isHor?size:1);this.psH+=(this.borderView.getTop()+this.borderView.getBottom())*(isHor?1:size)}}};this.paint=function(g){if(this.metrics!=null){var cv=this.metrics.getCellsVisibility();if(cv.hasVisibleCells()===false){return}var m=this.metrics,isHor=(this.orient==L.HORIZONTAL),gap=m.lineSize,top=0,left=0,bottom=0,right=0;if(this.borderView!=null){top+=this.borderView.getTop();left+=this.borderView.getLeft();bottom+=this.borderView.getBottom();right+=this.borderView.getRight()}var x=isHor?cv.fc[1]-this.x+m.getXOrigin()-gap:this.getLeft(),y=isHor?this.getTop():cv.fr[1]-this.y+m.getYOrigin()-gap,size=isHor?m.getGridCols():m.getGridRows();for(var i=(isHor?cv.fc[0]:cv.fr[0]);i<=(isHor?cv.lc[0]:cv.lr[0]);i++){var wh1=isHor?m.getColWidth(i)+gap+(((size-1)==i)?gap:0):this.psW,wh2=isHor?this.psH:m.getRowHeight(i)+gap+(((size-1)==i)?gap:0),v=this.getTitleView(i);if(this.borderView!=null){this.borderView.paint(g,x,y,wh1,wh2,this)}if(v!=null){var props=this.getTitleProps(i),ps=v.getPreferredSize();if(props!=null&&props[2]!=0){g.setColor(props[2]);g.fillRect(x,y,wh1-1,wh2-1)}g.save();if(this.borderView&&this.borderView.outline&&this.borderView.outline(g,x,y,wh1,wh2,this)){g.clip()}else{g.clipRect(x,y,wh1,wh2)}var vx=x+L.xAlignment(ps.width,props!=null?props[0]:L.CENTER,wh1-left-right)+left,vy=y+L.yAlignment(ps.height,props!=null?props[1]:L.CENTER,wh2-top-bottom)+top;v.paint(g,vx,vy,ps.width,ps.height,this);g.restore()}if(isHor){x+=wh1}else{y+=wh2}}}};this.getTitle=function(rowcol){return this.titles==null||this.titles.length/2<=rowcol?null:this.titles[rowcol*2]}},function(){this.$this(null)},function(titles){this.psW=this.psH=0;this.render=new ui.TextRender("");this.render.setFont(pkg.GridCaption.font);this.render.setColor(pkg.GridCaption.fontColor);this.$super(titles)},function setBorderView(v){if(v!=this.borderView){this.borderView=ui.$view(v);this.vrp()}},function putTitle(rowcol,title){var old=this.getTitle(rowcol);if(old!=title){if(this.titles==null){this.titles=arr((rowcol+1)*2,null)}else{if(Math.floor(this.titles.length/2)<=rowcol){var nt=arr((rowcol+1)*2,null);zebra.util.arraycopy(this.titles,0,nt,0,this.titles.length);this.titles=nt}}var index=rowcol*2;this.titles[index]=title;if(title==null&&index+2==this.titles.length){var nt=arr(this.titles.length-2,null);zebra.util.arraycopy(this.titles,0,nt,0,index);this.titles=nt}this.vrp()}},function setTitleProps(rowcol,ax,ay,bg){var p=this.getTitleProps(rowcol);if(p==null){p=[]}p[0]=ax;p[1]=ay;p[2]=bg==null?0:bg.getRGB();this.titles[rowcol*2+1]=p;this.repaint()},function getCaptionPS(rowcol){var size=this.$super(rowcol),v=this.getTitleView(this.selectedColRow),bv=this.borderView;if(bv!=null){size=size+((this.orient==L.HORIZONTAL)?bv.getLeft()+bv.getRight():bv.getTop()+bv.getBottom())}if(v!=null){size=Math.max(size,(this.orient==L.HORIZONTAL)?v.getPreferredSize().width:v.getPreferredSize().height)}return size}]);pkg.CompGridCaption=Class(pkg.BaseCaption,ui.Composite,[function $clazz(){this.Layout=Class(L.Layout,[function $prototype(){this.doLayout=function(target){var ps=L.getMaxPreferredSize(target),m=target.metrics,b=target.orient==L.HORIZONTAL,top=target.getTop(),left=target.getLeft(),xy=b?left+m.getXOrigin():top+m.getYOrigin();for(var i=0;iv.fc[0])?1:-1}for(var i=start;i!=col;x+=((this.colWidths[i]+this.lineSize)*d),i+=d){}return x};this.getRowY_=function(row){var start=0,d=1,y=this.getTop()+this.getTopCaptionHeight()+this.lineSize,v=this.visibility;if(v.hasVisibleCells()){start=v.fr[0];y=v.fr[1];d=(row>v.fr[0])?1:-1}for(var i=start;i!=row;y+=((this.rowHeights[i]+this.lineSize)*d),i+=d){}return y};this.rPs=function(){var cols=this.getGridCols(),rows=this.getGridRows();this.psWidth_=this.lineSize*(cols+1);this.psHeight_=this.lineSize*(rows+1);for(var i=0;i=0;col+=d){if(x+dxxx2){if(b){return[col,x]}}else{if(b===false){return this.colVisibility(col,x,(d>0?-1:1),true)}}if(d<0){if(col>0){x-=(this.colWidths[col-1]+this.lineSize)}}else{if(col0)?[col-1,x]:[0,left+this.getLeftCaptionWidth()+this.lineSize])};this.rowVisibility=function(row,y,d,b){var rows=this.getGridRows();if(rows===0){return null}var top=this.getTop(),dy=this.scrollManager.getSY(),yy1=Math.min(this.visibleArea.y+this.visibleArea.height,this.height-this.getBottom()),yy2=Math.max(this.visibleArea.y,top+this.getTopCaptionHeight());for(;row=0;row+=d){if(y+dyyy2){if(b){return[row,y]}}else{if(b===false){return this.rowVisibility(row,y,(d>0?-1:1),true)}}if(d<0){if(row>0){y-=(this.rowHeights[row-1]+this.lineSize)}}else{if(row0)?[row-1,y]:[0,top+this.getTopCaptionHeight()+this.lineSize])};this.vVisibility=function(){var va=ui.$cvp(this,{});if(va==null){this.visibleArea=null;this.visibility.cancelVisibleCells();return}else{if(this.visibleArea==null||va.x!=this.visibleArea.x||va.y!=this.visibleArea.y||va.width!=this.visibleArea.width||va.height!=this.visibleArea.height){this.iColVisibility(0);this.iRowVisibility(0);this.visibleArea=va}}var v=this.visibility,b=v.hasVisibleCells();if(this.colOffset!=100){if(this.colOffset>0&&b){v.lc=this.colVisibility(v.lc[0],v.lc[1],-1,true);v.fc=this.colVisibility(v.lc[0],v.lc[1],-1,false)}else{if(this.colOffset<0&&b){v.fc=this.colVisibility(v.fc[0],v.fc[1],1,true);v.lc=this.colVisibility(v.fc[0],v.fc[1],1,false)}else{v.fc=this.colVisibility(0,this.getLeft()+this.lineSize+this.getLeftCaptionWidth(),1,true);v.lc=(v.fc!=null)?this.colVisibility(v.fc[0],v.fc[1],1,false):null}}this.colOffset=100}if(this.rowOffset!=100){if(this.rowOffset>0&&b){v.lr=this.rowVisibility(v.lr[0],v.lr[1],-1,true);v.fr=this.rowVisibility(v.lr[0],v.lr[1],-1,false)}else{if(this.rowOffset<0&&b){v.fr=this.rowVisibility(v.fr[0],v.fr[1],1,true);v.lr=(v.fr!=null)?this.rowVisibility(v.fr[0],v.fr[1],1,false):null}else{v.fr=this.rowVisibility(0,this.getTop()+this.getTopCaptionHeight()+this.lineSize,1,true);v.lr=(v.fr!=null)?this.rowVisibility(v.fr[0],v.fr[1],1,false):null}}this.rowOffset=100}};this.calcOrigin=function(off,y){var top=this.getTop()+this.getTopCaptionHeight(),left=this.getLeft()+this.getLeftCaptionWidth(),o=ui.calcOrigin(this.getColX(0)-this.lineSize,y-this.lineSize,this.psWidth_,this.rowHeights[off]+2*this.lineSize,this.scrollManager.getSX(),this.scrollManager.getSY(),this,top,left,this.getBottom(),this.getRight());this.scrollManager.scrollTo(o[0],o[1])};this.$se=function(row,col,e){if(row>=0){this.stopEditing(true);if(this.editors!=null&&this.editors.shouldDo(pkg.START_EDITING,row,col,e)){return this.startEditing(row,col)}}return false};this.getXOrigin=function(){return this.scrollManager.getSX()};this.getYOrigin=function(){return this.scrollManager.getSY()};this.getColPSWidth=function(col){return this.getPSSize(col,false)};this.getRowPSHeight=function(row){return this.getPSSize(row,true)};this.recalc=function(){if(this.isUsePsMetric){this.rPsMetric()}else{this.rCustomMetric()}this.rPs()};this.getGridRows=function(){return this.model!=null?this.model.rows:0};this.getGridCols=function(){return this.model!=null?this.model.cols:0};this.getRowHeight=function(row){this.validateMetric();return this.rowHeights[row]};this.getColWidth=function(col){this.validateMetric();return this.colWidths[col]};this.getCellsVisibility=function(){this.validateMetric();return this.visibility};this.getColX=function(col){this.validateMetric();return this.getColX_(col)};this.getRowY=function(row){this.validateMetric();return this.getRowY_(row)};this.childInputEvent=function(e){if(this.editingRow>=0){if(this.editors.shouldDo(pkg.CANCEL_EDITING,this.editingRow,this.editingCol,e)){this.stopEditing(false)}else{if(this.editors.shouldDo(pkg.FINISH_EDITING,this.editingRow,this.editingCol,e)){this.stopEditing(true)}}}};this.dataToPaint=function(row,col){return this.model.get(row,col)};this.iColVisibility=function(off){this.colOffset=(this.colOffset==100)?this.colOffset=off:((off!=this.colOffset)?0:this.colOffset)};this.iRowVisibility=function(off){this.rowOffset=(this.rowOffset==100)?off:(((off+this.rowOffset)===0)?0:this.rowOffset)};this.getTopCaptionHeight=function(){return(this.topCaption!=null&&this.topCaption.isVisible)?this.topCaption.height:0};this.getLeftCaptionWidth=function(){return(this.leftCaption!=null&&this.leftCaption.isVisible)?this.leftCaption.width:0};this.paint=function(g){this.vVisibility();if(this.visibility.hasVisibleCells()){var dx=this.scrollManager.getSX(),dy=this.scrollManager.getSY(),th=this.getTopCaptionHeight(),tw=this.getLeftCaptionWidth();try{g.save();g.translate(dx,dy);if(th>0||tw>0){g.clipRect(tw-dx,th-dy,this.width-tw,this.height-th)}this.paintSelection(g);this.paintData(g);if(this.drawHorLines||this.drawVerLines){this.paintNet(g)}this.paintMarker(g)}finally{g.restore()}}};this.catchScrolled=function(psx,psy){var offx=this.scrollManager.getSX()-psx,offy=this.scrollManager.getSY()-psy;if(offx!==0){this.iColVisibility(offx>0?1:-1)}if(offy!==0){this.iRowVisibility(offy>0?1:-1)}this.stopEditing(false);this.repaint()};this.isInvalidatedByChild=function(c){return c!=this.editor||this.isUsePsMetric};this.stopEditing=function(applyData){if(this.editors!=null&&this.editingRow>=0&&this.editingCol>=0){try{if(zebra.instanceOf(this.editor,pkg.Grid)){this.editor.stopEditing(applyData)}var data=this.getDataToEdit(this.editingRow,this.editingCol);if(applyData){this.setEditedData(this.editingRow,this.editingCol,this.editors.fetchEditedValue(this.editingRow,this.editingCol,data,this.editor))}else{this.editors.editingCanceled(this.editingRow,this.editingCol,data,this.editor)}this.repaintRows(this.editingRow,this.editingRow)}finally{this.editingCol=this.editingRow=-1;if(this.indexOf(this.editor)>=0){this.remove(this.editor)}this.editor=null;this.requestFocus()}}};this.setDrawLines=function(hor,ver){if(this.drawVerLines!=hor||this.drawHorLines!=ver){this.drawHorLines=hor;this.drawVerLines=ver;this.repaint()}};this.getLines=function(){return this.getGridRows()};this.getLineSize=function(line){return 1};this.getMaxOffset=function(){return this.getGridRows()-1};this.posChanged=function(target,prevOffset,prevLine,prevCol){var off=this.position.currentLine;if(off>=0){this.calcOrigin(off,this.getRowY(off));this.select(off,true);this.repaintRows(prevOffset,off)}};this.makeRowVisible=function(row){this.calcOrigin(row,this.getRowY(row));this.repaint()};this.keyPressed=function(e){if(this.position!=null){var cl=this.position.currentLine;switch(e.code){case KE.LEFT:this.position.seek(-1);break;case KE.UP:this.position.seekLineTo(Position.UP);break;case KE.RIGHT:this.position.seek(1);break;case KE.DOWN:this.position.seekLineTo(Position.DOWN);break;case KE.PAGEUP:this.position.seekLineTo(Position.UP,this.pageSize(-1));break;case KE.PAGEDOWN:this.position.seekLineTo(Position.DOWN,this.pageSize(1));break;case KE.END:if(e.isControlPressed()){this.position.setOffset(this.getLines()-1)}break;case KE.HOME:if(e.isControlPressed()){this.position.setOffset(0)}break}this.$se(this.position.currentLine,this.position.currentCol,e);if(cl!=this.position.currentLine&&cl>=0){for(var i=0;i0};this.repaintRows=function(r1,r2){if(r1<0){r1=r2}if(r2<0){r2=r1}if(r1>r2){var i=r2;r2=r1;r1=i}var rows=this.getGridRows();if(r1=rows){r2=rows-1}var y1=this.getRowY(r1),y2=((r1==r2)?y1:this.getRowY(r2))+this.rowHeights[r2];this.repaint(0,y1+this.scrollManager.getSY(),this.width,y2-y1)}};this.cellByLocation=function(x,y){this.validate();var dx=this.scrollManager.getSX(),dy=this.scrollManager.getSY(),v=this.visibility,ry1=v.fr[1]+dy,rx1=v.fc[1]+dx,row=-1,col=-1,ry2=v.lr[1]+this.rowHeights[v.lr[0]]+dy,rx2=v.lc[1]+this.colWidths[v.lc[0]]+dx;if(y>ry1&&yry1&&yrx1&&xrx1&&x=0&&row>=0)?[row,col]:null};this.doLayout=function(target){var topHeight=(this.topCaption!=null&&this.topCaption.isVisible)?this.topCaption.getPreferredSize().height:0,leftWidth=(this.leftCaption!=null&&this.leftCaption.isVisible)?this.leftCaption.getPreferredSize().width:0;if(this.topCaption!=null){this.topCaption.setLocation(this.getLeft()+leftWidth,this.getTop());this.topCaption.setSize(Math.min(target.width-this.getLeft()-this.getRight()-leftWidth,this.psWidth_),topHeight)}if(this.leftCaption!=null){this.leftCaption.setLocation(this.getLeft(),this.getTop()+topHeight);this.leftCaption.setSize(leftWidth,Math.min(target.height-this.getTop()-this.getBottom()-topHeight,this.psHeight_))}if(this.stub!=null&&this.stub.isVisible){if(this.topCaption!=null&&this.topCaption.isVisible&&this.leftCaption!=null&&this.leftCaption.isVisible){this.stub.setLocation(this.getLeft(),this.getTop());this.stub.setSize(this.topCaption.x-this.stub.x,this.leftCaption.y-this.stub.y)}else{this.stub.setSize(0,0)}}if(this.editors!=null&&this.editor!=null&&this.editor.parent==this&&this.editor.isVisible){var w=this.colWidths[this.editingCol],h=this.rowHeights[this.editingRow],x=this.getColX_(this.editingCol),y=this.getRowY_(this.editingRow);if(this.isUsePsMetric){x+=this.cellInsetsLeft;y+=this.cellInsetsTop;w-=(this.cellInsetsLeft+this.cellInsetsRight);h-=(this.cellInsetsTop+this.cellInsetsBottom)}this.editor.setLocation(x+this.scrollManager.getSX(),y+this.scrollManager.getSY());this.editor.setSize(w,h)}};this.canHaveFocus=function(){return this.editor==null};this.clearSelect=function(){if(this.selectedIndex>=0){var prev=this.selectedIndex;this.selectedIndex=-1;this._.fired(this,-1,0,false);this.repaintRows(-1,prev)}};this.select=function(row,b){if(b==null){b=true}if(this.isSelected(row)!=b){if(this.selectedIndex>=0){this.clearSelect()}if(b){this.selectedIndex=row;this._.fired(this,row,1,b)}}};this.laidout=function(){this.vVisibility()};this.mouseClicked=function(e){this.pressedRow=-1;if(this.visibility.hasVisibleCells()){this.stopEditing(true);if(e.isActionMask()){var p=this.cellByLocation(e.x,e.y);if(p!=null){if(this.position!=null){var off=this.position.currentLine;if(off==p[0]){this.calcOrigin(off,this.getRowY(off))}else{this.clearSelect();this.position.setOffset(p[0])}}if(this.$se(p[0],p[1],e)===false){this.pressedRow=p[0];this.pressedCol=p[1]}}}}};this.calcPreferredSize=function(target){return{width:this.psWidth_+((this.leftCaption!=null&&this.leftCaption.isVisible)?this.leftCaption.getPreferredSize().width:0),height:this.psHeight_+((this.topCaption!=null&&this.topCaption.isVisible)?this.topCaption.getPreferredSize().height:0)}};this.paintNet=function(g){var v=this.visibility,topX=v.fc[1]-this.lineSize,topY=v.fr[1]-this.lineSize,botX=v.lc[1]+this.colWidths[v.lc[0]],botY=v.lr[1]+this.rowHeights[v.lr[0]],prevWidth=g.lineWidth;g.setColor(this.lineColor);g.lineWidth=this.lineSize;g.beginPath();if(this.drawHorLines){var y=topY+this.lineSize/2;for(var i=v.fr[0];i<=v.lr[0];i++){g.moveTo(topX,y);g.lineTo(botX,y);y+=this.rowHeights[i]+this.lineSize}g.moveTo(topX,y);g.lineTo(botX,y)}if(this.drawVerLines){topX+=this.lineSize/2;for(var i=v.fc[0];i<=v.lc[0];i++){g.moveTo(topX,topY);g.lineTo(topX,botY);topX+=this.colWidths[i]+this.lineSize}g.moveTo(topX,topY);g.lineTo(topX,botY)}g.stroke();g.lineWidth=prevWidth};this.paintData=function(g){var y=this.visibility.fr[1]+this.cellInsetsTop,addW=this.cellInsetsLeft+this.cellInsetsRight,addH=this.cellInsetsTop+this.cellInsetsBottom,ts=g.getTopStack(),cx=ts.x,cy=ts.y,cw=ts.width,ch=ts.height,res={};for(var i=this.visibility.fr[0];i<=this.visibility.lr[0]&&ycy){var x=this.visibility.fc[1]+this.cellInsetsLeft,notSelectedRow=this.isSelected(i)===false;for(var j=this.visibility.fc[0];j<=this.visibility.lc[0];j++){if(notSelectedRow){var bg=this.provider.getCellColor?this.provider.getCellColor(this,i,j):this.defCellColor;if(bg!=null){g.setColor(bg);g.fillRect(x-this.cellInsetsLeft,y-this.cellInsetsTop,this.colWidths[j],this.rowHeights[i])}}var v=(i==this.editingRow&&j==this.editingCol)?null:this.provider.getView(this,i,j,this.model.get(i,j));if(v!=null){var w=this.colWidths[j]-addW,h=this.rowHeights[i]-addH;res.x=x>cx?x:cx;res.width=Math.min(x+w,cx+cw)-res.x;res.y=y>cy?y:cy;res.height=Math.min(y+h,cy+ch)-res.y;if(res.width>0&&res.height>0){if(this.isUsePsMetric){v.paint(g,x,y,w,h,this)}else{var ax=this.provider.getXAlignment?this.provider.getXAlignment(this,i,j):this.defXAlignment,ay=this.provider.getYAlignment?this.provider.getYAlignment(this,i,j):this.defYAlignment,vw=w,vh=h,xx=x,yy=y,id=-1,ps=(ax!=L.NONE||ay!=L.NONE)?v.getPreferredSize():null;if(ax!=L.NONE){xx=x+((ax==L.CENTER)?~~((w-ps.width)/2):((ax==L.RIGHT)?w-ps.width:0));vw=ps.width}if(ay!=L.NONE){yy=y+((ay==L.CENTER)?~~((h-ps.height)/2):((ay==L.BOTTOM)?h-ps.height:0));vh=ps.height}if(xx(x+w)||(yy+vh)>(y+h)){id=g.save();g.clipRect(res.x,res.y,res.width,res.height)}v.paint(g,xx,yy,vw,vh,this);if(id>=0){g.restore()}}}}x+=(this.colWidths[j]+this.lineSize)}}y+=(this.rowHeights[i]+this.lineSize)}};this.paintMarker=function(g){var markerView=this.views.marker;if(markerView!=null&&this.position!=null&&this.position.offset>=0&&this.hasFocus()){var offset=this.position.offset,v=this.visibility;if(offset>=v.fr[0]&&offset<=v.lr[0]){g.clipRect(this.getLeftCaptionWidth()-this.scrollManager.getSX(),this.getTopCaptionHeight()-this.scrollManager.getSY(),this.width,this.height);markerView.paint(g,v.fc[1],this.getRowY(offset),v.lc[1]-v.fc[1]+this.getColWidth(v.lc[0]),this.rowHeights[offset],this)}}};this.paintSelection=function(g){if(this.editingRow>=0){return}var v=this.views[this.hasFocus()?"onselection":"offselection"];if(v==null){return}for(var j=this.visibility.fr[0];j<=this.visibility.lr[0];j++){if(this.isSelected(j)){var x=this.visibility.fc[1],y=this.getRowY(j),h=this.rowHeights[j];for(var i=this.visibility.fc[0];i<=this.visibility.lc[0];i++){v.paint(g,x,y,this.colWidths[i],h,this);x+=this.colWidths[i]+this.lineSize}}}};this.rPsMetric=function(){var cols=this.getGridCols(),rows=this.getGridRows();if(this.colWidths==null||this.colWidths.length!=cols){this.colWidths=arr(cols,0)}if(this.rowHeights==null||this.rowHeights.length!=rows){this.rowHeights=arr(rows,0)}var addW=this.cellInsetsLeft+this.cellInsetsRight,addH=this.cellInsetsTop+this.cellInsetsBottom;for(var i=0;ithis.colWidths[i]){this.colWidths[i]=ps.width}if(ps.height>this.rowHeights[j]){this.rowHeights[j]=ps.height}}else{if(pkg.Grid.DEF_COLWIDTH>this.colWidths[i]){this.colWidths[i]=pkg.Grid.DEF_COLWIDTH}if(pkg.Grid.DEF_ROWHEIGHT>this.rowHeights[j]){this.rowHeights[j]=pkg.Grid.DEF_ROWHEIGHT}}}}};this.getPSSize=function(rowcol,b){if(this.isUsePsMetric){return b?this.getRowHeight(rowcol):this.getColWidth(rowcol)}else{var max=0,count=b?this.getGridCols():this.getGridRows();for(var j=0;jmax){max=ps.height}}else{if(ps.width>max){max=ps.width}}}}return max+this.lineSize*2+(b?this.cellInsetsTop+this.cellInsetsBottom:this.cellInsetsLeft+this.cellInsetsRight)}};this.rCustomMetric=function(){var start=0;if(this.colWidths!=null){start=this.colWidths.length;if(this.colWidths.length!=this.getGridCols()){var na=arr(this.getGridCols(),0);zebra.util.arraycopy(this.colWidths,0,na,0,Math.min(this.colWidths.length,na.length));this.colWidths=na}}else{this.colWidths=arr(this.getGridCols(),0)}for(;start=0){var hh=this.visibleArea.height-this.getTopCaptionHeight(),sum=0,poff=off;for(;off>=0&&off=0&&this.editingCol>=0)?[this.editingRow,this.editingCol]:null},function winOpened(winLayer,target,b){if(this.editor==target&&b===false){this.stopEditing(this.editor.isAccepted())}},function getDataToEdit(row,col){return this.model.get(row,col)},function setEditedData(row,col,value){this.model.put(row,col,value)}]);pkg.Grid.prototype.setViews=ui.$ViewsSetter;pkg.GridStretchPan=Class(ui.Panel,L.Layout,[function $prototype(){this.calcPreferredSize=function(target){this.recalcPS();return(target.kids.length===0||!target.grid.isVisible)?{width:0,height:0}:{width:this.strPs.width,height:this.strPs.height}};this.doLayout=function(target){this.recalcPS();if(target.kids.length>0){var grid=this.grid;if(grid.isVisible){var left=target.getLeft(),top=target.getTop();grid.setLocation(left,top);grid.setSize(target.width-left-target.getRight(),target.height-top-target.getBottom());for(var i=0;i0&&p.vBar&&p.autoHide===false&&taHeight>>0;if(len===0){return -1}var n=0;if(arguments.length>0){n=Number(arguments[1]);if(n!=n){n=0}else{if(n!==0&&n!=Infinity&&n!=-Infinity){n=(n>0||-1)*~~Math.abs(n)}}}if(n>=len){return -1}var k=n>=0?n:Math.max(len-Math.abs(n),0);for(;k0)?new zebra.URL(ss.substring(0,i+1)):new zebra.URL(document.location.toString()).getParentURL()}}if(namespaces.hasOwnProperty(nsname)){throw new Error("Name space '"+nsname+"' already exists")}var f=function(name){if(arguments.length===0){return f.$env}if(typeof name==="function"){for(var k in f){if(f[k] instanceof Package){name(k,f[k])}}return null}var b=Array.isArray(name);if(isString(name)===false&&b===false){for(var k in name){if(name.hasOwnProperty(k)){f.$env[k]=name[k]}}return}if(b){for(var i=0;i=0){for(var k in p){if(k[0]!="$"&&k[0]!="_"&&(p[k] instanceof Package)===false&&p.hasOwnProperty(k)){code.push([k,ns,n,".",k].join(""))}}if(packages!=null){packages.splice(packages.indexOf(n),1)}}});if(packages!=null&&packages.length!==0){throw new Error("Unknown package(s): "+packages.join(","))}return code.length>0?["var ",code.join(","),";"].join(""):null};f.$env={};namespaces[nsname]=f;return f};zebra=namespace("zebra");var pkg=zebra,FN=pkg.$FN=(typeof namespace.name==="undefined")?(function(f){var mt=f.toString().match(/^function\s+([^\s(]+)/);return(mt==null)?"":mt[1]}):(function(f){return f.name});pkg.namespaces=namespaces;pkg.namespace=namespace;pkg.$global=this;pkg.isString=isString;pkg.isNumber=isNumber;pkg.isBoolean=isBoolean;pkg.version="1.2.0";pkg.$caller=null;function mnf(name,params){var cln=this.$clazz&&this.$clazz.$name?this.$clazz.$name+".":"";throw new ReferenceError("Method '"+cln+(name===""?"constructor":name)+"("+params+")' not found")}function $toString(){return this._hash_}function $equals(o){return this==o}function make_template(pt,tf,p){tf._hash_=["$zebra_",$$$++].join("");tf.toString=$toString;if(pt!=null){tf.prototype.$clazz=tf}tf.$clazz=pt;tf.prototype.toString=$toString;tf.prototype.equals=$equals;tf.prototype.constructor=tf;if(p&&p.length>0){tf.$parents={};for(var i=0;i0){return new (pkg.Class($Interface,arguments[0]))()}},arguments);return $Interface});pkg.$Extended=pkg.Interface();function ProxyMethod(name,f){if(isString(name)===false){throw new TypeError("Method name has not been defined")}var a=null;if(arguments.length==1){a=function(){var nm=a.methods[arguments.length];if(nm){var cm=pkg.$caller;pkg.$caller=nm;try{return nm.apply(this,arguments)}catch(e){throw e}finally{pkg.$caller=cm}}mnf.call(this,a.methodName,arguments.length)};a.methods={}}else{a=function(){var cm=pkg.$caller;pkg.$caller=f;try{return f.apply(this,arguments)}catch(e){throw e}finally{pkg.$caller=cm}};a.f=f}a.$clone$=function(){if(a.methodName===""){return null}if(a.f){return ProxyMethod(a.methodName,a.f)}var m=ProxyMethod(a.methodName);for(var k in a.methods){m.methods[k]=a.methods[k]}return m};a.methodName=name;return a}pkg.Class=make_template(null,function(){if(arguments.length===0){throw new Error("No class definition was found")}if(Array.isArray(arguments[arguments.length-1])===false){throw new Error("Invalid class definition was found")}if(arguments.length>1&&typeof arguments[0]!=="function"){throw new ReferenceError("Invalid parent class '"+arguments[0]+"'")}var df=arguments[arguments.length-1],$parent=null,args=Array.prototype.slice.call(arguments,0,arguments.length-1);if(args.length>0&&(args[0]==null||args[0].$clazz==pkg.Class)){$parent=args[0]}var $template=make_template(pkg.Class,function(){this._hash_=["$zObj_",$$$++].join("");if(arguments.length>0){var a=arguments[arguments.length-1];if(Array.isArray(a)===true&&typeof a[0]==="function"){a=a[0];var args=[$template],k=arguments.length-2;for(;k>=0&&pkg.instanceOf(arguments[k],pkg.Interface);k--){args.push(arguments[k])}args.push(arguments[arguments.length-1]);var cl=pkg.Class.apply(null,args),f=function(){};cl.$name=$template.$name;f.prototype=cl.prototype;var o=new f();cl.apply(o,Array.prototype.slice.call(arguments,0,k+1));o.constructor=cl;return o}}this[""]&&this[""].apply(this,arguments)},args);$template.$parent=$parent;if($parent!=null){for(var k in $parent.prototype){var f=$parent.prototype[k];if(f&&f.$clone$){f=f.$clone$();if(f==null){continue}}$template.prototype[k]=f}}$template.$propertyInfo={};$template.prototype.extend=function(){var c=this.$clazz,l=arguments.length,f=arguments[l-1];if(pkg.instanceOf(this,pkg.$Extended)===false){var cn=c.$name;c=Class(c,pkg.$Extended,[]);c.$name=cn;this.$clazz=c}if(Array.isArray(f)){for(var i=0;i0&&typeof arguments[0]==="function"){name=arguments[0].methodName;args=Array.prototype.slice.call(arguments,1)}var params=args.length;while($s!=null){var m=$s.prototype[name];if(m&&(typeof m.methods==="undefined"||m.methods[params])){return m.apply(this,args)}$s=$s.$parent}mnf.call(this,name,params)}throw new Error("$super is called outside of class context")};$template.prototype.$clazz=$template;$template.prototype.$this=function(){return pkg.$caller.boundTo.prototype[""].apply(this,arguments)};$template.constructor.prototype.getMethods=function(name){var m=[];for(var n in this.prototype){var f=this.prototype[n];if(arguments.length>0&&name!=n){continue}if(typeof f==="function"){if(f.$clone$){for(var mk in f.methods){m.push(f.methods[mk])}}else{m.push(f)}}}return m};$template.constructor.prototype.getMethod=function(name,params){var m=this.prototype[name];if(typeof m==="function"){if(m.$clone$){if(typeof params==="undefined"){if(m.methods[0]){return m.methods[0]}for(var k in m.methods){return m.methods[k]}return null}m=m.methods[params]}if(m){return m}}return null};$template.extend=function(df){if(Array.isArray(df)===false){throw new Error("Wrong class definition format "+df+", array is expected")}for(var i=0;i0){$busy--}}else{if(arguments.length==1&&$busy===0&&$f.length===0){arguments[0]();return}}for(var i=0;i0){$f.shift()()}};pkg.busy=function(){$busy++};pkg.Output=Class([function $prototype(){this.print=function print(o){this._p(0,o)};this.error=function error(o){this._p(2,o)};this.warn=function warn(o){this._p(1,o)};this._p=function(l,o){o=this.format(o);if(pkg.isInBrowser){if(typeof console==="undefined"||!console.log){alert(o)}else{if(l===0){console.log(o)}else{if(l==1){console.warn(o)}else{console.error(o)}}}}else{pkg.$global.print(o)}};this.format=function(o){if(o&&o.stack){return[o.toString(),":",o.stack.toString()].join("\n")}if(o===null){return""}if(typeof o==="undefined"){return""}if(isString(o)||isNumber(o)||isBoolean(o)){return o}var d=[o.toString()+" "+(o.$clazz?o.$clazz.$name:""),"{"];for(var k in o){if(o.hasOwnProperty(k)){d.push(" "+k+" = "+o[k])}}return d.join("\n")+"\n}"}}]);pkg.Dummy=Class([]);pkg.HtmlOutput=Class(pkg.Output,[function(){this.$this(null)},function(element){element=element||"zebra.out";if(pkg.isString(element)){this.el=document.getElementById(element);if(this.el==null){this.el=document.createElement("div");this.el.setAttribute("id",element);document.body.appendChild(this.el)}}else{if(element==null){throw new Error("Unknown HTML output element")}this.el=element}},function print(s){this.out("black",s)},function error(s){this.out("red",s)},function warn(s){this.out("orange",s)},function out(color,msg){var t=["
",this.format(msg),"
"];this.el.innerHTML+=t.join("")}]);pkg.isInBrowser=typeof navigator!=="undefined";pkg.isIE=pkg.isInBrowser&&(Object.hasOwnProperty.call(window,"ActiveXObject")||!!window.ActiveXObject);pkg.isFF=pkg.isInBrowser&&window.mozInnerScreenX!=null;pkg.isMobile=pkg.isInBrowser&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|windows mobile|windows phone|IEMobile/i.test(navigator.userAgent);pkg.isTouchable=pkg.isInBrowser&&((pkg.isIE===false&&(!!("ontouchstart" in window)||!!("onmsgesturechange" in window)))||(!!window.navigator.msPointerEnabled&&!!window.navigator.msMaxTouchPoints>0));pkg.out=new pkg.Output();pkg.isMacOS=pkg.isInBrowser&&navigator.platform.toUpperCase().indexOf("MAC")!==-1;pkg.print=function(){pkg.out.print.apply(pkg.out,arguments)};pkg.error=function(){pkg.out.error.apply(pkg.out,arguments)};pkg.warn=function(){pkg.out.warn.apply(pkg.out,arguments)};function complete(){pkg(function(n,p){function collect(pp,p){for(var k in p){if(k[0]!="$"&&p.hasOwnProperty(k)&&zebra.instanceOf(p[k],Class)){p[k].$name=pp?[pp,k].join("."):k;collect(k,p[k])}}}collect(null,p)});pkg.ready()}if(pkg.isInBrowser){var m=window.location.search.match(/[?&][a-zA-Z0-9_.]+=[^?&=]+/g),env={};for(var i=0;m&&i0){var f=function(){};f.prototype=clazz.prototype;var o=new f();o.constructor=clazz;clazz.apply(o,args);return o}return new clazz()};function hex(v){return(v<16)?["0",v.toString(16)].join(""):v.toString(16)}pkg.findInTree=function(root,path,eq,cb){var findRE=/(\/\/|\/)?([^\[\/]+)(\[\s*(\@[a-zA-Z_][a-zA-Z0-9_\.]*)\s*\=\s*([0-9]+|true|false|\'[^']*\')\s*\])?/g,m=null,res=[];function _find(root,ms,idx,cb){function list_child(r,name,deep,cb){if(r.kids){for(var i=0;i=ms.length){return cb(root)}var m=ms[idx];return list_child(root,m[2],m[1]=="//",function(child){if(m[3]&&child[m[4].substring(1)]!=m[5]){return false}return _find(child,ms,idx+1,cb)})}var c=0;while(m=findRE.exec(path)){if(m[1]==null||m[2]==null||m[2].trim().length===0){break}c+=m[0].length;if(m[3]&&m[5][0]=="'"){m[5]=m[5].substring(1,m[5].length-1)}res.push(m)}if(res.length==0||c3){this.a=parseInt(p[3].trim(),10)}return}}}this.r=r>>16;this.g=(r>>8)&255;this.b=(r&255)}else{this.r=r;this.g=g;this.b=b;if(arguments.length>3){this.a=a}}if(this.s==null){this.s=(typeof this.a!=="undefined")?["rgba(",this.r,",",this.g,",",this.b,",",this.a,")"].join(""):["#",hex(this.r),hex(this.g),hex(this.b)].join("")}};var rgb=pkg.rgb;rgb.prototype.toString=function(){return this.s};rgb.black=new rgb(0);rgb.white=new rgb(16777215);rgb.red=new rgb(255,0,0);rgb.blue=new rgb(0,0,255);rgb.green=new rgb(0,255,0);rgb.gray=new rgb(128,128,128);rgb.lightGray=new rgb(211,211,211);rgb.darkGray=new rgb(169,169,169);rgb.orange=new rgb(255,165,0);rgb.yellow=new rgb(255,255,0);rgb.pink=new rgb(255,192,203);rgb.cyan=new rgb(0,255,255);rgb.magenta=new rgb(255,0,255);rgb.darkBlue=new rgb(0,0,140);rgb.transparent=new rgb(0,0,0,1);pkg.Actionable=Interface();pkg.index2point=function(offset,cols){return[~~(offset/cols),(offset%cols)]};pkg.indexByPoint=function(row,col,cols){return(cols<=0)?-1:(row*cols)+col};pkg.intersection=function(x1,y1,w1,h1,x2,y2,w2,h2,r){r.x=x1>x2?x1:x2;r.width=Math.min(x1+w1,x2+w2)-r.x;r.y=y1>y2?y1:y2;r.height=Math.min(y1+h1,y2+h2)-r.y};pkg.isIntersect=function(x1,y1,w1,h1,x2,y2,w2,h2){return(Math.min(x1+w1,x2+w2)-(x1>x2?x1:x2))>0&&(Math.min(y1+h1,y2+h2)-(y1>y2?y1:y2))>0};pkg.unite=function(x1,y1,w1,h1,x2,y2,w2,h2,r){r.x=x1>8)&255);ar.push(code&255)}return ar};var digitRE=/[0-9]/;pkg.isDigit=function(ch){if(ch.length!=1){throw new Error("Incorrect character")}return digitRE.test(ch)};var letterRE=/[A-Za-z]/;pkg.isLetter=function(ch){if(ch.length!=1){throw new Error("Incorrect character")}return letterRE.test(ch)};var $NewListener=function(){if(arguments.length===0){arguments=["fired"]}var clazz=function(){};if(arguments.length==1){var name=arguments[0];clazz.prototype.add=function(l){if(this.v==null){this.v=[]}var ctx=this;if(typeof l!=="function"){ctx=l;l=l[name];if(l==null||typeof l!=="function"){throw new Error("Instance doesn't declare '"+names+"' listener method")}}this.v.push(ctx,l);return l};clazz.prototype.remove=function(l){if(this.v!=null){var i=0;while((i=this.v.indexOf(l))>=0){if(i%2>0){i--}this.v.splice(i,2)}}};clazz.prototype.removeAll=function(){if(this.v!=null){this.v.length=0}};clazz.prototype[name]=function(){if(this.v!=null){for(var i=0;i=0){if(i%2>0){i--}v.splice(i,2)}if(v.length===0){delete this.methods[k]}}}};clazz.prototype.removeAll=function(){if(this.methods!=null){for(var k in this.methods){if(this.methods.hasOwnProperty(k)){this.methods[k].length=0}}this.methods={}}}}return clazz};pkg.Listeners=$NewListener();pkg.Listeners.Class=$NewListener;var PosListeners=pkg.Listeners.Class("posChanged"),Position=pkg.Position=Class([function $clazz(){this.Metric=Interface();this.DOWN=1;this.UP=2;this.BEG=3;this.END=4},function $prototype(){this.clearPos=function(){if(this.offset>=0){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol;this.offset=this.currentLine=this.currentCol=-1;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.setOffset=function(o){if(o<0){o=0}else{var max=this.metrics.getMaxOffset();if(o>=max){o=max}}if(o!=this.offset){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol,p=this.getPointByOffset(o);this.offset=o;if(p!=null){this.currentLine=p[0];this.currentCol=p[1]}this.isValid=true;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.seek=function(off){this.setOffset(this.offset+off)};this.setRowCol=function(r,c){if(r!=this.currentLine||c!=this.currentCol){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol;this.offset=this.getOffsetByPoint(r,c);this.currentLine=r;this.currentCol=c;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.inserted=function(off,size){if(this.offset>=0&&off<=this.offset){this.isValid=false;this.setOffset(this.offset+size)}};this.removed=function(off,size){if(this.offset>=0&&this.offset>=off){this.isValid=false;if(this.offset>=(off+size)){this.setOffset(this.offset-size)}else{this.setOffset(off)}}};this.getPointByOffset=function(off){if(off==-1){return[-1,-1]}var m=this.metrics,max=m.getMaxOffset();if(off>max){throw new Error("Out of bounds:"+off)}if(max===0){return[(m.getLines()>0?0:-1),0]}if(off===0){return[0,0]}var d=0,sl=0,so=0;if(this.isValid&&this.offset!=-1){sl=this.currentLine;so=this.offset-this.currentCol;if(off>this.offset){d=1}else{if(off=0;sl+=d){var ls=m.getLineSize(sl);if(off>=so&&off0?ls:-m.getLineSize(sl-1)}return[-1,-1]};this.getOffsetByPoint=function(row,col){var startOffset=0,startLine=0,m=this.metrics;if(row>=m.getLines()||col>=m.getLineSize(row)){throw new Error()}if(this.isValid&&this.offset!=-1){startOffset=this.offset-this.currentCol;startLine=this.currentLine}if(startLine<=row){for(var i=startLine;i=row;i--){startOffset-=m.getLineSize(i)}}return startOffset+col};this.calcMaxOffset=function(){var max=0,m=this.metrics;for(var i=0;i0){this.offset-=this.currentCol;this.currentCol=0;this._.posChanged(this,prevOffset,prevLine,prevCol)}break;case Position.END:var maxCol=this.metrics.getLineSize(this.currentLine);if(this.currentCol<(maxCol-1)){this.offset+=(maxCol-this.currentCol-1);this.currentCol=maxCol-1;this._.posChanged(this,prevOffset,prevLine,prevCol)}break;case Position.UP:if(this.currentLine>0){this.offset-=(this.currentCol+1);this.currentLine--;for(var i=0;this.currentLine>0&&i<(num-1);i++,this.currentLine--){this.offset-=this.metrics.getLineSize(this.currentLine)}var maxCol=this.metrics.getLineSize(this.currentLine);if(this.currentCol0){for(var i=0;i=0){window.clearInterval(this.pid);this.pid=-1}};this.clear=function(l){var c=this.get(l);c.si=c.ri}})();pkg.Bag=zebra.Class([function $prototype(){this.concatArrays=false;this.usePropertySetters=true;this.ignoreNonExistentKeys=false;this.get=function(key){if(key==null){throw new Error("Null key")}var n=key.split("."),v=this.objects;for(var i=0;i1){m.apply(v,nv)}else{m.call(v,nv)}continue}}v[k]=nv}}if(inh!==null){this.inherit(v,inh)}return v};this.resolveClass=function(className){return this.aliases.hasOwnProperty(className)?this.aliases[className]:zebra.Class.forName(className)};this.inherit=function(o,pp){for(var i=0;i0?"&":"?")+(new Date()).getTime().toString();return this.load(zebra.io.GET(p),b)}])})(zebra("util"),zebra.Class,zebra.Interface);(function(pkg,Class,Interface){pkg.descent=function descent(a,b){if(a==null){return 1}return(zebra.isString(a))?a.localeCompare(b):a-b};pkg.ascent=function ascent(a,b){if(b==null){return 1}return(zebra.isString(b))?b.localeCompare(a):b-a};pkg.TextModel=Interface();var MB=zebra.util,oobi="Index is out of bounds: ";function Line(s){this.s=s;this.l=0}Line.prototype.toString=function(){return this.s};pkg.TextModelListeners=MB.Listeners.Class("textUpdated");pkg.Text=Class(pkg.TextModel,[function $prototype(){this.textLength=0;this.getLnInfo=function(lines,start,startOffset,o){for(;start=startOffset&&o<=startOffset+line.length){return[start,startOffset]}startOffset+=(line.length+1)}return[]};this.setExtraChar=function(i,ch){this.lines[i].l=ch};this.getExtraChar=function(i){return this.lines[i].l};this.getLine=function(line){return this.lines[line].s};this.getValue=function(){return this.lines.join("\n")};this.getLines=function(){return this.lines.length};this.getTextLength=function(){return this.textLength};this.write=function(s,offset){var slen=s.length,info=this.getLnInfo(this.lines,0,0,offset),line=this.lines[info[0]].s,j=0,lineOff=offset-info[1],tmp=[line.substring(0,lineOff),s,line.substring(lineOff)].join("");for(;j=slen){this.lines[info[0]].s=tmp;j=1}else{this.lines.splice(info[0],1);j=this.parse(info[0],tmp,this.lines)}this.textLength+=slen;this._.textUpdated(this,true,offset,slen,info[0],j)};this.remove=function(offset,size){var i1=this.getLnInfo(this.lines,0,0,offset),i2=this.getLnInfo(this.lines,i1[0],i1[1],offset+size),l2=this.lines[i2[0]].s,l1=this.lines[i1[0]].s,off1=offset-i1[1],off2=offset+size-i2[1],buf=[l1.substring(0,off1),l2.substring(off2)].join("");if(i2[0]==i1[0]){this.lines.splice(i1[0],1,new Line(buf))}else{this.lines.splice(i1[0],i2[0]-i1[0]+1);this.lines.splice(i1[0],0,new Line(buf))}this.textLength-=size;this._.textUpdated(this,false,offset,size,i1[0],i2[0]-i1[0]+1)};this.parse=function(startLine,text,lines){var size=text.length,prevIndex=0,prevStartLine=startLine;for(var index=0;index<=size;prevIndex=index,startLine++){var fi=text.indexOf("\n",index);index=(fi<0?size:fi);this.lines.splice(startLine,0,new Line(text.substring(prevIndex,index)));index++}return startLine-prevStartLine};this.setValue=function(text){if(text==null){throw new Error("Invalid null string")}var old=this.getValue();if(old!==text){if(old.length>0){var numLines=this.getLines(),txtLen=this.getTextLength();this.lines.length=0;this.lines=[new Line("")];this._.textUpdated(this,false,0,txtLen,0,numLines)}this.lines=[];this.parse(0,text,this.lines);this.textLength=text.length;this._.textUpdated(this,true,0,this.textLength,0,this.getLines())}};this[""]=function(s){this.lines=[new Line("")];this._=new pkg.TextModelListeners();this.setValue(s==null?"":s)}}]);pkg.SingleLineTxt=Class(pkg.TextModel,[function $prototype(){this.setExtraChar=function(i,ch){this.extra=ch};this.getExtraChar=function(i){return this.extra};this.getValue=function(){return this.buf};this.getLines=function(){return 1};this.getTextLength=function(){return this.buf.length};this.getLine=function(line){if(line!=0){throw new Error(oobi+line)}return this.buf};this.write=function(s,offset){var buf=this.buf,j=s.indexOf("\n");if(j>=0){s=s.substring(0,j)}var l=(this.maxLen>0&&(buf.length+s.length)>=this.maxLen)?this.maxLen-buf.length:s.length;if(l!==0){this.buf=[buf.substring(0,offset),s.substring(0,l),buf.substring(offset)].join("");if(l>0){this._.textUpdated(this,true,offset,l,0,1)}}};this.remove=function(offset,size){this.buf=[this.buf.substring(0,offset),this.buf.substring(offset+size)].join("");this._.textUpdated(this,false,offset,size,0,1)};this.setValue=function(text){if(text==null){throw new Error("Invalid null string")}var i=text.indexOf("\n");if(i>=0){text=text.substring(0,i)}if(this.buf==null||this.buf!==text){if(this.buf!=null&&this.buf.length>0){this._.textUpdated(this,false,0,this.buf.length,0,1)}if(this.maxLen>0&&text.length>this.maxLen){text=text.substring(0,this.maxLen)}this.buf=text;this._.textUpdated(this,true,0,text.length,0,1)}};this.setMaxLength=function(max){if(max!=this.maxLen){this.maxLen=max;this.setValue("")}};this[""]=function(s,max){this.maxLen=max==null?-1:max;this.buf=null;this.extra=0;this._=new pkg.TextModelListeners();this.setValue(s==null?"":s)}}]);pkg.ListModelListeners=MB.Listeners.Class("elementInserted","elementRemoved","elementSet");pkg.ListModel=Class([function $prototype(){this.get=function(i){if(i<0||i>=this.d.length){throw new Error(oobi+i)}return this.d[i]};this.add=function(o){this.d.push(o);this._.elementInserted(this,o,this.d.length-1)};this.removeAll=function(){var size=this.d.length;for(var i=size-1;i>=0;i--){this.removeAt(i)}};this.removeAt=function(i){var re=this.d[i];this.d.splice(i,1);this._.elementRemoved(this,re,i)};this.remove=function(o){for(var i=0;i=this.d.length){throw new Error(oobi+i)}this.d.splice(i,0,o);this._.elementInserted(this,o,i)};this.count=function(){return this.d.length};this.set=function(o,i){if(i<0||i>=this.d.length){throw new Error(oobi+i)}var pe=this.d[i];this.d[i]=o;this._.elementSet(this,o,pe,i);return pe};this.contains=function(o){return this.indexOf(o)>=0};this.indexOf=function(o){return this.d.indexOf(o)};this[""]=function(){this._=new pkg.ListModelListeners();this.d=(arguments.length===0)?[]:arguments[0]}}]);var Item=pkg.Item=Class([function $prototype(){this[""]=function(v){this.kids=[];this.value=v}}]);pkg.TreeModelListeners=MB.Listeners.Class("itemModified","itemRemoved","itemInserted");pkg.TreeModel=Class([function $clazz(){this.create=function(r,p){var item=new Item(r.hasOwnProperty("value")?r.value:r);item.parent=p;if(r.hasOwnProperty("kids")){for(var i=0;i=this.rows||col<0||col>=this.cols){throw new Error("Row of col is out of bounds: "+row+","+col)}return this.objs[row][col]};this.put=function(row,col,obj){var nr=this.rows,nc=this.cols;if(row>=nr){nr+=(row-nr+1)}if(col>=nc){nc+=(col-nc+1)}this.setRowsCols(nr,nc);var old=this.objs[row]?this.objs[row][col]:undefined;if(obj!=old){this.objs[row][col]=obj;this._.cellModified(this,row,col,old)}};this.puti=function(i,obj){var p=zebra.util.index2point(i,this.cols);this.put(p[0],p[1],obj)};this.setRowsCols=function(rows,cols){if(rows!=this.rows||cols!=this.cols){var pc=this.cols,pr=this.rows;this.rellocate(rows,cols);this.cols=cols;this.rows=rows;this._.matrixResized(this,pr,pc)}};this.rellocate=function(r,c){if(r>=this.rows){for(var i=this.rows;ithis.rows){throw new Error()}for(var i=(begrow+count);ithis.cols){throw new Error()}for(var i=(begcol+count);i0)?this.objs[0].length:0;this.rows=this.objs.length}else{this.objs=[];this.rows=this.cols=0;if(arguments.length>1){this.setRowsCols(arguments[0],arguments[1])}}}}])})(zebra("data"),zebra.Class,zebra.Interface);(function(pkg,Class){var HEX="0123456789ABCDEF";pkg.ID=function UUID(size){if(typeof size==="undefined"){size=16}var id=[];for(var i=0;i<36;i++){id[i]=HEX[~~(Math.random()*16)]}return id.join("")};pkg.sleep=function(){var r=new XMLHttpRequest(),t=(new Date()).getTime().toString(),i=window.location.toString().lastIndexOf("?");r.open("GET",window.location+(i>0?"&":"?")+t,false);r.send(null)};var b64str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";pkg.b64encode=function(input){var out=[],i=0,len=input.length,c1,c2,c3;if(typeof ArrayBuffer!=="undefined"){if(input instanceof ArrayBuffer){input=new Uint8Array(input)}input.charCodeAt=function(i){return this[i]}}if(Array.isArray(input)){input.charCodeAt=function(i){return this[i]}}while(i>2));if(i==len){out.push(b64str.charAt((c1&3)<<4),"==");break}c2=input.charCodeAt(i++);out.push(b64str.charAt(((c1&3)<<4)|((c2&240)>>4)));if(i==len){out.push(b64str.charAt((c2&15)<<2),"=");break}c3=input.charCodeAt(i++);out.push(b64str.charAt(((c2&15)<<2)|((c3&192)>>6)),b64str.charAt(c3&63))}return out.join("")};pkg.b64decode=function(input){var output=[],chr1,chr2,chr3,enc1,enc2,enc3,enc4;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while((input.length%4)!==0){input+="="}for(var i=0;i>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output.push(String.fromCharCode(chr1));if(enc3!=64){output.push(String.fromCharCode(chr2))}if(enc4!=64){output.push(String.fromCharCode(chr3))}}return output.join("")};pkg.dateToISO8601=function(d){function pad(n){return n<10?"0"+n:n}return[d.getUTCFullYear(),"-",pad(d.getUTCMonth()+1),"-",pad(d.getUTCDate()),"T",pad(d.getUTCHours()),":",pad(d.getUTCMinutes()),":",pad(d.getUTCSeconds()),"Z"].join("")};pkg.ISO8601toDate=function(v){var regexp=["([0-9]{4})(-([0-9]{2})(-([0-9]{2})","(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?","(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?"].join(""),d=v.match(new RegExp(regexp)),offset=0,date=new Date(d[1],0,1);if(d[3]){date.setMonth(d[3]-1)}if(d[5]){date.setDate(d[5])}if(d[7]){date.setHours(d[7])}if(d[8]){date.setMinutes(d[8])}if(d[10]){date.setSeconds(d[10])}if(d[12]){date.setMilliseconds(Number("0."+d[12])*1000)}if(d[14]){offset=(Number(d[16])*60)+Number(d[17]);offset*=((d[15]=="-")?1:-1)}offset-=date.getTimezoneOffset();date.setTime(Number(date)+(offset*60*1000));return date};pkg.parseXML=function(s){function rmws(node){if(node.childNodes!==null){for(var i=node.childNodes.length;i-->0;){var child=node.childNodes[i];if(child.nodeType===3&&child.data.match(/^\s*$/)){node.removeChild(child)}if(child.nodeType===1){rmws(child)}}}return node}if(typeof DOMParser!=="undefined"){return rmws((new DOMParser()).parseFromString(s,"text/xml"))}else{for(var n in {"Microsoft.XMLDOM":0,"MSXML2.DOMDocument":1,"MSXML.DOMDocument":2}){var p=null;try{p=new ActiveXObject(n);p.async=false}catch(e){continue}if(p===null){throw new Error("XML parser is not available")}p.loadXML(s);return p}}throw new Error("No XML parser is available")};pkg.QS=Class([function $clazz(){this.append=function(url,obj){return url+((obj===null)?"":((url.indexOf("?")>0)?"&":"?")+pkg.QS.toQS(obj,true))};this.parse=function(url){var m=window.location.search.match(/[?&][a-zA-Z0-9_.]+=[^?&=]+/g),r={};for(var i=0;m&&i0?this.data.charCodeAt(this.pos++)&255:-1}])}else{if(Array.isArray(container)===false){throw new Error("Wrong type: "+typeof(container))}}this.data=container}this.marked=-1;this.pos=0},function mark(){if(this.available()<=0){throw new Error()}this.marked=this.pos},function reset(){if(this.available()<=0||this.marked<0){throw new Error()}this.pos=this.marked;this.marked=-1},function close(){this.pos=this.data.length},function read(){return this.available()>0?this.data[this.pos++]:-1},function read(buf){return this.read(buf,0,buf.length)},function read(buf,off,len){for(var i=0;i191&&c<224){return String.fromCharCode(((c&31)<<6)|(c2&63))}else{var c3=this.read();if(c3<0){throw new Error()}return String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63))}},function readLine(){if(this.available()>0){var line=[],b;while((b=this.readChar())!=-1&&b!="\n"){line.push(b)}var r=line.join("");line.length=0;return r}return null},function available(){return this.data===null?-1:this.data.length-this.pos},function toBase64(){return pkg.b64encode(this.data)}]);pkg.URLInputStream=Class(pkg.InputStream,[function(url){this.$this(url,null)},function(url,f){var r=pkg.getRequest(),$this=this;r.open("GET",url,f!==null);if(f===null||isBA===false){if(!r.overrideMimeType){throw new Error("Binary mode is not supported")}r.overrideMimeType("text/plain; charset=x-user-defined")}if(f!==null){if(isBA){r.responseType="arraybuffer"}r.onreadystatechange=function(){if(r.readyState==4){if(r.status!=200){throw new Error(url)}$this.$clazz.$parent.getMethod("",1).call($this,isBA?r.response:r.responseText);f($this.data,r)}};r.send(null)}else{r.send(null);if(r.status!=200){throw new Error(url)}this.$super(r.responseText)}},function close(){this.$super();if(this.data){this.data.length=0;this.data=null}}]);pkg.Service=Class([function(url,methods){var $this=this;this.url=url;if(Array.isArray(methods)===false){methods=[methods]}for(var i=0;i0&&typeof args[args.length-1]=="function"){var callback=args.pop();return this.send(url,this.encode(name,args),function(request){var r=null;try{if(request.status==200){r=$this.decode(request.responseText)}else{r=new Error("Status: "+request.status+", '"+request.statusText+"'")}}catch(e){r=e}callback(r)})}return this.decode(this.send(url,this.encode(name,args),null))}})()}},function send(url,data,callback){var http=new pkg.HTTP(url);if(this.contentType!=null){http.header["Content-Type"]=this.contentType}return http.POST(data,callback)}]);pkg.Service.invoke=function(clazz,url,method){var rpc=new clazz(url,method);return function(){return rpc[method].apply(rpc,arguments)}};pkg.JRPC=Class(pkg.Service,[function(url,methods){this.$super(url,methods);this.version="2.0";this.contentType="application/json"},function encode(name,args){return JSON.stringify({jsonrpc:this.version,method:name,params:args,id:pkg.ID()})},function decode(r){if(r===null||r.length===0){throw new Error("Empty JSON result string")}r=JSON.parse(r);if(typeof(r.error)!=="undefined"){throw new Error(r.error.message)}if(typeof r.result==="undefined"||typeof r.id==="undefined"){throw new Error("Wrong JSON response format")}return r.result}]);pkg.Base64=function(s){if(arguments.length>0){this.encoded=pkg.b64encode(s)}};pkg.Base64.prototype.toString=function(){return this.encoded};pkg.Base64.prototype.decode=function(){return pkg.b64decode(this.encoded)};pkg.XRPC=Class(pkg.Service,[function(url,methods){this.$super(url,methods);this.contentType="text/xml"},function encode(name,args){var p=['\n',name,""];for(var i=0;i");this.encodeValue(args[i],p);p.push("")}p.push("");return p.join("")},function encodeValue(v,p){if(v===null){throw new Error("Null is not allowed")}if(zebra.isString(v)){v=v.replace("<","<");v=v.replace("&","&");p.push("",v,"")}else{if(zebra.isNumber(v)){if(Math.round(v)==v){p.push("",v.toString(),"")}else{p.push("",v.toString(),"")}}else{if(zebra.isBoolean(v)){p.push("",v?"1":"0","")}else{if(v instanceof Date){p.push("",pkg.dateToISO8601(v),"")}else{if(Array.isArray(v)){p.push("");for(var i=0;i");this.encodeValue(v[i],p);p.push("")}p.push("")}else{if(v instanceof pkg.Base64){p.push("",v.toString(),"")}else{p.push("");for(var k in v){if(v.hasOwnProperty(k)){p.push("",k,"");this.encodeValue(v[k],p);p.push("")}}p.push("")}}}}}}},function decodeValue(node){var tag=node.tagName.toLowerCase();if(tag=="struct"){var p={};for(var i=0;i0){var err=this.decodeValue(c[0].getElementsByTagName("struct")[0]);throw new Error(err.faultString)}c=p.getElementsByTagName("methodResponse")[0];c=c.childNodes[0].childNodes[0];if(c.tagName.toLowerCase()==="param"){return this.decodeValue(c.childNodes[0].childNodes[0])}throw new Error("incorrect XML-RPC response")}]);pkg.XRPC.invoke=function(url,method){return pkg.Service.invoke(pkg.XRPC,url,method)};pkg.JRPC.invoke=function(url,method){return pkg.Service.invoke(pkg.JRPC,url,method)}})(zebra("io"),zebra.Class);(function(pkg,Class){pkg.NONE=0;pkg.LEFT=1;pkg.RIGHT=2;pkg.TOP=4;pkg.BOTTOM=8;pkg.CENTER=16;pkg.HORIZONTAL=32;pkg.VERTICAL=64;pkg.TEMPORARY=128;pkg.USE_PS_SIZE=512;pkg.STRETCH=256;pkg.TLEFT=pkg.LEFT|pkg.TOP;pkg.TRIGHT=pkg.RIGHT|pkg.TOP;pkg.BLEFT=pkg.LEFT|pkg.BOTTOM;pkg.BRIGHT=pkg.RIGHT|pkg.BOTTOM;var $ctrs={};for(var k in pkg){if(pkg.hasOwnProperty(k)&&/^\d+$/.test(pkg[k])){$ctrs[k.toUpperCase()]=pkg[k]}}var $c=pkg.$constraints=function(v){return zebra.isString(v)?$ctrs[v.toUpperCase()]:v};var L=pkg.Layout=new zebra.Interface();pkg.getDirectChild=function(parent,child){for(;child!=null&&child.parent!=parent;child=child.parent){}return child};pkg.getDirectAt=function(x,y,p){for(var i=0;ix&&c.y+c.height>y){return i}}return -1};pkg.getTopParent=function(c){for(;c!=null&&c.parent!=null;c=c.parent){}return c};pkg.getAbsLocation=function(x,y,c){if(arguments.length==1){c=x;x=y=0}while(c.parent!=null){x+=c.x;y+=c.y;c=c.parent}return{x:x,y:y}};pkg.getRelLocation=function(x,y,p,c){while(c!=p){x-=c.x;y-=c.y;c=c.parent}return{x:x,y:y}};pkg.xAlignment=function(aow,alignX,aw){if(alignX==pkg.RIGHT){return aw-aow}if(alignX==pkg.CENTER){return ~~((aw-aow)/2)}if(alignX==pkg.LEFT||alignX==pkg.NONE){return 0}throw new Error("Invalid alignment "+alignX)};pkg.yAlignment=function(aoh,alignY,ah){if(alignY==pkg.BOTTOM){return ah-aoh}if(alignY==pkg.CENTER){return ~~((ah-aoh)/2)}if(alignY==pkg.TOP||alignY==pkg.NONE){return 0}throw new Error("Invalid alignment "+alignY)};pkg.getMaxPreferredSize=function(target){var maxWidth=0,maxHeight=0;for(var i=0;imaxWidth){maxWidth=ps.width}if(ps.height>maxHeight){maxHeight=ps.height}}}return{width:maxWidth,height:maxHeight}};pkg.isAncestorOf=function(p,c){for(;c!=null&&c!=p;c=c.parent){}return c!=null};pkg.Layoutable=Class(L,[function $prototype(){this.x=this.y=this.height=this.width=this.cachedHeight=0;this.psWidth=this.psHeight=this.cachedWidth=-1;this.isLayoutValid=this.isValid=false;this.constraints=this.parent=null;this.isVisible=true;this.find=function(path){var res=null;zebra.util.findInTree(this,path,function(node,name){return node.$clazz.$name==name},function(kid){res=kid;return true});return res};this.findAll=function(path,callback){var res=[];if(callback==null){callback=function(kid){res.push(kid);return false}}zebra.util.findInTree(this,path,function(node,name){return node.$clazz.$name==name},callback);return res};this.validateMetric=function(){if(this.isValid===false){if(this.recalc){this.recalc()}this.isValid=true}};this.invalidateLayout=function(){this.isLayoutValid=false;if(this.parent!=null){this.parent.invalidateLayout()}};this.invalidate=function(){this.isValid=this.isLayoutValid=false;this.cachedWidth=-1;if(this.parent!=null){this.parent.invalidate()}};this.validate=function(){this.validateMetric();if(this.width>0&&this.height>0&&this.isLayoutValid===false&&this.isVisible){this.layout.doLayout(this);for(var i=0;i=0?this.psWidth:ps.width+this.getLeft()+this.getRight();ps.height=this.psHeight>=0?this.psHeight:ps.height+this.getTop()+this.getBottom();this.cachedWidth=ps.width;this.cachedHeight=ps.height;return ps}return{width:this.cachedWidth,height:this.cachedHeight}};this.getTop=function(){return 0};this.getLeft=function(){return 0};this.getBottom=function(){return 0};this.getRight=function(){return 0};this.setParent=function(o){if(o!=this.parent){this.parent=o;this.invalidate()}};this.setLayout=function(m){if(m==null){throw new Error("Null layout")}if(this.layout!=m){var pl=this.layout;this.layout=m;this.invalidate()}};this.calcPreferredSize=function(target){return{width:10,height:10}};this.doLayout=function(target){};this.indexOf=function(c){return this.kids.indexOf(c)};this.insert=function(i,constr,d){if(d.constraints){constr=d.constraints}else{d.constraints=constr}if(i==this.kids.length){this.kids.push(d)}else{this.kids.splice(i,0,d)}d.setParent(this);if(this.kidAdded){this.kidAdded(i,constr,d)}this.invalidate();return d};this.setLocation=function(xx,yy){if(xx!=this.x||this.y!=yy){var px=this.x,py=this.y;this.x=xx;this.y=yy;if(this.relocated){this.relocated(px,py)}}};this.setBounds=function(x,y,w,h){this.setLocation(x,y);this.setSize(w,h)};this.setSize=function(w,h){if(w!=this.width||h!=this.height){var pw=this.width,ph=this.height;this.width=w;this.height=h;this.isLayoutValid=false;if(this.resized){this.resized(pw,ph)}}};this.getByConstraints=function(c){if(this.kids.length>0){for(var i=0;i0){if(arguments.length==1){this.hgap=this.vgap=hgap}else{this.hgap=hgap;this.vgap=vgap}}};this.calcPreferredSize=function(target){var center=null,west=null,east=null,north=null,south=null,d=null;for(var i=0;idim.height?d.height:dim.height)}if(west!=null){d=west.getPreferredSize();dim.width+=d.width+this.hgap;dim.height=d.height>dim.height?d.height:dim.height}if(center!=null){d=center.getPreferredSize();dim.width+=d.width;dim.height=d.height>dim.height?d.height:dim.height}if(north!=null){d=north.getPreferredSize();dim.width=d.width>dim.width?d.width:dim.width;dim.height+=d.height+this.vgap}if(south!=null){d=south.getPreferredSize();dim.width=d.width>dim.width?d.width:dim.width;dim.height+=d.height+this.vgap}return dim};this.doLayout=function(t){var top=t.getTop(),bottom=t.height-t.getBottom(),left=t.getLeft(),right=t.width-t.getRight(),center=null,west=null,east=null;for(var i=0;i0;for(var i=0;im.width){m.width=px}if(py>m.height){m.height=py}}}return m};this.doLayout=function(c){var r=c.width-c.getRight(),b=c.height-c.getBottom(),usePsSize=(this.flag&pkg.USE_PS_SIZE)>0;for(var i=0;i0){ww=r-el.x}if((this.flag&pkg.VERTICAL)>0){hh=b-el.y}el.setSize(ww,hh);if(el.constraints){var x=el.x,y=el.y;if(el.constraints==pkg.CENTER){x=(c.width-ww)/2;y=(c.height-hh)/2}else{if((el.constraints&pkg.TOP)>0){y=0}else{if((el.constraints&pkg.BOTTOM)>0){y=c.height-hh}}if((el.constraints&pkg.LEFT)>0){x=0}else{if((el.constraints&pkg.RIGHT)>0){x=c.width-ww}}}el.setLocation(x,y)}}}};this[""]=function(f){this.flag=f?f:0}}]);pkg.FlowLayout=Class(L,[function $prototype(){this.gap=0;this.ax=pkg.LEFT;this.ay=pkg.TOP;this.direction=pkg.HORIZONTAL;this[""]=function(ax,ay,dir,g){if(arguments.length==1){this.gap=ax}else{if(arguments.length>=2){this.ax=pkg.$constraints(ax);this.ay=pkg.$constraints(ay)}if(arguments.length>2){dir=pkg.$constraints(dir);if(dir!=pkg.HORIZONTAL&&dir!=pkg.VERTICAL){throw new Error("Invalid direction "+dir)}this.direction=dir}if(arguments.length>3){this.gap=g}}};this.calcPreferredSize=function(c){var m={width:0,height:0},cc=0;for(var i=0;im.height?d.height:m.height}else{m.width=d.width>m.width?d.width:m.width;m.height+=d.height}cc++}}var add=this.gap*(cc>0?cc-1:0);if(this.direction==pkg.HORIZONTAL){m.width+=add}else{m.height+=add}return m};this.doLayout=function(c){var psSize=this.calcPreferredSize(c),t=c.getTop(),l=c.getLeft(),lastOne=null,px=pkg.xAlignment(psSize.width,this.ax,c.width-l-c.getRight())+l,py=pkg.yAlignment(psSize.height,this.ay,c.height-t-c.getBottom())+t;for(var i=0;i0?this.gap:0));c++;if(wmax){max=d.height}as+=d.width}else{if(d.width>max){max=d.width}as+=d.height}}return(this.direction==pkg.HORIZONTAL)?{width:as,height:max}:{width:max,height:as}}}]);pkg.Constraints=Class([function $prototype(){this.top=this.bottom=this.left=this.right=0;this.ay=this.ax=pkg.STRETCH;this.rowSpan=this.colSpan=1;this[""]=function(ax,ay){if(arguments.length>0){this.ax=ax;if(arguments.length>1){this.ay=ay}}};this.setPadding=function(p){this.top=this.bottom=this.left=this.right=p};this.setPaddings=function(t,l,b,r){this.top=t;this.bottom=b;this.left=l;this.right=r}}]);pkg.GridLayout=Class(L,[function(r,c){this.$this(r,c,0)},function(r,c,m){this.rows=r;this.cols=c;this.mask=m;this.colSizes=Array(c+1);this.rowSizes=Array(r+1)},function $prototype(){var DEF_CONSTR=new pkg.Constraints();this.getSizes=function(c,isRow){var max=isRow?this.rows:this.cols,res=isRow?this.rowSizes:this.colSizes;res[max]=0;for(var i=0;imax?d:max)}}return max};this.calcColSize=function(col,c){var max=0,r=0,i=0;while((i=zebra.util.indexByPoint(r,col,this.cols))max?d:max)}r++}return max};this.calcPreferredSize=function(c){return{width:this.getSizes(c,false)[this.cols],height:this.getSizes(c,true)[this.rows]}};this.doLayout=function(c){var rows=this.rows,cols=this.cols,colSizes=this.getSizes(c,false),rowSizes=this.getSizes(c,true),top=c.getTop(),left=c.getLeft();if((this.mask&pkg.HORIZONTAL)>0){var dw=c.width-left-c.getRight()-colSizes[cols];for(var i=0;i0){var dh=c.height-top-c.getBottom()-rowSizes[rows];for(var i=0;i=0;i--){var c=$canvases[i];if(c.isFullScreen){c.setLocation(0,0);c.setSize(window.innerWidth,window.innerHeight)}c.recalcOffset()}}pkg.$view=function(v){if(v==null){return null}if(v.paint){return v}if(zebra.isString(v)){return rgb.hasOwnProperty(v)?rgb[v]:(pkg.borders&&pkg.borders.hasOwnProperty(v)?pkg.borders[v]:new rgb(v))}if(Array.isArray(v)){return new pkg.CompositeView(v)}if(typeof v!=="function"){return new pkg.ViewSet(v)}v=new pkg.View();v.paint=f;return v};pkg.$detectZCanvas=function(canvas){if(zebra.isString(canvas)){canvas=document.getElementById(canvas)}for(var i=0;canvas!=null&&i<$canvases.length;i++){if($canvases[i].canvas==canvas){return $canvases[i]}}return null};pkg.View=Class([function $prototype(){this.gap=2;this.getRight=this.getLeft=this.getBottom=this.getTop=function(){return this.gap};this.getPreferredSize=function(){return{width:0,height:0}};this.paint=function(g,x,y,w,h,c){}}]);pkg.Render=Class(pkg.View,[function $prototype(){this[""]=function(target){this.setTarget(target)};this.setTarget=function(o){if(this.target!=o){var old=this.target;this.target=o;if(this.targetWasChanged){this.targetWasChanged(old,o)}}}}]);pkg.Raised=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor)},function(brightest,middle){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.brightest);g.drawLine(x1,y1,x2,y1);g.drawLine(x1,y1,x1,y2);g.setColor(this.middle);g.drawLine(x2,y1,x2,y2+1);g.drawLine(x1,y2,x2,y2)}}]);pkg.Sunken=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor,pkg.darkBrColor)},function(brightest,middle,darkest){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle;this.darkest=darkest==null?"black":darkest},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.middle);g.drawLine(x1,y1,x2-1,y1);g.drawLine(x1,y1,x1,y2-1);g.setColor(this.brightest);g.drawLine(x2,y1,x2,y2+1);g.drawLine(x1,y2,x2,y2);g.setColor(this.darkest);g.drawLine(x1+1,y1+1,x1+1,y2);g.drawLine(x1+1,y1+1,x2,y1+1)}}]);pkg.Etched=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor)},function(brightest,middle){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.middle);g.drawLine(x1,y1,x1,y2-1);g.drawLine(x2-1,y1,x2-1,y2);g.drawLine(x1,y1,x2,y1);g.drawLine(x1,y2-1,x2-1,y2-1);g.setColor(this.brightest);g.drawLine(x2,y1,x2,y2);g.drawLine(x1+1,y1+1,x1+1,y2-1);g.drawLine(x1+1,y1+1,x2-1,y1+1);g.drawLine(x1,y2,x2+1,y2)}}]);pkg.Dotted=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){g.setColor(this.color);g.drawDottedRect(x,y,w,h)};this[""]=function(c){this.color=(c==null)?"black":c}}]);pkg.Border=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.color==null){return}var ps=g.lineWidth;g.lineWidth=this.width;if(this.radius>0){this.outline(g,x,y,w,h,d)}else{var dt=this.width/2;g.beginPath();g.rect(x+dt,y+dt,w-this.width,h-this.width)}g.setColor(this.color);g.stroke();g.lineWidth=ps};this.outline=function(g,x,y,w,h,d){if(this.radius<=0){return false}var r=this.radius,dt=this.width/2,xx=x+w-dt,yy=y+h-dt;x+=dt;y+=dt;g.beginPath();g.moveTo(x-1+r,y);g.lineTo(xx-r,y);g.quadraticCurveTo(xx,y,xx,y+r);g.lineTo(xx,yy-r);g.quadraticCurveTo(xx,yy,xx-r,yy);g.lineTo(x+r,yy);g.quadraticCurveTo(x,yy,x,yy-r);g.lineTo(x,y+r);g.quadraticCurveTo(x,y,x+r,y);return true};this[""]=function(c,w,r){this.color=(arguments.length===0)?"gray":c;this.width=(w==null)?1:w;this.radius=(r==null)?0:r;this.gap=this.width+Math.round(this.radius/4)}}]);pkg.RoundBorder=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.color!=null&&this.width>0){this.outline(g,x,y,w,h,d);g.setColor(this.color);g.stroke()}};this.outline=function(g,x,y,w,h,d){g.beginPath();g.lineWidth=this.width;g.arc(x+w/2,y+h/2,w/2,0,2*Math.PI,false);return true};this[""]=function(col,width){this.color=null;this.width=1;if(arguments.length>0){if(zebra.isNumber(col)){this.width=col}else{this.color=col;if(zebra.isNumber(width)){this.width=width}}}this.gap=this.width}}]);pkg.Gradient=Class(pkg.View,[function $prototype(){this[""]=function(){this.colors=Array.prototype.slice.call(arguments,0);if(zebra.isNumber(arguments[arguments.length-1])){this.orientation=arguments[arguments.length-1];this.colors.pop()}else{this.orientation=L.VERTICAL}};this.paint=function(g,x,y,w,h,dd){var d=(this.orientation==L.HORIZONTAL?[0,1]:[1,0]),x1=x*d[1],y1=y*d[0],x2=(x+w-1)*d[1],y2=(y+h-1)*d[0];if(this.gradient==null||this.gx1!=x1||this.gx2!=x2||this.gy1!=y1||this.gy2!=y2){this.gx1=x1;this.gx2=x2;this.gy1=y1;this.gy2=y2;this.gradient=g.createLinearGradient(x1,y1,x2,y2);for(var i=0;i4){this.x=x;this.y=y;this.width=w;this.height=h}else{this.x=this.y=this.width=this.height=0}if(zebra.isBoolean(arguments[arguments.length-1])===false){ub=w>0&&h>0&&w<64&&h<64}if(ub===true){this.buffer=document.createElement("canvas");this.buffer.width=0}};this.paint=function(g,x,y,w,h,d){if(this.target!=null&&w>0&&h>0){var img=this.target;if(this.buffer){img=this.buffer;if(img.width<=0){var ctx=img.getContext("2d");if(this.width>0){img.width=this.width;img.height=this.height;ctx.drawImage(this.target,this.x,this.y,this.width,this.height,0,0,this.width,this.height)}else{img.width=this.target.width;img.height=this.target.height;ctx.drawImage(this.target,0,0)}}}if(this.width>0&&!this.buffer){g.drawImage(img,this.x,this.y,this.width,this.height,x,y,w,h)}else{g.drawImage(img,x,y,w,h)}}};this.targetWasChanged=function(o,n){if(this.buffer){delete this.buffer}};this.getPreferredSize=function(){var img=this.target;return img==null?{width:0,height:0}:(this.width>0)?{width:this.width,height:this.height}:{width:img.width,height:img.height}}}]);pkg.Pattern=Class(pkg.Render,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.pattern==null){this.pattern=g.createPattern(this.target,"repeat")}g.rect(x,y,w,h);g.fillStyle=this.pattern;g.fill()}}]);pkg.CompositeView=Class(pkg.View,[function $prototype(){this.left=this.right=this.bottom=this.top=this.height=this.width=0;this.getTop=function(){return this.top};this.getLeft=function(){return this.left};this.getBottom=function(){return this.bottom};this.getRight=function(){return this.right};this.getPreferredSize=function(){return{width:this.width,height:this.height}};this.$recalc=function(v){var b=0,ps=v.getPreferredSize();if(v.getLeft){b=v.getLeft();if(b>this.left){this.left=b}}if(v.getRight){b=v.getRight();if(b>this.right){this.right=b}}if(v.getTop){b=v.getTop();if(b>this.top){this.top=b}}if(v.getBottom){b=v.getBottom();if(b>this.bottom){this.bottom=b}}if(ps.width>this.width){this.width=ps.width}if(ps.height>this.height){this.height=ps.height}if(this.voutline==null&&v.outline){this.voutline=v}};this.paint=function(g,x,y,w,h,d){for(var i=0;i1&&id[0]!="*"&&id[id.length-1]!="*"){var i=id.indexOf(".");if(i>0){var k=id.substring(0,i+1).concat("*");if(this.views.hasOwnProperty(k)){return(this.activeView=this.views[k])!=old}else{k="*"+id.substring(i);if(this.views.hasOwnProperty(k)){return(this.activeView=this.views[k])!=old}}}}}if(this.views.hasOwnProperty("*")){return(this.activeView=this.views["*"])!=old}return false};this[""]=function(args){if(args==null){throw new Error("Invalid null view set")}this.views={};this.activeView=null;for(var k in args){this.views[k]=pkg.$view(args[k]);if(this.views[k]){this.$recalc(this.views[k])}}this.activate("*")}}]);pkg.Bag=Class(zebra.util.Bag,[function $prototype(){this.usePropertySetters=true;this.contentLoaded=function(v){if(v==null||zebra.isNumber(v)||zebra.isBoolean(v)){return v}if(zebra.isString(v)){if(this.root&&v[0]=="%"&&v[1]=="r"){var s="%root%/";if(v.indexOf(s)===0){return this.root.join(v.substring(s.length))}}return v}if(Array.isArray(v)){for(var i=0;i0&&c.height>0&&c.isVisible){var p=c.parent,px=-c.x,py=-c.y;if(r==null){r={x:0,y:0,width:0,height:0}}else{r.x=r.y=0}r.width=c.width;r.height=c.height;while(p!=null&&r.width>0&&r.height>0){var xx=r.x>px?r.x:px,yy=r.y>py?r.y:py,w1=r.x+r.width,w2=px+p.width,h1=r.y+r.height,h2=py+p.height;r.width=(w10&&r.height>0?r:null}return null};pkg.configure=function(c){if(zebra.isString(c)){var path=c;c=function(conf){conf.loadByUrl(path,false)}}$configurators.push(c)};pkg.Font=function(name,style,size){if(arguments.length==1){name=name.replace(/[ ]+/," ");this.s=name.trim()}else{if(arguments.length==2){size=style;style=""}style=style.trim();this.s=[style,(style!==""?" ":""),size,"px ",name].join("")}$fmText.style.font=this.s;this.height=$fmText.offsetHeight;if(this.height===0){this.height=$fmText.offsetHeight}this.ascent=$fmImage.offsetTop-$fmText.offsetTop+1};pkg.Font.prototype.stringWidth=function(s){if(s.length===0){return 0}if($fmCanvas.font!=this.s){$fmCanvas.font=this.s}return($fmCanvas.measureText(s).width+0.5)|0};pkg.Font.prototype.charsWidth=function(s,off,len){if($fmCanvas.font!=this.s){$fmCanvas.font=this.s}return($fmCanvas.measureText(len==1?s[off]:s.substring(off,off+len)).width+0.5)|0};pkg.Font.prototype.toString=function(){return this.s};pkg.Cursor={DEFAULT:"default",MOVE:"move",WAIT:"wait",TEXT:"text",HAND:"pointer",NE_RESIZE:"ne-resize",SW_RESIZE:"sw-resize",SE_RESIZE:"se-resize",NW_RESIZE:"nw-resize",S_RESIZE:"s-resize",W_RESIZE:"w-resize",N_RESIZE:"n-resize",E_RESIZE:"e-resize",COL_RESIZE:"col-resize",HELP:"help"};var MouseListener=pkg.MouseListener=Interface(),FocusListener=pkg.FocusListener=Interface(),KeyListener=pkg.KeyListener=Interface(),Composite=pkg.Composite=Interface(),ChildrenListener=pkg.ChildrenListener=Interface(),CopyCutPaste=pkg.CopyCutPaste=Interface(),CL=pkg.ComponentListener=Interface();CL.ENABLED=1;CL.SHOWN=2;CL.MOVED=3;CL.SIZED=4;CL.ADDED=5;CL.REMOVED=6;var IE=pkg.InputEvent=Class([function $clazz(){this.MOUSE_UID=1;this.KEY_UID=2;this.FOCUS_UID=3;this.FOCUS_LOST=10;this.FOCUS_GAINED=11},function(target,id,uid){this.source=target;this.ID=id;this.UID=uid}]);var KE=pkg.KeyEvent=Class(IE,[function $clazz(){this.TYPED=15;this.RELEASED=16;this.PRESSED=17;this.M_CTRL=1;this.M_SHIFT=2;this.M_ALT=4;this.M_CMD=8},function $prototype(){this.reset=function(target,id,code,ch,mask){this.source=target;this.ID=id;this.code=code;this.mask=mask;this.ch=ch};this.isControlPressed=function(){return(this.mask&KE.M_CTRL)>0};this.isShiftPressed=function(){return(this.mask&KE.M_SHIFT)>0};this.isAltPressed=function(){return(this.mask&KE.M_ALT)>0};this.isCmdPressed=function(){return(this.mask&KE.M_CMD)>0}},function(target,id,code,ch,mask){this.$super(target,id,IE.KEY_UID);this.reset(target,id,code,ch,mask)}]);var ME=pkg.MouseEvent=Class(IE,[function $clazz(){this.CLICKED=21;this.PRESSED=22;this.RELEASED=23;this.ENTERED=24;this.EXITED=25;this.DRAGGED=26;this.DRAGSTARTED=27;this.DRAGENDED=28;this.MOVED=29;this.LEFT_BUTTON=128;this.RIGHT_BUTTON=512},function $prototype(){this.touchCounter=1;this.reset=function(target,id,ax,ay,mask,clicks){this.source=target;this.ID=id;this.absX=ax;this.absY=ay;this.mask=mask;this.clicks=clicks;var p=L.getTopParent(target);while(target!=p){ax-=target.x;ay-=target.y;target=target.parent}this.x=ax;this.y=ay};this.isActionMask=function(){return this.mask==ME.LEFT_BUTTON}},function(target,id,ax,ay,mask,clicks){this.$super(target,id,IE.MOUSE_UID);this.reset(target,id,ax,ay,mask,clicks)}]);var MDRAGGED=ME.DRAGGED,EM=null,MMOVED=ME.MOVED,MEXITED=ME.EXITED,KPRESSED=KE.PRESSED,MENTERED=ME.ENTERED,context=Object.getPrototypeOf(document.createElement("canvas").getContext("2d")),$mousePressedEvents={},$keyPressedCode=-1,$keyPressedOwner=null,$keyPressedModifiers=0,KE_STUB=new KE(null,KPRESSED,0,"x",0),ME_STUB=new ME(null,ME.PRESSED,0,0,0,1);pkg.paintManager=pkg.events=pkg.$mouseMoveOwner=null;document.addEventListener("mouseup",function(e){for(var k in $mousePressedEvents){var mp=$mousePressedEvents[k];if(mp.canvas!=null){mp.canvas.mouseReleased(k,mp)}}},false);var $alert=(function(){return this.alert}());window.alert=function(){if($keyPressedCode>0){KE_STUB.reset($keyPressedOwner,KE.RELEASED,$keyPressedCode,"",$keyPressedModifiers);EM.performInput(KE_STUB);$keyPressedCode=-1}$alert.apply(window,arguments);for(var k in $mousePressedEvents){var mp=$mousePressedEvents[k];if(mp.canvas!=null){mp.canvas.mouseReleased(k,mp)}}};context.setFont=function(f){f=(f.s!=null?f.s:f.toString());if(f!=this.font){this.font=f}};context.setColor=function(c){if(c==null){throw new Error("Null color")}c=(c.s?c.s:c.toString());if(c!=this.fillStyle){this.fillStyle=c}if(c!=this.strokeStyle){this.strokeStyle=c}};context.drawLine=function(x1,y1,x2,y2,w){if(arguments.length<5){w=1}var pw=this.lineWidth;this.beginPath();this.lineWidth=w;if(x1==x2){x1+=w/2;x2=x1}else{if(y1==y2){y1+=w/2;y2=y1}}this.moveTo(x1,y1);this.lineTo(x2,y2);this.stroke();this.lineWidth=pw};context.ovalPath=function(x,y,w,h){this.beginPath();x+=this.lineWidth;y+=this.lineWidth;w-=2*this.lineWidth;h-=2*this.lineWidth;var kappa=0.5522848,ox=(w/2)*kappa,oy=(h/2)*kappa,xe=x+w,ye=y+h,xm=x+w/2,ym=y+h/2;this.moveTo(x,ym);this.bezierCurveTo(x,ym-oy,xm-ox,y,xm,y);this.bezierCurveTo(xm+ox,y,xe,ym-oy,xe,ym);this.bezierCurveTo(xe,ym+oy,xm+ox,ye,xm,ye);this.bezierCurveTo(xm-ox,ye,x,ym+oy,x,ym)};context.polylinePath=function(xPoints,yPoints,nPoints){this.beginPath();this.moveTo(xPoints[0],yPoints[0]);for(var i=1;iMath.abs(dy)),slope=b?dy/dx:dx/dy,sign=b?(dx<0?-1:1):(dy<0?-1:1);if(b){compute=function(step){x+=step;y+=slope*step}}else{compute=function(step){x+=slope*step;y+=step}}ctx.moveTo(x,y);var dist=Math.sqrt(dx*dx+dy*dy),i=0;while(dist>=0.1){var idx=i%count;dl=distd.width-right){xx=d.width+right-ww}if(yy+hh>d.height-bottom){yy=d.height+bottom-hh}c.setLocation(xx,yy)};pkg.calcOrigin=function(x,y,w,h,px,py,t,tt,ll,bb,rr){if(arguments.length<8){tt=t.getTop();ll=t.getLeft();bb=t.getBottom();rr=t.getRight()}var dw=t.width,dh=t.height;if(dw>0&&dh>0){if(dw-ll-rr>w){var xx=x+px;if(xxdw-rr){px-=(xx-dw+rr)}}}if(dh-tt-bb>h){var yy=y+py;if(yydh-bb){py-=(yy-dh+bb)}}}return[px,py]}return[0,0]};pkg.loadImage=function(path,ready){var i=new Image();i.crossOrigin="";i.crossOrigin="anonymous";zebra.busy();if(arguments.length>1){i.onerror=function(){zebra.ready();ready(path,false,i)};i.onload=function(){zebra.ready();ready(path,true,i)}}else{i.onload=i.onerror=function(){zebra.ready()}}i.src=path;return i};pkg.Panel=Class(L.Layoutable,[function $prototype(){this.top=this.left=this.right=this.bottom=0;this.isEnabled=true;this.getCanvas=function(){var c=this;for(;c!=null&&c.$isMasterCanvas!==true;c=c.parent){}return c};this.notifyRender=function(o,n){if(o!=null&&o.ownerChanged){o.ownerChanged(null)}if(n!=null&&n.ownerChanged){n.ownerChanged(this)}};this.properties=function(p){for(var k in p){if(p.hasOwnProperty(k)){var v=p[k],m=zebra.getPropertySetter(this,k);if(v&&v.$new){v=v.$new()}if(m==null){this[k]=v}else{if(Array.isArray(v)){m.apply(this,v)}else{m.call(this,v)}}}}return this};this.load=function(jsonPath){new pkg.Bag(this).loadByUrl(jsonPath);return this};this.getComponentAt=function(x,y){var r=$cvp(this,temporary);if(r==null||(x=r.x+r.width||y>=r.y+r.height)){return null}var k=this.kids;if(k.length>0){for(var i=k.length;--i>=0;){var d=k[i];d=d.getComponentAt(x-d.x,y-d.y);if(d!=null){return d}}}return this.contains==null||this.contains(x,y)?this:null};this.vrp=function(){this.invalidate();if(this.isVisible&&this.parent!=null){this.repaint()}};this.getTop=function(){return this.border!=null?this.top+this.border.getTop():this.top};this.getLeft=function(){return this.border!=null?this.left+this.border.getLeft():this.left};this.getBottom=function(){return this.border!=null?this.bottom+this.border.getBottom():this.bottom};this.getRight=function(){return this.border!=null?this.right+this.border.getRight():this.right};this.isInvalidatedByChild=function(c){return true};this.kidAdded=function(index,constr,l){pkg.events.performComp(CL.ADDED,this,constr,l);if(l.width>0&&l.height>0){l.repaint()}else{this.repaint(l.x,l.y,1,1)}};this.kidRemoved=function(i,l){pkg.events.performComp(CL.REMOVED,this,null,l);if(l.isVisible){this.repaint(l.x,l.y,l.width,l.height)}};this.relocated=function(px,py){pkg.events.performComp(CL.MOVED,this,px,py);var p=this.parent,w=this.width,h=this.height;if(p!=null&&w>0&&h>0){var x=this.x,y=this.y,nx=xpx?x-px:px-x),h1=p.height-ny,h2=h+(y>py?y-py:py-y);pkg.paintManager.repaint(p,nx,ny,(w1pw)?this.width:pw,(this.height>ph)?this.height:ph)}};this.hasFocus=function(){return pkg.focusManager.hasFocus(this)};this.requestFocus=function(){pkg.focusManager.requestFocus(this)};this.requestFocusIn=function(timeout){if(arguments.length===0){timeout=50}var $this=this;setTimeout(function(){$this.requestFocus()},timeout)};this.setVisible=function(b){if(this.isVisible!=b){this.isVisible=b;this.invalidate();pkg.events.performComp(CL.SHOWN,this,-1,-1);if(this.parent!=null){if(b){this.repaint()}else{this.parent.repaint(this.x,this.y,this.width,this.height)}}}};this.setEnabled=function(b){if(this.isEnabled!=b){this.isEnabled=b;pkg.events.performComp(CL.ENABLED,this,-1,-1);if(this.kids.length>0){for(var i=0;i1){for(var i=0;i0&&this.height>0&&pkg.paintManager!=null){pkg.paintManager.repaint(this,x,y,w,h)}};this.removeAll=function(){if(this.kids.length>0){var size=this.kids.length,mx1=Number.MAX_VALUE,my1=mx1,mx2=0,my2=0;for(;size>0;size--){var child=this.kids[size-1];if(child.isVisible){var xx=child.x,yy=child.y;mx1=mx10){if(instanceOf(l,L.Layout)){this.setLayout(l)}else{this.properties(l)}}}}]);pkg.BaseLayer=Class(pkg.Panel,[function $prototype(){this.getFocusRoot=function(){return this};this.activate=function(b){var fo=pkg.focusManager.focusOwner;if(L.isAncestorOf(this,fo)===false){fo=null}if(b){pkg.focusManager.requestFocus(fo!=null?fo:this.pfo)}else{this.pfo=fo;pkg.focusManager.requestFocus(null)}}},function(id){if(id==null){throw new Error("Invalid layer id: "+id)}this.pfo=null;this.$super();this.id=id}]);pkg.RootLayer=Class(pkg.BaseLayer,[function $prototype(){this.layerMousePressed=function(x,y,m){return true};this.layerKeyPressed=function(code,m){return true}}]);pkg.ViewPan=Class(pkg.Panel,[function $prototype(){this.paint=function(g){if(this.view!=null){var l=this.getLeft(),t=this.getTop();this.view.paint(g,l,t,this.width-l-this.getRight(),this.height-t-this.getBottom(),this)}};this.setView=function(v){var old=this.view;v=pkg.$view(v);if(v!=old){this.view=v;this.notifyRender(old,v);this.vrp()}};this.calcPreferredSize=function(t){return this.view?this.view.getPreferredSize():{width:0,height:0}}}]);pkg.ImagePan=Class(pkg.ViewPan,[function(){this.$this(null)},function(img){this.setImage(img);this.$super()},function setImage(img){if(img&&zebra.isString(img)){var $this=this;pkg.loadImage(img,function(p,b,i){if(b){$this.setView(new pkg.Picture(i))}});return}this.setView(instanceOf(img,pkg.Picture)?img:new pkg.Picture(img))}]);pkg.Manager=Class([function(){if(pkg.events!=null&&pkg.events.addListener!=null){pkg.events.addListener(this)}}]);pkg.PaintManager=Class(pkg.Manager,[function $prototype(){var $painting={};var $timers={};this.repaint=function(c,x,y,w,h){if(arguments.length==1){x=y=0;w=c.width;h=c.height}if(w>0&&h>0&&c.isVisible===true){var r=$cvp(c,temporary);if(r==null){return}MB.intersection(r.x,r.y,r.width,r.height,x,y,w,h,r);if(r.width<=0||r.height<=0){return}x=r.x;y=r.y;w=r.width;h=r.height;var canvas=c;for(;canvas!=null&&canvas.$context==null;canvas=canvas.parent){}if(canvas!=null){var x2=canvas.width,y2=canvas.height;var cc=c;while(cc!=canvas){x+=cc.x;y+=cc.y;cc=cc.parent}if(x<0){w+=x;x=0}if(y<0){h+=y;y=0}if(w+x>x2){w=x2-x}if(h+y>y2){h=y2-y}if(w>0&&h>0){if($painting[canvas]!=null){zebra.warn("repaint called synchronously from paint, update, or paintOnTop ignored!");return}var da=canvas.$da;if($timers[canvas]!=null){if(xda.x+da.width||y+h>da.y+da.height){MB.unite(da.x,da.y,da.width,da.height,x,y,w,h,da)}return}MB.intersection(0,0,canvas.width,canvas.height,x,y,w,h,da);var $this=this;$timers[canvas]=setTimeout(function(){$timers[canvas]=null;var context=canvas.$context;$painting[canvas]=true;try{canvas.validate();context.save();context.translate(canvas.x,canvas.y);context.clipRect(canvas.$da.x,canvas.$da.y,canvas.$da.width,canvas.$da.height);if(canvas.bg==null){context.clearRect(canvas.$da.x,canvas.$da.y,canvas.$da.width,canvas.$da.height)}$this.paint(context,canvas);context.restore()}catch(e){zebra.print(e)}$painting[canvas]=null},50)}}}};this.paint=function(g,c){var dw=c.width,dh=c.height,ts=g.stack[g.counter];if(dw!==0&&dh!==0&&ts.width>0&&ts.height>0&&c.isVisible){c.validate();g.save();g.translate(c.x,c.y);g.clipRect(0,0,dw,dh);ts=g.stack[g.counter];var c_w=ts.width,c_h=ts.height;if(c_w>0&&c_h>0){this.paintComponent(g,c);var count=c.kids.length,c_x=ts.x,c_y=ts.y;for(var i=0;ic_x?kidX:c_x),ih=(kidYHc_y?kidY:c_y);if(iw>0&&ih>0){this.paint(g,kid)}}}if(c.paintOnTop!=null){c.paintOnTop(g)}}g.restore()}}}]);pkg.PaintManImpl=Class(pkg.PaintManager,[function $prototype(){this.paintComponent=function(g,c){var b=c.bg!=null&&(c.parent==null||c.bg!=c.parent.bg);if((c.border!=null&&c.border.outline!=null)&&(b||c.update!=null)&&c.border.outline(g,0,0,c.width,c.height,c)){g.save();g.clip();if(b){c.bg.paint(g,0,0,c.width,c.height,c)}if(c.update!=null){c.update(g)}g.restore()}else{if(b){c.bg.paint(g,0,0,c.width,c.height,c)}if(c.update!=null){c.update(g)}}if(c.border!=null){c.border.paint(g,0,0,c.width,c.height,c)}if(c.paint!=null){var left=c.getLeft(),top=c.getTop(),bottom=c.getBottom(),right=c.getRight();if(left+right+top+bottom>0){var ts=g.stack[g.counter];if(ts.width>0&&ts.height>0){var cx=ts.x,cy=ts.y,x1=(cx>left?cx:left),y1=(cy>top?cy:top),cxcw=cx+ts.width,cych=cy+ts.height,cright=c.width-right,cbottom=c.height-bottom;g.save();g.clipRect(x1,y1,(cxcw0){var isNComposite=(instanceOf(t,Composite)===false);for(var i=index;i>=0&&i0&&cc.height>0&&(isNComposite||(t.catchInput&&t.catchInput(cc)===false))&&((cc.canHaveFocus&&cc.canHaveFocus())||(cc=this.fd(cc,d>0?0:cc.kids.length-1,d))!=null)){return cc}}}return null};this.ff=function(c,d){var top=c;while(top&&top.getFocusRoot==null){top=top.parent}top=top.getFocusRoot();for(var index=(d>0)?0:c.kids.length-1;c!=top.parent;){var cc=this.fd(c,index,d);if(cc!=null){return cc}cc=c;c=c.parent;if(c!=null){index=d+c.indexOf(cc)}}return this.fd(top,d>0?0:top.kids.length-1,d)};this.requestFocus=function(c){if(c!=this.focusOwner&&(c==null||this.isFocusable(c))){if(c!=null){var canvas=c.getCanvas();if(canvas.$focusGainedCounter===0){canvas.$prevFocusOwner=c;if(zebra.instanceOf(canvas.$prevFocusOwner,pkg.HtmlElement)==false){canvas.requestFocus();return}}}var oldFocusOwner=this.focusOwner;if(c!=null){var nf=EM.getEventDestination(c);if(nf==null||oldFocusOwner==nf){return}this.focusOwner=nf}else{this.focusOwner=c}if(oldFocusOwner!=null){var ofc=oldFocusOwner.getCanvas();if(ofc!=null){ofc.$prevFocusOwner=oldFocusOwner}}if(oldFocusOwner!=null){pkg.events.performInput(new IE(oldFocusOwner,IE.FOCUS_LOST,IE.FOCUS_UID))}if(this.focusOwner!=null){pkg.events.performInput(new IE(this.focusOwner,IE.FOCUS_GAINED,IE.FOCUS_UID))}return this.focusOwner}return null};this.mousePressed=function(e){if(e.isActionMask()){this.requestFocus(e.source)}}}]);pkg.CommandManager=Class(pkg.Manager,KeyListener,[function $prototype(){this.keyPressed=function(e){var fo=pkg.focusManager.focusOwner;if(fo!=null&&this.keyCommands[e.code]){var c=this.keyCommands[e.code];if(c&&c[e.mask]!=null){c=c[e.mask];this._.fired(c);if(fo[c.command]){if(c.args&&c.args.length>0){fo[c.command].apply(fo,c.args)}else{fo[c.command]()}}}}};this.parseKey=function(k){var m=0,c=0,r=k.split("+");for(var i=0;i25){for(var i=0;i=0)||c.push(l)};this.r_=function(c,l){(c.indexOf(l)<0)||c.splice(i,1)}},function(){this.m_l=[];this.k_l=[];this.f_l=[];this.c_l=[];this.$super()}]);pkg.$createContext=function(canvas,w,h){var ctx=canvas.getContext("2d");var $save=ctx.save,$restore=ctx.restore,$rotate=ctx.rotate,$scale=ctx.$scale=ctx.scale,$translate=ctx.translate,$getImageData=ctx.getImageData;ctx.$ratio=$ratio/(ctx.webkitBackingStorePixelRatio||ctx.mozBackingStorePixelRatio||ctx.msBackingStorePixelRatio||ctx.backingStorePixelRatio||1);ctx.counter=0;ctx.stack=Array(50);for(var i=0;ixx?x:xx;c.width=(xwyy?y:yy;c.height=(yh0){var fo=pkg.focusManager.focusOwner;if(fo!=null){KE_STUB.reset(fo,KE.TYPED,e.keyCode,String.fromCharCode(e.charCode),km(e));if(EM.performInput(KE_STUB)){e.preventDefault()}}}if(e.keyCode<47){e.preventDefault()}};this.keyPressed=function(e){$keyPressedCode=e.keyCode;var code=e.keyCode,m=km(e),b=false;for(var i=this.kids.length-1;i>=0;i--){var l=this.kids[i];if(l.layerKeyPressed&&l.layerKeyPressed(code,m)){break}}var focusOwner=pkg.focusManager.focusOwner;if(pkg.clipboardTriggerKey>0&&e.keyCode==pkg.clipboardTriggerKey&&focusOwner!=null&&instanceOf(focusOwner,CopyCutPaste)){$clipboardCanvas=this;$clipboard.style.display="block";this.canvas.onfocus=this.canvas.onblur=null;$clipboard.value="1";$clipboard.select();$clipboard.focus();return}$keyPressedOwner=focusOwner;$keyPressedModifiers=m;if(focusOwner!=null){KE_STUB.reset(focusOwner,KPRESSED,code,code<47?KE.CHAR_UNDEFINED:"?",m);b=EM.performInput(KE_STUB);if(code==KE.ENTER){KE_STUB.reset(focusOwner,KE.TYPED,code,"\n",m);b=EM.performInput(KE_STUB)||b}}if((code<47&&code!=32)||b){e.preventDefault()}};this.keyReleased=function(e){$keyPressedCode=-1;var fo=pkg.focusManager.focusOwner;if(fo!=null){KE_STUB.reset(fo,KE.RELEASED,e.keyCode,KE.CHAR_UNDEFINED,km(e));if(EM.performInput(KE_STUB)){e.preventDefault()}}};this.mouseEntered=function(id,e){var mp=$mousePressedEvents[id];this.recalcOffset();if(mp==null||mp.canvas==null){var x=$meX(e,this),y=$meY(e,this),d=this.getComponentAt(x,y);if(pkg.$mouseMoveOwner!=null&&d!=pkg.$mouseMoveOwner){var prev=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(prev,MEXITED,x,y,-1,0);EM.performInput(ME_STUB)}if(d!=null&&d.isEnabled){pkg.$mouseMoveOwner=d;ME_STUB.reset(d,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}};this.mouseExited=function(id,e){var mp=$mousePressedEvents[id];if((mp==null||mp.canvas==null)&&pkg.$mouseMoveOwner!=null){var p=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(p,MEXITED,$meX(e,this),$meY(e,this),-1,0);EM.performInput(ME_STUB)}};this.mouseMoved=function(id,e){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){if(mp.component!=null&&mp.canvas.canvas==e.target){var x=this.$context.tX(e.pageX-this.offx,e.pageY-this.offy),y=this.$context.tY(e.pageX-this.offx,e.pageY-this.offy),m=mp.button;if(mp.draggedComponent==null){var xx=this.$context.tX(mp.pageX-this.offx,mp.pageY-this.offy),yy=this.$context.tY(mp.pageX-this.offx,mp.pageY-this.offy),d=(pkg.$mouseMoveOwner==null)?this.getComponentAt(xx,yy):pkg.$mouseMoveOwner;if(d!=null&&d.isEnabled===true){mp.draggedComponent=d;ME_STUB.reset(d,ME.DRAGSTARTED,xx,yy,m,0);EM.performInput(ME_STUB);if(xx!=x||yy!=y){ME_STUB.reset(d,MDRAGGED,x,y,m,0);EM.performInput(ME_STUB)}}}else{ME_STUB.reset(mp.draggedComponent,MDRAGGED,x,y,m,0);EM.performInput(ME_STUB)}}}else{var x=this.$context.tX(e.pageX-this.offx,e.pageY-this.offy),y=this.$context.tY(e.pageX-this.offx,e.pageY-this.offy),d=this.getComponentAt(x,y);if(pkg.$mouseMoveOwner!=null){if(d!=pkg.$mouseMoveOwner){var old=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(old,MEXITED,x,y,-1,0);EM.performInput(ME_STUB);if(d!=null&&d.isEnabled===true){pkg.$mouseMoveOwner=d;ME_STUB.reset(pkg.$mouseMoveOwner,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}else{if(d!=null&&d.isEnabled){ME_STUB.reset(d,MMOVED,x,y,-1,0);EM.performInput(ME_STUB)}}}else{if(d!=null&&d.isEnabled===true){pkg.$mouseMoveOwner=d;ME_STUB.reset(d,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}}};this.mouseReleased=function(id,e){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){var x=$meX(e,this),y=$meY(e,this),po=mp.component;if(mp.draggedComponent!=null){ME_STUB.reset(mp.draggedComponent,ME.DRAGENDED,x,y,mp.button,0);EM.performInput(ME_STUB)}if(po!=null){if(mp.draggedComponent==null&&(e.touch==null||e.touch.group==null)){ME_STUB.reset(po,ME.CLICKED,x,y,mp.button,mp.clicks);EM.performInput(ME_STUB)}ME_STUB.reset(po,ME.RELEASED,x,y,mp.button,mp.clicks);EM.performInput(ME_STUB)}if(zebra.isTouchable===false){var mo=pkg.$mouseMoveOwner;if(mp.draggedComponent!=null||(po!=null&&po!=mo)){var nd=this.getComponentAt(x,y);if(nd!=mo){if(mo!=null){ME_STUB.reset(mo,MEXITED,x,y,-1,0);EM.performInput(ME_STUB)}if(nd!=null&&nd.isEnabled===true){pkg.$mouseMoveOwner=nd;ME_STUB.reset(nd,MENTERED,x,y,-1,0);EM.performInput(ME_STUB)}}}}$mousePressedEvents[id].canvas=null}};this.mousePressed=function(id,e,button){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){this.mouseReleased(id,mp)}var clicks=mp!=null&&(new Date().getTime()-mp.time)<=pkg.doubleClickDelta?2:1;mp=$mousePressedEvents[id]={pageX:e.pageX,pageY:e.pageY,identifier:id,target:e.target,canvas:this,button:button,component:null,mouseDragged:null,time:(new Date()).getTime(),clicks:clicks};var x=$meX(e,this),y=$meY(e,this);mp.x=x;mp.y=y;for(var i=this.kids.length-1;i>=0;i--){var l=this.kids[i];if(l.layerMousePressed!=null&&l.layerMousePressed(x,y,button)){break}}var d=this.getComponentAt(x,y);if(d!=null&&d.isEnabled===true){mp.component=d;ME_STUB.reset(d,ME.PRESSED,x,y,button,clicks);EM.performInput(ME_STUB)}if(document.activeElement!=this.canvas){this.canvas.focus()}};this.getComponentAt=function(x,y){for(var i=this.kids.length;--i>=0;){var tl=this.kids[i];if(tl.isLayerActiveAt==null||tl.isLayerActiveAt(x,y)){return EM.getEventDestination(tl.getComponentAt(x,y))}}return null};this.recalcOffset=function(){var poffx=this.offx,poffy=this.offy,ba=this.canvas.getBoundingClientRect();this.offx=((ba.left+0.5)|0)+measure(this.canvas,"padding-left")+window.pageXOffset;this.offy=((ba.top+0.5)|0)+measure(this.canvas,"padding-top")+window.pageYOffset;if(this.offx!=poffx||this.offy!=poffy){this.relocated(this,poffx,poffy)}};this.getLayer=function(id){return this[id]};this.setStyles=function(styles){for(var k in styles){this.canvas.style[k]=styles[k]}};this.setAttribute=function(name,value){this.canvas.setAttribute(name,value)};this.relocated=function(px,py){pkg.events.performComp(CL.MOVED,this,px,py)};this.resized=function(pw,ph){pkg.events.performComp(CL.SIZED,this,pw,ph)};this.repaint=function(x,y,w,h){if((document.contains!=null&&document.contains(this.canvas)===false)||this.canvas.style.visibility=="hidden"){return}if(arguments.length===0){x=y=0;w=this.width;h=this.height}if(w>0&&h>0&&pkg.paintManager!=null){pkg.paintManager.repaint(this,x,y,w,h)}}},function(){this.$this(400,400)},function(w,h){this.$this(this.toString(),w,h)},function(canvas){this.$this(canvas,-1,-1)},function(canvas,w,h){this.$focusGainedCounter=0;var pc=canvas,$this=this;this.nativeListeners={onmousemove:null,onmousedown:null,onmouseup:null,onmouseover:null,onmouseout:null,onkeydown:null,onkeyup:null,onkeypress:null};var addToBody=true;if(zebra.isBoolean(canvas)){addToBody=canvas;canvas=null}else{if(zebra.isString(canvas)){canvas=document.getElementById(canvas);if(canvas!=null&&pkg.$detectZCanvas(canvas)){throw new Error("Canvas id='"+pc+"'' is already in use")}}}if(canvas==null){canvas=document.createElement("canvas");canvas.setAttribute("class","zebcanvas");canvas.setAttribute("width",w<=0?"400":""+w);canvas.setAttribute("height",h<=0?"400":""+h);canvas.setAttribute("id",pc);if(addToBody){document.body.appendChild(canvas)}}if(canvas.getAttribute("tabindex")===null){canvas.setAttribute("tabindex","1")}this.$da={x:0,y:0,width:-1,height:0};this.canvas=canvas;this.$super(new pkg.zCanvas.Layout());for(var i=0;i0){e.preventDefault();return}if(pkg.focusManager.canvasFocusGained){pkg.focusManager.canvasFocusGained($this)}};this.canvas.onblur=function(e){if(document.activeElement==$this.canvas){e.preventDefault();return}if($this.$focusGainedCounter!==0){$this.$focusGainedCounter=0;if(pkg.focusManager.canvasFocusLost){pkg.focusManager.canvasFocusLost($this)}}};var addons=pkg.zCanvas.addons;if(addons){for(var i=0;i0){$configurators.shift()(pkg.$configuration)}pkg.$configuration.end();EM=pkg.events;if(pkg.clipboardTriggerKey>0){$clipboard=document.createElement("textarea");$clipboard.setAttribute("style","display:none; position: absolute; left: -99em; top:-99em;");$clipboard.onkeydown=function(ee){$clipboardCanvas.keyPressed(ee);$clipboard.value="1";$clipboard.select()};$clipboard.onkeyup=function(ee){if(ee.keyCode==pkg.clipboardTriggerKey){$clipboard.style.display="none";$clipboardCanvas.canvas.focus();$clipboardCanvas.canvas.onblur=$clipboardCanvas.focusLost;$clipboardCanvas.canvas.onfocus=$clipboardCanvas.focusGained}$clipboardCanvas.keyReleased(ee)};$clipboard.onblur=function(){this.value="";this.style.display="none";$clipboardCanvas.canvas.focus()};$clipboard.oncopy=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.copy){var v=pkg.focusManager.focusOwner.copy();$clipboard.value=v==null?"":v;$clipboard.select()}};$clipboard.oncut=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.cut){$clipboard.value=pkg.focusManager.focusOwner.cut();$clipboard.select()}};if(zebra.isFF){$clipboard.addEventListener("input",function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.paste){pkg.focusManager.focusOwner.paste($clipboard.value)}},false)}else{$clipboard.onpaste=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.paste){var txt=(typeof ee.clipboardData=="undefined")?window.clipboardData.getData("Text"):ee.clipboardData.getData("text/plain");pkg.focusManager.focusOwner.paste(txt)}$clipboard.value=""}}document.body.appendChild($clipboard)}document.addEventListener("DOMNodeInserted",function(e){elBoundsUpdated()},false);document.addEventListener("DOMNodeRemoved",function(e){elBoundsUpdated();for(var i=$canvases.length-1;i>=0;i--){var canvas=$canvases[i];if(e.target==canvas.canvas){$canvases.splice(i,1);if(canvas.saveBeforeLeave){canvas.saveBeforeLeave()}break}}},false);window.addEventListener("resize",function(e){elBoundsUpdated()},false);window.onbeforeunload=function(e){var msgs=[];for(var i=$canvases.length-1;i>=0;i--){if($canvases[i].saveBeforeLeave){var m=$canvases[i].saveBeforeLeave();if(m!=null){msgs.push(m)}}}if(msgs.length>0){var message=msgs.join(" ");if(typeof e==="undefined"){e=window.event}if(e){e.returnValue=message}return message}};if(zebra.isIE){window.focus()}}catch(e){zebra.error(e.toString());throw e}finally{zebra.ready()}})})(zebra("ui"),zebra.Class,zebra.Interface);(function(pkg,Class){var PI4=Math.PI/4,PI4_3=PI4*3,$abs=Math.abs,$atan2=Math.atan2,L=zebra.layout;pkg.TouchHandler=Class([function $prototype(){this.touchCounter=0;this.start=function(e){if(this.touchCounter>e.touches.length){return}if(this.timer==null){var $this=this;this.timer=setTimeout(function(){$this.Q();$this.timer=null},25)}var t=e.touches;for(var i=0;i1){for(var i=0;i0){for(var i=0;i0&&t.dx>0),dys=(dy<0&&t.dy<0)||(dy>0&&t.dy>0);t.pageX=nmt.pageX;t.pageY=nmt.pageY;if($abs(dx)>2||$abs(dy)>2){gamma=$atan2(dy,dx);if(gamma>-PI4){d=(gamma-PI4_3)?L.TOP:L.LEFT}if(t.direction!=d){if(t.dc<3){t.direction=d}t.dc=0}else{t.dc++}t.gamma=gamma}if($this.timer==null){t.dx=dx;t.dy=dy;$this.moved(t)}else{$this.dc=0}}}}e.preventDefault()},false)}}])})(zebra("ui"),zebra.Class);(function(pkg,Class,Interface){pkg.ExternalEditor=Interface();var MB=zebra.util,Composite=pkg.Composite,ME=pkg.MouseEvent,MouseListener=pkg.MouseListener,Cursor=pkg.Cursor,TextModel=zebra.data.TextModel,View=pkg.View,Listeners=zebra.util.Listeners,Actionable=zebra.util.Actionable,KE=pkg.KeyEvent,L=zebra.layout,instanceOf=zebra.instanceOf,timer=zebra.util.timer,KeyListener=pkg.KeyListener,ChildrenListener=pkg.ChildrenListener,$invalidA="Invalid alignment",$invalidO="Invalid orientation",$invalidC="Invalid constraints";pkg.$ViewsSetter=function(v){this.views={};for(var k in v){if(v.hasOwnProperty(k)){this.views[k]=pkg.$view(v[k])}}this.vrp()};pkg.MouseWheelSupport=Class([function $prototype(){this.mouseWheelMoved=function(e){var owner=pkg.$mouseMoveOwner;while(owner!=null&&instanceOf(owner,pkg.ScrollPan)===false){owner=owner.parent}if(owner!=null){var d=[0,0];d[0]=(e.detail?e.detail:e.wheelDelta/120);if(e.axis){if(e.axis===e.HORIZONTAL_AXIS){d[1]=d[0];d[0]=0}}if(d[0]>1){d[0]=~~(d[0]/3)}if(!e.detail){d[0]=-d[0]}for(var i=0;i<2;i++){if(d[i]!==0){var bar=i===0?owner.vBar:owner.hBar;if(bar&&bar.isVisible){bar.position.setOffset(bar.position.offset+d[i]*bar.pageIncrement)}}}e.preventDefault?e.preventDefault():e.returnValue=false}}},function setup(canvas){if(canvas==null){throw new Error("Null canvas")}var $this=this;canvas.canvas.addEventListener("mousewheel",function(e){$this.mouseWheelMoved(e)},false);canvas.canvas.addEventListener("DOMMouseScroll",function(e){$this.mouseWheelMoved(e)},false)}]);pkg.CompRender=Class(pkg.Render,[function $prototype(){this.getPreferredSize=function(){return this.target==null?{width:0,height:0}:this.target.getPreferredSize()};this.paint=function(g,x,y,w,h,d){var c=this.target;if(c!=null){c.validate();var prevW=-1,prevH=0,cx=x-c.x,cy=y-c.y;if(c.getCanvas()==null){prevW=c.width;prevH=c.height;c.setSize(w,h)}g.translate(cx,cy);pkg.paintManager.paint(g,c);g.translate(-cx,-cy);if(prevW>=0){c.setSize(prevW,prevH);c.validate()}}}}]);pkg.Line=Class(pkg.Panel,[function(){this.$this(L.VERTICAL)},function(orient){orient=L.$constraints(orient);if(orient!=L.HORIZONTAL&&orient!=L.VERTICAL){throw new Error($invalidO)}this.orient=orient;this.$super()},function $prototype(){this.lineWidth=1;this.lineColor="black";this.paint=function(g){g.setColor(this.lineColor);if(this.orient==L.HORIZONTAL){var yy=this.top+~~((this.height-this.top-this.bottom-1)/2);g.drawLine(this.left,yy,this.width-this.right-this.left,yy,this.lineWidth)}else{var xx=this.left+~~((this.width-this.left-this.right-1)/2);g.drawLine(xx,this.top,xx,this.height-this.top-this.bottom,this.lineWidth)}};this.getPreferredSize=function(){return{width:this.lineWidth,height:this.lineWidth}}}]);pkg.TextRender=Class(pkg.Render,zebra.util.Position.Metric,[function $prototype(){this.owner=null;this.getLineIndent=function(){return 1};this.getLines=function(){return this.target.getLines()};this.getLineSize=function(l){return this.target.getLine(l).length+1};this.getLineHeight=function(l){return this.font.height};this.getMaxOffset=function(){return this.target.getTextLength()};this.ownerChanged=function(v){this.owner=v};this.paintLine=function(g,x,y,line,d){g.fillText(this.getLine(line),x,y+this.font.ascent)};this.getLine=function(r){return this.target.getLine(r)};this.targetWasChanged=function(o,n){if(o!=null){o._.remove(this)}if(n!=null){n._.add(this);this.invalidate(0,this.getLines())}else{this.lines=0}};this.getValue=function(){var text=this.target;return text==null?null:text.getValue()};this.lineWidth=function(line){this.recalc();return this.target.getExtraChar(line)};this.recalc=function(){if(this.lines>0&&this.target!=null){var text=this.target;if(text!=null){if(this.lines>0){for(var i=this.startLine+this.lines-1;i>=this.startLine;i--){text.setExtraChar(i,this.font.stringWidth(this.getLine(i)))}this.startLine=this.lines=0}this.textWidth=0;var size=text.getLines();for(var i=0;ithis.textWidth){this.textWidth=len}}this.textHeight=this.getLineHeight()*size+(size-1)*this.getLineIndent()}}};this.textUpdated=function(src,b,off,size,ful,updatedLines){if(b===false){if(this.lines>0){var p1=ful-this.startLine,p2=this.startLine+this.lines-ful-updatedLines;this.lines=((p1>0)?p1:0)+((p2>0)?p2:0)+1;this.startLine=this.startLine0){if(ful<=this.startLine){this.startLine+=(updatedLines-1)}else{if(ful<(this.startLine+size)){size+=(updatedLines-1)}}}this.invalidate(ful,updatedLines)}};this.invalidate=function(start,size){if(size>0&&(this.startLine!=start||size!=this.lines)){if(this.lines===0){this.startLine=start;this.lines=size}else{var e=this.startLine+this.lines;this.startLine=start0&&ts.height>0){var lineIndent=this.getLineIndent(),lineHeight=this.getLineHeight(),lilh=lineHeight+lineIndent,startLine=0;w=ts.width(ts.y+ts.height)){return}}var size=this.target.getLines();if(startLinelineIndent)?1:0);if(startLine+lines>size){lines=size-startLine}y+=startLine*lilh;g.setFont(this.font);if(d==null||d.isEnabled===true){g.setColor(this.color);for(var i=0;i=p1[0]&&line<=p2[0]){var s=this.getLine(line),lw=this.lineWidth(line),xx=x;if(line==p1[0]){var ww=this.font.charsWidth(s,0,p1[1]);xx+=ww;lw-=ww;if(p1[0]==p2[0]){lw-=this.font.charsWidth(s,p2[1],s.length-p2[1])}}else{if(line==p2[0]){lw=this.font.charsWidth(s,0,p2[1])}}this.paintSelection(g,xx,y,lw===0?1:lw,lilh,line,d);g.setColor(this.color)}}}this.paintLine(g,x,y,i+startLine,d);y+=lilh}}else{for(var i=0;i0){buf[ln.length-1]=ln[ln.length-1]}return buf.join("")}]);pkg.TabBorder=Class(View,[function(t){this.$this(t,1)},function(t,w){this.type=t;this.gap=4+w;this.width=w;this.onColor1=pkg.palette.black;this.onColor2=pkg.palette.gray5;this.offColor=pkg.palette.gray1;this.fillColor1="#DCF0F7";this.fillColor2=pkg.palette.white;this.fillColor3=pkg.palette.gray7},function $prototype(){this.paint=function(g,x,y,w,h,d){var xx=x+w-1,yy=y+h-1,o=d.parent.orient,t=this.type,s=this.width,dt=s/2;if(d.isEnabled){g.setColor(t==2?this.fillColor1:this.fillColor2);g.fillRect(x+1,y,w-3,h);g.setColor(this.fillColor3);g.fillRect(x+1,y+2,w-3,~~((h-6)/2))}g.setColor((t===0||t==2)?this.onColor1:this.offColor);switch(o){case L.LEFT:g.drawLine(x+2,y,xx+1,y);g.drawLine(x,y+2,x,yy-2);g.drawLine(x,y+2,x+2,y);g.drawLine(x+2,yy,xx+1,yy);g.drawLine(x,yy-2,x+2,yy);if(t==1){g.setColor(this.onColor2);g.drawLine(x+2,yy-1,xx,yy-1);g.drawLine(x+2,yy,xx,yy)}break;case L.RIGHT:g.drawLine(x,y,xx-2,y);g.drawLine(xx-2,y,xx,y+2);g.drawLine(xx,y+2,xx,yy-2);g.drawLine(xx,yy-2,xx-2,yy);g.drawLine(x,yy,xx-2,yy);if(t==1){g.setColor(this.onColor2);g.drawLine(xx-2,yy-1,x,yy-1);g.drawLine(xx-2,yy,x,yy)}break;case L.TOP:g.lineWidth=s;g.beginPath();g.moveTo(x+dt,yy+1);g.lineTo(x+dt,y+dt+2);g.lineTo(x+dt+2,y+dt);g.lineTo(xx-dt-1,y+dt);g.lineTo(xx-dt+1,y+dt+2);g.lineTo(xx-dt+1,yy+1);g.stroke();if(t===0){g.setColor(this.onColor2);g.beginPath();g.moveTo(xx-dt-2,y+dt+1);g.lineTo(xx-dt,y+dt+3);g.lineTo(xx-dt,yy-dt+1);g.stroke()}g.lineWidth=1;break;case L.BOTTOM:g.drawLine(x+2,yy,xx-2,yy);g.drawLine(x,yy-2,x,y-2);g.drawLine(xx,yy-2,xx,y-2);g.drawLine(x,yy-2,x+2,yy);g.drawLine(xx,yy-2,xx-2,yy);if(t==1){g.setColor(this.onColor2);g.drawLine(xx-1,yy-2,xx-1,y-2);g.drawLine(xx,yy-2,xx,y-2)}break;default:throw new Error("Invalid tab orientation")}};this.getTop=function(){return 3};this.getBottom=function(){return 2}}]);pkg.TitledBorder=Class(pkg.Render,[function $prototype(){this.getTop=function(){return this.target.getTop()};this.getLeft=function(){return this.target.getLeft()};this.getRight=function(){return this.target.getRight()};this.getBottom=function(){return this.target.getBottom()};this.outline=function(g,x,y,w,h,d){var xx=x+w,yy=y+h;if(d.getTitleInfo){var r=d.getTitleInfo();if(r!=null){var o=r.orient,cx=x,cy=y;if(o==L.BOTTOM||o==L.TOP){switch(this.lineAlignment){case L.CENTER:cy=r.y+~~(r.height/2);break;case L.TOP:cy=r.y+(o==L.BOTTOM?1:0)*(r.height-1);break;case L.BOTTOM:cy=r.y+(o==L.BOTTOM?0:1)*(r.height-1);break}if(o==L.BOTTOM){yy=cy}else{y=cy}}else{switch(this.lineAlignment){case L.CENTER:cx=r.x+~~(r.width/2);break;case L.TOP:cx=r.x+((o==L.RIGHT)?1:0)*(r.width-1);break;case L.BOTTOM:cx=r.x+((o==L.RIGHT)?0:1)*(r.width-1);break}if(o==L.RIGHT){xx=cx}else{x=cx}}}}if(this.target&&this.target.outline){return this.target.outline(g,x,y,xx-x,yy-y,d)}g.rect(x,y,xx-x,yy-y);return true};this.paint=function(g,x,y,w,h,d){if(d.getTitleInfo){var r=d.getTitleInfo();if(r!=null){var xx=x+w,yy=y+h,o=r.orient;g.save();g.beginPath();var br=(o==L.RIGHT),bb=(o==L.BOTTOM),dt=(bb||br)?-1:1;if(bb||o==L.TOP){var sy=y,syy=yy,cy=0;switch(this.lineAlignment){case L.CENTER:cy=r.y+~~(r.height/2);break;case L.TOP:cy=r.y+(bb?1:0)*(r.height-1);break;case L.BOTTOM:cy=r.y+(bb?0:1)*(r.height-1);break}if(bb){sy=yy;syy=y}g.moveTo(r.x+1,sy);g.lineTo(r.x+1,r.y+dt*(r.height));g.lineTo(r.x+r.width-1,r.y+dt*(r.height));g.lineTo(r.x+r.width-1,sy);g.lineTo(xx,sy);g.lineTo(xx,syy);g.lineTo(x,syy);g.lineTo(x,sy);g.lineTo(r.x,sy);if(bb){yy=cy}else{y=cy}}else{var sx=x,sxx=xx,cx=0;if(br){sx=xx;sxx=x}switch(this.lineAlignment){case L.CENTER:cx=r.x+~~(r.width/2);break;case L.TOP:cx=r.x+(br?1:0)*(r.width-1);break;case L.BOTTOM:cx=r.x+(br?0:1)*(r.width-1);break}g.moveTo(sx,r.y);g.lineTo(r.x+dt*(r.width),r.y);g.lineTo(r.x+dt*(r.width),r.y+r.height-1);g.lineTo(sx,r.y+r.height-1);g.lineTo(sx,yy);g.lineTo(sxx,yy);g.lineTo(sxx,y);g.lineTo(sx,y);g.lineTo(sx,r.y);if(br){xx=cx}else{x=cx}}g.clip();this.target.paint(g,x,y,xx-x,yy-y,d);g.restore()}}else{this.target.paint(g,x,y,w,h,d)}}},function(border){this.$this(border,L.BOTTOM)},function(b,a){a=L.$constraints(a);if(b==null&&a!=L.BOTTOM&&a!=L.TOP&&a!=L.CENTER){throw new Error($invalidA)}this.$super(b);this.lineAlignment=a}]);pkg.Label=Class(pkg.ViewPan,[function $prototype(){this.getValue=function(){return this.view.getValue()};this.getColor=function(){return this.view.color};this.setModel=function(m){this.setView(new pkg.TextRender(m))};this.getFont=function(){return this.view.font};this.setText=function(s){this.setValue(s)};this.getText=function(){return this.getValue()};this.setValue=function(s){this.view.setValue(s);this.repaint()};this.setColor=function(c){if(this.view.setColor(c)){this.repaint()}return this};this.setFont=function(f){if(f==null){throw new Error("Null font")}if(this.view.font!=f){this.view.setFont(f);this.repaint()}return this}},function(){this.$this("")},function(r){if(zebra.isString(r)){r=new zebra.data.SingleLineTxt(r)}this.setView(instanceOf(r,TextModel)?new pkg.TextRender(r):r);this.$super()}]);pkg.MLabel=Class(pkg.Label,[function(){this.$this("")},function(t){this.$super(new zebra.data.Text(t))}]);pkg.BoldLabel=Class(pkg.Label,[]);pkg.ImageLabel=Class(pkg.Panel,[function(txt,img){this.$super(new L.FlowLayout(L.LEFT,L.CENTER,L.HORIZONTAL,6));this.add(new pkg.ImagePan(img));this.add(new pkg.Label(txt))}]);var OVER=0,PRESSED_OVER=1,OUT=2,PRESSED_OUT=3,DISABLED=4;pkg.StatePan=Class(pkg.ViewPan,Composite,MouseListener,KeyListener,[function $clazz(){this.OVER=OVER;this.PRESSED_OVER=PRESSED_OVER;this.OUT=OUT;this.PRESSED_OUT=PRESSED_OUT;this.DISABLED=DISABLED},function $prototype(){var IDS=["over","pressed.over","out","pressed.out","disabled"];this.state=OUT;this.isCanHaveFocus=false;this.focusComponent=null;this.focusMarkerView=null;this.$isIn=false;this.idByState=function(s){return IDS[s]};this.updateState=function(s){if(s!=this.state){var prev=this.state;this.state=s;this.stateUpdated(prev,s)}};this.stateUpdated=function(o,n){var id=this.idByState(n),b=false;for(var i=0;i=0&&e.y>=0&&e.x0&&e.y>0&&e.x0){timer.start(this,400,this.firePeriod)}}}else{if(this.firePeriod>0&&timer.get(this)!=null){timer.stop(this)}if(n==OVER&&(o==PRESSED_OVER&&this.isFireByPress===false)){this.fire()}}}]);pkg.BorderPan=Class(pkg.Panel,[function $clazz(){this.Label=Class(pkg.Label,[])},function $prototype(){this.vGap=this.hGap=0;this.indent=4;this.getTitleInfo=function(){return(this.label!=null)?{x:this.label.x,y:this.label.y,width:this.label.width,height:this.label.height,orient:this.label.constraints&(L.TOP|L.BOTTOM)}:null};this.calcPreferredSize=function(target){var ps=this.center!=null&&this.center.isVisible?this.center.getPreferredSize():{width:0,height:0};if(this.label!=null&&this.label.isVisible){var lps=this.label.getPreferredSize();ps.height+=lps.height;ps.width=Math.max(ps.width,lps.width+this.indent)}ps.width+=(this.hGap*2);ps.height+=(this.vGap*2);return ps};this.doLayout=function(target){var h=0,right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),xa=this.label?this.label.constraints&(L.LEFT|L.CENTER|L.RIGHT):0,ya=this.label?this.label.constraints&(L.BOTTOM|L.TOP):0;if(this.label!=null&&this.label.isVisible){var ps=this.label.getPreferredSize();h=ps.height;this.label.setSize(ps.width,h);this.label.setLocation((xa==L.LEFT)?left+this.indent:((xa==L.RIGHT)?this.width-right-ps.width-this.indent:~~((this.width-ps.width)/2)),(ya==L.BOTTOM)?(this.height-bottom-ps.height):top)}if(this.center!=null&&this.center.isVisible){this.center.setLocation(left+this.hGap,(ya==L.BOTTOM?top:top+h)+this.vGap);this.center.setSize(this.width-right-left-2*this.hGap,this.height-top-bottom-h-2*this.vGap)}};this.setGaps=function(vg,hg){if(this.vGap!=vg||hg!=this.hGap){this.vGap=vg;this.hGap=hg;this.vrp()}}},function(title){this.$this(title,null)},function(){this.$this(null)},function(title,center){this.$this(title,center,L.TOP|L.LEFT)},function(title,center,ctr){if(zebra.isString(title)){title=new pkg.BorderPan.Label(title)}this.label=this.center=null;this.$super();if(title!=null){this.add(L.$constraints(ctr),title)}if(center!=null){this.add(L.CENTER,center)}},function kidAdded(index,id,lw){this.$super(index,id,lw);if(L.CENTER==id){this.center=lw}else{this.label=lw}},function kidRemoved(index,lw){this.$super(index,lw);if(lw==this.label){this.label=null}else{this.center=null}}]);pkg.SwitchManager=Class([function $prototype(){this.getState=function(o){return this.state};this.setState=function(o,b){if(this.getState(o)!=b){this.state=b;this.updated(o,b)}};this.updated=function(o,b){if(o!=null){o.switched(b)}this._.fired(this,o)};this.install=function(o){o.switched(this.getState(o))};this.uninstall=function(o){};this[""]=function(){this.state=false;this._=new Listeners()}}]);pkg.Group=Class(pkg.SwitchManager,[function(){this.$super();this.state=null},function $prototype(){this.getState=function(o){return o==this.state};this.setState=function(o,b){if(this.getState(o)!=b){this.clearSelected();this.state=o;this.updated(o,true)}};this.clearSelected=function(){if(this.state!=null){var old=this.state;this.state=null;this.updated(old,false)}}}]);pkg.Checkbox=Class(pkg.StatePan,[function $clazz(){var IDS=["on.out","off.out","don","doff","on.over","off.over"];this.Box=Class(pkg.ViewPan,[function parentStateUpdated(o,n,id){this.view.activate(id);this.repaint()}]);this.Label=Class(pkg.Label,[])},function $prototype(){this.setValue=function(b){return this.setState(b)};this.getValue=function(){return this.getState()};this.setState=function(b){this.manager.setState(this,b);return this};this.getState=function(){return this.manager?this.manager.getState(this):false};this.switched=function(b){this.stateUpdated(this.state,this.state)};this.idByState=function(state){if(this.isEnabled){if(this.getState()){return(this.state==OVER)?"on.over":"on.out"}return(this.state==OVER)?"off.over":"off.out"}return this.getState()?"don":"doff"}},function(){this.$this(null)},function(c){this.$this(c,new pkg.SwitchManager())},function(c,m){var clazz=this.$clazz;if(zebra.isString(c)){c=clazz.Label?new clazz.Label(c):new pkg.Checkbox.Label(c)}this.$super();this.box=clazz.Box?new clazz.Box():new pkg.Checkbox.Box();this.add(this.box);if(c!=null){this.add(c);this.setFocusAnchorComponent(c)}this.setSwitchManager(m)},function keyPressed(e){if(instanceOf(this.manager,pkg.Group)&&this.getState()){var code=e.code,d=0;if(code==KE.LEFT||code==KE.UP){d=-1}else{if(code==KE.RIGHT||code==KE.DOWN){d=1}}if(d!==0){var p=this.parent,idx=p.indexOf(this);for(var i=idx+d;i=0;i+=d){var l=p.kids[i];if(l.isVisible&&l.isEnabled&&instanceOf(l,pkg.Checkbox)&&l.manager==this.manager){l.requestFocus();l.setState(true);break}}return}}this.$super(e)},function setSwitchManager(m){if(m==null){throw new Error("Null switch manager")}if(this.manager!=m){if(this.manager!=null){this.manager.uninstall(this)}this.manager=m;this.manager.install(this)}},function stateUpdated(o,n){if(o==PRESSED_OVER&&n==OVER){this.setState(!this.getState())}this.$super(o,n)},function kidRemoved(index,c){if(this.box==c){this.box=null}this.$super(index,c)}]);pkg.Radiobox=Class(pkg.Checkbox,[function $clazz(){this.Box=Class(pkg.Checkbox.Box,[]);this.Label=Class(pkg.Checkbox.Label,[])},function(c){this.$this(c,new pkg.Group())},function(c,group){this.$super(c,group)}]);pkg.SplitPan=Class(pkg.Panel,[function $clazz(){this.Bar=Class(pkg.StatePan,MouseListener,[function $prototype(){this.mouseDragged=function(e){var x=this.x+e.x,y=this.y+e.y;if(this.target.orientation==L.VERTICAL){if(this.prevLoc!=x){x=this.target.normalizeBarLoc(x);if(x>0){this.prevLoc=x;this.target.setGripperLoc(x)}}}else{if(this.prevLoc!=y){y=this.target.normalizeBarLoc(y);if(y>0){this.prevLoc=y;this.target.setGripperLoc(y)}}}};this.mouseDragStarted=function(e){var x=this.x+e.x,y=this.y+e.y;if(e.isActionMask()){if(this.target.orientation==L.VERTICAL){x=this.target.normalizeBarLoc(x);if(x>0){this.prevLoc=x}}else{y=this.target.normalizeBarLoc(y);if(y>0){this.prevLoc=y}}}};this.mouseDragEnded=function(e){var xy=this.target.normalizeBarLoc(this.target.orientation==L.VERTICAL?this.x+e.x:this.y+e.y);if(xy>0){this.target.setGripperLoc(xy)}};this.getCursorType=function(t,x,y){return this.target.orientation==L.VERTICAL?Cursor.W_RESIZE:Cursor.N_RESIZE}},function(target){this.prevLoc=0;this.target=target;this.$super()}])},function $prototype(){this.leftMinSize=this.rightMinSize=50;this.isMoveable=true;this.gap=1;this.normalizeBarLoc=function(xy){if(xythis.maxXY){xy=this.maxXY}}return(xy>this.maxXY||xysSize.width)?fSize.width:sSize.width),bSize.width);bSize.height=fSize.height+sSize.height+bSize.height+2*this.gap}else{bSize.width=fSize.width+sSize.width+bSize.width+2*this.gap;bSize.height=Math.max(((fSize.height>sSize.height)?fSize.height:sSize.height),bSize.height)}return bSize};this.doLayout=function(target){var right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),bSize=pkg.getPreferredSize(this.gripper);if(this.orientation==L.HORIZONTAL){var w=this.width-left-right;if(this.barLocationthis.height-bottom-bSize.height){this.barLocation=this.height-bottom-bSize.height}}if(this.gripper!=null){if(this.isMoveable){this.gripper.setLocation(left,this.barLocation);this.gripper.setSize(w,bSize.height)}else{this.gripper.setSize(bSize.width,bSize.height);this.gripper.toPreferredSize();this.gripper.setLocation(~~((w-bSize.width)/2),this.barLocation)}}if(this.leftComp!=null){this.leftComp.setLocation(left,top);this.leftComp.setSize(w,this.barLocation-this.gap-top)}if(this.rightComp!=null){this.rightComp.setLocation(left,this.barLocation+bSize.height+this.gap);this.rightComp.setSize(w,this.height-this.rightComp.y-bottom)}}else{var h=this.height-top-bottom;if(this.barLocationthis.width-right-bSize.width){this.barLocation=this.width-right-bSize.width}}if(this.gripper!=null){if(this.isMoveable){this.gripper.setLocation(this.barLocation,top);this.gripper.setSize(bSize.width,h)}else{this.gripper.setSize(bSize.width,bSize.height);this.gripper.setLocation(this.barLocation,~~((h-bSize.height)/2))}}if(this.leftComp!=null){this.leftComp.setLocation(left,top);this.leftComp.setSize(this.barLocation-left-this.gap,h)}if(this.rightComp!=null){this.rightComp.setLocation(this.barLocation+bSize.width+this.gap,top);this.rightComp.setSize(this.width-this.rightComp.x-right,h)}}};this.setGap=function(g){if(this.gap!=g){this.gap=g;this.vrp()}};this.setLeftMinSize=function(m){if(this.leftMinSize!=m){this.leftMinSize=m;this.vrp()}};this.setRightMinSize=function(m){if(this.rightMinSize!=m){this.rightMinSize=m;this.vrp()}};this.setGripperMovable=function(b){if(b!=this.isMoveable){this.isMoveable=b;this.vrp()}}},function(){this.$this(null,null,L.VERTICAL)},function(f,s){this.$this(f,s,L.VERTICAL)},function(f,s,o){this.minXY=this.maxXY=0;this.barLocation=70;this.leftComp=this.rightComp=this.gripper=null;this.orientation=L.$constraints(o);this.$super();if(f!=null){this.add(L.LEFT,f)}if(s!=null){this.add(L.RIGHT,s)}this.add(L.CENTER,new pkg.SplitPan.Bar(this))},function kidAdded(index,id,c){this.$super(index,id,c);if(L.LEFT==id){this.leftComp=c}else{if(L.RIGHT==id){this.rightComp=c}else{if(L.CENTER==id){this.gripper=c}else{throw new Error($invalidC)}}}},function kidRemoved(index,c){this.$super(index,c);if(c==this.leftComp){this.leftComp=null}else{if(c==this.rightComp){this.rightComp=null}else{if(c==this.gripper){this.gripper=null}}}},function resized(pw,ph){var ps=this.gripper.getPreferredSize();if(this.orientation==L.VERTICAL){this.minXY=this.getLeft()+this.gap+this.leftMinSize;this.maxXY=this.width-this.gap-this.rightMinSize-ps.width-this.getRight()}else{this.minXY=this.getTop()+this.gap+this.leftMinSize;this.maxXY=this.height-this.gap-this.rightMinSize-ps.height-this.getBottom()}this.$super(pw,ph)}]);pkg.Progress=Class(pkg.Panel,Actionable,[function $prototype(){this.gap=2;this.orientation=L.HORIZONTAL;this.paint=function(g){var left=this.getLeft(),right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),rs=(this.orientation==L.HORIZONTAL)?this.width-left-right:this.height-top-bottom,bundleSize=(this.orientation==L.HORIZONTAL)?this.bundleWidth:this.bundleHeight;if(rs>=bundleSize){var vLoc=~~((rs*this.value)/this.maxValue),x=left,y=this.height-bottom,bundle=this.bundleView,wh=this.orientation==L.HORIZONTAL?this.height-top-bottom:this.width-left-right;while(x<(vLoc+left)&&this.height-vLoc-bottom=0?this.bundleHeight:ps.height)}:{width:(this.bundleWidth>=0?this.bundleWidth:ps.width),height:v1};if(this.titleView!=null){var tp=this.titleView.getPreferredSize();ps.width=Math.max(ps.width,tp.width);ps.height=Math.max(ps.height,tp.height)}return ps}},function(){this.value=0;this.setBundleView("darkBlue");this.bundleWidth=this.bundleHeight=6;this.maxValue=20;this._=new Listeners();this.$super()},function setOrientation(o){o=L.$constraints(o);if(o!=L.HORIZONTAL&&o!=L.VERTICAL){throw new Error($invalidO)}if(o!=this.orientation){this.orientation=o;this.vrp()}},function setMaxValue(m){if(m!=this.maxValue){this.maxValue=m;this.setValue(this.value);this.vrp()}},function setValue(p){p=p%(this.maxValue+1);if(this.value!=p){var old=this.value;this.value=p;this._.fired(this,old);this.repaint()}},function setGap(g){if(this.gap!=g){this.gap=g;this.vrp()}},function setBundleView(v){if(this.bundleView!=v){this.bundleView=pkg.$view(v);this.vrp()}},function setBundleSize(w,h){if(w!=this.bundleWidth&&h!=this.bundleHeight){this.bundleWidth=w;this.bundleHeight=h;this.vrp()}}]);pkg.Link=Class(pkg.Button,[function $prototype(){this.cursorType=Cursor.HAND},function(s){this.$super(null);var font=this.$clazz.font;if(font==null){font=pkg.Link.font}this.setView(new pkg.TextRender(s));this.view.setFont(font);this.stateUpdated(this.state,this.state)},function setColor(state,c){if(this.colors[state]!=c){this.colors[state]=c;this.stateUpdated(state,state)}},function stateUpdated(o,n){this.$super(o,n);var r=this.view;if(r&&r.color!=this.colors[n]){r.setColor(this.colors[n]);this.repaint()}}]);pkg.Extender=Class(pkg.Panel,[function $prototype(){this.toggle=function(){this.isCollapsed=this.isCollapsed?false:true;this.contentPan.setVisible(!this.isCollapsed);this.togglePan.view.activate(this.isCollapsed?"off":"on");this.repaint();if(this._){this._.fired(this,this.isCollapsed)}}},function $clazz(){this.Label=Class(pkg.Label,[]);this.TitlePan=Class(pkg.Panel,[]);this.TogglePan=Class(pkg.ViewPan,MouseListener,[function $prototype(){this.mousePressed=function(e){if(e.isActionMask()){this.parent.parent.toggle()}};this.setViews=function(v){this.setView(new pkg.ViewSet(v))};this.cursorType=Cursor.HAND}])},function(content,lab){this.isCollapsed=true;this.$super();if(zebra.isString(lab)){lab=new pkg.Extender.Label(lab)}this.label=lab;this.titlePan=new pkg.Extender.TitlePan();this.add(L.TOP,this.titlePan);this.togglePan=new pkg.Extender.TogglePan();this.titlePan.add(this.togglePan);this.titlePan.add(this.label);this.contentPan=content;this.contentPan.setVisible(!this.isCollapsed);this.add(L.CENTER,this.contentPan);this.toggle();this._=new Listeners()}]);var ScrollManagerListeners=Listeners.Class("scrolled");pkg.ScrollManager=Class([function $prototype(){this.getSX=function(){return this.sx};this.getSY=function(){return this.sy};this.scrollXTo=function(v){this.scrollTo(v,this.getSY())};this.scrollYTo=function(v){this.scrollTo(this.getSX(),v)};this.scrollTo=function(x,y){var psx=this.getSX(),psy=this.getSY();if(psx!=x||psy!=y){this.sx=x;this.sy=y;if(this.updated){this.updated(x,y,psx,psy)}if(this.target.catchScrolled){this.target.catchScrolled(psx,psy)}this._.scrolled(psx,psy)}};this.makeVisible=function(x,y,w,h){var p=pkg.calcOrigin(x,y,w,h,this.getSX(),this.getSY(),this.target);this.scrollTo(p[0],p[1])}},function(c){this.sx=this.sy=0;this._=new ScrollManagerListeners();this.target=c}]);pkg.Scroll=Class(pkg.Panel,MouseListener,zebra.util.Position.Metric,Composite,[function $clazz(){var SB=Class(pkg.Button,[function $prototype(){this.isDragable=this.isFireByPress=true;this.firePeriod=20}]);this.VIncButton=Class(SB,[]);this.VDecButton=Class(SB,[]);this.HIncButton=Class(SB,[]);this.HDecButton=Class(SB,[]);this.VBundle=Class(pkg.Panel,[]);this.HBundle=Class(pkg.Panel,[]);this.MIN_BUNDLE_SIZE=16},function $prototype(){this.extra=this.max=100;this.pageIncrement=20;this.unitIncrement=5;this.isInBundle=function(x,y){var bn=this.bundle;return(bn!=null&&bn.isVisible&&bn.x<=x&&bn.y<=y&&bn.x+bn.width>x&&bn.y+bn.height>y)};this.amount=function(){var db=this.decBt,ib=this.incBt;return(this.type==L.VERTICAL)?ib.y-db.y-db.height:ib.x-db.x-db.width};this.pixel2value=function(p){var db=this.decBt;return(this.type==L.VERTICAL)?~~((this.max*(p-db.y-db.height))/(this.amount()-this.bundle.height)):~~((this.max*(p-db.x-db.width))/(this.amount()-this.bundle.width))};this.value2pixel=function(){var db=this.decBt,bn=this.bundle,off=this.position.offset;return(this.type==L.VERTICAL)?db.y+db.height+~~(((this.amount()-bn.height)*off)/this.max):db.x+db.width+~~(((this.amount()-bn.width)*off)/this.max)};this.catchInput=function(child){return child==this.bundle||(this.bundle.kids.length>0&&L.isAncestorOf(this.bundle,child))};this.posChanged=function(target,po,pl,pc){if(this.bundle!=null){if(this.type==L.HORIZONTAL){this.bundle.setLocation(this.value2pixel(),this.getTop())}else{this.bundle.setLocation(this.getLeft(),this.value2pixel())}}};this.getLines=function(){return this.max};this.getLineSize=function(line){return 1};this.getMaxOffset=function(){return this.max};this.fired=function(src){this.position.setOffset(this.position.offset+((src==this.incBt)?this.unitIncrement:-this.unitIncrement))};this.mouseDragged=function(e){if(Number.MAX_VALUE!=this.startDragLoc){this.position.setOffset(this.pixel2value(this.bundleLoc-this.startDragLoc+((this.type==L.HORIZONTAL)?e.x:e.y)))}};this.mouseDragStarted=function(e){this.startDragLoc=this.type==L.HORIZONTAL?e.x:e.y;this.bundleLoc=this.type==L.HORIZONTAL?this.bundle.x:this.bundle.y};this.mouseDragEnded=function(e){this.startDragLoc=Number.MAX_VALUE};this.mouseClicked=function(e){if(this.isInBundle(e.x,e.y)===false&&e.isActionMask()){var d=this.pageIncrement;if(this.type==L.VERTICAL){if(e.y<(this.bundle!=null?this.bundle.y:~~(this.height/2))){d=-d}}else{if(e.x<(this.bundle!=null?this.bundle.x:~~(this.width/2))){d=-d}}this.position.setOffset(this.position.offset+d)}};this.calcPreferredSize=function(target){var ps1=pkg.getPreferredSize(this.incBt),ps2=pkg.getPreferredSize(this.decBt),ps3=pkg.getPreferredSize(this.bundle);if(this.type==L.HORIZONTAL){ps1.width+=(ps2.width+ps3.width);ps1.height=Math.max((ps1.height>ps2.height?ps1.height:ps2.height),ps3.height)}else{ps1.height+=(ps2.height+ps3.height);ps1.width=Math.max((ps1.width>ps2.width?ps1.width:ps2.width),ps3.width)}return ps1};this.doLayout=function(target){var right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),ew=this.width-left-right,eh=this.height-top-bottom,b=(this.type==L.HORIZONTAL),ps1=pkg.getPreferredSize(this.decBt),ps2=pkg.getPreferredSize(this.incBt),minbs=pkg.Scroll.MIN_BUNDLE_SIZE;this.decBt.setSize(b?ps1.width:ew,b?eh:ps1.height);this.decBt.setLocation(left,top);this.incBt.setSize(b?ps2.width:ew,b?eh:ps2.height);this.incBt.setLocation(b?this.width-right-ps2.width:left,b?top:this.height-bottom-ps2.height);if(this.bundle!=null&&this.bundle.isVisible){var am=this.amount();if(am>minbs){var bsize=Math.max(Math.min(~~((this.extra*am)/this.max),am-minbs),minbs);this.bundle.setSize(b?bsize:ew,b?eh:bsize);this.bundle.setLocation(b?this.value2pixel():left,b?top:this.value2pixel())}else{this.bundle.setSize(0,0)}}};this.setMaximum=function(m){if(m!=this.max){this.max=m;if(this.position.offset>this.max){this.position.setOffset(this.max)}this.vrp()}};this.setPosition=function(p){if(p!=this.position){if(this.position!=null){this.position._.remove(this)}this.position=p;if(this.position!=null){this.position._.add(this);this.position.setMetric(this);this.position.setOffset(0)}}};this.setExtraSize=function(e){if(e!=this.extra){this.extra=e;this.vrp()}}},function(t){if(t!=L.VERTICAL&&t!=L.HORIZONTAL){throw new Error($invalidA)}this.incBt=this.decBt=this.bundle=this.position=null;this.bundleLoc=this.type=0;this.startDragLoc=Number.MAX_VALUE;this.$super(this);this.add(L.CENTER,t==L.VERTICAL?new pkg.Scroll.VBundle():new pkg.Scroll.HBundle());this.add(L.TOP,t==L.VERTICAL?new pkg.Scroll.VDecButton():new pkg.Scroll.HDecButton());this.add(L.BOTTOM,t==L.VERTICAL?new pkg.Scroll.VIncButton():new pkg.Scroll.HIncButton());this.type=t;this.setPosition(new zebra.util.Position(this))},function kidAdded(index,id,lw){this.$super(index,id,lw);if(L.CENTER==id){this.bundle=lw}else{if(L.BOTTOM==id){this.incBt=lw;this.incBt._.add(this)}else{if(L.TOP==id){this.decBt=lw;this.decBt._.add(this)}else{throw new Error($invalidC)}}}},function kidRemoved(index,lw){this.$super(index,lw);if(lw==this.bundle){this.bundle=null}else{if(lw==this.incBt){this.incBt._.remove(this);this.incBt=null}else{if(lw==this.decBt){this.decBt._.remove(this);this.decBt=null}}}}]);pkg.ScrollPan=Class(pkg.Panel,[function $clazz(){this.ContentPan=Class(pkg.Panel,[function(c){this.$super(new L.RasterLayout(L.USE_PS_SIZE));this.scrollManager=new pkg.ScrollManager(c,[function $prototype(){this.getSX=function(){return this.target.x};this.getSY=function(){return this.target.y};this.updated=function(sx,sy,psx,psy){this.target.setLocation(sx,sy)}}]);this.add(c)}])},function $prototype(){this.autoHide=false;this.$interval=0;this.setAutoHide=function(b){if(this.autoHide!=b){this.autoHide=b;if(this.hBar!=null){if(this.hBar.incBt!=null){this.hBar.incBt.setVisible(!b)}if(this.hBar.decBt!=null){this.hBar.decBt.setVisible(!b)}}if(this.vBar!=null){if(this.vBar.incBt!=null){this.vBar.incBt.setVisible(!b)}if(this.vBar.decBt!=null){this.vBar.decBt.setVisible(!b)}}if(this.$interval!=0){clearInterval(this.$interval);$this.$interval=0}this.vrp()}};this.scrolled=function(psx,psy){try{this.validate();this.isPosChangedLocked=true;if(this.hBar!=null){this.hBar.position.setOffset(-this.scrollObj.scrollManager.getSX())}if(this.vBar!=null){this.vBar.position.setOffset(-this.scrollObj.scrollManager.getSY())}if(this.scrollObj.scrollManager==null){this.invalidate()}}catch(e){throw e}finally{this.isPosChangedLocked=false}};this.calcPreferredSize=function(target){return pkg.getPreferredSize(this.scrollObj)};this.doLayout=function(target){var sman=(this.scrollObj==null)?null:this.scrollObj.scrollManager,right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),ww=this.width-left-right,maxH=ww,hh=this.height-top-bottom,maxV=hh,so=this.scrollObj.getPreferredSize(),vps=this.vBar==null?{width:0,height:0}:this.vBar.getPreferredSize(),hps=this.hBar==null?{width:0,height:0}:this.hBar.getPreferredSize();if(this.hBar!=null&&this.autoHide===false&&(so.width>ww||(so.height>hh&&so.width>(ww-vps.width)))){maxV-=hps.height}maxV=so.height>maxV?(so.height-maxV):-1;if(this.vBar!=null&&this.autoHide===false&&(so.height>hh||(so.width>ww&&so.height>(hh-hps.height)))){maxH-=vps.width}maxH=so.width>maxH?(so.width-maxH):-1;var sy=sman.getSY(),sx=sman.getSX();if(this.vBar!=null){if(maxV<0){if(this.vBar.isVisible){this.vBar.setVisible(false);sman.scrollTo(sx,0);this.vBar.position.setOffset(0)}sy=0}else{this.vBar.setVisible(true)}}if(this.hBar!=null){if(maxH<0){if(this.hBar.isVisible){this.hBar.setVisible(false);sman.scrollTo(0,sy);this.hBar.position.setOffset(0)}}else{this.hBar.setVisible(true)}}if(this.scrollObj.isVisible){this.scrollObj.setLocation(left,top);this.scrollObj.setSize(ww-(this.autoHide===false&&this.vBar!=null&&this.vBar.isVisible?vps.width:0),hh-(this.autoHide===false&&this.hBar!=null&&this.hBar.isVisible?hps.height:0))}if(this.$interval===0&&this.autoHide){hps.height=vps.width=1}if(this.hBar!=null&&this.hBar.isVisible){this.hBar.setLocation(left,this.height-bottom-hps.height);this.hBar.setSize(ww-(this.vBar!=null&&this.vBar.isVisible?vps.width:0),hps.height);this.hBar.setMaximum(maxH)}if(this.vBar!=null&&this.vBar.isVisible){this.vBar.setLocation(this.width-right-vps.width,top);this.vBar.setSize(vps.width,hh-(this.hBar!=null&&this.hBar.isVisible?hps.height:0));this.vBar.setMaximum(maxV)}};this.posChanged=function(target,prevOffset,prevLine,prevCol){if(this.isPosChangedLocked===false){if(this.autoHide){this.$dontHide=true;if(this.$interval===0&&((this.vBar!=null&&this.vBar.isVisible)||(this.hBar!=null&&this.hBar.isVisible))){var $this=this;if(this.vBar){this.vBar.toFront()}if(this.hBar){this.hBar.toFront()}this.vrp();this.$interval=setInterval(function(){if($this.$dontHide||($this.vBar!=null&&pkg.$mouseMoveOwner==$this.vBar)||($this.hBar!=null&&pkg.$mouseMoveOwner==$this.hBar)){$this.$dontHide=false}else{clearInterval($this.$interval);$this.$interval=0;$this.doLayout()}},500)}}if(this.vBar!=null&&this.vBar.position==target){this.scrollObj.scrollManager.scrollYTo(-this.vBar.position.offset)}else{if(this.hBar!=null){this.scrollObj.scrollManager.scrollXTo(-this.hBar.position.offset)}}}}},function(){this.$this(null,L.HORIZONTAL|L.VERTICAL)},function(c){this.$this(c,L.HORIZONTAL|L.VERTICAL)},function(c,barMask){this.hBar=this.vBar=this.scrollObj=null;this.isPosChangedLocked=false;this.$super();if((L.HORIZONTAL&barMask)>0){this.add(L.BOTTOM,new pkg.Scroll(L.HORIZONTAL))}if((L.VERTICAL&barMask)>0){this.add(L.RIGHT,new pkg.Scroll(L.VERTICAL))}if(c!=null){this.add(L.CENTER,c)}},function setIncrements(hUnit,hPage,vUnit,vPage){if(this.hBar!=null){if(hUnit!=-1){this.hBar.unitIncrement=hUnit}if(hPage!=-1){this.hBar.pageIncrement=hPage}}if(this.vBar!=null){if(vUnit!=-1){this.vBar.unitIncrement=vUnit}if(vPage!=-1){this.vBar.pageIncrement=vPage}}},function insert(i,ctr,c){if(L.CENTER==ctr&&c.scrollManager==null){c=new pkg.ScrollPan.ContentPan(c)}return this.$super(i,ctr,c)},function kidAdded(index,id,comp){this.$super(index,id,comp);if(L.CENTER==id){this.scrollObj=comp;this.scrollObj.scrollManager._.add(this)}if(L.BOTTOM==id||L.TOP==id){this.hBar=comp;this.hBar.position._.add(this)}else{if(L.LEFT==id||L.RIGHT==id){this.vBar=comp;this.vBar.position._.add(this)}}},function kidRemoved(index,comp){this.$super(index,comp);if(comp==this.scrollObj){this.scrollObj.scrollManager._.remove(this);this.scrollObj=null}else{if(comp==this.hBar){this.hBar.position._.remove(this);this.hBar=null}else{if(comp==this.vBar){this.vBar.position._.remove(this);this.vBar=null}}}}]);pkg.Tabs=Class(pkg.Panel,MouseListener,KeyListener,[function $prototype(){this.mouseMoved=function(e){var i=this.getTabAt(e.x,e.y);if(this.overTab!=i){this.overTab=i;if(this.views.tabover!=null){this.repaint(this.tabAreaX,this.tabAreaY,this.tabAreaWidth,this.tabAreaHeight)}}};this.mouseDragEnded=function(e){var i=this.getTabAt(e.x,e.y);if(this.overTab!=i){this.overTab=i;if(this.views.tabover!=null){this.repaint(this.tabAreaX,this.tabAreaY,this.tabAreaWidth,this.tabAreaHeight)}}};this.mouseExited=function(e){if(this.overTab>=0){this.overTab=-1;if(this.views.tabover!=null){this.repaint(this.tabAreaX,this.tabAreaY,this.tabAreaWidth,this.tabAreaHeight)}}};this.next=function(page,d){for(;page>=0&&page<~~(this.pages.length/2);page+=d){if(this.isTabEnabled(page)){return page}}return -1};this.getTitleInfo=function(){var b=(this.orient==L.LEFT||this.orient==L.RIGHT),res=b?{x:this.tabAreaX,y:0,width:this.tabAreaWidth,height:0,orient:this.orient}:{x:0,y:this.tabAreaY,width:0,height:this.tabAreaHeight,orient:this.orient};if(this.selectedIndex>=0){var r=this.getTabBounds(this.selectedIndex);if(b){res[1]=r.y;res[3]=r.height}else{res[0]=r.x;res[2]=r.width}}return res};this.canHaveFocus=function(){return true};this.getTabView=function(index){var data=this.pages[2*index];if(data.paint){return data}this.render.target.setValue(data.toString());return this.render};this.isTabEnabled=function(index){return this.kids[index].isEnabled};this.paint=function(g){if(this.selectedIndex>0){var r=this.getTabBounds(this.selectedIndex)}for(var i=0;i=0){var r=this.getTabBounds(this.selectedIndex)}for(var i=this.selectedIndex+1;i<~~(this.pages.length/2);i++){this.paintTab(g,i)}if(this.selectedIndex>=0){this.paintTab(g,this.selectedIndex);if(this.hasFocus()){this.drawMarker(g,this.getTabBounds(this.selectedIndex))}}};this.drawMarker=function(g,r){var marker=this.views.marker;if(marker!=null){var bv=this.views.tab;marker.paint(g,r.x+bv.getLeft(),r.y+bv.getTop(),r.width-bv.getLeft()-bv.getRight(),r.height-bv.getTop()-bv.getBottom(),this)}};this.paintTab=function(g,pageIndex){var b=this.getTabBounds(pageIndex),page=this.kids[pageIndex],vs=this.views,tab=vs.tab,tabover=vs.tabover,tabon=vs.tabon;if(this.selectedIndex==pageIndex&&tabon!=null){tabon.paint(g,b.x,b.y,b.width,b.height,page)}else{tab.paint(g,b.x,b.y,b.width,b.height,page)}if(this.overTab>=0&&this.overTab==pageIndex&&tabover!=null){tabover.paint(g,b.x,b.y,b.width,b.height,page)}var v=this.getTabView(pageIndex),ps=v.getPreferredSize(),px=b.x+L.xAlignment(ps.width,L.CENTER,b.width),py=b.y+L.yAlignment(ps.height,L.CENTER,b.height);v.paint(g,px,py,ps.width,ps.height,page);if(this.selectedIndex==pageIndex){v.paint(g,px+1,py,ps.width,ps.height,page)}};this.getTabBounds=function(i){return this.pages[2*i+1]};this.calcPreferredSize=function(target){var max=L.getMaxPreferredSize(target);if(this.orient==L.BOTTOM||this.orient==L.TOP){max.width=Math.max(2*this.sideSpace+max.width,this.tabAreaWidth);max.height+=this.tabAreaHeight}else{max.width+=this.tabAreaWidth;max.height=Math.max(2*this.sideSpace+max.height,this.tabAreaHeight)}max.width+=(this.hgap*2);max.height+=(this.vgap*2);return max};this.doLayout=function(target){var right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),b=(this.orient==L.TOP||this.orient==L.BOTTOM);if(b){this.tabAreaX=left;this.tabAreaY=(this.orient==L.TOP)?top:this.height-bottom-this.tabAreaHeight}else{this.tabAreaX=(this.orient==L.LEFT)?left:this.width-right-this.tabAreaWidth;this.tabAreaY=top}var count=~~(this.pages.length/2),sp=2*this.sideSpace,xx=b?(this.tabAreaX+this.sideSpace):((this.orient==L.LEFT)?(this.tabAreaX+this.upperSpace):this.tabAreaX+1),yy=b?(this.orient==L.TOP?this.tabAreaY+this.upperSpace:this.tabAreaY+1):(this.tabAreaY+this.sideSpace);for(var i=0;i=0){var r=this.getTabBounds(this.selectedIndex),dt=0;if(b){r.x-=this.sideSpace;r.y-=(this.orient==L.TOP)?this.upperSpace:this.brSpace;dt=(r.xthis.width-right)?this.width-right-r.x-r.width:0}else{r.x-=(this.orient==L.LEFT)?this.upperSpace:this.brSpace;r.y-=this.sideSpace;dt=(r.ythis.height-bottom)?this.height-bottom-r.y-r.height:0}for(var i=0;i0){this.tabAreaHeight=this.tabAreaWidth=0;var bv=this.views.tab,b=(this.orient==L.LEFT||this.orient==L.RIGHT),max=0,hadd=2*this.hTabGap+bv.getLeft()+bv.getRight(),vadd=2*this.vTabGap+bv.getTop()+bv.getBottom();for(var i=0;imax){max=ps.width+hadd}this.tabAreaHeight+=r.height}else{r.width=ps.width+hadd;if(ps.height+vadd>max){max=ps.height+vadd}this.tabAreaWidth+=r.width}}for(var i=0;i=0){var r=this.getTabBounds(this.selectedIndex);if(b){r.height+=2*this.sideSpace;r.width+=(this.brSpace+this.upperSpace)}else{r.height+=(this.brSpace+this.upperSpace);r.width+=2*this.sideSpace}}}};this.getTabAt=function(x,y){this.validate();if(x>=this.tabAreaX&&y>=this.tabAreaY&&x=tb.x&&y>=tb.y&&x0){switch(e.code){case KE.UP:case KE.LEFT:var nxt=this.next(this.selectedIndex-1,-1);if(nxt>=0){this.select(nxt)}break;case KE.DOWN:case KE.RIGHT:var nxt=this.next(this.selectedIndex+1,1);if(nxt>=0){this.select(nxt)}break}}};this.mouseClicked=function(e){if(e.isActionMask()){var index=this.getTabAt(e.x,e.y);if(index>=0&&this.isTabEnabled(index)){this.select(index)}}};this.select=function(index){if(this.selectedIndex!=index){this.selectedIndex=index;this._.fired(this,this.selectedIndex);this.vrp()}};this.setTitle=function(pageIndex,data){if(this.pages[2*pageIndex]!=data){this.pages[pageIndex*2]=data;this.vrp()}};this.setTabSpaces=function(vg,hg,sideSpace,upperSpace,brSpace){if(this.vTabGap!=vg||this.hTabGap!=hg||sideSpace!=this.sideSpace||upperSpace!=this.upperSpace||brSpace!=this.brSpace){this.vTabGap=vg;this.hTabGap=hg;this.sideSpace=sideSpace;this.upperSpace=upperSpace;this.brSpace=brSpace;this.vrp()}};this.setGaps=function(vg,hg){if(this.vgap!=vg||hg!=this.hgap){this.vgap=vg;this.hgap=hg;this.vrp()}};this.setTitleAlignment=function(o){o=L.$constraints(o);if(o!=L.TOP&&o!=L.BOTTOM&&o!=L.LEFT&&o!=L.RIGHT){throw new Error($invalidA)}if(this.orient!=o){this.orient=o;this.vrp()}};this.enableTab=function(i,b){var c=this.kids[i];if(c.isEnabled!=b){c.setEnabled(b);if(b===false&&this.selectedIndex==i){this.select(-1)}this.repaint()}}},function(){this.$this(L.TOP)},function(o){this.brSpace=this.upperSpace=this.vgap=this.hgap=this.tabAreaX=0;this.hTabGap=this.vTabGap=this.sideSpace=1;this.tabAreaY=this.tabAreaWidth=this.tabAreaHeight=0;this.overTab=this.selectedIndex=-1;this.orient=L.$constraints(o);this._=new Listeners();this.pages=[];this.views={};this.render=new pkg.TextRender(new zebra.data.SingleLineTxt(""));if(pkg.Tabs.font!=null){this.render.setFont(pkg.Tabs.font)}if(pkg.Tabs.fontColor!=null){this.render.setColor(pkg.Tabs.fontColor)}this.$super();this.setTitleAlignment(o)},function focused(){this.$super();if(this.selectedIndex>=0){var r=this.getTabBounds(this.selectedIndex);this.repaint(r.x,r.y,r.width,r.height)}else{if(!this.hasFocus()){this.select(this.next(0,1))}}},function insert(index,constr,c){this.pages.splice(index*2,0,constr==null?"Page "+index:constr,{x:0,y:0,width:0,height:0});var r=this.$super(index,constr,c);if(this.selectedIndex<0){this.select(this.next(0,1))}return r},function removeAt(i){if(this.selectedIndex==i){this.select(-1)}this.pages.splice(i*2,2);this.$super(i)},function removeAll(){if(this.selectedIndex>=0){this.select(-1)}this.pages.splice(0,this.pages.length);this.pages.length=0;this.$super()},function setSize(w,h){if(this.width!=w||this.height!=h){if(this.orient==L.RIGHT||this.orient==L.BOTTOM){this.tabAreaX=-1}this.$super(w,h)}}]);pkg.Tabs.prototype.setViews=pkg.$ViewsSetter;pkg.Slider=Class(pkg.Panel,KeyListener,MouseListener,Actionable,[function $prototype(){this.max=this.min=this.value=this.roughStep=this.exactStep=0;this.netSize=this.gap=3;this.correctDt=this.scaleStep=this.psW=this.psH=0;this.intervals=this.pl=null;this.paintNums=function(g,loc){if(this.isShowTitle){for(var i=0;ithis.max){v=this.max}else{if(vsl+ss){xy=sl+ss}}return this.min+~~(((this.max-this.min)*(xy-sl))/ss)};this.nextValue=function(value,s,d){if(this.isIntervalMode){return this.getNeighborPoint(value,d)}var v=value+(d*s);if(v>this.max){v=this.max}else{if(vright){return right}}if(d>0){var start=this.min;for(var i=0;iv){return start}}return right}else{var start=right;for(var i=this.intervals.length-1;i>=0;i--){if(start0){for(var i=0;ihMax){hMax=d.height}if(d.width>wMax){wMax=d.width}}}if(this.orient==L.HORIZONTAL){this.psW=dt*2+ps.width;this.psH=ps.height+ns+hMax}else{this.psW=ps.width+ns+wMax;this.psH=dt*2+ps.height}};this.setValue=function(v){if(vthis.max){throw new Error("Value is out of bounds: "+v)}var prev=this.value;if(this.value!=v){this.value=v;this._.fired(this,prev);this.repaint()}};this.getPointValue=function(i){var v=this.min+this.intervals[0];for(var j=0;j=this.min){this.setValue(v)}break;case KE.DOWN:case KE.RIGHT:var v=this.nextValue(this.value,this.exactStep,1);if(v<=this.max){this.setValue(v)}break;case KE.HOME:this.setValue(b?this.getPointValue(0):this.min);break;case KE.END:this.setValue(b?this.getPointValue(this.intervals.length-1):this.max);break}};this.mousePressed=function(e){if(e.isActionMask()){var x=e.x,y=e.y,bb=this.getBundleBounds(this.value);if(x=bb.x+bb.width||y>=bb.y+bb.height){var l=((this.orient==L.HORIZONTAL)?x:y),v=this.loc2value(l);if(this.value!=v){this.setValue(this.isJumpOnPress?v:this.nextValue(this.value,this.roughStep,v=r.x&&e.y>=r.y&&e.x=max||min+roughStep>max||min+exactStep>max){throw new Error("Invalid values")}for(var i=0,start=min;imax||intervals[i]<0){throw new Error()}}this.min=min;this.max=max;this.roughStep=roughStep;this.exactStep=exactStep;this.intervals=Array(intervals.length);for(var i=0;imax){this.setValue(this.isIntervalMode?min+intervals[0]:min)}this.vrp()},function invalidate(){this.pl=null;this.$super()}]);pkg.Slider.prototype.setViews=pkg.$ViewsSetter;pkg.StatusBar=Class(pkg.Panel,[function(){this.$this(2)},function(gap){this.setPaddings(gap,0,0,0);this.$super(new L.PercentLayout(Layout.HORIZONTAL,gap))},function setBorderView(v){if(v!=this.borderView){this.borderView=v;for(var i=0;i0?isDec:false;this.stretched=arguments.length>1?str:false}},function $prototype(){var OVER="over",OUT="out",PRESSED="pressed";this.isDecorative=function(c){return c.constraints.isDecorative};this.childInputEvent=function(e){if(e.UID==pkg.InputEvent.MOUSE_UID){var dc=L.getDirectChild(this,e.source);if(this.isDecorative(dc)===false){switch(e.ID){case ME.ENTERED:this.select(dc,true);break;case ME.EXITED:if(this.selected!=null&&L.isAncestorOf(this.selected,e.source)){this.select(null,true)}break;case ME.PRESSED:this.select(this.selected,false);break;case ME.RELEASED:this.select(this.selected,true);break}}}};this.recalc=function(){var v=this.views,vover=v[OVER],vpressed=v[PRESSED];this.leftShift=Math.max(vover!=null&&vover.getLeft?vover.getLeft():0,vpressed!=null&&vpressed.getLeft?vpressed.getLeft():0);this.rightShift=Math.max(vover!=null&&vover.getRight?vover.getRight():0,vpressed!=null&&vpressed.getRight?vpressed.getRight():0);this.topShift=Math.max(vover!=null&&vover.getTop?vover.getTop():0,vpressed!=null&&vpressed.getTop?vpressed.getTop():0);this.bottomShift=Math.max(vover!=null&&vover.getBottom?vover.getBottom():0,vpressed!=null&&vpressed.getBottom?vpressed.getBottom():0)};this.paint=function(g){for(var i=0;i0?this.gap:0));h=ps.height>h?ps.height:h}else{w=ps.width>w?ps.width:w;h+=(ps.height+(c>0?this.gap:0))}c++}}return{width:(b?w+c*(this.leftShift+this.rightShift):w+this.topShift+this.bottomShift),height:(b?h+this.leftShift+this.rightShift:h+c*(this.topShift+this.bottomShift))}};this.doLayout=function(t){var b=(this.orient==L.HORIZONTAL),x=t.getLeft(),y=t.getTop(),av=this.topShift+this.bottomShift,ah=this.leftShift+this.rightShift,hw=b?t.height-y-t.getBottom():t.width-x-t.getRight();for(var i=0;i=-1&&$this.$dt<=1)){clearInterval($this.timer);$this.timer=$this.target=null}},40)}};this.mousePressed=function(e){if(this.timer!=null){clearInterval(this.timer);this.timer=null}this.target=null}}]);pkg.configure(function(conf){var p=zebra()["ui.json"];conf.loadByUrl(p?p:pkg.$url.join("ui.json"),false)})})(zebra("ui"),zebra.Class,zebra.Interface);(function(pkg,Class){var ME=pkg.MouseEvent,KE=pkg.KeyEvent,PO=zebra.util.Position;pkg.TextField=Class(pkg.Label,pkg.KeyListener,pkg.MouseListener,pkg.FocusListener,pkg.CopyCutPaste,[function $clazz(){this.TextPosition=Class(PO,[function(render){this.$super(render);render.target._.add(this)},function $prototype(){this.textUpdated=function(src,b,off,size,startLine,lines){if(b===true){this.inserted(off,size)}else{this.removed(off,size)}}},function destroy(){this.metrics.target._.remove(this)}])},function $prototype(){this.selectionColor=this.curView=this.position=null;this.blinkingPeriod=-1;this.blinkMe=true;this.blinkMeCounter=0;this.cursorType=pkg.Cursor.TEXT;this.isEditable=true;this.setBlinking=function(period){if(period!=this.blinkingPeriod){this.blinkingPeriod=period;this.repaintCursor()}};this.getTextRowColAt=function(x,y){var size=this.view.target.getLines();if(size===0){return null}var lh=this.view.getLineHeight(),li=this.view.getLineIndent(),ln=(y<0)?0:~~((y+li)/(lh+li))+((y+li)%(lh+li)>li?1:0)-1;if(ln>=size){return[size-1,this.view.getLine(size-1).length]}else{if(ln<0){return[0,0]}}if(x<0){return[ln,0]}var x1=0,x2=0,s=this.view.getLine(ln);for(var c=0;c=x1&&x=t.getLines()){return null}var ln=t.getLine(line);col+=d;if(col<0&&line>0){return[line-1,t.getLine(line-1).length]}else{if(col>ln.length&&line=0&&col0){if(zebra.util.isLetter(ln[col])){return[line,col]}}else{if(!zebra.util.isLetter(ln[col])){return[line,col+1]}}}else{b=d>0?!zebra.util.isLetter(ln[col]):zebra.util.isLetter(ln[col])}}return(d>0?[line,ln.length]:[line,0])};this.getSubString=function(r,start,end){var res=[],sr=start[0],er=end[0],sc=start[1],ec=end[1];for(var i=sr;ithis.endOff?this.startOff:this.endOff)-start);this.clearSelection()}};this.startSelection=function(){if(this.startOff<0){var pos=this.position;this.endLine=this.startLine=pos.currentLine;this.endCol=this.startCol=pos.currentCol;this.endOff=this.startOff=pos.offset}};this.keyTyped=function(e){if(e.isControlPressed()||e.isCmdPressed()||this.isEditable===false||(e.ch=="\n"&&zebra.instanceOf(this.view.target,zebra.data.SingleLineTxt))){return}this.removeSelected();this.write(this.position.offset,e.ch)};this.selectAll_command=function(){this.select(0,this.position.metrics.getMaxOffset())};this.nextWord_command=function(b,d){if(b){this.startSelection()}var p=this.findNextWord(this.view.target,this.position.currentLine,this.position.currentCol,d);if(p!=null){this.position.setRowCol(p[0],p[1])}};this.nextPage_command=function(b,d){if(b){this.startSelection()}this.position.seekLineTo(d==1?PO.DOWN:PO.UP,this.pageSize())};this.keyPressed=function(e){if(this.isFiltered(e)){return}var position=this.position,col=position.currentCol,isShiftDown=e.isShiftPressed(),line=position.currentLine,foff=1;if(isShiftDown&&e.ch==KE.CHAR_UNDEFINED){this.startSelection()}switch(e.code){case KE.DOWN:position.seekLineTo(PO.DOWN);break;case KE.UP:position.seekLineTo(PO.UP);break;case KE.LEFT:foff=-1;case KE.RIGHT:if(e.isControlPressed()===false&&e.isCmdPressed()===false){position.seek(foff)}break;case KE.END:if(e.isControlPressed()){position.seekLineTo(PO.DOWN,position.metrics.getLines()-line-1)}else{position.seekLineTo(PO.END)}break;case KE.HOME:if(e.isControlPressed()){position.seekLineTo(PO.UP,line)}else{position.seekLineTo(PO.BEG)}break;case KE.DELETE:if(this.hasSelection()&&this.isEditable){this.removeSelected()}else{if(this.isEditable){this.remove(position.offset,1)}}break;case KE.BSPACE:if(this.isEditable){if(this.hasSelection()){this.removeSelected()}else{if(this.isEditable&&position.offset>0){position.seek(-1);this.remove(position.offset,1)}}}break;default:return}if(isShiftDown===false){this.clearSelection()}};this.isFiltered=function(e){var code=e.code;return code==KE.SHIFT||code==KE.CTRL||code==KE.TAB||code==KE.ALT||(e.mask&KE.M_ALT)>0};this.remove=function(pos,size){if(this.isEditable){var position=this.position;if(pos>=0&&(pos+size)<=position.metrics.getMaxOffset()){if(size<10000){this.historyPos=(this.historyPos+1)%this.history.length;this.history[this.historyPos]=[-1,pos,this.getValue().substring(pos,pos+size)];if(this.undoCounter=0){var cl=p.currentLine;this.curX=r.font.charsWidth(r.getLine(cl),0,p.currentCol)+this.getLeft();this.curY=cl*(r.getLineHeight()+r.getLineIndent())+this.getTop()}this.curH=r.getLineHeight()-1};this.catchScrolled=function(psx,psy){this.repaint()};this.canHaveFocus=function(){return true};this.drawCursor=function(g){if(this.position.offset>=0&&this.curView!=null&&this.blinkMe&&this.hasFocus()){this.curView.paint(g,this.curX,this.curY,this.curW,this.curH,this)}};this.mouseDragStarted=function(e){if(e.mask==ME.LEFT_BUTTON&&this.position.metrics.getMaxOffset()>0){this.startSelection()}};this.mouseDragEnded=function(e){if(e.mask==ME.LEFT_BUTTON&&this.hasSelection()===false){this.clearSelection()}};this.mouseDragged=function(e){if(e.mask==ME.LEFT_BUTTON){var p=this.getTextRowColAt(e.x-this.scrollManager.getSX(),e.y-this.scrollManager.getSY());if(p!=null){this.position.setRowCol(p[0],p[1])}}};this.select=function(startOffset,endOffset){if(endOffsetthis.position.metrics.getMaxOffset()){throw new Error("Invalid selection offsets")}if(this.startOff!=startOffset||endOffset!=this.endOff){if(startOffset==endOffset){this.clearSelection()}else{this.startOff=startOffset;var p=this.position.getPointByOffset(startOffset);this.startLine=p[0];this.startCol=p[1];this.endOff=endOffset;p=this.position.getPointByOffset(endOffset);this.endLine=p[0];this.endCol=p[1];this.repaint()}}};this.hasSelection=function(){return this.startOff!=this.endOff};this.posChanged=function(target,po,pl,pc){this.recalc();var position=this.position;if(position.offset>=0){this.blinkMeCounter=0;this.blinkMe=true;var lineHeight=this.view.getLineHeight(),top=this.getTop();this.scrollManager.makeVisible(this.curX,this.curY,this.curW,lineHeight);if(pl>=0){if(this.startOff>=0){this.endLine=position.currentLine;this.endCol=position.currentCol;this.endOff=position.offset}var minUpdatedLine=plposition.currentLine)?pl:position.currentLine)-minUpdatedLine+1)*(lineHeight+li);if(y1+h>this.height-bottom){h=this.height-bottom-y1}this.repaint(left,y1,this.width-left-this.getRight(),h)}}else{this.repaint()}}};this.paintOnTop=function(g){if(this.hint&&this.hasFocus()===false&&this.getValue()==""){this.hint.paint(g,this.getLeft(),this.height-this.getBottom()-this.hint.getLineHeight(),this.width,this.height,this)}};this.setHint=function(hint,font,color){this.hint=hint;if(hint!=null&&zebra.instanceOf(hint,pkg.View)===false){this.hint=new pkg.TextRender(hint);font=font?font:pkg.TextField.hintFont;color=color?color:pkg.TextField.hintColor;this.hint.setColor(color);this.hint.setFont(font)}this.repaint();return this.hint};this.undo_command=function(){if(this.undoCounter>0){var h=this.history[this.historyPos];this.historyPos--;if(h[0]==1){this.remove(h[1],h[2])}else{this.write(h[1],h[2])}this.undoCounter-=2;this.redoCounter++;this.historyPos--;if(this.historyPos<0){this.historyPos=this.history.length-1}this.repaint()}};this.redo_command=function(){if(this.redoCounter>0){var h=this.history[(this.historyPos+1)%this.history.length];if(h[0]==1){this.remove(h[1],h[2])}else{this.write(h[1],h[2])}this.redoCounter--;this.repaint()}};this.getStartSelection=function(){return this.startOff!=this.endOff?((this.startOff0){this.blinkMeCounter=0;this.blinkMe=true;zebra.util.timer.start(this,Math.floor(this.blinkingPeriod/3),Math.floor(this.blinkingPeriod/3))}};this.focusLost=function(e){if(this.isEditable){if(this.hint){this.repaint()}else{this.repaintCursor()}if(this.blinkingPeriod>0){zebra.util.timer.stop(this);this.blinkMe=true}}};this.repaintCursor=function(){if(this.curX>0&&this.curW>0&&this.curH>0){this.repaint(this.curX+this.scrollManager.getSX(),this.curY+this.scrollManager.getSY(),this.curW,this.curH)}};this.run=function(){this.blinkMeCounter=(this.blinkMeCounter+1)%3;if(this.blinkMeCounter===0){this.blinkMe=!this.blinkMe;this.repaintCursor()}};this.clearSelection=function(){if(this.startOff>=0){var b=this.hasSelection();this.endOff=this.startOff=-1;if(b){this.repaint()}}};this.pageSize=function(){var height=this.height-this.getTop()-this.getBottom(),indent=this.view.getLineIndent(),textHeight=this.view.getLineHeight();return(((height+indent)/(textHeight+indent)+0.5)|0)+(((height+indent)%(textHeight+indent)>indent)?1:0)};this.createPosition=function(r){return new pkg.TextField.TextPosition(r)};this.paste=function(txt){if(txt!=null){this.removeSelected();this.write(this.position.offset,txt)}};this.copy=function(){return this.getSelectedText()};this.cut=function(){var t=this.getSelectedText();if(this.isEditable){this.removeSelected()}return t};this.setPosition=function(p){if(this.position!=p){if(this.position!=null){this.position._.remove(this);if(this.position.destroy){this.position.destroy()}}this.position=p;this.position._.add(this);this.invalidate()}};this.setCursorView=function(v){this.curW=1;this.curView=pkg.$view(v);this.vrp()};this.setPSByRowsCols=function(r,c){var tr=this.view,w=(c>0)?(tr.font.stringWidth("W")*c):this.psWidth,h=(r>0)?(r*tr.getLineHeight()+(r-1)*tr.getLineIndent()):this.psHeight;this.setPreferredSize(w,h)};this.setEditable=function(b){if(b!=this.isEditable){this.isEditable=b;if(b&&this.blinkingPeriod>0&&this.hasFocus()){zebra.util.timer.stop(this);this.blinkMe=true}this.vrp()}};this.mousePressed=function(e){if(e.isActionMask()){if(e.clicks>1){this.select(0,this.position.metrics.getMaxOffset())}else{if((e.mask&KE.M_SHIFT)>0){this.startSelection()}else{this.clearSelection()}var p=this.getTextRowColAt(e.x-this.scrollManager.getSX()-this.getLeft(),e.y-this.scrollManager.getSY()-this.getTop());if(p!=null){this.position.setRowCol(p[0],p[1])}}}};this.setSelectionColor=function(c){if(c!=this.selectionColor){this.selectionColor=c;if(this.hasSelection()){this.repaint()}}};this.calcPreferredSize=function(t){return this.view.getPreferredSize()};this.paint=function(g){var sx=this.scrollManager.getSX(),sy=this.scrollManager.getSY();try{g.translate(sx,sy);var l=this.getLeft(),t=this.getTop();this.view.paint(g,l,t,this.width-l-this.getRight(),this.height-t-this.getBottom(),this);this.drawCursor(g)}catch(e){throw e}finally{g.translate(-sx,-sy)}}},function(){this.$this("")},function(s,maxCol){var b=zebra.isNumber(maxCol);this.$this(b?new zebra.data.SingleLineTxt(s,maxCol):(maxCol?new zebra.data.Text(s):s));if(b&&maxCol>0){this.setPSByRowsCols(-1,maxCol)}},function(render){if(zebra.isString(render)){render=new pkg.TextRender(new zebra.data.SingleLineTxt(render))}else{if(zebra.instanceOf(render,zebra.data.TextModel)){render=new pkg.TextRender(render)}}this.startLine=this.startCol=this.endLine=this.endCol=this.curX=0;this.startOff=this.endOff=-1;this.history=Array(100);this.historyPos=-1;this.redoCounter=this.undoCounter=this.curY=this.curW=this.curH=0;this.$super(render);this.scrollManager=new pkg.ScrollManager(this)},function setView(v){if(v!=this.view){this.$super(v);this.setPosition(this.createPosition(this.view))}},function setValue(s){var txt=this.getValue();if(txt!=s){this.position.setOffset(0);this.scrollManager.scrollTo(0,0);this.$super(s)}},function setEnabled(b){this.clearSelection();this.$super(b)}]);pkg.TextArea=Class(pkg.TextField,[function(){this.$this("")},function(txt){this.$super(new zebra.data.Text(txt))}]);pkg.PassTextField=Class(pkg.TextField,[function(txt){this.$this(txt,-1)},function(txt,size){this.$this(txt,size,false)},function(txt,size,showLast){var pt=new pkg.PasswordText(new zebra.data.SingleLineTxt(txt,size));pt.showLast=showLast;this.$super(pt)}])})(zebra("ui"),zebra.Class);(function(pkg,Class){var L=zebra.layout,Position=zebra.util.Position,KE=pkg.KeyEvent,Listeners=zebra.util.Listeners;pkg.BaseList=Class(pkg.Panel,pkg.MouseListener,pkg.KeyListener,Position.Metric,[function $prototype(){this.gap=2;this.setValue=function(v){if(v==null){this.select(-1);return}for(var i=0;i0){var index=this.selectedIndex<0?0:this.selectedIndex+1;ch=ch.toLowerCase();for(var i=0;i0&&item[0].toLowerCase()==ch){return idx}}}return -1};this.isSelected=function(i){return i==this.selectedIndex};this.correctPM=function(x,y){if(this.isComboMode){var index=this.getItemIdxAt(x,y);if(index>=0&&index!=this.position.offset){this.position.setOffset(index);this.notifyScrollMan(index)}}};this.getItemLocation=function(i){this.validate();var gap=this.getItemGap(),y=this.getTop()+this.scrollManager.getSY()+gap;for(var i=0;imaxH){maxH=is.height}if(is.width>maxW){maxW=is.width}}}return{width:maxW,height:maxH}};this.repaintByOffsets=function(p,n){this.validate();var xx=this.width-this.getRight(),gap=this.getItemGap(),count=this.model==null?0:this.model.count();if(p>=0&&p=0&&n=0&&this.views.select!=null){var gap=this.getItemGap(),is=this.getItemSize(this.selectedIndex),l=this.getItemLocation(this.selectedIndex);this.drawSelMarker(g,l.x-gap,l.y-gap,is.width+2*gap,is.height+2*gap)}};this.paintOnTop=function(g){if(this.views.marker!=null&&(this.isComboMode||this.hasFocus())){var offset=this.position.offset;if(offset>=0){var gap=this.getItemGap(),is=this.getItemSize(offset),l=this.getItemLocation(offset);this.drawPosMarker(g,l.x-gap,l.y-gap,is.width+2*gap,is.height+2*gap)}}};this.select=function(index){if(this.model!=null&&index>=this.model.count()){throw new Error("index="+index+",max="+this.model.count())}if(this.selectedIndex!=index){var prev=this.selectedIndex;this.selectedIndex=index;this.notifyScrollMan(index);this.repaintByOffsets(prev,this.selectedIndex);this._.fired(this,prev)}else{this._.fired(this,null)}};this.mouseClicked=function(e){if(this.model!=null&&e.isActionMask()&&this.model.count()>0){this.select(this.position.offset<0?0:this.position.offset)}};this.mouseReleased=function(e){if(this.model!=null&&this.model.count()>0&&e.isActionMask()&&this.position.offset!=this.selectedIndex){this.position.setOffset(this.selectedIndex)}};this.mousePressed=function(e){if(e.isActionMask()&&this.model!=null&&this.model.count()>0){var index=this.getItemIdxAt(e.x,e.y);if(index>=0&&this.position.offset!=index){this.position.setOffset(index)}}};this.mouseEntered=function(e){this.correctPM(e.x,e.y)};this.keyPressed=function(e){if(this.model!=null&&this.model.count()>0){var po=this.position.offset;switch(e.code){case KE.END:if(e.isControlPressed()){this.position.setOffset(this.position.metrics.getMaxOffset())}else{this.position.seekLineTo(Position.END)}break;case KE.HOME:if(e.isControlPressed()){this.position.setOffset(0)}else{this.position.seekLineTo(Position.BEG)}break;case KE.RIGHT:this.position.seek(1);break;case KE.DOWN:this.position.seekLineTo(Position.DOWN);break;case KE.LEFT:this.position.seek(-1);break;case KE.UP:this.position.seekLineTo(Position.UP);break;case KE.PAGEUP:this.position.seek(this.pageSize(-1));break;case KE.PAGEDOWN:this.position.seek(this.pageSize(1));break;case KE.SPACE:case KE.ENTER:this.select(this.position.offset);break}if(po!=this.position.offset){if(this.isComboMode){this.notifyScrollMan(this.position.offset)}else{this.select(this.position.offset)}}}};this.keyTyped=function(e){var i=this.lookupItem(e.ch);if(i>=0){this.select(i)}};this.elementInserted=function(target,e,index){this.invalidate();if(this.selectedIndex>=0&&this.selectedIndex>=index){this.selectedIndex++}this.position.inserted(index,1);this.repaint()};this.elementRemoved=function(target,e,index){this.invalidate();if(this.selectedIndex==index||this.model.count()===0){this.select(-1)}else{if(this.selectedIndex>index){this.selectedIndex--}}this.position.removed(index,1);this.repaint()};this.elementSet=function(target,e,pe,index){this.invalidate();this.repaint()};this.posChanged=function(target,prevOffset,prevLine,prevCol){var off=this.position.offset;this.repaintByOffsets(prevOffset,off)};this.drawSelMarker=function(g,x,y,w,h){if(this.views.select){this.views.select.paint(g,x,y,w,h,this)}};this.drawPosMarker=function(g,x,y,w,h){if(this.views.marker){this.views.marker.paint(g,x,y,w,h,this)}};this.setItemGap=function(g){if(this.gap!=g){this.gap=g;this.vrp()}};this.setModel=function(m){if(m!=this.model){if(m!=null&&Array.isArray(m)){m=new zebra.data.ListModel(m)}if(this.model!=null&&this.model._){this.model._.remove(this)}this.model=m;if(this.model!=null&&this.model._){this.model._.add(this)}this.vrp()}};this.setPosition=function(c){if(c!=this.position){if(this.position!=null){this.position._.remove(this)}this.position=c;this.position._.add(this);this.position.setMetric(this);this.repaint()}};this.setViewProvider=function(v){if(this.provider!=v){if(typeof v=="function"){var o=new zebra.Dummy();o.getView=v;v=o}this.provider=v;this.vrp()}};this.notifyScrollMan=function(index){if(index>=0&&this.scrollManager!=null){this.validate();var gap=this.getItemGap(),dx=this.scrollManager.getSX(),dy=this.scrollManager.getSY(),is=this.getItemSize(index),l=this.getItemLocation(index);this.scrollManager.makeVisible(l.x-dx-gap,l.y-dy-gap,is.width+2*gap,is.height+2*gap)}};this.pageSize=function(d){var offset=this.position.offset;if(offset>=0){var vp=pkg.$cvp(this,{});if(vp!=null){var sum=0,i=offset,gap=2*this.getItemGap();for(;i>=0&&i<=this.position.metrics.getMaxOffset()&&sum":value.toString());return this.text}}])},function $prototype(){this.paint=function(g){this.vVisibility();if(this.firstVisible>=0){var sx=this.scrollManager.getSX(),sy=this.scrollManager.getSY();try{g.translate(sx,sy);var gap=this.getItemGap(),y=this.firstVisibleY,x=this.getLeft()+gap,yy=this.vArea.y+this.vArea.height-sy,count=this.model.count(),provider=this.provider;for(var i=this.firstVisible;iyy){break}}}catch(e){throw e}finally{g.translate(-sx,-sy)}}};this.recalc=function(){this.psWidth_=this.psHeight_=0;if(this.model!=null){var count=this.model.count();if(this.heights==null||this.heights.length!=count){this.heights=Array(count)}if(this.widths==null||this.widths.length!=count){this.widths=Array(count)}var provider=this.provider;if(provider!=null){for(var i=0;ithis.psWidth_){this.psWidth_=this.widths[i]}this.psHeight_+=this.heights[i]}}}};this.calcPreferredSize=function(l){var gap=2*this.getItemGap();return{width:gap+this.psWidth_,height:this.model==null?0:gap*this.model.count()+this.psHeight_}};this.vVisibility=function(){this.validate();var prev=this.vArea;this.vArea=pkg.$cvp(this,{});if(this.vArea==null){this.firstVisible=-1;return}if(this.visValid===false||(prev==null||prev.x!=this.vArea.x||prev.y!=this.vArea.y||prev.width!=this.vArea.width||prev.height!=this.vArea.height)){var top=this.getTop(),gap=this.getItemGap();if(this.firstVisible>=0){var dy=this.scrollManager.getSY();while(this.firstVisibleY+dy>=top&&this.firstVisible>0){this.firstVisible--;this.firstVisibleY-=(this.heights[this.firstVisible]+2*gap)}}else{this.firstVisible=0;this.firstVisibleY=top+gap}if(this.firstVisible>=0){var count=this.model==null?0:this.model.count(),hh=this.height-this.getBottom();for(;this.firstVisible=top&&y1=top&&y2=hh)){break}this.firstVisibleY+=(this.heights[this.firstVisible]+2*gap)}if(this.firstVisible>=count){this.firstVisible=-1}}this.visValid=true}};this.getItemLocation=function(index){this.validate();var gap=this.getItemGap(),y=this.getTop()+this.scrollManager.getSY()+gap;for(var i=0;i=0){var yy=this.firstVisibleY+this.scrollManager.getSY(),hh=this.height-this.getBottom(),count=this.model.count(),gap=this.getItemGap(),dgap=gap*2;for(var i=this.firstVisible;i=yy-gap&&yhh){break}}}return -1}},function(){this.$this(false)},function(m){if(zebra.isBoolean(m)){this.$this([],m)}else{this.$this(m,false)}},function(m,b){this.firstVisible=-1;this.firstVisibleY=this.psWidth_=this.psHeight_=0;this.heights=this.widths=this.vArea=null;this.visValid=false;this.setViewProvider(new pkg.List.ViewProvider());this.$super(m,b)},function invalidate(){this.visValid=false;this.firstVisible=-1;this.$super()},function drawSelMarker(g,x,y,w,h){this.$super(g,x,y,this.width-this.getRight()-x,h)},function drawPosMarker(g,x,y,w,h){this.$super(g,x,y,this.width-this.getRight()-x,h)},function catchScrolled(psx,psy){this.firstVisible=-1;this.visValid=false;this.$super(psx,psy)}]);pkg.CompList=Class(pkg.BaseList,pkg.Composite,[function $clazz(){this.Label=Class(pkg.Label,[]);this.ImageLabel=Class(pkg.ImageLabel,[]);var CompListModelListeners=Listeners.Class("elementInserted","elementRemoved");this.CompListModel=Class([function $prototype(){this.get=function(i){return this.src.kids[i]};this.set=function(item,i){this.src.removeAt(i);this.src.insert(i,null,item)};this.add=function(o){this.src.add(o)};this.removeAt=function(i){this.src.removeAt(i)};this.insert=function(item,i){this.src.insert(i,null,item)};this.count=function(){return this.src.kids.length};this.removeAll=function(){this.src.removeAll()}},function(src){this.src=src;this._=new CompListModelListeners()}])},function $prototype(){this.catchScrolled=function(px,py){};this.getItemLocation=function(i){var gap=this.getItemGap();return{x:this.kids[i].x+gap,y:this.kids[i].y+gap}};this.getItemSize=function(i){var gap=this.getItemGap();return{width:this.kids[i].width-2*gap,height:this.kids[i].height-2*gap}};this.recalc=function(){var gap=this.getItemGap();this.max=L.getMaxPreferredSize(this);this.max.width-=2*gap;this.max.height-=2*gap};this.calcMaxItemSize=function(){this.validate();return{width:this.max.width,height:this.max.height}};this.getItemIdxAt=function(x,y){return L.getDirectAt(x,y,this)};this.catchInput=function(child){if(this.isComboMode){return true}var b=this.input!=null&&L.isAncestorOf(this.input,child);if(b&&this.input!=null&&L.isAncestorOf(this.input,pkg.focusManager.focusOwner)&&this.hasFocus()===false){this.input=null}return(this.input==null||b===false)}},function(){this.$this([],false)},function(b){if(zebra.isBoolean(b)){this.$this([],b)}else{this.$this(b,false)}},function(d,b){this.input=this.max=null;this.setViewProvider(new zebra.Dummy([function getView(target,obj,i){return new pkg.CompRender(obj)}]));this.$super(d,b)},function setModel(m){var a=[];if(Array.isArray(m)){a=m;m=new pkg.CompList.CompListModel(this)}if(zebra.instanceOf(m,pkg.CompList.CompListModel)===false){throw new Error("Invalid model")}this.$super(m);for(var i=0;i=0&&o==this.selectedIndex)?this.model.get(this.position.offset):null;this.$super()},function drawSelMarker(g,x,y,w,h){if(this.input==null||L.isAncestorOf(this.input,pkg.focusManager.focusOwner)===false){this.$super(g,x,y,w,h)}},function posChanged(target,prevOffset,prevLine,prevCol){this.$super(target,prevOffset,prevLine,prevCol);if(this.isComboMode===false){this.input=(this.position.offset>=0)?this.model.get(this.position.offset):null}},function insert(index,constr,e){var c=zebra.isString(e)?new pkg.CompList.Label(e):e,g=this.getItemGap();c.setPaddings(c.top+g,c.left+g,c.bottom+g,c.right+g);return this.$super(index,constr,c)},function kidAdded(index,constr,e){this.$super(index,constr,e);this.model._.elementInserted(this,e,index)},function kidRemoved(index,e){var g=this.getItemGap();e.setPaddings(c.top-g,c.left-g,c.bottom-g,c.right-g);this.model._.elementRemoved(this,e,index)}]);var ContentListeners=Listeners.Class("contentUpdated");pkg.Combo=Class(pkg.Panel,pkg.MouseListener,pkg.KeyListener,pkg.Composite,[function $clazz(){this.ContentPan=Class(pkg.Panel,[function $prototype(){this.updateValue=function(combo,value){};this.getCombo=function(){var p=this;while((p=p.parent)&&zebra.instanceOf(p,pkg.Combo)==false){}return p}}]);this.ComboPadPan=Class(pkg.ScrollPan,[function $prototype(){this.closeTime=0},function setParent(l){this.$super(l);if(l==null&&this.owner){this.owner.requestFocus()}this.closeTime=l==null?new Date().getTime():0}]);this.ReadonlyContentPan=Class(this.ContentPan,[function $prototype(){this.calcPreferredSize=function(l){var p=this.getCombo();return p?p.list.calcMaxItemSize():{width:0,height:0}};this.paintOnTop=function(g){var list=this.getCombo().list,selected=list.getSelected(),v=selected!=null?list.provider.getView(list,selected,list.selectedIndex):null;if(v!=null){var ps=v.getPreferredSize();v.paint(g,this.getLeft(),this.getTop()+~~((this.height-this.getTop()-this.getBottom()-ps.height)/2),this.width,ps.height,this)}}}]);this.EditableContentPan=Class(this.ContentPan,[function $clazz(){this.TextField=Class(pkg.TextField,[])},function(){this.$super(new L.BorderLayout());this._=new ContentListeners();this.isEditable=true;this.dontGenerateUpdateEvent=false;this.textField=new pkg.Combo.EditableContentPan.TextField("",-1);this.textField.view.target._.add(this);this.add(L.CENTER,this.textField)},function focused(){this.$super();this.textField.requestFocus()},function $prototype(){this.textUpdated=function(src,b,off,size,startLine,lines){if(this.dontGenerateUpdateEvent===false){this._.contentUpdated(this,this.textField.getValue())}};this.canHaveFocus=function(){return true};this.updateValue=function(combo,v){this.dontGenerateUpdateEvent=true;try{var txt=(v==null?"":v.toString());this.textField.setValue(txt);this.textField.select(0,txt.length)}finally{this.dontGenerateUpdateEvent=false}}}]);this.Button=Class(pkg.Button,[function(){this.setFireParams(true,-1);this.setCanHaveFocus(false);this.$super()}]);this.List=Class(pkg.List,[])},function $prototype(){this.paint=function(g){if(this.content!=null&&this.selectionView!=null&&this.hasFocus()){this.selectionView.paint(g,this.content.x,this.content.y,this.content.width,this.content.height,this)}};this.catchInput=function(child){return child!=this.button&&(this.content==null||!this.content.isEditable)};this.canHaveFocus=function(){return this.winpad.parent==null&&(this.content!=null||!this.content.isEditable)};this.contentUpdated=function(src,text){if(src==this.content){try{this.lockListSelEvent=true;if(text==null){this.list.select(-1)}else{var m=this.list.model;for(var i=0;i100&&e.x>this.content.x&&e.y>this.content.y&&e.xthis.width){ps.height+=this.winpad.hbar.getPreferredSize().height}if(this.maxPadHeight>0&&ps.height>this.maxPadHeight){ps.height=this.maxPadHeight}if(py+this.height+ps.height>canvas.height){if(py-ps.height>=0){py-=(ps.height+this.height)}else{var hAbove=canvas.height-py-this.height;if(py>hAbove){ps.height=py;py-=(ps.height+this.height)}else{ps.height=hAbove}}}this.winpad.setSize(this.width,ps.height);this.winpad.setLocation(px,py+this.height);this.list.notifyScrollMan(this.list.selectedIndex);winlayer.add(this,this.winpad);this.list.requestFocus()}};this.setList=function(l){if(this.list!=l){this.hidePad();if(this.list!=null){this.list._.remove(this)}this.list=l;if(this.list._){this.list._.add(this)}this.winpad=new pkg.Combo.ComboPadPan(this.list);this.winpad.owner=this;if(this.content!=null){this.content.updateValue(this,this.list.getSelected())}this.vrp()}};this.keyPressed=function(e){if(this.list.model!=null){var index=this.list.selectedIndex;switch(e.code){case KE.LEFT:case KE.UP:if(index>0){this.list.select(index-1)}break;case KE.DOWN:case KE.RIGHT:if(this.list.model.count()-1>index){this.list.select(index+1)}break}}};this.keyTyped=function(e){this.list.keyTyped(e)};this.setSelectionView=function(c){if(c!=this.selectionView){this.selectionView=pkg.$view(c);this.repaint()}};this.setMaxPadHeight=function(h){if(this.maxPadHeight!=h){this.hidePad();this.maxPadHeight=h}}},function(){this.$this(new pkg.Combo.List(true))},function(list){if(zebra.isBoolean(list)){this.$this(new pkg.Combo.List(true),list)}else{this.$this(list,false)}},function(list,editable){if(zebra.instanceOf(list,pkg.BaseList)===false){list=new pkg.Combo.List(list,true)}this.button=this.content=this.winpad=null;this.maxPadHeight=0;this.lockListSelEvent=false;this._=new Listeners();this.setList(list);this.$super();this.add(L.CENTER,editable?new pkg.Combo.EditableContentPan():new pkg.Combo.ReadonlyContentPan());this.add(L.RIGHT,new pkg.Combo.Button())},function focused(){this.$super();this.repaint()},function kidAdded(index,s,c){if(zebra.instanceOf(c,pkg.Combo.ContentPan)){if(this.content!=null){throw new Error("Content panel is set")}if(c._){c._.add(this)}this.content=c;if(this.list!=null){c.updateValue(this,this.list.getSelected())}}this.$super(index,s,c);if(this.button==null&&zebra.instanceOf(c,zebra.util.Actionable)){this.button=c;this.button._.add(this)}},function kidRemoved(index,l){if(this.content==l){if(l._){l._.remove(this)}this.content=null}this.$super(index,l);if(this.button==l){this.button._.remove(this);this.button=null}},function fired(src){if((new Date().getTime()-this.winpad.closeTime)>100){this.showPad()}},function fired(src,data){if(this.lockListSelEvent===false){this.hidePad();if(this.content!=null){this.content.updateValue(this,this.list.getSelected());if(this.content.isEditable){pkg.focusManager.requestFocus(this.content)}this.repaint()}}}]);pkg.ComboArrowView=Class(pkg.View,[function $prototype(){this[""]=function(col,state){this.color=col==null?"black":col;this.state=state==null?false:state;this.gap=4};this.paint=function(g,x,y,w,h,d){if(this.state){g.setColor("#CCCCCC");g.drawLine(x,y,x,y+h);g.setColor("gray");g.drawLine(x+1,y,x+1,y+h)}else{g.setColor("#CCCCCC");g.drawLine(x,y,x,y+h);g.setColor("#EEEEEE");g.drawLine(x+1,y,x+1,y+h)}x+=this.gap+1;y+=this.gap+1;w-=this.gap*2;h-=this.gap*2;var s=Math.min(w,h);x=x+(w-s)/2+1;y=y+(h-s)/2;g.setColor(this.color);g.beginPath();g.moveTo(x,y);g.lineTo(x+s,y);g.lineTo(x+s/2,y+s);g.lineTo(x,y);g.fill()};this.getPreferredSize=function(){return{width:2*this.gap+6,height:2*this.gap+6}}}])})(zebra("ui"),zebra.Class);(function(pkg,Class,Interface){pkg.WinListener=Interface();var KE=pkg.KeyEvent,timer=zebra.util.timer,L=zebra.layout,MouseEvent=pkg.MouseEvent,WIN_OPENED=1,WIN_CLOSED=2,WIN_ACTIVATED=3,WIN_DEACTIVATED=4,VIS_PART_SIZE=30,WinListeners=zebra.util.Listeners.Class("winOpened","winActivated");pkg.showModalWindow=function(context,win,listener){pkg.showWindow(context,"modal",win,listener)};pkg.showWindow=function(context,type,win,listener){if(arguments.length<3){win=type;type="info"}return context.getCanvas().getLayer("win").addWin(type,win,listener)};pkg.hideWindow=function(win){if(win.parent&&win.parent.indexOf(win)>=0){win.parent.remove(win)}};pkg.WinLayer=Class(pkg.BaseLayer,pkg.ChildrenListener,[function $clazz(){this.ID="win";this.activate=function(c){c.getCanvas().getLayer("win").activate(c)}},function $prototype(){this.isLayerActiveAt=function(x,y){return this.activeWin!=null};this.layerMousePressed=function(x,y,mask){var cnt=this.kids.length;if(cnt>0){if(this.activeWin!=null&&this.indexOf(this.activeWin)==cnt-1){var x1=this.activeWin.x,y1=this.activeWin.y,x2=x1+this.activeWin.width,y2=y1+this.activeWin.height;if(x>=x1&&y>=y1&&x=0&&i>=this.topModalIndex;i--){var d=this.kids[i];if(d.isVisible&&d.isEnabled&&this.winType(d)!="info"&&x>=d.x&&y>=d.y&&x0&&keyCode==KE.TAB&&(mask&KE.M_SHIFT)>0){if(this.activeWin==null){this.activate(this.kids[this.kids.length-1])}else{var winIndex=this.winsStack.indexOf(this.activeWin)-1;if(winIndex=0;this.topModalIndex--){if(this.winType(this.winsStack[this.topModalIndex])=="modal"){break}}}}this.fire(WIN_CLOSED,lw,l);if(this.topModalIndex>=0){var aindex=this.winsStack.length-1;while(this.winType(this.winsStack[aindex])=="info"){aindex--}this.activate(this.winsStack[aindex])}}]);var $StatePan=Class(pkg.Panel,[function $prototype(){this.setState=function(s){if(this.state!=s){var old=this.state;this.state=s;this.updateState(old,s)}};this.updateState=function(olds,news){var b=false;if(this.bg&&this.bg.activate){b=this.bg.activate(news)}if(this.border&&this.border.activate){b=this.border.activate(news)||b}if(b){this.repaint()}}},function(){this.state="inactive";this.$super()},function setBorder(v){this.$super(v);this.updateState(this.state,this.state)},function setBackground(v){this.$super(v);this.updateState(this.state,this.state)}]);pkg.Window=Class($StatePan,pkg.WinListener,pkg.MouseListener,pkg.Composite,pkg.ExternalEditor,[function $prototype(){var MOVE_ACTION=1,SIZE_ACTION=2;this.minSize=40;this.isSizeable=true;this.isActive=function(){var c=this.getCanvas();return c!=null&&c.getLayer("win").activeWin==this};this.mouseDragStarted=function(e){this.px=e.x;this.py=e.y;this.psw=this.width;this.psh=this.height;this.action=this.insideCorner(this.px,this.py)?(this.isSizeable?SIZE_ACTION:-1):MOVE_ACTION;if(this.action>0){this.dy=this.dx=0}};this.mouseDragged=function(e){if(this.action>0){if(this.action!=MOVE_ACTION){var nw=this.psw+this.dx,nh=this.psh+this.dy;if(nw>this.minSize&&nh>this.minSize){this.setSize(nw,nh)}}this.dx=(e.x-this.px);this.dy=(e.y-this.py);if(this.action==MOVE_ACTION){this.invalidate();this.setLocation(this.x+this.dx,this.y+this.dy)}}};this.mouseDragEnded=function(e){if(this.action>0){if(this.action==MOVE_ACTION){this.invalidate();this.setLocation(this.x+this.dx,this.y+this.dy)}this.action=-1}};this.insideCorner=function(px,py){return this.getComponentAt(px,py)==this.sizer};this.getCursorType=function(target,x,y){return(this.isSizeable&&this.insideCorner(x,y))?pkg.Cursor.SE_RESIZE:null};this.catchInput=function(c){var tp=this.caption;return c==tp||(L.isAncestorOf(tp,c)&&zebra.instanceOf(c,pkg.Button)===false)||this.sizer==c};this.winOpened=function(winLayer,target,b){var state=this.isActive()?"active":"inactive";if(this.caption!=null&&this.caption.setState){this.caption.setState(state)}this.setState(state)};this.winActivated=function(winLayer,target,b){this.winOpened(winLayer,target,b)};this.mouseClicked=function(e){var x=e.x,y=e.y,cc=this.caption;if(e.clicks==2&&this.isSizeable&&x>cc.x&&xcc.y&&y=0){this.setLocation(this.prevX,this.prevY);this.setSize(this.prevW,this.prevH);this.prevW=-1}},function close(){if(this.parent){this.parent.remove(this)}},function setButtons(buttons){for(var i=0;i0&&this.isDecorative(i-1)){this.kids[i-1].setVisible(src.isVisible)}break}}}};this.hasVisibleItems=function(){for(var i=0;i=0&&!this.isDecorative(offset)){var is=this.getItemSize(offset),l=this.getItemLocation(offset);this.views.marker.paint(g,l.x-gap,l.y-gap,is.width+2*gap,is.height+2*gap,this)}}};this.mouseExited=function(e){var offset=this.position.offset;if(offset>=0&&this.getMenuAt(offset)==null){this.position.clearPos()}};this.drawPosMarker=function(g,x,y,w,h){};this.keyPressed=function(e){var position=this.position;if(position.metrics.getMaxOffset()>=0){var code=e.code,offset=position.offset;if(code==KE.DOWN){var ccc=this.kids.length;do{offset=(offset+1)%ccc}while(this.isDecorative(offset));position.setOffset(offset)}else{if(code==KE.UP){var ccc=this.kids.length;do{offset=(ccc+offset-1)%ccc}while(this.isDecorative(offset));position.setOffset(offset)}else{if(e.code==KE.ENTER||e.code==KE.SPACE){this.select(offset)}}}}};this.getMenuAt=function(index){return this.menus[this.kids[index]]};this.setMenuAt=function(i,m){if(m==this||this.isDecorative(i)){throw new Error()}var p=this.kids[i],sub=this.menus[p];this.menus[p]=m;if(m!=null){if(sub==null){p.set(L.RIGHT,new pkg.Menu.SubImage())}}else{if(sub!=null){p.set(L.RIGHT,null)}}}},function $clazz(){this.Label=Class(pkg.Label,[]);this.CheckStatePan=Class(pkg.ViewPan,[]);this.ItemPan=Class(pkg.Panel,[function $prototype(){this.gap=8;this.selected=function(){if(this.content.setState){this.content.setState(!this.content.getState())}};this.calcPreferredSize=function(target){var cc=0,pw=0,ph=0;for(var i=0;i0?this.gap:0);if(ps.height>ph){ph=ps.height}cc++}}return{width:pw,height:ph}};this.doLayout=function(target){var mw=-1;for(var i=0;imw){mw=ps.width}}}}var left=target.getByConstraints(L.LEFT),right=target.getByConstraints(L.RIGHT),content=target.getByConstraints(L.CENTER),t=target.getTop(),eh=target.height-t-target.getBottom();if(left&&left.isVisible){left.toPreferredSize();left.setLocation(this.getLeft(),t+(eh-left.height)/2)}if(content&&content.isVisible){content.toPreferredSize();content.setLocation(target.getLeft()+(mw>=0?mw+this.gap:0),t+(eh-content.height)/2)}if(right&&right.isVisible){right.toPreferredSize();right.setLocation(target.width-target.getLeft()-right.width,t+(eh-right.height)/2)}}},function(c){this.$super();this.content=c;this.add(L.CENTER,c);this.setEnabled(c.isEnabled);this.setVisible(c.isVisible)}]);this.ChItemPan=Class(this.ItemPan,[function(c,state){this.$super(c);this.add(L.LEFT,new pkg.Menu.CheckStatePan());this.state=state},function selected(){this.$super();this.state=!this.state;this.getByConstraints(L.LEFT).view.activate(this.state?"on":"off")}]);this.Line=Class(pkg.Line,[]);this.SubImage=Class(pkg.ImagePan,[])},function(){this.menus={};this.$super(true)},function(d){this.$this();for(var k in d){if(d.hasOwnProperty(k)){this.add(k);if(d[k]){this.setMenuAt(this.kids.length-1,new pkg.Menu(d[k]))}}}},function insert(i,ctr,c){if(zebra.isString(c)){if(c=="-"){return this.$super(i,ctr,new pkg.Menu.Line())}else{var m=c.match(/(\[\s*\]|\[x\]|\(x\)|\(\s*\))?\s*(.*)/);if(m!=null&&m[1]!=null){return this.$super(i,ctr,new pkg.Menu.ChItemPan(new pkg.Menu.Label(m[2]),m[1].indexOf("x")>0))}c=new pkg.Menu.Label(c)}}return this.$super(i,ctr,new pkg.Menu.ItemPan(c))},function addDecorative(c){this.$super(this.insert,this.kids.length,null,c)},function kidRemoved(i,c){this.setMenuAt(i,null);this.$super(i,c)},function posChanged(target,prevOffset,prevLine,prevCol){var off=this.position.offset;if(off<0||(this.kids.length>0&&this.kids[off].isVisible)){this.$super(target,prevOffset,prevLine,prevCol)}else{var d=(prevOffset0&&(this.kids[off].isVisible===false||this.isDecorative(off));cc--){off+=d;if(off<0){off=ccc-1}if(off>=ccc){off=0}}if(cc>0){this.position.setOffset(off);this.repaint()}}},function select(i){if(i<0||this.isDecorative(i)===false){if(i>=0){if(this.kids[i].content.isEnabled===false){return}this.kids[i].selected()}this.$super(i)}}]);pkg.Menubar=Class(pkg.Panel,pkg.ChildrenListener,pkg.KeyListener,[function $prototype(){this.childInputEvent=function(e){var target=L.getDirectChild(this,e.source);switch(e.ID){case MouseEvent.ENTERED:if(this.over!=target){var prev=this.over;this.over=target;if(this.selected!=null){this.$select(this.over)}else{this.repaint2(prev,this.over)}}break;case MouseEvent.EXITED:var p=L.getRelLocation(e.absX,e.absY,this.getCanvas(),this.over);if(p.x<0||p.y<0||p.x>=this.over.width||p.y>=this.over.height){var prev=this.over;this.over=null;if(this.selected==null){this.repaint2(prev,this.over)}}break;case MouseEvent.CLICKED:this.over=target;this.$select(this.selected==target?null:target);break}};this.activated=function(b){if(b===false){this.$select(null)}};this.$select=function(b){if(this.selected!=b){var prev=this.selected,d=this.getCanvas();this.selected=b;if(d!=null){var pop=d.getLayer(pkg.PopupLayer.ID);pop.removeAll();if(this.selected!=null){pop.setMenubar(this);var menu=this.getMenu(this.selected);if(menu!=null&&menu.hasVisibleItems()){var abs=L.getAbsLocation(0,0,this.selected);menu.setLocation(abs.x,abs.y+this.selected.height+1);pop.add(menu)}}else{pop.setMenubar(null)}}this.repaint2(prev,this.selected);this._.fired(this,this.selected==null?-1:this.indexOf(this.selected),prev==null?-1:this.indexOf(prev))}};this.repaint2=function(i1,i2){if(i1!=null){i1.repaint()}if(i2!=null){i2.repaint()}};this.paint=function(g){if(this.views!=null){var target=(this.selected!=null)?this.selected:this.over;if(target!=null){var v=(this.selected!=null)?this.views.on:this.views.off;if(v!=null){v.paint(g,target.x,target.y,target.width,target.height,this)}}}};this.keyPressed=function(e){if(this.selected!=null){var idx=this.indexOf(this.selected),pidx=idx,c=null;if(e.code==KE.LEFT){var ccc=this.kids.length;do{idx=(ccc+idx-1)%ccc;c=this.kids[idx]}while(c.isEnabled===false||c.isVisible===false)}else{if(e.code==KE.RIGHT){var ccc=this.kids.length;do{idx=(idx+1)%ccc;c=this.kids[idx]}while(c.isEnabled===false||c.isVisible===false)}}if(idx!=pidx){this.$select(this.kids[idx])}}};this.addMenu=function(c,m){this.add(c);this.setMenuAt(this.kids.length-1,m)};this.setMenuAt=function(i,m){if(i>=this.kids.length){throw new Error("Invalid kid index:"+i)}var c=this.kids[i];if(m==null){var pm=this.menus.hasOwnProperty(c)?this.menus[c]:null;if(pm!=null){delete this.menus[c]}}else{this.menus[c]=m}};this.getMenuAt=function(i){return this.getMenu(this.kids[i])};this.getMenu=function(c){return this.menus.hasOwnProperty(c)?this.menus[c]:null}},function $clazz(){this.Label=Class(pkg.Label,[])},function(){this.menus={};this.over=this.selected=null;this.$super();this._=new zebra.util.Listeners()},function(d){this.$this();for(var k in d){if(d.hasOwnProperty(k)){if(d[k]){this.addMenu(k,new pkg.Menu(d[k]))}else{this.add(k)}}}},function insert(i,constr,c){if(zebra.isString(c)){c=new pkg.Menubar.Label(c)}this.$super(i,constr,c)},function kidRemoved(i,c){this.setMenuAt(i,null);this.$super(i)},function removeAll(){this.$super();this.menus={}}]);pkg.Menubar.prototype.setViews=pkg.$ViewsSetter;pkg.PopupLayer=Class(pkg.BaseLayer,pkg.ChildrenListener,[function $clazz(){this.ID="pop"},function $prototype(){this.mTop=this.mLeft=this.mBottom=this.mRight=0;this.layerMousePressed=function(x,y,mask){if(this.isLayerActiveAt(x,y)===false||this.getComponentAt(x,y)==this){if(this.kids.length>0){this.removeAll()}if(this.mbar!=null){this.setMenubar(null)}return false}return true};this.isLayerActiveAt=function(x,y){return this.kids.length>0&&(this.mbar==null||y>this.mBottom||ythis.mRight)};this.childInputEvent=function(e){if(e.UID==pkg.InputEvent.KEY_UID){if(e.ID==KE.PRESSED&&e.code==KE.ESCAPE){this.remove(L.getDirectChild(this,e.source));if(this.kids===0){this.setMenubar(null)}}if(zebra.instanceOf(this.mbar,pkg.KeyListener)){pkg.events.performInput(new KE(this.mbar,e.ID,e.code,e.ch,e.mask))}}};this.calcPreferredSize=function(target){return{width:0,height:0}};this.setMenubar=function(mb){if(this.mbar!=mb){this.removeAll();if(this.mbar&&this.mbar.activated){this.mbar.activated(false)}this.mbar=mb;if(this.mbar!=null){var abs=L.getAbsLocation(0,0,this.mbar);this.mLeft=abs.x;this.mRight=this.mLeft+this.mbar.width-1;this.mTop=abs.y;this.mBottom=this.mTop+this.mbar.height-1}if(this.mbar&&this.mbar.activated){this.mbar.activated(true)}}};this.posChanged=function(target,prevOffset,prevLine,prevCol){if(timer.get(this)){timer.stop(this)}var selectedIndex=target.offset;if(selectedIndex>=0){var index=this.pcMap.indexOf(target),sub=this.kids[index].getMenuAt(selectedIndex);if(index+1=0){var sub=src.getMenuAt(index);if(sub!=null){if(sub.parent==null){sub.setLocation(src.x+src.width-10,src.y+src.kids[index].y);this.add(sub)}else{pkg.focusManager.requestFocus(this.kids[this.kids.length-1])}}else{this.removeAll();this.setMenubar(null)}}else{if(src.selectedIndex>=0){var sub=src.getMenuAt(src.selectedIndex);if(sub!=null){this.remove(sub)}}}};this.run=function(){timer.stop(this);if(this.kids.length>0){var menu=this.kids[this.kids.length-1];menu.select(menu.position.offset)}};this.doLayout=function(target){var cnt=this.kids.length;for(var i=0;ithis.width)?this.width-ps.width:m.x,yy=(m.y+ps.height>this.height)?this.height-ps.height:m.y;m.setSize(ps.width,ps.height);if(xx<0){xx=0}if(yy<0){yy=0}m.setLocation(xx,yy)}}}},function(){this.mbar=null;this.pcMap=[];this.showIn=250;this.$super(pkg.PopupLayer.ID)},function removeAt(index){for(var i=this.kids.length-1;i>=index;i--){this.$super(index)}},function kidAdded(index,id,lw){this.$super(index,id,lw);if(zebra.instanceOf(lw,pkg.Menu)){lw.position.clearPos();lw.select(-1);this.pcMap.splice(index,0,lw.position);lw._.add(this);lw.position._.add(this);lw.requestFocus()}},function kidRemoved(index,lw){this.$super(index,lw);if(zebra.instanceOf(lw,pkg.Menu)){lw._.remove(this);lw.position._.remove(this);this.pcMap.splice(index,1);if(this.kids.length>0){this.kids[this.kids.length-1].select(-1);this.kids[this.kids.length-1].requestFocus()}}}]);pkg.Tooltip=Class(pkg.Panel,[function $clazz(){this.borderColor="black";this.borderWidth=1;this.Label=Class(pkg.Label,[]);this.TooltipBorder=Class(pkg.View,[function $prototype(){this[""]=function(col,size){this.color=col!=null?col:"black";this.size=size==null?4:size;this.gap=2*this.size};this.paint=function(g,x,y,w,h,d){if(this.color!=null){var old=g.lineWidth;this.outline(g,x,y,w,h,d);g.setColor(this.color);g.lineWidth=this.size;g.stroke();g.lineWidth=old}};this.outline=function(g,x,y,w,h,d){g.beginPath();h-=2*this.size;w-=2*this.size;x+=this.size;y+=this.size;var w2=(w/2+0.5)|0,h3=(h/3+0.5)|0,w3_8=((3*w)/8+0.5)|0,h2_3=((2*h)/3+0.5)|0,h3=(h/3+0.5)|0,w4=(w/4+0.5)|0;g.moveTo(x+w2,y);g.quadraticCurveTo(x,y,x,y+h3);g.quadraticCurveTo(x,y+h2_3,x+w4,y+h2_3);g.quadraticCurveTo(x+w4,y+h,x,y+h);g.quadraticCurveTo(x+w3_8,y+h,x+w2,y+h2_3);g.quadraticCurveTo(x+w,y+h2_3,x+w,y+h3);g.quadraticCurveTo(x+w,y,x+w2,y);return true}}])},function(content){this.$super();this.setBorder(new pkg.Tooltip.TooltipBorder(pkg.Tooltip.borderColor,pkg.Tooltip.borderWidth));this.add(zebra.instanceOf(content,pkg.Panel)?content:new pkg.Tooltip.Label(content));this.toPreferredSize()},function recalc(){this.$contentPs=(this.kids.length===0?this.$super():this.kids[0].getPreferredSize())},function getBottom(){return this.$super()+this.$contentPs.height},function getTop(){return this.$super()+((this.$contentPs.height/6+0.5)|0)},function getLeft(){return this.$super()+((this.$contentPs.height/6+0.5)|0)},function getRight(){return this.$super()+((this.$contentPs.height/6+0.5)|0)}]);pkg.PopupManager=Class(pkg.Manager,pkg.MouseListener,[function $prototype(){this.mouseClicked=function(e){this.popupMenuX=e.absX;this.popupManuY=e.absY;if((e.mask&MouseEvent.RIGHT_BUTTON)>0){var popup=null;if(e.source.popup!=null){popup=e.source.popup}else{if(e.source.getPopup!=null){popup=e.source.getPopup(e.source,e.x,e.y)}}if(popup!=null){popup.setLocation(this.popupMenuX,this.popupManuY);e.source.getCanvas().getLayer(pkg.PopupLayer.ID).add(popup);popup.requestFocus()}}};this.hideTooltipByPress=true;this.mouseEntered=function(e){var c=e.source;if(c.getTooltip!=null||c.tooltip!=null){this.target=c;this.targetTooltipLayer=c.getCanvas().getLayer(pkg.WinLayer.ID);this.tooltipX=e.x;this.tooltipY=e.y;timer.start(this,this.showTooltipIn,this.showTooltipIn)}};this.mouseExited=function(e){if(this.target!=null){timer.stop(this);this.target=null;this.hideTooltip()}};this.mouseMoved=function(e){if(this.target!=null){timer.clear(this);this.tooltipX=e.x;this.tooltipY=e.y;this.hideTooltip()}};this.run=function(){if(this.tooltip==null){this.tooltip=this.target.tooltip!=null?this.target.tooltip:this.target.getTooltip(this.target,this.tooltipX,this.tooltipY);if(this.tooltip!=null){var p=L.getAbsLocation(this.tooltipX,this.tooltipY,this.target);this.tooltip.toPreferredSize();var tx=p.x,ty=p.y-this.tooltip.height,dw=this.targetTooltipLayer.width;if(tx+this.tooltip.width>dw){tx=dw-this.tooltip.width-1}this.tooltip.setLocation(tx<0?0:tx,ty<0?0:ty);this.targetTooltipLayer.addWin("info",this.tooltip,null)}}};this.hideTooltip=function(){if(this.tooltip!=null){this.targetTooltipLayer.remove(this.tooltip);this.tooltip=null}};this.mousePressed=function(e){if(this.hideTooltipByPress&&this.target!=null){timer.stop(this);this.target=null;this.hideTooltip()}};this.mouseReleased=function(e){if(this.hideTooltipByPress&&this.target!=null){this.x=e.x;this.y=e.y;timer.start(this,this.showTooltipIn,this.showTooltipIn)}}},function(){this.$super();this.popupMenuX=this.popupManuY=0;this.tooltipX=this.tooltipY=0;this.targetTooltipLayer=this.tooltip=this.target=null;this.showTooltipIn=400}]);pkg.WindowTitleView=Class(pkg.View,[function $prototype(){this[""]=function(bg){this.radius=6;this.gap=this.radius;this.bg=bg?bg:"#66CCFF"};this.paint=function(g,x,y,w,h,d){this.outline(g,x,y,w,h,d);g.setColor(this.bg);g.fill()};this.outline=function(g,x,y,w,h,d){g.beginPath();g.moveTo(x+this.radius,y);g.lineTo(x+w-this.radius*2,y);g.quadraticCurveTo(x+w,y,x+w,y+this.radius);g.lineTo(x+w,y+h);g.lineTo(x,y+h);g.lineTo(x,y+this.radius);g.quadraticCurveTo(x,y,x+this.radius,y);return true}}])})(zebra("ui"),zebra.Class,zebra.Interface);(function(pkg,Class,ui){var L=zebra.layout,Cursor=ui.Cursor,KeyEvent=ui.KeyEvent,CURSORS=[];CURSORS[L.LEFT]=Cursor.W_RESIZE;CURSORS[L.RIGHT]=Cursor.E_RESIZE;CURSORS[L.TOP]=Cursor.N_RESIZE;CURSORS[L.BOTTOM]=Cursor.S_RESIZE;CURSORS[L.TLEFT]=Cursor.NW_RESIZE;CURSORS[L.TRIGHT]=Cursor.NE_RESIZE;CURSORS[L.BLEFT]=Cursor.SW_RESIZE;CURSORS[L.BRIGHT]=Cursor.SE_RESIZE;CURSORS[L.CENTER]=Cursor.MOVE;CURSORS[L.NONE]=Cursor.DEFAULT;pkg.ShaperBorder=Class(ui.View,[function $prototype(){this.color="blue";this.gap=7;function contains(x,y,gx,gy,ww,hh){return gx<=x&&(gx+ww)>x&&gy<=y&&(gy+hh)>y}this.paint=function(g,x,y,w,h,d){var cx=~~((w-this.gap)/2),cy=~~((h-this.gap)/2);g.setColor(this.color);g.beginPath();g.rect(x,y,this.gap,this.gap);g.rect(x+cx,y,this.gap,this.gap);g.rect(x,y+cy,this.gap,this.gap);g.rect(x+w-this.gap,y,this.gap,this.gap);g.rect(x,y+h-this.gap,this.gap,this.gap);g.rect(x+cx,y+h-this.gap,this.gap,this.gap);g.rect(x+w-this.gap,y+cy,this.gap,this.gap);g.rect(x+w-this.gap,y+h-this.gap,this.gap,this.gap);g.fill();g.beginPath();g.rect(x+~~(this.gap/2),y+~~(this.gap/2),w-this.gap,h-this.gap);g.stroke()};this.detectAt=function(target,x,y){var gap=this.gap,gap2=gap*2,w=target.width,h=target.height;if(contains(x,y,gap,gap,w-gap2,h-gap2)){return L.CENTER}if(contains(x,y,0,0,gap,gap)){return L.TLEFT}if(contains(x,y,0,h-gap,gap,gap)){return L.BLEFT}if(contains(x,y,w-gap,0,gap,gap)){return L.TRIGHT}if(contains(x,y,w-gap,h-gap,gap,gap)){return L.BRIGHT}var mx=~~((w-gap)/2);if(contains(x,y,mx,0,gap,gap)){return L.TOP}if(contains(x,y,mx,h-gap,gap,gap)){return L.BOTTOM}var my=~~((h-gap)/2);if(contains(x,y,0,my,gap,gap)){return L.LEFT}return contains(x,y,w-gap,my,gap,gap)?L.RIGHT:L.NONE}}]);pkg.InsetsArea=Class([function $prototype(){this.top=this.right=this.left=this.bottom=6;this.detectAt=function(c,x,y){var t=0,b1=false,b2=false;if(x(c.width-this.right)){t+=L.RIGHT}else{b1=true}}if(y(c.height-this.bottom)){t+=L.BOTTOM}else{b2=true}}return b1&&b2?L.CENTER:t}}]);pkg.ShaperPan=Class(ui.Panel,ui.Composite,ui.KeyListener,ui.MouseListener,[function $prototype(){this.minHeight=this.minWidth=12;this.isResizeEnabled=this.isMoveEnabled=true;this.state=null;this.getCursorType=function(t,x,y){return this.kids.length>0?CURSORS[this.shaperBr.detectAt(t,x,y)]:null};this.canHaveFocus=function(){return true};this.keyPressed=function(e){if(this.kids.length>0){var b=(e.mask&KeyEvent.M_SHIFT)>0,c=e.code,dx=(c==KeyEvent.LEFT?-1:(c==KeyEvent.RIGHT?1:0)),dy=(c==KeyEvent.UP?-1:(c==KeyEvent.DOWN?1:0)),w=this.width+dx,h=this.height+dy,x=this.x+dx,y=this.y+dy;if(b){if(this.isResizeEnabled&&w>this.shaperBr.gap*2&&h>this.shaperBr.gap*2){this.setSize(w,h)}}else{if(this.isMoveEnabled){var ww=this.width,hh=this.height,p=this.parent;if(x+ww/2>0&&y+hh/2>0&&x0?1:0),left:((t&L.LEFT)>0?1:0),right:((t&L.RIGHT)>0?1:0),bottom:((t&L.BOTTOM)>0?1:0)};if(this.state!=null){this.px=e.absX;this.py=e.absY}}};this.mouseDragged=function(e){if(this.state!=null){var dy=(e.absY-this.py),dx=(e.absX-this.px),s=this.state,nw=this.width-dx*s.left+dx*s.right,nh=this.height-dy*s.top+dy*s.bottom;if(nw>=this.minWidth&&nh>=this.minHeight){this.px=e.absX;this.py=e.absY;if((s.top+s.right+s.bottom+s.left)===0){this.setLocation(this.x+dx,this.y+dy)}else{this.setSize(nw,nh);this.setLocation(this.x+dx*s.left,this.y+dy*s.top)}}}};this.setColor=function(b,color){this.colors[b?1:0]=color;this.shaperBr.color=this.colors[this.hasFocus()?1:0];this.repaint()}},function(t){this.$super(new L.BorderLayout());this.px=this.py=0;this.shaperBr=new pkg.ShaperBorder();this.colors=["lightGray","blue"];this.shaperBr.color=this.colors[0];this.setBorder(this.shaperBr);if(t!=null){this.add(t)}},function insert(i,constr,d){if(this.kids.length>0){this.removeAll()}var top=this.getTop(),left=this.getLeft();if(d.width===0||d.height===0){d.toPreferredSize()}this.setLocation(d.x-left,d.y-top);this.setSize(d.width+left+this.getRight(),d.height+top+this.getBottom());this.$super(i,L.CENTER,d)},function focused(){this.$super();this.shaperBr.color=this.colors[this.hasFocus()?1:0];this.repaint()}]);pkg.FormTreeModel=Class(zebra.data.TreeModel,[function $prototype(){this.buildModel=function(comp,root){var b=this.exclude&&this.exclude(comp),item=b?root:this.createItem(comp);for(var i=0;i0?name.substring(index+1):name);item.comp=comp;return item}},function(target){this.$super(this.buildModel(target,null))}])})(zebra("ui.designer"),zebra.Class,zebra("ui"));(function(pkg,Class){pkg.HtmlElement=Class(pkg.Panel,pkg.FocusListener,[function $prototype(){this.isLocAdjusted=false;this.canvas=null;this.ePsW=this.ePsH=0;this.setFont=function(f){this.element.style.font=f.toString();this.vrp()};this.setColor=function(c){this.element.style.color=c.toString()};this.adjustLocation=function(){if(this.isLocAdjusted===false&&this.canvas!=null){var visibility=this.element.style.visibility;this.element.style.visibility="hidden";if(zebra.instanceOf(this.parent,pkg.HtmlElement)){this.element.style.top=""+this.y+"px";this.element.style.left=""+this.x+"px"}else{var a=zebra.layout.getAbsLocation(0,0,this);this.element.style.top=""+(this.canvas.offy+a.y)+"px";this.element.style.left=""+(this.canvas.offx+a.x)+"px"}this.isLocAdjusted=true;this.element.style.visibility=visibility}};this.calcPreferredSize=function(target){return{width:this.ePsW,height:this.ePsH}};var $store=["visibility","paddingTop","paddingLeft","paddingBottom","paddingRight","border","borderStyle","borderWidth","borderTopStyle","borderTopWidth","borderBottomStyle","borderBottomWidth","borderLeftStyle","borderLeftWidth","borderRightStyle","borderRightWidth","width","height"];this.recalc=function(){var e=this.element,vars={};for(var i=0;i<$store.length;i++){var k=$store[i];vars[k]=e.style[k]}e.style.visibility="hidden";e.style.padding="0px";e.style.border="none";e.style.width="auto";e.style.height="auto";this.ePsW=e.offsetWidth;this.ePsH=e.offsetHeight;for(var k in vars){var v=vars[k];if(v!=null){e.style[k]=v}}this.setSize(this.width,this.height)};this.setContent=function(content){this.element.innerHTML=content;this.vrp()};this.setStyles=function(styles){for(var k in styles){this.setStyle(k,styles[k])}};this.setStyle=function(name,value){name=name.trim();var i=name.indexOf(":");if(i>0){if(zebra[name.substring(0,i)]==null){return}name=name.substring(i+1)}this.element.style[name]=value;this.vrp()};this.setAttribute=function(name,value){this.element.setAttribute(name,value)};this.isInInvisibleState=function(){if(this.width<=0||this.height<=0||this.getCanvas()==null){return true}var p=this.parent;while(p!=null&&p.isVisible&&p.width>0&&p.height>0){p=p.parent}return p!=null};this.paint=function(g){if(this.element.style.visibility=="hidden"){this.element.style.visibility="visible"}}},function(e){e=this.element=zebra.isString(e)?document.createElement(e):e;e.setAttribute("id",this.toString());e.style.visibility="hidden";this.$super();var $this=this;this.globalCompListener=new pkg.ComponentListener([function $prototype(){this.compShown=function(c){if(c!=$this&&c.isVisible===false&&zebra.layout.isAncestorOf(c,$this)){$this.element.style.visibility="hidden"}};this.compMoved=function(c,px,py){if($this.canvas==c){$this.isLocAdjusted=false;$this.adjustLocation()}};this.compRemoved=function(p,c){if(c!=$this&&zebra.layout.isAncestorOf(c,$this)){$this.element.style.visibility="hidden"}};this.compSized=function(c,pw,ph){if(c!=$this&&zebra.layout.isAncestorOf(c,$this)&&$this.isInInvisibleState()){$this.element.style.visibility="hidden"}}}]);if(zebra.isTouchable===false){e.onmousemove=function(ee){if($this.canvas!=null){$this.canvas.mouseMoved(1,{target:$this.canvas.canvas,pageX:ee.pageX,pageY:ee.pageY})}};e.onmousedown=function(ee){if($this.canvas!=null){$this.canvas.mousePressed(1,{target:$this.canvas.canvas,pageX:ee.pageX,pageY:ee.pageY})}};e.onmouseup=function(ee){if($this.canvas!=null){$this.canvas.mouseReleased(1,{target:$this.canvas.canvas,pageX:ee.pageX,pageY:ee.pageY},ee.button===0?pkg.MouseEvent.LEFT_BUTTON:(ee.button==2?pkg.MouseEvent.RIGHT_BUTTON:0))}}}e.addEventListener("focus",function(ee){$this.element.canvas=$this.canvas;zebra.ui.focusManager.requestFocus($this)},false);e.addEventListener("blur",function(ee){$this.element.canvas=null;if($this.canvas!=null){setTimeout(function(){var fo=zebra.ui.focusManager.focusOwner;if((document.activeElement!=$this.canvas.canvas)&&(document.activeElement!=null&&$this.canvas!=document.activeElement.canvas)){zebra.ui.focusManager.requestFocus(null)}},100)}},false);e.onkeydown=function(ee){if($this.canvas!=null){var pfo=zebra.ui.focusManager.focusOwner;$this.canvas.keyPressed({keyCode:ee.keyCode,target:ee.target,altKey:ee.altKey,shiftKey:ee.shiftKey,ctrlKey:ee.ctrlKey,metaKey:ee.metaKey,preventDefault:function(){}});var nfo=zebra.ui.focusManager.focusOwner;if(nfo!=pfo){ee.preventDefault();if(nfo!=null&&zebra.instanceOf(nfo,pkg.HtmlElement)&&document.activeElement!=nfo.element){nfo.element.focus()}else{$this.canvas.canvas.focus()}}}};e.onkeyup=function(ee){if($this.canvas!=null){$this.canvas.keyReleased(ee)}};e.onkeypress=function(ee){if($this.canvas!=null){$this.canvas.keyTyped({keyCode:ee.keyCode,target:ee.target,altKey:ee.altKey,shiftKey:ee.shiftKey,ctrlKey:ee.ctrlKey,metaKey:ee.metaKey,preventDefault:function(){}})}}},function focused(){if(this.hasFocus()){var canvas=this.getCanvas();var pfo=canvas.$prevFocusOwner;if(pfo==null||zebra.instanceOf(pfo,pkg.HtmlElement)===false){this.element.focus()}}this.$super()},function setBorder(b){if(b==null){this.element.style.border="none"}else{var e=this.element;e.style.border="0px solid transparent";e.style.borderTopStyle="solid";e.style.borderTopColor="transparent";e.style.borderTopWidth=""+b.getTop()+"px";e.style.borderLeftStyle="solid";e.style.borderLeftColor="transparent";e.style.borderLeftWidth=""+b.getLeft()+"px";e.style.borderBottomStyle="solid";e.style.borderBottomColor="transparent";e.style.borderBottomWidth=""+b.getBottom()+"px";e.style.borderRightStyle="solid";e.style.borderRightColor="transparent";e.style.borderRightWidth=""+b.getRight()+"px"}this.$super(b)},function setPaddings(t,l,b,r){var e=this.element;e.style.paddingTop=""+t+"px";e.style.paddingLeft=""+l+"px";e.style.paddingRight=""+r+"px";e.style.paddingBottom=""+b+"px";this.$super(t,l,b,r)},function setVisible(b){if(this.isInInvisibleState()){this.element.style.visibility="hidden"}else{this.element.style.visibility=b?"visible":"hidden"}this.$super(b)},function setEnabled(b){this.$super(b);this.element.disabled=!b},function setSize(w,h){this.$super(w,h);var visibility=this.element.style.visibility;this.element.style.visibility="hidden";this.element.style.width=""+w+"px";this.element.style.height=""+h+"px";var dx=this.element.offsetWidth-w,dy=this.element.offsetHeight-h;this.element.style.width=""+(w-dx)+"px";this.element.style.height=""+(h-dy)+"px";if(this.isInInvisibleState()){this.element.style.visibility="hidden"}else{this.element.style.visibility=visibility}},function setLocation(x,y){this.$super(x,y);this.isLocAdjusted=false},function validate(){if(this.canvas==null&&this.parent!=null){this.canvas=this.getCanvas()}if(this.canvas!=null&&this.isLocAdjusted===false){this.adjustLocation()}this.$super()},function setParent(p){this.$super(p);if(p==null){if(this.element.parentNode!=null){this.element.parentNode.removeChild(this.element)}this.element.style.visibility="hidden";pkg.events.removeComponentListener(this.globalCompListener)}else{if(zebra.instanceOf(p,pkg.HtmlElement)){p.element.appendChild(this.element)}else{document.body.appendChild(this.element)}if(this.isInInvisibleState()){this.element.style.visibility="hidden"}else{this.element.style.visibility=this.isVisible?"visible":"hidden"}pkg.events.addComponentListener(this.globalCompListener)}this.isLocAdjusted=false;this.canvas=p!=null?this.getCanvas():null}]);pkg.HtmlTextInput=Class(pkg.HtmlElement,[function $prototype(){this.canHaveFocus=function(){return true};this.getText=function(){return this.element.value.toString()};this.setText=function(t){if(this.element.value!=t){this.element.value=t;this.vrp()}}},function(text,elementName){this.$super(elementName);this.element.setAttribute("tabindex",0);this.setText(text)}]);pkg.HtmlContent=Class(pkg.HtmlElement,[function(){this.$super("div");this.setStyle("overflow","hidden")},function loadContent(url){var c=zebra.io.GET(url);this.setContent(c);this.vrp()}]);pkg.HtmlTextField=Class(pkg.HtmlTextInput,[function(){this.$this("")},function(text){this.$super(text,"input");this.element.setAttribute("type","text")}]);pkg.HtmlTextArea=Class(pkg.HtmlTextInput,[function(){this.$this("")},function(text){this.$super(text,"textarea");this.element.setAttribute("rows",10)}])})(zebra("ui"),zebra.Class);(function(pkg,Class,ui){var KE=ui.KeyEvent,IM=function(b){this.width=this.height=this.x=this.y=this.viewHeight=0;this.viewWidth=-1;this.isOpen=b},TreeListeners=zebra.util.Listeners.Class("toggled","selected");pkg.DefEditors=Class([function(){this.tf=new ui.TextField(new zebra.data.SingleLineTxt(""));this.tf.setBackground("white");this.tf.setBorder(null);this.tf.setPadding(0)},function $prototype(){this.getEditor=function(src,item){var o=item.value;this.tf.setValue((o==null)?"":o.toString());return this.tf};this.fetchEditedValue=function(src,editor){return editor.view.target.getValue()};this.shouldStartEdit=function(src,e){return(e.ID==ui.MouseEvent.CLICKED&&e.clicks>1)||(e.ID==KE.PRESSED&&e.code==KE.ENTER)}}]);pkg.DefViews=Class([function $prototype(){this.getView=function(d,obj){if(obj.value&&obj.value.paint){return obj.value}this.render.target.setValue(obj.value==null?"":obj.value);return this.render};this[""]=function(color,font){if(color==null){color=pkg.Tree.fontColor}if(font==null){font=pkg.Tree.font}this.render=new ui.TextRender("");this.render.setFont(font);this.render.setColor(color)}}]);pkg.Tree=Class(ui.Panel,ui.MouseListener,ui.KeyListener,ui.ChildrenListener,[function $prototype(){this.itemGapY=this.gapx=this.gapy=2;this.itemGapX=4;this.canHaveFocus=function(){return true};this.childInputEvent=function(e){if(e.ID==KE.PRESSED){if(e.code==KE.ESCAPE){this.stopEditing(false)}else{if(e.code==KE.ENTER){if((zebra.instanceOf(e.source,ui.TextField)===false)||(zebra.instanceOf(e.source.view.target,zebra.data.SingleLineTxt))){this.stopEditing(true)}}}}};this.isInvalidatedByChild=function(c){return false};this.catchScrolled=function(psx,psy){this.stopEditing(true);if(this.firstVisible==null){this.firstVisible=this.model.root}this.firstVisible=(this.y~~(this.maxh/2))?this.prevVisible(this.findLast(this.model.root)):this.nextVisible(this.model.root)}}}}this._isVal=true};this.recalc=function(){this.maxh=this.maxw=0;if(this.model!=null&&this.model.root!=null){this.recalc_(this.getLeft(),this.getTop(),null,this.model.root,true);this.maxw-=this.getLeft();this.maxh-=this.gapy}};this.getViewBounds=function(root){var metrics=this.getIM(root),toggle=this.getToggleBounds(root),image=this.getImageBounds(root);toggle.x=image.x+image.width+(image.width>0||toggle.width>0?this.gapx:0);toggle.y=metrics.y+~~((metrics.height-metrics.viewHeight)/2);toggle.width=metrics.viewWidth;toggle.height=metrics.viewHeight;return toggle};this.getToggleBounds=function(root){var node=this.getIM(root),d=this.getToggleSize(root);return{x:node.x,y:node.y+~~((node.height-d.height)/2),width:d.width,height:d.height}};this.getToggleView=function(i){return i.kids.length>0?(this.getIM(i).isOpen?this.views.on:this.views.off):null};this.recalc_=function(x,y,parent,root,isVis){var node=this.getIM(root);if(isVis===true){if(node.viewWidth<0){var viewSize=this.provider.getView(this,root).getPreferredSize();node.viewWidth=viewSize.width===0?5:viewSize.width+this.itemGapX*2;node.viewHeight=viewSize.height+this.itemGapY*2}var imageSize=this.getImageSize(root),toggleSize=this.getToggleSize(root);if(parent!=null){var pImg=this.getImageBounds(parent);x=pImg.x+~~((pImg.width-toggleSize.width)/2)}node.x=x;node.y=y;node.width=toggleSize.width+imageSize.width+node.viewWidth+(toggleSize.width>0?this.gapx:0)+(imageSize.width>0?this.gapx:0);node.height=Math.max(((toggleSize.height>imageSize.height)?toggleSize.height:imageSize.height),node.viewHeight);if(node.x+node.width>this.maxw){this.maxw=node.x+node.width}this.maxh+=(node.height+this.gapy);x=node.x+toggleSize.width+(toggleSize.width>0?this.gapx:0);y+=(node.height+this.gapy)}var b=node.isOpen&&isVis;if(b){var count=root.kids.length;for(var i=0;i0&&this.getIM(i).isOpen&&this.isOpen_(i.parent))};this.getIM=function(i){var node=this.nodes[i];if(typeof node==="undefined"){node=new IM(this.isOpenVal);this.nodes[i]=node}return node};this.getItemAt=function(root,x,y){this.validate();if(arguments.length<3){root=this.model.root}if(this.firstVisible!=null&&y>=this.visibleArea.y&&y=node.x&&y>=node.y&&x0?(this.getIM(i).isOpen?this.views.open:this.views.close):this.views.leaf};this.getImageSize=function(i){var v=i.kids.length>0?(this.getIM(i).isOpen?this.viewSizes.open:this.viewSizes.close):this.viewSizes.leaf;return v?v:{width:0,height:0}};this.getImageBounds=function(root){var node=this.getIM(root),id=this.getImageSize(root),td=this.getToggleSize(root);return{x:node.x+td.width+(td.width>0?this.gapx:0),y:node.y+~~((node.height-id.height)/2),width:id.width,height:id.height}};this.getImageY=function(root){var node=this.getIM(root);return node.y+~~((node.height-this.getImageSize(root).height)/2)};this.getToggleY=function(root){var node=this.getIM(root);return node.y+~~((node.height-this.getToggleSize(root).height)/2)};this.getToggleSize=function(i){return this.isOpen_(i)?this.viewSizes.on:this.viewSizes.off};this.isAbove=function(i){var node=this.getIM(i);return node.y+node.height+this.scrollManager.getSY()0&&this.isOpen_(item)){return item.kids[0]}var parent=null;while((parent=item.parent)!=null){var index=parent.kids.indexOf(item);if(index+1=0)?this.findLast(parent.kids[index-1]):parent}}return null};this.findLast=function(item){return this.isOpen_(item)&&item.kids.length>0?this.findLast(item.kids[item.kids.length-1]):item};this.prevVisible=function(item){if(item==null||this.isAbove(item)){return this.nextVisible(item)}var parent=null;while((parent=item.parent)!=null){for(var i=parent.kids.indexOf(item)-1;i>=0;i--){var child=parent.kids[i];if(this.isAbove(child)){return this.nextVisible(child)}}item=parent}return item};this.isVerVisible=function(item){if(this.visibleArea==null){return false}var node=this.getIM(item),yy1=node.y+this.scrollManager.getSY(),yy2=yy1+node.height-1,by=this.visibleArea.y+this.visibleArea.height;return((this.visibleArea.y<=yy1&&yy1yy1&&yy2>=by))};this.nextVisible=function(item){if(item==null||this.isVerVisible(item)){return item}var res=this.nextVisibleInBranch(item),parent=null;if(res!=null){return res}while((parent=item.parent)!=null){var count=parent.kids.length;for(var i=parent.kids.indexOf(item)+1;i0){this.getImageView(root).paint(g,image.x,image.y,image.width,image.height,this)}var vx=image.x+image.width+(image.width>0||toggle.width>0?this.gapx:0),vy=node.y+~~((node.height-node.viewHeight)/2);if(this.selected==root&&root!=this.editedItem){var selectView=this.views[this.hasFocus()?"aselect":"iselect"];if(selectView!=null){selectView.paint(g,vx,vy,node.viewWidth,node.viewHeight,this)}}if(root!=this.editedItem){var vvv=this.provider.getView(this,root),vvvps=vvv.getPreferredSize();vvv.paint(g,vx+this.itemGapX,vy+this.itemGapY,vvvps.width,vvvps.height,this)}if(this.lnColor!=null){g.setColor(this.lnColor);var x1=toggle.x+(toggleView==null?~~(toggle.width/2)+1:toggle.width),yy=toggle.y+~~(toggle.height/2)+0.5;g.beginPath();g.moveTo(x1-1,yy);g.lineTo(image.x,yy);g.stroke()}}else{if(node.y+dy>this.visibleArea.y+this.visibleArea.height||node.x+dx>this.visibleArea.x+this.visibleArea.width){return false}}return this.paintChild(g,root,0)};this.y_=function(item,isStart){var ty=this.getToggleY(item),th=this.getToggleSize(item).height,dy=this.scrollManager.getSY(),y=(item.kids.length>0)?(isStart?ty+th:ty-1):ty+~~(th/2);if(y+dy<0){y=-dy-1}else{if(y+dy>this.height){y=this.height-dy}}return y};this.paintChild=function(g,root,index){var b=this.isOpen_(root),vs=this.viewSizes;if(root==this.firstVisible&&this.lnColor!=null){g.setColor(this.lnColor);var y1=this.getTop(),y2=this.y_(root,false),xx=this.getIM(root).x+~~((b?vs.on.width:vs.off.width)/2);g.beginPath();g.moveTo(xx+0.5,y1);g.lineTo(xx+0.5,y2);g.stroke()}if(b&&root.kids.length>0){var firstChild=root.kids[0];if(firstChild==null){return true}var x=this.getIM(firstChild).x+~~((this.isOpen_(firstChild)?vs.on.width:vs.off.width)/2);var count=root.kids.length;if(index0)?this.y_(root.kids[index-1],true):this.getImageY(root)+this.getImageSize(root).height;for(var i=index;i1&&e.isActionMask()&&this.getItemAt(this.firstVisible,e.x,e.y)==this.selected){this.toggle(this.selected)}}};this.mouseReleased=function(e){if(this.se(this.pressedItem,e)){this.pressedItem=null}};this.keyTyped=function(e){if(this.selected!=null){switch(e.ch){case"+":if(this.isOpen(this.selected)===false){this.toggle(this.selected)}break;case"-":if(this.isOpen(this.selected)){this.toggle(this.selected)}break}}};this.keyPressed=function(e){var newSelection=null;switch(e.code){case KE.DOWN:case KE.RIGHT:newSelection=this.findNext(this.selected);break;case KE.UP:case KE.LEFT:newSelection=this.findPrev(this.selected);break;case KE.HOME:if(e.isControlPressed()){this.select(this.model.root)}break;case KE.END:if(e.isControlPressed()){this.select(this.findLast(this.model.root))}break;case KE.PAGEDOWN:if(this.selected!=null){this.select(this.nextPage(this.selected,1))}break;case KE.PAGEUP:if(this.selected!=null){this.select(this.nextPage(this.selected,-1))}break}if(newSelection!=null){this.select(newSelection)}this.se(this.selected,e)};this.mousePressed=function(e){this.pressedItem=null;this.stopEditing(true);if(this.firstVisible!=null&&e.isActionMask()){var x=e.x,y=e.y,root=this.getItemAt(this.firstVisible,x,y);if(root!=null){x-=this.scrollManager.getSX();y-=this.scrollManager.getSY();var r=this.getToggleBounds(root);if(x>=r.x&&x=r.y&&y0){this.toggle(root)}}else{if(x>r.x+r.width){this.select(root)}if(this.se(root,e)===false){this.pressedItem=root}}}}};this.toggleAll=function(root,b){var model=this.model;if(root.kids.length>0){if(this.getItemMetrics(root).isOpen!=b){this.toggle(root)}for(var i=0;i0){this.stopEditing(true);this.validate();var node=this.getIM(item);node.isOpen=(node.isOpen?false:true);this.invalidate();this._.toggled(this,item);if(!node.isOpen&&this.selected!=null){var parent=this.selected;do{parent=parent.parent}while(parent!=item&&parent!=null);if(parent==item){this.select(item)}}this.repaint()}};this.itemInserted=function(target,item){this.stopEditing(false);this.vrp()};this.itemRemoved=function(target,item){if(item==this.firstVisible){this.firstVisible=null}this.stopEditing(false);if(item==this.selected){this.select(null)}delete this.nodes[item];this.vrp()};this.itemModified=function(target,item){var node=this.getIM(item);if(node!=null){node.viewWidth=-1}this.vrp()};this.startEditing=function(item){this.stopEditing(true);if(this.editors!=null){var editor=this.editors.getEditor(this,item);if(editor!=null){this.editedItem=item;var b=this.getViewBounds(this.editedItem),ps=editor.getPreferredSize();editor.setLocation(b.x+this.scrollManager.getSX(),b.y-~~((ps.height-b.height)/2)+this.scrollManager.getSY());editor.setSize(ps.width,ps.height);this.add(editor);ui.focusManager.requestFocus(editor)}}};this.stopEditing=function(applyData){if(this.editors!=null&&this.editedItem!=null){try{if(applyData){this.model.setValue(this.editedItem,this.editors.fetchEditedValue(this.editedItem,this.kids[0]))}}finally{this.editedItem=null;this.removeAt(0);this.requestFocus()}}};this.calcPreferredSize=function(target){return this.model==null?{width:0,height:0}:{width:this.maxw,height:this.maxh}}},function(){this.$this(null)},function(d){this.$this(d,true)},function(d,b){this.provider=this.selected=this.firstVisible=this.editedItem=this.pressedItem=null;this.maxw=this.maxh=0;this.visibleArea=this.lnColor=this.editors=null;this.views={};this.viewSizes={};this._isVal=false;this.nodes={};this._=new TreeListeners();this.setLineColor("gray");this.isOpenVal=b;this.setModel(d);this.setViewProvider(new pkg.DefViews());this.setSelectable(true);this.$super();this.scrollManager=new ui.ScrollManager(this)},function focused(){this.$super();if(this.selected!=null){var m=this.getItemMetrics(this.selected);this.repaint(m.x+this.scrollManager.getSX(),m.y+this.scrollManager.getSY(),m.width,m.height)}},function setEditorProvider(p){if(p!=this.editors){this.stopEditing(false);this.editors=p}},function setSelectable(b){if(this.isSelectable!=b){if(b===false&&this.selected!=null){this.select(null)}this.isSelectable=b;this.repaint()}},function setLineColor(c){this.lnColor=c;this.repaint()},function setGaps(gx,gy){if(gx!=this.gapx||gy!=this.gapy){this.gapx=gx;this.gapy=gy;this.vrp()}},function setViewProvider(p){if(p==null){p=this}if(this.provider!=p){this.stopEditing(false);this.provider=p;delete this.nodes;this.nodes={};this.vrp()}},function setViews(v){for(var k in v){if(v.hasOwnProperty(k)){var vv=ui.$view(v[k]);this.views[k]=vv;if(k!="aselect"&&k!="iselect"){this.stopEditing(false);this.viewSizes[k]=vv?vv.getPreferredSize():null;this.vrp()}}}},function setModel(d){if(this.model!=d){if(zebra.instanceOf(d,zebra.data.TreeModel)===false){d=new zebra.data.TreeModel(d)}this.stopEditing(false);this.select(null);if(this.model!=null&&this.model._){this.model._.remove(this)}this.model=d;if(this.model!=null&&this.model._){this.model._.add(this)}this.firstVisible=null;delete this.nodes;this.nodes={};this.vrp()}},function invalidate(){if(this.isValid){this._isVal=false;this.$super()}}]);pkg.TreeSignView=Class(ui.View,[function $prototype(){this[""]=function(plus,color,bg){this.color=color==null?"white":color;this.bg=bg==null?"lightGray":bg;this.plus=plus==null?false:plus;this.br=new ui.Border("rgb(65, 131, 215)",1,3);this.width=this.height=12};this.paint=function(g,x,y,w,h,d){this.br.outline(g,x,y,w,h,d);g.setColor(this.bg);g.fill();this.br.paint(g,x,y,w,h,d);g.setColor(this.color);g.lineWidth=2;x+=2;w-=4;h-=4;y+=2;g.beginPath();g.moveTo(x,y+h/2);g.lineTo(x+w,y+h/2);if(this.plus){g.moveTo(x+w/2,y);g.lineTo(x+w/2,y+h)}g.stroke();g.lineWidth=1};this.getPreferredSize=function(){return{width:this.width,height:this.height}}}])})(zebra("ui.tree"),zebra.Class,zebra.ui);(function(pkg,Class,ui){var Matrix=zebra.data.Matrix,L=zebra.layout,WinLayer=ui.WinLayer,MB=zebra.util,Cursor=ui.Cursor,Position=zebra.util.Position,KE=ui.KeyEvent,Listeners=zebra.util.Listeners;function arr(l,v){var a=Array(l);for(var i=0;i=0&&this.isResizable&&this.metrics.isUsePsMetric===false?((this.orient==L.HORIZONTAL)?Cursor.W_RESIZE:Cursor.S_RESIZE):null};this.mouseDragged=function(e){if(this.pxy!=null){var b=(this.orient==L.HORIZONTAL),rc=this.selectedColRow,ns=(b?this.metrics.getColWidth(rc)+e.x:this.metrics.getRowHeight(rc)+e.y)-this.pxy;this.captionResized(rc,ns);if(ns>this.minSize){this.pxy=b?e.x:e.y}}};this.mouseDragStarted=function(e){if(this.metrics!=null&&this.isResizable&&this.metrics.isUsePsMetric===false){this.calcRowColAt(e.x,e.y);if(this.selectedColRow>=0){this.pxy=(this.orient==L.HORIZONTAL)?e.x:e.y}}};this.mouseDragEnded=function(e){if(this.pxy!=null){this.pxy=null}if(this.metrics!=null){this.calcRowColAt(e.x,e.y)}};this.mouseMoved=function(e){if(this.metrics!=null){this.calcRowColAt(e.x,e.y)}};this.mouseClicked=function(e){if(this.pxy==null&&this.metrics!=null&&e.clicks>1&&this.selectedColRow>=0&&this.isAutoFit){var size=this.getCaptionPS(this.selectedColRow);if(this.orient==L.HORIZONTAL){this.metrics.setColWidth(this.selectedColRow,size)}else{this.metrics.setRowHeight(this.selectedColRow,size)}this.captionResized(this.selectedColRow,size)}};this.getCaptionPS=function(rowcol){return(this.orient==L.HORIZONTAL)?this.metrics.getColPSWidth(this.selectedColRow):this.metrics.getRowPSHeight(this.selectedColRow)};this.captionResized=function(rowcol,ns){if(ns>this.minSize){if(this.orient==L.HORIZONTAL){var pw=this.metrics.getColWidth(rowcol);this.metrics.setColWidth(rowcol,ns);this._.captionResized(this,rowcol,pw)}else{var ph=this.metrics.getRowHeight(rowcol);this.metrics.setRowHeight(rowcol,ns);this._.captionResized(this,rowcol,ph)}}};this.calcRowColAt=function(x,y){var isHor=(this.orient==L.HORIZONTAL),cv=this.metrics.getCellsVisibility();if((isHor&&cv.fc!=null)||(isHor===false&&cv.fr!=null)){var m=this.metrics,xy=isHor?x:y,xxyy=isHor?cv.fc[1]-this.x+m.getXOrigin()-m.lineSize:cv.fr[1]-this.y+m.getYOrigin()-m.lineSize;for(var i=(isHor?cv.fc[0]:cv.fr[0]);i<=(isHor?cv.lc[0]:cv.lr[0]);i++){var wh=isHor?m.getColWidth(i):m.getRowHeight(i);xxyy+=(wh+m.lineSize);if(xyxxyy-this.activeAreaSize){this.selectedColRow=i;return}}}this.selectedColRow=-1};this.getCaptionAt=function(x,y){if(this.metrics!=null&&x>=0&&y>=0&&xxxyy&&xythis.psH){this.psH=ps.height}this.psW+=ps.width}else{if(ps.width>this.psW){this.psW=ps.width}this.psH+=ps.height}}}if(this.psH===0){this.psH=pkg.Grid.DEF_ROWHEIGHT}if(this.psW===0){this.psW=pkg.Grid.DEF_COLWIDTH}if(this.borderView!=null){this.psW+=(this.borderView.getLeft()+this.borderView.getRight())*(isHor?size:1);this.psH+=(this.borderView.getTop()+this.borderView.getBottom())*(isHor?1:size)}}};this.paint=function(g){if(this.metrics!=null){var cv=this.metrics.getCellsVisibility();if(cv.hasVisibleCells()===false){return}var m=this.metrics,isHor=(this.orient==L.HORIZONTAL),gap=m.lineSize,top=0,left=0,bottom=0,right=0;if(this.borderView!=null){top+=this.borderView.getTop();left+=this.borderView.getLeft();bottom+=this.borderView.getBottom();right+=this.borderView.getRight()}var x=isHor?cv.fc[1]-this.x+m.getXOrigin()-gap:this.getLeft(),y=isHor?this.getTop():cv.fr[1]-this.y+m.getYOrigin()-gap,size=isHor?m.getGridCols():m.getGridRows();for(var i=(isHor?cv.fc[0]:cv.fr[0]);i<=(isHor?cv.lc[0]:cv.lr[0]);i++){var wh1=isHor?m.getColWidth(i)+gap+(((size-1)==i)?gap:0):this.psW,wh2=isHor?this.psH:m.getRowHeight(i)+gap+(((size-1)==i)?gap:0),v=this.getTitleView(i);if(this.borderView!=null){this.borderView.paint(g,x,y,wh1,wh2,this)}if(v!=null){var props=this.getTitleProps(i),ps=v.getPreferredSize();if(props!=null&&props[2]!=0){g.setColor(props[2]);g.fillRect(x,y,wh1-1,wh2-1)}g.save();if(this.borderView&&this.borderView.outline&&this.borderView.outline(g,x,y,wh1,wh2,this)){g.clip()}else{g.clipRect(x,y,wh1,wh2)}var vx=x+L.xAlignment(ps.width,props!=null?props[0]:L.CENTER,wh1-left-right)+left,vy=y+L.yAlignment(ps.height,props!=null?props[1]:L.CENTER,wh2-top-bottom)+top;v.paint(g,vx,vy,ps.width,ps.height,this);g.restore()}if(isHor){x+=wh1}else{y+=wh2}}}};this.getTitle=function(rowcol){return this.titles==null||this.titles.length/2<=rowcol?null:this.titles[rowcol*2]}},function(){this.$this(null)},function(titles){this.psW=this.psH=0;this.render=new ui.TextRender("");this.render.setFont(pkg.GridCaption.font);this.render.setColor(pkg.GridCaption.fontColor);this.$super(titles)},function setBorderView(v){if(v!=this.borderView){this.borderView=ui.$view(v);this.vrp()}},function putTitle(rowcol,title){var old=this.getTitle(rowcol);if(old!=title){if(this.titles==null){this.titles=arr((rowcol+1)*2,null)}else{if(Math.floor(this.titles.length/2)<=rowcol){var nt=arr((rowcol+1)*2,null);zebra.util.arraycopy(this.titles,0,nt,0,this.titles.length);this.titles=nt}}var index=rowcol*2;this.titles[index]=title;if(title==null&&index+2==this.titles.length){var nt=arr(this.titles.length-2,null);zebra.util.arraycopy(this.titles,0,nt,0,index);this.titles=nt}this.vrp()}},function setTitleProps(rowcol,ax,ay,bg){var p=this.getTitleProps(rowcol);if(p==null){p=[]}p[0]=ax;p[1]=ay;p[2]=bg==null?0:bg.getRGB();this.titles[rowcol*2+1]=p;this.repaint()},function getCaptionPS(rowcol){var size=this.$super(rowcol),v=this.getTitleView(this.selectedColRow),bv=this.borderView;if(bv!=null){size=size+((this.orient==L.HORIZONTAL)?bv.getLeft()+bv.getRight():bv.getTop()+bv.getBottom())}if(v!=null){size=Math.max(size,(this.orient==L.HORIZONTAL)?v.getPreferredSize().width:v.getPreferredSize().height)}return size}]);pkg.CompGridCaption=Class(pkg.BaseCaption,ui.Composite,[function $clazz(){this.Layout=Class(L.Layout,[function $prototype(){this.doLayout=function(target){var ps=L.getMaxPreferredSize(target),m=target.metrics,b=target.orient==L.HORIZONTAL,top=target.getTop(),left=target.getLeft(),xy=b?left+m.getXOrigin():top+m.getYOrigin();for(var i=0;iv.fc[0])?1:-1}for(var i=start;i!=col;x+=((this.colWidths[i]+this.lineSize)*d),i+=d){}return x};this.getRowY_=function(row){var start=0,d=1,y=this.getTop()+this.getTopCaptionHeight()+this.lineSize,v=this.visibility;if(v.hasVisibleCells()){start=v.fr[0];y=v.fr[1];d=(row>v.fr[0])?1:-1}for(var i=start;i!=row;y+=((this.rowHeights[i]+this.lineSize)*d),i+=d){}return y};this.rPs=function(){var cols=this.getGridCols(),rows=this.getGridRows();this.psWidth_=this.lineSize*(cols+1);this.psHeight_=this.lineSize*(rows+1);for(var i=0;i=0;col+=d){if(x+dxxx2){if(b){return[col,x]}}else{if(b===false){return this.colVisibility(col,x,(d>0?-1:1),true)}}if(d<0){if(col>0){x-=(this.colWidths[col-1]+this.lineSize)}}else{if(col0)?[col-1,x]:[0,left+this.getLeftCaptionWidth()+this.lineSize])};this.rowVisibility=function(row,y,d,b){var rows=this.getGridRows();if(rows===0){return null}var top=this.getTop(),dy=this.scrollManager.getSY(),yy1=Math.min(this.visibleArea.y+this.visibleArea.height,this.height-this.getBottom()),yy2=Math.max(this.visibleArea.y,top+this.getTopCaptionHeight());for(;row=0;row+=d){if(y+dyyy2){if(b){return[row,y]}}else{if(b===false){return this.rowVisibility(row,y,(d>0?-1:1),true)}}if(d<0){if(row>0){y-=(this.rowHeights[row-1]+this.lineSize)}}else{if(row0)?[row-1,y]:[0,top+this.getTopCaptionHeight()+this.lineSize])};this.vVisibility=function(){var va=ui.$cvp(this,{});if(va==null){this.visibleArea=null;this.visibility.cancelVisibleCells();return}else{if(this.visibleArea==null||va.x!=this.visibleArea.x||va.y!=this.visibleArea.y||va.width!=this.visibleArea.width||va.height!=this.visibleArea.height){this.iColVisibility(0);this.iRowVisibility(0);this.visibleArea=va}}var v=this.visibility,b=v.hasVisibleCells();if(this.colOffset!=100){if(this.colOffset>0&&b){v.lc=this.colVisibility(v.lc[0],v.lc[1],-1,true);v.fc=this.colVisibility(v.lc[0],v.lc[1],-1,false)}else{if(this.colOffset<0&&b){v.fc=this.colVisibility(v.fc[0],v.fc[1],1,true);v.lc=this.colVisibility(v.fc[0],v.fc[1],1,false)}else{v.fc=this.colVisibility(0,this.getLeft()+this.lineSize+this.getLeftCaptionWidth(),1,true);v.lc=(v.fc!=null)?this.colVisibility(v.fc[0],v.fc[1],1,false):null}}this.colOffset=100}if(this.rowOffset!=100){if(this.rowOffset>0&&b){v.lr=this.rowVisibility(v.lr[0],v.lr[1],-1,true);v.fr=this.rowVisibility(v.lr[0],v.lr[1],-1,false)}else{if(this.rowOffset<0&&b){v.fr=this.rowVisibility(v.fr[0],v.fr[1],1,true);v.lr=(v.fr!=null)?this.rowVisibility(v.fr[0],v.fr[1],1,false):null}else{v.fr=this.rowVisibility(0,this.getTop()+this.getTopCaptionHeight()+this.lineSize,1,true);v.lr=(v.fr!=null)?this.rowVisibility(v.fr[0],v.fr[1],1,false):null}}this.rowOffset=100}};this.calcOrigin=function(off,y){var top=this.getTop()+this.getTopCaptionHeight(),left=this.getLeft()+this.getLeftCaptionWidth(),o=ui.calcOrigin(this.getColX(0)-this.lineSize,y-this.lineSize,this.psWidth_,this.rowHeights[off]+2*this.lineSize,this.scrollManager.getSX(),this.scrollManager.getSY(),this,top,left,this.getBottom(),this.getRight());this.scrollManager.scrollTo(o[0],o[1])};this.$se=function(row,col,e){if(row>=0){this.stopEditing(true);if(this.editors!=null&&this.editors.shouldDo(pkg.START_EDITING,row,col,e)){return this.startEditing(row,col)}}return false};this.getXOrigin=function(){return this.scrollManager.getSX()};this.getYOrigin=function(){return this.scrollManager.getSY()};this.getColPSWidth=function(col){return this.getPSSize(col,false)};this.getRowPSHeight=function(row){return this.getPSSize(row,true)};this.recalc=function(){if(this.isUsePsMetric){this.rPsMetric()}else{this.rCustomMetric()}this.rPs()};this.getGridRows=function(){return this.model!=null?this.model.rows:0};this.getGridCols=function(){return this.model!=null?this.model.cols:0};this.getRowHeight=function(row){this.validateMetric();return this.rowHeights[row]};this.getColWidth=function(col){this.validateMetric();return this.colWidths[col]};this.getCellsVisibility=function(){this.validateMetric();return this.visibility};this.getColX=function(col){this.validateMetric();return this.getColX_(col)};this.getRowY=function(row){this.validateMetric();return this.getRowY_(row)};this.childInputEvent=function(e){if(this.editingRow>=0){if(this.editors.shouldDo(pkg.CANCEL_EDITING,this.editingRow,this.editingCol,e)){this.stopEditing(false)}else{if(this.editors.shouldDo(pkg.FINISH_EDITING,this.editingRow,this.editingCol,e)){this.stopEditing(true)}}}};this.dataToPaint=function(row,col){return this.model.get(row,col)};this.iColVisibility=function(off){this.colOffset=(this.colOffset==100)?this.colOffset=off:((off!=this.colOffset)?0:this.colOffset)};this.iRowVisibility=function(off){this.rowOffset=(this.rowOffset==100)?off:(((off+this.rowOffset)===0)?0:this.rowOffset)};this.getTopCaptionHeight=function(){return(this.topCaption!=null&&this.topCaption.isVisible)?this.topCaption.height:0};this.getLeftCaptionWidth=function(){return(this.leftCaption!=null&&this.leftCaption.isVisible)?this.leftCaption.width:0};this.paint=function(g){this.vVisibility();if(this.visibility.hasVisibleCells()){var dx=this.scrollManager.getSX(),dy=this.scrollManager.getSY(),th=this.getTopCaptionHeight(),tw=this.getLeftCaptionWidth();try{g.save();g.translate(dx,dy);if(th>0||tw>0){g.clipRect(tw-dx,th-dy,this.width-tw,this.height-th)}this.paintSelection(g);this.paintData(g);if(this.drawHorLines||this.drawVerLines){this.paintNet(g)}this.paintMarker(g)}finally{g.restore()}}};this.catchScrolled=function(psx,psy){var offx=this.scrollManager.getSX()-psx,offy=this.scrollManager.getSY()-psy;if(offx!==0){this.iColVisibility(offx>0?1:-1)}if(offy!==0){this.iRowVisibility(offy>0?1:-1)}this.stopEditing(false);this.repaint()};this.isInvalidatedByChild=function(c){return c!=this.editor||this.isUsePsMetric};this.stopEditing=function(applyData){if(this.editors!=null&&this.editingRow>=0&&this.editingCol>=0){try{if(zebra.instanceOf(this.editor,pkg.Grid)){this.editor.stopEditing(applyData)}var data=this.getDataToEdit(this.editingRow,this.editingCol);if(applyData){this.setEditedData(this.editingRow,this.editingCol,this.editors.fetchEditedValue(this.editingRow,this.editingCol,data,this.editor))}else{this.editors.editingCanceled(this.editingRow,this.editingCol,data,this.editor)}this.repaintRows(this.editingRow,this.editingRow)}finally{this.editingCol=this.editingRow=-1;if(this.indexOf(this.editor)>=0){this.remove(this.editor)}this.editor=null;this.requestFocus()}}};this.setDrawLines=function(hor,ver){if(this.drawVerLines!=hor||this.drawHorLines!=ver){this.drawHorLines=hor;this.drawVerLines=ver;this.repaint()}};this.getLines=function(){return this.getGridRows()};this.getLineSize=function(line){return 1};this.getMaxOffset=function(){return this.getGridRows()-1};this.posChanged=function(target,prevOffset,prevLine,prevCol){var off=this.position.currentLine;if(off>=0){this.calcOrigin(off,this.getRowY(off));this.select(off,true);this.repaintRows(prevOffset,off)}};this.makeRowVisible=function(row){this.calcOrigin(row,this.getRowY(row));this.repaint()};this.keyPressed=function(e){if(this.position!=null){var cl=this.position.currentLine;switch(e.code){case KE.LEFT:this.position.seek(-1);break;case KE.UP:this.position.seekLineTo(Position.UP);break;case KE.RIGHT:this.position.seek(1);break;case KE.DOWN:this.position.seekLineTo(Position.DOWN);break;case KE.PAGEUP:this.position.seekLineTo(Position.UP,this.pageSize(-1));break;case KE.PAGEDOWN:this.position.seekLineTo(Position.DOWN,this.pageSize(1));break;case KE.END:if(e.isControlPressed()){this.position.setOffset(this.getLines()-1)}break;case KE.HOME:if(e.isControlPressed()){this.position.setOffset(0)}break}this.$se(this.position.currentLine,this.position.currentCol,e);if(cl!=this.position.currentLine&&cl>=0){for(var i=0;i0};this.repaintRows=function(r1,r2){if(r1<0){r1=r2}if(r2<0){r2=r1}if(r1>r2){var i=r2;r2=r1;r1=i}var rows=this.getGridRows();if(r1=rows){r2=rows-1}var y1=this.getRowY(r1),y2=((r1==r2)?y1:this.getRowY(r2))+this.rowHeights[r2];this.repaint(0,y1+this.scrollManager.getSY(),this.width,y2-y1)}};this.cellByLocation=function(x,y){this.validate();var dx=this.scrollManager.getSX(),dy=this.scrollManager.getSY(),v=this.visibility,ry1=v.fr[1]+dy,rx1=v.fc[1]+dx,row=-1,col=-1,ry2=v.lr[1]+this.rowHeights[v.lr[0]]+dy,rx2=v.lc[1]+this.colWidths[v.lc[0]]+dx;if(y>ry1&&yry1&&yrx1&&xrx1&&x=0&&row>=0)?[row,col]:null};this.doLayout=function(target){var topHeight=(this.topCaption!=null&&this.topCaption.isVisible)?this.topCaption.getPreferredSize().height:0,leftWidth=(this.leftCaption!=null&&this.leftCaption.isVisible)?this.leftCaption.getPreferredSize().width:0;if(this.topCaption!=null){this.topCaption.setLocation(this.getLeft()+leftWidth,this.getTop());this.topCaption.setSize(Math.min(target.width-this.getLeft()-this.getRight()-leftWidth,this.psWidth_),topHeight)}if(this.leftCaption!=null){this.leftCaption.setLocation(this.getLeft(),this.getTop()+topHeight);this.leftCaption.setSize(leftWidth,Math.min(target.height-this.getTop()-this.getBottom()-topHeight,this.psHeight_))}if(this.stub!=null&&this.stub.isVisible){if(this.topCaption!=null&&this.topCaption.isVisible&&this.leftCaption!=null&&this.leftCaption.isVisible){this.stub.setLocation(this.getLeft(),this.getTop());this.stub.setSize(this.topCaption.x-this.stub.x,this.leftCaption.y-this.stub.y)}else{this.stub.setSize(0,0)}}if(this.editors!=null&&this.editor!=null&&this.editor.parent==this&&this.editor.isVisible){var w=this.colWidths[this.editingCol],h=this.rowHeights[this.editingRow],x=this.getColX_(this.editingCol),y=this.getRowY_(this.editingRow);if(this.isUsePsMetric){x+=this.cellInsetsLeft;y+=this.cellInsetsTop;w-=(this.cellInsetsLeft+this.cellInsetsRight);h-=(this.cellInsetsTop+this.cellInsetsBottom)}this.editor.setLocation(x+this.scrollManager.getSX(),y+this.scrollManager.getSY());this.editor.setSize(w,h)}};this.canHaveFocus=function(){return this.editor==null};this.clearSelect=function(){if(this.selectedIndex>=0){var prev=this.selectedIndex;this.selectedIndex=-1;this._.fired(this,-1,0,false);this.repaintRows(-1,prev)}};this.select=function(row,b){if(b==null){b=true}if(this.isSelected(row)!=b){if(this.selectedIndex>=0){this.clearSelect()}if(b){this.selectedIndex=row;this._.fired(this,row,1,b)}}};this.laidout=function(){this.vVisibility()};this.mouseClicked=function(e){this.pressedRow=-1;if(this.visibility.hasVisibleCells()){this.stopEditing(true);if(e.isActionMask()){var p=this.cellByLocation(e.x,e.y);if(p!=null){if(this.position!=null){var off=this.position.currentLine;if(off==p[0]){this.calcOrigin(off,this.getRowY(off))}else{this.clearSelect();this.position.setOffset(p[0])}}if(this.$se(p[0],p[1],e)===false){this.pressedRow=p[0];this.pressedCol=p[1]}}}}};this.calcPreferredSize=function(target){return{width:this.psWidth_+((this.leftCaption!=null&&this.leftCaption.isVisible)?this.leftCaption.getPreferredSize().width:0),height:this.psHeight_+((this.topCaption!=null&&this.topCaption.isVisible)?this.topCaption.getPreferredSize().height:0)}};this.paintNet=function(g){var v=this.visibility,topX=v.fc[1]-this.lineSize,topY=v.fr[1]-this.lineSize,botX=v.lc[1]+this.colWidths[v.lc[0]],botY=v.lr[1]+this.rowHeights[v.lr[0]],prevWidth=g.lineWidth;g.setColor(this.lineColor);g.lineWidth=this.lineSize;g.beginPath();if(this.drawHorLines){var y=topY+this.lineSize/2;for(var i=v.fr[0];i<=v.lr[0];i++){g.moveTo(topX,y);g.lineTo(botX,y);y+=this.rowHeights[i]+this.lineSize}g.moveTo(topX,y);g.lineTo(botX,y)}if(this.drawVerLines){topX+=this.lineSize/2;for(var i=v.fc[0];i<=v.lc[0];i++){g.moveTo(topX,topY);g.lineTo(topX,botY);topX+=this.colWidths[i]+this.lineSize}g.moveTo(topX,topY);g.lineTo(topX,botY)}g.stroke();g.lineWidth=prevWidth};this.paintData=function(g){var y=this.visibility.fr[1]+this.cellInsetsTop,addW=this.cellInsetsLeft+this.cellInsetsRight,addH=this.cellInsetsTop+this.cellInsetsBottom,ts=g.getTopStack(),cx=ts.x,cy=ts.y,cw=ts.width,ch=ts.height,res={};for(var i=this.visibility.fr[0];i<=this.visibility.lr[0]&&ycy){var x=this.visibility.fc[1]+this.cellInsetsLeft,notSelectedRow=this.isSelected(i)===false;for(var j=this.visibility.fc[0];j<=this.visibility.lc[0];j++){if(notSelectedRow){var bg=this.provider.getCellColor?this.provider.getCellColor(this,i,j):this.defCellColor;if(bg!=null){g.setColor(bg);g.fillRect(x-this.cellInsetsLeft,y-this.cellInsetsTop,this.colWidths[j],this.rowHeights[i])}}var v=(i==this.editingRow&&j==this.editingCol)?null:this.provider.getView(this,i,j,this.model.get(i,j));if(v!=null){var w=this.colWidths[j]-addW,h=this.rowHeights[i]-addH;res.x=x>cx?x:cx;res.width=Math.min(x+w,cx+cw)-res.x;res.y=y>cy?y:cy;res.height=Math.min(y+h,cy+ch)-res.y;if(res.width>0&&res.height>0){if(this.isUsePsMetric){v.paint(g,x,y,w,h,this)}else{var ax=this.provider.getXAlignment?this.provider.getXAlignment(this,i,j):this.defXAlignment,ay=this.provider.getYAlignment?this.provider.getYAlignment(this,i,j):this.defYAlignment,vw=w,vh=h,xx=x,yy=y,id=-1,ps=(ax!=L.NONE||ay!=L.NONE)?v.getPreferredSize():null;if(ax!=L.NONE){xx=x+((ax==L.CENTER)?~~((w-ps.width)/2):((ax==L.RIGHT)?w-ps.width:0));vw=ps.width}if(ay!=L.NONE){yy=y+((ay==L.CENTER)?~~((h-ps.height)/2):((ay==L.BOTTOM)?h-ps.height:0));vh=ps.height}if(xx(x+w)||(yy+vh)>(y+h)){id=g.save();g.clipRect(res.x,res.y,res.width,res.height)}v.paint(g,xx,yy,vw,vh,this);if(id>=0){g.restore()}}}}x+=(this.colWidths[j]+this.lineSize)}}y+=(this.rowHeights[i]+this.lineSize)}};this.paintMarker=function(g){var markerView=this.views.marker;if(markerView!=null&&this.position!=null&&this.position.offset>=0&&this.hasFocus()){var offset=this.position.offset,v=this.visibility;if(offset>=v.fr[0]&&offset<=v.lr[0]){g.clipRect(this.getLeftCaptionWidth()-this.scrollManager.getSX(),this.getTopCaptionHeight()-this.scrollManager.getSY(),this.width,this.height);markerView.paint(g,v.fc[1],this.getRowY(offset),v.lc[1]-v.fc[1]+this.getColWidth(v.lc[0]),this.rowHeights[offset],this)}}};this.paintSelection=function(g){if(this.editingRow>=0){return}var v=this.views[this.hasFocus()?"onselection":"offselection"];if(v==null){return}for(var j=this.visibility.fr[0];j<=this.visibility.lr[0];j++){if(this.isSelected(j)){var x=this.visibility.fc[1],y=this.getRowY(j),h=this.rowHeights[j];for(var i=this.visibility.fc[0];i<=this.visibility.lc[0];i++){v.paint(g,x,y,this.colWidths[i],h,this);x+=this.colWidths[i]+this.lineSize}}}};this.rPsMetric=function(){var cols=this.getGridCols(),rows=this.getGridRows();if(this.colWidths==null||this.colWidths.length!=cols){this.colWidths=arr(cols,0)}if(this.rowHeights==null||this.rowHeights.length!=rows){this.rowHeights=arr(rows,0)}var addW=this.cellInsetsLeft+this.cellInsetsRight,addH=this.cellInsetsTop+this.cellInsetsBottom;for(var i=0;ithis.colWidths[i]){this.colWidths[i]=ps.width}if(ps.height>this.rowHeights[j]){this.rowHeights[j]=ps.height}}else{if(pkg.Grid.DEF_COLWIDTH>this.colWidths[i]){this.colWidths[i]=pkg.Grid.DEF_COLWIDTH}if(pkg.Grid.DEF_ROWHEIGHT>this.rowHeights[j]){this.rowHeights[j]=pkg.Grid.DEF_ROWHEIGHT}}}}};this.getPSSize=function(rowcol,b){if(this.isUsePsMetric){return b?this.getRowHeight(rowcol):this.getColWidth(rowcol)}else{var max=0,count=b?this.getGridCols():this.getGridRows();for(var j=0;jmax){max=ps.height}}else{if(ps.width>max){max=ps.width}}}}return max+this.lineSize*2+(b?this.cellInsetsTop+this.cellInsetsBottom:this.cellInsetsLeft+this.cellInsetsRight)}};this.rCustomMetric=function(){var start=0;if(this.colWidths!=null){start=this.colWidths.length;if(this.colWidths.length!=this.getGridCols()){var na=arr(this.getGridCols(),0);zebra.util.arraycopy(this.colWidths,0,na,0,Math.min(this.colWidths.length,na.length));this.colWidths=na}}else{this.colWidths=arr(this.getGridCols(),0)}for(;start=0){var hh=this.visibleArea.height-this.getTopCaptionHeight(),sum=0,poff=off;for(;off>=0&&off=0&&this.editingCol>=0)?[this.editingRow,this.editingCol]:null},function winOpened(winLayer,target,b){if(this.editor==target&&b===false){this.stopEditing(this.editor.isAccepted())}},function getDataToEdit(row,col){return this.model.get(row,col)},function setEditedData(row,col,value){this.model.put(row,col,value)}]);pkg.Grid.prototype.setViews=ui.$ViewsSetter;pkg.GridStretchPan=Class(ui.Panel,L.Layout,[function $prototype(){this.calcPreferredSize=function(target){this.recalcPS();return(target.kids.length===0||!target.grid.isVisible)?{width:0,height:0}:{width:this.strPs.width,height:this.strPs.height}};this.doLayout=function(target){this.recalcPS();if(target.kids.length>0){var grid=this.grid;if(grid.isVisible){var left=target.getLeft(),top=target.getTop();grid.setLocation(left,top);grid.setSize(target.width-left-target.getRight(),target.height-top-target.getBottom());for(var i=0;i0&&p.vBar&&p.autoHide===false&&taHeight