(function(){var p={},n=zul.db.Timebox=zk.$extends(zul.inp.FormatWidget,{_buttonVisible:!0,_format:"HH:mm",_timezoneAbbr:"",_timezone:"",$init:function(){this.$supers("$init",arguments);this.$class._updFormat(this,this._format)},$define:{timezoneAbbr:function(a){this.$class._updFormat(this,this._format)},timezone:function(a){this._value&&this._value.tz(a)},buttonVisible:function(a){zul.inp.RoundUtl.buttonVisible(this,a)},unformater:function(a){eval("Timebox._unformater = "+a)},localizedSymbols:[function(a){return a?
(p[a[0]]||(p[a[0]]=a[1]),p[a[0]]):a}]},inRoundedMold:function(){return!0},setFormat:function(a){a=a?a.replace(/\'/g,""):a;this.$class._updFormat(this,a);this.$supers("setFormat",arguments)},setValue:function(a,b){var d=this.getTimezone();d&&a&&a.tz(d);b&&null===a&&(this._changed=!1);this.$supers("setValue",arguments)},coerceToString_:function(a){if(!this._changed&&!a&&arguments.length)return"";for(var b="",d,e,c,f=0,g=this._fmthdler,h=g.length;f<h;f++)d=g[f],e=d.format(a),b+=e,d.type&&!1!==(c=d.isSingleLength())&&
(c+=e.length-1)&&d._doShift(this,c);return b},coerceFromString_:function(a){var b=n._unformater,d=this.getTimezone();if(b&&jq.isFunction(b)&&(b=b(a)))return this._shortcut=a,b;if(!a)return null;d=this._value?Dates.newInstance(this._value.getTime(),d):zUtl.today(this._format,d);b=[];var e=0;d.setSeconds(0);d.setMilliseconds(0);for(var c=0,f=this._fmthdler,g=f.length;c<g;c++)if(3==f[c].type){var h=!0;var k=f[c].unformat(d,a);f[c].getText(a).trim().length||e++}else f[c].type&&(b.push(f[c]),f[c].getText(a).trim().length||
e++);if(b.length==(h?--e:e))this._changed=!1;else{c=0;for(g=b.length;c<g;c++)h||6!=b[c].type&&7!=b[c].type||(k=!0),d=b[c].unformat(d,a,k);return d}},onSize:function(){var a=this.getInputNode();a&&this._value&&!a.value&&(a.value=this.coerceToString_(this._value));zul.inp.RoundUtl.onSize(this,this.$n("btn"))},onHide:zul.inp.Textbox.onHide,validate:zul.inp.Intbox.validate,doClick_:function(a){a.domTarget==this.getInputNode()&&this._doCheckPos();this.$supers("doClick_",arguments)},doKeyPress_:function(a){zk.opera&&
9!=a.keyCode?a.stop():this.$supers("doKeyPress_",arguments)},doKeyDown_:function(a){var b=this.getInputNode();if(!b.disabled&&!b.readOnly){if(!n._unformater){var d=a.keyCode;switch(d){case 48:case 96:case 49:case 97:case 50:case 98:case 51:case 99:case 52:case 100:case 53:case 101:case 54:case 102:case 55:case 103:case 56:case 104:case 57:case 105:this._doType(d-(96<=d?96:48));a.stop();return;case 35:this.lastPos=b.value.length;return;case 36:this.lastPos=0;return;case 37:0<this.lastPos&&this.lastPos--;
return;case 39:this.lastPos<b.value.length&&this.lastPos++;return;case 38:this._doUp();a.stop();return;case 40:this._doDown();a.stop();return;case 46:this._doDel();a.stop();return;case 8:this._doBack();a.stop();return;case 9:break;case 13:case 27:break;case 86:if(a.ctrlKey){var e=this,c=b.value;setTimeout(function(){var a=e.getInputNode();a&&c!=a.value&&(e._changed=!0)},0);break}default:112<=d&&123>=d||a.ctrlKey||a.altKey||a.stop()}}this.$supers("doKeyDown_",arguments)}},_ondropbtnup:function(a){this.domUnlisten_(document.body,
"onZMouseup","_ondropbtnup");this._stopAutoIncProc();this._currentbtn=null},_btnDown:function(a){if(this._buttonVisible&&!this._disabled){this._lastPos=this._getPos();var b=this.$n("btn"),d=this.getInputNode();zk.dragging||(this._currentbtn&&this._ondropbtnup(a),this.domListen_(document.body,"onZMouseup","_ondropbtnup"),this._currentbtn=b);d.value&&n._unformater&&(d.value=this.coerceToString_(this.coerceFromString_(d.value)));d.value||(d.value=this.coerceToString_());var e=zk(b).revisedOffset();b=
a.pageY-e[1]<b.offsetHeight/2;zk.webkit&&zk(d).focus();e=this._getPos();this._lastPos!=e&&zk(d).setSelectionRange(this._lastPos);b?(this._doUp(),this._startAutoIncProc(!0)):(this._doDown(),this._startAutoIncProc(!1));this._changed=!0;delete this._shortcut;var c=zk(d).getSelectionRange();if(zk.ie8_){var f=this;setTimeout(function(){if(zk.currentFocus==f&&f.desktop){var a=zk(d).getSelectionRange();c&&a&&c[0]!=c[1]&&(c[0]!=a[0]||c[1]!=a[1])&&zk(d).setSelectionRange(c[0],c[1])}},150)}zk.Widget.mimicMouseDown_(this);
zk(d).focus();a.stop()}},_btnUp:function(a){!this._buttonVisible||this._disabled||zk.dragging||(zk.opera&&zk(inp).focus(),this._onChanging(),this._stopAutoIncProc(),(11>zk.ie||zk.webkit)&&this._lastPos&&zk(this.getInputNode()).setSelectionRange(this._lastPos,this._lastPos))},_getPos:function(){return zk(this.getInputNode()).getSelectionRange()[0]},_doCheckPos:function(){this.lastPos=this._getPos()},_doUp:function(){this._changed=!0;this.getTimeHandler().increase(this,1);this._onChanging()},_doDown:function(){this._changed=
!0;this.getTimeHandler().increase(this,-1);this._onChanging()},_doBack:function(){this._changed=!0;this.getTimeHandler().deleteTime(this,!0)},_doDel:function(){this._changed=!0;this.getTimeHandler().deleteTime(this,!1)},_doType:function(a){this._changed=!0;this.getTimeHandler().addTime(this,a)},getTimeHandler:function(){var a=zk(this.getInputNode()).getSelectionRange(),b=a[0];a=a[1];for(var d,e=0,c=this._fmthdler,f=c.length;e<f;e++)if(c[e].type&&c[e].index[0]<=b&&(d=c[e],c[e].index[1]+1>=a))return c[e];
return d||this._fmthdler[0]},getNextTimeHandler:function(a){var b=this._fmthdler;a=b.$indexOf(a);for(var d;(d=b[++a])&&(!d.type||3==d.type););return d},_startAutoIncProc:function(a){this.timerId&&clearInterval(this.timerId);var b=this,d=a?"_doUp":"_doDown";this.timerId=setInterval(function(){(11>zk.ie||zk.webkit)&&b._lastPos&&zk(b.getInputNode()).setSelectionRange(b._lastPos,b._lastPos);b[d]()},300)},_stopAutoIncProc:function(){this.timerId&&clearTimeout(this.timerId);this.currentStep=this.defaultStep;
this.timerId=null},doFocus_:function(a){this.$supers("doFocus_",arguments);this.$n();var b=this.getInputNode(),d=zk(b).getSelectionRange();b.value||(b.value=n._unformater?"":this.coerceToString_());this._doCheckPos();d[0]!==d[1]&&(zk(b).setSelectionRange(d[0],d[1]),this.lastPos=d[1]);zul.inp.RoundUtl.doFocus_(this)},doBlur_:function(a){this._value||this._changed||n._unformater||(this.getInputNode().value=this._defRawVal="");this.$supers("doBlur_",arguments);zul.inp.RoundUtl.doBlur_(this)},afterKeyDown_:function(a,
b){!b&&this._inplace&&jq(this.$n()).toggleClass(this.getInplaceCSS(),13==a.keyCode?null:!1);return this.$supers("afterKeyDown_",arguments)},bind_:function(){this.$supers(zul.db.Timebox,"bind_",arguments);var a;(a=this.$n("btn"))&&this.domListen_(a,"onZMouseDown","_btnDown").domListen_(a,"onZMouseUp","_btnUp");zWatch.listen({onSize:this})},unbind_:function(){this.timerId&&(clearTimeout(this.timerId),this.timerId=null);zWatch.unlisten({onSize:this});var a=this.$n("btn");a&&this.domUnlisten_(a,"onZMouseDown",
"_btnDown").domUnlisten_(a,"onZMouseUp","_btnUp");this._changed=!1;this.$supers(zul.db.Timebox,"unbind_",arguments)},getBtnUpIconClass_:function(){return"z-icon-angle-up"},getBtnDownIconClass_:function(){return"z-icon-angle-down"}},{_updFormat:function(a,b){for(var d=[],e=a._localizedSymbols?a._localizedSymbols.APM:zk.APM,c=0,f=b.length;c<f;c++){var g=b.charAt(c);switch(g){case "a":d.push(new zul.inp.AMPMHandler([c,c+e[0].length-1],3,a));break;case "K":var h=c,k="K"==b.charAt(c+1)?++c:c;d.push(new zul.inp.HourHandler2([h,
k],7));break;case "h":h=c;k="h"==b.charAt(c+1)?++c:c;d.push(new zul.inp.HourHandler([h,k],6));break;case "H":h=c;k="H"==b.charAt(c+1)?++c:c;d.push(new zul.inp.HourInDayHandler([h,k],4));break;case "k":h=c;k="k"==b.charAt(c+1)?++c:c;d.push(new zul.inp.HourInDayHandler2([h,k],5));break;case "m":h=c;k="m"==b.charAt(c+1)?++c:c;d.push(new zul.inp.MinuteHandler([h,k],1));break;case "s":h=c;k="s"==b.charAt(c+1)?++c:c;d.push(new zul.inp.SecondHandler([h,k],2));break;case "z":d.push({index:[c,c],format:function(a){return function(){return a}}(a._timezoneAbbr)});
break;default:var l="";for(k=h=c;(l+=g)&&++k<f;)if(g=b.charAt(k),-1!="ahKHksmz".indexOf(g)){k--;break}d.push({index:[h,k],format:function(a){return function(){return a}}(l)});c=k}}c=0;for(f=d.length;c<f;c++)if(3==d[c].type){var m=d[c].index[1]-d[c].index[0];if(!m)break}else m&&(d[c].index[0]+=m,d[c].index[1]+=m);a._fmthdler=d}});zul.inp.TimeHandler=zk.$extends(zk.Object,{maxsize:59,minsize:0,digits:2,$init:function(a,b,d){this.index=a;this.type=b;a[0]==a[1]&&(this.digits=1);this.wgt=d},format:function(a){return"00"},
unformat:function(a,b){return a},increase:function(a,b){var d=a.getInputNode(),e=this.index[0],c=this.index[1]+1,f=d.value,g=this.getText(f),h=!1!==this.isSingleLength();g=zk.parseInt(h?g:g.replace(/ /g,"0"))+b;var k=this.maxsize+1;if(g<this.minsize){g=this.maxsize;var l=1}else g>=k?(g=this.minsize,l=-1):h&&(l=0<b?10==g?1:0:9==g?-1:0);10>g&&!h&&(g="0"+g);d.value=f.substring(0,e)+g+f.substring(c);h&&l&&(this._doShift(a,l),c+=l);zk(d).setSelectionRange(e,c)},deleteTime:function(a,b){var d=a.getInputNode(),
e=zk(d).getSelectionRange(),c=e[0],f=d.value,g=this.$class._getMaxLen(a);f.length>g&&(f=d.value=f.substr(0,g),e=[Math.min(e[0],g),Math.min(e[1],g)],c=e[0]);if(c!=e[1])d.value=f.substring(0,c)+this.$class._cleanSelectionText(a,this)+f.substring(e[1]);else{var h=a._fmthdler,k=h.$indexOf(this);e=b?-1:1;var l=b?0:1;g=b?1:0;if(c==this.index[l]+l){if(h=h[k+2*e])c=h.index[g]+g+e}else c+=e,h=this;if(h){var m=h.isSingleLength();d.value=f.substring(0,(g+=c)-1)+(m?"":" ")+f.substring(g);m&&h._doShift(a,m)}m&&
!b&&c--}zk(d).setSelectionRange(c,c)},_addNextTime:function(a,b){var d=a.getInputNode(),e;if(e=a.getNextTimeHandler(this)){var c=e.index[0];zk(d).setSelectionRange(c,Math.max(c,zk(d).getSelectionRange()[1]));e.addTime(a,b)}},addTime:function(a,b){var d=a.getInputNode(),e=zk(d).getSelectionRange(),c=d.value,f=e[0],g=this.$class._getMaxLen(a),h=this.isSingleLength();c.length>g&&(c=d.value=c.substr(0,g),e=[Math.min(e[0],g),Math.min(e[1],g)],f=e[0]);if(f!=g){if(f==this.index[0]){var k=this.getText(c).substring(0===
h?0:2).trim();k.length||(k="0");zk.parseInt(b+k)>this.maxsize&&(0!==h&&(c=d.value=c.substring(0,f)+(h?"0":"00")+c.substring(f+2),h||f++,zk(d).setSelectionRange(f,Math.max(e[1],f)),e=zk(d).getSelectionRange()),h&&this._doShift(a,h))}else if(f==this.index[1]+1){if(!1!==h&&(k=this.getText(c),(k=zk.parseInt(k+b))<=this.maxsize))if(k&&10>k)f--;else if(k||h)c=d.value=c.substring(0,f+h)+(h?"":"0")+c.substring(f),k?this._doShift(a,1):(zk(d).setSelectionRange(f,Math.max(e[1],f)),h&&this._doShift(a,h));if(!k||
k>this.maxsize){this._addNextTime(a,b);return}}if(f!=e[1]){k=this.$class._cleanSelectionText(a,this);var l;!1!==h&&(l=f-this.index[1])&&this._doShift(a,l);d.value=c.substring(0,f++)+b+k.substring(l?0:1)+c.substring(e[1])}else d.value=c.substring(0,f)+b+c.substring(++f);a.lastPos=f;zk(d).setSelectionRange(f,f)}},getText:function(a){return a.substring(this.index[0],this.index[1]+1)},_doShift:function(a,b){a=a._fmthdler;var d=a.$indexOf(this),e;for(this.index[1]+=b;e=a[++d];)e.index[0]+=b,e.index[1]+=
b},isSingleLength:function(){return 1==this.digits&&this.index[0]-this.index[1]}},{_getMaxLen:function(a){for(var b=a.getInputNode().value,d=0,e,c=0,f=a._fmthdler,g=f.length;c<g;c++)a=f[c],d=c==g-1?d+a.format().length:d+(a.type?a.getText(b):a.format()).length,a.type&&(e=a);return 1==e.digits?++d:d},_cleanSelectionText:function(a,b){var d=a.getInputNode(),e=zk(d).getSelectionRange();d=e[0];e=e[1];var c=a._fmthdler,f=c.$indexOf(b),g="",h=!0,k;do{var l=b.index[0];var m=b.index[1]+1;b.type&&(k=b.isSingleLength())&&
(b._doShift(a,k),e--);if(m>=e&&b.type){for(l=e-l;0<l--;)g+=" ";break}if(b.type){var n=h?d:l;h=!1}else{for(l-=n;0<l--;)g+=" ";g+=b.format()}}while(b=c[++f]);return g}});zul.inp.HourInDayHandler=zk.$extends(zul.inp.TimeHandler,{maxsize:23,minsize:0,format:function(a){var b=1==this.digits;return a?(a=a.getHours(),!b&&10>a&&(a="0"+a),a.toString()):b?"0":"00"},unformat:function(a,b){a.setHours(zk.parseInt(this.getText(b)));return a}});zul.inp.HourInDayHandler2=zk.$extends(zul.inp.TimeHandler,{maxsize:24,
minsize:1,format:function(a){return a?(a=a.getHours(),0==a?a="24":2==this.digits&&10>a&&(a="0"+a),a.toString()):"24"},unformat:function(a,b){b=zk.parseInt(this.getText(b));24==b&&(b=0);a.setHours(b);return a}});zul.inp.HourHandler=zk.$extends(zul.inp.TimeHandler,{maxsize:12,minsize:1,format:function(a){return a?(a=a.getHours(),a%=12,0==a?a="12":2==this.digits&&10>a&&(a="0"+a),a.toString()):"12"},unformat:function(a,b,d){b=zk.parseInt(this.getText(b));12==b&&(b=0);a.setHours(d?b:b+12);return a}});
zul.inp.HourHandler2=zk.$extends(zul.inp.TimeHandler,{maxsize:11,minsize:0,format:function(a){var b=1==this.digits;return a?(a=a.getHours(),a%=12,!b&&10>a&&(a="0"+a),a.toString()):b?"0":"00"},unformat:function(a,b,d){b=zk.parseInt(this.getText(b));a.setHours(d?b:b+12);return a}});zul.inp.MinuteHandler=zk.$extends(zul.inp.TimeHandler,{format:function(a){var b=1==this.digits;return a?(a=a.getMinutes(),!b&&10>a&&(a="0"+a),a.toString()):b?"0":"00"},unformat:function(a,b){a.setMinutes(zk.parseInt(this.getText(b)));
return a}});zul.inp.SecondHandler=zk.$extends(zul.inp.TimeHandler,{format:function(a){var b=1==this.digits;return a?(a=a.getSeconds(),!b&&10>a&&(a="0"+a),a.toString()):b?"0":"00"},unformat:function(a,b){a.setSeconds(zk.parseInt(this.getText(b)));return a}});zul.inp.AMPMHandler=zk.$extends(zul.inp.TimeHandler,{format:function(a){var b=this.wgt._localizedSymbols?this.wgt._localizedSymbols.APM:zk.APM;if(!a)return b[0];a=a.getHours();return b[12>a?0:1]},unformat:function(a,b){a=this.getText(b).trim();
b=this.wgt._localizedSymbols?this.wgt._localizedSymbols.APM:zk.APM;return a.length==b[0].length?b[0]==a:!0},addTime:function(a,b){var d=a.getInputNode(),e=this.index[0],c=this.index[1]+1,f=d.value,g=f.substring(e,c),h=a._localizedSymbols?a._localizedSymbols.APM:zk.APM;g!=h[0]&&g!=h[1]&&(g=h[0],d.value=f.substring(0,e)+g+f.substring(c));this._addNextTime(a,b)},deleteTime:function(a,b){var d=a.getInputNode(),e=zk(d).getSelectionRange(),c=this.index[0],f=this.index[1]+1,g=d.value;if(e[1]-e[0]>f-c)return this.$supers("deleteTime",
arguments);e=[""];for(var h=f-c;0<h;h--)e.push(" ");d.value=g.substring(0,c)+e.join("")+g.substring(f);zk(d).setSelectionRange(c,c)},increase:function(a,b){b=a.getInputNode();var d=this.index[0],e=this.index[1]+1,c=b.value,f=c.substring(d,e);a=a._localizedSymbols?a._localizedSymbols.APM:zk.APM;f=a[0]==f?a[1]:a[0];b.value=c.substring(0,d)+f+c.substring(e);zk(b).setSelectionRange(d,e)}})})();
