/* w2ui 1.5.rc1 (nightly) (c) http://w2ui.com, vitmalina@gmail.com */ var w2ui=w2ui||{},w2obj=w2obj||{},w2utils=function(a){function b(a){var b=/^[0-1]+$/;return b.test(a)}function c(a){var b=/^[-+]?[0-9]+$/;return b.test(a)}function d(a){return"string"==typeof a&&(a=a.replace(/\s+/g,"").replace(w2utils.settings.groupSymbol,"").replace(w2utils.settings.decimalSymbol,".")),("number"==typeof a||"string"==typeof a&&""!==a)&&!isNaN(Number(a))}function e(a){var b=w2utils.settings,c=new RegExp("^"+(b.currencyPrefix?"\\"+b.currencyPrefix+"?":"")+"[-+]?"+(b.currencyPrefix?"\\"+b.currencyPrefix+"?":"")+"[0-9]*[\\"+b.decimalSymbol+"]?[0-9]+"+(b.currencySuffix?"\\"+b.currencySuffix+"?":"")+"$","i");return"string"==typeof a&&(a=a.replace(new RegExp(b.groupSymbol,"g"),"")),"object"!=typeof a&&""!==a&&c.test(a)}function f(a){var b=/^[a-fA-F0-9]+$/;return b.test(a)}function g(a){var b=/^[a-zA-Z0-9_-]+$/;return b.test(a)}function h(a){var b=/^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;return b.test(a)}function i(a,b,d){if(!a)return!1;var e,f,g,h="Invalid Date";if(null==b&&(b=w2utils.settings.dateFormat),"function"==typeof a.getUTCFullYear)g=a.getUTCFullYear(),e=a.getUTCMonth()+1,f=a.getUTCDate();else if(parseInt(a)==a&&parseInt(a)>0)a=new Date(parseInt(a)),g=a.getUTCFullYear(),e=a.getUTCMonth()+1,f=a.getUTCDate();else{if(a=String(a),new RegExp("mon","ig").test(b)){b=b.replace(/month/gi,"m").replace(/mon/gi,"m").replace(/dd/gi,"d").replace(/[, ]/gi,"/").replace(/\/\//g,"/").toLowerCase(),a=a.replace(/[, ]/gi,"/").replace(/\/\//g,"/").toLowerCase();for(var i=0,j=w2utils.settings.fullmonths.length;i=0,f=b.indexOf("PM")>=0;var g=f||e;d=g?12:24,b=b.replace("AM","").replace("PM",""),b=a.trim(b);var h=b.split(":"),i=parseInt(h[0]||0),j=parseInt(h[1]||0),k=parseInt(h[2]||0);return!!(g&&1===h.length||2===h.length||3===h.length)&&(!(""===h[0]||i<0||i>d||!this.isInt(h[0])||h[0].length>2)&&(!(h.length>1&&(""===h[1]||j<0||j>59||!this.isInt(h[1])||2!==h[1].length))&&(!(h.length>2&&(""===h[2]||k<0||k>59||!this.isInt(h[2])||2!==h[2].length))&&(!!(g||d!==i||0===j&&0===k)&&((!g||1!==h.length||0!==i)&&(c!==!0||(f&&12!==i&&(i+=12),e&&12===i&&(i+=12),{hours:i,minutes:j,seconds:k})))))))}function k(a,b,c){null==b&&(b=w2utils.settings.datetimeFormat);var d=b.split("|");if("function"==typeof a.getUTCFullYear)return c!==!0||a;if(parseInt(a)==a&&parseInt(a)>0)return a=new Date(parseInt(a)),c!==!0||a;var e=String(a).indexOf(" "),f=[a.substr(0,e),a.substr(e).trim()];d[0]=d[0].trim(),d[1]&&(d[1]=d[1].trim());var g=w2utils.isDate(f[0],d[0],!0),h=w2utils.isTime(f[1],!0);return g!==!1&&h!==!1&&(c!==!0||(g.setHours(h.hours),g.setMinutes(h.minutes),g.setSeconds(h.seconds),g))}function l(a){var b;if(""===a||null==a)return"";if(b="function"==typeof a.getUTCFullYear?a:parseInt(a)==a&&parseInt(a)>0?new Date(parseInt(a)):new Date(a),"Invalid Date"==String(b))return"";var c=new Date,d=(c.getTime()-b.getTime())/1e3,e="",f="";return d<0?(e=0,f="sec"):d<60?(e=Math.floor(d),f="sec",d<0&&(e=0,f="sec")):d<3600?(e=Math.floor(d/60),f="min"):d<86400?(e=Math.floor(d/60/60),f="hour"):d<2592e3?(e=Math.floor(d/24/60/60),f="day"):d<31536e3?(e=Math.floor(d/30/24/60/60*10)/10,f="month"):d<126144e3?(e=Math.floor(d/365/24/60/60*10)/10,f="year"):d>=126144e3&&(e=Math.floor(d/365.25/24/60/60*10)/10,f="year"),e+" "+f+(e>1?"s":"")}function m(a){var b="";return b=a<1e3?"< 1 sec":a<6e4?Math.floor(a/1e3)+" secs":a<36e5?Math.floor(a/6e4)+" mins":a<864e5?Math.floor(a/36e5*10)/10+" hours":a<2628e6?Math.floor(a/864e5*10)/10+" days":a<31536e6?Math.floor(a/2628e6*10)/10+" months":Math.floor(a/31536e5)/10+" years"}function n(a){if(""===a||null==a||"object"==typeof a&&!a.getMonth)return"";var b=new Date(a);if(w2utils.isInt(a)&&(b=new Date(Number(a))),"Invalid Date"==String(b))return"";var c=w2utils.settings.shortmonths,d=new Date,e=new Date;e.setTime(e.getTime()-864e5);var f=c[b.getMonth()]+" "+b.getDate()+", "+b.getFullYear(),g=c[d.getMonth()]+" "+d.getDate()+", "+d.getFullYear(),h=c[e.getMonth()]+" "+e.getDate()+", "+e.getFullYear(),i=b.getHours()-(b.getHours()>12?12:0)+":"+(b.getMinutes()<10?"0":"")+b.getMinutes()+" "+(b.getHours()>=12?"pm":"am"),j=b.getHours()-(b.getHours()>12?12:0)+":"+(b.getMinutes()<10?"0":"")+b.getMinutes()+":"+(b.getSeconds()<10?"0":"")+b.getSeconds()+" "+(b.getHours()>=12?"pm":"am"),k=f;return f===g&&(k=i),f===h&&(k=w2utils.lang("Yesterday")),''+k+""}function o(a){if(!w2utils.isFloat(a)||""===a)return"";if(a=parseFloat(a),0===a)return 0;var b=["Bt","KB","MB","GB","TB","PB","EB","ZB"],c=parseInt(Math.floor(Math.log(a)/Math.log(1024)));return(Math.floor(a/Math.pow(1024,c)*10)/10).toFixed(0===c?0:1)+" "+(b[c]||"??")}function p(a,b,c){if(null==a||""===a||"object"==typeof a)return"";var d={minimumFractionDigits:b,maximumFractionDigits:b,useGrouping:c};return(null==b||b<0)&&(d.minimumFractionDigits=0,d.maximumFractionDigits=20),parseFloat(a).toLocaleString(w2utils.settings.locale,d)}function q(a,b){if(b||(b=this.settings.dateFormat),""===a||null==a||"object"==typeof a&&!a.getMonth)return"";var c=new Date(a);if(w2utils.isInt(a)&&(c=new Date(Number(a))),"Invalid Date"==String(c))return"";var d=c.getFullYear(),e=c.getMonth(),f=c.getDate();return b.toLowerCase().replace("month",w2utils.settings.fullmonths[e]).replace("mon",w2utils.settings.shortmonths[e]).replace(/yyyy/g,d).replace(/yyy/g,d).replace(/yy/g,d>2e3?100+parseInt(String(d).substr(2)):String(d).substr(2)).replace(/(^|[^a-z$])y/g,"$1"+d).replace(/mm/g,(e+1<10?"0":"")+(e+1)).replace(/dd/g,(f<10?"0":"")+f).replace(/th/g,1==f?"st":"th").replace(/th/g,2==f?"nd":"th").replace(/th/g,3==f?"rd":"th").replace(/(^|[^a-z$])m/g,"$1"+(e+1)).replace(/(^|[^a-z$])d/g,"$1"+f)}function r(a,b){w2utils.settings.shortmonths,w2utils.settings.fullmonths;if(b||(b=this.settings.timeFormat),""===a||null==a||"object"==typeof a&&!a.getMonth)return"";var c=new Date(a);if(w2utils.isInt(a)&&(c=new Date(Number(a))),w2utils.isTime(a)){var d=w2utils.isTime(a,!0);c=new Date,c.setHours(d.hours),c.setMinutes(d.minutes)}if("Invalid Date"==String(c))return"";var e="am",f=c.getHours(),g=c.getHours(),h=c.getMinutes(),i=c.getSeconds();return h<10&&(h="0"+h),i<10&&(i="0"+i),b.indexOf("am")===-1&&b.indexOf("pm")===-1||(f>=12&&(e="pm"),f>12&&(f-=12)),b.toLowerCase().replace("am",e).replace("pm",e).replace("hhh",f<10?"0"+f:f).replace("hh24",g<10?"0"+g:g).replace("h24",g).replace("hh",f).replace("mm",h).replace("mi",h).replace("ss",i).replace(/(^|[^a-z$])h/g,"$1"+f).replace(/(^|[^a-z$])m/g,"$1"+h).replace(/(^|[^a-z$])s/g,"$1"+i)}function s(a,b){var c;return""===a||null==a||"object"==typeof a&&!a.getMonth?"":("string"!=typeof b?c=[this.settings.dateFormat,this.settings.timeFormat]:(c=b.split("|"),c[0]=c[0].trim(),c[1]=c[1].trim()),"h12"==c[1]&&(c[1]="h:m pm"),"h24"==c[1]&&(c[1]="h24:m"),this.formatDate(a,c[0])+" "+this.formatTime(a,c[1]))}function t(b){if(null==b)return b;switch(typeof b){case"number":break;case"string":b=String(b).replace(/(<([^>]+)>)/gi,"");break;case"object":if(Array.isArray(b)){b=a.extend(!0,[],b);for(var c=0;c/g,">").replace(/").replace(/</g,"<").replace(/"/g,'"').replace(/&/g,"&");break;case"object":if(Array.isArray(b)){b=a.extend(!0,[],b);for(var c=0;c\|\/? {}\\])/g,"\\$1")}function x(a){function b(a){a=String(a).replace(/\r\n/g,"\n");for(var b="",c=0;c127&&d<2048?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b}var c,d,e,f,g,h,i,j="",k=0,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";for(a=b(a);k>2,g=(3&c)<<4|d>>4,h=(15&d)<<2|e>>6,i=63&e,isNaN(d)?h=i=64:isNaN(e)&&(i=64),j=j+l.charAt(f)+l.charAt(g)+l.charAt(h)+l.charAt(i);return j}function y(a){function b(a){for(var b,c,d="",e=0,f=0;e191&&f<224?(b=a.charCodeAt(e+1),d+=String.fromCharCode((31&f)<<6|63&b),e+=2):(b=a.charCodeAt(e+1),c=a.charCodeAt(e+2),d+=String.fromCharCode((15&f)<<12|(63&b)<<6|63&c),e+=3);return d}var c,d,e,f,g,h,i,j="",k=0,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(c),64!==h&&(j+=String.fromCharCode(d)),64!==i&&(j+=String.fromCharCode(e));return j=b(j)}function z(a){function b(a){return d(c(e(a)))}function c(a){return g(h(f(a),8*a.length))}function d(a){try{}catch(a){p=0}for(var b,c=p?"0123456789ABCDEF":"0123456789abcdef",d="",e=0;e>>4&15)+c.charAt(15&b);return d}function e(a){for(var b,c,d="",e=-1;++e>>6&31,128|63&b):b<=65535?d+=String.fromCharCode(224|b>>>12&15,128|b>>>6&63,128|63&b):b<=2097151&&(d+=String.fromCharCode(240|b>>>18&7,128|b>>>12&63,128|b>>>6&63,128|63&b));return d}function f(a){for(var b=Array(a.length>>2),c=0;c>5]|=(255&a.charCodeAt(c/8))<>5]>>>c%32&255);return b}function h(a,b){a[b>>5]|=128<>>9<<4)+14]=b;for(var c=1732584193,d=-271733879,e=-1732584194,f=271733878,g=0;g>16)+(b>>16)+(c>>16);return d<<16|65535&c}function o(a,b){return a<>>32-b}var p=0;return b(a)}function A(b,c,d,e){var f=a(b).width(),g=a(b).height(),h=.5;if(!b||!c)return void console.log("ERROR: Cannot do transition when one of the divs is null");switch(b.parentNode.style.cssText+="perspective: 900px; overflow: hidden;",b.style.cssText+="; position: absolute; z-index: 1019; backface-visibility: hidden",c.style.cssText+="; position: absolute; z-index: 1020; backface-visibility: hidden",d){case"slide-left":b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; transform: translate3d("+f+"px, 0, 0)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: translate3d(0, 0, 0)",b.style.cssText+="transition: "+h+"s; transform: translate3d(-"+f+"px, 0, 0)"},1);break;case"slide-right":b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; transform: translate3d(-"+f+"px, 0, 0)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: translate3d(0px, 0, 0)",b.style.cssText+="transition: "+h+"s; transform: translate3d("+f+"px, 0, 0)"},1);break;case"slide-down":b.style.cssText+="overflow: hidden; z-index: 1; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; z-index: 0; transform: translate3d(0, 0, 0)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: translate3d(0, 0, 0)",b.style.cssText+="transition: "+h+"s; transform: translate3d(0, "+g+"px, 0)"},1);break;case"slide-up":b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; transform: translate3d(0, "+g+"px, 0)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: translate3d(0, 0, 0)",b.style.cssText+="transition: "+h+"s; transform: translate3d(0, 0, 0)"},1);break;case"flip-left":b.style.cssText+="overflow: hidden; transform: rotateY(0deg)",c.style.cssText+="overflow: hidden; transform: rotateY(-180deg)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: rotateY(0deg)",b.style.cssText+="transition: "+h+"s; transform: rotateY(180deg)"},1);break;case"flip-right":b.style.cssText+="overflow: hidden; transform: rotateY(0deg)",c.style.cssText+="overflow: hidden; transform: rotateY(180deg)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: rotateY(0deg)",b.style.cssText+="transition: "+h+"s; transform: rotateY(-180deg)"},1);break;case"flip-down":b.style.cssText+="overflow: hidden; transform: rotateX(0deg)",c.style.cssText+="overflow: hidden; transform: rotateX(180deg)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: rotateX(0deg)",b.style.cssText+="transition: "+h+"s; transform: rotateX(-180deg)"},1);break;case"flip-up":b.style.cssText+="overflow: hidden; transform: rotateX(0deg)",c.style.cssText+="overflow: hidden; transform: rotateX(-180deg)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: rotateX(0deg)",b.style.cssText+="transition: "+h+"s; transform: rotateX(180deg)"},1);break;case"pop-in":b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); transform: scale(.8); opacity: 0;",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: scale(1); opacity: 1;",b.style.cssText+="transition: "+h+"s;"},1);break;case"pop-out":b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); transform: scale(1); opacity: 1;",c.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); opacity: 0;",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; opacity: 1;",b.style.cssText+="transition: "+h+"s; transform: scale(1.7); opacity: 0;"},1);break;default:b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; translate3d(0, 0, 0); opacity: 0;",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; opacity: 1;",b.style.cssText+="transition: "+h+"s"},1)}setTimeout(function(){"slide-down"===d&&(a(b).css("z-index","1019"),a(c).css("z-index","1020")),c&&a(c).css({opacity:"1"}).css(w2utils.cssPrefix({transition:"",transform:""})),b&&a(b).css({opacity:"1"}).css(w2utils.cssPrefix({transition:"",transform:""})),"function"==typeof e&&e()},1e3*h)}function B(b,c,d){var e={};"object"==typeof c?e=c:(e.msg=c,e.spinner=d),e.msg||0===e.msg||(e.msg=""),w2utils.unlock(b),a(b).prepend('
');var f=a(b).find(".w2ui-lock"),g=a(b).find(".w2ui-lock-msg");e.msg||g.css({"background-color":"transparent",border:"0px"}),e.spinner===!0&&(e.msg='
"+e.msg),null!=e.opacity&&f.css("opacity",e.opacity),"function"==typeof f.fadeIn?(f.fadeIn(200),g.html(e.msg).fadeIn(200)):(f.show(),g.html(e.msg).show(0))}function C(b,d){c(d)?(a(b).find(".w2ui-lock").fadeOut(d),setTimeout(function(){a(b).find(".w2ui-lock").remove(),a(b).find(".w2ui-lock-msg").remove()},d)):(a(b).find(".w2ui-lock").remove(),a(b).find(".w2ui-lock-msg").remove())}function D(b,c){function d(c,d){if(null==f&&(f=d.trigger({phase:"before",type:"open",target:"self"}),f.isCancelled===!0))return l.css("z-index",l.data("old-z-index")),void a(b.box).find("#w2ui-message"+n).remove();var e=c.data("prev_focus");c.remove(),e&&e.length>0?e.focus():g&&g.focus&&g.focus(),l.css("z-index",l.data("old-z-index")),d.trigger(a.extend(f,{phase:"after"}))}var e,f,g=this;a().w2tag(),c||(c={width:200,height:100}),null==c.on&&a.extend(c,w2utils.event),null==c.width&&(c.width=200),null==c.height&&(c.height=100);var h=parseInt(a(b.box).width()),i=parseInt(a(b.box).height()),j=parseInt(a(b.box).find(b.title).css("height")||0);c.width>h&&(c.width=h-10),c.height>i-j&&(c.height=i-10-j),c.originalWidth=c.width,c.originalHeight=c.height,parseInt(c.width)<0&&(c.width=h+c.width),parseInt(c.width)<10&&(c.width=10),parseInt(c.height)<0&&(c.height=i+c.height-j),parseInt(c.height)<10&&(c.height=10),null==c.hideOnClick&&(c.hideOnClick=!1);var k=a(b.box).data("options")||{};(null==c.width||c.width>k.width-10)&&(c.width=k.width-10),(null==c.height||c.height>k.height-j-5)&&(c.height=k.height-j-5),c.originalHeight<0&&(c.height=i+c.originalHeight-j),c.originalWidth<0&&(c.width=h+2*c.originalWidth);var l=a(b.box).find(b.title),m=a(b.box).find(".w2ui-message.w2ui-closing");a(b.box).find(".w2ui-message.w2ui-closing").length>0&&(clearTimeout(e),d(m,m.data("options")||{}));var n=a(b.box).find(".w2ui-message").length;if(""===a.trim(c.html)&&""===a.trim(c.body)&&""===a.trim(c.buttons)){if(0===n)return;var o=a(b.box).find("#w2ui-message"+(n-1)),c=o.data("options")||{};if(f=c.trigger({phase:"before",type:"close",target:"self"}),f.isCancelled===!0)return;o.css(w2utils.cssPrefix({transition:"0.15s",transform:"translateY(-"+c.height+"px)"})).addClass("w2ui-closing"),1==n?this.unlock&&(b.param?this.unlock(b.param,150):this.unlock(150)):a(b.box).find("#w2ui-message"+(n-2)).css("z-index",1500),e=setTimeout(function(){d(o,c)},150)}else{""===a.trim(c.body)&&""===a.trim(c.buttons)||(c.html='
'+(c.body||"")+'
'+(c.buttons||"")+"
"),a(b.box).find(".w2ui-message").css("z-index",1390),l.data("old-z-index",l.css("z-index")),l.css("z-index",1501),a(b.box).find(b.body).before('"),a(b.box).find("#w2ui-message"+n).data("options",c).data("prev_focus",a(":focus"));var p=a(b.box).find("#w2ui-message"+n).css("display");if(a(b.box).find("#w2ui-message"+n).css(w2utils.cssPrefix({transform:"none"==p?"translateY(-"+c.height+"px)":"translateY(0px)"})),"none"==p){if(a(b.box).find("#w2ui-message"+n).show().html(c.html),c.box=a(b.box).find("#w2ui-message"+n),f=c.trigger({phase:"before",type:"open",target:"self"}),f.isCancelled===!0)return l.css("z-index",l.data("old-z-index")),void a(b.box).find("#w2ui-message"+n).remove();setTimeout(function(){a(b.box).find("#w2ui-message"+n).css(w2utils.cssPrefix({transform:"none"==p?"translateY(0px)":"translateY(-"+c.height+"px)"}))},1),0===n&&this.lock&&(b.param?this.lock(b.param):this.lock()),setTimeout(function(){a(b.box).find("#w2ui-message"+n).css(w2utils.cssPrefix({transition:"0s"})),c.trigger(a.extend(f,{phase:"after"}))},350)}}}function E(b,c){var d=a(b),e={left:parseInt(d.css("border-left-width"))||0,right:parseInt(d.css("border-right-width"))||0,top:parseInt(d.css("border-top-width"))||0,bottom:parseInt(d.css("border-bottom-width"))||0},f={left:parseInt(d.css("margin-left"))||0,right:parseInt(d.css("margin-right"))||0,top:parseInt(d.css("margin-top"))||0,bottom:parseInt(d.css("margin-bottom"))||0},g={left:parseInt(d.css("padding-left"))||0,right:parseInt(d.css("padding-right"))||0,top:parseInt(d.css("padding-top"))||0,bottom:parseInt(d.css("padding-bottom"))||0};switch(c){case"top":return e.top+f.top+g.top;case"bottom":return e.bottom+f.bottom+g.bottom;case"left":return e.left+f.left+g.left;case"right":return e.right+f.right+g.right;case"width":return e.left+e.right+f.left+f.right+g.left+g.right+parseInt(d.width());case"height":return e.top+e.bottom+f.top+f.bottom+g.top+g.bottom+parseInt(d.height());case"+width":return e.left+e.right+f.left+f.right+g.left+g.right;case"+height":return e.top+e.bottom+f.top+f.bottom+g.top+g.bottom}return 0}function F(b,c){var d,e='
'+u(b)+"
";return a("body").append(e),d=a("#_tmp_width").width(),a("#_tmp_width").remove(),d}function G(a){var b=this.settings.phrases[a];return null==b?a:b}function H(b){return b||(b="en-us"),"string"!=typeof b?void(w2utils.settings=a.extend(!0,w2utils.settings,b)):(5===b.length&&(b="locale/"+b+".json"),w2utils.settings.phrases={},void a.ajax({url:b,type:"GET",dataType:"JSON",async:!1,success:function(b,c,d){w2utils.settings=a.extend(!0,w2utils.settings,b)},error:function(a,c,d){console.log("ERROR: Cannot load locale "+b)}}))}function I(){if(Q.scrollBarSize)return Q.scrollBarSize;var b='
1
';return a("body").append(b),Q.scrollBarSize=100-a("#_scrollbar_width > div").width(),a("#_scrollbar_width").remove(),String(navigator.userAgent).indexOf("MSIE")>=0&&(Q.scrollBarSize=Q.scrollBarSize/2),Q.scrollBarSize}function J(a,b){return a&&null!=a.name?null!=w2ui[a.name]?(console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+a.name+")."),!1):!!w2utils.isAlphaNumeric(a.name)||(console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). '),!1):(console.log('ERROR: The parameter "name" is required but not supplied in $().'+b+"()."),!1)}function K(b,c,d,e){a.isArray(c)||(c=[c]);for(var f=0;f0){var f=b.getRangeAt(0),g=f.cloneRange();g.selectNodeContents(a),g.setEnd(f.endContainer,f.endOffset),c=g.toString().length}}else if((b=d.selection)&&"Control"!=b.type){var h=b.createRange(),i=d.body.createTextRange();i.moveToElementText(a),i.setEndPoint("EndToEnd",h),c=i.text.length}return c}function O(b,c,d){var e,f=document.createRange(),g=window.getSelection();if(null!=b){for(var h=0;h").replace(/&/g,"&").replace(/"/g,'"').replace(/ /g," ")),c<=i.length){e=b.childNodes[h],e.childNodes&&e.childNodes.length>0&&(e=e.childNodes[0]),e.childNodes&&e.childNodes.length>0&&(e=e.childNodes[0]);break}c-=i.length}null!=e&&(c>e.length&&(c=e.length),f.setStart(e,c),d?f.setEnd(e,d):f.collapse(!0),g.removeAllRanges(),g.addRange(f))}}function P(){var a="w2ui_test";try{return localStorage.setItem(a,a),localStorage.removeItem(a),!0}catch(a){return!1}}var Q={},R={version:"1.5.RC1",settings:{locale:"en-us",dateFormat:"m/d/yyyy",timeFormat:"hh:mi pm",datetimeFormat:"m/d/yyyy|hh:mi pm",currencyPrefix:"$",currencySuffix:"",currencyPrecision:2,groupSymbol:",",decimalSymbol:".",shortmonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],fullmonths:["January","February","March","April","May","June","July","August","September","October","November","December"],shortdays:["M","T","W","T","F","S","S"],fulldays:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],weekStarts:"M",dataType:"HTTPJSON",phrases:{},dateStartYear:1950,dateEndYear:2020},isBin:b,isInt:c,isFloat:d,isMoney:e,isHex:f,isAlphaNumeric:g,isEmail:h,isDate:i,isTime:j,isDateTime:k,age:l,interval:m,date:n,formatSize:o,formatNumber:p,formatDate:q,formatTime:r,formatDateTime:s,stripTags:t,encodeTags:u,decodeTags:v,escapeId:w,base64encode:x,base64decode:y,md5:z,transition:A,lock:B,unlock:C,message:D,lang:G,locale:H,getSize:E,getStrWidth:F,scrollBarSize:I,checkName:J,checkUniqueId:K,parseRoute:L,cssPrefix:M,getCursorPosition:N,setCursorPosition:O,testLocalStorage:P,hasLocalStorage:P(),isIOS:navigator.userAgent.toLowerCase().indexOf("iphone")!=-1||navigator.userAgent.toLowerCase().indexOf("ipod")!=-1||navigator.userAgent.toLowerCase().indexOf("ipad")!=-1,isIE:navigator.userAgent.toLowerCase().indexOf("msie")!=-1||navigator.userAgent.toLowerCase().indexOf("trident")!=-1};return R}(jQuery);w2utils.formatters={number:function(a,b){return parseInt(b)>20&&(b=20),parseInt(b)<0&&(b=0),null==a||""===a?"":w2utils.formatNumber(parseFloat(a),b,!0)},float:function(a,b){return w2utils.formatters.number(a,b)},int:function(a,b){return w2utils.formatters.number(a,0)},money:function(a,b){if(null==a||""===a)return"";var c=w2utils.formatNumber(Number(a),w2utils.settings.currencyPrecision||2);return(w2utils.settings.currencyPrefix||"")+c+(w2utils.settings.currencySuffix||"")},currency:function(a,b){return w2utils.formatters.money(a,b)},percent:function(a,b){return null==a||""===a?"":w2utils.formatNumber(a,b||1)+"%"},size:function(a,b){return null==a||""===a?"":w2utils.formatSize(parseInt(a))},date:function(a,b){if(""===b&&(b=w2utils.settings.dateFormat),null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,b,!0);return c===!1&&(c=w2utils.isDate(a,b,!0)),''+w2utils.formatDate(c,b)+""},datetime:function(a,b){if(""===b&&(b=w2utils.settings.datetimeFormat),null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,b,!0);return c===!1&&(c=w2utils.isDate(a,b,!0)),''+w2utils.formatDateTime(c,b)+""},time:function(a,b){if(""===b&&(b=w2utils.settings.timeFormat),"h12"===b&&(b="hh:mi pm"),"h24"===b&&(b="h24:mi"),null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,b,!0);return c===!1&&(c=w2utils.isDate(a,b,!0)),''+w2utils.formatTime(a,b)+""},timestamp:function(a,b){if(""===b&&(b=w2utils.settings.datetimeFormat),null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,b,!0);return c===!1&&(c=w2utils.isDate(a,b,!0)),c.toString?c.toString():""},gmt:function(a,b){if(""===b&&(b=w2utils.settings.datetimeFormat),null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,b,!0);return c===!1&&(c=w2utils.isDate(a,b,!0)),c.toUTCString?c.toUTCString():""},age:function(a,b){if(null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,null,!0);return c===!1&&(c=w2utils.isDate(a,null,!0)),''+w2utils.age(a)+(b?" "+b:"")+""},interval:function(a,b){return null==a||0===a||""===a?"":w2utils.interval(a)+(b?" "+b:"")},toggle:function(a,b){return a?"Yes":""},password:function(a,b){for(var c="",d=0;d=0;f--){var g=this.handlers[f];if(!(g.edata.type!==a.type&&"*"!==g.edata.type||g.edata.target!==a.target&&null!=g.edata.target||g.edata.execute!==a.phase&&"*"!==g.edata.execute&&"*"!==g.edata.phase)&&(a=b.extend({},g.edata,a),c=[],e=new RegExp(/\((.*?)\)/).exec(g.handler),e&&(c=e[1].split(/\s*,\s*/)),2===c.length?g.handler.call(this,a.target,a):g.handler.call(this,a),a.isStopped===!0||a.stop===!0))return a}var h="on"+a.type.substr(0,1).toUpperCase()+a.type.substr(1);if("before"===a.phase&&"function"==typeof this[h]&&(d=this[h],c=[],e=new RegExp(/\((.*?)\)/).exec(d),e&&(c=e[1].split(/\s*,\s*/)),2===c.length?d.call(this,a.target,a):d.call(this,a),a.isStopped===!0||a.stop===!0))return a;if(null!=a.object&&"before"===a.phase&&"function"==typeof a.object[h]&&(d=a.object[h],c=[],e=new RegExp(/\((.*?)\)/).exec(d),e&&(c=e[1].split(/\s*,\s*/)),2===c.length?d.call(this,a.target,a):d.call(this,a),a.isStopped===!0||a.stop===!0))return a;if("after"===a.phase){"function"==typeof a.onComplete&&a.onComplete.call(this,a);for(var i=0;i0&&("string"==typeof b&&w2ui[b]&&w2ui[b].render(a(this)[0]),"object"==typeof b&&b.render(a(this)[0]))},a.fn.w2destroy=function(a){!a&&this.length>0&&(a=this.attr("name")),"string"==typeof a&&w2ui[a]&&w2ui[a].destroy(),"object"==typeof a&&a.destroy()},a.fn.w2marker=function(){function b(a,b){for(;b.innerHTML.indexOf('')!=-1;)b.innerHTML=b.innerHTML.replace(/\((.|\n|\r)*)\<\/span\>/gi,"$1")}var c=Array.prototype.slice.call(arguments,0);return Array.isArray(c[0])&&(c=c[0]),0!==c.length&&c[0]?a(this).each(function(a,d){function e(a){return''+a+""}b(a,d);for(var f=0;f/g,"<");var h=new RegExp(g+"(?!([^<]+)?>)","gi");d.innerHTML=d.innerHTML.replace(h,e)}}):a(this).each(b)},a.fn.w2tag=function(b,c){return 1==arguments.length&&"object"==typeof b&&(c=b,null!=c.html&&(b=c.html)),c=a.extend({id:null,html:b,position:"right|top",align:"none",left:0,top:0,style:"",css:{},className:"",inputClass:"",onShow:null,onHide:null,hideOnKeyPress:!0,hideOnBlur:!1,hideOnClick:!1},c),null!=c.name&&null==c.id&&(c.id=c.name),""!==c.class&&""===c.inputClass&&(c.inputClass=c.class),0===a(this).length?void a(".w2ui-tag").each(function(b,c){var d=a(c).data("options");null==d&&(d={}),a(a(c).data("taged-el")).removeClass(d.inputClass).removeData("w2tag").removeData("checkIfMoved"),clearInterval(a(c).data("timer")),a(c).remove()}):a(this).each(function(d,e){function f(){j=a("#w2ui-tag-"+i),j.length<=0||(clearInterval(j.data("timer")),j.remove(),a(document).off(".w2tag"),a(e).off(".w2tag",f).removeClass(c.inputClass).removeData("w2tag").removeData("checkIfMoved"),a(e).length>0&&(a(e)[0].style.cssText=k),"function"==typeof c.onHide&&c.onHide())}function g(b,d){var h=a(e).offset();if(0===a(e).length||0===h.left&&0===h.top||0===j.find(".w2ui-tag-body").length)return clearInterval(j.data("timer")),void f();d||setTimeout(g,100);var i="w2ui-tag-right",k=parseInt(h.left+e.offsetWidth+(c.left?c.left:0)),l=parseInt(h.top+(c.top?c.top:0)),m=j.find(".w2ui-tag-body"),n=m[0].offsetWidth,o=m[0].offsetHeight;if("string"==typeof c.position&&c.position.indexOf("|")!=-1&&(c.position=c.position.split("|")),"top"==c.position)i="w2ui-tag-top",k=parseInt(h.left+(c.left?c.left:0))-14,l=parseInt(h.top+(c.top?c.top:0))-o-10;else if("bottom"==c.position)i="w2ui-tag-bottom",k=parseInt(h.left+(c.left?c.left:0))-14,l=parseInt(h.top+e.offsetHeight+(c.top?c.top:0))+10;else if("left"==c.position)i="w2ui-tag-left",k=parseInt(h.left+(c.left?c.left:0))-n-20,l=parseInt(h.top+(c.top?c.top:0));else if(Array.isArray(c.position)){for(var p=window.innerWidth,q=window.innerHeight,r=0;r=0)break}else if("top"==s){if(i="w2ui-tag-top",k=parseInt(h.left+(c.left?c.left:0))-14,l=parseInt(h.top+(c.top?c.top:0))-o-10,k+n<=p&&l>=0)break}else if("bottom"==s&&(i="w2ui-tag-bottom",k=parseInt(h.left+(c.left?c.left:0))-14,l=parseInt(h.top+e.offsetHeight+(c.top?c.top:0))+10,k+n<=p&&l+o<=q))break}m.data("posClass")!==i&&m.removeClass("w2ui-tag-right w2ui-tag-left w2ui-tag-top w2ui-tag-bottom").addClass(i).data("posClass",i)}return j.data("position")!==k+"x"+l&&b!==!0&&j.css(w2utils.cssPrefix({transition:d?"0s":".2s"})).css({left:k+"px",top:l+"px"}).data("position",k+"x"+l),{left:k,top:l,posClass:i}}var h=c.id?c.id:e.id,i=w2utils.escapeId(h),j=a("#w2ui-tag-"+i);if(""===b||null==b)return j.css("opacity",0),clearInterval(j.data("timer")),void j.remove();if(0!==j.length)c=a.extend(j.data("options"),c),j.data("options",c),j.find(".w2ui-tag-body").attr("style",c.style).addClass(c.className).html(c.html),g(!0);else{var k="";a(e).length>0&&(k=a(e)[0].style.cssText),a("body").append('"),j=a("#w2ui-tag-"+i),a(e).data("w2tag",j.get(0)).data("checkIfMoved",g)}setTimeout(function(){if(j.css("display","block"),a(e).offset()){var b=g(!0);null!=b&&(j.css({opacity:"1",left:b.left+"px",top:b.top+"px"}).data("options",c).data("taged-el",e).data("position",b.left+"x"+b.top).data("timer",setTimeout(g,100)).find(".w2ui-tag-body").addClass(b.posClass),a(e).css(c.css).off(".w2tag").addClass(c.inputClass),c.hideOnKeyPress&&a(e).on("keypress.w2tag",f),c.hideOnBlur&&a(e).on("blur.w2tag",f),c.hideOnClick&&a(document).on("click.w2tag",f),"function"==typeof c.onShow&&c.onShow())}},1)})},a.fn.w2overlay=function(b,c){function d(){var b=a("#w2ui-overlay"+h);if(b.data("element")===g[0]&&0!==b.length){var c=a(g).offset()||{},f=c.left+"x"+c.top;b.data("position")!==f?e():setTimeout(d,250)}}function e(b){if(!b||0===b.button){var d=a("#w2ui-overlay"+h);if(d.data("keepOpen")===!0)return void d.removeData("keepOpen");var f;"function"==typeof c.onHide&&(f=c.onHide()),f!==!1&&(d.remove(),a(document).off("click",e),clearInterval(d.data("timer")))}}function f(){var b=a("#w2ui-overlay"+h),d=b.find(" > div"),e=a("#w2ui-overlay"+h+" div.menu");if(e.css("overflow-y","hidden"),b.length>0){d.height("auto").width("auto");var i=!1,j=d.height(),k=d.width();c.width&&c.widtha.height()&&d.find("div.menu").css("overflow-y","hidden")},1),setTimeout(function(){var a=d.find("div.menu");"auto"!=a.css("overflow-y")&&a.css("overflow-y","auto")},10)),c.tmp.contentWidth&&"both"!=c.align&&(k=parseInt(c.tmp.contentWidth),d.width(k),setTimeout(function(){k>d.find("div.menu > table").width()&&d.find("div.menu > table").css("overflow-x","hidden")},1),setTimeout(function(){d.find("div.menu > table").css("overflow-x","auto")},10));var l=c.left,m=c.width,n=c.tipLeft;switch(c.align){case"both":l=17,0===c.width&&(c.width=w2utils.getSize(a(g),"width")),c.maxWidth&&c.width>c.maxWidth&&(c.width=c.maxWidth);break;case"left":l=17;break;case"right":l=w2utils.getSize(a(g),"width")-k+10,n=k-40}m=30!==k||m?c.width?c.width:"auto":30;var o=(k-17)/2;"auto"!=m&&(o=(m-17)/2),o<25&&(l=25-o,n=Math.floor(o));var p,q,r;if(c.contextMenu)p=c.pageX+8,q=c.pageY-0,r=c.pageY;else{var s=g.offset()||{};p=(s.left>25?s.left:25)+l,q=s.top+w2utils.getSize(g,"height")+c.top+7,r=s.top}b.css({left:p+"px",top:q+"px","min-width":m,"min-height":c.height?c.height:"auto"});var s=d.offset()||{},t=window.innerHeight+a(document).scrollTop()-s.top-7,u=window.innerWidth+a(document).scrollLeft()-s.left-7;if(c.contextMenu&&(t=window.innerHeight+a(document).scrollTop()-c.pageY-15,u=window.innerWidth+a(document).scrollLeft()-c.pageX),t>-50&&t<210||c.openAbove===!0){var v;c.contextMenu?(t=c.pageY-7,v=5):(t=s.top-a(document).scrollTop()-7,v=24),c.maxHeight&&t>c.maxHeight&&(t=c.maxHeight),j>t&&(i=!0,d.height(t).width(k).css({"overflow-y":"auto"}),j=t),b.addClass("bottom-arrow"),b.css("top",r-j-v+c.top+"px"),b.find(">style").html("#w2ui-overlay"+h+":before { margin-left: "+parseInt(n)+"px; }#w2ui-overlay"+h+":after { margin-left: "+parseInt(n)+"px; }")}else c.maxHeight&&t>c.maxHeight&&(t=c.maxHeight),j>t&&(i=!0,d.height(t).width(k).css({"overflow-y":"auto"})),b.addClass("top-arrow"),b.find(">style").html("#w2ui-overlay"+h+":before { margin-left: "+parseInt(n)+"px; }#w2ui-overlay"+h+":after { margin-left: "+parseInt(n)+"px; }");k=d.width(),u=window.innerWidth+a(document).scrollLeft()-s.left-7,c.maxWidth&&u>c.maxWidth&&(u=c.maxWidth),k>u&&"both"!==c.align&&(c.align="right",setTimeout(function(){f()},1)),(c.contextMenu||c.noTip)&&b.find(">style").html("#w2ui-overlay"+h+":before { display: none; }#w2ui-overlay"+h+":after { display: none; }"),i&&"both"!=c.align&&d.width(k+w2utils.scrollBarSize()+2)}e.css("overflow-y","auto")}var g=this,h="",i={name:null,html:"",align:"none",left:0,top:0,tipLeft:30,noTip:!1,selectable:!1,width:0,height:0,maxWidth:null,maxHeight:null,contextMenu:!1,pageX:null,pageY:null,originalEvent:null,style:"",class:"",overlayStyle:"",onShow:null,onHide:null,openAbove:!1,tmp:{}};1==arguments.length&&(c="object"==typeof b?b:{html:b}),2==arguments.length&&(c.html=b),a.isPlainObject(c)||(c={}),c=a.extend({},i,c),c.name&&(h="-"+c.name);var j;if(0===this.length||""===c.html||null==c.html)return a("#w2ui-overlay"+h).length>0?(j=a("#w2ui-overlay"+h)[0].hide,"function"==typeof j&&j()):a("#w2ui-overlay"+h).remove(),a(this);a("#w2ui-overlay"+h).length>0&&(j=a("#w2ui-overlay"+h)[0].hide,a(document).off(".w2overlayHide"),"function"==typeof j&&j()),g.length>0&&(null==g[0].tagName||"BODY"==g[0].tagName.toUpperCase())&&(c.contextMenu=!0),c.contextMenu&&c.originalEvent&&(c.pageX=c.originalEvent.pageX,c.pageY=c.originalEvent.pageY),!c.contextMenu||null!=c.pageX&&null!=c.pageY||console.log("ERROR: to display menu at mouse location, pass options.pageX and options.pageY."),a("body").append('');var k=a("#w2ui-overlay"+h),l=k.find(" > div");l.html(c.html);var m=l.css("background-color");null!=m&&"rgba(0, 0, 0, 0)"!==m&&"transparent"!==m&&k.css({"background-color":m,"border-color":m});var n=a(g).offset()||{};return k.data("element",g.length>0?g[0]:null).data("options",c).data("position",n.left+"x"+n.top).fadeIn("fast").on("click",function(a){"LABEL"==a.target.tagName.toUpperCase()&&a.stopPropagation()}).on("mousedown",function(b){a("#w2ui-overlay"+h).data("keepOpen",!0),["INPUT","TEXTAREA","SELECT"].indexOf(b.target.tagName.toUpperCase())!=-1||c.selectable||b.preventDefault()}),k[0].hide=e,k[0].resize=f,setTimeout(function(){f(),a(document).off(".w2overlayHide").on("click.w2overlayHide",e),"function"==typeof c.onShow&&c.onShow()},10),d(),a(this)},a.fn.w2menu=function(b,c){function d(){setTimeout(function(){a("#w2ui-overlay"+i+" tr.w2ui-selected").removeClass("w2ui-selected");var b=a("#w2ui-overlay"+i+" tr[index="+c.index+"]"),d=a("#w2ui-overlay"+i+" div.menu").scrollTop();if(b.addClass("w2ui-selected"),c.tmp&&(c.tmp.contentHeight=a("#w2ui-overlay"+i+" table").height()+(c.search?50:10)),c.tmp&&(c.tmp.contentWidth=a("#w2ui-overlay"+i+" table").width()),a("#w2ui-overlay"+i).length>0&&a("#w2ui-overlay"+i)[0].resize(),b.length>0){var e=b[0].offsetTop-5,f=a("#w2ui-overlay"+i+" div.menu"),g=f.height();a("#w2ui-overlay"+i+" div.menu").scrollTop(d),(ed+g)&&a("#w2ui-overlay"+i+" div.menu").animate({scrollTop:e-(g-2*b.height())/2},200,"linear")}},1)}function e(b){var e=this.value,f=b.keyCode,g=!1;switch(f){case 13:a("#w2ui-overlay"+i).remove(),a.fn.w2menuClick(b,c.index);break;case 9:case 27:a("#w2ui-overlay"+i).remove(),a.fn.w2menuClick(b,-1);break;case 38:for(c.index=w2utils.isInt(c.index)?parseInt(c.index):0,c.index--;c.index>0&&c.items[c.index].hidden;)c.index--;if(0===c.index&&c.items[c.index].hidden)for(;c.items[c.index]&&c.items[c.index].hidden;)c.index++;c.index<0&&(c.index=0),g=!0;break;case 40:for(c.index=w2utils.isInt(c.index)?parseInt(c.index):0,c.index++;c.index=c.items.length&&(c.index=c.items.length-1),g=!0}if(!g){for(var j=0,k=0;k
'+w2utils.lang("Loading...")+"
";for(var a=0,b='',d=null,e=null,f=0;f
'),e&&(h='
'),null==i||""===i||/^-+$/.test(i))b+='';else{var j=a%2===0?"w2ui-item-even":"w2ui-item-odd";c.altRows!==!0&&(j="");var k=1;""===h&&k++,null==g.count&&null==g.hotkey&&k++,null==g.tooltip&&null!=g.hint&&(g.tooltip=g.hint),b+='"+h+' ",a++}}c.items[f]=g}return 0===a&&(b+='"),b+="
'+c.msgNoItems+"
"}c&&"function"==typeof c.items&&(c.items=c.items());var g={type:"normal",index:null,items:[],render:null,msgNoItems:"No items",onSelect:null,tmp:{}},h=this,i="";if("refresh"===b)if(a("#w2ui-overlay"+i).length>0){c=a.extend(a.fn.w2menuOptions,c);var j=a("#w2ui-overlay"+i+" div.menu").scrollTop();a("#w2ui-overlay"+i+" div.menu").html(f()),a("#w2ui-overlay"+i+" div.menu").scrollTop(j),d()}else a(this).w2menu(c);else{if("refresh-index"!==b){1===arguments.length?c=b:c.items=b,"object"!=typeof c&&(c={}),c=a.extend({},g,c),a.fn.w2menuOptions=c,c.name&&(i="-"+c.name),"function"==typeof c.select&&"function"!=typeof c.onSelect&&(c.onSelect=c.select),"function"==typeof c.onRender&&"function"!=typeof c.render&&(c.render=c.onRender),a.fn.w2menuClick=function(b,d){var e=!1;["radio","check"].indexOf(c.type)!=-1&&(b.shiftKey||b.metaKey||b.ctrlKey)&&(e=!0),"function"==typeof c.onSelect&&setTimeout(function(){c.onSelect({index:d,item:c.items[d],keepOpen:e,originalEvent:b})},10);var f=a("#w2ui-overlay"+i);f.removeData("keepOpen"),"function"!=typeof f[0].hide||e||f[0].hide()},a.fn.w2menuDown=function(b,d){var e=a(b.target).parents("tr"),f=e.find(".w2ui-icon");if("check"==c.type||"radio"==c.type){var g=c.items[d];g.checked=!g.checked,g.checked?("radio"==c.type&&f.parents("table").find(".w2ui-icon").removeClass("w2ui-icon-check").addClass("w2ui-icon-empty"),f.removeClass("w2ui-icon-empty").addClass("w2ui-icon-check")):"check"==c.type&&f.removeClass("w2ui-icon-check").addClass("w2ui-icon-empty")}e.parent().find("tr").removeClass("w2ui-selected"),e.addClass("w2ui-selected")};var k="";if(c.search){k+='
',c.style+=";background-color: #ECECEC",c.index=0;for(var l=0;l'+f()+"";var m=a(this).w2overlay(k,c);return setTimeout(function(){if(a("#w2ui-overlay"+i+" #menu-search").on("keyup",e).on("keydown",function(a){9===a.keyCode&&(a.stopPropagation(),a.preventDefault())}),c.search){if(["text","password"].indexOf(a(h)[0].type)!=-1||"TEXTAREA"==a(h)[0].tagName.toUpperCase())return;a("#w2ui-overlay"+i+" #menu-search").focus()}d()},200),d(),m}var n=a("#w2ui-overlay"+i+" div.menu"),o=n.find("tr[index="+c.index+"]"),j=n.scrollTop();if(n.find("tr.w2ui-selected").removeClass("w2ui-selected"),o.addClass("w2ui-selected"),o.length>0){var p=o[0].offsetTop-5,q=n.height();n.scrollTop(j),(pj+q)&&n.animate({scrollTop:p-(q-2*o.height())/2},200,"linear")}d()}},a.fn.w2color=function(b,c){function d(a){for(var b=(a.color,'
'),c=0;c";for(var d=0;d
'+(a.color==g[c][d]?"•":" ")+"
",a.color==g[c][d]&&(f=[c,d]);b+="",c<2&&(b+='
')}var e=g[g.length-1];return b+='',b+="
'+(a.color==e[0]?"•":" ")+'
'+(a.color==e[1]?"•":" ")+'
'+(a.color==e[2]?"•":" ")+'
'+(a.color==e[3]?"•":" ")+'
"}var e=a(this)[0],f=[-1,-1];null==a.fn.w2colorPalette&&(a.fn.w2colorPalette=[["000000","555555","888888","BBBBBB","DDDDDD","EEEEEE","F7F7F7","FFFFFF"],["FF011B","FF9838","FFFD59","01FD55","00FFFE","006CE7","9B24F4","FF21F5"],["FFEAEA","FCEFE1","FCF5E1","EBF7E7","E9F3F5","ECF4FC","EAE6F4","F5E7ED"],["F4CCCC","FCE5CD","FFF2CC","D9EAD3","D0E0E3","CFE2F3","D9D1E9","EAD1DC"],["EA9899","F9CB9C","FEE599","B6D7A8","A2C4C9","9FC5E8","B4A7D6","D5A6BD"],["E06666","F6B26B","FED966","93C47D","76A5AF","6FA8DC","8E7CC3","C27BA0"],["CC0814","E69138","F1C232","6AA84F","45818E","3D85C6","674EA7","A54D79"],["99050C","B45F17","BF901F","37761D","124F5C","0A5394","351C75","741B47"],["F2F2F2","F2F2F2","F2F2F2","F2F2F2","F2F2F2"]]);var g=a.fn.w2colorPalette;"string"==typeof b&&(b={color:b,transparent:!0}),b.transparent&&"555555"==g[0][1]&&(g[0].splice(1,1),g[0].push("")),b.transparent||"555555"==g[0][1]||(g[0].splice(1,0,"555555"),g[0].pop()),b.color&&(b.color=String(b.color).toUpperCase()),0===a("#w2ui-overlay").length?a(e).w2overlay(d(b),{onHide:function(){"function"==typeof c&&c(a(e).data("_color")),a(e).removeData("_color")}}):a("#w2ui-overlay .w2ui-color").parent().html(d(b)),a("#w2ui-overlay .color").off(".w2color").on("mousedown.w2color",function(b){var c=a(b.originalEvent.target).attr("name");f=a(b.originalEvent.target).attr("index").split(":"),a(e).data("_color",c)}).on("mouseup.w2color",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)}),a("#w2ui-overlay input").off(".w2color").on("mousedown.w2color",function(b){a("#w2ui-overlay").data("keepOpen",!0),setTimeout(function(){a("#w2ui-overlay").data("keepOpen",!0)},10),b.stopPropagation()}).on("keyup.w2color",function(a){""!==this.value&&"#"!==this.value[0]&&(this.value="#"+this.value)}).on("change.w2color",function(d){var f=this.value;return"#"==f.substr(0,1)&&(f=f.substr(1)),6!=f.length?void a(this).w2tag("Invalid color."):(a.fn.w2colorPalette[g.length-1].unshift(f.toUpperCase()),a(e).w2color(b,c),void setTimeout(function(){a("#w2ui-overlay input")[0].focus()},100))}).w2field("hex"),e.nav=function(b){switch(b){case"up":f[0]--;break;case"down":f[0]++;break;case"right":f[1]++;break;case"left":f[1]--}return f[0]<0&&(f[0]=0),f[0]>g.length-2&&(f[0]=g.length-2),f[1]<0&&(f[1]=0),f[1]>g[0].length-1&&(f[1]=g[0].length-1),color=g[f[0]][f[1]],a(e).data("_color",color),color}}}(jQuery),function($){var w2grid=function(a){this.name=null,this.box=null,this.header="",this.url="",this.routeData={},this.columns=[],this.columnGroups=[],this.records=[],this.summary=[],this.searches=[],this.searchData=[],this.sortData=[],this.postData={},this.httpHeaders={},this.toolbar={},this.stateId=null,this.show={header:!1,toolbar:!1,footer:!1,columnHeaders:!0,lineNumbers:!1,expandColumn:!1,selectColumn:!1,emptyRecords:!0,toolbarReload:!0,toolbarColumns:!0,toolbarSearch:!0,toolbarInput:!0,toolbarAdd:!1,toolbarEdit:!1,toolbarDelete:!1,toolbarSave:!1,searchAll:!0,statusRange:!0,statusBuffered:!1,statusRecordID:!0,statusSelection:!0,statusResponse:!0,statusSort:!1,statusSearch:!1,recordTitles:!0,selectionBorder:!0,skipRecords:!0,saveRestoreState:!0},this.hasFocus=!1,this.autoLoad=!0,this.fixedBody=!0,this.recordHeight=24,this.lineNumberWidth=null,this.vs_start=150,this.vs_extra=15,this.keyboard=!0,this.selectType="row",this.multiSearch=!0,this.multiSelect=!0,this.multiSort=!0,this.reorderColumns=!1,this.reorderRows=!1,this.markSearch=!0,this.columnTooltip="normal",this.disableCVS=!1,this.textSearch="begins",this.total=0,this.limit=100,this.offset=0,this.style="",this.ranges=[],this.menu=[],this.method=null,this.recid=null,this.parser=null,this.last={field:"",caption:"",logic:"OR",search:"",searchIds:[],selection:{indexes:[],columns:{}},multi:!1,scrollTop:0,scrollLeft:0,colStart:0,colEnd:0,sortData:null,sortCount:0,xhr:null,range_start:null,range_end:null,sel_ind:null,sel_col:null,sel_type:null,edit_col:null,isSafari:/^((?!chrome|android).)*safari/i.test(navigator.userAgent)},$.extend(!0,this,w2obj.grid,a)};$.fn.w2grid=function(a){if($.isPlainObject(a)){if(!w2utils.checkName(a,"w2grid"))return;var b=a.columns,c=a.columnGroups,d=a.records,e=a.searches,f=a.searchData,g=a.sortData,h=a.postData,i=a.httpHeaders,j=a.toolbar,k=new w2grid(a);$.extend(k,{postData:{},httpHeaders:{},records:[],columns:[],searches:[],toolbar:{},sortData:[],searchData:[],handlers:[]}),null!=k.onExpand&&(k.show.expandColumn=!0),$.extend(!0,k.toolbar,j);var l;if(b)for(l=0;l0?(s[a]&&s[a].apply(s,Array.prototype.slice.call(arguments,1)),this):s:null},w2grid.prototype={msgDelete:"Are you sure you want to delete selected records?",msgNotJSON:"Returned data is not in valid JSON format.",msgAJAXerror:"AJAX error. See console for more details.",msgRefresh:"Refreshing...",msgNeedReload:"Your remote data source record count has changed, reloading from the first record.",msgEmpty:"",buttons:{reload:{type:"button",id:"w2ui-reload",icon:"w2ui-icon-reload",tooltip:"Reload data in the list"},columns:{type:"drop",id:"w2ui-column-on-off",icon:"w2ui-icon-columns",tooltip:"Show/hide columns",arrow:!1,html:""},search:{type:"html",id:"w2ui-search",html:"
"},"search-go":{type:"drop",id:"w2ui-search-advanced",icon:"w2ui-icon-search",text:"Search",tooltip:"Open Search Fields"},add:{type:"button",id:"w2ui-add",text:"Add New",tooltip:"Add new record",icon:"w2ui-icon-plus"},edit:{type:"button",id:"w2ui-edit",text:"Edit",tooltip:"Edit selected record",icon:"w2ui-icon-pencil",disabled:!0},delete:{type:"button",id:"w2ui-delete",text:"Delete",tooltip:"Delete selected records",icon:"w2ui-icon-cross",disabled:!0},save:{type:"button",id:"w2ui-save",text:"Save",tooltip:"Save changed records",icon:"w2ui-icon-check"}},operators:{text:["is","begins","contains","ends"],number:["is","between",{oper:"less",text:"less than"},{oper:"more",text:"more than"}],date:["is","between",{oper:"less",text:"before"},{oper:"more",text:"after"}],list:["is"],hex:["is","between"],color:["is","begins","contains","ends"],enum:["in","not in"]},operatorsMap:{text:"text",int:"number",float:"number",money:"number",currency:"number",percent:"number",hex:"hex",alphanumeric:"text",color:"color",date:"date",time:"date",datetime:"date",list:"list",combo:"text",enum:"enum",file:"enum",select:"list",radio:"list",checkbox:"list",toggle:"list"},onAdd:null,onEdit:null,onRequest:null,onLoad:null,onDelete:null,onSave:null,onSelect:null,onUnselect:null,onClick:null,onDblClick:null,onContextMenu:null,onMenuClick:null,onColumnClick:null,onColumnDblClick:null,onColumnResize:null,onSort:null,onSearch:null,onSearchOpen:null,onChange:null,onRestore:null,onExpand:null,onCollapse:null,onError:null,onKeydown:null,onToolbar:null,onColumnOnOff:null,onCopy:null,onPaste:null,onSelectionExtend:null,onEditField:null,onRender:null,onRefresh:null,onReload:null,onResize:null,onDestroy:null,onStateSave:null,onStateRestore:null,onFocus:null,onBlur:null,onReorderRow:null,add:function(a,b){$.isArray(a)||(a=[a]);for(var c=0,d=0;d=0;c--)this.records[c].recid==arguments[b]&&(this.records.splice(c,1), a++);for(var c=this.summary.length-1;c>=0;c--)this.summary[c].recid==arguments[b]&&(this.summary.splice(c,1),a++)}var d="object"!=typeof this.url?this.url:this.url.get;return d||(this.localSort(!1,!0),this.localSearch()),this.refresh(),a},addColumn:function(a,b){var c=0;1==arguments.length?(b=a,a=this.columns.length):("string"==typeof a&&(a=this.getColumn(a,!0)),null==a&&(a=this.columns.length)),$.isArray(b)||(b=[b]);for(var d=0;d=0;c--)this.columns[c].field==arguments[b]&&(this.columns[c].searchable&&this.removeSearch(arguments[b]),this.columns.splice(c,1),a++);return this.refresh(),a},getColumn:function(a,b){if(0===arguments.length){for(var c=[],d=0;d=0;c--){var d=this.columns[c];d.field==arguments[b]&&(d.hidden=!d.hidden,a++)}return this.refreshBody(),this.resizeRecords(),a},showColumn:function(){for(var a=0,b=0;b=0;c--){var d=this.columns[c];d.gridMinWidth&&delete d.gridMinWidth,d.field==arguments[b]&&d.hidden!==!1&&(d.hidden=!1,a++)}return this.refreshBody(),this.resizeRecords(),a},hideColumn:function(){for(var a=0,b=0;b=0;c--){var d=this.columns[c];d.field==arguments[b]&&d.hidden!==!0&&(d.hidden=!0,a++)}return this.refreshBody(),this.resizeRecords(),a},addSearch:function(a,b){var c=0;1==arguments.length?(b=a,a=this.searches.length):("string"==typeof a&&(a=this.getSearch(a,!0)),null==a&&(a=this.searches.length)),$.isArray(b)||(b=[b]);for(var d=0;d=0;c--)this.searches[c].field==arguments[b]&&(this.searches.splice(c,1),a++);return this.searchClose(),a},getSearch:function(a,b){if(0===arguments.length){for(var c=[],d=0;d=0;c--)this.searches[c].field==arguments[b]&&(this.searches[c].hidden=!this.searches[c].hidden,a++);return this.searchClose(),a},showSearch:function(){for(var a=0,b=0;b=0;c--)this.searches[c].field==arguments[b]&&this.searches[c].hidden!==!1&&(this.searches[c].hidden=!1,a++);return this.searchClose(),a},hideSearch:function(){for(var a=0,b=0;b=0;c--)this.searches[c].field==arguments[b]&&this.searches[c].hidden!==!0&&(this.searches[c].hidden=!0,a++);return this.searchClose(),a},getSearchData:function(a){for(var b=0;bd.length?1:c.lengthtypeof b?e:-e;if(a.constructor.name!=b.constructor.name)return a.constructor.name>b.constructor.name?e:-e;a&&"object"==typeof a&&(a=a.valueOf()),b&&"object"==typeof b&&(b=b.valueOf());var f={}.toString;return a&&"object"==typeof a&&a.toString!=f&&(a=String(a)),b&&"object"==typeof b&&b.toString!=f&&(b=String(b)),"string"==typeof a&&(a=$.trim(a.toLowerCase())),"string"==typeof b&&(b=$.trim(b.toLowerCase())),a>b?e:a=parseFloat(k)&&parseFloat(f.parseField(a,h.field))<=parseFloat(l)&&c++;else if("date"==h.type){var j=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),k=w2utils.isDate(k,w2utils.settings.dateFormat,!0),l=w2utils.isDate(l,w2utils.settings.dateFormat,!0);null!=l&&(l=new Date(l.getTime()+864e5)),j>=k&&j=k&&j=k&&j=parseFloat(e.value)&&c++;else if("date"==h.type){var m=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),j=w2utils.formatDate(m,"yyyy-mm-dd"),k=w2utils.formatDate(w2utils.isDate(k,w2utils.settings.dateFormat,!0),"yyyy-mm-dd");j>=k&&c++}else if("time"==h.type){var m=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),j=w2utils.formatTime(m,"hh24:mi"),k=w2utils.formatTime(k,"hh24:mi");j>=k&&c++}else if("datetime"==h.type){var m=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),j=w2utils.formatDateTime(m,"yyyy-mm-dd|hh24:mm:ss"),k=w2utils.formatDateTime(w2utils.isDateTime(k,w2utils.settings.datetimeFormat,!0),"yyyy-mm-dd|hh24:mm:ss");j.length==k.length&&j>=k&&c++}break;case"in":var m=e.value;e.svalue&&(m=e.svalue),m.indexOf(w2utils.isFloat(j)?parseFloat(j):j)!==-1&&c++,m.indexOf(w2utils.isFloat(i)?parseFloat(i):i)!==-1&&c++;break;case"not in":var m=e.value;e.svalue&&(m=e.svalue),m.indexOf(w2utils.isFloat(j)?parseFloat(j):j)==-1&&c++,m.indexOf(w2utils.isFloat(i)?parseFloat(i):i)==-1&&c++;break;case"begins":case"begins with":0===j.indexOf(k)&&c++;break;case"contains":j.indexOf(k)>=0&&c++;break;case"null":null==f.parseField(a,h.field)&&c++;break;case"not null":null!=f.parseField(a,h.field)&&c++;break;case"ends":case"ends with":var n=j.lastIndexOf(k);n!==-1&&n==j.length-k.length&&c++}}}if("OR"==f.last.logic&&0!==c||"AND"==f.last.logic&&c==f.searchData.length)return!0;if(a.w2ui&&a.w2ui.children&&a.w2ui.expanded!==!0)for(var o=0;o0&&!d){this.total=0;for(var i=0;i=0;d--)this.ranges[d].name==c&&(this.ranges.splice(d,1),a++)}return a},refreshRanges:function(){function a(a){var e=d.getSelection();d.last.move={type:"expand",x:a.screenX,y:a.screenY,divX:0,divY:0,recid:e[0].recid,column:e[0].column,originalRange:[{recid:e[0].recid,column:e[0].column},{recid:e[e.length-1].recid,column:e[e.length-1].column}],newRange:[{recid:e[0].recid,column:e[0].column},{recid:e[e.length-1].recid,column:e[e.length-1].column}]},$(document).off("mousemove",b).on("mousemove",b),$(document).off("mouseup",c).on("mouseup",c),a.preventDefault()}function b(a){var b=d.last.move;if(b&&"expand"==b.type){b.divX=a.screenX-b.x,b.divY=a.screenY-b.y;var c,e,f=a.originalEvent.target;if("TD"!=f.tagName.toUpperCase()&&(f=$(f).parents("td")[0]),null!=$(f).attr("col")&&(e=parseInt($(f).attr("col"))),f=$(f).parents("tr")[0],c=$(f).attr("recid"),b.newRange[1].recid!=c||b.newRange[1].column!=e){var g=$.extend({},b.newRange);return b.newRange=[{recid:b.recid,column:b.column},{recid:c,column:e}],B=d.trigger($.extend(B,{originalRange:b.originalRange,newRange:b.newRange})),B.isCancelled===!0?(b.newRange=g,void(B.newRange=g)):(d.removeRange("grid-selection-expand"),void d.addRange({name:"grid-selection-expand",range:B.newRange,style:"background-color: rgba(100,100,100,0.1); border: 2px dotted rgba(100,100,100,0.5);"}))}}}function c(a){d.removeRange("grid-selection-expand"),delete d.last.move,$(document).off("mousemove",b),$(document).off("mouseup",c),d.trigger($.extend(B,{phase:"after"}))}if(0!==this.ranges.length){for(var d=this,e=(new Date).getTime(),f=$("#grid_"+this.name+"_frecords"),g=$("#grid_"+this.name+"_records"),h=0;hthis.last.colStart&&(l=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(j.recid)+' td[col="start"]')),j.columnthis.last.colEnd&&(p='"end"',m=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(k.recid)+' td[col="end"]'));var q=parseInt($("#grid_"+this.name+"_rec_top").next().attr("index")),r=parseInt($("#grid_"+this.name+"_rec_bottom").prev().attr("index")),s=parseInt($("#grid_"+this.name+"_frec_top").next().attr("index")),t=parseInt($("#grid_"+this.name+"_frec_bottom").prev().attr("index"));0===l.length&&j.indexq&&(l=$("#grid_"+this.name+"_rec_top").next().find("td[col="+j.column+"]")),0===m.length&&k.index>r&&j.indexs&&(n=$("#grid_"+this.name+"_frec_top").next().find("td[col="+j.column+"]")),0===o.length&&k.index>t&&j.index0||o.length>0)if(0===y.length?(f.append('
'+("selection"==i.name?'
':"")+"
"),y=$("#grid_"+this.name+"_f"+i.name)):(y.attr("style",i.style),y.find(".w2ui-selection-resizer").show()),0===o.length&&(o=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(k.recid)+" td:last-child"),0===o.length&&(o=$("#grid_"+this.name+"_frec_bottom td:first-child")),y.css("border-right","0px"),y.find(".w2ui-selection-resizer").hide()),null!=j.recid&&null!=k.recid&&n.length>0&&o.length>0){var z=n.position().left-1+f.scrollLeft(),A=n.position().top-1+f.scrollTop();y.show().css({left:(z>0?z:0)+"px",top:(A>0?A:0)+"px",width:o.position().left-n.position().left+o.width()+3+"px",height:o.position().top-n.position().top+o.height()+3+"px"})}else y.hide();else y.hide();var y=$("#grid_"+this.name+"_"+i.name);if(l.length>0||m.length>0)if(0===y.length?(g.append('
'+("selection"==i.name?'
':"")+"
"),y=$("#grid_"+this.name+"_"+i.name)):y.attr("style",i.style),0===l.length&&(l=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(j.recid)+" td:first-child"),0===l.length&&(l=$("#grid_"+this.name+"_rec_top td:first-child"))),0!==o.length&&y.css("border-left","0px"),null!=j.recid&&null!=k.recid&&l.length>0&&m.length>0){var z=l.position().left-1+g.scrollLeft(),A=l.position().top-1+g.scrollTop();y.show().css({left:(z>0?z:0)+"px",top:(A>0?A:0)+"px",width:m.position().left-l.position().left+m.width()+3+"px",height:m.position().top-l.position().top+m.height()+3+"px"})}else y.hide();else y.hide()}}$(this.box).find(".w2ui-selection-resizer").off("mousedown").on("mousedown",a).off("dblclick").on("dblclick",function(a){var b=d.trigger({phase:"before",type:"resizerDblClick",target:d.name,originalEvent:a});b.isCancelled!==!0&&d.trigger($.extend(b,{phase:"after"}))});var B={phase:"before",type:"selectionExtend",target:d.name,originalRange:null,newRange:null};return(new Date).getTime()-e}},select:function(){if(0===arguments.length)return 0;var a=((new Date).getTime(),0),b=this.last.selection;this.multiSelect||this.selectNone();var c={phase:"before",type:"select",target:this.name};1==arguments.length?(c.multiple=!1,$.isPlainObject(arguments[0])?(c.recid=arguments[0].recid,c.column=arguments[0].column):c.recid=arguments[0]):(c.multiple=!0,c.recids=Array.prototype.slice.call(arguments,0));var d=this.trigger(c);if(d.isCancelled===!0)return 0;if("row"==this.selectType)for(var e=0;e=this.last.range_start&&g+1<=this.last.range_end)&&(h=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(f)),i=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(f))),"row"==this.selectType){if(b.indexes.indexOf(g)!=-1)continue;b.indexes.push(g),h&&i&&(h.addClass("w2ui-selected").data("selected","yes").find(".w2ui-col-number").addClass("w2ui-row-selected"),i.addClass("w2ui-selected").data("selected","yes").find(".w2ui-col-number").addClass("w2ui-row-selected"),h.find(".w2ui-grid-select-check").prop("checked",!0)),a++}}}else{for(var j={},e=0;e=this.last.range_start&&g+1<=this.last.range_end&&(h=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(f)),i=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(f)));var n=b.columns[g]||[];b.indexes.indexOf(g)==-1&&b.indexes.push(g);for(var o=0;o0&&b.indexes.length==this.records.length,s=b.indexes.length>0&&0!==this.searchData.length&&b.indexes.length==this.last.searchIds.length;return r||s?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.addRange("selection"),this.trigger($.extend(d,{phase:"after"})),a},unselect:function(){for(var a=0,b=this.last.selection,c=0;c td[col="+j+"]").removeClass("w2ui-selected w2ui-inactive"),$("#grid_"+this.name+"_frec_"+w2utils.escapeId(d)).find(" > td[col="+j+"]").removeClass("w2ui-selected w2ui-inactive");for(var n=!1,o=!1,p=this.getSelection(),l=0;l0&&b.indexes.length==this.records.length,r=b.indexes.length>0&&0!==this.searchData.length&&b.indexes.length==this.last.searchIds.length;return q||r?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.addRange("selection"),a},selectAll:function(){var a=(new Date).getTime();if(this.multiSelect!==!1){var b=this.trigger({phase:"before",type:"select",target:this.name,all:!0});if(b.isCancelled!==!0){for(var c="object"!=typeof this.url?this.url:this.url.get,d=this.last.selection,e=[],f=0;f=1?this.toolbar.enable("w2ui-delete"):this.toolbar.disable("w2ui-delete"),this.addRange("selection"),$("#grid_"+this.name+"_check_all").prop("checked",!0),this.trigger($.extend(b,{phase:"after"})),(new Date).getTime()-a}}},selectNone:function(){var a=(new Date).getTime(),b=this.trigger({phase:"before",type:"unselect",target:this.name,all:!0});if(b.isCancelled!==!0){var c=this.last.selection;return"row"==this.selectType?($(this.box).find(".w2ui-grid-records tr.w2ui-selected").removeClass("w2ui-selected w2ui-inactive").removeData("selected").find(".w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-frecords tr.w2ui-selected").removeClass("w2ui-selected w2ui-inactive").removeData("selected").find(".w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find("input.w2ui-grid-select-check").prop("checked",!1)):($(this.box).find(".w2ui-grid-columns td .w2ui-col-header, .w2ui-grid-fcolumns td .w2ui-col-header").removeClass("w2ui-col-selected"),$(this.box).find(".w2ui-grid-records tr .w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-frecords tr .w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-data.w2ui-selected").removeClass("w2ui-selected w2ui-inactive").removeData("selected"),$(this.box).find("input.w2ui-grid-select-check").prop("checked",!1)),c.indexes=[],c.columns={},this.toolbar.disable("w2ui-edit","w2ui-delete"),this.removeRange("selection"),$("#grid_"+this.name+"_check_all").prop("checked",!1),this.trigger($.extend(b,{phase:"after"})),(new Date).getTime()-a}},getSelection:function(a){var b=[],c=this.last.selection;if("row"==this.selectType){for(var d=0;d0)for(var j=0;j0){var v={field:k.field,type:k.type,operator:null!=k.operator?k.operator:"in",value:x};d.push(v)}}}else for(var j=0;j0&&c[0].focus(),a.trigger($.extend(b,{phase:"after"}))}})}},searchClose:function(){this.box&&0!==this.searches.length&&(this.toolbar&&this.toolbar.uncheck("w2ui-search-advanced"),$().w2overlay({name:this.name+"-searchOverlay"}),$().w2overlay({name:this.name+"-searchOverlay"}))},searchReset:function(a){for(var b=[],c=!1,d=0;d0)if(this.multiSearch&&this.show.searchAll)this.last.field="all",this.last.caption=w2utils.lang("All Fields");else{for(var f=0;f=this.searches.length?(this.last.field="",this.last.caption=""):(this.last.field=this.searches[f].field,this.last.caption=this.searches[f].caption)}this.last.multi=!1,this.last.xhr_offset=0,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selection.indexes=[],this.last.selection.columns={},this.searchClose(),$("#grid_"+this.name+"_search_all").val("").removeData("selected"),a||this.reload(),this.trigger($.extend(e,{phase:"after"}))}},searchShowFields:function(){for(var a=this,b=$("#grid_"+this.name+"_search_all"),c='
',d=-1;d "}c+="
'+e.caption+"
",setTimeout(function(){$(b).w2overlay({html:c,name:a.name+"-searchFields",left:-10})},1)},initAllField:function(a,b){var c=$("#grid_"+this.name+"_search_all");if("all"==a){var d={field:"all",caption:w2utils.lang("All Fields")};c.w2field("clear"),c.change()}else{var d=this.getSearch(a);if(null==d)return;var e=d.type;["enum","select"].indexOf(e)!=-1&&(e="list"),c.w2field(e,$.extend({},d.options,{suffix:"",autoFormat:!1,selected:b})),["list","enum","date","time","datetime"].indexOf(d.type)!=-1&&(this.last.search="",this.last.item="",c.val(""))}""!=this.last.search?(this.last.caption=d.caption,this.search(d.field,this.last.search)):(this.last.field=d.field,this.last.caption=d.caption),c.attr("placeholder",w2utils.lang(d.caption)),$().w2overlay({name:this.name+"-searchFields"})},clear:function(a){this.total=0,this.records=[],this.summary=[],this.last.xhr_offset=0,this.reset(!0),a||this.refresh()},reset:function(a){this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selection={indexes:[],columns:{}},this.last.range_start=null,this.last.range_end=null,$("#grid_"+this.name+"_records").prop("scrollTop",0),a||this.refresh()},skip:function(a,b){var c="object"!=typeof this.url?this.url:this.url.get;c?(this.offset=parseInt(a),this.offset>this.total&&(this.offset=this.total-this.limit),(this.offset<0||!w2utils.isInt(this.offset))&&(this.offset=0),this.clear(!0),this.reload(b)):console.log("ERROR: grid.skip() can only be called when you have remote data source.")},load:function(a,b){return null==a?void console.log('ERROR: You need to provide url argument when calling .load() method of "'+this.name+'" object.'):(this.clear(!0),void this.request("get",{},a,b))},reload:function(a){var b=this,c="object"!=typeof this.url?this.url:this.url.get;b.selectionSave(),c?this.load(c,function(){b.selectionRestore(),"function"==typeof a&&a()}):(this.reset(!0),this.localSearch(),this.selectionRestore(),"function"==typeof a&&a({status:"success"}))},request:function(a,b,c,d){if(null==b&&(b={}),""!=c&&null!=c||(c=this.url),""!=c&&null!=c){var e={};if(w2utils.isInt(this.offset)||(this.offset=0),w2utils.isInt(this.last.xhr_offset)||(this.last.xhr_offset=0),e.cmd=a,e.selected=this.getSelection(),e.limit=this.limit,e.offset=parseInt(this.offset)+parseInt(this.last.xhr_offset),e.search=this.searchData,e.searchLogic=this.last.logic,e.sort=this.sortData,0===this.searchData.length&&(delete e.search,delete e.searchLogic),0===this.sortData.length&&delete e.sort,$.extend(e,this.postData),$.extend(e,b),"get"==a){var f=this.trigger({phase:"before",type:"request",target:this.name,url:c,postData:e,httpHeaders:this.httpHeaders});if(f.isCancelled===!0)return void("function"==typeof d&&d({status:"error",message:"Request aborted."}))}else var f={url:c,postData:e,httpHeaders:this.httpHeaders};var g=this;if(0===this.last.xhr_offset)g.lock(w2utils.lang(g.msgRefresh),!0);else{var h=$("#grid_"+this.name+"_rec_more, #grid_"+this.name+"_frec_more");this.autoLoad===!0?h.show().find("td").html('
'):h.find("td").html("
"+w2utils.lang("Load")+" "+g.limit+" "+w2utils.lang("More")+"...
")}if(this.last.xhr)try{this.last.xhr.abort()}catch(a){}if(c="object"!=typeof f.url?f.url:f.url.get,"save"==e.cmd&&"object"==typeof f.url&&(c=f.url.save),"delete"==e.cmd&&"object"==typeof f.url&&(c=f.url.remove),!$.isEmptyObject(g.routeData)){var i=w2utils.parseRoute(c);if(i.keys.length>0)for(var j=0;jc.width()&&c.width(e+20)}catch(a){}}var f=this,g=f.get(a,!0),h=f.getCellEditable(g,b);if(h){var i=f.records[g],j=f.columns[b],k=j.frozen===!0?"_f":"_";if(["enum","file"].indexOf(h.type)!=-1)return void console.log('ERROR: input types "enum" and "file" are not supported in inline editing.');var l=f.trigger({phase:"before",type:"editField",target:f.name,recid:a,column:b,value:c,index:g,originalEvent:d});if(l.isCancelled!==!0&&(c=l.value,this.selectNone(),this.select({recid:a,column:b}),this.last.edit_col=b,["checkbox","check"].indexOf(h.type)==-1)){var m=$("#grid_"+f.name+k+"rec_"+w2utils.escapeId(a)),n=m.find("[col="+b+"] > div");$(this.box).find("div.w2ui-edit-box").remove(),"row"!=this.selectType&&($("#grid_"+this.name+k+"selection").attr("id","grid_"+this.name+"_editable").removeClass("w2ui-selection").addClass("w2ui-edit-box").prepend('
').find(".w2ui-selection-resizer").remove(),n=$("#grid_"+this.name+"_editable >div:first-child")),null==h.inTag&&(h.inTag=""),null==h.outTag&&(h.outTag=""),null==h.style&&(h.style=""),null==h.items&&(h.items=[]);var o=i.w2ui&&i.w2ui.changes&&null!=i.w2ui.changes[j.field]?w2utils.stripTags(i.w2ui.changes[j.field]):w2utils.stripTags(i[j.field]);null==o&&(o="");var p="object"!=typeof o?o:"";null!=l.old_value&&(p=l.old_value),null!=c&&(o=c);var q=null!=j.style?j.style+";":"";switch("string"==typeof j.render&&["number","int","float","money","percent","size"].indexOf(j.render.split(":")[0])!=-1&&(q+="text-align: right;"),h.items.length>0&&!$.isPlainObject(h.items[0])&&(h.items=w2obj.field.prototype.normMenu(h.items)),h.type){case"select":for(var r="",s=0;s"+h.items[s].text+"";n.addClass("w2ui-editable").html('"+h.outTag),setTimeout(function(){n.find("select").on("change",function(a){delete f.last.move}).on("blur",function(a){1!=$(this).data("keep-open")&&f.editChange.call(f,this,g,b,a)})},10);break;case"div":var t=m.find("[col="+b+"] > div"),u="font-family: "+t.css("font-family")+"; font-size: "+t.css("font-size")+";";n.addClass("w2ui-editable").html('
"+h.outTag),null==c&&n.find("div.w2ui-input").text("object"!=typeof o?o:"");var v=n.find("div.w2ui-input").get(0);setTimeout(function(){var a=v;$(a).on("blur",function(c){1!=$(this).data("keep-open")&&f.editChange.call(f,a,g,b,c)})},10),null!=c&&$(v).text("object"!=typeof o?o:"");break;default:var t=m.find("[col="+b+"] > div"),u="font-family: "+t.css("font-family")+"; font-size: "+t.css("font-size");n.addClass("w2ui-editable").html('"+h.outTag),"number"==h.type&&(o=w2utils.formatNumber(o)),"date"==h.type&&(o=w2utils.formatDate(w2utils.isDate(o,h.format,!0),h.format)),null==c&&n.find("input").val("object"!=typeof o?o:"");var v=n.find("input").get(0);$(v).w2field(h.type,$.extend(h,{selected:o})),setTimeout(function(){var a=v;"list"==h.type&&(a=$($(v).data("w2field").helpers.focus).find("input"),"object"!=typeof o&&""!=o&&a.val(o).css({opacity:1}).prev().css({opacity:1}),n.find("input").on("change",function(a){f.editChange.call(f,v,g,b,a)})),$(a).on("blur",function(a){1!=$(this).data("keep-open")&&f.editChange.call(f,v,g,b,a)})},10),null!=c&&$(v).val("object"!=typeof o?o:"")}setTimeout(function(){n.find("input, select, div.w2ui-input").data("old_value",p).on("mousedown",function(a){a.stopPropagation()}).on("click",function(a){"div"==h.type?e.call(n.find("div.w2ui-input")[0],null):e.call(n.find("input, select")[0],null)}).on("paste",function(a){var b=a.originalEvent;a.preventDefault();var c=b.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,c)}).on("keydown",function(c){var d=this,k="DIV"==d.tagName.toUpperCase()?$(d).text():$(d).val();switch(c.keyCode){case 8:"list"!=h.type||$(v).data("w2field")||c.preventDefault();break;case 9:case 13:c.preventDefault();break;case 37:0===w2utils.getCursorPosition(d)&&c.preventDefault();break;case 39:w2utils.getCursorPosition(d)==k.length&&(w2utils.setCursorPosition(d,k.length),c.preventDefault())}setTimeout(function(){switch(c.keyCode){case 9:var h=a,k=c.shiftKey?f.prevCell(g,b,!0):f.nextCell(g,b,!0);if(null==k){var l=c.shiftKey?f.prevRow(g,b):f.nextRow(g,b);if(null!=l&&l!=g){h=f.records[l].recid;for(var m=0;m0&&(a.focus(),clearTimeout(f.last.kbd_timer),"SELECT"!=a[0].tagName&&w2utils.setCursorPosition(a[0],b),a[0].resize=e,e.call(a[0],null))},50),f.trigger($.extend(l,{phase:"after",input:n.find("input, select, div.w2ui-input")}))},5)}}},editChange:function(a,b,c,d){var e=this;setTimeout(function(){var a=$(e.box).find("#grid_"+e.name+"_focus");a.is(":focus")||a.focus()},10);var f=b<0;b=b<0?-b-1:b;var g=f?this.summary:this.records,h=g[b],i=this.columns[c],j=$("#grid_"+this.name+(i.frozen===!0?"_frec_":"_rec_")+w2utils.escapeId(h.recid)),k=a.tagName&&"DIV"==a.tagName.toUpperCase()?$(a).text():a.value,l=this.parseField(h,i.field),m=$(a).data("w2field");m&&("list"==m.type&&(k=$(a).data("selected")),($.isEmptyObject(k)||null==k)&&(k=""),$.isPlainObject(k)||(k=m.clean(k))),"checkbox"==a.type&&(h.w2ui&&h.w2ui.editable===!1&&(a.checked=!a.checked),k=a.checked);var n={phase:"before",type:"change",target:this.name,input_id:a.id,recid:h.recid,index:b,column:c,originalEvent:d.originalEvent?d.originalEvent:d,value_new:k,value_previous:h.w2ui&&h.w2ui.changes&&h.w2ui.changes.hasOwnProperty(i.field)?h.w2ui.changes[i.field]:l,value_original:l};for(null!=$(d.target).data("old_value")&&(n.value_previous=$(d.target).data("old_value"));;){if(k=n.value_new,"object"!=typeof k&&String(l)!=String(k)||"object"==typeof k&&k.id!=l&&("object"!=typeof l||null==l||k.id!=l.id)){if(n=this.trigger($.extend(n,{type:"change",phase:"before"})),n.isCancelled!==!0){if(k!==n.value_new)continue;h.w2ui=h.w2ui||{},h.w2ui.changes=h.w2ui.changes||{},h.w2ui.changes[i.field]=n.value_new,this.trigger($.extend(n,{phase:"after"}))}}else if(n=this.trigger($.extend(n,{type:"restore",phase:"before"})),n.isCancelled!==!0){if(k!==n.value_new)continue;h.w2ui&&h.w2ui.changes&&delete h.w2ui.changes[i.field],h.w2ui&&$.isEmptyObject(h.w2ui.changes)&&delete h.w2ui.changes,this.trigger($.extend(n,{phase:"after"}))}break}var o=$(j).find("[col="+c+"]");f||(h.w2ui&&h.w2ui.changes&&null!=h.w2ui.changes[i.field]?o.addClass("w2ui-changed"):o.removeClass("w2ui-changed"),o.replaceWith(this.getCellHTML(b,c,f))),$(this.box).find("div.w2ui-edit-box").remove(),this.show.toolbarSave&&(this.getChanges().length>0?this.toolbar.enable("w2ui-save"):this.toolbar.disable("w2ui-save"))},delete:function(a){var b=((new Date).getTime(),this),c=this.trigger({phase:"before",target:this.name,type:"delete",force:a});if(c.isCancelled!==!0){a=c.force,setTimeout(function(){$().w2tag()},20);var d=this.getSelection();if(0!==d.length){if(""!=this.msgDelete&&!a)return void this.message({width:350,height:170,body:'
'+w2utils.lang(b.msgDelete)+"
",buttons:'",onOpen:function(a){var c=$(this.box).find("input, textarea, select, button");c.off(".message").on("blur.message",function(a){c.index(a.target)+1===c.length&&(c.get(0).focus(),a.preventDefault())}).on("keydown.message",function(a){27==a.keyCode&&b.message()}),setTimeout(function(){$(this.box).find(".w2ui-btn:last-child").focus(),clearTimeout(b.last.kbd_timer)},25)}});this.message();var e="object"!=typeof this.url?this.url:this.url.remove;if(e)this.request("delete");else if("object"!=typeof d[0])this.selectNone(),this.remove.apply(this,d);else{for(var f=0;f0&&e.multiSelect){if(i[0].recid){var l=this.get(i[0].recid,!0),m=this.get(a,!0);if(d>i[0].column)var n=i[0].column,o=d;else var n=d,o=i[0].column;for(var p=n;p<=o;p++)k.push(p)}else var l=this.get(f,!0),m=this.get(a,!0);var q=[];if(l>m){var g=l;l=m,m=g}for(var r="object"!=typeof this.url?this.url:this.url.get,s=l;s<=m;s++)if(!(this.searchData.length>0)||r||$.inArray(s,this.last.searchIds)!=-1)if("row"==this.selectType)q.push(this.records[s].recid);else for(var t=0;t300?this.selectNone():this.unselect.apply(this,i),v===!0&&1==i.length?this.unselect({recid:a,column:d}):this.select({recid:a,column:d}))}this.status(),e.initResize(),this.trigger($.extend(h,{phase:"after"}))}}},columnClick:function(a,b){var c=this.trigger({phase:"before",type:"columnClick",target:this.name,field:a,originalEvent:b});if(c.isCancelled!==!0){if("row"==this.selectType){var d=this.getColumn(a);d&&d.sortable&&this.sort(a,null,!(!b||!b.ctrlKey&&!b.metaKey)),"line-number"==c.field&&(this.getSelection().length>=this.records.length?this.selectNone():this.selectAll())}else if("line-number"==c.field)this.getSelection().length>=this.records.length?this.selectNone():this.selectAll();else{b.shiftKey||b.metaKey||b.ctrlKey||this.selectNone();var e=this.getSelection(),d=this.getColumn(c.field,!0),f=[],g=[];if(0!=e.length&&b.shiftKey){var h=d,i=e[0].column;h>i&&(h=e[0].column,i=d);for(var j=h;j<=i;j++)g.push(j)}else g.push(d);var c=this.trigger({phase:"before",type:"columnSelect",target:this.name,columns:g});if(c.isCancelled!==!0){for(var j=0;j1){for(var a=0;a1&&(i.splice(i.indexOf(d.records[d.last.sel_ind].recid),1),d.unselect.apply(d,i),!0)}var d=this,e="object"!=typeof this.url?this.url:this.url.get;if(d.keyboard===!0){var f=d.trigger({phase:"before",type:"keydown",target:d.name,originalEvent:a});if(f.isCancelled!==!0){if($(this.box).find(">.w2ui-message").length>0)return void(27==a.keyCode&&this.message());var g=!1,h=$("#grid_"+d.name+"_records"),i=d.getSelection();0===i.length&&(g=!0);var j=i[0]||null,k=[],l=i[i.length-1];if("object"==typeof j&&null!=j){j=i[0].recid,k=[];for(var m=0;;){if(!i[m]||i[m].recid!=j)break;k.push(i[m].column),m++}l=i[i.length-1].recid}var n=d.get(j,!0),o=d.get(l,!0),p=(d.get(j),$("#grid_"+d.name+"_rec_"+(null!=n?w2utils.escapeId(d.records[n].recid):"none"))),q=!1,r=a.keyCode,s=a.shiftKey;switch(r){case 8:case 46:(this.show.toolbarDelete||this.onDelete)&&d.delete(),q=!0,a.stopPropagation();break;case 27:d.selectNone(),q=!0;break;case 65:if(!a.metaKey&&!a.ctrlKey)break;d.selectAll(),q=!0;break;case 13:if("row"==this.selectType&&d.show.expandColumn===!0){if(p.length<=0)break;d.toggle(j,a),q=!0}else{for(var t=0;t0&&(d.editField(j,k[0],null,a),q=!0)}break;case 37:if(g){b();break}if("row"==this.selectType){if(p.length<=0)break;var v=this.records[n].w2ui||{};!v||null==v.parent_recid||Array.isArray(v.children)&&0!==v.children.length&&v.expanded?d.collapse(j,a):(d.unselect(j),d.collapse(v.parent_recid,a),d.select(v.parent_recid))}else{var w=d.prevCell(n,k[0]);if(s||null!=w||(this.selectNone(),w=0),null!=w)if(s&&d.multiSelect){if(c())return;var v=[],x=[],y=[];if(0===k.indexOf(this.last.sel_col)&&k.length>1){for(var z=0;z1)d.selectNone();else for(var A=1;A1){for(var z=0;z1)d.selectNone();else for(var A=0;Aw&&d.last.sel_ind!=o?d.unselect(d.records[o].recid):d.select(d.records[w].recid);else if(d.last.sel_ind>w&&d.last.sel_ind!=o){w=o;for(var v=[],t=0;t300?this.selectNone():this.unselect.apply(this,i),d.click({recid:d.records[w].recid,column:k[0]},a);d.scrollIntoView(w),a.preventDefault&&a.preventDefault()}else if(!s)if(i.length>1)d.selectNone();else for(var A=1;A300?this.selectNone():this.unselect.apply(this,i),d.click({recid:d.records[B].recid,column:k[0]},a);d.scrollIntoView(B),q=!0}else if(!s)if(i.length>1)d.selectNone();else for(var A=0;A0&&(a=this.last.searchIds.indexOf(a)),f.height()0?g:d)&&f.length>0){var h=Math.floor(f[0].scrollTop/this.recordHeight),i=h+Math.floor(f.height()/this.recordHeight);a==h&&(c===!0?f.prop({scrollTop:f.scrollTop()-f.height()/1.3}):(f.stop(),f.animate({scrollTop:f.scrollTop()-f.height()/1.3},250,"linear"))),a==i&&(c===!0?f.prop({scrollTop:f.scrollTop()+f.height()/1.3}):(f.stop(),f.animate({scrollTop:f.scrollTop()+f.height()/1.3},250,"linear"))),(ai)&&(c===!0?f.prop({scrollTop:(a-1)*this.recordHeight}):(f.stop(),f.animate({scrollTop:(a-1)*this.recordHeight},250,"linear")))}if(null!=b){for(var j=0,k=0,l=w2utils.scrollBarSize(),m=0;m<=b;m++){var n=this.columns[m];n.frozen||n.hidden||(j=k,k+=parseInt(n.sizeCalculated))}f.width()0&&$(d.box).find(c.target).w2menu(d.menu,{originalEvent:c,contextMenu:!0,onSelect:function(b){d.menuClick(a,parseInt(b.index),b.originalEvent)}}),c.preventDefault&&c.preventDefault(),d.trigger($.extend(i,{phase:"after"})))}},menuClick:function(a,b,c){var d=this,e=d.trigger({phase:"before",type:"menuClick",target:d.name,originalEvent:c,recid:a,menuIndex:b,menuItem:d.menu[b]});e.isCancelled!==!0&&d.trigger($.extend(e,{phase:"after"}))},toggle:function(a){var b=this.get(a);return b.w2ui=b.w2ui||{},b.w2ui.expanded===!0?this.collapse(a):this.expand(a)},expand:function(a){var b=this.get(a,!0),c=this.records[b];c.w2ui=c.w2ui||{};var d=w2utils.escapeId(a),e=c.w2ui.children;if(Array.isArray(e)){if(c.w2ui.expanded===!0||0===e.length)return!1;var f=this.trigger({phase:"before",type:"expand",target:this.name,recid:a});if(f.isCancelled===!0)return!1;c.w2ui.expanded=!0,e.forEach(function(a){a.w2ui=a.w2ui||{},a.w2ui.parent_recid=c.recid,null==a.w2ui.children&&(a.w2ui.children=[])}),this.records.splice.apply(this.records,[b+1,0].concat(e)),this.total+=e.length;var g="object"!=typeof this.url?this.url:this.url.get;g||(this.localSort(!0,!0),this.searchData.length>0&&this.localSearch(!0)),this.refresh(),this.trigger($.extend(f,{phase:"after"}))}else{if($("#grid_"+this.name+"_rec_"+d+"_expanded_row").length>0||this.show.expandColumn!==!0)return!1;if("none"==c.w2ui.expanded)return!1;$("#grid_"+this.name+"_rec_"+d).after('
'),$("#grid_"+this.name+"_frec_"+d).after(''+(this.show.lineNumbers?'':"")+'
');var f=this.trigger({phase:"before",type:"expand",target:this.name,recid:a,box_id:"grid_"+this.name+"_rec_"+a+"_expanded",fbox_id:"grid_"+this.name+"_frec_"+d+"_expanded"});if(f.isCancelled===!0)return $("#grid_"+this.name+"_rec_"+d+"_expanded_row").remove(),$("#grid_"+this.name+"_frec_"+d+"_expanded_row").remove(),!1;var h=$(this.box).find("#grid_"+this.name+"_rec_"+a+"_expanded"),i=$(this.box).find("#grid_"+this.name+"_frec_"+a+"_expanded"),j=h.find("> div:first-child").height();h.height()=0)break;l++}this.records.splice(k,l-k+1),this.total-=l-k+1;var m="object"!=typeof this.url?this.url:this.url.get;m||this.searchData.length>0&&this.localSearch(!0),this.refresh(),c.trigger($.extend(h,{phase:"after"}))}else{if(0===$("#grid_"+this.name+"_rec_"+f+"_expanded_row").length||this.show.expandColumn!==!0)return!1;var h=this.trigger({phase:"before",type:"collapse",target:this.name,recid:a,box_id:"grid_"+this.name+"_rec_"+f+"_expanded",fbox_id:"grid_"+this.name+"_frec_"+f+"_expanded"});if(h.isCancelled===!0)return!1;$("#grid_"+this.name+"_rec_"+f).removeAttr("expanded").removeClass("w2ui-expanded"),$("#grid_"+this.name+"_frec_"+f).removeAttr("expanded").removeClass("w2ui-expanded"),$("#grid_"+this.name+"_cell_"+this.get(a,!0)+"_expand div").html("+"),$("#grid_"+c.name+"_rec_"+f+"_expanded").css("height","0px"),$("#grid_"+c.name+"_frec_"+f+"_expanded").css("height","0px"),setTimeout(function(){$("#grid_"+c.name+"_rec_"+f+"_expanded_row").remove(),$("#grid_"+c.name+"_frec_"+f+"_expanded_row").remove(),e.w2ui.expanded=!1,c.trigger($.extend(h,{phase:"after"})),c.resizeRecords()},300)}return!0},sort:function(a,b,c){var d=this.trigger({phase:"before",type:"sort",target:this.name,field:a,direction:b,multiField:c});if(d.isCancelled!==!0){if(null!=a){for(var e=this.sortData.length,f=0;f0&&this.localSearch(!0),this.last.scrollTop=0,$("#grid_"+this.name+"_records").prop("scrollTop",0),this.trigger($.extend(d,{phase:"after"})),this.refresh())}},copy:function(a,b){if($.isPlainObject(a))return this.trigger($.extend(a,{phase:"after"})),a.text;var c=this.getSelection();if(0===c.length)return"";var d="";if("object"==typeof c[0]){for(var e=c[0].column,f=c[0].column,g=[],h=0;hf&&(f=c[h].column),g.indexOf(c[h].index)==-1&&g.push(c[h].index);g.sort(function(a,b){return a-b});for(var i=0;i div.w2ui-grid-box").css("width",$(this.box).width()).css("height",$(this.box).height());var c=this.trigger({phase:"before",type:"resize",target:this.name});if(c.isCancelled!==!0)return a.resizeBoxes(),a.resizeRecords(),a.toolbar&&a.toolbar.resize&&a.toolbar.resize(),this.trigger($.extend(c,{phase:"after"})),(new Date).getTime()-b}},update:function(a){var b=(new Date).getTime();if(null==this.box)return 0;if(null==a){for(var c=this.last.range_start-1;c<=this.last.range_end-1;c++)if(!(c<0)){var d=this.records[c]||{};d.w2ui||(d.w2ui={});for(var e=0;e0){null==b&&(b=this.get(a,!0));var e=c.attr("line"),f=!this.records[b]||this.records[b].recid!=a,g="object"!=typeof this.url?this.url:this.url.get;if(this.searchData.length>0&&!g)for(var h=0;h0&&(this.last.field=this.searches[0].field,this.last.caption=this.searches[0].caption);for(var h=0;h0&&k.indexes.length==this.records.length,m=k.indexes.length>0&&0!==this.searchData.length&&k.indexes.length==this.last.searchIds.length;l||m?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status();for(var n=a.find({"w2ui.expanded":!0},!0),o=0;o0&&$(a.box).find(".w2ui-grid-data > div").w2marker(b)},50),this.show.toolbarSave&&(this.getChanges().length>0?this.toolbar.enable("w2ui-save"):this.toolbar.disable("w2ui-save")),this.trigger($.extend(d,{phase:"after"})),a.resize(),a.addRange("selection"),setTimeout(function(){a.resize(),a.scroll()},1),a.reorderColumns&&!a.last.columnDrag?a.last.columnDrag=a.initColumnDrag():!a.reorderColumns&&a.last.columnDrag&&a.last.columnDrag.remove(),(new Date).getTime()-b}}},refreshBody:function(){var a=this.find({"w2ui.summary":!0},!0);if(a.length>0){for(var b=0;b=0;b--)this.records.splice(a[b],1)}this.scroll();var c=this.getRecordsHTML(),d=this.getColumnsHTML(),e='
'+c[0]+'
"+c[1]+'
'+d[0]+'
'+d[1]+"
";if($("#grid_"+this.name+"_body").html(e),0===this.records.length&&this.msgEmpty?$("#grid_"+this.name+"_body").append('
'+this.msgEmpty+"
"):$("#grid_"+this.name+"_empty_msg").length>0&&$("#grid_"+this.name+"_empty_msg").remove(),this.summary.length>0){var f=this.getSummaryHTML();$("#grid_"+this.name+"_fsummary").html(f[0]).show(),$("#grid_"+this.name+"_summary").html(f[1]).show()}else $("#grid_"+this.name+"_fsummary").hide(),$("#grid_"+this.name+"_summary").hide()},render:function(a){function b(a){if(1==a.which&&("text"==e.last.userSelect&&(delete e.last.userSelect,$(e.box).find(".w2ui-grid-body").css(w2utils.cssPrefix("user-select","none"))),!("row"==e.selectType&&($(a.target).parents().hasClass("w2ui-head")||$(a.target).hasClass("w2ui-head"))||e.last.move&&"expand"==e.last.move.type))){if(a.altKey)$(e.box).find(".w2ui-grid-body").css(w2utils.cssPrefix("user-select","text")),e.selectNone(),e.last.move={type:"text-select"},e.last.userSelect="text";else if(e.multiSelect||e.reorderRows){for(var b=a.target,f={x:a.offsetX-10,y:a.offsetY-10},g=!1;b&&(!b.classList||!b.classList.contains("w2ui-grid"));)b.tagName&&"TD"==b.tagName.toUpperCase()&&(g=!0),b.tagName&&"TR"!=b.tagName.toUpperCase()&&1==g&&(f.x+=b.offsetLeft,f.y+=b.offsetTop),b=b.parentNode;e.last.move={x:a.screenX,y:a.screenY,divX:0,divY:0,focusX:f.x,focusY:f.y,recid:$(a.target).parents("tr").attr("recid"),column:parseInt("TD"==a.target.tagName.toUpperCase()?$(a.target).attr("col"):$(a.target).parents("td").attr("col")),type:"select",ghost:!1,start:!0},null==e.last.move.recid&&(e.last.move.type="select-column");var h=a.target,i=$(e.box).find("#grid_"+e.name+"_focus");if(e.last.move){var j=e.last.move.focusX,k=e.last.move.focusY,l=$(h).parents("table").parent();(l.hasClass("w2ui-grid-records")||l.hasClass("w2ui-grid-frecords")||l.hasClass("w2ui-grid-columns")||l.hasClass("w2ui-grid-fcolumns")||l.hasClass("w2ui-grid-summary"))&&(j=e.last.move.focusX-$(e.box).find("#grid_"+e.name+"_records").scrollLeft(),k=e.last.move.focusY-$(e.box).find("#grid_"+e.name+"_records").scrollTop()),($(h).hasClass("w2ui-grid-footer")||$(h).parents("div.w2ui-grid-footer").length>0)&&(k=$(e.box).find("#grid_"+e.name+"_footer").position().top),i.css({left:j-10,top:k})}setTimeout(function(){["INPUT","TEXTAREA","SELECT"].indexOf(h.tagName.toUpperCase())!=-1?$(h).focus():i.is(":focus")||i.focus()},50)}if(1==e.reorderRows){var m=a.target;if("TD"!=m.tagName.toUpperCase()&&(m=$(m).parents("td")[0]),$(m).hasClass("w2ui-col-number")){e.selectNone(),e.last.move.reorder=!0;var n=$(e.box).find(".w2ui-even.w2ui-empty-record").css("background-color"),o=$(e.box).find(".w2ui-odd.w2ui-empty-record").css("background-color");$(e.box).find(".w2ui-even td").not(".w2ui-col-number").css("background-color",n),$(e.box).find(".w2ui-odd td").not(".w2ui-col-number").css("background-color",o);var p=e.last.move;if(!p.ghost){var q=$("#grid_"+e.name+"_rec_"+p.recid),b=q.parents("table").find("tr:first-child").clone();p.offsetY=a.offsetY,p.from=p.recid,p.pos=q.position(),p.ghost=$(q).clone(!0),p.ghost.removeAttr("id"),q.find("td").remove(),q.append('');var r=$(e.box).find(".w2ui-grid-records");r.append('
'),$("#grid_"+e.name+"_ghost").append(b).append(p.ghost)}var s=$("#grid_"+e.name+"_ghost"),r=$(e.box).find(".w2ui-grid-records");s.css({top:p.pos.top+r.scrollTop(),left:p.pos.left,"border-top":"1px solid #aaa","border-bottom":"1px solid #aaa"})}else e.last.move.reorder=!1}$(document).on("mousemove",c),$(document).on("mouseup",d),a.stopPropagation()}}function c(a){var b=e.last.move;if(b&&["select","select-column"].indexOf(b.type)!=-1&&(b.divX=a.screenX-b.x,b.divY=a.screenY-b.y,!(Math.abs(b.divX)<=1&&Math.abs(b.divY)<=1))){if(e.last.cancelClick=!0,1==e.reorderRows&&e.last.move.reorder){var c=$(a.target).parents("tr"),d=c.attr("recid");if(d!=b.from){var f=($("#grid_"+e.name+"_rec_"+b.recid),$("#grid_"+e.name+"_rec_"+d));$(e.box).find(".tmp-ghost").css("border-top","0px"),f.addClass("tmp-ghost").css("border-top","2px solid #769EFC"),b.lastY=a.screenY,b.to=d}var g=$("#grid_"+e.name+"_ghost"),h=$(e.box).find(".w2ui-grid-records");return void g.css({top:b.pos.top+b.divY+h.scrollTop(),left:b.pos.left})}b.start&&b.recid&&(e.selectNone(),b.start=!1);var i=[],d="TR"==a.target.tagName.toUpperCase()?$(a.target).attr("recid"):$(a.target).parents("tr").attr("recid");if(null==d){if("row"==e.selectType)return;if(e.last.move&&"select"==e.last.move.type)return;var j=parseInt($(a.target).parents("td").attr("col"));if(isNaN(j))e.removeRange("column-selection"),$(e.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected"),$(e.box).find(".w2ui-col-number").removeClass("w2ui-row-selected"),delete b.colRange;else{var k=j+"-"+j;b.columnj&&(k=j+"-"+b.column);for(var l=[],c=k.split("-"),n=parseInt(c[0]);n<=parseInt(c[1]);n++)l.push(n);if(b.colRange!=k&&(m=e.trigger({phase:"before",type:"columnSelect",target:e.name,columns:l,isCancelled:!1}),m.isCancelled!==!0)){null==b.colRange&&e.selectNone();var c=k.split("-");$(e.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected");for(var o=parseInt(c[0]);o<=parseInt(c[1]);o++)$(e.box).find("#grid_"+e.name+"_column_"+o+" .w2ui-col-header").addClass("w2ui-col-selected");$(e.box).find(".w2ui-col-number").not(".w2ui-head").addClass("w2ui-row-selected"),b.colRange=k,e.removeRange("column-selection"),e.addRange({name:"column-selection",range:[{recid:e.records[0].recid,column:c[0]},{recid:e.records[e.records.length-1].recid,column:c[1]}],style:"background-color: rgba(90, 145, 234, 0.1)"})}}}else{var p=e.get(b.recid,!0);if(null==p||e.records[p]&&e.records[p].recid!=b.recid)return;var q=e.get(d,!0);if(null==q)return;var r=parseInt(b.column),s=parseInt("TD"==a.target.tagName.toUpperCase()?$(a.target).attr("col"):$(a.target).parents("td").attr("col"));if(isNaN(r)&&isNaN(s)&&(r=0,s=e.columns.length-1),p>q){var c=p;p=q,q=c}var c="ind1:"+p+",ind2;"+q+",col1:"+r+",col2:"+s;if(b.range==c)return;b.range=c;for(var t=p;t<=q;t++)if(!(e.last.searchIds.length>0&&e.last.searchIds.indexOf(t)==-1))if("row"!=e.selectType){if(r>s){var c=r;r=s,s=c}for(var c=[],u=r;u<=s;u++)e.columns[u].hidden||i.push({recid:e.records[t].recid,column:parseInt(u)})}else i.push(e.records[t].recid);if("row"!=e.selectType){for(var v=e.getSelection(),c=[],w=0;wn?e.records.splice(n,0,f):e.records.splice(n-1,0,f)),$("#grid_"+e.name+"_ghost").remove(),e.refresh(),e.trigger($.extend(k,{phase:"after"}))}}delete e.last.move,$(document).off("mousemove",c),$(document).off("mouseup",d)}}var e=this,f=(new Date).getTime();if(null!=a&&($(this.box).find("#grid_"+this.name+"_body").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-grid").html(""),this.box=a),this.box){var g="object"!=typeof this.url?this.url:this.url.get,h=this.trigger({phase:"before",target:this.name,type:"render",box:a});if(h.isCancelled!==!0){if(this.reset(!0),!this.last.field)if(this.multiSearch&&this.show.searchAll)this.last.field="all",this.last.caption=w2utils.lang("All Fields");else{for(var i=0;i=this.searches.length?(this.last.field="",this.last.caption=""):(this.last.field=this.searches[i].field,this.last.caption=this.searches[i].caption)}if($(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-grid").html('
'),"row"!=this.selectType&&$(this.box).addClass("w2ui-ss"),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.initToolbar(),null!=this.toolbar&&this.toolbar.render($("#grid_"+this.name+"_toolbar")[0]),this.last.field&&"all"!=this.last.field){var j=this.searchData;setTimeout(function(){e.initAllField(e.last.field,1==j.length?j[0].value:null)},1)}$("#grid_"+this.name+"_footer").html(this.getFooterHTML()),this.last.state||(this.last.state=this.stateSave(!0)),this.stateRestore(),g&&this.refresh();for(var k=!1,l=0;l0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-grid").html(""),delete w2ui[this.name],this.trigger($.extend(a,{phase:"after"})))},initColumnOnOff:function(){if(this.show.toolbarColumns){for(var a=this,b='
",c=0;c ")}var f="object"!=typeof this.url?this.url:this.url.get;(f&&a.show.skipRecords||a.show.saveRestoreState)&&(b+=''),f&&a.show.skipRecords&&(b+='"),a.show.saveRestoreState&&(b+='"),b+="
'+w2utils.lang("Skip")+' "+w2utils.lang("Records")+"
"+w2utils.lang("Save Grid State")+'
"+w2utils.lang("Restore Default State")+"
",this.toolbar.get("w2ui-column-on-off").html=b}},initColumnDrag:function(a){function b(){j.pressed=!1,clearTimeout(j.timeout)}function c(a){j.timeout&&clearTimeout(j.timeout);var b=this;j.pressed=!0,j.timeout=setTimeout(function(){if(j.pressed){var c,f,g,h,k,l=["w2ui-col-number","w2ui-col-expand","w2ui-col-select"],m=["w2ui-head-last"],n=l.concat(m),o=".w2ui-col-number, .w2ui-col-expand, .w2ui-col-select",p=".w2ui-head.w2ui-col-number, .w2ui-head.w2ui-col-expand, .w2ui-head.w2ui-col-select";if($(a.originalEvent.target).parents().hasClass("w2ui-head")){for(var q=0,r=n.length;q
'),j.markerLeft=$('
')),j.lastInt&&j.lastInt===a||(j.lastInt=a,j.marker.remove(),j.markerLeft.remove(),$(".w2ui-head").removeClass("w2ui-col-intersection"),a>=j.columns.length?($(j.columns[j.columns.length-1]).children("div:last").append(j.marker.addClass("right").removeClass("left")),$(j.columns[j.columns.length-1]).addClass("w2ui-col-intersection")):a<=j.numberPreColumnsPresent?($(j.columns[j.numberPreColumnsPresent]).prepend(j.marker.addClass("left").removeClass("right")).css({position:"relative"}),$(j.columns[j.numberPreColumnsPresent]).prev().addClass("w2ui-col-intersection")):($(j.columns[a]).children("div:last").prepend(j.marker.addClass("left").removeClass("right")),$(j.columns[a]).prev().children("div:last").append(j.markerLeft.addClass("right").removeClass("left")).css({position:"relative"}),$(j.columns[a-1]).addClass("w2ui-col-intersection")))}function g(a,b,c){if(a<=b[0])return 0;if(a>=b[b.length-1]+c)return b.length;for(var d=0,e=b.length;df&&a<=h)return d;if(a>h&&a<=g)return d+1}return intersection}function h(a,b){$(j.ghost).css({left:a-10,top:b-10})}if(this.columnGroups&&this.columnGroups.length)throw"Draggable columns are not currently supported with column groups.";var i=this,j={};return j.lastInt=null,j.pressed=!1,j.timeout=null,j.columnHead=null,$(i.box).on("mousedown",c),$(i.box).on("mouseup",b),{remove:function(){$(i.box).off("mousedown",c),$(i.box).off("mouseup",b),$(i.box).find(".w2ui-head").removeAttr("draggable"),i.last.columnDrag=!1}}},columnOnOff:function(a,b){var c=$(a.target).parents("tr").find(".w2ui-column-check"),d=this.trigger({phase:"before",target:this.name,type:"columnOnOff",field:b,originalEvent:a});if(d.isCancelled!==!0){for(var e=this,f=e.find({"w2ui.expanded":!0},!0),g=0;g ';this.toolbar.items.push({type:"html",id:"w2ui-search",html:c})}if(this.show.toolbarSearch&&this.multiSearch&&this.searches.length>0&&this.toolbar.items.push($.extend(!0,{},this.buttons["search-go"])),(this.show.toolbarSearch||this.show.toolbarInput)&&(this.show.toolbarAdd||this.show.toolbarEdit||this.show.toolbarDelete||this.show.toolbarSave)&&this.toolbar.items.push({type:"break",id:"w2ui-break1"}),this.show.toolbarAdd&&this.toolbar.items.push($.extend(!0,{},this.buttons.add)),this.show.toolbarEdit&&this.toolbar.items.push($.extend(!0,{},this.buttons.edit)),this.show.toolbarDelete&&this.toolbar.items.push($.extend(!0,{},this.buttons.delete)),this.show.toolbarSave&&((this.show.toolbarAdd||this.show.toolbarDelete||this.show.toolbarEdit)&&this.toolbar.items.push({type:"break",id:"w2ui-break2"}),this.toolbar.items.push($.extend(!0,{},this.buttons.save))),b)for(var d=0;d0&&(c.css({bottom:0+(this.show.footer?w2utils.getSize(e,"height"):0)+"px"}),d.css({bottom:0+(this.show.footer?w2utils.getSize(e,"height"):0)+"px",right:"0px"})),this.show.footer&&e.css({bottom:"0px",left:"0px",right:"0px"}),f.css({top:0+(this.show.header?w2utils.getSize(a,"height"):0)+(this.show.toolbar?w2utils.getSize(b,"height"):0)+"px",bottom:0+(this.show.footer?w2utils.getSize(e,"height"):0)+(this.summary.length>0?w2utils.getSize(d,"height"):0)+"px",left:"0px",right:"0px"})},resizeRecords:function(){function a(a,b,c){var d="",e="",f="";d+='',e+='',c.show.lineNumbers&&(d+=''),c.show.selectColumn&&(d+=''),c.show.expandColumn&&(d+=''),e+='';for(var g=0;gc.last.colEnd)&&!h.frozen||(f='',h.frozen?d+=f:e+=f)}d+=' ',e+=' ',$("#grid_"+c.name+"_frecords > table").append(d),$("#grid_"+c.name+"_records > table").append(e)}var b=this;$(this.box).find(".w2ui-empty-record").remove();var c=$(this.box),d=$(this.box).find("> div.w2ui-grid-box"),e=$("#grid_"+this.name+"_header"),f=$("#grid_"+this.name+"_toolbar"),g=$("#grid_"+this.name+"_summary"),h=$("#grid_"+this.name+"_fsummary"),i=$("#grid_"+this.name+"_footer"),j=$("#grid_"+this.name+"_body"),k=$("#grid_"+this.name+"_columns"),l=$("#grid_"+this.name+"_fcolumns"),m=$("#grid_"+this.name+"_records"),n=$("#grid_"+this.name+"_frecords"),o=$("#grid_"+this.name+"_scroll1"),p=8*String(this.total).length+10;p<34&&(p=34),null!=this.lineNumberWidth&&(p=this.lineNumberWidth);for(var q=!1,r=!1,s=0,t=0;ttable").height()+(q?w2utils.scrollBarSize():0)&&(r=!0),this.fixedBody){var v=d.height()-(this.show.header?w2utils.getSize(e,"height"):0)-(this.show.toolbar?w2utils.getSize(f,"height"):0)-("none"!=g.css("display")?w2utils.getSize(g,"height"):0)-(this.show.footer?w2utils.getSize(i,"height"):0);j.css("height",v)}else{var v=w2utils.getSize(k,"height")+w2utils.getSize($("#grid_"+b.name+"_records table"),"height")+(q?w2utils.scrollBarSize():0);b.height=v+w2utils.getSize(d,"+height")+(b.show.header?w2utils.getSize(e,"height"):0)+(b.show.toolbar?w2utils.getSize(f,"height"):0)+("none"!=g.css("display")?w2utils.getSize(g,"height"):0)+(b.show.footer?w2utils.getSize(i,"height"):0),d.css("height",b.height),j.css("height",v),c.css("height",w2utils.getSize(d,"height")+w2utils.getSize(c,"+height"))}var w=this.records.length,x="object"!=typeof this.url?this.url:this.url.get;if(0==this.searchData.length||x||(w=this.last.searchIds.length),this.fixedBody||(r=!1),q||r?(k.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show(),m.css({top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(k,"height")+"px","-webkit-overflow-scrolling":"touch","overflow-x":q?"auto":"hidden","overflow-y":r?"auto":"hidden"})):(k.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").hide(),m.css({top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(k,"height")+"px",overflow:"hidden"}),m.length>0&&(this.last.scrollTop=0,this.last.scrollLeft=0)),q?(n.css("margin-bottom",w2utils.scrollBarSize()),o.show()):(n.css("margin-bottom",0),o.hide()),n.css({overflow:"hidden",top:m.css("top")}),this.show.emptyRecords&&!r){var y=Math.floor(m.height()/this.recordHeight)-1,z=0;if(m[0]&&(z=m[0].scrollHeight-y*this.recordHeight),z>=this.recordHeight&&(z-=this.recordHeight,y++),this.fixedBody){for(var A=w;A0){for(var B=parseInt(j.width())-(r?w2utils.scrollBarSize():0)-(this.show.lineNumbers?p:0)-(this.show.selectColumn?26:0)-(this.show.expandColumn?26:0)-1,C=B,D=0,E=!1,t=0;t0&&(F.gridMinWidth>C&&F.hidden!==!0&&(F.hidden=!0,E=!0),F.gridMinWidth0)for(var t=0;tparseInt(F.max)&&(F.sizeCalculated=F.max+"px"),G+=parseInt(F.sizeCalculated))}var H=parseInt(C)-parseInt(G);if(H>0&&D>0)for(var t=0;;){var F=this.columns[t];if(null!=F)if(F.hidden||"px"==F.sizeType)t++;else{if(F.sizeCalculated=parseInt(F.sizeCalculated)+1+"px",H--,0===H)break;t++}else t=0}else H>0&&k.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show();var I=1;this.show.lineNumbers&&(I+=p),this.show.selectColumn&&(I+=26),this.show.expandColumn&&(I+=26);for(var t=0;t table > tbody > tr:nth-child(1) td").add(l.find("> table > tbody > tr:nth-child(1) td")).each(function(a,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",p);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0===D?H:0)+"px")}),3==k.find("> table > tbody > tr").length&&k.find("> table > tbody > tr:nth-child(1) td").add(l.find("> table > tbody > tr:nth-child(1) td")).html("").css({height:"0px",border:"0px",padding:"0px",margin:"0px"}),m.find("> table > tbody > tr:nth-child(1) td").add(n.find("> table > tbody > tr:nth-child(1) td")).each(function(a,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",p);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0===D?H:0)+"px")}),g.find("> table > tbody > tr:nth-child(1) td").add(h.find("> table > tbody > tr:nth-child(1) td")).each(function(a,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",p);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0===D?H:0)+"px")}),this.initResize(),this.refreshRanges(),(this.last.scrollTop||this.last.scrollLeft)&&m.length>0&&(k.prop("scrollLeft",this.last.scrollLeft),m.prop("scrollTop",this.last.scrollTop),m.prop("scrollLeft",this.last.scrollLeft))},getSearchesHTML:function(){function a(a,c){var d="",e=b.operators[b.operatorsMap[a]];null!=c&&(e=c);for(var f=0;f'+w2utils.lang(h)+"\n"}return d}for(var b=this,c='',d=!1,e=0;eX",d=!0),null==f.inTag&&(f.inTag=""),null==f.outTag&&(f.outTag=""),null==f.style&&(f.style=""),null==f.type&&(f.type="text");var h='";switch(c+='"}}return c+='
'+g+' '+(f.caption||"")+' '+h+' ',f.type){case"text":case"alphanumeric":case"hex":case"color":case"list":case"combo":case"enum":var i="width: 250px;";["hex","color"].indexOf(f.type)!=-1&&(i="width: 90px;"),c+='";break;case"int":case"float":case"money":case"currency":case"percent":case"date":case"time":case"datetime":var i="width: 90px";"datetime"==f.type&&(i="width: 140px;"),c+='";break;case"select":c+=''}c+=f.outTag+"
"},initOperator:function(a,b){var c=this,d=c.searches[b],e=$("#grid_"+c.name+"_range_"+b),f=$("#grid_"+c.name+"_field_"+b),g=f.parent().find("span input");switch(f.show(),e.hide(),$(a).val()){case"between":e.show(),g.w2field(d.type,d.options);break;case"not null":case"null":f.hide(),f.val("1"),f.change()}},initSearches:function(){for(var a=this,b=0;b'+l+""}else i+='"}$("#grid_"+this.name+"_field_"+b).html(i)}null!=d?("int"==d.type&&["in","not in"].indexOf(d.operator)!=-1&&$("#grid_"+this.name+"_field_"+b).w2field("clear").val(d.value),$("#grid_"+this.name+"_operator_"+b).val(d.operator).trigger("change"),$.isArray(d.value)?["in","not in"].indexOf(d.operator)!=-1?$("#grid_"+this.name+"_field_"+b).val(d.value).trigger("change"):($("#grid_"+this.name+"_field_"+b).val(d.value[0]).trigger("change"),$("#grid_"+this.name+"_field2_"+b).val(d.value[1]).trigger("change")):null!=d.value&&$("#grid_"+this.name+"_field_"+b).val(d.value).trigger("change")):$("#grid_"+this.name+"_operator_"+b).val(f).trigger("change")}$("#w2ui-overlay-"+this.name+"-searchOverlay .w2ui-grid-searches *[rel=search]").on("keypress",function(b){13==b.keyCode&&(a.search(),$().w2overlay({name:a.name+"-searchOverlay"}))})},getColumnsHTML:function(){function a(){var a="",b="",d="";""!=c.columnGroups[c.columnGroups.length-1].caption&&c.columnGroups.push({caption:""}),c.show.lineNumbers&&(a+='
 
'),c.show.selectColumn&&(a+='
 
'),c.show.expandColumn&&(a+='
 
');var e=0;b+='';for(var f=0;f'),d='"+m+'
'+(h.caption?h.caption:" ")+"
",h&&h.frozen?a+=d:b+=d}else d='
'+(g.caption?g.caption:" ")+"
",h&&h.frozen?a+=d:b+=d;e+=g.span}return a+="",b+='',[a,b]}function b(a){var b="",d="";c.show.lineNumbers&&(b+='
#
"),c.show.selectColumn&&(b+='
"),c.show.expandColumn&&(b+='
 
');var e,f=0,g=0;d+='';for(var h=0;hc.last.colEnd)||i.frozen)&&!i.hidden&&(e.master!==!0||a)){var j=c.getColumnCellHTML(h);i&&i.frozen?b+=j:d+=j}}return b+='
 
',d+='
 
',b+="",d+="",[b,d]}var c=this,d="",e="";if(this.show.columnHeaders)if(this.columnGroups.length>0){var f=b(!0),g=a(),h=b(!1);d=f[0]+g[0]+h[0],e=f[1]+g[1]+h[1]}else{var i=b(!0);d=i[0],e=i[1]}return[d,e]},getColumnCellHTML:function(a){var b=this.columns[a];if(null==b)return""; for(var c=!this.reorderColumns||this.columnGroups&&this.columnGroups.length?"":" w2ui-reorder-cols-head ",d="",e=0;e"+(b.resizable!==!1?'
':"")+'
'+(b.caption?b.caption:" ")+"
";return i},columnTooltipShow:function(a){if("normal"!=this.columnTooltip){var b=$(this.box).find("#grid_"+this.name+"_column_"+a),c=this.columns[a],d=this.columnTooltip;b.prop("_mouse_over",!0),setTimeout(function(){b.prop("_mouse_over")===!0&&b.prop("_mouse_tooltip")!==!0&&(b.prop("_mouse_tooltip",!0),b.w2tag(c.tooltip,{position:d}))},1)}},columnTooltipHide:function(a){if("normal"!=this.columnTooltip){var b=$(this.box).find("#grid_"+this.name+"_column_"+a);this.columns[a];b.removeProp("_mouse_over"),setTimeout(function(){b.prop("_mouse_over")!==!0&&b.prop("_mouse_tooltip")===!0&&(b.removeProp("_mouse_tooltip"),b.w2tag())},1)}},getRecordsHTML:function(){var a=this.records.length,b="object"!=typeof this.url?this.url:this.url.get;0==this.searchData.length||b||(a=this.last.searchIds.length),a>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start;var c=$("#grid_"+this.name+"_records"),d=Math.floor(c.height()/this.recordHeight)+this.last.show_extra+1;(!this.fixedBody||d>a)&&(d=a);var e=this.getRecordHTML(-1,0),f=""+e[0],g="
"+e[1];f+='',g+='';for(var h=0;h
',g+=' ',this.last.range_start=0,this.last.range_end=d,[f,g]},getSummaryHTML:function(){if(0!==this.summary.length){for(var a=this.getRecordHTML(-1,0),b=""+a[0],c="
"+a[1],d=0;d0&&$(c.box).find(".w2ui-grid-data > div").w2marker(a)},50))}var c=((new Date).getTime(),this),d="object"!=typeof this.url?this.url:this.url.get,e=$("#grid_"+this.name+"_records"),f=$("#grid_"+this.name+"_frecords");if(a){var g=a.target.scrollTop,h=a.target.scrollLeft;c.last.scrollTop=g,c.last.scrollLeft=h,$("#grid_"+c.name+"_columns")[0].scrollLeft=h,$("#grid_"+c.name+"_summary")[0].scrollLeft=h,f[0].scrollTop=g}this.last.bubbleEl&&($(this.last.bubbleEl).w2tag(),this.last.bubbleEl=null);var i=null,j=null;if(c.disableCVS||c.columnGroups.length>0)i=0,j=c.columns.length-1;else{for(var k=e.width(),l=0,m=0;mc.last.scrollLeft&&null==i&&(i=m),l+n-30>c.last.scrollLeft+k&&null==j&&(j=m),l+=n}null==j&&(j=c.columns.length-1)}if(null!=i&&(i<0&&(i=0),j<0&&(j=0),i==j&&(i>0?i--:j++),i!=c.last.colStart||j!=c.last.colEnd)){var o=$(c.box),p=Math.abs(i-c.last.colStart),q=Math.abs(j-c.last.colEnd);if(p<5&&q<5){var r=o.find(".w2ui-grid-columns #grid_"+c.name+"_column_start"),s=o.find(".w2ui-grid-columns .w2ui-head-last"),t=o.find("#grid_"+c.name+"_records .w2ui-grid-data-spacer"),u=o.find("#grid_"+c.name+"_records .w2ui-grid-data-last"),v=o.find("#grid_"+c.name+"_summary .w2ui-grid-data-spacer"),w=o.find("#grid_"+c.name+"_summary .w2ui-grid-data-last");if(i>c.last.colStart)for(var m=c.last.colStart;mj;m--)o.find("#grid_"+c.name+"_columns #grid_"+c.name+"_column_"+m).remove(),o.find("#grid_"+c.name+'_records td[col="'+m+'"]').remove(),o.find("#grid_"+c.name+'_summary td[col="'+m+'"]').remove();if(i=i;m--)c.columns[m]&&(c.columns[m].frozen||c.columns[m].hidden)||(r.after(c.getColumnCellHTML(m)),t.each(function(a,b){var d=$(b).parent().attr("index"),e='';null!=d&&(e=c.getCellHTML(parseInt(d),m,!1)),$(b).after(e)}),v.each(function(a,b){var d=$(b).parent().attr("index"),e='';null!=d&&(e=c.getCellHTML(parseInt(d),m,!0)),$(b).after(e)}));if(j>c.last.colEnd)for(var m=c.last.colEnd+1;m<=j;m++)c.columns[m]&&(c.columns[m].frozen||c.columns[m].hidden)||(s.before(c.getColumnCellHTML(m)),u.each(function(a,b){var d=$(b).parent().attr("index"),e='';null!=d&&(e=c.getCellHTML(parseInt(d),m,!1)),$(b).before(e)}),w.each(function(a,b){var d=$(b).parent().attr("index"),e=c.getCellHTML(parseInt(d),m,!0);$(b).before(e)}));c.last.colStart=i,c.last.colEnd=j,c.resizeRecords()}else{c.last.colStart=i,c.last.colEnd=j;var x=this.getColumnsHTML(),y=this.getRecordsHTML(),z=this.getSummaryHTML(),A=o.find("#grid_"+this.name+"_columns"),B=o.find("#grid_"+this.name+"_records"),C=o.find("#grid_"+this.name+"_frecords"),D=o.find("#grid_"+this.name+"_summary");A.find("tbody").html(x[1]),C.html(y[0]),B.prepend(y[1]),null!=z&&D.html(z[1]),setTimeout(function(){B.find("> table").not("table:first-child").remove(),D[0]&&(D[0].scrollLeft=c.last.scrollLeft)},1),c.resizeRecords()}}var E=this.records.length;if(0==this.searchData.length||d||(E=this.last.searchIds.length),0!==E&&0!==e.length&&0!==e.height()&&(E>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start,!(e.height()E&&(F=E),G>=E-1&&(G=E),$("#grid_"+this.name+"_footer .w2ui-footer-right").html((c.show.statusRange?w2utils.formatNumber(this.offset+F)+"-"+w2utils.formatNumber(this.offset+G)+(this.total!=-1?" "+w2utils.lang("of")+" "+w2utils.formatNumber(this.total):""):"")+(d&&c.show.statusBuffered?" ("+w2utils.lang("buffered")+" "+w2utils.formatNumber(E)+(this.offset>0?", skip "+w2utils.formatNumber(this.offset):"")+")":"")),d||this.fixedBody&&!(this.total!=-1&&this.total<=this.vs_start)){var H=Math.floor(e[0].scrollTop/this.recordHeight)-this.last.show_extra,I=H+Math.floor(e.height()/this.recordHeight)+2*this.last.show_extra+1;H<1&&(H=1),I>this.total&&this.total!=-1&&(I=this.total);var J=e.find("#grid_"+this.name+"_rec_top"),K=e.find("#grid_"+this.name+"_rec_bottom"),L=f.find("#grid_"+this.name+"_frec_top"),M=f.find("#grid_"+this.name+"_frec_bottom");String(J.next().prop("id")).indexOf("_expanded_row")!=-1&&(J.next().remove(),L.next().remove()),this.total>I&&String(K.prev().prop("id")).indexOf("_expanded_row")!=-1&&(K.prev().remove(),M.prev().remove());var N=parseInt(J.next().attr("line")),O=parseInt(K.prev().attr("line"));if(N=N-this.last.show_extra+2&&H>1)return;for(;;){var P=f.find("#grid_"+this.name+"_frec_bottom").prev(),Q=e.find("#grid_"+this.name+"_rec_bottom").prev();if("top"==Q.attr("line"))break;if(!(parseInt(Q.attr("line"))>I))break;P.remove(),Q.remove()}var R=e.find("#grid_"+this.name+"_rec_top").next(),S=R.attr("line");"bottom"==S&&(S=I);for(var m=parseInt(S)-1;m>=H;m--)if(this.records[m-1]){var Q=this.records[m-1].w2ui;Q&&!Array.isArray(Q.children)&&(Q.expanded=!1);var T=this.getRecordHTML(m-1,m);J.after(T[1]),L.after(T[0])}b(),setTimeout(function(){c.refreshRanges()},0)}var U=(H-1)*c.recordHeight,V=(E-I)*c.recordHeight;V<0&&(V=0),J.css("height",U+"px"),L.css("height",U+"px"),K.css("height",V+"px"),M.css("height",V+"px"),c.last.range_start=H,c.last.range_end=I;var W=Math.floor(e[0].scrollTop/this.recordHeight),X=W+Math.floor(e.height()/this.recordHeight);if(X+10>E&&this.last.pull_more!==!0&&(E
')}),(Y.find("td .w2ui-spinner").length>0||Y.find("td").text().indexOf("Load")==-1)&&Y.find("td").html("
"+w2utils.lang("Load")+" "+c.limit+" "+w2utils.lang("More")+"...
")}E>=this.total-this.offset&&this.total!=-1&&$("#grid_"+this.name+"_rec_more, #grid_"+this.name+"_frec_more").hide()}}},getRecordHTML:function(a,b,c){var d,e="",f="",g="",h=this.last.selection;if(a==-1){f+='
',g+='',this.show.lineNumbers&&(f+=''),this.show.selectColumn&&(f+=''),this.show.expandColumn&&(f+=''),g+='';for(var i=0;i',j.frozen&&!j.hidden)f+=e;else{if(j.hidden||ithis.last.colEnd)continue;g+=e}}return f+='',g+='',f+="",g+="",[f,g]}var k="object"!=typeof this.url?this.url:this.url.get;if(c!==!0)if(this.searchData.length>0&&!k){if(a>=this.last.searchIds.length)return"";a=this.last.searchIds[a],d=this.records[a]}else{if(a>=this.records.length)return"";d=this.records[a]}else{if(a>=this.summary.length)return"";d=this.summary[a]}if(!d)return"";null==d.recid&&null!=this.recid&&null!=d[this.recid]&&(d.recid=d[this.recid]);var l=(w2utils.escapeId(d.recid),!1);h.indexes.indexOf(a)!=-1&&(l=!0);var m=d.w2ui?d.w2ui.style:"";null!=m&&"string"==typeof m||(m="");var n=d.w2ui?d.w2ui.class:"";if(null!=n&&"string"==typeof n||(n=""),f+='",g+='",this.show.lineNumbers&&(f+='"),this.show.selectColumn&&(f+='"),this.show.expandColumn){var o="";o=d.w2ui&&d.w2ui.expanded===!0?"-":"+",d.w2ui&&"none"==d.w2ui.expanded&&(o=""),d.w2ui&&"spinner"==d.w2ui.expanded&&(o='
'),f+='"}g+='';for(var p=0,q=0;;){var r=1,j=this.columns[p];if(null==j)break;if(j.hidden)p++,q>0&&q--;else if(q>0){if(p++,null==this.columns[p])break;d.w2ui.colspan[this.columns[p-1].field]=0,q--}else{if(d.w2ui){var s=d.w2ui.colspan,t=this.columns[p].field;s&&0===s[t]&&delete s[t]}if(!(pthis.last.colEnd)||j.frozen){if(d.w2ui&&"object"==typeof d.w2ui.colspan){var u=parseInt(d.w2ui.colspan[j.field])||null;if(u>1){for(var v=0,i=p;i=this.columns.length);i++)this.columns[i].hidden&&v++;r=u-v,q=u-1}}var w=this.getCellHTML(a,p,c,r);j.frozen?f+=w:g+=w,p++}else p++}}return f+='',g+='',f+="",g+="",[f,g]},getLineHTML:function(a){return"
"+a+"
"},getCellHTML:function(a,b,c,d){var e=this.columns[b];if(null==e)return"";var f=c!==!0?this.records[a]:this.summary[a],g=this.getCellValue(a,b,c),h=this.getCellEditable(a,b),i="max-height: "+parseInt(this.recordHeight)+"px;",j=!c&&f&&f.w2ui&&f.w2ui.changes&&null!=f.w2ui.changes[e.field],k="",l="",m=this.last.selection,n=!1,o="";if(m.indexes.indexOf(a)!=-1&&(n=!0),null==d&&(d=f&&f.w2ui&&f.w2ui.colspan&&f.w2ui.colspan[e.field]?f.w2ui.colspan[e.field]:1),0===b&&f&&f.w2ui&&Array.isArray(f.w2ui.children)){for(var p=0,q=this.get(f.w2ui.parent_recid,!0);;){if(null==q)break;p++;var r=this.records[q].w2ui;if(null==r||null==r.parent_recid)break;q=this.get(r.parent_recid,!0)}if(f.w2ui.parent_recid)for(var s=0;s';o+='"}if(e.info===!0&&(e.info={}),null!=e.info&&(e.info.icon||(e.info.icon="w2ui-icon-info"),o+=''),null!=e.render){if("function"==typeof e.render&&(g=$.trim(e.render.call(this,f,a,b,g)),(g.length<4||"'+o+String(g)+"")),"object"==typeof e.render&&(g='
'+o+(e.render[g]||"")+"
"),"string"==typeof e.render){var t=e.render.toLowerCase().indexOf(":"),r=[];t==-1?(r[0]=e.render.toLowerCase(),r[1]=""):(r[0]=e.render.toLowerCase().substr(0,t),r[1]=e.render.toLowerCase().substr(t+1));var u=w2utils.formatters[r[0]];g='
'+o+("function"==typeof u?u(g,r[1]):"")+"
"}}else{if(h&&["checkbox","check"].indexOf(h.type)!=-1){var v=c?-(a+1):a;i+="text-align: center;",g='',o=""}if(this.show.recordTitles){var w=w2utils.stripTags(String(g).replace(/"/g,"''"));null!=e.title&&("function"==typeof e.title&&(w=e.title.call(this,f,a,b)),"string"==typeof e.title&&(w=e.title))}g='
'+o+String(g)+"
"}if(null==g&&(g=""),"string"==typeof e.render){var r=e.render.toLowerCase().split(":");["number","int","float","money","currency","percent","size"].indexOf(r[0])!=-1&&(k+="text-align: right;")}f&&f.w2ui&&("object"==typeof f.w2ui.style&&("string"==typeof f.w2ui.style[b]&&(k+=f.w2ui.style[b]+";"),"string"==typeof f.w2ui.style[e.field]&&(k+=f.w2ui.style[e.field]+";")),"object"==typeof f.w2ui.class&&("string"==typeof f.w2ui.class[b]&&(l+=f.w2ui.class[b]+" "),"string"==typeof f.w2ui.class[e.field]&&(l+=f.w2ui.class[e.field]+" ")));var x=!1;return n&&$.inArray(b,m.columns[a])!=-1&&(x=!0),g='
"},showBubble:function(a,b){var c="",d=this.columns[b].info,e=this.records[a],f=$(this.box).find("#grid_"+this.name+"_data_"+a+"_"+b+" .w2ui-info");if(this.last.bubbleEl&&$(this.last.bubbleEl).w2tag(),this.last.bubbleEl=f,null==d.fields){d.fields=[];for(var g=0;g1&&(w2utils.formatters[j[1]]?k=w2utils.formatters[j[1]](k,j[2]||null):console.log('ERROR: w2utils.formatters["'+j[1]+'"] does not exists.')),(d.showEmpty===!0||null!=k&&""!=k)&&(null!=d.maxLength&&"string"==typeof k&&k.length>d.maxLength&&(k=k.substr(0,d.maxLength)+"..."),c+="")}else c+=''}c+="
"+(c!==!0?this.getLineHTML(b,d):"")+"'+(c!==!0?'
':"")+"
'+(c!==!0?'
"+o+"
":"")+"
1?'colspan="'+d+'"':"")+">"+g+"
"+h.caption+""+((0===k?"0":k)||"")+"
"}else if($.isPlainObject(i)){c='';for(var l in i){var m=i[l];if(""!=m&&"-"!=m&&"--"!=m&&"---"!=m){var j=String(m).split(":"),h=this.getColumn(j[0]);null==h&&(h={field:j[0],caption:j[0]});var k=h?this.parseField(e,h.field):"";j.length>1&&(w2utils.formatters[j[1]]?k=w2utils.formatters[j[1]](k,j[2]||null):console.log('ERROR: w2utils.formatters["'+j[1]+'"] does not exists.')),"function"==typeof m&&(k=m(e,a,b)),(d.showEmpty===!0||null!=k&&""!=k)&&(null!=d.maxLength&&"string"==typeof k&&k.length>d.maxLength&&(k=k.substr(0,d.maxLength)+"..."),c+="")}else c+=''}c+="
"+l+""+(k||"")+"
"}$(f).w2tag($.extend({html:c,left:-4,position:"bottom|top",className:"w2ui-info-bubble",style:"",hideOnClick:!0},d.options||{}))},getCellEditable:function(a,b){var c=this.columns[b],d=this.records[a];if(!d||!c)return null;var e=d.w2ui?d.w2ui.editable:null;if(e===!1)return null;if((null==e||e===!0)&&(e=c?c.editable:null,"function"==typeof e)){var f=this.getCellValue(a,b,!1);e=e.call(this,d,a,b,f)}return e},getCellValue:function(a,b,c){var d=this.columns[b],e=c!==!0?this.records[a]:this.summary[a],f=this.parseField(e,d.field);return e&&e.w2ui&&e.w2ui.changes&&null!=e.w2ui.changes[d.field]&&(f=e.w2ui.changes[d.field]),$.isPlainObject(f)&&d.editable&&(null!=f.text&&(f=f.text),null!=f.id&&(f=f.id)),null==f&&(f=""),f},getFooterHTML:function(){return'
'},status:function(a){if(null!=a)$("#grid_"+this.name+"_footer").find(".w2ui-footer-left").html(a);else{var b="",c=this.getSelection();if(c.length>0&&(this.show.statusSelection&&c.length>1&&(b=String(c.length).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")+" "+w2utils.lang("selected")),this.show.statusRecordID&&1==c.length)){var d=c[0];"object"==typeof d&&(d=d.recid+", "+w2utils.lang("Column")+": "+d.column),b=w2utils.lang("Record ID")+": "+d+" "}$("#grid_"+this.name+"_footer .w2ui-footer-left").html(b),1==c.length?this.toolbar.enable("w2ui-edit"):this.toolbar.disable("w2ui-edit"),c.length>=1?this.toolbar.enable("w2ui-delete"):this.toolbar.disable("w2ui-delete")}},lock:function(a,b){var c=this,d=Array.prototype.slice.call(arguments,0);d.unshift(this.box),setTimeout(function(){$(c.box).find("#grid_"+c.name+"_empty_msg").remove(),w2utils.lock.apply(window,d)},10)},unlock:function(a){var b=this.box;setTimeout(function(){$(b).find(".w2ui-message").not(".w2ui-closing").length>0||w2utils.unlock(b,a)},25)},stateSave:function(a){if(!w2utils.hasLocalStorage)return null;for(var b={columns:[],show:$.extend({},this.show),last:{search:this.last.search,multi:this.last.multi,logic:this.last.logic,caption:this.last.caption,field:this.last.field,scrollTop:this.last.scrollTop,scrollLeft:this.last.scrollLeft},sortData:[],searchData:[]},c=0;c0&&b.localSort(),b.searchData.length>0&&b.localSearch()),b.last.scrollTop=f,b.last.scrollLeft=g,b.refresh()},1)}return this.trigger($.extend(e,{phase:"after"})),!0},stateReset:function(){if(this.stateRestore(this.last.state),w2utils.hasLocalStorage)try{var a=$.parseJSON(localStorage.w2ui||"{}");a.states&&a.states[this.stateId||this.name]&&delete a.states[this.stateId||this.name],localStorage.w2ui=JSON.stringify(a)}catch(a){return delete localStorage.w2ui,null}},parseField:function(a,b){var c="";try{c=a;for(var d=String(b).split("."),e=0;e=this.columns.length)return null;var e=this.records[a].w2ui,f=(this.columns[b],this.columns[d]),g=e&&e.colspan&&!isNaN(e.colspan[f.field])?parseInt(e.colspan[f.field]):1;if(null==f)return null;if(f&&f.hidden||0===g)return this.nextCell(a,d,c);if(c){var h=this.getCellEditable(a,b);if(null==h||["checkbox","check"].indexOf(h.type)!=-1)return this.nextCell(a,d,c)}return d},prevCell:function(a,b,c){var d=b-1;if(d<0)return null;var e=this.records[a].w2ui,f=this.columns[d],g=e&&e.colspan&&!isNaN(e.colspan[f.field])?parseInt(e.colspan[f.field]):1;if(null==f)return null;if(f&&f.hidden||0===g)return this.prevCell(a,d,c);if(c){var h=this.getCellEditable(a,b);if(null==h||["checkbox","check"].indexOf(h.type)!=-1)return this.prevCell(a,d,c)}return d},nextRow:function(a,b){var c=this.last.searchIds,d=null;if(a+10&&a0)for(;;){if($.inArray(a,c)!=-1||a>this.records.length)break;a++}var e=this.records[a].w2ui,f=this.columns[b],g=e&&e.colspan&&null!=f&&!isNaN(e.colspan[f.field])?parseInt(e.colspan[f.field]):1;d=0===g?this.nextRow(a,b):a}return d},prevRow:function(a,b){var c=this.last.searchIds,d=null;if(a>0&&0===c.length||c.length>0&&a>c[0]){if(a--,c.length>0)for(;;){if($.inArray(a,c)!=-1||a<0)break;a--}var e=this.records[a].w2ui,f=this.columns[b],g=e&&e.colspan&&null!=f&&!isNaN(e.colspan[f.field])?parseInt(e.colspan[f.field]):1;d=0===g?this.prevRow(a,b):a}return d},selectionSave:function(){return this.last._selection=this.getSelection(),this.last._selection},selectionRestore:function(a){var b=(new Date).getTime();this.last.selection={indexes:[],columns:{}};for(var c=this.last.selection,d=this.last._selection,e=0;e'+a+"",buttons:'",onOpen:function(a){setTimeout(function(){$(this.box).find(".w2ui-btn").focus()},25)},onClose:function(a){"function"==typeof b&&b()}}),w2utils.message.call(this,{box:this.box,path:"w2ui."+this.name,title:".w2ui-grid-header:visible",body:".w2ui-grid-box"},a)}},$.extend(w2grid.prototype,w2utils.event),w2obj.grid=w2grid}(jQuery),function(a){var b=function(b){this.box=null,this.name=null,this.panels=[],this.tmp={},this.padding=1,this.resizer=4,this.style="",a.extend(!0,this,w2obj.layout,b)},c=["top","left","main","preview","right","bottom"];a.fn.w2layout=function(d){function e(b,c,d){var e=b.get(c);return null!=e&&null==d&&(d=e.tabs),null!=e&&null!=d&&(a.isArray(d)&&(d={tabs:d}),a().w2destroy(b.name+"_"+c+"_tabs"),e.tabs=a().w2tabs(a.extend({},d,{owner:b,name:b.name+"_"+c+"_tabs"})),e.show.tabs=!0,!0)}function f(b,c,d){var e=b.get(c);return null!=e&&null==d&&(d=e.toolbar),null!=e&&null!=d&&(a.isArray(d)&&(d={items:d}),a().w2destroy(b.name+"_"+c+"_toolbar"),e.toolbar=a().w2toolbar(a.extend({},d,{owner:b,name:b.name+"_"+c+"_toolbar"})),e.show.toolbar=!0,!0)}if(a.isPlainObject(d)){if(!w2utils.checkName(d,"w2layout"))return;var g=d.panels||[],h=new b(d);a.extend(h,{handlers:[],panels:[]});for(var i=0,j=g.length;i0&&h.render(a(this)[0]),w2ui[h.name]=h,h}var l=w2ui[a(this).attr("name")];return l?arguments.length>0?(l[d]&&l[d].apply(l,Array.prototype.slice.call(arguments,1)),this):l:null},b.prototype={onShow:null,onHide:null,onResizing:null,onResizerClick:null,onRender:null,onRefresh:null,onContent:null, onResize:null,onDestroy:null,panel:{type:null,title:"",size:100,minSize:20,maxSize:!1,hidden:!1,resizable:!1,overflow:"auto",style:"",content:"",tabs:null,toolbar:null,width:null,height:null,show:{toolbar:!1,tabs:!1},onRefresh:null,onShow:null,onHide:null},html:function(a,b,c){return this.content(a,b,c)},content:function(b,c,d){var e=this,f=this.get(b);if("css"==b)return a("#layout_"+e.name+"_panel_css").html(""),!0;if(null==f)return!1;if(null==c)return f.content;var g=this.trigger({phase:"before",type:"content",target:b,object:f,content:c,transition:d});if(g.isCancelled!==!0){if(c instanceof jQuery)return console.log("ERROR: You can not pass jQuery object to w2layout.content() method"),!1;var h="#layout_"+this.name+"_panel_"+f.type,i=a(h+"> .w2ui-panel-content"),j=0;if(i.length>0&&(a(h).scrollTop(0),j=a(i).position().top),""===f.content)f.content=c,this.refresh(b);else{if(f.content=c,!f.hidden&&null!=d&&""!==d){var k=a(h+"> .w2ui-panel-content");k.after('
');var l=a(h+"> .w2ui-panel-content.new-panel");k.css("top",j),l.css("top",j),"object"==typeof c?(c.box=l[0],c.render()):l.html(c),w2utils.transition(k[0],l[0],d,function(){k.remove(),l.removeClass("new-panel"),l.css("overflow",f.overflow),e.resize(),window.navigator.userAgent.indexOf("MSIE")!=-1&&setTimeout(function(){e.resize()},100)})}this.refresh(b)}return e.trigger(a.extend(g,{phase:"after"})),e.resize(),window.navigator.userAgent.indexOf("MSIE")!=-1&&setTimeout(function(){e.resize()},100),!0}},message:function(b,c){var d=this;"string"==typeof c&&(c={width:c.length<300?350:550,height:c.length<300?170:250,body:'
'+c+"
",buttons:'",onOpen:function(b){setTimeout(function(){a(this.box).find(".w2ui-btn").focus()},25)}});var e,f=this.get(b),g=a("#layout_"+this.name+"_panel_"+f.type),h=g.css("overflow");c&&(c.onClose&&(e=c.onClose),c.onClose=function(b){"function"==typeof e&&e(b),b.done(function(){a("#layout_"+d.name+"_panel_"+f.type).css("overflow",h)})}),a("#layout_"+this.name+"_panel_"+f.type).css("overflow","hidden"),w2utils.message.call(this,{box:a("#layout_"+this.name+"_panel_"+f.type),param:b,path:"w2ui."+this.name,title:".w2ui-panel-title:visible",body:".w2ui-panel-content"},c)},load:function(b,c,d,e){var f=this;return"css"==b?(a.get(c,function(a,c,d){f.content(b,d.responseText),e&&e()}),!0):null!=this.get(b)&&(a.get(c,function(a,c,g){f.content(b,g.responseText,d),e&&e(),f.resize(),window.navigator.userAgent.indexOf("MSIE")!=-1&&setTimeout(function(){f.resize()},100)}),!0)},sizeTo:function(b,c,d){var e=this,f=e.get(b);return null!=f&&(a(e.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",d!==!0?".2s":"0s")),setTimeout(function(){e.set(b,{size:c})},1),setTimeout(function(){a(e.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),e.resize()},500),!0)},show:function(b,c){var d=this,e=this.trigger({phase:"before",type:"show",target:b,object:this.get(b),immediate:c});if(e.isCancelled!==!0){var f=d.get(b);return null!=f&&(f.hidden=!1,c===!0?(a("#layout_"+d.name+"_panel_"+b).css({opacity:"1"}),d.trigger(a.extend(e,{phase:"after"})),d.resize()):(a("#layout_"+d.name+"_panel_"+b).css({opacity:"0"}),a(d.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",".2s")),setTimeout(function(){d.resize()},1),setTimeout(function(){a("#layout_"+d.name+"_panel_"+b).css({opacity:"1"})},250),setTimeout(function(){a(d.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),d.trigger(a.extend(e,{phase:"after"})),d.resize()},500)),!0)}},hide:function(b,c){var d=this,e=this.trigger({phase:"before",type:"hide",target:b,object:this.get(b),immediate:c});if(e.isCancelled!==!0){var f=d.get(b);return null!=f&&(f.hidden=!0,c===!0?(a("#layout_"+d.name+"_panel_"+b).css({opacity:"0"}),d.trigger(a.extend(e,{phase:"after"})),d.resize()):(a(d.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",".2s")),a("#layout_"+d.name+"_panel_"+b).css({opacity:"0"}),setTimeout(function(){d.resize()},1),setTimeout(function(){a(d.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),d.trigger(a.extend(e,{phase:"after"})),d.resize()},500)),!0)}},toggle:function(a,b){var c=this.get(a);return null!=c&&(c.hidden?this.show(a,b):this.hide(a,b))},set:function(b,c){var d=this.get(b,!0);return null!=d&&(a.extend(this.panels[d],c),null==c.content&&null==c.resizable||this.refresh(b),this.resize(),!0)},get:function(a,b){for(var c=0;c .w2ui-panel-content");return 1!=c.length?null:c[0]},hideToolbar:function(b){var c=this.get(b);c&&(c.show.toolbar=!1,a("#layout_"+this.name+"_panel_"+b+"> .w2ui-panel-toolbar").hide(),this.resize())},showToolbar:function(b){var c=this.get(b);c&&(c.show.toolbar=!0,a("#layout_"+this.name+"_panel_"+b+"> .w2ui-panel-toolbar").show(),this.resize())},toggleToolbar:function(a){var b=this.get(a);b&&(b.show.toolbar?this.hideToolbar(a):this.showToolbar(a))},assignToolbar:function(b,c){"string"==typeof c&&null!=w2ui[c]&&(c=w2ui[c]);var d=this.get(b);d.toolbar=c;var e=a(this.box).find(b+"> .w2ui-panel-toolbar");null!=d.toolbar?(0===e.find("[name="+d.toolbar.name+"]").length?e.w2render(d.toolbar):null!=d.toolbar&&d.toolbar.refresh(),this.showToolbar(b),this.refresh("main")):(e.html(""),this.hideToolbar(b))},hideTabs:function(b){var c=this.get(b);c&&(c.show.tabs=!1,a("#layout_"+this.name+"_panel_"+b+"> .w2ui-panel-tabs").hide(),this.resize())},showTabs:function(b){var c=this.get(b);c&&(c.show.tabs=!0,a("#layout_"+this.name+"_panel_"+b+"> .w2ui-panel-tabs").show(),this.resize())},toggleTabs:function(a){var b=this.get(a);b&&(b.show.tabs?this.hideTabs(a):this.showTabs(a))},render:function(b){function d(){h.tmp.events={resize:function(a){w2ui[h.name].resize()},resizeStart:e,mouseMove:g,mouseUp:f},a(window).on("resize",h.tmp.events.resize)}function e(b,d){if(h.box){d||(d=window.event),a(document).off("mousemove",h.tmp.events.mouseMove).on("mousemove",h.tmp.events.mouseMove),a(document).off("mouseup",h.tmp.events.mouseUp).on("mouseup",h.tmp.events.mouseUp),h.tmp.resize={type:b,x:d.screenX,y:d.screenY,diff_x:0,diff_y:0,value:0};for(var e=0;e0?f.attr("locked","previous"):h.lock(c[e],{opacity:0})}"left"!=b&&"right"!=b||(h.tmp.resize.value=parseInt(a("#layout_"+h.name+"_resizer_"+b)[0].style.left)),"top"!=b&&"preview"!=b&&"bottom"!=b||(h.tmp.resize.value=parseInt(a("#layout_"+h.name+"_resizer_"+b)[0].style.top))}}function f(b){if(h.box&&(b||(b=window.event),a(document).off("mousemove",h.tmp.events.mouseMove),a(document).off("mouseup",h.tmp.events.mouseUp),null!=h.tmp.resize)){for(var d=0;dc.width&&(g=c.minSize-c.width),c.maxSize&&c.width+g>c.maxSize&&(g=c.maxSize-c.width),j.minSize+g>j.width&&(g=j.width-j.minSize);break;case"right":c.minSize+g>c.width&&(g=c.width-c.minSize),c.maxSize&&c.width-g>c.maxSize&&(g=c.width-c.maxSize),j.minSize-g>j.width&&(g=j.minSize-j.width);break;case"top":c.minSize-i>c.height&&(i=c.minSize-c.height),c.maxSize&&c.height+i>c.maxSize&&(i=c.maxSize-c.height),j.minSize+i>j.height&&(i=j.height-j.minSize);break;case"preview":case"bottom":c.minSize+i>c.height&&(i=c.height-c.minSize),c.maxSize&&c.height-i>c.maxSize&&(i=c.height-c.maxSize),j.minSize-i>j.height&&(i=j.minSize-j.height)}switch(d.diff_x=g,d.diff_y=i,d.type){case"top":case"preview":case"bottom":d.diff_x=0,f.length>0&&(f[0].style.top=d.value+d.diff_y+"px");break;case"left":case"right":d.diff_y=0,f.length>0&&(f[0].style.left=d.value+d.diff_x+"px")}h.trigger(a.extend(e,{phase:"after"}))}}}var h=this,i=(new Date).getTime(),j=h.trigger({phase:"before",type:"render",target:h.name,box:b});if(j.isCancelled!==!0){if(null!=b&&(a(h.box).find("#layout_"+h.name+"_panel_main").length>0&&a(h.box).removeAttr("name").removeClass("w2ui-layout").html(""),h.box=b),!h.box)return!1;a(h.box).attr("name",h.name).addClass("w2ui-layout").html("
"),a(h.box).length>0&&(a(h.box)[0].style.cssText+=h.style);for(var k=0;k
');a(h.box).find(" > div").append(l)}return a(h.box).find(" > div").append('
'),h.refresh(),h.trigger(a.extend(j,{phase:"after"})),setTimeout(function(){d(),h.resize()},0),(new Date).getTime()-i}},refresh:function(b){var c=this;null==b&&(b=null);var d=(new Date).getTime(),e=c.trigger({phase:"before",type:"refresh",target:null!=b?b:c.name,object:c.get(b)});if(e.isCancelled!==!0){if("string"==typeof b){var f=c.get(b);if(null==f)return;var g="#layout_"+c.name+"_panel_"+f.type,h="#layout_"+c.name+"_resizer_"+f.type;a(g).css({display:f.hidden?"none":"block"}),f.resizable?a(h).show():a(h).hide(),"object"==typeof f.content&&"function"==typeof f.content.render?(f.content.box=a(g+"> .w2ui-panel-content")[0],setTimeout(function(){a(g+"> .w2ui-panel-content").length>0&&(a(g+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").css("overflow",f.overflow)[0].style.cssText+=";"+f.style),f.content&&"function"==typeof f.content.render&&f.content.render()},1)):a(g+"> .w2ui-panel-content").length>0&&(a(g+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").html(f.content).css("overflow",f.overflow)[0].style.cssText+=";"+f.style);var i=a(c.box).find(g+"> .w2ui-panel-tabs");f.show.tabs?0===i.find("[name="+f.tabs.name+"]").length&&null!=f.tabs?i.w2render(f.tabs):f.tabs.refresh():i.html("").removeClass("w2ui-tabs").hide(),i=a(c.box).find(g+"> .w2ui-panel-toolbar"),f.show.toolbar?0===i.find("[name="+f.toolbar.name+"]").length&&null!=f.toolbar?i.w2render(f.toolbar):f.toolbar.refresh():i.html("").removeClass("w2ui-toolbar").hide(),i=a(c.box).find(g+"> .w2ui-panel-title"),f.title?i.html(f.title).show():i.html("").hide()}else{if(0===a("#layout_"+c.name+"_panel_main").length)return void c.render();c.resize();for(var j=0;j div").css({width:f+"px",height:g+"px"});for(var h,i,j,k,l,m=this,n=this.get("main"),o=this.get("preview"),p=this.get("left"),q=this.get("right"),r=this.get("top"),s=this.get("bottom"),t=null!=o&&o.hidden!==!0,u=null!=p&&p.hidden!==!0,v=null!=q&&q.hidden!==!0,w=null!=r&&r.hidden!==!0,x=null!=s&&s.hidden!==!0,y=0;ythis.padding?this.resizer:this.padding,a("#layout_"+this.name+"_resizer_top").show().css({display:"block",left:h+"px",top:i+"px",width:j+"px",height:k+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(b){var c=m.trigger({phase:"before",type:"resizerClick",target:"top",originalEvent:b});if(c.isCancelled!==!0)return w2ui[m.name].tmp.events.resizeStart("top",b),m.trigger(a.extend(c,{phase:"after"})),!1}))):(a("#layout_"+this.name+"_panel_top").hide(),a("#layout_"+this.name+"_resizer_top").hide()),null!=p&&p.hidden!==!0?(h=0,i=0+(w?r.sizeCalculated+this.padding:0),j=p.sizeCalculated,k=g-(w?r.sizeCalculated+this.padding:0)-(x?s.sizeCalculated+this.padding:0),l=a("#layout_"+this.name+"_panel_left"),window.navigator.userAgent.indexOf("MSIE")!=-1&&l.length>0&&l[0].clientHeightthis.padding?this.resizer:this.padding,a("#layout_"+this.name+"_resizer_left").show().css({display:"block",left:h+"px",top:i+"px",width:j+"px",height:k+"px",cursor:"ew-resize"}).off("mousedown").on("mousedown",function(b){var c=m.trigger({phase:"before",type:"resizerClick",target:"left",originalEvent:b});if(c.isCancelled!==!0)return w2ui[m.name].tmp.events.resizeStart("left",b),m.trigger(a.extend(c,{phase:"after"})),!1}))):(a("#layout_"+this.name+"_panel_left").hide(),a("#layout_"+this.name+"_resizer_left").hide()),null!=q&&q.hidden!==!0?(h=f-q.sizeCalculated,i=0+(w?r.sizeCalculated+this.padding:0),j=q.sizeCalculated,k=g-(w?r.sizeCalculated+this.padding:0)-(x?s.sizeCalculated+this.padding:0),a("#layout_"+this.name+"_panel_right").css({display:"block",left:h+"px",top:i+"px",width:j+"px",height:k+"px"}).show(),q.width=j,q.height=k,q.resizable&&(h-=this.padding,j=this.resizer>this.padding?this.resizer:this.padding,a("#layout_"+this.name+"_resizer_right").show().css({display:"block",left:h+"px",top:i+"px",width:j+"px",height:k+"px",cursor:"ew-resize"}).off("mousedown").on("mousedown",function(b){var c=m.trigger({phase:"before",type:"resizerClick",target:"right",originalEvent:b});if(c.isCancelled!==!0)return w2ui[m.name].tmp.events.resizeStart("right",b),m.trigger(a.extend(c,{phase:"after"})),!1}))):(a("#layout_"+this.name+"_panel_right").hide(),a("#layout_"+this.name+"_resizer_right").hide()),null!=s&&s.hidden!==!0?(h=0,i=g-s.sizeCalculated,j=f,k=s.sizeCalculated,a("#layout_"+this.name+"_panel_bottom").css({display:"block",left:h+"px",top:i+"px",width:j+"px",height:k+"px"}).show(),s.width=j,s.height=k,s.resizable&&(i-=0===this.padding?0:this.padding,k=this.resizer>this.padding?this.resizer:this.padding,a("#layout_"+this.name+"_resizer_bottom").show().css({display:"block",left:h+"px",top:i+"px",width:j+"px",height:k+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(b){var c=m.trigger({phase:"before",type:"resizerClick",target:"bottom",originalEvent:b});if(c.isCancelled!==!0)return w2ui[m.name].tmp.events.resizeStart("bottom",b),m.trigger(a.extend(c,{phase:"after"})),!1}))):(a("#layout_"+this.name+"_panel_bottom").hide(),a("#layout_"+this.name+"_resizer_bottom").hide()),h=0+(u?p.sizeCalculated+this.padding:0),i=0+(w?r.sizeCalculated+this.padding:0),j=f-(u?p.sizeCalculated+this.padding:0)-(v?q.sizeCalculated+this.padding:0),k=g-(w?r.sizeCalculated+this.padding:0)-(x?s.sizeCalculated+this.padding:0)-(t?o.sizeCalculated+this.padding:0),l=a("#layout_"+this.name+"_panel_main"),window.navigator.userAgent.indexOf("MSIE")!=-1&&l.length>0&&l[0].clientHeight0&&l[0].clientHeightthis.padding?this.resizer:this.padding,a("#layout_"+this.name+"_resizer_preview").show().css({display:"block",left:h+"px",top:i+"px",width:j+"px",height:k+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(b){var c=m.trigger({phase:"before",type:"resizerClick",target:"preview",originalEvent:b});if(c.isCancelled!==!0)return w2ui[m.name].tmp.events.resizeStart("preview",b),m.trigger(a.extend(c,{phase:"after"})),!1}))):(a("#layout_"+this.name+"_panel_preview").hide(),a("#layout_"+this.name+"_resizer_preview").hide());for(var B=0;B .w2ui-panel-",E=0;C&&(C.title&&(E+=w2utils.getSize(a(D+"title").css({top:E+"px",display:"block"}),"height")),C.show.tabs&&(null!=C.tabs&&w2ui[this.name+"_"+c[B]+"_tabs"]&&w2ui[this.name+"_"+c[B]+"_tabs"].resize(),E+=w2utils.getSize(a(D+"tabs").css({top:E+"px",display:"block"}),"height")),C.show.toolbar&&(null!=C.toolbar&&w2ui[this.name+"_"+c[B]+"_toolbar"]&&w2ui[this.name+"_"+c[B]+"_toolbar"].resize(),E+=w2utils.getSize(a(D+"toolbar").css({top:E+"px",display:"block"}),"height"))),a(D+"content").css({display:"block"}).css({top:E+"px"})}return clearTimeout(this._resize_timer),this._resize_timer=setTimeout(function(){for(var b in w2ui)if("function"==typeof w2ui[b].resize){null==w2ui[b].panels&&w2ui[b].resize();var c=a(w2ui[b].box).parents(".w2ui-layout");c.length>0&&c.attr("name")==m.name&&w2ui[b].resize()}},100),this.trigger(a.extend(e,{phase:"after"})),(new Date).getTime()-b}},destroy:function(){var b=this.trigger({phase:"before",type:"destroy",target:this.name});if(b.isCancelled!==!0)return null!=w2ui[this.name]&&(a(this.box).find("#layout_"+this.name+"_panel_main").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-layout").html(""),delete w2ui[this.name],this.trigger(a.extend(b,{phase:"after"})),this.tmp.events&&this.tmp.events.resize&&a(window).off("resize",this.tmp.events.resize),!0)},lock:function(a,b,d){if(c.indexOf(a)==-1)return void console.log("ERROR: First parameter needs to be the a valid panel name.");var e=Array.prototype.slice.call(arguments,0);e[0]="#layout_"+this.name+"_panel_"+a,w2utils.lock.apply(window,e)},unlock:function(a,b){if(c.indexOf(a)==-1)return void console.log("ERROR: First parameter needs to be the a valid panel name.");var d="#layout_"+this.name+"_panel_"+a;w2utils.unlock(d,b)}},a.extend(b.prototype,w2utils.event),w2obj.layout=b}(jQuery);var w2popup={};!function(a){a.fn.w2popup=function(b,c){null==b&&(c={},b="open"),a.isPlainObject(b)&&(c=b,b="open"),b=b.toLowerCase(),"load"===b&&"string"==typeof c&&(c=a.extend({url:c},arguments.length>2?arguments[2]:{})),"open"===b&&null!=c.url&&(b="load"),c=c||{};var d={};if(a(this).length>0&&"open"==b){if(a(this).find("div[rel=title], div[rel=body], div[rel=buttons]").length>0){if(a("#w2ui-popup").length>0){var e=a("#w2ui-popup").data("options");w2popup._prev={template:w2popup._template,title:e.title,body:e.body,buttons:e.buttons}}w2popup._template=this,a(this).find("div[rel=title]").length>0&&(d.title=a(this).find("div[rel=title]")),a(this).find("div[rel=body]").length>0&&(d.body=a(this).find("div[rel=body]"),d.style=a(this).find("div[rel=body]")[0].style.cssText),a(this).find("div[rel=buttons]").length>0&&(d.buttons=a(this).find("div[rel=buttons]"))}else d.title=" ",d.body=a(this).html();0!==parseInt(a(this).css("width"))&&(d.width=parseInt(a(this).css("width"))),0!==parseInt(a(this).css("height"))&&(d.height=parseInt(a(this).css("height")))}return w2popup[b](a.extend({},d,c))},w2popup={defaults:{title:"",body:"",buttons:"",style:"",color:"#000",opacity:.4,speed:.3,modal:!1,maximized:!1,keyboard:!0,width:500,height:300,showClose:!0,showMax:!1,transition:null},status:"closed",handlers:[],onOpen:null,onClose:null,onMax:null,onMin:null,onToggle:null,onKeydown:null,open:function(b){function c(b){return b||(b=window.event),w2popup.status="moving",p.resizing=!0,p.isLocked=1==a("#w2ui-popup > .w2ui-lock").length,p.x=b.screenX,p.y=b.screenY,p.pos_x=a("#w2ui-popup").position().left,p.pos_y=a("#w2ui-popup").position().top,p.isLocked||w2popup.lock({opacity:0}),a(document).on("mousemove",p.mvMove),a(document).on("mouseup",p.mvStop),b.stopPropagation?b.stopPropagation():b.cancelBubble=!0,!!b.preventDefault&&void b.preventDefault()}function d(b){1==p.resizing&&(b||(b=window.event),p.div_x=b.screenX-p.x,p.div_y=b.screenY-p.y,a("#w2ui-popup").css(w2utils.cssPrefix({transition:"none",transform:"translate3d("+p.div_x+"px, "+p.div_y+"px, 0px)"})))}function e(b){1==p.resizing&&(b||(b=window.event),w2popup.status="open",p.div_x=b.screenX-p.x,p.div_y=b.screenY-p.y,a("#w2ui-popup").css({left:p.pos_x+p.div_x+"px",top:p.pos_y+p.div_y+"px"}).css(w2utils.cssPrefix({transition:"none",transform:"translate3d(0px, 0px, 0px)"})),p.resizing=!1,a(document).off("mousemove",p.mvMove),a(document).off("mouseup",p.mvStop),p.isLocked||w2popup.unlock())}var f=this;if("closing"==w2popup.status)return void setTimeout(function(){f.open.call(f,b)},100);var g=a("#w2ui-popup").data("options"),b=a.extend({},this.defaults,g,{title:"",body:"",buttons:""},b,{maximized:!1});setTimeout(function(){a("#w2ui-popup").data("options",b)},100),0===a("#w2ui-popup").length&&(w2popup.onMax=null,w2popup.onMin=null,w2popup.onToggle=null,w2popup.onOpen=null,w2popup.onClose=null,w2popup.onKeydown=null),b.onOpen&&(w2popup.onOpen=b.onOpen),b.onClose&&(w2popup.onClose=b.onClose),b.onMax&&(w2popup.onMax=b.onMax),b.onMin&&(w2popup.onMin=b.onMin),b.onToggle&&(w2popup.onToggle=b.onToggle),b.onKeydown&&(w2popup.onKeydown=b.onKeydown),b.width=parseInt(b.width),b.height=parseInt(b.height);var h,i;void 0==window.innerHeight?(h=parseInt(document.documentElement.offsetWidth),i=parseInt(document.documentElement.offsetHeight),"IE7"===w2utils.engine&&(h+=21,i+=4)):(h=parseInt(window.innerWidth),i=parseInt(window.innerHeight)),h-10';a("body").append(n);var o=a("#w2ui-popup");if(o.find("div[rel=title], div[rel=body], div[rel=buttons]").length>0){var p=o.find("div[rel=title]");p.length>0&&(b.title=p.html(),p.remove());var p=o.find("div[rel=buttons]");p.length>0&&(b.buttons=p.html(),p.remove());var p=o.find("div[rel=body]");p.length>0?b.body=p.html():b.body=o.html()}var n='
'+m+'
';a("#w2ui-popup").html(n),b.title&&a("#w2ui-popup .w2ui-popup-title").append(b.title),b.buttons&&a("#w2ui-popup .w2ui-popup-buttons").append(b.buttons),b.body&&a("#w2ui-popup .w2ui-popup-body").append(b.body),setTimeout(function(){a("#w2ui-popup").css("opacity","1").css(w2utils.cssPrefix({transition:b.speed+"s opacity, "+b.speed+"s -webkit-transform",transform:"scale(1)"})),f.focus()},1),setTimeout(function(){a("#w2ui-popup").css(w2utils.cssPrefix("transform","")),w2popup.status="open",setTimeout(function(){f.trigger(a.extend(l,{phase:"after"}))},100)},1e3*b.speed)}else{null==w2popup._prev&&null!=w2popup._template&&f.restoreTemplate();var l=this.trigger({phase:"before",type:"open",target:"popup",options:b,present:!0});if(l.isCancelled===!0)return;w2popup.status="opening",null!=g&&(g.maximized||g.width==b.width&&g.height==b.height||w2popup.resize(b.width,b.height),b.prevSize=b.width+"px:"+b.height+"px",b.maximized=g.maximized);var q=a("#w2ui-popup .w2ui-box").clone();if(q.removeClass("w2ui-box").addClass("w2ui-box-temp").find(".w2ui-popup-body").empty().append(b.body),"string"==typeof b.body&&q.find("div[rel=title], div[rel=body], div[rel=buttons]").length>0){var p=q.find("div[rel=title]");p.length>0&&(b.title=p.html(),p.remove());var p=q.find("div[rel=buttons]");p.length>0&&(b.buttons=p.html(),p.remove());var p=q.find("div[rel=body]");p.length>0?b.body=p.html():b.body=q.html(),q.html(b.body)}a("#w2ui-popup .w2ui-box").after(q),b.buttons?(a("#w2ui-popup .w2ui-popup-buttons").show().html("").append(b.buttons),a("#w2ui-popup .w2ui-popup-body").removeClass("w2ui-popup-no-buttons"),a("#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp").css("bottom","")):(a("#w2ui-popup .w2ui-popup-buttons").hide().html(""),a("#w2ui-popup .w2ui-popup-body").addClass("w2ui-popup-no-buttons"),a("#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp").css("bottom","0px")),b.title?(a("#w2ui-popup .w2ui-popup-title").show().html((b.showClose?'
Close
':"")+(b.showMax?'
Max
':"")).append(b.title),a("#w2ui-popup .w2ui-popup-body").removeClass("w2ui-popup-no-title"),a("#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp").css("top","")):(a("#w2ui-popup .w2ui-popup-title").hide().html(""),a("#w2ui-popup .w2ui-popup-body").addClass("w2ui-popup-no-title"),a("#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp").css("top","0px"));var r=a("#w2ui-popup .w2ui-box")[0],s=a("#w2ui-popup .w2ui-box-temp")[0];w2utils.transition(r,s,b.transition,function(){f.restoreTemplate(),a(r).remove(),a(s).removeClass("w2ui-box-temp").addClass("w2ui-box");var c=a(s).find(".w2ui-popup-body");1==c.length&&(c[0].style.cssText=b.style),a("#w2ui-popup").data("prev-size",null),f.focus(),w2popup.status="open",f.trigger(a.extend(l,{phase:"after"}))})}b._last_focus=a(":focus"),b.keyboard&&a(document).on("keydown",this.keydown);var p={resizing:!1,mvMove:d,mvStop:e};return a("#w2ui-popup .w2ui-popup-title").on("mousedown",function(a){w2popup.get().maximized||c(a)}),this},keydown:function(b){var c=a("#w2ui-popup").data("options");if(!c||c.keyboard){var d=w2popup.trigger({phase:"before",type:"keydown",target:"popup",options:c,originalEvent:b});if(d.isCancelled!==!0){switch(b.keyCode){case 27:b.preventDefault(),a("#w2ui-popup .w2ui-message").length>0?w2popup.message():w2popup.close()}w2popup.trigger(a.extend(d,{phase:"after"}))}}},close:function(b){var c=this,b=a.extend({},a("#w2ui-popup").data("options"),b);if(0!==a("#w2ui-popup").length&&"closed"!=this.status){if("opening"==this.status)return void setTimeout(function(){w2popup.close()},100);var d=this.trigger({phase:"before",type:"close",target:"popup",options:b});d.isCancelled!==!0&&(w2popup.status="closing",a("#w2ui-popup").css("opacity","0").css(w2utils.cssPrefix({transition:b.speed+"s opacity, "+b.speed+"s -webkit-transform",transform:"scale(0.9)"})),w2popup.unlockScreen(b),setTimeout(function(){c.restoreTemplate(),a("#w2ui-popup").remove(),w2popup.status="closed",b._last_focus.length>0&&b._last_focus.focus(),c.trigger(a.extend(d,{phase:"after"}))},1e3*b.speed),b.keyboard&&a(document).off("keydown",this.keydown))}},toggle:function(){var b=this,c=a("#w2ui-popup").data("options"),d=this.trigger({phase:"before",type:"toggle",target:"popup",options:c});d.isCancelled!==!0&&(c.maximized===!0?w2popup.min():w2popup.max(),setTimeout(function(){b.trigger(a.extend(d,{phase:"after"}))},1e3*c.speed+50))},max:function(){var b=this,c=a("#w2ui-popup").data("options");if(c.maximized!==!0){var d=this.trigger({phase:"before",type:"max",target:"popup",options:c});d.isCancelled!==!0&&(w2popup.status="resizing",c.prevSize=a("#w2ui-popup").css("width")+":"+a("#w2ui-popup").css("height"),w2popup.resize(1e4,1e4,function(){w2popup.status="open",c.maximized=!0,b.trigger(a.extend(d,{phase:"after"})),a("#w2ui-popup .w2ui-grid, #w2ui-popup .w2ui-form, #w2ui-popup .w2ui-layout").each(function(){var b=a(this).attr("name");w2ui[b]&&w2ui[b].resize&&w2ui[b].resize()})}))}},min:function(){var b=this,c=a("#w2ui-popup").data("options");if(c.maximized===!0){var d=c.prevSize.split(":"),e=this.trigger({phase:"before",type:"min",target:"popup",options:c});e.isCancelled!==!0&&(w2popup.status="resizing",w2popup.resize(parseInt(d[0]),parseInt(d[1]),function(){w2popup.status="open",c.maximized=!1,c.prevSize=null,b.trigger(a.extend(e,{phase:"after"})),a("#w2ui-popup .w2ui-grid, #w2ui-popup .w2ui-form, #w2ui-popup .w2ui-layout").each(function(){var b=a(this).attr("name");w2ui[b]&&w2ui[b].resize&&w2ui[b].resize()})}))}},get:function(){return a("#w2ui-popup").data("options")},set:function(a){w2popup.open(a)},clear:function(){a("#w2ui-popup .w2ui-popup-title").html(""),a("#w2ui-popup .w2ui-popup-body").html(""),a("#w2ui-popup .w2ui-popup-buttons").html("")},reset:function(){w2popup.open(w2popup.defaults)},load:function(b){function c(c,d){if(delete b.url,a("body").append('"),null!=d&&a("#w2ui-tmp #"+d).length>0?a("#w2ui-tmp #"+d).w2popup(b):a("#w2ui-tmp > div").w2popup(b),a("#w2ui-tmp > style").length>0){var e=a("
").append(a("#w2ui-tmp > style").clone()).html();0===a("#w2ui-popup #div-style").length&&a("#w2ui-popup").append('
'), a("#w2ui-popup #div-style").html(e)}a("#w2ui-tmp").remove()}if(w2popup.status="loading",null==b.url)return void console.log("ERROR: The url parameter is empty.");var d=String(b.url).split("#"),e=d[0],f=d[1];null==b&&(b={});var g=a("#w2ui-popup").data(e);null!=g?c(g,f):a.get(e,function(b,d,g){c(g.responseText,f),a("#w2ui-popup").data(e,g.responseText)})},message:function(b){var c=this;a().w2tag(),b||(b={width:200,height:100});var d=parseInt(a("#w2ui-popup").width()),e=parseInt(a("#w2ui-popup").height());b.originalWidth=b.width,b.originalHeight=b.height,parseInt(b.width)<10&&(b.width=10),parseInt(b.height)<10&&(b.height=10),null==b.hideOnClick&&(b.hideOnClick=!1);var f=a("#w2ui-popup").data("options")||{},g=parseInt(a("#w2ui-popup > .w2ui-popup-title").css("height"));(null==b.width||b.width>f.width-10)&&(b.width=f.width-10),(null==b.height||b.height>f.height-g-5)&&(b.height=f.height-g-5),b.originalHeight<0&&(b.height=e+b.originalHeight-g),b.originalWidth<0&&(b.width=d+2*b.originalWidth);var h=a("#w2ui-popup .w2ui-popup-title"),i=a("#w2ui-popup .w2ui-message").length;if(""===a.trim(b.html)&&""===a.trim(b.body)&&""===a.trim(b.buttons)){var j=a("#w2ui-popup #w2ui-message"+(i-1)),b=j.data("options")||{};j.css(w2utils.cssPrefix({transition:"0.15s",transform:"translateY(-"+b.height+"px)"})),1==i?w2popup.unlock(150):a("#w2ui-popup #w2ui-message"+(i-2)).css("z-index",1500),setTimeout(function(){var a=j.data("prev_focus");j.remove(),a&&a.length>0?a.focus():c.focus(),"function"==typeof b.onClose&&b.onClose()},150)}else{""===a.trim(b.body)&&""===a.trim(b.buttons)||(b.html='
'+b.body+'
'+b.buttons+"
"),a("#w2ui-popup .w2ui-message").css("z-index",1390),h.css("z-index",1501),a("#w2ui-popup .w2ui-box").before('"),a("#w2ui-popup #w2ui-message"+i).data("options",b).data("prev_focus",a(":focus"));var k=a("#w2ui-popup #w2ui-message"+i).css("display");a("#w2ui-popup #w2ui-message"+i).css(w2utils.cssPrefix({transform:"none"==k?"translateY(-"+b.height+"px)":"translateY(0px)"})),"none"==k&&(a("#w2ui-popup #w2ui-message"+i).show().html(b.html),setTimeout(function(){a("#w2ui-popup #w2ui-message"+i).css(w2utils.cssPrefix({transform:"none"==k?"translateY(0px)":"translateY(-"+b.height+"px)"}))},1),0===i&&w2popup.lock(),setTimeout(function(){c.focus(),a("#w2ui-popup #w2ui-message"+i).css(w2utils.cssPrefix({transition:"0s"})),"function"==typeof b.onOpen&&b.onOpen()},350))}},focus:function(){var b=null,c=a("#w2ui-popup"),d="input:visible, button:visible, select:visible, textarea:visible";a(c).find(d).off(".keep-focus");var e=a("#w2ui-popup .w2ui-message").length-1,f=a("#w2ui-popup #w2ui-message"+e);if(f.length>0){var g=a(f[f.length-1]).find("button");g.length>0&&g[0].focus(),b=f}else if(c.length>0){var g=c.find(".w2ui-popup-buttons button");g.length>0&&g[0].focus(),b=c}a(b).find(d).on("blur.keep-focus",function(c){setTimeout(function(){var c=a(":focus");if(c.length>0&&!a(b).find(d).is(c)||c.hasClass("w2ui-popup-hidden")){var e=a(b).find(d);e.length>0&&e[0].focus()}},1)})},lock:function(b,c){var d=Array.prototype.slice.call(arguments,0);d.unshift(a("#w2ui-popup")),w2utils.lock.apply(window,d)},unlock:function(b){w2utils.unlock(a("#w2ui-popup"),b)},lockScreen:function(b){return!(a("#w2ui-lock").length>0)&&(null==b&&(b=a("#w2ui-popup").data("options")),null==b&&(b={}),b=a.extend({},w2popup.defaults,b),a("body").append('
'),setTimeout(function(){a("#w2ui-lock").css("opacity",b.opacity).css(w2utils.cssPrefix("transition",b.speed+"s opacity"))},1),1==b.modal?(a("#w2ui-lock").on("mousedown",function(){a("#w2ui-lock").css("opacity","0.6").css(w2utils.cssPrefix("transition",".1s"))}),a("#w2ui-lock").on("mouseup",function(){setTimeout(function(){a("#w2ui-lock").css("opacity",b.opacity).css(w2utils.cssPrefix("transition",".1s"))},100)})):a("#w2ui-lock").on("mousedown",function(){w2popup.close()}),!0)},unlockScreen:function(b){return 0!==a("#w2ui-lock").length&&(null==b&&(b=a("#w2ui-popup").data("options")),null==b&&(b={}),b=a.extend({},w2popup.defaults,b),a("#w2ui-lock").css("opacity","0").css(w2utils.cssPrefix("transition",b.speed+"s opacity")),setTimeout(function(){a("#w2ui-lock").remove()},1e3*b.speed),!0)},resizeMessages:function(){a("#w2ui-popup").data("options");a("#w2ui-popup .w2ui-message").each(function(){var b=a(this).data("options"),c=a("#w2ui-popup");parseInt(b.width)<10&&(b.width=10),parseInt(b.height)<10&&(b.height=10);var d=parseInt(c.find("> .w2ui-popup-title").css("height")),e=parseInt(c.width()),f=parseInt(c.height());b.width=b.originalWidth,b.width>e-10&&(b.width=e-10),b.height=b.originalHeight,b.height>f-d-5&&(b.height=f-d-5),b.originalHeight<0&&(b.height=f+b.originalHeight-d),b.originalWidth<0&&(b.width=e+2*b.originalWidth),a(this).css({left:(e-b.width)/2+"px",width:b.width+"px",height:b.height+"px"})})},resize:function(b,c,d){var e=this,f=a("#w2ui-popup").data("options");b=parseInt(b),c=parseInt(c);var g,h;void 0==window.innerHeight?(g=parseInt(document.documentElement.offsetWidth),h=parseInt(document.documentElement.offsetHeight),"IE7"===w2utils.engine&&(g+=21,h+=4)):(g=parseInt(window.innerWidth),h=parseInt(window.innerHeight)),g-100&&"closing"!=w2popup.status?w2popup.message({width:400,height:170,body:'
'+a+"
",buttons:'",onOpen:function(){d("#w2ui-popup .w2ui-message .w2ui-popup-btn").focus()},onClose:function(){"function"==typeof c&&c()}}):w2popup.open({width:450,height:220,showMax:!1,showClose:!1,title:b,body:'
'+a+"
",buttons:'",onOpen:function(a){setTimeout(function(){d("#w2ui-popup .w2ui-popup-btn").focus()},1)},onKeydown:function(a){d("#w2ui-popup .w2ui-popup-btn").focus().addClass("clicked")},onClose:function(){"function"==typeof c&&c()}}),{ok:function(a){return c=a,this},done:function(a){return c=a,this}}},w2confirm=function(a,b,c){var d=jQuery,e={},f={msg:"",title:w2utils.lang("Confirmation"),width:d("#w2ui-popup").length>0?400:450,height:d("#w2ui-popup").length>0?170:220,yes_text:"Yes",yes_class:"",yes_style:"",yes_callBack:null,no_text:"No",no_class:"",no_style:"",no_callBack:null,callBack:null};return 1==arguments.length&&"object"==typeof a?d.extend(e,f,a):"function"==typeof b?d.extend(e,f,{msg:a,callBack:b}):d.extend(e,f,{msg:a,title:b,callBack:c}),"object"==typeof e.btn_yes&&(e.yes_text=e.btn_yes.text||e.yes_text,e.yes_class=e.btn_yes.class||e.yes_class,e.yes_style=e.btn_yes.style||e.yes_style,e.yes_callBack=e.btn_yes.callBack||e.yes_callBack),"object"==typeof e.btn_no&&(e.no_text=e.btn_no.text||e.no_text,e.no_class=e.btn_no.class||e.no_class,e.no_style=e.btn_no.style||e.no_style,e.no_callBack=e.btn_no.callBack||e.no_callBack),d("#w2ui-popup").length>0&&"closing"!=w2popup.status&&w2popup.get()?(e.width>w2popup.get().width&&(e.width=w2popup.get().width),e.height>w2popup.get().height-50&&(e.height=w2popup.get().height-50),w2popup.message({width:e.width,height:e.height,body:'
'+e.msg+"
",buttons:'",onOpen:function(){d("#w2ui-popup .w2ui-message .w2ui-btn").on("click.w2confirm",function(a){w2popup._confirm_btn=a.target.id,w2popup.message()})},onClose:function(){d("#w2ui-popup .w2ui-message .w2ui-btn").off("click.w2confirm"),setTimeout(function(){"function"==typeof e.callBack&&e.callBack(w2popup._confirm_btn),"Yes"==w2popup._confirm_btn&&"function"==typeof e.yes_callBack&&e.yes_callBack(),"No"==w2popup._confirm_btn&&"function"==typeof e.no_callBack&&e.no_callBack()},300)}})):(w2utils.isInt(e.height)||(e.height=e.height+50),w2popup.open({width:e.width,height:e.height,title:e.title,modal:!0,showClose:!1,body:'
'+e.msg+"
",buttons:'",onOpen:function(a){setTimeout(function(){d("#w2ui-popup .w2ui-popup-btn").on("click",function(a){w2popup.close(),"function"==typeof e.callBack&&e.callBack(a.target.id),"Yes"==a.target.id&&"function"==typeof e.yes_callBack&&e.yes_callBack(),"No"==a.target.id&&"function"==typeof e.no_callBack&&e.no_callBack()}),d("#w2ui-popup .w2ui-popup-btn#Yes").focus()},1)},onKeydown:function(a){if(0===d("#w2ui-popup .w2ui-message").length)switch(a.originalEvent.keyCode){case 13:d("#w2ui-popup .w2ui-popup-btn#Yes").focus().addClass("clicked"),w2popup.close();break;case 27:d("#w2ui-popup .w2ui-popup-btn#No").focus().click(),w2popup.close()}}})),{yes:function(a){return e.yes_callBack=a,this},no:function(a){return e.no_callBack=a,this}}},w2prompt=function(a,b,c){var d=jQuery,e={},f={label:"",value:"",attrs:"",title:w2utils.lang("Notification"),ok_text:w2utils.lang("Ok"),cancel_text:w2utils.lang("Cancel"),width:d("#w2ui-popup").length>0?400:450,height:d("#w2ui-popup").length>0?170:220,callBack:null};return 1==arguments.length&&"object"==typeof a?d.extend(e,f,a):"function"==typeof b?d.extend(e,f,{label:a,callBack:b}):d.extend(e,f,{label:a,title:b,callBack:c}),d("#w2ui-popup").length>0&&"closing"!=w2popup.status&&w2popup.get()?(e.width>w2popup.get().width&&(e.width=w2popup.get().width),e.height>w2popup.get().height-50&&(e.height=w2popup.get().height-50),w2popup.message({width:e.width,height:e.height,body:'
",buttons:'",onOpen:function(){d("#w2prompt").val(e.value),d("#w2ui-popup .w2ui-message .w2ui-btn#Ok").on("click.w2prompt",function(a){w2popup._prompt_value=d("#w2prompt").val(),w2popup.message()}),d("#w2ui-popup .w2ui-message .w2ui-btn#Cancel").on("click.w2prompt",function(a){w2popup._prompt_value=null,w2popup.message()}),setTimeout(function(){d("#w2prompt").focus()},100)},onClose:function(){d("#w2ui-popup .w2ui-message .w2ui-btn").off("click.w2prompt"),setTimeout(function(){"function"==typeof e.callBack&&null!=w2popup._prompt_value&&e.callBack(w2popup._prompt_value)},300)}})):(w2utils.isInt(e.height)||(e.height=e.height+50),w2popup.open({width:e.width,height:e.height,title:e.title,modal:!0,showClose:!1,body:'
',buttons:'",onOpen:function(a){setTimeout(function(){d("#w2prompt").val(e.value),d("#w2prompt").w2field("text"),d("#w2ui-popup .w2ui-popup-btn#Ok").on("click",function(a){w2popup._prompt_value=d("#w2prompt").val(),w2popup.close(),"function"==typeof e.callBack&&e.callBack(w2popup._prompt_value)}),d("#w2ui-popup .w2ui-popup-btn#Cancel").on("click",function(a){w2popup._prompt_value=null,w2popup.close()}),d("#w2ui-popup .w2ui-popup-btn#Ok"),setTimeout(function(){d("#w2prompt").focus()},100)},1)},onKeydown:function(a){if(0===d("#w2ui-popup .w2ui-message").length)switch(a.originalEvent.keyCode){case 13:d("#w2ui-popup .w2ui-popup-btn#Ok").focus().addClass("clicked"),w2popup.close();break;case 27:w2popup.close()}}})),{change:function(a){return d("#w2prompt").on("keyup",a).keyup(),this},ok:function(a){return e.callBack=a,this}}};!function(a){var b=function(b){this.box=null,this.name=null,this.active=null,this.flow="down",this.tooltip="top|left",this.tabs=[],this.routeData={},this.right="",this.style="",a.extend(this,{handlers:[]}),a.extend(!0,this,w2obj.tabs,b)};a.fn.w2tabs=function(c){if(a.isPlainObject(c)){if(!w2utils.checkName(c,"w2tabs"))return;for(var d=c.tabs||[],e=new b(c),f=0;f0?(g[c]&&g[c].apply(g,Array.prototype.slice.call(arguments,1)),this):g:null},b.prototype={onClick:null,onClose:null,onRender:null,onRefresh:null,onResize:null,onDestroy:null,tab:{id:null,text:null,route:null,hidden:!1,disabled:!1,closable:!1,tooltip:null,style:"",onClick:null,onRefresh:null,onClose:null},add:function(a){return this.insert(null,a)},insert:function(c,d){a.isArray(d)||(d=[d]);for(var e=0;e
");var j=i+'
"+w2utils.lang(g)+"
";if(0===h.length){var k="";f.hidden&&(k+="display: none;"),f.disabled&&(k+="opacity: 0.2;");var l=''+j+"";this.get(b,!0)!==this.tabs.length-1&&a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(b,!0))+1].id)).length>0?a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(b,!0))+1].id)).before(l):a(this.box).find("#tabs_"+this.name+"_right").before(l)}else h.html(j),f.hidden?h.css("display","none"):h.css("display",""),f.disabled?h.css({opacity:"0.2"}):h.css({opacity:"1"})}return a("#tabs_"+this.name+"_right").html(this.right),this.trigger(a.extend(d,{phase:"after"})),(new Date).getTime()-c}},render:function(b){var c=(new Date).getTime(),d=this.trigger({phase:"before",type:"render",target:this.name,box:b});if(d.isCancelled!==!0){if(null!=b&&(a(this.box).find("> table #tabs_"+this.name+"_right").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-tabs").html(""),this.box=b),!this.box)return!1;var e='
'+this.right+'
";return a(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-tabs").html(e),a(this.box).length>0&&(a(this.box)[0].style.cssText+=this.style),this.trigger(a.extend(d,{phase:"after"})),this.refresh(),this.resize(),(new Date).getTime()-c}},scroll:function(b){var c,d,e,f=a(this.box),g=this,h=f.find(".w2ui-scroll-wrapper"),i=h.scrollLeft();switch(b){case"left":c=h.outerWidth(),d=h.find(":first").outerWidth(),e=i-c+50,e<=0&&(e=0),h.animate({scrollLeft:e},300);break;case"right":c=h.outerWidth(),d=h.find(":first").outerWidth(),e=i+c-50,e>=d-c&&(e=d-c),h.animate({scrollLeft:e},300)}setTimeout(function(){g.resize()},350)},resize:function(){var b=(new Date).getTime(),c=this.trigger({phase:"before",type:"resize",target:this.name});if(c.isCancelled!==!0){var d=a(this.box);d.find(".w2ui-scroll-left, .w2ui-scroll-right").hide();var e=d.find(".w2ui-scroll-wrapper");return e.find(":first").outerWidth()>e.outerWidth()&&(e.scrollLeft()>0&&d.find(".w2ui-scroll-left").show(),e.scrollLeft() table #tabs_"+this.name+"_right").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-tabs").html(""),delete w2ui[this.name],this.trigger(a.extend(b,{phase:"after"})))},click:function(b,c){var d=this.get(b);if(null==d||d.disabled)return!1;var e=this.trigger({phase:"before",type:"click",target:b,tab:d,object:d,originalEvent:c});if(e.isCancelled!==!0){if(a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.active)+" .w2ui-tab").removeClass("active"),this.active=d.id,"string"==typeof d.route){var f=""!==d.route?String("/"+d.route).replace(/\/{2,}/g,"/"):"",g=w2utils.parseRoute(f);if(g.keys.length>0)for(var h=0;h'),setTimeout(function(){a(f.box).find("#tabs_"+f.name+"_tab_"+w2utils.escapeId(d.id)).find(":first-child").css({width:"0px"})},50)},200),setTimeout(function(){f.remove(b)},450),this.trigger(a.extend(e,{phase:"after"})),this.refresh()}},animateInsert:function(b,c){if(null!=this.get(b)&&a.isPlainObject(c)&&w2utils.checkUniqueId(c.id,this.tabs,"tabs",this.name)){var d=a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(c.id));if(0===d.length){null==c.text&&null!=c.caption&&(c.text=c.caption);var e='
'+(c.closable?'
':"")+'
'+c.text+"
";a("body").append(e);var f='
 
',g="";c.hidden&&(g+="display: none;"),c.disabled&&(g+="opacity: 0.2;");var h=''+f+"";this.get(b,!0)!==this.tabs.length&&a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(b,!0))].id)).length>0?a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(b,!0))].id)).before(h):a(this.box).find("#tabs_"+this.name+"_right").before(h);var i=this;setTimeout(function(){var b=a("#_tmp_simple_tab").width();a("#_tmp_tabs").remove(),a("#tabs_"+i.name+"_tab_"+w2utils.escapeId(c.id)+" > div").css("width",b+"px")},1),setTimeout(function(){i.insert(b,c)},200)}}}},a.extend(b.prototype,w2utils.event),w2obj.tabs=b}(jQuery),function(a){var b=function(b){this.box=null,this.name=null,this.routeData={},this.items=[],this.right="",this.tooltip="top|left",a.extend(!0,this,w2obj.toolbar,b)};a.fn.w2toolbar=function(c){if(a.isPlainObject(c)){if(!w2utils.checkName(c,"w2toolbar"))return;var d=c.items||[],e=new b(c);a.extend(e,{items:[],handlers:[]});for(var f=0;f0?(j[c]&&j[c].apply(j,Array.prototype.slice.call(arguments,1)),this):j:null},b.prototype={onClick:null,onRender:null,onRefresh:null,onResize:null,onDestroy:null,item:{id:null,type:"button",text:null,html:"",tooltip:null,count:null,hidden:!1,disabled:!1,checked:!1,img:null,icon:null,route:null,arrow:!0,style:null,color:null,transparent:null,group:null,items:null,selected:null,overlay:{},onClick:null,onRefresh:null},add:function(a){this.insert(null,a)},insert:function(c,d){a.isArray(d)||(d=[d]);for(var e=0;e1){var g=this.get(b);return void(g&&!g.disabled&&d.menuClick({name:d.name,item:f,subItem:g,originalEvent:c}))}if(f&&!f.disabled){var h=this.trigger({phase:"before",type:"click",target:null!=b?b:this.name,item:f,object:f,originalEvent:c});if(h.isCancelled===!0)return;var i="#tb_"+this.name+"_item_"+w2utils.escapeId(f.id)+" table.w2ui-button";if(a(i).removeClass("down"),"radio"==f.type){for(var j=0;j19&&(g=19),"drop"==f.type&&e.w2overlay(f.html,a.extend({name:d.name,left:g,top:3},f.overlay,{onHide:function(a){b()}})),["menu","menu-radio","menu-check"].indexOf(f.type)!=-1){var h="normal";"menu-radio"==f.type&&(h="radio",f.items.forEach(function(a){f.selected==a.id?a.checked=!0:a.checked=!1})),"menu-check"==f.type&&(h="check",f.items.forEach(function(b){a.isArray(f.selected)&&f.selected.indexOf(b.id)!=-1?b.checked=!0:b.checked=!1})),e.w2menu(a.extend({name:d.name,items:f.items,left:g,top:3},f.overlay,{type:h,select:function(a){d.menuClick({name:d.name,item:f,subItem:a.item,originalEvent:a.originalEvent,keepOpen:a.keepOpen})},onHide:function(a){b()}}))}["color","text-color"].indexOf(f.type)!=-1&&(null==f.transparent&&(f.transparent=!0), a(e).w2color({color:f.color,transparent:f.transparent},function(a,e){null!=a&&d.colorClick({name:d.name,item:f,color:a,originalEvent:c.originalEvent}),b()}))},1)),["check","menu","menu-radio","menu-check","drop","color","text-color"].indexOf(f.type)!=-1&&(f.checked=!f.checked,f.checked?a(i).addClass("checked"):a(i).removeClass("checked")),f.route){var l=String("/"+f.route).replace(/\/{2,}/g,"/"),m=w2utils.parseRoute(l);if(m.keys.length>0)for(var n=0;n=d-c&&(e=d-c),h.animate({scrollLeft:e},300)}setTimeout(function(){g.resize()},350)},render:function(b){var c=(new Date).getTime(),d=this.trigger({phase:"before",type:"render",target:this.name,box:b});if(d.isCancelled!==!0&&(null!=b&&(a(this.box).find("> table #tb_"+this.name+"_right").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-toolbar").html(""),this.box=b),this.box)){for(var e='
',f=0;f':'')}return e+='",e+='
'+this.right+"
",a(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-toolbar").html(e),a(this.box).length>0&&(a(this.box)[0].style.cssText+=this.style),this.refresh(),this.resize(),this.trigger(a.extend(d,{phase:"after"})),(new Date).getTime()-c}},refresh:function(b){var c=(new Date).getTime(),d=this.trigger({phase:"before",type:"refresh",target:null!=b?b:this.name,item:this.get(b)});if(d.isCancelled!==!0){if(null!=b){var e=this.get(b);if(null==e)return!1;if("function"==typeof e.onRefresh){var f=this.trigger({phase:"before",type:"refresh",target:b,item:e,object:e});if(f.isCancelled===!0)return}var g=a(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(e.id)),h=this.getItemHTML(e);return 0===g.length?(h="spacer"==e.type?'':''+h+"",this.get(b,!0)==this.items.length-1?a(this.box).find("#tb_"+this.name+"_right").before(h):a(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(this.items[parseInt(this.get(b,!0))+1].id)).before(h)):(["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(e.type)!=-1&&0==e.checked&&a("#w2ui-overlay-"+this.name).length>0&&a("#w2ui-overlay-"+this.name)[0].hide(),g.html(h),e.hidden?g.css("display","none"):g.css("display",""),e.disabled?g.addClass("disabled"):g.removeClass("disabled")),"function"==typeof e.onRefresh&&this.trigger(a.extend(f,{phase:"after"})),this.trigger(a.extend(d,{phase:"after"})),(new Date).getTime()-c}for(var i=0;ie.outerWidth()&&(e.scrollLeft()>0&&d.find(".w2ui-scroll-left").show(),e.scrollLeft() table #tb_"+this.name+"_right").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-toolbar").html(""),a(this.box).html(""),delete w2ui[this.name],this.trigger(a.extend(b,{phase:"after"})))},getItemHTML:function(a){var b="";null!=a.caption&&null==a.text&&(a.text=a.caption),null==a.text&&(a.text=""),null==a.tooltip&&null!=a.hint&&(a.tooltip=a.hint),null==a.tooltip&&(a.tooltip="");var c=" ",d=a.text;if("function"==typeof d&&(d=d.call(this,a)),a.img&&(c='
'),a.icon&&(c='
'),""===b)switch(a.type){case"color":case"text-color":"string"==typeof a.color&&"#"==a.color.substr(0,1)&&(a.color=a.color.substr(1)),"color"==a.type&&(d='
'+(a.text?'
'+w2utils.lang(a.text)+"
":"")),"text-color"==a.type&&(d='
'+(a.text?w2utils.lang(a.text):"Aa")+"
");case"menu":case"menu-check":case"menu-radio":case"button":case"check":case"radio":case"drop":b+='
'+c+(""!==d?'":"")+(null!=a.count?'":"")+(["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(a.type)!=-1&&a.arrow!==!1?'':"")+"
'+w2utils.lang(d)+"'+a.count+"
";break;case"break":b+='
 
';break;case"html":b+='
'+("function"==typeof a.html?a.html.call(this,a):a.html)+"
"}return"
"+b+"
"},tooltipShow:function(b,c,d){if(null!=this.tooltip){var e=a(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(b)),f=this.get(b),g=this.tooltip,h=f.tooltip;"function"==typeof h&&(h=h.call(this,f)),e.prop("_mouse_over",!0),setTimeout(function(){if(e.prop("_mouse_over")===!0&&e.prop("_mouse_tooltip")!==!0){if(e.prop("_mouse_tooltip",!0),["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(f.type)!=-1&&1==f.checked)return;e.w2tag(w2utils.lang(h),{position:g})}1==d&&e.w2tag(w2utils.lang(h),{position:g})},1)}},tooltipHide:function(b,c){if(null!=this.tooltip){var d=a(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(b));this.get(b);d.removeProp("_mouse_over"),setTimeout(function(){d.prop("_mouse_over")!==!0&&d.prop("_mouse_tooltip")===!0&&(d.removeProp("_mouse_tooltip"),d.w2tag())},1)}},menuClick:function(b){var c=this;if(b.item&&!b.item.disabled){var d=this.trigger({phase:"before",type:"click",target:b.item.id+":"+b.subItem.id,item:b.item,subItem:b.subItem,originalEvent:b.originalEvent});if(d.isCancelled===!0)return;var e=b.subItem,f=this.get(b.item.id);if("menu-radio"==f.type&&(f.selected=e.id,b.item.items.forEach(function(a){a.checked=!1}),e.checked=!0),"menu-check"==f.type){a.isArray(f.selected)||(f.selected=[]);var g=f.selected.indexOf(e.id);g==-1?(f.selected.push(e.id),e.checked=!0):(f.selected.splice(g,1),e.checked=!1)}if("string"==typeof e.route){var h=""!==e.route?String("/"+e.route).replace(/\/{2,}/g,"/"):"",i=w2utils.parseRoute(h);if(i.keys.length>0)for(var j=0;j0?(f[c]&&f[c].apply(f,Array.prototype.slice.call(arguments,1)),this):f:null},b.prototype={onClick:null,onDblClick:null,onContextMenu:null,onMenuClick:null,onExpand:null,onCollapse:null,onKeydown:null,onRender:null,onRefresh:null,onResize:null,onDestroy:null,onFocus:null,onBlur:null,onFlat:null,node:{id:null,text:"",count:null,img:null,icon:null,nodes:[],style:"",route:null,selected:!1,expanded:!1,hidden:!1,disabled:!1,group:!1,groupShowHide:!0,collapsible:!0,plus:!1,onClick:null,onDblClick:null,onContextMenu:null,onExpand:null,onCollapse:null,parent:null,sidebar:null},add:function(a,b){return 1==arguments.length&&(b=arguments[0],a=this),"string"==typeof a&&(a=this.get(a)),this.insert(a,null,b)},insert:function(c,d,e){var f,g,h,i,j;if(2==arguments.length)if(e=arguments[1],d=arguments[0],null!=d){if(g=this.get(d),null==g)return a.isArray(e)||(e=[e]),f=null!=e[0].caption?e[0].caption:e[0].text,console.log('ERROR: Cannot insert node "'+f+'" because cannot find node "'+d+'" to insert before.'),null;c=this.get(d).parent}else c=this;"string"==typeof c&&(c=this.get(c)),a.isArray(e)||(e=[e]);for(var k=0;k0&&this.insert(h,null,j)}else f=null!=i.caption?i.caption:i.text,console.log("ERROR: Cannot insert node with id="+i.id+" (text: "+f+") because another node with the same id already exists.");else f=null!=i.caption?i.caption:i.text,console.log('ERROR: Cannot insert node "'+f+'" because it has no id.');return this.refresh(c.id),h},remove:function(){for(var a,b=0,c=0;c0&&1==arguments.length?this.refresh(a.parent.id):this.refresh(),b},set:function(b,c,d){if(2==arguments.length&&(d=c,c=b,b=this),"string"==typeof b&&(b=this.get(b)),null==b.nodes)return null;for(var e=0;e0&&(c=this.find(a.nodes[d],b,c))}return c},hide:function(){for(var a=0,b=0;b+'),d.expanded=!1,this.trigger(a.extend(e,{phase:"after"})),setTimeout(function(){c.refresh(b)},200),!0},collapseAll:function(a){if(null==a&&(a=this),"string"==typeof a&&(a=this.get(a)),null==a.nodes)return!1;for(var b=0;b0&&this.collapseAll(a.nodes[b]);return this.refresh(a.id),!0},expand:function(b){var c=this,d=this.get(b),e=this.trigger({phase:"before",type:"expand",target:b,object:d});if(e.isCancelled!==!0)return a(this.box).find("#node_"+w2utils.escapeId(b)+"_sub").slideDown(200),a(this.box).find("#node_"+w2utils.escapeId(b)+" .w2ui-node-dots:first-child").html('
-
'),d.expanded=!0,this.trigger(a.extend(e,{phase:"after"})),setTimeout(function(){c.refresh(b)},200),!0},expandAll:function(a){if(null==a&&(a=this),"string"==typeof a&&(a=this.get(a)),null==a.nodes)return!1;for(var b=0;b0&&this.expandAll(a.nodes[b]);this.refresh(a.id)},expandParents:function(a){var b=this.get(a);return null!=b&&(b.parent&&(b.parent.expanded||(b.parent.expanded=!0,this.refresh(b.parent.id)),this.expandParents(b.parent.id)),!0)},click:function(b,c){var d=this,e=this.get(b);if(null!=e&&!e.disabled&&!e.group){a(d.box).find(".w2ui-node.w2ui-selected").each(function(b,c){var e=a(c).attr("id").replace("node_",""),f=d.get(e);null!=f&&(f.selected=!1),a(c).removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected")});var f=a(d.box).find("#node_"+w2utils.escapeId(b)),g=a(d.box).find("#node_"+w2utils.escapeId(d.selected));f.addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected"),setTimeout(function(){var h=d.trigger({phase:"before",type:"click",target:b,originalEvent:c,node:e,object:e});if(h.isCancelled===!0)return f.removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected"),void g.addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected");if(null!=g&&(g.selected=!1),d.get(b).selected=!0,d.selected=b,"string"==typeof e.route){var i=""!==e.route?String("/"+e.route).replace(/\/{2,}/g,"/"):"",j=w2utils.parseRoute(i);if(j.keys.length>0)for(var k=0;k0&&b!==!0){var g=a.nodes[0];f=g.hidden||g.disabled||g.group?e(g):g}else f=c&&d+10?g(b.nodes[c-1]):b;return null!=d&&(d.hidden||d.disabled||d.group)&&(d=f(d)),d}function g(a){if(a.expanded&&a.nodes.length>0){var b=a.nodes[a.nodes.length-1];return b.hidden||b.disabled||b.group?f(b):g(b)}return a}var h=this,i=h.get(h.selected);if(h.keyboard===!0){i||(i=h.nodes[0]);var j=h.trigger({phase:"before",type:"keydown",target:h.name,originalEvent:b});j.isCancelled!==!0&&(13!=b.keyCode&&32!=b.keyCode||i.nodes.length>0&&h.toggle(h.selected),37==b.keyCode&&(i.nodes.length>0&&i.expanded?h.collapse(h.selected):(c(i.parent),i.parent.group||h.collapse(i.parent.id))),39==b.keyCode&&(i.nodes.length>0||i.plus)&&!i.expanded&&h.expand(h.selected),38==b.keyCode&&c(d(i,f)),40==b.keyCode&&c(d(i,e)),a.inArray(b.keyCode,[13,32,37,38,39,40])!=-1&&(b.preventDefault&&b.preventDefault(),b.stopPropagation&&b.stopPropagation()),h.trigger(a.extend(j,{phase:"after"})))}},scrollIntoView:function(b){null==b&&(b=this.selected);var c=this.get(b);if(null!=c){var d=a(this.box).find(".w2ui-sidebar-div"),e=a(this.box).find("#node_"+w2utils.escapeId(b)),f=e.offset().top-d.offset().top;(f+e.height()>d.height()||f<=0)&&d.animate({scrollTop:d.scrollTop()+f-d.height()/2+e.height()},250,"linear")}},dblClick:function(b,c){var d=this.get(b),e=this.trigger({phase:"before",type:"dblClick",target:b,originalEvent:c,object:d});e.isCancelled!==!0&&(this.toggle(b),this.trigger(a.extend(e,{phase:"after"})))},contextMenu:function(b,c){var d=this,e=d.get(b);b!=d.selected&&d.click(b);var f=d.trigger({phase:"before",type:"contextMenu",target:b,originalEvent:c,object:e,allowOnDisabled:!1});f.isCancelled!==!0&&(e.disabled&&!f.allowOnDisabled||(d.menu.length>0&&a(d.box).find("#node_"+w2utils.escapeId(b)).w2menu({items:d.menu,contextMenu:!0,originalEvent:c,onSelect:function(a){d.menuClick(b,parseInt(a.index),a.originalEvent)}}),c.preventDefault&&c.preventDefault(),d.trigger(a.extend(f,{phase:"after"}))))},menuClick:function(b,c,d){var e=this,f=e.trigger({phase:"before",type:"menuClick",target:b,originalEvent:d,menuIndex:c,menuItem:e.menu[c]});f.isCancelled!==!0&&e.trigger(a.extend(f,{phase:"after"}))},goFlat:function(){var b=this.trigger({phase:"before",type:"flat",goFlat:!this.flat});b.isCancelled!==!0&&(this.flat=!this.flat,this.refresh(),this.trigger(a.extend(b,{phase:"after"})))},render:function(b){var c=(new Date).getTime(),d=this,e=this.trigger({phase:"before",type:"render",target:this.name,box:b});if(e.isCancelled!==!0&&(null!=b&&(a(this.box).find("> div > div.w2ui-sidebar-div").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-sidebar").html(""),this.box=b),this.box)){a(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-sidebar").html('
'),a(this.box).find("> div").css({width:a(this.box).width()+"px",height:a(this.box).height()+"px"}),a(this.box).length>0&&(a(this.box)[0].style.cssText+=this.style);var f="";1==this.flatButton&&(f='
"),""===this.topHTML&&""===f||(a(this.box).find(".w2ui-sidebar-top").html(this.topHTML+f),a(this.box).find(".w2ui-sidebar-div").css("top",a(this.box).find(".w2ui-sidebar-top").height()+"px")),""!==this.bottomHTML&&(a(this.box).find(".w2ui-sidebar-bottom").html(this.bottomHTML),a(this.box).find(".w2ui-sidebar-div").css("bottom",a(this.box).find(".w2ui-sidebar-bottom").height()+"px"));var g;return a(this.box).find("#sidebar_"+this.name+"_focus").on("focus",function(a){clearTimeout(g),d.hasFocus||d.focus(a)}).on("blur",function(a){g=setTimeout(function(){d.hasFocus&&d.blur(a)},100)}).on("keydown",function(a){9!=a.keyCode&&w2ui[d.name].keydown.call(w2ui[d.name],a)}),a(this.box).off("mousedown").on("mousedown",function(b){setTimeout(function(){if(["INPUT","TEXTAREA","SELECT"].indexOf(b.target.tagName.toUpperCase())==-1){var c=a(d.box).find("#sidebar_"+d.name+"_focus");if(!c.is(":focus")){if(a(b.target).hasClass("w2ui-node")){var e=a(b.target).position().top+a(d.box).find(".w2ui-sidebar-top").height()+b.offsetY;c.css({top:e+"px",left:"0px"})}c.focus()}}},1)}),this.trigger(a.extend(e,{phase:"after"})),this.refresh(),(new Date).getTime()-c}},refresh:function(b){function c(a){var b="",c=a.img;null==c&&(c=this.img);var d=a.icon;null==d&&(d=this.icon);for(var e=a.parent,f=0;e&&null!=e.parent;)e.group&&f--,e=e.parent,f++;if(null!=a.caption&&(a.text=a.caption),a.group)b='
"+(a.groupShowHide&&a.collapsible?""+(!a.hidden&&a.expanded?w2utils.lang("Hide"):w2utils.lang("Show"))+"":"")+("function"==typeof a.text?a.text.call(j,a):""+a.text+"")+'
',j.flat&&(b='
 
');else{a.selected&&!a.disabled&&(j.selected=a.id),e="",c&&(e='
'),d&&(e='
');var g=a.text;"function"==typeof a.text&&(g=a.text.call(j,a)),b='
'+(a.nodes.length>0?a.expanded?"-":"+":a.plus?"+":"")+'
'+e+(a.count||0===a.count?'
'+a.count+"
":"")+'
'+g+'
',j.flat&&(b='
'+a.count+"":""))+"'), { id: '"+a.id+"', left: -5 })\" onmouseout=\"jQuery(this).find('.w2ui-node-data').w2tag(null, { id: '"+a.id+"' })\" ondblclick=\"w2ui['"+j.name+"'].dblClick('"+a.id+"', event);\" oncontextmenu=\"w2ui['"+j.name+"'].contextMenu('"+a.id+"', event);\" onClick=\"w2ui['"+j.name+"'].click('"+a.id+'\', event); ">
'+e+'
')}return b}var d=(new Date).getTime(),e=this.trigger({phase:"before",type:"refresh",target:null!=b?b:this.name,fullRefresh:null==b});if(e.isCancelled!==!0){var f="";1==this.flatButton&&(f='
"),""===this.topHTML&&""===f||(a(this.box).find(".w2ui-sidebar-top").html(this.topHTML+f),a(this.box).find(".w2ui-sidebar-div").css("top",a(this.box).find(".w2ui-sidebar-top").height()+"px")),""!==this.bottomHTML&&(a(this.box).find(".w2ui-sidebar-bottom").html(this.bottomHTML),a(this.box).find(".w2ui-sidebar-div").css("bottom",a(this.box).find(".w2ui-sidebar-bottom").height()+"px")),a(this.box).find("> div").removeClass("w2ui-sidebar-flat").addClass(this.flat?"w2ui-sidebar-flat":"").css({width:a(this.box).width()+"px",height:a(this.box).height()+"px"});var g,h,i,j=this;if(null==b)g=this,i=".w2ui-sidebar-div";else{if(g=this.get(b),null==g)return;i="#node_"+w2utils.escapeId(g.id)+"_sub"}var k;if(g!==this){var l="#node_"+w2utils.escapeId(g.id);k=c(g),a(this.box).find(l).before(''),a(this.box).find(l).remove(),a(this.box).find(i).remove(),a("#sidebar_"+this.name+"_tmp").before(k),a("#sidebar_"+this.name+"_tmp").remove()}a(this.box).find(i).html("");for(var m=0;m div").css({width:a(this.box).width()+"px",height:a(this.box).height()+"px"}),this.trigger(a.extend(c,{phase:"after"})),(new Date).getTime()-b},destroy:function(){var b=this.trigger({phase:"before",type:"destroy",target:this.name});b.isCancelled!==!0&&(a(this.box).find("> div > div.w2ui-sidebar-div").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-sidebar").html(""),delete w2ui[this.name],this.trigger(a.extend(b,{phase:"after"})))},lock:function(a,b){var c=Array.prototype.slice.call(arguments,0);c.unshift(this.box),w2utils.lock.apply(window,c)},unlock:function(a){w2utils.unlock(this.box,a)}},a.extend(b.prototype,w2utils.event),w2obj.sidebar=b}(jQuery),function(a){var b=function(b){this.el=null,this.helpers={},this.type=b.type||"text",this.options=a.extend(!0,{},b),this.onSearch=b.onSearch||null,this.onRequest=b.onRequest||null,this.onLoad=b.onLoad||null,this.onError=b.onError||null,this.onClick=b.onClick||null,this.onAdd=b.onAdd||null,this.onNew=b.onNew||null,this.onRemove=b.onRemove||null,this.onMouseOver=b.onMouseOver||null,this.onMouseOut=b.onMouseOut||null,this.onIconClick=b.onIconClick||null,this.onScroll=b.onScroll||null,this.tmp={},delete this.options.type,delete this.options.onSearch,delete this.options.onRequest,delete this.options.onLoad,delete this.options.onError,delete this.options.onClick,delete this.options.onMouseOver,delete this.options.onMouseOut,delete this.options.onIconClick,delete this.options.onScroll,a.extend(!0,this,w2obj.field)};a.fn.w2field=function(c,d){if(0!==this.length){if(0===arguments.length){var e=a(this).data("w2field");return e}return"string"==typeof c&&"object"==typeof d&&(c=a.extend(!0,{},d,{type:c})),"string"==typeof c&&null==d&&(c={type:c}),c.type=String(c.type).toLowerCase(),this.each(function(d,e){var f=a(e).data("w2field");if(null==f){var f=new b(c);return a.extend(f,{handlers:[]}),e&&(f.el=a(e)[0]),f.init(),a(e).data("w2field",f),f}if(f.clear(),"clear"!=c.type){var f=new b(c);return a.extend(f,{handlers:[]}),e&&(f.el=a(e)[0]),f.init(),a(e).data("w2field",f),f}})}var f=b.prototype;if(f[c])return f[c].apply(f,Array.prototype.slice.call(arguments,1))},b.prototype={custom:{},addType:function(a,b){return a=String(a).toLowerCase(),this.custom[a]=b,!0},removeType:function(a){return a=String(a).toLowerCase(),!!this.custom[a]&&(delete this.custom[a],!0)},init:function(){var b,c=this,d=this.options;if("function"==typeof this.custom[this.type])return void this.custom[this.type].call(this,d);if(["INPUT","TEXTAREA"].indexOf(this.el.tagName.toUpperCase())==-1)return void console.log("ERROR: w2field could only be applied to INPUT or TEXTAREA.",this.el);switch(this.type){case"text":case"int":case"float":case"money":case"currency":case"percent":case"alphanumeric":case"bin":case"hex":b={min:null,max:null,step:1,autoFormat:!0,currencyPrefix:w2utils.settings.currencyPrefix,currencySuffix:w2utils.settings.currencySuffix,currencyPrecision:w2utils.settings.currencyPrecision,decimalSymbol:w2utils.settings.decimalSymbol,groupSymbol:w2utils.settings.groupSymbol,arrows:!1,keyboard:!0,precision:null,silent:!0,prefix:"",suffix:""},this.options=a.extend(!0,{},b,d),d=this.options,d.numberRE=new RegExp("["+d.groupSymbol+"]","g"),d.moneyRE=new RegExp("["+d.currencyPrefix+d.currencySuffix+d.groupSymbol+"]","g"),d.percentRE=new RegExp("["+d.groupSymbol+"%]","g"),["text","alphanumeric","hex","bin"].indexOf(this.type)!=-1&&(d.arrows=!1, d.keyboard=!1),this.addPrefix(),this.addSuffix();break;case"color":b={prefix:"#",suffix:'
 
',arrows:!1,keyboard:!1,transparent:!0},a.extend(d,b),this.addPrefix(),this.addSuffix(),a(this.el).attr("maxlength",6),""!==a(this.el).val()&&setTimeout(function(){c.change()},1);break;case"date":b={format:w2utils.settings.dateFormat,keyboard:!0,silent:!0,start:"",end:"",blocked:{},colored:{},blockWeekDays:null},this.options=a.extend(!0,{},b,d),d=this.options,null==a(this.el).attr("placeholder")&&a(this.el).attr("placeholder",d.format);break;case"time":b={format:w2utils.settings.timeFormat,keyboard:!0,silent:!0,start:"",end:"",noMinutes:!1},this.options=a.extend(!0,{},b,d),d=this.options,null==a(this.el).attr("placeholder")&&a(this.el).attr("placeholder",d.format);break;case"datetime":b={format:w2utils.settings.dateFormat+" | "+w2utils.settings.timeFormat,keyboard:!0,silent:!0,start:"",end:"",blocked:[],colored:{},placeholder:null,btn_now:!0,noMinutes:!1},this.options=a.extend(!0,{},b,d),d=this.options,null==a(this.el).attr("placeholder")&&a(this.el).attr("placeholder",d.placeholder||d.format);break;case"list":case"combo":if(b={items:[],selected:{},url:null,recId:null,recText:null,method:null,interval:350,postData:{},minLength:1,cacheMax:250,maxDropHeight:350,maxDropWidth:null,match:"begins",silent:!0,icon:null,iconStyle:"",onSearch:null,onRequest:null,onLoad:null,onError:null,onIconClick:null,renderDrop:null,compare:null,filter:!0,prefix:"",suffix:"",openOnFocus:!1,markSearch:!1},d.items=this.normMenu(d.items),"list"==this.type){if(b.openOnFocus=!0,a(this.el).addClass("w2ui-select"),!a.isPlainObject(d.selected)&&d.items)for(var e=0;e0?b.resize():clearInterval(c.sizeTimer)},200),a(b.el).data("tmp",c)},get:function(){var b;return b=["list","enum","file"].indexOf(this.type)!=-1?a(this.el).data("selected"):a(this.el).val()},set:function(b,c){if(["list","enum","file"].indexOf(this.type)!=-1){if("list"!=this.type&&c)null==a(this.el).data("selected")&&a(this.el).data("selected",[]),a(this.el).data("selected").push(b),a(this.el).change();else{var d="enum"==this.type?[b]:b;a(this.el).data("selected",d).change()}this.refresh()}else a(this.el).val(b)},setIndex:function(b,c){if(["list","enum"].indexOf(this.type)!=-1){var d=this.options.items;if(d&&d[b]){if("list"!=this.type&&c)null==a(this.el).data("selected")&&a(this.el).data("selected",[]),a(this.el).data("selected").push(d[b]),a(this.el).change();else{var e="enum"==this.type?[d[b]]:d[b];a(this.el).data("selected",e).change()}return this.refresh(),!0}}return!1},clear:function(){var b=this.options;["money","currency"].indexOf(this.type)!=-1&&a(this.el).val(a(this.el).val().replace(b.moneyRE,"")),"percent"==this.type&&a(this.el).val(a(this.el).val().replace(/%/g,"")),"color"==this.type&&a(this.el).removeAttr("maxlength"),"list"==this.type&&a(this.el).removeClass("w2ui-select"),this.type="clear";var c=a(this.el).data("tmp");if(this.tmp){null!=c&&(a(this.el).height("auto"),c&&c["old-padding-left"]&&a(this.el).css("padding-left",c["old-padding-left"]),c&&c["old-padding-right"]&&a(this.el).css("padding-right",c["old-padding-right"]),c&&c["old-background-color"]&&a(this.el).css("background-color",c["old-background-color"]),c&&c["old-border-color"]&&a(this.el).css("border-color",c["old-border-color"]),clearInterval(c.sizeTimer)),a(this.el).val(this.clean(a(this.el).val())).removeClass("w2field").removeData().off(".w2field");for(var d in this.helpers)a(this.helpers[d]).remove();this.helpers={}}},refresh:function(){var b=this,c=this.options,d=a(this.el).data("selected"),e=(new Date).getTime();if(["list"].indexOf(this.type)!=-1&&(a(b.el).parent().css("white-space","nowrap"),b.helpers.prefix&&b.helpers.prefix.hide(),setTimeout(function(){if(b.helpers.focus){!a.isEmptyObject(d)&&c.icon?(c.prefix='',b.addPrefix()):(c.prefix="",b.addPrefix());var e=b.helpers.focus.find("input");""===a(e).val()?(a(e).css("text-indent","-9999em").prev().css("opacity",0),a(b.el).val(d&&null!=d.text?w2utils.lang(d.text):"")):(a(e).css("text-indent",0).prev().css("opacity",1),a(b.el).val(""),setTimeout(function(){b.helpers.prefix&&b.helpers.prefix.hide();var d="position: absolute; opacity: 0; margin: 4px 0px 0px 2px; background-position: left !important;";c.icon?(a(e).css("margin-left","17px"),a(b.helpers.focus).find(".icon-search").attr("style",d+"width: 11px !important; opacity: 1; display: block")):(a(e).css("margin-left","0px"),a(b.helpers.focus).find(".icon-search").attr("style",d+"width: 0px !important; opacity: 0; display: none"))},1)),a(b.el).prop("readonly")||a(b.el).prop("disabled")?setTimeout(function(){a(b.helpers.prefix).css("opacity","0.6"),a(b.helpers.suffix).css("opacity","0.6")},1):setTimeout(function(){a(b.helpers.prefix).css("opacity","1"),a(b.helpers.suffix).css("opacity","1")},1)}},1)),["enum","file"].indexOf(this.type)!=-1){var f="";if(d)for(var g=0;g  '):'
  
'+("enum"==b.type?h.text:h.name+' - '+w2utils.formatSize(h.size)+""),f+='
  • '+i+"
  • "}var j=b.helpers.multi,k=j.find("ul");if(j.attr("style",j.attr("style")+";"+c.style),a(b.el).css("z-index","-1"),a(b.el).prop("readonly")||a(b.el).prop("disabled")?setTimeout(function(){j[0].scrollTop=0,j.addClass("w2ui-readonly").find("li").css("opacity","0.9").parent().find("li.nomouse").hide().find("input").prop("readonly",!0).parents("ul").find(".w2ui-list-remove").hide()},1):setTimeout(function(){j.removeClass("w2ui-readonly").find("li").css("opacity","1").parent().find("li.nomouse").show().find("input").prop("readonly",!1).parents("ul").find(".w2ui-list-remove").show()},1),j.find(".w2ui-enum-placeholder").remove(),k.find("li").not("li.nomouse").remove(),""!==f)k.prepend(f);else if(null!=a(b.el).attr("placeholder")&&""===j.find("input").val()){var l="padding-top: "+a(this.el).css("padding-top")+";padding-left: "+a(this.el).css("padding-left")+"; box-sizing: "+a(this.el).css("box-sizing")+"; line-height: "+a(this.el).css("line-height")+"; font-size: "+a(this.el).css("font-size")+"; font-family: "+a(this.el).css("font-family")+"; ";j.prepend('
    '+a(b.el).attr("placeholder")+"
    ")}j.off("scroll.w2field").on("scroll.w2field",function(c){var d=b.trigger({phase:"before",type:"scroll",target:b.el,originalEvent:c});d.isCancelled!==!0&&b.trigger(a.extend(d,{phase:"after"}))}).find("li").data("mouse","out").on("click",function(c){var e="LI"==c.target.tagName.toUpperCase()?c.target:a(c.target).parents("LI"),f=d[a(e).attr("index")];if(!a(e).hasClass("nomouse"))if(c.stopPropagation(),a(c.target).hasClass("w2ui-list-remove")){if(a(b.el).prop("readonly")||a(b.el).prop("disabled"))return;var g=b.trigger({phase:"before",type:"remove",target:b.el,originalEvent:c.originalEvent,item:f});if(g.isCancelled===!0)return;a().w2overlay(),d.splice(a(c.target).attr("index"),1),a(b.el).trigger("change"),a(c.target).parent().fadeOut("fast"),setTimeout(function(){b.refresh(),b.trigger(a.extend(g,{phase:"after"}))},300)}else{var g=b.trigger({phase:"before",type:"click",target:b.el,originalEvent:c.originalEvent,item:f});if(g.isCancelled===!0)return;if("file"==b.type){var h="";/image/i.test(f.type)&&(h='
    ');var i='style="padding: 3px; text-align: right; color: #777;"',j='style="padding: 3px"';h+='
    "+w2utils.lang("Name")+":"+f.name+"
    "+w2utils.lang("Size")+":"+w2utils.formatSize(f.size)+"
    "+w2utils.lang("Type")+": '+f.type+"
    "+w2utils.lang("Modified")+":"+w2utils.date(f.modified)+"
    ",a("#w2ui-overlay").remove(),a(e).w2overlay(h)}b.trigger(a.extend(g,{phase:"after"}))}}).on("mouseover",function(c){var e="LI"==c.target.tagName.toUpperCase()?c.target:a(c.target).parents("LI");if(!a(e).hasClass("nomouse")){if("out"==a(e).data("mouse")){var f=d[a(c.target).attr("index")],g=b.trigger({phase:"before",type:"mouseOver",target:b.el,originalEvent:c.originalEvent,item:f});if(g.isCancelled===!0)return;b.trigger(a.extend(g,{phase:"after"}))}a(e).data("mouse","over")}}).on("mouseout",function(c){var e="LI"==c.target.tagName.toUpperCase()?c.target:a(c.target).parents("LI");a(e).hasClass("nomouse")||(a(e).data("mouse","leaving"),setTimeout(function(){if("leaving"==a(e).data("mouse")){a(e).data("mouse","out");var f=d[a(c.target).attr("index")],g=b.trigger({phase:"before",type:"mouseOut",target:b.el,originalEvent:c.originalEvent,item:f});if(g.isCancelled===!0)return;b.trigger(a.extend(g,{phase:"after"}))}},0))}),a(this.el).height("auto");var m=a(j).find("> div.w2ui-multi-items").height()+2*w2utils.getSize(j,"+height");m<26&&(m=26),m>c.maxHeight&&(m=c.maxHeight),j.length>0&&(j[0].scrollTop=1e3);var n=w2utils.getSize(a(this.el),"height")-2;if(n>m&&(m=n),a(j).css({height:m+"px",overflow:m==c.maxHeight?"auto":"hidden"}),m0)){var e=this.helpers.focus,f=this.helpers.multi,g=this.helpers.suffix,h=this.helpers.prefix;if(e&&e.width(a(b.el).width()),f){var i=w2utils.getSize(b.el,"width")-parseInt(a(b.el).css("margin-left"),10)-parseInt(a(b.el).css("margin-right"),10);a(f).width(i)}g&&(b.options.suffix='
    ',b.addSuffix()),h&&b.addPrefix(),b.tmp.current_width=c}},clean:function(b){if("number"==typeof b)return b;var c=this.options;return b=String(b).trim(),["int","float","money","currency","percent"].indexOf(this.type)!=-1&&("string"==typeof b&&(c.autoFormat&&["money","currency"].indexOf(this.type)!=-1&&(b=String(b).replace(c.moneyRE,"")),c.autoFormat&&"percent"==this.type&&(b=String(b).replace(c.percentRE,"")),c.autoFormat&&["int","float"].indexOf(this.type)!=-1&&(b=String(b).replace(c.numberRE,"")),b=b.replace(/\s+/g,"").replace(w2utils.settings.groupSymbol,"").replace(w2utils.settings.decimalSymbol,".")),parseFloat(b)==b&&(null!=c.min&&bc.max&&(b=c.max,a(this.el).val(c.max))),b=""!==b&&w2utils.isFloat(b)?Number(b):""),b},format:function(a){var b=this.options;if(b.autoFormat&&""!==a)switch(this.type){case"money":case"currency":a=w2utils.formatNumber(a,b.currencyPrecision,b.groupSymbol),""!==a&&(a=b.currencyPrefix+a+b.currencySuffix);break;case"percent":a=w2utils.formatNumber(a,b.precision,b.groupSymbol),""!==a&&(a+="%");break;case"float":a=w2utils.formatNumber(a,b.precision,b.groupSymbol);break;case"int":a=w2utils.formatNumber(a,0,b.groupSymbol)}return a},change:function(b){var c=this,d=c.options;if(["int","float","money","currency","percent"].indexOf(this.type)!=-1){var e=a(this.el).val(),f=this.format(this.clean(a(this.el).val()));if(""!==e&&e!=f)return a(this.el).val(f).change(),b.stopPropagation(),b.preventDefault(),!1}if("color"==this.type){var g="#"+a(this.el).val();6!=a(this.el).val().length&&3!=a(this.el).val().length&&(g=""),a(this.el).next().find("div").css("background-color",g),a(c.el).is(":focus")&&this.updateOverlay()}if(["list","enum","file"].indexOf(this.type)!=-1&&(c.refresh(),setTimeout(function(){c.refresh()},5)),["date","time","datetime"].indexOf(this.type)!=-1){var h=parseInt(c.el.value);w2utils.isInt(c.el.value)&&h>3e3&&("time"==this.type&&a(c.el).val(w2utils.formatTime(new Date(h),d.format)).change(),"date"==this.type&&a(c.el).val(w2utils.formatDate(new Date(h),d.format)).change(),"datetime"==this.type&&a(c.el).val(w2utils.formatDateTime(new Date(h),d.format)).change())}},click:function(b){b.stopPropagation(),["list","combo","enum"].indexOf(this.type)!=-1&&(a(this.el).is(":focus")||this.focus(b)),["date","time","color","datetime"].indexOf(this.type)!=-1&&this.updateOverlay()},focus:function(b){var c=this;this.options;if(["color","date","time","datetime"].indexOf(c.type)!==-1){if(a(c.el).prop("readonly")||a(c.el).prop("disabled"))return;a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),setTimeout(function(){c.updateOverlay()},150)}if(["list","combo","enum"].indexOf(c.type)!=-1){if(a(c.el).prop("readonly")||a(c.el).prop("disabled"))return;a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),c.resize(),setTimeout(function(){return"list"==c.type&&a(c.el).is(":focus")?void a(c.helpers.focus).find("input").focus():(c.search(),void setTimeout(function(){c.updateOverlay()},1))},1)}"file"==c.type&&a(c.helpers.multi).css({outline:"auto 5px #7DB4F3","outline-offset":"-2px"})},blur:function(b){var c=this,d=c.options,e=a(c.el).val().trim();["color","date","time","list","combo","enum","datetime"].indexOf(c.type)!=-1&&a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),["int","float","money","currency","percent"].indexOf(c.type)!=-1&&(""===e||c.checkType(e)||(a(c.el).val("").change(),d.silent===!1&&(a(c.el).w2tag("Not a valid number"),setTimeout(function(){a(c.el).w2tag("")},3e3)))),["date","time","datetime"].indexOf(c.type)!=-1&&(""===e||c.inRange(c.el.value)?"date"!=c.type||""===e||w2utils.isDate(c.el.value,d.format)?"time"!=c.type||""===e||w2utils.isTime(c.el.value)?"datetime"!=c.type||""===e||w2utils.isDateTime(c.el.value,d.format)||(a(c.el).val("").removeData("selected").change(),d.silent===!1&&(a(c.el).w2tag("Not a valid date"),setTimeout(function(){a(c.el).w2tag("")},3e3))):(a(c.el).val("").removeData("selected").change(),d.silent===!1&&(a(c.el).w2tag("Not a valid time"),setTimeout(function(){a(c.el).w2tag("")},3e3))):(a(c.el).val("").removeData("selected").change(),d.silent===!1&&(a(c.el).w2tag("Not a valid date"),setTimeout(function(){a(c.el).w2tag("")},3e3))):(a(c.el).val("").removeData("selected").change(),d.silent===!1&&(a(c.el).w2tag("Not in range"),setTimeout(function(){a(c.el).w2tag("")},3e3)))),"enum"==c.type&&a(c.helpers.multi).find("input").val("").width(20),"file"==c.type&&a(c.helpers.multi).css({outline:"none"})},keyPress:function(a){var b=this;b.options;if(["int","float","money","currency","percent","hex","bin","color","alphanumeric"].indexOf(b.type)!=-1){if(a.metaKey||a.ctrlKey||a.altKey||a.charCode!=a.keyCode&&a.keyCode>0)return;var c=String.fromCharCode(a.charCode);if(!b.checkType(c,!0)&&13!=a.keyCode)return a.preventDefault(),a.stopPropagation?a.stopPropagation():a.cancelBubble=!0,!1}["date","time","datetime"].indexOf(b.type)!=-1&&9!==a.keyCode&&setTimeout(function(){b.updateOverlay()},1)},keyDown:function(b,c){var d=this,e=d.options,f=b.keyCode||c&&c.keyCode;if(["int","float","money","currency","percent"].indexOf(d.type)!=-1){if(!e.keyboard||a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;var g=!1,h=parseFloat(a(d.el).val().replace(e.moneyRE,""))||0,i=e.step;switch((b.ctrlKey||b.metaKey)&&(i=10),f){case 38:if(b.shiftKey)break;a(d.el).val(h+i<=e.max||null==e.max?Number((h+i).toFixed(12)):e.max).change(),g=!0;break;case 40:if(b.shiftKey)break;a(d.el).val(h-i>=e.min||null==e.min?Number((h-i).toFixed(12)):e.min).change(),g=!0}g&&(b.preventDefault(),setTimeout(function(){d.el.setSelectionRange(d.el.value.length,d.el.value.length)},0))}if("date"==d.type){if(!e.keyboard||a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;var g=!1,j=864e5,i=1;(b.ctrlKey||b.metaKey)&&(i=10);var k=w2utils.isDate(a(d.el).val(),e.format,!0);switch(k||(k=new Date,j=0),f){case 38:if(b.shiftKey)break;var l=w2utils.formatDate(k.getTime()+j,e.format);10==i&&(l=w2utils.formatDate(new Date(k.getFullYear(),k.getMonth()+1,k.getDate()),e.format)),a(d.el).val(l).change(),g=!0;break;case 40:if(b.shiftKey)break;var l=w2utils.formatDate(k.getTime()-j,e.format);10==i&&(l=w2utils.formatDate(new Date(k.getFullYear(),k.getMonth()-1,k.getDate()),e.format)),a(d.el).val(l).change(),g=!0}g&&(b.preventDefault(),setTimeout(function(){d.el.setSelectionRange(d.el.value.length,d.el.value.length),d.updateOverlay()},0))}if("time"==d.type){if(!e.keyboard||a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;var g=!1,i=b.ctrlKey||b.metaKey?60:1,h=a(d.el).val(),m=d.toMin(h)||d.toMin((new Date).getHours()+":"+((new Date).getMinutes()-1));switch(f){case 38:if(b.shiftKey)break;m+=i,g=!0;break;case 40:if(b.shiftKey)break;m-=i,g=!0}g&&(a(d.el).val(d.fromMin(m)).change(),b.preventDefault(),setTimeout(function(){d.el.setSelectionRange(d.el.value.length,d.el.value.length)},0))}if("datetime"==d.type){if(!e.keyboard||a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;var g=!1,j=864e5,i=1;(b.ctrlKey||b.metaKey)&&(i=10);var n=a(d.el).val(),k=w2utils.isDateTime(n,this.options.format,!0);switch(k||(k=new Date,j=0),f){case 38:if(b.shiftKey)break;var l=w2utils.formatDateTime(k.getTime()+j,e.format);10==i&&(l=w2utils.formatDateTime(new Date(k.getFullYear(),k.getMonth()+1,k.getDate()),e.format)),a(d.el).val(l).change(),g=!0;break;case 40:if(b.shiftKey)break;var l=w2utils.formatDateTime(k.getTime()-j,e.format);10==i&&(l=w2utils.formatDateTime(new Date(k.getFullYear(),k.getMonth()-1,k.getDate()),e.format)),a(d.el).val(l).change(),g=!0}g&&(b.preventDefault(),setTimeout(function(){d.el.setSelectionRange(d.el.value.length,d.el.value.length),d.updateOverlay()},0))}if("color"==d.type){if(a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;if(86==b.keyCode&&(b.ctrlKey||b.metaKey)&&(a(d.el).prop("maxlength",7),setTimeout(function(){var b=a(d).val();"#"==b.substr(0,1)&&(b=b.substr(1)),w2utils.isHex(b)||(b=""),a(d).val(b).prop("maxlength",6).change()},20)),(b.ctrlKey||b.metaKey)&&!b.shiftKey){var o=null,p=null;switch(f){case 38:o="up";break;case 40:o="down";break;case 39:o="right";break;case 37:o="left"}d.el.nav&&null!=o&&(p=d.el.nav(o),a(d.el).val(p).change(),b.preventDefault())}}if(["list","combo","enum"].indexOf(d.type)!=-1){if(a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;var q=a(d.el).data("selected"),r=a(d.el),s=!1;switch(["list","enum"].indexOf(d.type)!=-1&&("list"==d.type&&(r=a(d.helpers.focus).find("input")),"enum"==d.type&&(r=a(d.helpers.multi).find("input")),[37,38,39,40].indexOf(f)==-1&&setTimeout(function(){d.refresh()},1),86==b.keyCode&&(b.ctrlKey||b.metaKey)&&setTimeout(function(){d.refresh(),d.search(),d.request()},50)),f){case 27:"list"==d.type&&(""!==r.val()&&r.val(""),b.stopPropagation());break;case 37:case 39:break;case 13:if(0===a("#w2ui-overlay").length)break;var t=e.items[e.index];if("enum"==d.type)if(null!=t){var u=d.trigger({phase:"before",type:"add",target:d.el,originalEvent:b.originalEvent,item:t});if(u.isCancelled===!0)return;t=u.item,q.length>=e.max&&e.max>0&&q.pop(),delete t.hidden,delete d.tmp.force_open,q.push(t),a(d.el).change(),r.val("").width(20),d.refresh(),d.trigger(a.extend(u,{phase:"after"}))}else{t={id:r.val(),text:r.val()};var u=d.trigger({phase:"before",type:"new",target:d.el,originalEvent:b.originalEvent,item:t});if(u.isCancelled===!0)return;t=u.item,"function"==typeof d.onNew&&(q.length>=e.max&&e.max>0&&q.pop(),delete d.tmp.force_open,q.push(t),a(d.el).change(),r.val("").width(20),d.refresh()),d.trigger(a.extend(u,{phase:"after"}))}else t&&a(d.el).data("selected",t).val(t.text).change(),""===a(d.el).val()&&a(d.el).data("selected")&&a(d.el).removeData("selected").val("").change(),"list"==d.type&&(r.val(""),d.refresh()),d.tmp.force_hide=!0;break;case 8:case 46:if("enum"==d.type&&8==f&&""===r.val()&&q.length>0){var t=q[q.length-1],u=d.trigger({phase:"before",type:"remove",target:d.el,originalEvent:b.originalEvent,item:t});if(u.isCancelled===!0)return;q.pop(),a(d.el).trigger("change"),d.refresh(),d.trigger(a.extend(u,{phase:"after"}))}"list"==d.type&&""===r.val()&&(a(d.el).data("selected",{}).change(),d.refresh());break;case 38:for(e.index=w2utils.isInt(e.index)?parseInt(e.index):0,e.index--;e.index>0&&e.items[e.index].hidden;)e.index--;if(0===e.index&&e.items[e.index].hidden)for(;e.items[e.index]&&e.items[e.index].hidden;)e.index++;s=!0;break;case 40:for(e.index=w2utils.isInt(e.index)?parseInt(e.index):-1,e.index++;e.index=e.items.length&&(e.index=e.items.length-1),d.updateOverlay(s),b.preventDefault(),void setTimeout(function(){if("enum"==d.type){var a=r.get(0);a.setSelectionRange(a.value.length,a.value.length)}else if("list"==d.type){var a=r.get(0);a.setSelectionRange(a.value.length,a.value.length)}else d.el.setSelectionRange(d.el.value.length,d.el.value.length)},0);"enum"==d.type&&r.width(8*(r.val().length+2)+"px")}},keyUp:function(b){var c=this;if("color"==this.type&&86==b.keyCode&&(b.ctrlKey||b.metaKey)&&a(this).prop("maxlength",6),["list","combo","enum"].indexOf(this.type)!=-1){if(a(c.el).prop("readonly")||a(c.el).prop("disabled"))return;if([16,17,18,20,37,39,91].indexOf(b.keyCode)==-1){var d=a(this.helpers.focus).find("input");0===d.length&&(d=a(this.el));var e=this.trigger({phase:"before",type:"search",originalEvent:b,target:d,search:d.val()});if(e.isCancelled===!0)return;this.tmp.force_hide||this.request(),1==d.val().length&&this.refresh(),0!==a("#w2ui-overlay").length&&[38,40].indexOf(b.keyCode)!=-1||this.search(),this.trigger(a.extend(e,{phase:"after"}))}}},clearCache:function(){var a=this.options;a.items=[],this.tmp.xhr_loading=!1,this.tmp.xhr_search="",this.tmp.xhr_total=-1},request:function(b){var c=this,d=this.options,e=a(c.el).val()||"";if(d.url){if("enum"==c.type){var f=a(c.helpers.multi).find("input");e=0===f.length?"":f.val()}if("list"==c.type){var f=a(c.helpers.focus).find("input");e=0===f.length?"":f.val()}if(0!==d.minLength&&e.lengthc.tmp.xhr_search.length||e.length>=c.tmp.xhr_search.length&&e.substr(0,c.tmp.xhr_search.length)!=c.tmp.xhr_search||e.lengthd.cacheMax&&b.records.splice(d.cacheMax,1e5),null==d.recId&&null!=d.recid&&(d.recId=d.recid),(d.recId||d.recText)&&b.records.forEach(function(a){"string"==typeof d.recId&&(a.id=a[d.recId]),"function"==typeof d.recId&&(a.id=d.recId(a)),"string"==typeof d.recText&&(a.text=a[d.recText]),"function"==typeof d.recText&&(a.text=d.recText(a))}),c.tmp.xhr_loading=!1,c.tmp.xhr_search=e,c.tmp.xhr_total=b.records.length,d.items=c.normMenu(b.records),""===e&&0===b.records.length?c.tmp.emptySet=!0:c.tmp.emptySet=!1,c.search(),c.trigger(a.extend(i,{phase:"after"}))}}).fail(function(b,d,f){var g={status:d,error:f,rawResponseText:b.responseText},h=c.trigger({phase:"before",type:"error",target:c.el,search:e,error:g,xhr:b});if(h.isCancelled!==!0){if("abort"!=d){var i;try{i=a.parseJSON(b.responseText)}catch(a){}console.log("ERROR: Server communication failed.","\n EXPECTED:",{status:"success",records:[{id:1,text:"item"}]},"\n OR:",{status:"error",message:"error message"},"\n RECEIVED:","object"==typeof i?i:b.responseText)}c.clearCache(),c.search(),c.trigger(a.extend(h,{phase:"after"}))}}),c.trigger(a.extend(g,{phase:"after"}))}},b))}},search:function(){var b=this,c=this.options,d=a(b.el).val(),e=b.el,f=[],g=a(b.el).data("selected");if("enum"==b.type){e=a(b.helpers.multi).find("input"),d=e.val();for(var h in g)g[h]&&f.push(g[h].id)}else if("list"==b.type){e=a(b.helpers.focus).find("input"),d=e.val();for(var h in g)g[h]&&f.push(g[h].id)}if(b.tmp.xhr_loading!==!0){for(var i=0,j=0;j',{css:{"background-color":"#f5f5f5"}});var e,f,g=w2utils.isDate(a(c.el).val(),c.options.format,!0);g&&(e=g.getMonth()+1,f=g.getFullYear()),function b(d,e){a("#w2ui-overlay > div > div").html(c.getMonthHTML(d,e,a(c.el).val())),a("#w2ui-overlay .w2ui-calendar-title").on("mousedown",function(){if(a(this).next().hasClass("w2ui-calendar-jump"))a(this).next().remove();else{var d,e;a(this).after('
    '),a(this).next().hide().html(c.getYearHTML()).fadeIn(200),setTimeout(function(){a("#w2ui-overlay .w2ui-calendar-jump").find(".w2ui-jump-month, .w2ui-jump-year").on("click",function(){a(this).hasClass("w2ui-jump-month")&&(a(this).parent().find(".w2ui-jump-month").removeClass("selected"),a(this).addClass("selected"),e=a(this).attr("name")),a(this).hasClass("w2ui-jump-year")&&(a(this).parent().find(".w2ui-jump-year").removeClass("selected"),a(this).addClass("selected"),d=a(this).attr("name")),null!=d&&null!=e&&(a("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout(function(){b(parseInt(e)+1,d)},100))}),a("#w2ui-overlay .w2ui-calendar-jump >:last-child").prop("scrollTop",2e3)},1)}}),a("#w2ui-overlay .w2ui-date").on("mousedown",function(){var b=a(this).attr("date");a(c.el).val(b).change(),a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"})}).on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)}),a("#w2ui-overlay .previous").on("mousedown",function(){var a=c.options.current.split("/");a[0]=parseInt(a[0])-1,b(a[0],a[1])}),a("#w2ui-overlay .next").on("mousedown",function(){var a=c.options.current.split("/");a[0]=parseInt(a[0])+1,b(a[0],a[1])})}(e,f)}if("time"==this.type){if(a(c.el).prop("readonly")||a(c.el).prop("disabled"))return;0===a("#w2ui-overlay").length&&a(c.el).w2overlay('
    ',{css:{"background-color":"#fff"}});var h="h24"==this.options.format;a("#w2ui-overlay > div").html(c.getHourHTML()),a("#w2ui-overlay .w2ui-time").on("mousedown",function(b){ a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"});var d=a(this).attr("hour");a(c.el).val((d>12&&!h?d-12:d)+":00"+(h?"":d<12?" am":" pm")).change()}),null==this.options.noMinutes||this.options.noMinutes===!1?a("#w2ui-overlay .w2ui-time").on("mouseup",function(){var b=a(this).attr("hour");a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),a(c.el).w2overlay('
    ',{css:{"background-color":"#fff"}}),a("#w2ui-overlay > div").html(c.getMinHTML(b)),a("#w2ui-overlay .w2ui-time").on("mousedown",function(){a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"});var d=a(this).attr("min");a(c.el).val((b>12&&!h?b-12:b)+":"+(d<10?0:"")+d+(h?"":b<12?" am":" pm")).change()}).on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}):a("#w2ui-overlay .w2ui-time").on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}if("datetime"==this.type){if(a(c.el).prop("readonly")||a(c.el).prop("disabled"))return;a("#w2ui-overlay .w2ui-time").length>0&&a("#w2ui-overlay")[0].hide(),0===a("#w2ui-overlay").length&&a(c.el).w2overlay('
    ',{css:{"background-color":"#f5f5f5"}});var e,f,g=w2utils.isDateTime(a(c.el).val(),c.options.format,!0);g&&(e=g.getMonth()+1,f=g.getFullYear());var i=null;!function b(e,f){a("#w2ui-overlay > div > div").html(c.getMonthHTML(e,f,a(c.el).val())+(d.btn_now?'
    '+w2utils.lang("Current Date & Time")+"
    ":"")),a("#w2ui-overlay .w2ui-calendar-title").on("mousedown",function(){if(a(this).next().hasClass("w2ui-calendar-jump"))a(this).next().remove();else{var d,e;a(this).after('
    '),a(this).next().hide().html(c.getYearHTML()).fadeIn(200),setTimeout(function(){a("#w2ui-overlay .w2ui-calendar-jump").find(".w2ui-jump-month, .w2ui-jump-year").on("click",function(){a(this).hasClass("w2ui-jump-month")&&(a(this).parent().find(".w2ui-jump-month").removeClass("selected"),a(this).addClass("selected"),e=a(this).attr("name")),a(this).hasClass("w2ui-jump-year")&&(a(this).parent().find(".w2ui-jump-year").removeClass("selected"),a(this).addClass("selected"),d=a(this).attr("name")),null!=d&&null!=e&&(a("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout(function(){b(parseInt(e)+1,d)},100))}),a("#w2ui-overlay .w2ui-calendar-jump >:last-child").prop("scrollTop",2e3)},1)}}),a("#w2ui-overlay .w2ui-date").on("mousedown",function(){var b=a(this).attr("date");a(c.el).val(b).change(),a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),i=new Date(a(this).attr("data-date"))}).on("mouseup",function(){var b,d;a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),a(c.el).w2overlay('
    ',{css:{"background-color":"#fff"}});"h24"==c.options.format;a("#w2ui-overlay > div").html(c.getHourHTML()),a("#w2ui-overlay .w2ui-time").on("mousedown",function(d){a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),b=a(this).attr("hour"),i.setHours(b);var e=w2utils.formatDateTime(i,c.options.format);a(c.el).val(e).change()}),null==c.options.noMinutes||c.options.noMinutes===!1?a("#w2ui-overlay .w2ui-time").on("mouseup",function(){var e=a(this).attr("hour");a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),a(c.el).w2overlay('
    ',{css:{"background-color":"#fff"}}),a("#w2ui-overlay > div").html(c.getMinHTML(e)),a("#w2ui-overlay .w2ui-time").on("mousedown",function(){a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),d=a(this).attr("min"),i.setHours(b,d);var e=w2utils.formatDateTime(i,c.options.format);a(c.el).val(e).change()}).on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}):a("#w2ui-overlay .w2ui-time").on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}),a("#w2ui-overlay .previous").on("mousedown",function(){var a=c.options.current.split("/");a[0]=parseInt(a[0])-1,b(a[0],a[1])}),a("#w2ui-overlay .next").on("mousedown",function(){var a=c.options.current.split("/");a[0]=parseInt(a[0])+1,b(a[0],a[1])}),a("#w2ui-overlay .now").on("mousedown",function(){var b=w2utils.formatDateTime(new Date,c.options.format);return a(c.el).val(b).change(),!1}).on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}(e,f)}if(["list","combo","enum"].indexOf(this.type)!=-1){var j=this.el,k=this.el;if("enum"==this.type&&(j=a(this.helpers.multi),k=a(j).find("input")),"list"==this.type){var l=a(k).data("selected");a.isPlainObject(l)&&!a.isEmptyObject(l)&&d.index==-1&&d.items.forEach(function(a,b){a.id==l.id&&(d.index=b)}),k=a(this.helpers.focus).find("input")}if(a(k).is(":focus")){if(d.openOnFocus===!1&&""===a(k).val()&&c.tmp.force_open!==!0)return void a().w2overlay();if(c.tmp.force_hide)return a().w2overlay(),void setTimeout(function(){delete c.tmp.force_hide},1);""!==a(k).val()&&delete c.tmp.force_open;var m=w2utils.lang("No matches");null!=d.url&&a(k).val().length=d.max&&d.max>0&&e.pop(),delete b.item.hidden,e.push(b.item),a(c.el).data("selected",e).change(),a(c.helpers.multi).find("input").val("").width(20),c.refresh(),a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),c.trigger(a.extend(f,{phase:"after"}))}}else a(c.el).data("selected",b.item).val(b.item.text).change(),c.helpers.focus&&c.helpers.focus.find("input").val("")}}))}}},inRange:function(b,c){var d=!1;if("date"==this.type){var e=w2utils.isDate(b,this.options.format,!0);if(e){if(this.options.start||this.options.end){var f="string"==typeof this.options.start?this.options.start:a(this.options.start).val(),g="string"==typeof this.options.end?this.options.end:a(this.options.end).val(),h=w2utils.isDate(f,this.options.format,!0),i=w2utils.isDate(g,this.options.format,!0),j=new Date(e);h||(h=j),i||(i=j),j>=h&&j<=i&&(d=!0)}else d=!0;if(this.options.blocked&&a.inArray(b,this.options.blocked)!=-1&&(d=!1),null!=this.options.blockWeekDays&&void 0!=this.options.blockWeekDays&&void 0!=this.options.blockWeekDays.length)for(var k=this.options.blockWeekDays.length,l=0;l=n&&m<=o&&(d=!0)}else d=!0;else if("datetime"==this.type){var e=w2utils.isDateTime(b,this.options.format,!0);if(e){if(this.options.start||this.options.end){var h,i;if("object"==typeof this.options.start&&this.options.start instanceof Date)h=this.options.start;else{var f="string"==typeof this.options.start?this.options.start:a(this.options.start).val();h=""!==f.trim()?w2utils.isDateTime(f,this.options.format,!0):""}if("object"==typeof this.options.end&&this.options.end instanceof Date)i=this.options.end;else{var g="string"==typeof this.options.end?this.options.end:a(this.options.end).val();i=""!==g.trim()?w2utils.isDateTime(g,this.options.format,!0):""}var j=e;h||(h=j),i||(i=j),c&&h instanceof Date&&(h.setHours(0),h.setMinutes(0),h.setSeconds(0)),j>=h&&j<=i&&(d=!0)}else d=!0;if(d&&this.options.blocked)for(var l=0;l'+b.options.prefix+""),c=a(b.el).prev(),c.css({color:a(b.el).css("color"),"font-family":a(b.el).css("font-family"),"font-size":a(b.el).css("font-size"),"padding-top":a(b.el).css("padding-top"),"padding-bottom":a(b.el).css("padding-bottom"),"padding-left":a(b.el).css("padding-left"),"padding-right":0,"margin-top":parseInt(a(b.el).css("margin-top"),10)+2+"px","margin-bottom":parseInt(a(b.el).css("margin-bottom"),10)+1+"px","margin-left":a(b.el).css("margin-left"),"margin-right":0}).on("click",function(c){if(b.options.icon&&"function"==typeof b.onIconClick){var d=b.trigger({phase:"before",type:"iconClick",target:b.el,el:a(this).find("span.w2ui-icon")[0]});if(d.isCancelled===!0)return;b.trigger(a.extend(d,{phase:"after"}))}else"list"==b.type?a(b.helpers.focus).find("input").focus():a(b.el).focus()}),a(b.el).css("padding-left",c.width()+parseInt(a(b.el).css("padding-left"),10)+"px"),b.helpers.prefix=c)}},1)},addSuffix:function(){var b,c,d=this;setTimeout(function(){if("clear"!==d.type){var e=a(d.el).data("tmp")||{};if(e["old-padding-right"]&&a(d.el).css("padding-right",e["old-padding-right"]),e["old-padding-right"]=a(d.el).css("padding-right"),a(d.el).data("tmp",e),c=parseInt(a(d.el).css("padding-right"),10),d.options.arrows){d.helpers.arrows&&a(d.helpers.arrows).remove(),a(d.el).after('
     
    ');w2utils.getSize(d.el,"height");b=a(d.el).next(),b.css({color:a(d.el).css("color"),"font-family":a(d.el).css("font-family"),"font-size":a(d.el).css("font-size"),height:a(d.el).height()+parseInt(a(d.el).css("padding-top"),10)+parseInt(a(d.el).css("padding-bottom"),10)+"px",padding:0,"margin-top":parseInt(a(d.el).css("margin-top"),10)+1+"px","margin-bottom":0,"border-left":"1px solid silver"}).css("margin-left","-"+(b.width()+parseInt(a(d.el).css("margin-right"),10)+12)+"px").on("mousedown",function(b){function c(){clearTimeout(f.data("_field_update_timer")),f.off("mouseup",c)}function e(c){a(d.el).focus(),d.keyDown(a.Event("keydown"),{keyCode:"up"==a(b.target).attr("type")?38:40}),c!==!1&&a("body").data("_field_update_timer",setTimeout(e,60))}var f=a("body");f.on("mouseup",c),f.data("_field_update_timer",setTimeout(e,700)),e(!1)}),c+=b.width()+12,a(d.el).css("padding-right",c+"px"),d.helpers.arrows=b}""!==d.options.suffix&&(d.helpers.suffix&&a(d.helpers.suffix).remove(),a(d.el).after('
    '+d.options.suffix+"
    "),b=a(d.el).next(),b.css({color:a(d.el).css("color"),"font-family":a(d.el).css("font-family"),"font-size":a(d.el).css("font-size"),"padding-top":a(d.el).css("padding-top"),"padding-bottom":a(d.el).css("padding-bottom"),"padding-left":"3px","padding-right":a(d.el).css("padding-right"),"margin-top":parseInt(a(d.el).css("margin-top"),10)+2+"px","margin-bottom":parseInt(a(d.el).css("margin-bottom"),10)+1+"px"}).on("click",function(b){"list"==d.type?a(d.helpers.focus).find("input").focus():a(d.el).focus()}),b.css("margin-left","-"+(w2utils.getSize(b,"width")+parseInt(a(d.el).css("margin-right"),10)+2)+"px"),c+=b.width()+3,a(d.el).css("padding-right",c+"px"),d.helpers.suffix=b)}},1)},addFocus:function(){var b,c=this,d=(this.options,0);a(c.helpers.focus).remove();var e=a(c.el).attr("tabIndex");e&&e!=-1&&(c.el._tabIndex=e),c.el._tabIndex&&(e=c.el._tabIndex),null==e&&(e=-1);var f='
    ';a(c.el).attr("tabindex",-1).before(f);var g=a(c.el).prev();c.helpers.focus=g,g.css({width:a(c.el).width(),"margin-top":a(c.el).css("margin-top"),"margin-left":parseInt(a(c.el).css("margin-left"))+parseInt(a(c.el).css("padding-left"))+"px","margin-bottom":a(c.el).css("margin-bottom"),"margin-right":a(c.el).css("margin-right")}).find("input").css({cursor:"default",width:"100%",outline:"none",opacity:1,margin:0,border:"1px solid transparent",padding:a(c.el).css("padding-top"),"padding-left":0,"margin-left":d>0?d+6:0,"background-color":"transparent"}),g.find("input").on("click",function(b){0===a("#w2ui-overlay").length&&c.focus(b),b.stopPropagation()}).on("focus",function(d){b=a(c.el).attr("placeholder"),a(c.el).css({outline:"auto 5px #7DB4F3","outline-offset":"-2px"}),a(this).val(""),a(c.el).triggerHandler("focus"),d.stopPropagation?d.stopPropagation():d.cancelBubble=!0}).on("blur",function(d){a(c.el).css("outline","none"),a(this).val(""),c.refresh(),a(c.el).triggerHandler("blur"),d.stopPropagation?d.stopPropagation():d.cancelBubble=!0,null!=b&&a(c.el).attr("placeholder",b)}).on("keydown",function(d){var e=this;c.keyDown(d),setTimeout(function(){""===e.value?a(c.el).attr("placeholder",b):a(c.el).attr("placeholder","")},10)}).on("keyup",function(a){c.keyUp(a)}).on("keypress",function(a){c.keyPress(a)}),g.on("click",function(b){a(this).find("input").focus()}),c.refresh()},addMulti:function(){var b=this;this.options;a(b.helpers.multi).remove();var c="",d="margin-top : 0px; margin-bottom : 0px; margin-left : "+a(b.el).css("margin-left")+"; margin-right : "+a(b.el).css("margin-right")+"; width : "+(w2utils.getSize(b.el,"width")-parseInt(a(b.el).css("margin-left"),10)-parseInt(a(b.el).css("margin-right"),10))+"px;";if("enum"==b.type){var e=a(b.el).attr("tabIndex");e&&e!=-1&&(b.el._tabIndex=e),b.el._tabIndex&&(e=b.el._tabIndex),null==e&&(e=-1),c='
    '}"file"==b.type&&(c='
    ');var f=a(b.el).data("tmp")||{};f["old-background-color"]=a(b.el).css("background-color"),f["old-border-color"]=a(b.el).css("border-color"),a(b.el).data("tmp",f),a(b.el).before(c).css({"background-color":"transparent","border-color":"transparent"});var g=a(b.el).prev();b.helpers.multi=g,"enum"==b.type&&(a(b.el).attr("tabindex",-1),g.find("input").on("click",function(c){0===a("#w2ui-overlay").length&&b.focus(c),a(b.el).triggerHandler("click")}).on("focus",function(c){a(g).css({outline:"auto 5px #7DB4F3","outline-offset":"-2px"}),a(b.el).triggerHandler("focus"),c.stopPropagation?c.stopPropagation():c.cancelBubble=!0}).on("blur",function(c){a(g).css("outline","none"),a(b.el).triggerHandler("blur"),c.stopPropagation?c.stopPropagation():c.cancelBubble=!0}).on("keyup",function(a){b.keyUp(a)}).on("keydown",function(a){b.keyDown(a)}).on("keypress",function(a){b.keyPress(a)}),g.on("click",function(b){a(this).find("input").focus()})),"file"==b.type&&(a(b.el).css("outline","none"),g.on("click",function(c){a(b.el).focus(),a(b.el).prop("readonly")||a(b.el).prop("disabled")||(b.blur(c),b.resize(),setTimeout(function(){g.find("input").click()},10))}).on("dragenter",function(c){a(b.el).prop("readonly")||a(b.el).prop("disabled")||a(g).addClass("w2ui-file-dragover")}).on("dragleave",function(c){if(!a(b.el).prop("readonly")&&!a(b.el).prop("disabled")){var d=a(c.target).parents(".w2ui-field-helper");0===d.length&&a(g).removeClass("w2ui-file-dragover")}}).on("drop",function(c){if(!a(b.el).prop("readonly")&&!a(b.el).prop("disabled")){a(g).removeClass("w2ui-file-dragover");for(var d=c.originalEvent.dataTransfer.files,e=0,f=d.length;ee.maxFileSize)return c="Maximum file size is "+w2utils.formatSize(e.maxFileSize),e.silent===!1&&a(d.el).w2tag(c),void console.log("ERROR: "+c);if(0!==e.maxSize&&h+g.size>e.maxSize)return c="Maximum total size is "+w2utils.formatSize(e.maxSize),e.silent===!1&&a(d.el).w2tag(c),void console.log("ERROR: "+c);if(0!==e.max&&i>=e.max)return c="Maximum number of files is "+e.max,e.silent===!1&&a(d.el).w2tag(c),void console.log("ERROR: "+c);if(f.push(g),"undefined"!=typeof FileReader&&e.readContent===!0){var l=new FileReader;l.onload=function(){return function(b){var c=b.target.result,e=c.indexOf(",");g.content=c.substr(e+1),d.refresh(),a(d.el).trigger("change"),d.trigger(a.extend(k,{phase:"after"}))}}(),l.readAsDataURL(b)}else d.refresh(),a(d.el).trigger("change")}},normMenu:function(b){if(a.isArray(b)){for(var c=0;c12&&(a-=12,b++),(a<1||0===a)&&(a+=12,b--),b/4==Math.floor(b/4)?f[1]="29":f[1]="28",j.current=a+"/"+b,d=new Date(b,a-1,1);for(var k=d.getDay(),l="",m=0;m'+i[m]+"";var n='
    '+e[a-1]+", "+b+'
    '+l+"",o=1;if("M"!=w2utils.settings.weekStarts&&k++,"datetime"===this.type){var p=w2utils.isDateTime(c,j.format,!0);c=w2utils.formatDate(p,w2utils.settings.dateFormat)}for(var q=1;q<43;q++){if(0===k&&1==q){for(var r=0;r<6;r++)n+='';q+=6}else if(qf[a-1]){n+='',q%7===0&&(n+="");continue}var s=b+"/"+a+"/"+o,t=new Date(s),u="";6===t.getDay()&&(u=" w2ui-saturday"),0===t.getDay()&&(u=" w2ui-sunday"),s==g&&(u+=" w2ui-today");var v,w,x=o,y="",z="";if("datetime"===this.type?(v=w2utils.formatDateTime(s,j.format),w=w2utils.formatDate(s,w2utils.settings.dateFormat)):(v=w2utils.formatDate(s,j.format),w=v),j.colored&&void 0!==j.colored[w]){var A=j.colored[w].split(":");z="background-color: "+A[0]+";",y="color: "+A[1]+";"}n+='",(q%7===0||0===k&&1==q)&&(n+=""),o++}return n+="
      
    '+x+"
    "},getYearHTML:function(){for(var a=w2utils.settings.shortmonths,b=w2utils.settings.dateStartYear,c=w2utils.settings.dateEndYear,d="",e="",f=0;f'+a[f]+"";for(var g=b;g<=c;g++)e+='
    '+g+"
    ";return"
    "+d+"
    "+e+"
    "},getHourHTML:function(){var a=[],b=this.options;null==b&&(b={format:w2utils.settings.timeFormat});for(var c=b.format.indexOf("h24")>-1,d=0;d<24;d++){var e=(d>=12&&!c?d-12:d)+":00"+(c?"":d<12?" am":" pm");12!=d||c||(e="12:00 pm"),a[Math.floor(d/8)]||(a[Math.floor(d/8)]="");var f=this.fromMin(this.toMin(e)),g=this.fromMin(this.toMin(e)+59);if("datetime"===this.type){var h=w2utils.isDateTime(this.el.value,b.format,!0),i=b.format.split("|")[0].trim();f=w2utils.formatDate(h,i)+" "+f,g=w2utils.formatDate(h,i)+" "+g}a[Math.floor(d/8)]+='
    '+e+"
    "}var j='
    '+w2utils.lang("Select Hour")+'
    '+a[0]+" "+a[1]+" "+a[2]+"
    ";return j},getMinHTML:function(a){null==a&&(a=0);var b=this.options;null==b&&(b={format:w2utils.settings.timeFormat});for(var c=b.format.indexOf("h24")>-1,d=[],e=0;e<60;e+=5){var f=(a>12&&!c?a-12:a)+":"+(e<10?0:"")+e+" "+(c?"":a<12?"am":"pm"),g=f,h=e<20?0:e<40?1:2;if(d[h]||(d[h]=""),"datetime"===this.type){var i=w2utils.isDateTime(this.el.value,b.format,!0),j=b.format.split("|")[0].trim();g=w2utils.formatDate(i,j)+" "+g}d[h]+='
    '+f+"
    "}var k='
    '+w2utils.lang("Select Minute")+'
    '+d[0]+" "+d[1]+" "+d[2]+"
    ";return k},toMin:function(a){if("string"!=typeof a)return null;var b=a.split(":");return 2!==b.length?null:(b[0]=parseInt(b[0]),b[1]=parseInt(b[1]),a.indexOf("pm")!=-1&&12!=b[0]&&(b[0]+=12),60*b[0]+b[1])},fromMin:function(a){var b="";a>=1440&&(a%=1440),a<0&&(a=1440+a);var c=Math.floor(a/60),d=(a%60<10?"0":"")+a%60,e=this.options;return null==e&&(e={format:w2utils.settings.timeFormat}),b=e.format.indexOf("h24")!=-1?c+":"+d:(c<=12?c:c-12)+":"+d+" "+(c>=12?"pm":"am")}},a.extend(b.prototype,w2utils.event),w2obj.field=b}(jQuery),function($){var w2form=function(a){this.name=null,this.header="",this.box=null,this.url="",this.routeData={},this.formURL="",this.formHTML="",this.page=0,this.recid=0,this.fields=[],this.actions={},this.record={},this.original={},this.postData={},this.httpHeaders={},this.method=null,this.toolbar={},this.tabs={},this.style="",this.focus=0,this.isGenerated=!1,this.last={xhr:null},$.extend(!0,this,w2obj.form,a)};$.fn.w2form=function(a){if($.isPlainObject(a)){var b=this;if(!w2utils.checkName(a,"w2form"))return;var c=a.record,d=a.original,e=a.fields,f=a.toolbar,g=a.tabs,h=new w2form(a);if($.extend(h,{record:{},original:{},fields:[],tabs:{},toolbar:{},handlers:[]}),$.isArray(g)){$.extend(!0,h.tabs,{tabs:[]});for(var i=0;i0&&(h.box=b[0]),""!==h.formURL?$.get(h.formURL,function(a){h.formHTML=a,h.isGenerated=!0,0===$(h.box).length&&0===a.length||($(h.box).html(a),h.render(h.box))}):""!==h.formHTML||(0!==$(this).length&&""!==$.trim($(this).html())?h.formHTML=$(this).html():h.formHTML=h.generateHTML()),w2ui[h.name]=h,""===h.formURL&&(String(h.formHTML).indexOf("w2ui-page")==-1&&(h.formHTML='
    '+h.formHTML+"
    "),$(h.box).html(h.formHTML),h.isGenerated=!0,h.render(h.box)),h}var b=w2ui[$(this).attr("name")];return b?arguments.length>0?(b[a]&&b[a].apply(b,Array.prototype.slice.call(arguments,1)),this):b:null},w2form.prototype={onRequest:null,onLoad:null,onValidate:null,onSubmit:null,onProgress:null,onSave:null,onChange:null,onRender:null,onRefresh:null,onResize:null,onDestroy:null,onAction:null,onToolbar:null,onError:null,msgNotJSON:"Returned data is not in valid JSON format.",msgAJAXerror:"AJAX error. See console for more details.",msgRefresh:"Refreshing...",msgSaving:"Saving...",get:function(a,b){if(0===arguments.length){for(var c=[],d=0;d0&&this.refresh(),a},hide:function(){for(var a=0,b=0;b0&&this.refresh(),a},enable:function(){for(var a=0,b=0;b0&&this.refresh(),a},disable:function(){for(var a=0,b=0;b0&&this.refresh(),a},reload:function(a){var b="object"!=typeof this.url?this.url:this.url.get;b&&0!==this.recid&&null!=this.recid?this.request(a):"function"==typeof a&&a()},clear:function(){this.recid=0,this.record={},$().w2tag(),this.refresh()},error:function(a){var b=this,c=this.trigger({target:this.name,type:"error",message:a,xhr:this.last.xhr});return c.isCancelled===!0?void("function"==typeof callBack&&callBack()):(setTimeout(function(){b.message(a)},1),void this.trigger($.extend(c,{phase:"after"})))},message:function(a){"string"==typeof a&&(a={width:a.length<300?350:550,height:a.length<300?170:250,body:'
    '+a+"
    ",buttons:'",onOpen:function(a){setTimeout(function(){$(a.box).find(".w2ui-btn").focus()},25)}}),w2utils.message.call(this,{box:this.box,path:"w2ui."+this.name,title:".w2ui-form-header:visible",body:".w2ui-form-box"},a)},validate:function(a){null==a&&(a=!0),$().w2tag();for(var b=[],c=0;c0)for(var k=0;k
    '),setTimeout(function(){var params={};params.cmd="save",params.recid=obj.recid,params.name=obj.name,$.extend(params,obj.postData),$.extend(params,postData),obj.fields.forEach(function(a){"file"==a.type&&Array.isArray(obj.record[a.field])&&obj.record[a.field].forEach(function(a){delete a.file})}),params.record=$.extend(!0,{},obj.record);var edata=obj.trigger({phase:"before",type:"submit",target:obj.name,url:obj.url,postData:params,httpHeaders:obj.httpHeaders});if(edata.isCancelled!==!0){var url=edata.url;if("object"==typeof edata.url&&edata.url.save&&(url=edata.url.save),obj.last.xhr)try{obj.last.xhr.abort()}catch(a){}if(!$.isEmptyObject(obj.routeData)){var info=w2utils.parseRoute(url);if(info.keys.length>0)for(var k=0;k';switch(g.type){case"pass":case"password":h='';break;case"checkbox":h='';break;case"radio":h="";var i=g.options.items?g.options.items:g.html.items;$.isArray(i)||(i=[]),i.length>0&&(i=w2obj.field.prototype.normMenu(i));for(var j=0;j '+i[j].text+"
    ";break;case"select":h='";break;case"textarea":h='';break;case"toggle":h='
    ';break;case"html":case"custom":case"empty":h=""}""!==e&&(a!=g.html.page||b!=g.html.column||g.html.group&&e!=g.html.group)&&(d[a][b]+="\n ",e=""),g.html.group&&e!=g.html.group&&(c+='\n
    '+g.html.group+'
    \n
    ',e=g.html.group),c+='\n
    \n \n
    "+h+w2utils.lang(g.html.text)+"
    \n
    ",null==d[g.html.page]&&(d[g.html.page]=[]),null==d[g.html.page][g.html.column]&&(d[g.html.page][g.html.column]=""),d[g.html.page][g.html.column]+=c,a=g.html.page,b=g.html.column}if(""!==e&&(d[a][b]+="\n
    "),this.tabs.tabs)for(var j=0;j'+w2utils.lang(n.caption)+""}k+="\n"}c="";for(var o=0;o
    ';for(var p=0;p'+(d[o][p]||"")+"\n
    ";c+="\n"}return c+=k},action:function(a,b){var c=this.actions[a],d=c;$.isPlainObject(c)&&c.onClick&&(d=c.onClick);var e=this.trigger({phase:"before",target:a,type:"action",click:d,originalEvent:b});e.isCancelled!==!0&&("function"==typeof d&&d.call(this,b),this.trigger($.extend(e,{phase:"after"})))},resize:function(){function a(){d.width($(b.box).width()).height($(b.box).height()),f.css("top",""!==b.header?w2utils.getSize(e,"height"):0),g.css("top",(""!==b.header?w2utils.getSize(e,"height"):0)+("object"==typeof b.toolbar&&$.isArray(b.toolbar.items)&&b.toolbar.items.length>0?w2utils.getSize(f,"height"):0)),h.css("top",(""!==b.header?w2utils.getSize(e,"height"):0)+("object"==typeof b.toolbar&&$.isArray(b.toolbar.items)&&b.toolbar.items.length>0?w2utils.getSize(f,"height")+5:0)+("object"==typeof b.tabs&&$.isArray(b.tabs.tabs)&&b.tabs.tabs.length>0?w2utils.getSize(g,"height")+5:0)),h.css("bottom",k.length>0?w2utils.getSize(k,"height"):0)}var b=this,c=this.trigger({phase:"before",target:this.name,type:"resize"});if(c.isCancelled!==!0){var d=$(this.box).find("> div.w2ui-form-box"),e=$(this.box).find("> div .w2ui-form-header"),f=$(this.box).find("> div .w2ui-form-toolbar"),g=$(this.box).find("> div .w2ui-form-tabs"),h=$(this.box).find("> div .w2ui-page"),i=$(this.box).find("> div .w2ui-page.page-"+this.page),j=$(this.box).find("> div .w2ui-page.page-"+this.page+" > div"),k=$(this.box).find("> div .w2ui-buttons");a(),0!==parseInt($(this.box).height())&&$(this.box).data("auto-size")!==!0||($(this.box).height((e.length>0?w2utils.getSize(e,"height"):0)+("object"==typeof this.tabs&&$.isArray(this.tabs.tabs)&&this.tabs.tabs.length>0?w2utils.getSize(g,"height"):0)+("object"==typeof this.toolbar&&$.isArray(this.toolbar.items)&&this.toolbar.items.length>0?w2utils.getSize(f,"height"):0)+(h.length>0?w2utils.getSize(j,"height")+w2utils.getSize(i,"+height")+12:0)+(k.length>0?w2utils.getSize(k,"height"):0)),$(this.box).data("auto-size",!0)),a(),this.toolbar&&this.toolbar.resize&&this.toolbar.resize(),this.tabs&&this.tabs.resize&&this.tabs.resize(),b.trigger($.extend(c,{phase:"after"}))}},refresh:function(a){var b=(new Date).getTime(),c=this;if(this.box&&this.isGenerated&&null!=$(this.box).html()){var d=this.trigger({phase:"before",target:this.name,type:"refresh",page:this.page,field:a});if(d.isCancelled!==!0){if(null!=a)var e=c.get(a,!0),f=e+1;else{$(this.box).find("input, textarea, select").each(function(a,b){var d=null!=$(b).attr("name")?$(b).attr("name"):$(b).attr("id"),e=c.get(d);if(e){var f=$(b).parents(".w2ui-page");if(f.length>0)for(var g=0;g<100;g++)if(f.hasClass("page-"+g)){e.page=g;break}}}),$(this.box).find(".w2ui-page").hide(),$(this.box).find(".w2ui-page.page-"+this.page).show(),$(this.box).find(".w2ui-form-header").html(this.header),"object"==typeof this.tabs&&$.isArray(this.tabs.tabs)&&this.tabs.tabs.length>0?($("#form_"+this.name+"_tabs").show(),this.tabs.active=this.tabs.tabs[this.page].id,this.tabs.refresh()):$("#form_"+this.name+"_tabs").hide(),"object"==typeof this.toolbar&&$.isArray(this.toolbar.items)&&this.toolbar.items.length>0?($("#form_"+this.name+"_toolbar").show(),this.toolbar.refresh()):$("#form_"+this.name+"_toolbar").hide();var e=0,f=this.fields.length}for(var g=e;g0){var j=$(d.el).data("w2field").helpers.multi;$(j).removeClass("w2ui-error")}(""===i||null==i||$.isArray(i)&&0===i.length||$.isPlainObject(i)&&$.isEmptyObject(i))&&(i=null),c.record[this.name]=i,c.trigger($.extend(h,{phase:"after"}))}}),a.required?$(a.el).parent().parent().addClass("w2ui-required"):$(a.el).parent().parent().removeClass("w2ui-required"),null!=a.disabled&&(a.disabled?$(a.el).prop("readonly",!0):$(a.el).prop("readonly",!1)),a.hidden?$(a.el).parent().parent().hide():$(a.el).parent().parent().show()}$(this.box).find("button, input[type=button]").each(function(a,b){$(b).off("click").on("click",function(a){var b=this.value;this.id&&(b=this.id),this.name&&(b=this.name),c.action(b,a)})});for(var g=e;g0&&!$.isPlainObject(k[0])&&(a.options.items=w2obj.field.prototype.normMenu(k));for(var l=0;l0){k=w2obj.field.prototype.normMenu(k),$(a.el).html("");for(var n=0;n'+k[n].text+" *").length>1&&$(h[l]).wrapInner("
    ");return this.trigger($.extend(d,{phase:"after"})),this.resize(),(new Date).getTime()-b}}},render:function(a){function b(){var a=$(d.box).find("div:not(.w2ui-field-helper) > input, select, textarea, div > label:nth-child(1) > :radio").not(".file-input");a.length>d.focus&&a[d.focus].focus()}var c=(new Date).getTime(),d=this;if("object"==typeof a&&($(this.box).find("#form_"+this.name+"_tabs").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),this.box=a),this.isGenerated&&this.box){var e=this.trigger({phase:"before",target:this.name,type:"render",box:null!=a?a:this.box});if(e.isCancelled!==!0){$.isEmptyObject(this.original)&&!$.isEmptyObject(this.record)&&(this.original=$.extend(!0,{},this.record));var f='
    '+(""!==this.header?'
    '+this.header+"
    ":"")+' '+this.formHTML+"
    ";$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-form").html(f),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),"function"!=typeof this.toolbar.render&&(this.toolbar=$().w2toolbar($.extend({},this.toolbar,{name:this.name+"_toolbar",owner:this})),this.toolbar.on("click",function(a){var b=d.trigger({phase:"before",type:"toolbar",target:a.target,originalEvent:a});b.isCancelled!==!0&&d.trigger($.extend(b,{phase:"after"}))})),"object"==typeof this.toolbar&&"function"==typeof this.toolbar.render&&this.toolbar.render($("#form_"+this.name+"_toolbar")[0]),"function"!=typeof this.tabs.render&&(this.tabs=$().w2tabs($.extend({},this.tabs,{name:this.name+"_tabs",owner:this,active:this.tabs.active})),this.tabs.on("click",function(a){d.goto(this.get(a.target,!0))})),"object"==typeof this.tabs&&"function"==typeof this.tabs.render&&(this.tabs.render($("#form_"+this.name+"_tabs")[0]),this.tabs.active&&this.tabs.click(this.tabs.active)),this.trigger($.extend(e,{phase:"after"})),this.resize();var g="object"!=typeof this.url?this.url:this.url.get;return g&&0!==this.recid&&null!=this.recid?this.request():this.refresh(),0===$(".w2ui-layout").length&&(this.tmp_resize=function(a){w2ui[d.name].resize()},$(window).off("resize","body").on("resize","body",this.tmp_resize)),this.focus>=0&&setTimeout(function(){0===$(d.box).find("input, select, textarea").length?setTimeout(b,500):b()},10),(new Date).getTime()-c}}},destroy:function(){var a=this.trigger({phase:"before",target:this.name,type:"destroy"});a.isCancelled!==!0&&("object"==typeof this.toolbar&&this.toolbar.destroy&&this.toolbar.destroy(),"object"==typeof this.tabs&&this.tabs.destroy&&this.tabs.destroy(),$(this.box).find("#form_"+this.name+"_tabs").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),delete w2ui[this.name],this.trigger($.extend(a,{phase:"after"})),$(window).off("resize","body"))}},$.extend(w2form.prototype,w2utils.event),w2obj.form=w2form}(jQuery);