From 41daf4fbcd4dec3a5491a5e19281c654ea3dcad6 Mon Sep 17 00:00:00 2001 From: Vitali Malinouski Date: Sun, 24 Jan 2016 22:17:37 -0800 Subject: [PATCH] Recompiled JS --- dist/w2ui.js | 65 +++++++++++++++++++++++++++++++----------------- dist/w2ui.min.js | 22 ++++++++-------- 2 files changed, 53 insertions(+), 34 deletions(-) diff --git a/dist/w2ui.js b/dist/w2ui.js index 19d7957d2..5cbbb2a46 100644 --- a/dist/w2ui.js +++ b/dist/w2ui.js @@ -2863,6 +2863,7 @@ w2utils.event = { * - disableCVS * - grid.message * - added noReset option to localSort() +* - onColumnSelect * ************************************************************************/ @@ -4059,6 +4060,8 @@ w2utils.event = { }; $(document).off('mousemove', mouseMove).on('mousemove', mouseMove); $(document).off('mouseup', mouseStop).on('mouseup', mouseStop); + // do not blur grid + event.preventDefault(); } function mouseMove (event) { @@ -5811,11 +5814,14 @@ w2utils.event = { } else { cols.push(column); } - // -- - for (var i = 0; i < this.records.length; i++) { - sel.push({ recid: this.records[i].recid, column: cols }); + var edata = this.trigger({ phase: 'before', type: 'columnSelect', target: this.name, columns: cols }); + if (edata.isCancelled !== true) { + for (var i = 0; i < this.records.length; i++) { + sel.push({ recid: this.records[i].recid, column: cols }); + } + this.select.apply(this, sel); } - this.select.apply(this, sel); + this.trigger($.extend(edata, { phase: 'after' })); } } // event after @@ -7122,6 +7128,7 @@ w2utils.event = { w2ui[obj.name].keydown.call(w2ui[obj.name], event); }); // init mouse events for mouse selection + var edataCol; // event for column select $(this.box).on('mousedown', mouseStart); // event after this.trigger($.extend(edata, { phase: 'after' })); @@ -7179,6 +7186,7 @@ w2utils.event = { ghost : false, start : true }; + if (obj.last.move.recid == null) obj.last.move.type = 'select-column'; // set focus to grid var target = event.target; setTimeout(function () { @@ -7242,7 +7250,7 @@ w2utils.event = { function mouseMove (event) { var mv = obj.last.move; - if (!mv || mv.type != 'select') return; + if (!mv || ['select', 'select-column'].indexOf(mv.type) == -1) return; mv.divX = (event.screenX - mv.x); mv.divY = (event.screenY - mv.y); if (Math.abs(mv.divX) <= 1 && Math.abs(mv.divY) <= 1) return; // only if moved more then 1px @@ -7277,6 +7285,7 @@ w2utils.event = { if (recid == null) { // select by dragging columns if (obj.selectType == 'row') return; + if (obj.last.move && obj.last.move.type == 'select') return; var col = parseInt($(event.target).parents('td').attr('col')); if (isNaN(col)) { obj.removeRange('column-selection'); @@ -7288,23 +7297,32 @@ w2utils.event = { var newRange = col + '-' + col; if (mv.column < col) newRange = mv.column + '-' + col; if (mv.column > col) newRange = col + '-' + mv.column; - if (mv.colRange == null) obj.selectNone(); - // highlight columns - var tmp = newRange.split('-'); - $(obj.box).find('.w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header').removeClass('w2ui-col-selected'); - for (var j = parseInt(tmp[0]); j <= parseInt(tmp[1]); j++) { - $(obj.box).find('#grid_'+ obj.name +'_column_' + j + ' .w2ui-col-header').addClass('w2ui-col-selected'); + // array of selected columns + var cols = []; + var tmp = newRange.split('-'); + for (var ii = parseInt(tmp[0]); ii <= parseInt(tmp[1]); ii++) { + cols.push(ii) } - $(obj.box).find('.w2ui-col-number').not('.w2ui-head').addClass('w2ui-row-selected'); - // show new range if (mv.colRange != newRange) { - mv.colRange = newRange; - obj.removeRange('column-selection'); - obj.addRange({ - name : 'column-selection', - range : [{ recid: obj.records[0].recid, column: tmp[0] }, { recid: obj.records[obj.records.length-1].recid, column: tmp[1] }], - style : 'background-color: rgba(90, 145, 234, 0.1)' - }); + edataCol = obj.trigger({ phase: 'before', type: 'columnSelect', target: obj.name, columns: cols, isCancelled: false }); // initial isCancelled + if (edataCol.isCancelled !== true) { + if (mv.colRange == null) obj.selectNone(); + // highlight columns + var tmp = newRange.split('-'); + $(obj.box).find('.w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header').removeClass('w2ui-col-selected'); + for (var j = parseInt(tmp[0]); j <= parseInt(tmp[1]); j++) { + $(obj.box).find('#grid_'+ obj.name +'_column_' + j + ' .w2ui-col-header').addClass('w2ui-col-selected'); + } + $(obj.box).find('.w2ui-col-number').not('.w2ui-head').addClass('w2ui-row-selected'); + // show new range + mv.colRange = newRange; + obj.removeRange('column-selection'); + obj.addRange({ + name : 'column-selection', + range : [{ recid: obj.records[0].recid, column: tmp[0] }, { recid: obj.records[obj.records.length-1].recid, column: tmp[1] }], + style : 'background-color: rgba(90, 145, 234, 0.1)' + }); + } } } @@ -7372,8 +7390,8 @@ w2utils.event = { var mv = obj.last.move; setTimeout(function () { delete obj.last.cancelClick; }, 1); if ($(event.target).parents().hasClass('.w2ui-head') || $(event.target).hasClass('.w2ui-head')) return; - if (mv && mv.type == 'select') { - if (mv.colRange != null) { + if (mv && ['select', 'select-column'].indexOf(mv.type) != -1) { + if (mv.colRange != null && edataCol.isCancelled !== true) { var tmp = mv.colRange.split('-'); var sel = []; for (var i = 0; i < obj.records.length; i++) { @@ -7381,8 +7399,9 @@ w2utils.event = { for (var j = parseInt(tmp[0]); j <= parseInt(tmp[1]); j++) cols.push(j); sel.push({ recid: obj.records[i].recid, column: cols }); } - obj.select.apply(obj, sel); obj.removeRange('column-selection'); + obj.trigger($.extend(edataCol, { phase: 'after' })); + obj.select.apply(obj, sel); } if (obj.reorderRows == true && obj.last.move.reorder) { // event diff --git a/dist/w2ui.min.js b/dist/w2ui.min.js index 75db51e9b..d0ad80216 100644 --- a/dist/w2ui.min.js +++ b/dist/w2ui.min.js @@ -1,14 +1,14 @@ /* w2ui 1.5.x (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?!1: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;j>i;i++){var k=w2utils.settings.fullmonths[i];a=a.replace(new RegExp(k,"ig"),parseInt(i)+1).replace(new RegExp(k.substr(0,3),"ig"),parseInt(i)+1)}}var l=a.replace(/-/g,"/").replace(/\./g,"/").toLowerCase().split("/"),m=b.replace(/-/g,"/").replace(/\./g,"/").toLowerCase();"mm/dd/yyyy"===m&&(e=l[0],f=l[1],g=l[2]),"m/d/yyyy"===m&&(e=l[0],f=l[1],g=l[2]),"dd/mm/yyyy"===m&&(e=l[1],f=l[0],g=l[2]),"d/m/yyyy"===m&&(e=l[1],f=l[0],g=l[2]),"yyyy/dd/mm"===m&&(e=l[2],f=l[1],g=l[0]),"yyyy/d/m"===m&&(e=l[2],f=l[1],g=l[0]),"yyyy/mm/dd"===m&&(e=l[1],f=l[2],g=l[0]),"yyyy/m/d"===m&&(e=l[1],f=l[2],g=l[0]),"mm/dd/yy"===m&&(e=l[0],f=l[1],g=l[2]),"m/d/yy"===m&&(e=l[0],f=l[1],g=parseInt(l[2])+1900),"dd/mm/yy"===m&&(e=l[1],f=l[0],g=parseInt(l[2])+1900),"d/m/yy"===m&&(e=l[1],f=l[0],g=parseInt(l[2])+1900),"yy/dd/mm"===m&&(e=l[2],f=l[1],g=parseInt(l[0])+1900),"yy/d/m"===m&&(e=l[2],f=l[1],g=parseInt(l[0])+1900),"yy/mm/dd"===m&&(e=l[1],f=l[2],g=parseInt(l[0])+1900),"yy/m/d"===m&&(e=l[1],f=l[2],g=parseInt(l[0])+1900)}return c(g)&&c(e)&&c(f)?(g=+g,e=+e,f=+f,h=new Date(g,e-1,f),null==e?!1:"Invalid Date"==String(h)?!1:h.getMonth()+1!==e||h.getDate()!==f||h.getFullYear()!==g?!1:d===!0?h:!0):!1}function j(b,c){if(null==b)return!1;var d,e;b=String(b),b=b.toUpperCase(),e=b.indexOf("PM")>=0;var f=e||b.indexOf("AM")>=0;d=f?12:24,b=b.replace("AM","").replace("PM",""),b=a.trim(b);var g=b.split(":"),h=parseInt(g[0]||0),i=parseInt(g[1]||0),j=parseInt(g[2]||0);return f&&1===g.length||2===g.length||3===g.length?""===g[0]||0>h||h>d||!this.isInt(g[0])||g[0].length>2?!1:g.length>1&&(""===g[1]||0>i||i>59||!this.isInt(g[1])||2!==g[1].length)?!1:g.length>2&&(""===g[2]||0>j||j>59||!this.isInt(g[2])||2!==g[2].length)?!1:f||d!==h||0===i&&0===j?f&&1===g.length&&0===h?!1:c===!0?(e&&12!==h&&(h+=12),e||12!==h||(h+=12),{hours:h,minutes:i,seconds:j}):!0:!1:!1}function k(a,b,c){null==b&&(b=w2utils.settings.dateFormat+"|"+w2utils.settings.timeFormat);var d=b.split("|");if("function"==typeof a.getUTCFullYear)return c!==!0?!0:a;if(parseInt(a)==a&&parseInt(a)>0)return a=new Date(parseInt(a)),c!==!0?!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?!0:(g.setHours(h.hours),g.setMinutes(h.minutes),g.setSeconds(h.seconds),g):!1}function l(a){var b;if(""===a||null==a)return"";if("function"==typeof a.getUTCFullYear?b=a:parseInt(a)==a&&parseInt(a)>0?d1=new Date(parseInt(a)):d1=new Date(a),"Invalid Date"==String(d1))return"";var c=new Date,d=(c.getTime()-d1.getTime())/1e3,e="",f="";return 0>d?(e='0 sec',f=""):60>d?(e=Math.floor(d),f="sec",0>d&&(e=0,f="sec")):3600>d?(e=Math.floor(d/60),f="min"):86400>d?(e=Math.floor(d/60/60),f="hour"):2592e3>d?(e=Math.floor(d/24/60/60),f="day"):31536e3>d?(e=Math.floor(d/30/24/60/60*10)/10,f="month"):126144e3>d?(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=1e3>a?"< 1 sec":6e4>a?Math.floor(a/1e3)+" secs":36e5>a?Math.floor(a/6e4)+" mins":864e5>a?Math.floor(a/36e5*10)/10+" hours":2628e6>a?Math.floor(a/864e5*10)/10+" days":31536e6>a?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){var d={minimumFractionDigits:b,maximumFractionDigits:b,useGrouping:c};return(null==b||0>b)&&(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,(10>e+1?"0":"")+(e+1)).replace(/dd/g,(10>f?"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 10>h&&(h="0"+h),10>i&&(i="0"+i),(-1!==b.indexOf("am")||-1!==b.indexOf("pm"))&&(f>=12&&(e="pm"),f>12&&(f-=12)),b.toLowerCase().replace("am",e).replace("pm",e).replace("hhh",10>f?"0"+f:f).replace("hh24",10>g?"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(/\|\/? {}\\])/g,"\\$1")}function w(a){function b(a){a=String(a).replace(/\r\n/g,"\n");for(var b="",c=0;cd?b+=String.fromCharCode(d):d>127&&2048>d?(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 x(a){function b(a){for(var b,c,d="",e=0,f=0;ef?(d+=String.fromCharCode(f),e++):f>191&&224>f?(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 y(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(b){p=0}for(var c,d=p?"0123456789ABCDEF":"0123456789abcdef",e="",f=0;f>>4&15)+d.charAt(15&c);return e}function e(a){for(var b,c,d="",e=-1;++e=55296&&56319>=b&&c>=56320&&57343>=c&&(b=65536+((1023&b)<<10)+(1023&c),e++),127>=b?d+=String.fromCharCode(b):2047>=b?d+=String.fromCharCode(192|b>>>6&31,128|63&b):65535>=b?d+=String.fromCharCode(224|b>>>12&15,128|b>>>6&63,128|63&b):2097151>=b&&(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 z(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 A(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 B(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 C(b,c){var d=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 e=parseInt(a(b.box).width()),f=parseInt(a(b.box).height()),g=parseInt(a(b.box).find(b.title).css("height")||0);c.originalWidth=c.width,c.originalHeight=c.height,parseInt(c.width)<0&&(c.width=e+c.width),parseInt(c.width)<10&&(c.width=10),parseInt(c.height)<0&&(c.height=f+c.height-g),parseInt(c.height)<10&&(c.height=10),null==c.hideOnClick&&(c.hideOnClick=!1);var h=a(b.box).data("options")||{};(null==c.width||c.width>h.width-10)&&(c.width=h.width-10),(null==c.height||c.height>h.height-g-5)&&(c.height=h.height-g-5),c.originalHeight<0&&(c.height=f+c.originalHeight-g),c.originalWidth<0&&(c.width=e+2*c.originalWidth);var i=a(b.box).find(b.title),j=a(b.box).find(".w2ui-message").length;if(""==a.trim(c.html)&&""==a.trim(c.body)&&""==a.trim(c.buttons)){var k=a(b.box).find("#w2ui-message"+(j-1)),c=k.data("options")||{},l=c.trigger({phase:"before",type:"close",target:"self"});if(l.isCancelled===!0)return;k.css(w2utils.cssPrefix({transition:"0.15s",transform:"translateY(-"+c.height+"px)"})),1==j?this.unlock&&this.unlock(150):a(b.box).find("#w2ui-message"+(j-2)).css("z-index",1500),setTimeout(function(){var b=k.data("prev_focus");k.remove(),b&&b.length>0?b.focus():d&&d.focus&&d.focus(),i.css("z-index",i.data("old-z-index")),c.trigger(a.extend(l,{phase:"after"}))},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),i.data("old-z-index",i.css("z-index")),i.css("z-index",1501),a(b.box).find(b.body).before('"),a(b.box).find("#w2ui-message"+j).data("options",c).data("prev_focus",a(":focus"));var m=a(b.box).find("#w2ui-message"+j).css("display");if(a(b.box).find("#w2ui-message"+j).css(w2utils.cssPrefix({transform:"none"==m?"translateY(-"+c.height+"px)":"translateY(0px)"})),"none"==m){a(b.box).find("#w2ui-message"+j).show().html(c.html),c.box=a(b.box).find("#w2ui-message"+j);var l=c.trigger({phase:"before",type:"open",target:"self"});if(l.isCancelled===!0)return i.css("z-index",i.data("old-z-index")),void a(b.box).find("#w2ui-message"+j).remove();setTimeout(function(){a(b.box).find("#w2ui-message"+j).css(w2utils.cssPrefix({transform:"none"==m?"translateY(0px)":"translateY(-"+c.height+"px)"}))},1),0==j&&this.lock&&this.lock(),setTimeout(function(){a(b.box).find("#w2ui-message"+j).css(w2utils.cssPrefix({transition:"0s"})),c.trigger(a.extend(l,{phase:"after"}))},350)}}}function D(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 E(b,c){var d,e='
'+u(b)+"
";return a("body").append(e),d=a("#_tmp_width").width(),a("#_tmp_width").remove(),d}function F(a){var b=this.settings.phrases[a];return null==b?a:b}function G(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,cache:!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 H(){if(O.scrollBarSize)return O.scrollBarSize;var b='
1
';return a("body").append(b),O.scrollBarSize=100-a("#_scrollbar_width > div").width(),a("#_scrollbar_width").remove(),String(navigator.userAgent).indexOf("MSIE")>=0&&(O.scrollBarSize=O.scrollBarSize/2),O.scrollBarSize}function I(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)?!0:(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 J(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 N(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))}}var O={},P={version:"1.5.x",settings:{locale:"en-us",dateFormat:"m/d/yyyy",timeFormat:"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,escapeId:v,base64encode:w,base64decode:x,md5:y,transition:z,lock:A,unlock:B,message:C,lang:F,locale:G,getSize:D,getStrWidth:E,scrollBarSize:H,checkName:I,checkUniqueId:J,parseRoute:K,cssPrefix:L,getCursorPosition:M,setCursorPosition:N,isIOS:-1!=navigator.userAgent.toLowerCase().indexOf("iphone")||-1!=navigator.userAgent.toLowerCase().indexOf("ipod")||-1!=navigator.userAgent.toLowerCase().indexOf("ipad")?!0:!1,isIE:-1!=navigator.userAgent.toLowerCase().indexOf("msie")||-1!=navigator.userAgent.toLowerCase().indexOf("trident")?!0:!1};return P}(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)return"";var c=w2utils.isDateTime(a,b,!0);return""==c&&(c=w2utils.isDate(a,b,!0)),''+w2utils.formatDate(c,b)+""},datetime:function(a,b){if(""==b&&(b=w2utils.settings.dateFormat+"|"+w2utils.settings.timeFormat),null==a||0==a)return"";var c=w2utils.isDateTime(a,b,!0);return""==c&&(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)return"";var c=w2utils.isDateTime(a,b,!0);return""==c&&(c=w2utils.isDate(a,b,!0)),''+w2utils.formatTime(a,b)+""},timestamp:function(a,b){if(""==b&&(b=w2utils.settings.dateFormat+"|"+w2utils.settings.timeFormat),null==a||0==a)return"";var c=w2utils.isDateTime(a,b,!0);return""==c&&(c=w2utils.isDate(a,b,!0)),c.toString?c.toString():""},gmt:function(a,b){if(""==b&&(b=w2utils.settings.dateFormat+"|"+w2utils.settings.timeFormat),null==a||0==a)return"";var c=w2utils.isDateTime(a,b,!0);return""==c&&(c=w2utils.isDate(a,b,!0)),c.toUTCString?c.toUTCString():""},age:function(a,b){if(null==a||0==a)return"";var c=w2utils.isDateTime(a,null,!0);return""==c&&(c=w2utils.isDate(a,null,!0)),''+w2utils.age(a)+(b?" "+b:"")+""},interval:function(a,b){return null==a||0==a?"":w2utils.interval(a)+(b?" "+b:"")},toggle:function(a,b){return a?"Yes":""}},w2utils.event={on:function(a,b){var c=jQuery;if("string"==typeof a&&-1!=a.indexOf(":")){var d=a.split(":");-1!=["complete","done"].indexOf(a[1])&&(a[1]="after"),a={type:d[0],execute:d[1]}}return c.isPlainObject(a)||(a={type:a}),a=c.extend({type:null,execute:"before",target:null,onComplete:null},a),a.type?b?(c.isArray(this.handlers)||(this.handlers=[]),void this.handlers.push({edata:a,handler:b})):void console.log("ERROR: You must specify event handler function when calling .on() method of "+this.name):void console.log("ERROR: You must specify event type when calling .on() method of "+this.name)},off:function(a,b){var c=jQuery;if("string"==typeof a&&-1!=a.indexOf(":")){var d=a.split(":");-1!=["complete","done"].indexOf(a[1])&&(a[1]="after"),a={type:d[0],execute:d[1]}}if(c.isPlainObject(a)||(a={type:a}),a=c.extend({},{type:null,execute:"before",target:null,onComplete:null},a),!a.type)return void console.log("ERROR: You must specify event type when calling .off() method of "+this.name);b||(b=null);for(var e=[],f=0,g=this.handlers.length;g>f;f++){var h=this.handlers[f];(h.edata.type!==a.type&&"*"!==a.type||h.edata.target!==a.target&&null!=a.target||h.edata.execute!==a.execute&&null!=a.execute||h.handler!==b&&null!=b)&&e.push(h)}this.handlers=e},trigger:function(a){var b=jQuery,a=b.extend({type:null,phase:"before",target:null,doneHandlers:[]},a,{isStopped:!1,isCancelled:!1,done:function(a){this.doneHandlers.push(a)},preventDefault:function(){ this.isCancelled=!0},stopPropagation:function(){this.isStopped=!0}});"before"===a.phase&&(a.onComplete=null);var c,d,e;null==a.target&&(a.target=null),b.isArray(this.handlers)||(this.handlers=[]);for(var f=this.handlers.length-1;f>=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(;-1!=b.innerHTML.indexOf('');)b.innerHTML=b.innerHTML.replace(/\(.*)\<\/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",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),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"),a(e).length>0&&(a(e)[0].style.cssText=k),"function"==typeof c.onHide&&c.onHide())}function g(b){var d=a(e).offset();if(0===a(e).length||0===d.left&&0===d.top||0==j.find(".w2ui-tag-body").length)return clearInterval(j.data("timer")),void f();setTimeout(g,100);var h="w2ui-tag-right",i=parseInt(a(e).offset().left+e.offsetWidth+(c.left?c.left:0)),k=parseInt(a(e).offset().top+(c.top?c.top:0)),l=j.find(".w2ui-tag-body"),m=l[0].offsetWidth,n=l[0].offsetHeight;return"top"==c.position&&(h="w2ui-tag-top",i=parseInt(a(e).offset().left+(c.left?c.left:0))-14,k=parseInt(a(e).offset().top+(c.top?c.top:0))-n-10),"bottom"==c.position&&(h="w2ui-tag-bottom",i=parseInt(a(e).offset().left+(c.left?c.left:0))-14,k=parseInt(a(e).offset().top+e.offsetHeight+(c.top?c.top:0))+10),"left"==c.position&&(h="w2ui-tag-left",i=parseInt(a(e).offset().left+(c.left?c.left:0))-m-20,k=parseInt(a(e).offset().top+(c.top?c.top:0))),j.data("position")!==i+"x"+k&&b!==!0&&j.css(w2utils.cssPrefix({transition:".2s"})).css({left:i+"px",top:k+"px"}).data("position",i+"x"+k),{left:i,top:k,posClass:h}}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);else{var k="";a(e).length>0&&(k=a(e)[0].style.cssText),a("body").append('
0?"w2ui-tag-popup":"")+'">
'+b+"
"),j=a("#w2ui-tag-"+i),a(e).data("w2tag",j.get(0))}setTimeout(function(){if(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.widthk&&(k=30),c.tmp.contentHeight&&(j=parseInt(c.tmp.contentHeight),d.height(j),setTimeout(function(){var a=d.find("div.menu");j>a.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&&(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=(k-17)/2,m=c.left,n=c.width,o=c.tipLeft;switch(c.align){case"both":m=17+parseInt(c.left),0===c.width&&(c.width=w2utils.getSize(a(g),"width")),c.maxWidth&&c.width>c.maxWidth&&(c.width=c.maxWidth);break;case"left":m=17+parseInt(c.left);break;case"right":m=w2utils.getSize(a(g),"width")-k+14+parseInt(c.left),o=k-40}n=30!==k||n?c.width?c.width:"auto":30,25>l&&(m=25-l,o=Math.floor(l));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)+m,q=s.top+w2utils.getSize(g,"height")+c.top+7,r=s.top}b.css({left:p+"px",top:q+"px","min-width":n,"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-c.pageY-15,u=window.innerWidth-c.pageX),t>-50&&210>t||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(o)+"px; }#w2ui-overlay"+h+":after { margin-left: "+parseInt(o)+"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(o)+"px; }#w2ui-overlay"+h+":after { margin-left: "+parseInt(o)+"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),-1!=["INPUT","TEXTAREA","SELECT"].indexOf(b.target.tagName.toUpperCase())||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),(d>e||e+b.height()>d+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=j&&(c.index=-1)}a(h).w2menu("refresh",c),d()}function f(){if(c.spinner)return'
'+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+"
"}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;-1!=["radio","check"].indexOf(c.type)&&(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"),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(-1!=["text","password"].indexOf(a(h)[0].type)||"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),(j>p||p+o.height()>j+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+="",2>c&&(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.toolbar={},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:!0,statusSearch:!0,recordTitles:!0,selectionBorder:!0,skipRecords:!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.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.toolbar,j=new w2grid(a);if($.extend(j,{postData:{},records:[],columns:[],searches:[],toolbar:{},sortData:[],searchData:[],handlers:[]}),null!=j.onExpand&&(j.show.expandColumn=!0),$.extend(!0,j.toolbar,i),b)for(var k=0;k0?(r[a]&&r[a].apply(r,Array.prototype.slice.call(arguments,1)),this):r: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.",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","less:less than","more:more than"],date:["is","between","less:before","more:after"],list:["is"],"enum":["in","not in"]},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,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(),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.refresh(),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.refresh(),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.refresh(),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:b>a?-e:0}var i="object"!=typeof this.url?this.url:this.url.get;if(i)return void console.log("ERROR: grid.localSort can only be used on local data source, grid.url should be empty.");if(!$.isEmptyObject(this.sortData)){var j=(new Date).getTime(),k=this;k.selectionSave(),k.prepareData(),b||k.reset();for(var l=0;l=parseFloat(k)&&parseFloat(f.parseField(a,h.field))<=parseFloat(l)&&c++,"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&&l>j&&c++}if("time"==h.type){var j=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),k=w2utils.isTime(k,!0),l=w2utils.isTime(l,!0);k=(new Date).setHours(k.hours,k.minutes,k.seconds?k.seconds:0,0),l=(new Date).setHours(l.hours,l.minutes,l.seconds?l.seconds:0,0),j>=k&&l>j&&c++}break;case"less":if(-1!=["int","float","money","currency","percent"].indexOf(h.type))parseFloat(f.parseField(a,h.field))<=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");k>=j&&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");k>=j&&c++}break;case"more":if(-1!=["int","float","money","currency","percent"].indexOf(h.type))parseFloat(f.parseField(a,h.field))>=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++}break;case"in":var m=e.value;e.svalue&&(m=e.svalue),-1!==m.indexOf(w2utils.isFloat(j)?parseFloat(j):j)&&c++,-1!==m.indexOf(w2utils.isFloat(i)?parseFloat(i):i)&&c++;break;case"not in":var m=e.value;e.svalue&&(m=e.svalue),-1==m.indexOf(w2utils.isFloat(j)?parseFloat(j):j)&&c++,-1==m.indexOf(w2utils.isFloat(i)?parseFloat(i):i)&&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);-1!==n&&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=h;h++){var i=this.records[h],j=i[this.columns[e].field]||null;b!==!0?g.push(j):g.push({data:j,column:e,index:h,record:i})}else if(c==d)for(var i=this.records[c],k=e;f>=k;k++){var j=i[this.columns[k].field]||null;b!==!0?g.push(j):g.push({data:j,column:k,index:c,record:i})}else for(var h=c;d>=h;h++){var i=this.records[h];g.push([]);for(var k=e;f>=k;k++){var j=i[this.columns[k].field];b!==!0?g[g.length-1].push(j):g[g.length-1].push({data:j,column:k,index:h,record:i})}}return g},addRange:function(a){var b=0;if("row"==this.selectType)return b;$.isArray(a)||(a=[a]);for(var c=0;c=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)}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(-1!=b.indexes.indexOf(g))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]||[];-1==b.indexes.indexOf(g)&&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;ff;f++)d.indexes.push(f),"row"!=this.selectType&&(d.columns[f]=e.slice())}else for(var 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:y};d.push(v)}}}else for(var j=0;j0&&b[0].focus()}})}},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(),null!=b&&c.focus()}else{var d=this.getSearch(a);if(null==d)return;var e=d.type;-1!=["enum","select"].indexOf(e)&&(e="list"),c.w2field(e,$.extend({},d.options,{suffix:"",autoFormat:!1,selected:b})),-1!=["list","enum","date","time"].indexOf(d.type)&&(this.last.search="",this.last.item="",c.val("")),setTimeout(function(){null!=b&&c.focus()},1)}""!=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",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)+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});if(f.isCancelled===!0)return void("function"==typeof d&&d({status:"error",message:"Request aborted."}))}else var f={url:c,postData:e};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(i){}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 j=w2utils.parseRoute(c);if(j.keys.length>0)for(var k=0;kc.width()&&c.width(e+20)}catch(g){}}var f=this,g=f.get(a,!0),h=f.records[g],i=f.columns[b],j=i.frozen===!0?"_f":"_",k=h&&h.w2ui?h.w2ui.editable:null;if((null==k||k===!0)&&(k=i?i.editable:null),h&&i&&k&&(!h.w2ui||h.w2ui.editable!==!1)){if(-1!=["enum","file"].indexOf(k.type))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,-1==["checkbox","check"].indexOf(k.type))){var m=$("#grid_"+f.name+j+"rec_"+w2utils.escapeId(a)),n=m.find("[col="+b+"] > div");$(this.box).find("div.w2ui-edit-box").remove(),"row"!=this.selectType&&($("#grid_"+this.name+j+"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==k.inTag&&(k.inTag=""),null==k.outTag&&(k.outTag=""),null==k.style&&(k.style=""),null==k.items&&(k.items=[]);var o=h.w2ui&&h.w2ui.changes&&null!=h.w2ui.changes[i.field]?w2utils.stripTags(h.w2ui.changes[i.field]):w2utils.stripTags(h[i.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!=i.style?i.style+";":"";if("string"==typeof i.render&&-1!=["number","int","float","money","percent","size"].indexOf(i.render.split(":")[0])&&(q+="text-align: right;"),k.items.length>0&&!$.isPlainObject(k.items[0])&&(k.items=w2obj.field.prototype.normMenu(k.items)),"select"==k.type){for(var r="",s=0;s"+k.items[s].text+"";n.addClass("w2ui-editable").html('"+k.outTag),setTimeout(function(){n.find("select").focus().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)}else if("div"==k.type){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('
"+k.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:"")}else{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('"+k.outTag),"number"==k.type&&(o=w2utils.formatNumber(o)),"date"==k.type&&(o=w2utils.formatDate(w2utils.isDate(o,k.format,!0),k.format)),null==c&&n.find("input").val("object"!=typeof o?o:"");var v=n.find("input").get(0);$(v).w2field(k.type,$.extend(k,{selected:o})),setTimeout(function(){var a=v;"list"==k.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(){if(n.find("input, select, div.w2ui-input").data("old_value",p).on("mousedown",function(a){a.stopPropagation()}).on("click",function(a){"div"==k.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,j="DIV"==d.tagName.toUpperCase()?$(d).text():$(d).val();switch(c.keyCode){case 8:"list"!=k.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)==j.length&&(w2utils.setCursorPosition(d,j.length),c.preventDefault())}setTimeout(function(){switch(c.keyCode){case 9:var j=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){j=f.records[l].recid;for(var m=0;m0&&(d.focus(),clearTimeout(f.last.kbd_timer),null!=c?w2utils.setCursorPosition(d[0],$(d).text().length):w2utils.setCursorPosition(d[0],0,$(d).text().length),e.call(n.find("div.w2ui-input")[0],null))}else{var d=n.find("input, select");d.length>0&&(d[0].focus(),clearTimeout(f.last.kbd_timer),null!=c?d[0].setSelectionRange(d.val().length,d.val().length):d[0].select&&d[0].select(),e.call(n.find("input, select")[0],null))}d.length>0&&(d[0].resize=e),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=0>b;b=0>b?-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;o>=p;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;m>=s;s++)if(!(this.searchData.length>0)||r||-1!=$.inArray(s,this.last.searchIds))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)?!0:!1),"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;i>=j;j++)g.push(j)}else g.push(d);for(var j=0;ja)&&(a=0),d.select({recid:d.records[a].recid,column:0})}function c(){if("click"!=d.last.sel_type)return!1;if("row"!=d.selectType){if(d.last.sel_type="key",i.length>1){for(var a=0;a1?(i.splice(i.indexOf(d.records[d.last.sel_ind].recid),1),d.unselect.apply(d,i),!0):!1}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 70:if(!a.metaKey&&!a.ctrlKey)break;$("#grid_"+d.name+"_search_all").focus(),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 u=this.records[n].w2ui||{};!u||null==u.parent_recid||Array.isArray(u.children)&&0!=u.children.length&&u.expanded?d.collapse(j,a):(d.unselect(j),d.collapse(u.parent_recid,a),d.select(u.parent_recid))}else{var v=d.prevCell(n,k[0]);if(s||null!=v||(this.selectNone(),v=0),null!=v)if(s&&d.multiSelect){if(c())return;var u=[],w=[],x=[];if(0==k.indexOf(this.last.sel_col)&&k.length>1){for(var y=0;y1)d.selectNone();else for(var z=1;z1){for(var y=0;y1)d.selectNone();else for(var z=0;zv&&d.last.sel_ind!=o?d.unselect(d.records[o].recid):d.select(d.records[v].recid);else if(d.last.sel_ind>v&&d.last.sel_ind!=o){v=o;for(var u=[],t=0;t300?this.selectNone():this.unselect.apply(this,i),d.click({recid:d.records[v].recid,column:k[0]},a);d.scrollIntoView(v),a.preventDefault&&a.preventDefault()}else if(!s)if(i.length>1)d.selectNone();else for(var z=1;z300?this.selectNone():this.unselect.apply(this,i),d.click({recid:d.records[A].recid,column:k[0]},a);d.scrollIntoView(A),q=!0}else if(!s)if(i.length>1)d.selectNone();else for(var z=0;z=y;y++)u.push(y);-1==u.indexOf(r)||a.ctrlKey||a.metaKey||q||(0==k.length&&k.push(0),q=!1,setTimeout(function(){var b=$("#grid_"+d.name+"_focus"),c=b.val();b.val(""),d.editField(j,k[0],c,a)},1)),q&&a.preventDefault&&a.preventDefault(),d.trigger($.extend(f,{phase:"after"}))}}},scrollIntoView:function(a,b,c){var d=this.records.length;if(0==this.searchData.length||this.url||(d=this.last.searchIds.length),0!=d){if(null==a){var e=this.getSelection();if(0==e.length)return;$.isPlainObject(e[0])?(a=e[0].index,b=e[0].column):a=this.get(e[0],!0)}var f=$("#grid_"+this.name+"_records"),g=this.last.searchIds.length;if(g>0&&(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.animate({scrollTop:f.scrollTop()-f.height()/1.3},250,"linear")),a==i&&(c===!0?f.prop({scrollTop:f.scrollTop()+f.height()/1.3}):f.animate({scrollTop:f.scrollTop()+f.height()/1.3},250,"linear")),(h>a||a>i)&&(c===!0?f.prop({scrollTop:(a-1)*this.recordHeight}):f.animate({scrollTop:(a-1)*this.recordHeight},250,"linear"))}if(null!=b){for(var j=0,k=0,l=w2utils.scrollBarSize(),m=0;b>=m;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"});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"});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.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),-1==g.indexOf(c[h].index)&&g.push(c[h].index);g.sort(function(a,b){return a-b});for(var i=0;i=k;k++){var l=this.columns[k];l.hidden!==!0&&(d+=w2utils.stripTags(this.getCellHTML(j,k))+" ")}d=d.substr(0,d.length-1),d+="\n"}}else{for(var k=0;k 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(!(0>c)){var d=this.records[c]||{};d.w2ui||(d.w2ui={});for(var e=0;ec))if(null!=c&&null!=e){var d=this.records[c]||{},f=$(this.box).find("#grid_"+this.name+"_data_"+c+"_"+e);d.w2ui||(d.w2ui={}),f.replaceWith(this.getCellHTML(c,e,!1)),null==d.w2ui.style||$.isEmptyObject(d.w2ui.style)?f.attr("style",""):("string"==typeof d.w2ui.style&&$(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(d.recid)).attr("style",d.w2ui.style),$.isPlainObject(d.w2ui.style)&&"string"==typeof d.w2ui.style[e]&&f.attr("style",d.w2ui.style[e]))}else console.log("ERROR: Wrong argument for grid.update(cells), cells should be [{ index: X, column: Y }, ...]")}return(new Date).getTime()-b},refreshCell:function(a,b){var c=this.get(a,!0),d=this.records[c]&&this.records[c].recid==a?!1:!0,e=this.getColumn(b,!0),f=d?this.summary[c]:this.records[c],g=this.columns[e],h=$(this.box).find("#grid_"+this.name+"_data_"+c+"_"+e);h.replaceWith(this.getCellHTML(c,e,d)),f.w2ui&&f.w2ui.changes&&null!=f.w2ui.changes[g.field]?h.addClass("w2ui-changed"):h.removeClass("w2ui-changed"),f.w2ui&&null!=f.w2ui.style&&!$.isEmptyObject(f.w2ui.style)?("string"==typeof f.w2ui.style&&$(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(f.recid)).attr("style",f.w2ui.style),$.isPlainObject(f.w2ui.style)&&"string"==typeof f.w2ui.style[e]&&h.attr("style",f.w2ui.style[e])):h.attr("style","")},refreshRow:function(a,b){var c=$(this.box).find("#grid_"+this.name+"_frec_"+w2utils.escapeId(a)),d=$(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(a));if(c.length>0){null==b&&(b=this.get(a,!0));var e=c.attr("line"),f=this.records[b]&&this.records[b].recid==a?!1:!0,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){this.summary=[];for(var f=0;f=0;f--)this.records.splice(e[f],1)}a.scroll();var j=this.getRecordsHTML(),k=this.getColumnsHTML(),l='
'+j[0]+'
"+j[1]+'
'+k[0]+'
'+k[1]+"
";if($("#grid_"+this.name+"_body").html(l),this.summary.length>0){var m=this.getSummaryHTML();$("#grid_"+this.name+"_fsummary").html(m[0]).show(),$("#grid_"+this.name+"_summary").html(m[1]).show()}else $("#grid_"+this.name+"_fsummary").hide(),$("#grid_"+this.name+"_summary").hide();this.show.footer?$("#grid_"+this.name+"_footer").html(this.getFooterHTML()).show():$("#grid_"+this.name+"_footer").hide(),this.searchData.length>0?$("#grid_"+this.name+"_searchClear").show():$("#grid_"+this.name+"_searchClear").hide();var n=this.last.selection,o=this.records.length>0&&n.indexes.length==this.records.length,p=n.indexes.length>0&&0!==this.searchData.length&&n.indexes.length==this.last.searchIds.length;o||p?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status();for(var q=a.find({"w2ui.expanded":!0},!0),r=0;r0&&$(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}}},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)return;for(var b=a.target,f={x:a.offsetX-10,y:a.offsetY-10},g=!1;b&&!b.classList.contains("w2ui-grid");)"TD"==b.tagName.toUpperCase()&&(g=!0),"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};var h=a.target;setTimeout(function(){var a=$(e.box).find("#grid_"+e.name+"_focus");a.is(":focus")||a.focus(),e.last.move&&a.css({left:e.last.move.focusX-$(e.box).find("#grid_"+e.name+"_records").scrollLeft(),top:e.last.move.focusY-$(e.box).find("#grid_"+e.name+"_records").scrollTop()}),setTimeout(function(){-1!=["INPUT","TEXTAREA","SELECT"].indexOf(h.tagName.toUpperCase())&&$(h).focus()},50)},1)}if(1==e.reorderRows){var i=a.target;if("TD"!=i.tagName.toUpperCase()&&(i=$(i).parents("td")[0]),$(i).hasClass("w2ui-col-number")){e.selectNone(),e.last.move.reorder=!0;var j=$(e.box).find(".w2ui-even.w2ui-empty-record").css("background-color"),k=$(e.box).find(".w2ui-odd.w2ui-empty-record").css("background-color");$(e.box).find(".w2ui-even td").not(".w2ui-col-number").css("background-color",j),$(e.box).find(".w2ui-odd td").not(".w2ui-col-number").css("background-color",k);var l=e.last.move;if(!l.ghost){var m=$("#grid_"+e.name+"_rec_"+l.recid),b=m.parents("table").find("tr:first-child").clone();l.offsetY=a.offsetY,l.from=l.recid,l.pos=m.position(),l.ghost=$(m).clone(!0),l.ghost.removeAttr("id"),m.find("td").remove(),m.append('');var n=$(e.box).find(".w2ui-grid-records");n.append('
'),$("#grid_"+e.name+"_ghost").append(b).append(l.ghost)}var o=$("#grid_"+e.name+"_ghost"),n=$(e.box).find(".w2ui-grid-records");o.css({top:l.pos.top+n.scrollTop(),left:l.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)}}function c(a){var b=e.last.move;if(b&&"select"==b.type&&(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;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),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 l=parseInt(c[0]);l<=parseInt(c[1]);l++)$(e.box).find("#grid_"+e.name+"_column_"+l+" .w2ui-col-header").addClass("w2ui-col-selected");$(e.box).find(".w2ui-col-number").not(".w2ui-head").addClass("w2ui-row-selected"),b.colRange!=k&&(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 m=e.get(b.recid,!0);if(null==m||e.records[m]&&e.records[m].recid!=b.recid)return;var n=e.get(d,!0);if(null==n)return;var o=parseInt(b.column),p=parseInt("TD"==a.target.tagName.toUpperCase()?$(a.target).attr("col"):$(a.target).parents("td").attr("col"));if(isNaN(o)&&isNaN(p)&&(o=0,p=e.columns.length-1),m>n){var c=m;m=n,n=c}var c="ind1:"+m+",ind2;"+n+",col1:"+o+",col2:"+p;if(b.range==c)return;b.range=c;for(var q=m;n>=q;q++)if(!(e.last.searchIds.length>0&&-1==e.last.searchIds.indexOf(q)))if("row"!=e.selectType){if(o>p){var c=o;o=p,p=c}for(var c=[],r=o;p>=r;r++)e.columns[r].hidden||i.push({recid:e.records[q].recid,column:parseInt(r)})}else i.push(e.records[q].recid);if("row"!=e.selectType){for(var s=e.getSelection(),c=[],t=0;tm?e.records.splice(m,0,f):e.records.splice(m-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.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 ")}b+='';var f="object"!=typeof this.url?this.url:this.url.get;f&&a.show.skipRecords&&(b+='"),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;r>q;q++)if($(a.originalEvent.target).parents().hasClass(n[q]))return;if(j.numberPreColumnsPresent=$(i.box).find(p).length,j.columnHead=h=$(a.originalEvent.target).parents(".w2ui-head"),k=parseInt(h.attr("col"),10),c=i.trigger({type:"columnDragStart",phase:"before",originalEvent:a,origColumnNumber:k,target:h[0]}),c.isCancelled===!0)return!1;f=j.columns=$(i.box).find(".w2ui-head:not(.w2ui-head-last)"),$(document).on("mouseup",e),$(document).on("mousemove",d),j.originalPos=parseInt($(a.originalEvent.target).parent(".w2ui-head").attr("col"),10),j.ghost=$(b).clone(!0),$(j.ghost).find('[col]:not([col="'+j.originalPos+'"]), .w2ui-toolbar, .w2ui-grid-header').remove(),$(j.ghost).find(o).remove(),$(j.ghost).find(".w2ui-grid-body").css({top:0}),g=$(j.ghost).find('[col="'+j.originalPos+'"]'),$(document.body).append(j.ghost),$(j.ghost).css({width:0,height:0,margin:0,position:"fixed",zIndex:999999,opacity:0}).addClass(".w2ui-grid-ghost").animate({width:g.width(),height:$(i.box).find(".w2ui-grid-body:first").height(),left:a.pageX,top:a.pageY,opacity:.8},0),j.offsets=[];for(var q=0,r=f.length;r>q;q++)j.offsets.push($(f[q]).offset().left);i.trigger($.extend(c,{phase:"after"}))}}},150)}function d(a){if(j.pressed){var b=a.originalEvent.pageX,c=a.originalEvent.pageY,d=j.offsets,e=$(".w2ui-head:not(.w2ui-head-last)").width();j.targetInt=Math.max(j.numberPreColumnsPresent,g(b,d,e)),f(j.targetInt),h(b,c)}}function e(a){j.pressed=!1;var b,c,f,g,h,k=$(".w2ui-grid-ghost");return b=i.trigger({type:"columnDragEnd",phase:"before",originalEvent:a,target:j.columnHead[0]}),b.isCancelled===!0?!1:(f=i.columns[j.originalPos],g=i.columns,h=$(j.columns[Math.min(j.lastInt,j.columns.length-1)]),c=j.lastInt
'),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;e>d;d++){var f=b[d],g=b[d+1]||b[d]+c,h=(g-b[d])/2+b[d];if(a>f&&h>=a)return d;if(a>h&&g>=a)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(){var a=this;$(this.box).find(".w2ui-empty-record").remove();var b=$(this.box),c=$(this.box).find("> div.w2ui-grid-box"),d=$("#grid_"+this.name+"_header"),e=$("#grid_"+this.name+"_toolbar"),f=$("#grid_"+this.name+"_summary"),g=$("#grid_"+this.name+"_fsummary"),h=$("#grid_"+this.name+"_footer"),i=$("#grid_"+this.name+"_body"),j=$("#grid_"+this.name+"_columns"),k=$("#grid_"+this.name+"_fcolumns"),l=$("#grid_"+this.name+"_records"),m=$("#grid_"+this.name+"_frecords"),n=$("#grid_"+this.name+"_scroll1"),o=8*String(this.total).length+10;34>o&&(o=34),null!=this.lineNumberWidth&&(o=this.lineNumberWidth);for(var p=!1,q=!1,r=0,s=0;stable").height()+(p?w2utils.scrollBarSize():0)&&(q=!0),this.fixedBody){var u=c.height()-(this.show.header?w2utils.getSize(d,"height"):0)-(this.show.toolbar?w2utils.getSize(e,"height"):0)-("none"!=f.css("display")?w2utils.getSize(f,"height"):0)-(this.show.footer?w2utils.getSize(h,"height"):0);i.css("height",u)}else{var u=w2utils.getSize(j,"height")+w2utils.getSize($("#grid_"+a.name+"_records table"),"height")+(p?w2utils.scrollBarSize():0);a.height=u+w2utils.getSize(c,"+height")+(a.show.header?w2utils.getSize(d,"height"):0)+(a.show.toolbar?w2utils.getSize(e,"height"):0)+("none"!=f.css("display")?w2utils.getSize(f,"height"):0)+(a.show.footer?w2utils.getSize(h,"height"):0),c.css("height",a.height),i.css("height",u),b.css("height",w2utils.getSize(c,"height")+w2utils.getSize(b,"+height"))}var v=this.records.length,w="object"!=typeof this.url?this.url:this.url.get;if(0==this.searchData.length||w||(v=this.last.searchIds.length),this.fixedBody||(q=!1),p||q?(j.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show(),l.css({top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(j,"height")+"px","-webkit-overflow-scrolling":"touch","overflow-x":p?"auto":"hidden","overflow-y":q?"auto":"hidden"})):(j.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").hide(),l.css({top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(j,"height")+"px",overflow:"hidden"}),l.length>0&&(this.last.scrollTop=0,this.last.scrollLeft=0)),p?(m.css("margin-bottom",w2utils.scrollBarSize()),n.show()):(m.css("margin-bottom",0),n.hide()),m.css({overflow:"hidden",top:l.css("top")}),this.show.emptyRecords&&!q){var x=Math.floor(l.height()/this.recordHeight)+1;if(this.fixedBody)for(var y=v;x>=y;y++){var z="",A="",B="";z+='',A+='',this.show.lineNumbers&&(z+=''),this.show.selectColumn&&(z+=''),this.show.expandColumn&&(z+=''),A+='';for(var C=0;Cthis.last.colEnd)||D.frozen)&&(B='',D.frozen?z+=B:A+=B)}z+=' ',A+=' ',$("#grid_"+this.name+"_frecords > table").append(z),$("#grid_"+this.name+"_records > table").append(A)}}if(i.length>0){for(var E=parseInt(i.width())-(q?w2utils.scrollBarSize():0)-(this.show.lineNumbers?o:0)-(this.show.selectColumn?26:0)-(this.show.expandColumn?26:0)-1,F=E,G=0,H=!1,s=0;s0&&(D.gridMinWidth>F&&D.hidden!==!0&&(D.hidden=!0,H=!0),D.gridMinWidth0)for(var s=0;sparseInt(D.max)&&(D.sizeCalculated=D.max+"px"),I+=parseInt(D.sizeCalculated))}var J=parseInt(F)-parseInt(I);if(J>0&&G>0)for(var s=0;;){var D=this.columns[s];if(null!=D)if(D.hidden||"px"==D.sizeType)s++;else{if(D.sizeCalculated=parseInt(D.sizeCalculated)+1+"px",J--,0==J)break;s++}else s=0}else J>0&&j.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show();var K=1;this.show.lineNumbers&&(K+=o),this.show.selectColumn&&(K+=26),this.show.expandColumn&&(K+=26);for(var s=0;s table > tbody > tr:nth-child(1) td").add(k.find("> table > tbody > tr:nth-child(1) td")).each(function(b,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",o);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0==G?J:0)+"px")}),3==j.find("> table > tbody > tr").length&&j.find("> table > tbody > tr:nth-child(1) td").add(k.find("> table > tbody > tr:nth-child(1) td")).html("").css({height:"0px",border:"0px",padding:"0px",margin:"0px"}),l.find("> table > tbody > tr:nth-child(1) td").add(m.find("> table > tbody > tr:nth-child(1) td")).each(function(b,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",o);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0==G?J:0)+"px")}),f.find("> table > tbody > tr:nth-child(1) td").add(g.find("> table > tbody > tr:nth-child(1) td")).each(function(b,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",o);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0==G?J:0)+"px")}),this.initResize(),this.refreshRanges(),(this.last.scrollTop||this.last.scrollLeft)&&l.length>0&&(j.prop("scrollLeft",this.last.scrollLeft),l.prop("scrollTop",this.last.scrollTop),l.prop("scrollLeft",this.last.scrollLeft))},getSearchesHTML:function(){function a(a){for(var c="",d=0;d'+w2utils.lang(f)+""}return c}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"),-1!=["text","alphanumeric","combo"].indexOf(f.type))var h='";if(-1!=["int","float","money","currency","percent","date","time"].indexOf(f.type))var h='";if(-1!=["select","list","hex"].indexOf(f.type))var h='";if(-1!=["enum"].indexOf(f.type))var h='";switch(c+='"}}return c+='
'+g+' '+(f.caption||"")+' '+h+' ',f.type){case"text":case"alphanumeric":case"hex":case"list":case"combo":case"enum":c+='";break;case"int":case"float":case"money":case"currency":case"percent":case"date":case"time":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"in":case"not in":f.w2field("clear");break;case"between":e.show(),g.w2field(d.type);break;case"not null":case"null":f.hide(),f.val("1"),f.change()}},initSearches:function(){for(var a=this,b=0;b'+j+""}else f+='"}$("#grid_"+this.name+"_field_"+b).html(f)}null!=d?("int"==d.type&&-1!=["in","not in"].indexOf(d.operator)&&$("#grid_"+this.name+"_field_"+b).w2field("clear").val(d.value),$("#grid_"+this.name+"_operator_"+b).val(d.operator).trigger("change"),$.isArray(d.value)?-1!=["in","not in"].indexOf(d.operator)?$("#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(e).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=i);else if(g.master===!0){for(var k="",l=0;l'),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;d>h;h++)e=this.getRecordHTML(h,h+1),f+=e[0],g+=e[1];return f+='
',g+=' ',this.last.range_start=0,this.last.range_end=d,[f,g]},getSummaryHTML:function(){if(0!=this.summary.length){for(var a="",b="",c="
",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&&(0>i&&(i=0),0>j&&(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(5>p&&5>q){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;i>m;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(jj;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;j>=m;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)+" "+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<=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;1>H&&(H=1),I>this.total&&(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");-1!=String(J.next().prop("id")).indexOf("_expanded_row")&&(J.next().remove(),L.next().remove()),this.total>I&&-1!=String(K.prev().prop("id")).indexOf("_expanded_row")&&(K.prev().remove(),M.prev().remove());var N=parseInt(J.next().attr("line")),O=parseInt(K.prev().attr("line"));if(H>N||1==N||this.last.pull_refresh){if(I<=O+this.last.show_extra-2&&I!=this.total)return;for(this.last.pull_refresh=!1;;){var P=f.find("#grid_"+this.name+"_frec_top").next(),Q=e.find("#grid_"+this.name+"_rec_top").next();if("bottom"==Q.attr("line"))break;if(!(parseInt(Q.attr("line"))=m;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);K.before(T[1]),M.before(T[0])}b(),setTimeout(function(){c.refreshRanges()},0)}else{if(H>=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;0>V&&(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
')}),-1==Y.find("td").text().indexOf("Load")&&Y.find("td").html("
"+w2utils.lang("Load")+" "+c.limit+" "+w2utils.lang("More")+"...
")}E>=this.total-this.offset&&$("#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(-1==a){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);if(-1!=h.indexes.indexOf(a)&&(l=!0),f+='",g+='",this.show.lineNumbers&&(f+='"),this.show.selectColumn&&(f+='"),this.show.expandColumn){var m="";m=d.w2ui&&d.w2ui.expanded===!0?"-":"+",d.w2ui&&"none"==d.w2ui.expanded&&(m=""),d.w2ui&&"spinner"==d.w2ui.expanded&&(m='
'),f+='"}g+='';for(var n=0,o=0;;){var p=1,j=this.columns[n];if(null==j)break;if(j.hidden)n++,o>0&&o--;else if(o>0){if(n++,null==this.columns[n])break;d.w2ui.colspan[this.columns[n].field]=0,o--}else if(!(nthis.last.colEnd)||j.frozen){if(d.w2ui&&"object"==typeof d.w2ui.colspan){var q=parseInt(d.w2ui.colspan[j.field])||null;if(q>1){for(var r=0,i=n;n+q>i&&!(i>=this.columns.length);i++)this.columns[i].hidden&&r++;p=q-r,o=q-1}}var s=this.getCellHTML(a,n,c,p);j.frozen?f+=s:g+=s,n++}else n++}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=e.editable,i="max-height: "+parseInt(this.recordHeight)+"px;",j=!c&&f&&f.w2ui&&f.w2ui.changes&&null!=f.w2ui.changes[e.field],k="",l=this.last.selection,m=!1,n="";if(-1!=l.indexes.indexOf(a)&&(m=!0),null==d&&(d=1),0==b&&f&&f.w2ui&&Array.isArray(f.w2ui.children)){for(var o=0,p=this.get(f.w2ui.parent_recid,!0);;){if(null==p)break;o++;var q=this.records[p].w2ui;if(null==q||null==q.parent_recid)break;p=this.get(q.parent_recid,!0)}for(var r=0;o>r;r++)n+='';n+='"}if(e.info===!0&&(e.info={}),null!=e.info&&(e.info.icon||(e.info.icon="w2ui-icon-info"),n+=''),null!=e.render){if("function"==typeof e.render&&(g=$.trim(e.render.call(this,f,a,b)),(g.length<4||"'+n+String(g)+"")),"object"==typeof e.render&&(g='
'+n+(e.render[g]||"")+"
"),"string"==typeof e.render){var s=e.render.toLowerCase().indexOf(":"),q=[];-1==s?(q[0]=e.render.toLowerCase(),q[1]=""):(q[0]=e.render.toLowerCase().substr(0,s),q[1]=e.render.toLowerCase().substr(s+1));var t=w2utils.formatters[q[0]];g='
'+n+("function"==typeof t?t(g,q[1]):"")+"
"}}else{if(h&&-1!=["checkbox","check"].indexOf(h.type)){var u=c?-(a+1):a;i+="text-align: center;",g='',n=""}if(this.show.recordTitles){var v=w2utils.stripTags(String(g).replace(/"/g,"''"));null!=e.title&&("function"==typeof e.title&&(v=e.title.call(this,f,a,b)),"string"==typeof e.title&&(v=e.title))}g='
'+n+String(g)+"
"}if(null==g&&(g=""),"string"==typeof e.render){var q=e.render.toLowerCase().split(":");-1!=["number","int","float","money","currency","percent","size"].indexOf(q[0])&&(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]+";"));var w=!1;return m&&-1!=$.inArray(b,l.columns[a])&&(w=!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(),null==d.fields&&"function"==typeof d.render&&(d.fields=d.render),this.last.bubbleEl=f,null==d.fields){d.fields=[];for(var g=0;g1&&(w2utils.formatters[i[1]]?j=w2utils.formatters[i[1]](j,i[2]||null):console.log('ERROR: w2utils.formatters["'+i[1]+'"] does not exists.')),(d.showEmpty===!0||null!=j&&""!=j)&&(null!=d.maxLength&&"string"==typeof j&&j.length>d.maxLength&&(j=j.substr(0,d.maxLength)+"..."),c+="")}else c+=''}c+="
"+(c!==!0?this.getLineHTML(b,d):"")+"'+(c!==!0?'
":"")+"
'+(c!==!0?'
"+m+"
":"")+"
1?'colspan="'+d+'"':"")+">"+g+"
"+h.caption+""+((0===j?"0":j)||"")+"
"}else if($.isPlainObject(d.fields)){c='';for(var k in d.fields){var l=d.fields[k];if(""!=l&&"-"!=l&&"--"!=l&&"---"!=l){var i=String(l).split(":"),h=this.getColumn(i[0]);null==h&&(h={field:i[0],caption:i[0]});var j=h?this.parseField(e,h.field):"";i.length>1&&(w2utils.formatters[i[1]]?j=w2utils.formatters[i[1]](j,i[2]||null):console.log('ERROR: w2utils.formatters["'+i[1]+'"] does not exists.')),"function"==typeof l&&(j=l(e,a,b)),(d.showEmpty===!0||null!=j&&""!=j)&&(null!=d.maxLength&&"string"==typeof j&&j.length>d.maxLength&&(j=j.substr(0,d.maxLength)+"..."),c+="")}else c+=''}c+="
"+k+""+(j||"")+"
"}$(f).w2tag($.extend({html:c,left:-4,position:"bottom",className:"w2ui-info-bubble",style:"",hideOnClick:!0},d.options||{}))},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&&"list"==d.editable.type&&(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=Array.prototype.slice.call(arguments,0);c.unshift(this.box),setTimeout(function(){w2utils.lock.apply(window,c)},10)},unlock:function(a){var b=this.box;setTimeout(function(){w2utils.unlock(b,a)},25)},stateSave:function(a){if(!localStorage)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=g,b.last.scrollLeft=h,b.refresh()},1)}return this.trigger($.extend(f,{phase:"after"})),!0},stateReset:function(){if(this.stateRestore(this.last.state),localStorage)try{var a=$.parseJSON(localStorage.w2ui||"{}");a.states&&a.states[this.name]&&delete a.states[this.name],localStorage.w2ui=JSON.stringify(a)}catch(b){return delete localStorage.w2ui,null}},parseField:function(a,b){var c="";try{c=a;for(var d=String(b).split("."),e=0;ed)return null;var e=this.records[a].w2ui,f=this.columns[d],g=e&&e.colspan?e.colspan[f.field]:1,h=f?f.editable:null;return null==f?null:f&&f.hidden||0==g||1==c&&(null==h||-1!=["checkbox","check"].indexOf(h.type))?this.prevCell(a,d,c):d},nextRow:function(a,b){var c=this.last.searchIds;if(a+10&&a0)for(;;){if(-1!=$.inArray(a,c)||a>this.records.length)break;a++}return a}return null},prevRow:function(a,b){var c=this.last.searchIds;if(a>0&&0==c.length||c.length>0&&a>c[0]){if(a--,c.length>0)for(;;){if(-1!=$.inArray(a,c)||0>a)break;a--}return a}return null},selectionSave:function(){return this.last._selection=this.getSelection(),this.last._selection},selectionRestore:function(){var a=(new Date).getTime();this.last.selection={indexes:[],columns:{}};for(var b=this.last.selection,c=this.last._selection,d=0;d'+a+"",buttons:'",onOpen:function(a){setTimeout(function(){$(this.box).find(".w2ui-btn").focus()},25)}}),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?!1:(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?!1:(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;j>i;i++)h.panels[i]=a.extend(!0,{},b.prototype.panel,g[i]),(a.isPlainObject(h.panels[i].tabs)||a.isArray(h.panels[i].tabs))&&e(h,g[i].type),(a.isPlainObject(h.panels[i].toolbar)||a.isArray(h.panels[i].toolbar))&&f(h,g[i].type);for(var k=0;k0&&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(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){e.resize()},100)})}this.refresh(b)}return e.trigger(a.extend(g,{phase:"after"})),e.resize(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){e.resize()},100),!0}},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(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){f.resize()},100)}),!0):!1},sizeTo:function(b,c,d){var e=this,f=e.get(b);return null==f?!1:(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?!1:(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?!1:(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?!1:c.hidden?this.show(a,b):this.hide(a,b)},set:function(b,c){var d=this.get(b,!0);return null==d?!1:(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?!0:!1,u=null!=p&&p.hidden!==!0?!0:!1,v=null!=q&&q.hidden!==!0?!0:!1,w=null!=r&&r.hidden!==!0?!0:!1,x=null!=s&&s.hidden!==!0?!0:!1,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"),-1!=window.navigator.userAgent.indexOf("MSIE")&&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"),-1!=window.navigator.userAgent.indexOf("MSIE")&&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]?!1:(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(-1==c.indexOf(a))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(-1==c.indexOf(a))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?!0:!1,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():!1}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?!1:(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?!1:(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)),b>g-10&&(b=g-10),c>h-10&&(c=h-10);var i=(h-c)/2*.6,j=(g-b)/2;a("#w2ui-popup").css(w2utils.cssPrefix({transition:f.speed+"s width, "+f.speed+"s height, "+f.speed+"s left, "+f.speed+"s top"})).css({top:i,left:j,width:b,height:c});var k=setInterval(function(){e.resizeMessages()},10);setTimeout(function(){clearInterval(k),f.width=b,f.height=c,e.resizeMessages(),"function"==typeof d&&d()},1e3*f.speed+50)},restoreTemplate:function(){var b=a("#w2ui-popup").data("options");if(null!=b){var c=w2popup._template,d=b.title,e=b.body,f=b.buttons;if(w2popup._prev?(c=w2popup._prev.template,d=w2popup._prev.title,e=w2popup._prev.body,f=w2popup._prev.buttons,delete w2popup._prev):delete w2popup._template,null!=c){var g=a(c);if(0==g.length)return;"body"==a(e).attr("rel")?(d&&g.append(d),e&&g.append(e),f&&g.append(f)):g.append(e)}}}},a.extend(w2popup,w2utils.event)}(jQuery);var w2alert=function(a,b,c){var d=jQuery;null==b&&(b=w2utils.lang("Notification")),d("#w2ui-popup").length>0&&"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()}})},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}}};!function(a){var b=function(b){this.box=null,this.name=null,this.active=null,this.flow="down",this.tooltip="top",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+'
"+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,0>=e&&(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",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()}})),-1!=["menu","menu-radio","menu-check"].indexOf(f.type)){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)&&-1!=f.selected.indexOf(b.id)?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()}}))}-1!=["color","text-color"].indexOf(f.type)&&(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)),-1!=["check","menu","menu-radio","menu-check","drop","color","text-color"].indexOf(f.type)&&(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=e&&(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)},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)):(-1!=["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(e.type)&&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?'":"")+(-1!=["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(a.type)&&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),-1!=["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(f.type)&&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);-1==g?(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):void 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});return e.isCancelled!==!0?(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):void 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?!1:(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)),-1!=a.inArray(b.keyCode,[13,32,37,38,39,40])&&(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()||0>=f)&&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});f.isCancelled!==!0&&(e.group||e.disabled||(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(-1==["INPUT","TEXTAREA","SELECT"].indexOf(b.target.tagName.toUpperCase())){var c=a(d.box).find("#sidebar_"+d.name+"_focus");c.is(":focus")||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?!1:!0});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").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):void 0},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;return f[c]?f[c].apply(f,Array.prototype.slice.call(arguments,1)):void 0},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):!1},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(-1==["INPUT","TEXTAREA"].indexOf(this.el.tagName.toUpperCase()))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"),-1!=["text","alphanumeric","hex","bin"].indexOf(this.type)&&(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=-1!=["list","enum","file"].indexOf(this.type)?a(this.el).data("selected"):a(this.el).val()},set:function(b){-1!=["list","enum","file"].indexOf(this.type)?(a(this.el).data("selected",b).change(),this.refresh()):a(this.el).val(b)},setIndex:function(b){var c=this.options.items;return c&&c[b]?(a(this.el).data("selected",c[b]).change(),this.refresh(),!0):!1},clear:function(){var b=this.options;-1!=["money","currency"].indexOf(this.type)&&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(-1!=["list"].indexOf(this.type)&&(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?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)),-1!=["enum","file"].indexOf(this.type)){var f="";for(var g in d){var h=d[g],i="";i="function"==typeof c.renderItem?c.renderItem(h,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")){c.stopPropagation();var g=b.trigger({phase:"before",type:"click",target:b.el,originalEvent:c.originalEvent,item:f});if(g.isCancelled!==!0){if(a(c.target).hasClass("w2ui-list-remove")){if(a(b.el).attr("readonly")||a(b.el).attr("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)}if("file"==b.type&&!a(c.target).hasClass("w2ui-list-remove")){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");26>m&&(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(),-1!=["int","float","money","currency","percent"].indexOf(this.type)&&("string"==typeof b&&(c.autoFormat&&-1!=["money","currency"].indexOf(this.type)&&(b=String(b).replace(c.moneyRE,"")),c.autoFormat&&"percent"==this.type&&(b=String(b).replace(c.percentRE,"")),c.autoFormat&&-1!=["int","float"].indexOf(this.type)&&(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(-1!=["int","float","money","currency","percent"].indexOf(this.type)){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(-1!=["list","enum","file"].indexOf(this.type)&&(c.refresh(),setTimeout(function(){c.refresh()},5)),-1!=["date","time","datetime"].indexOf(this.type)){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(),-1!=["list","combo","enum"].indexOf(this.type)&&(a(this.el).is(":focus")||this.focus(b)),-1!=["date","time","color","datetime"].indexOf(this.type)&&this.updateOverlay()},focus:function(b){var c=this;this.options;if(-1!==["color","date","time","datetime"].indexOf(c.type)){if(a(c.el).attr("readonly")||a(c.el).attr("disabled"))return;a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),setTimeout(function(){c.updateOverlay()},150)}if(-1!=["list","combo","enum"].indexOf(c.type)){if(a(c.el).attr("readonly")||a(c.el).attr("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();-1!=["color","date","time","list","combo","enum","datetime"].indexOf(c.type)&&a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),-1!=["int","float","money","currency","percent"].indexOf(c.type)&&(""===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)))),-1!=["date","time","datetime"].indexOf(c.type)&&(""===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(-1!=["int","float","money","currency","percent","hex","bin","color","alphanumeric"].indexOf(b.type)){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}-1!=["date","time","datetime"].indexOf(b.type)&&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(-1!=["int","float","money","currency","percent"].indexOf(d.type)){if(!e.keyboard||a(d.el).attr("readonly"))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).attr("readonly"))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).attr("readonly"))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).attr("readonly"))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).attr("readonly"))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(-1!=["list","combo","enum"].indexOf(d.type)){if(a(d.el).attr("readonly"))return;var q=a(d.el).data("selected"),r=a(d.el),s=!1;switch(-1!=["list","enum"].indexOf(d.type)&&("list"==d.type&&(r=a(d.helpers.focus).find("input")),"enum"==d.type&&(r=a(d.helpers.multi).find("input")),-1==[37,38,39,40].indexOf(f)&&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){if("color"==this.type&&86==b.keyCode&&(b.ctrlKey||b.metaKey)&&a(this).prop("maxlength",6),-1!=["list","combo","enum"].indexOf(this.type)&&-1==[16,17,18,20,37,39,91].indexOf(b.keyCode)){var c=a(this.helpers.focus).find("input");0==c.length&&(c=a(this.el));var d=this.trigger({phase:"before",type:"search",originalEvent:b,target:c,search:c.val()});if(d.isCancelled===!0)return;this.tmp.force_hide||this.request(),1==c.val().length&&this.refresh(),(0==a("#w2ui-overlay").length||-1==[38,40].indexOf(b.keyCode))&&this.search(),this.trigger(a.extend(d,{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(j){}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)}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=i&&(c.index=-1),c.spinner=!1,b.updateOverlay(),setTimeout(function(){var b=a("#w2ui-overlay").html()||"";c.markSearch&&-1!=b.indexOf("$.fn.w2menuHandler")&&a("#w2ui-overlay").w2marker(d)},1)}else c.items.splice(0,c.cacheMax),c.spinner=!0,b.updateOverlay()},updateOverlay:function(b){var c=this,d=this.options;if("color"==this.type){if(a(c.el).attr("readonly"))return;a(this.el).w2color({color:a(this.el).val(),transparent:d.transparent},function(b){null!=b&&a(c.el).val(b).change()})}if("date"==this.type){if(a(c.el).attr("readonly"))return;0==a("#w2ui-overlay").length&&a(c.el).w2overlay('
    ',{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 n(b,d){a("#w2ui-overlay > div > div").html(c.getMonthHTML(b,d,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 b,d;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"),d=a(this).attr("name")),a(this).hasClass("w2ui-jump-year")&&(a(this).parent().find(".w2ui-jump-year").removeClass("selected"),a(this).addClass("selected"),b=a(this).attr("name")),null!=b&&null!=d&&(a("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout(function(){n(parseInt(d)+1,b)},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,n(a[0],a[1])}),a("#w2ui-overlay .next").on("mousedown",function(){var a=c.options.current.split("/");a[0]=parseInt(a[0])+1,n(a[0],a[1])})}(e,f)}if("time"==this.type){if(a(c.el).attr("readonly"))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?"":12>d?" 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)+":"+(10>d?0:"")+d+(h?"":12>b?" 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).attr("readonly"))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.isDate(a(c.el).val(),c.options.format,!0);g&&(e=g.getMonth()+1,f=g.getFullYear());var i=null;!function o(b,e){a("#w2ui-overlay > div > div").html(c.getMonthHTML(b,e,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 b,d;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"),d=a(this).attr("name")),a(this).hasClass("w2ui-jump-year")&&(a(this).parent().find(".w2ui-jump-year").removeClass("selected"),a(this).addClass("selected"),b=a(this).attr("name")),null!=b&&null!=d&&(a("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout(function(){o(parseInt(d)+1,b)},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,o(a[0],a[1])}),a("#w2ui-overlay .next").on("mousedown",function(){var a=c.options.current.split("/");a[0]=parseInt(a[0])+1,o(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(-1!=["list","combo","enum"].indexOf(this.type)){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)&&-1==d.index&&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&&i>=j&&(d=!0)}else d=!0;if(this.options.blocked&&-1!=a.inArray(b,this.options.blocked)&&(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;k>l;l++)e.getDay()==this.options.blockWeekDays[l]&&(d=!1)}}else if("time"==this.type)if(this.options.start||this.options.end){var m=this.toMin(b),n=this.toMin(this.options.start),o=this.toMin(this.options.end);n||(n=m),o||(o=m),m>=n&&o>=m&&(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&&i>=j&&(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&&-1!=e&&(c.el._tabIndex=e),c.el._tabIndex&&(e=c.el._tabIndex);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;";"enum"==b.type&&(c='
    "),"file"==b.type&&(c='
    ');var e=a(b.el).data("tmp")||{};e["old-background-color"]=a(b.el).css("background-color"),e["old-border-color"]=a(b.el).css("border-color"),a(b.el).data("tmp",e),a(b.el).before(c).css({"background-color":"transparent","border-color":"transparent"});var f=a(b.el).prev();b.helpers.multi=f,"enum"==b.type&&(a(b.el).attr("tabindex",-1),f.find("input").on("click",function(c){0==a("#w2ui-overlay").length&&b.focus(c),a(b.el).triggerHandler("click")}).on("focus",function(c){a(f).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(f).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)}),f.on("click",function(b){a(this).find("input").focus()})),"file"==b.type&&(a(b.el).css("outline","none"),f.on("click",function(c){a(b.el).focus(),a(b.el).attr("readonly")||(b.blur(c),b.resize(),setTimeout(function(){f.find("input").click()},10))}).on("dragenter",function(c){a(b.el).attr("readonly")||a(f).addClass("w2ui-file-dragover")}).on("dragleave",function(c){if(!a(b.el).attr("readonly")){var d=a(c.target).parents(".w2ui-field-helper");0==d.length&&a(f).removeClass("w2ui-file-dragover")}}).on("drop",function(c){if(!a(b.el).attr("readonly")){a(f).removeClass("w2ui-file-dragover");for(var d=c.originalEvent.dataTransfer.files,e=0,g=d.length;g>e;e++)b.addFile.call(b,d[e]);c.preventDefault(),c.stopPropagation()}}).on("dragover",function(a){a.preventDefault(),a.stopPropagation()}),f.find("input").on("click",function(a){a.stopPropagation()}).on("change",function(){if("undefined"!=typeof this.files)for(var a=0,c=this.files.length;c>a;a++)b.addFile.call(b,this.files[a])})),b.refresh()},addFile:function(b){var c,d=this,e=this.options,f=a(d.el).data("selected"),g={name:b.name,type:b.type,modified:b.lastModifiedDate,size:b.size,content:null,file:b},h=0,i=0;for(var j in f){if(f[j].name==b.name&&f[j].size==b.size)return;h+=f[j].size,i++}var k=d.trigger({phase:"before",type:"add",target:d.el,file:g,total:i,totalSize:h});if(k.isCancelled!==!0){if(0!==e.maxFileSize&&g.size>e.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){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++),(1>a||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;43>q;q++){if(0===k&&1==q){for(var r=0;6>r;r++)n+='';q+=6}else if(k>q||o>f[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;c>=g;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;24>d;d++){var e=(d>=12&&!c?d-12:d)+":00"+(c?"":12>d?" 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;60>e;e+=5){var f=(a>12&&!c?a-12:a)+":"+(10>e?0:"")+e+" "+(c?"":12>a?"am":"pm"),g=f,h=20>e?0:40>e?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='
    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]),-1!=a.indexOf("pm")&&12!=b[0]&&(b[0]+=12),60*b[0]+b[1])},fromMin:function(a){var b="";a>=1440&&(a%=1440),0>a&&(a=1440+a);var c=Math.floor(a/60),d=(10>a%60?"0":"")+a%60,e=this.options;return null==e&&(e={format:w2utils.settings.timeFormat}),b=-1!=e.format.indexOf("h24")?c+":"+d:(12>=c?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.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&&(-1==String(h.formHTML).indexOf("w2ui-page")&&(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:"Return data is not in 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,$.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});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(e){}if(!$.isEmptyObject(obj.routeData)){var info=w2utils.parseRoute(url);if(info.keys.length>0)for(var k=0;k";switch(f.type){case"pass":case"password":g='";break;case"checkbox":g='";break;case"radio":g="";var h=f.options.items?f.options.items:f.html.items;$.isArray(h)||(h=[]),h.length>0&&(h=w2obj.field.prototype.normMenu(h));for(var i=0;i '+h[i].text+"
    ";break;case"select":g='";break;case"textarea":g='";break;case"toggle":g='
    '}f.html.group&&(""!=c&&(e+="\n "),e+='\n
    '+f.html.group+'
    \n
    ',c=f.html.group),f.html.page!=a&&""!=c&&(b[b.length-1]+="\n
    ",c=""),e+='\n
    \n \n
    "+g+w2utils.lang(f.html.text)+"
    \n
    ",null==b[f.html.page]&&(b[f.html.page]=""),b[f.html.page]+=e,a=f.html.page}if(""!=c&&(b[b.length-1]+="\n "),this.tabs.tabs)for(var i=0;i'+b[j]+"\n";var k="";if(!$.isEmptyObject(this.actions)){k+='\n
    ';for(var l in this.actions){var m=this.actions[l],n={caption:"",style:"","class":""};$.isPlainObject(m)?(m.caption&&(n.caption=m.caption),m.style&&(n.style=m.style),m["class"]&&(n["class"]=m["class"])):(n.caption=l,-1!=["save","update","create"].indexOf(l.toLowerCase())?n["class"]="w2ui-btn-blue":n["class"]=""),k+='\n "}k+="\n
    "}return b.join("")+k},action:function(a,b){var c=null,d=this.actions[a],c=d;$.isPlainObject(d)&&d.onClick&&(c=d.onClick);var e=this.trigger({phase:"before",target:a,type:"action",click:c,originalEvent:b});e.isCancelled!==!0&&("function"==typeof c&&c.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;100>g;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;f>g;g++){var a=this.fields[g];null==a.name&&null!=a.field&&(a.name=a.field),null==a.field&&null!=a.name&&(a.field=a.name),a.$el=$(this.box).find('[name="'+String(a.name).replace(/\\/g,"\\\\")+'"]'),a.el=a.$el[0],null==a.el&&console.log('ERROR: Cannot associate field "'+a.name+'" with html control. Make sure html control exists with the same name.'),a.el&&(a.el.id=a.name);var h=$(a).data("w2field");h&&h.clear(),$(a.$el).off("change").on("change",function(){var a=this.value,b=c.record[this.name]?c.record[this.name]:"",d=c.get(this.name);if(-1!=["list","enum","file"].indexOf(d.type)&&$(this).data("selected")){var e=$(this).data("selected"),f=c.record[this.name];if($.isArray(e)){a=[];for(var g=0;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;f>g;g++){var a=this.fields[g],i=null!=this.record[a.name]?this.record[a.name]:"";if(a.el)switch($(a.el).hasClass("w2ui-input")||$(a.el).addClass("w2ui-input"),a.type=String(a.type).toLowerCase(),a.options||(a.options={}),a.type){case"text":case"textarea":case"email":case"pass":case"password":a.el.value=i;break;case"int":case"float":case"money":case"currency":case"percent":a.el.value=i,$(a.el).w2field($.extend({},a.options,{type:a.type}));break;case"hex":case"alphanumeric":case"color":case"date":case"time":a.el.value=i,$(a.el).w2field($.extend({},a.options,{type:a.type}));break;case"toggle":w2utils.isFloat(i)&&(i=parseFloat(i)),$(a.el).prop("checked",i?!0:!1),this.record[a.name]=i?i:!1;break;case"list":case"combo":if("list"==a.type){var j=$.isPlainObject(i)?i.id:$.isPlainObject(a.options.selected)?a.options.selected.id:i;a.options.items||(a.options.items=[]);var k=a.options.items;$.isArray(k)&&k.length>0&&!$.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("input, select, textarea");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})),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.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)),setTimeout(function(){d.resize(),d.refresh()},150),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); \ No newline at end of file +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:b>a?-e:0}var i="object"!=typeof this.url?this.url:this.url.get;if(i)return void console.log("ERROR: grid.localSort can only be used on local data source, grid.url should be empty.");if(!$.isEmptyObject(this.sortData)){var j=(new Date).getTime(),k=this;k.selectionSave(),k.prepareData(),b||k.reset();for(var l=0;l=parseFloat(k)&&parseFloat(f.parseField(a,h.field))<=parseFloat(l)&&c++,"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&&l>j&&c++}if("time"==h.type){var j=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),k=w2utils.isTime(k,!0),l=w2utils.isTime(l,!0);k=(new Date).setHours(k.hours,k.minutes,k.seconds?k.seconds:0,0),l=(new Date).setHours(l.hours,l.minutes,l.seconds?l.seconds:0,0),j>=k&&l>j&&c++}break;case"less":if(-1!=["int","float","money","currency","percent"].indexOf(h.type))parseFloat(f.parseField(a,h.field))<=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");k>=j&&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");k>=j&&c++}break;case"more":if(-1!=["int","float","money","currency","percent"].indexOf(h.type))parseFloat(f.parseField(a,h.field))>=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++}break;case"in":var m=e.value;e.svalue&&(m=e.svalue),-1!==m.indexOf(w2utils.isFloat(j)?parseFloat(j):j)&&c++,-1!==m.indexOf(w2utils.isFloat(i)?parseFloat(i):i)&&c++;break;case"not in":var m=e.value;e.svalue&&(m=e.svalue),-1==m.indexOf(w2utils.isFloat(j)?parseFloat(j):j)&&c++,-1==m.indexOf(w2utils.isFloat(i)?parseFloat(i):i)&&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);-1!==n&&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=h;h++){var i=this.records[h],j=i[this.columns[e].field]||null;b!==!0?g.push(j):g.push({data:j,column:e,index:h,record:i})}else if(c==d)for(var i=this.records[c],k=e;f>=k;k++){var j=i[this.columns[k].field]||null;b!==!0?g.push(j):g.push({data:j,column:k,index:c,record:i})}else for(var h=c;d>=h;h++){var i=this.records[h];g.push([]);for(var k=e;f>=k;k++){var j=i[this.columns[k].field];b!==!0?g[g.length-1].push(j):g[g.length-1].push({data:j,column:k,index:h,record:i})}}return g},addRange:function(a){var b=0;if("row"==this.selectType)return b;$.isArray(a)||(a=[a]);for(var c=0;c=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(-1!=b.indexes.indexOf(g))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]||[];-1==b.indexes.indexOf(g)&&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;ff;f++)d.indexes.push(f),"row"!=this.selectType&&(d.columns[f]=e.slice())}else for(var 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:y};d.push(v)}}}else for(var j=0;j0&&b[0].focus()}})}},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(),null!=b&&c.focus()}else{var d=this.getSearch(a);if(null==d)return;var e=d.type;-1!=["enum","select"].indexOf(e)&&(e="list"),c.w2field(e,$.extend({},d.options,{suffix:"",autoFormat:!1,selected:b})),-1!=["list","enum","date","time"].indexOf(d.type)&&(this.last.search="",this.last.item="",c.val("")),setTimeout(function(){null!=b&&c.focus()},1)}""!=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",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)+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});if(f.isCancelled===!0)return void("function"==typeof d&&d({status:"error",message:"Request aborted."}))}else var f={url:c,postData:e};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(i){}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 j=w2utils.parseRoute(c);if(j.keys.length>0)for(var k=0;kc.width()&&c.width(e+20)}catch(g){}}var f=this,g=f.get(a,!0),h=f.records[g],i=f.columns[b],j=i.frozen===!0?"_f":"_",k=h&&h.w2ui?h.w2ui.editable:null;if((null==k||k===!0)&&(k=i?i.editable:null),h&&i&&k&&(!h.w2ui||h.w2ui.editable!==!1)){if(-1!=["enum","file"].indexOf(k.type))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,-1==["checkbox","check"].indexOf(k.type))){var m=$("#grid_"+f.name+j+"rec_"+w2utils.escapeId(a)),n=m.find("[col="+b+"] > div");$(this.box).find("div.w2ui-edit-box").remove(),"row"!=this.selectType&&($("#grid_"+this.name+j+"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==k.inTag&&(k.inTag=""),null==k.outTag&&(k.outTag=""),null==k.style&&(k.style=""),null==k.items&&(k.items=[]);var o=h.w2ui&&h.w2ui.changes&&null!=h.w2ui.changes[i.field]?w2utils.stripTags(h.w2ui.changes[i.field]):w2utils.stripTags(h[i.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!=i.style?i.style+";":"";if("string"==typeof i.render&&-1!=["number","int","float","money","percent","size"].indexOf(i.render.split(":")[0])&&(q+="text-align: right;"),k.items.length>0&&!$.isPlainObject(k.items[0])&&(k.items=w2obj.field.prototype.normMenu(k.items)),"select"==k.type){for(var r="",s=0;s"+k.items[s].text+"";n.addClass("w2ui-editable").html('"+k.outTag),setTimeout(function(){n.find("select").focus().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)}else if("div"==k.type){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('
    "+k.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:"")}else{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('"+k.outTag),"number"==k.type&&(o=w2utils.formatNumber(o)),"date"==k.type&&(o=w2utils.formatDate(w2utils.isDate(o,k.format,!0),k.format)),null==c&&n.find("input").val("object"!=typeof o?o:"");var v=n.find("input").get(0);$(v).w2field(k.type,$.extend(k,{selected:o})),setTimeout(function(){var a=v;"list"==k.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(){if(n.find("input, select, div.w2ui-input").data("old_value",p).on("mousedown",function(a){a.stopPropagation()}).on("click",function(a){"div"==k.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,j="DIV"==d.tagName.toUpperCase()?$(d).text():$(d).val();switch(c.keyCode){case 8:"list"!=k.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)==j.length&&(w2utils.setCursorPosition(d,j.length),c.preventDefault())}setTimeout(function(){switch(c.keyCode){case 9:var j=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){j=f.records[l].recid;for(var m=0;m0&&(d.focus(),clearTimeout(f.last.kbd_timer),null!=c?w2utils.setCursorPosition(d[0],$(d).text().length):w2utils.setCursorPosition(d[0],0,$(d).text().length),e.call(n.find("div.w2ui-input")[0],null))}else{var d=n.find("input, select");d.length>0&&(d[0].focus(),clearTimeout(f.last.kbd_timer),null!=c?d[0].setSelectionRange(d.val().length,d.val().length):d[0].select&&d[0].select(),e.call(n.find("input, select")[0],null))}d.length>0&&(d[0].resize=e),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=0>b;b=0>b?-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;o>=p;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;m>=s;s++)if(!(this.searchData.length>0)||r||-1!=$.inArray(s,this.last.searchIds))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)?!0:!1),"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;i>=j;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;ja)&&(a=0),d.select({recid:d.records[a].recid,column:0})}function c(){if("click"!=d.last.sel_type)return!1;if("row"!=d.selectType){if(d.last.sel_type="key",i.length>1){for(var a=0;a1?(i.splice(i.indexOf(d.records[d.last.sel_ind].recid),1),d.unselect.apply(d,i),!0):!1}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 70:if(!a.metaKey&&!a.ctrlKey)break;$("#grid_"+d.name+"_search_all").focus(),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 u=this.records[n].w2ui||{};!u||null==u.parent_recid||Array.isArray(u.children)&&0!=u.children.length&&u.expanded?d.collapse(j,a):(d.unselect(j),d.collapse(u.parent_recid,a),d.select(u.parent_recid))}else{var v=d.prevCell(n,k[0]);if(s||null!=v||(this.selectNone(),v=0),null!=v)if(s&&d.multiSelect){if(c())return;var u=[],w=[],x=[];if(0==k.indexOf(this.last.sel_col)&&k.length>1){for(var y=0;y1)d.selectNone();else for(var z=1;z1){for(var y=0;y1)d.selectNone();else for(var z=0;zv&&d.last.sel_ind!=o?d.unselect(d.records[o].recid):d.select(d.records[v].recid);else if(d.last.sel_ind>v&&d.last.sel_ind!=o){v=o;for(var u=[],t=0;t300?this.selectNone():this.unselect.apply(this,i),d.click({recid:d.records[v].recid,column:k[0]},a);d.scrollIntoView(v),a.preventDefault&&a.preventDefault()}else if(!s)if(i.length>1)d.selectNone();else for(var z=1;z300?this.selectNone():this.unselect.apply(this,i),d.click({recid:d.records[A].recid,column:k[0]},a);d.scrollIntoView(A),q=!0}else if(!s)if(i.length>1)d.selectNone();else for(var z=0;z=y;y++)u.push(y);-1==u.indexOf(r)||a.ctrlKey||a.metaKey||q||(0==k.length&&k.push(0),q=!1,setTimeout(function(){var b=$("#grid_"+d.name+"_focus"),c=b.val();b.val(""),d.editField(j,k[0],c,a)},1)),q&&a.preventDefault&&a.preventDefault(),d.trigger($.extend(f,{phase:"after"}))}}},scrollIntoView:function(a,b,c){var d=this.records.length;if(0==this.searchData.length||this.url||(d=this.last.searchIds.length),0!=d){if(null==a){var e=this.getSelection();if(0==e.length)return;$.isPlainObject(e[0])?(a=e[0].index,b=e[0].column):a=this.get(e[0],!0)}var f=$("#grid_"+this.name+"_records"),g=this.last.searchIds.length;if(g>0&&(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.animate({scrollTop:f.scrollTop()-f.height()/1.3},250,"linear")),a==i&&(c===!0?f.prop({scrollTop:f.scrollTop()+f.height()/1.3}):f.animate({scrollTop:f.scrollTop()+f.height()/1.3},250,"linear")),(h>a||a>i)&&(c===!0?f.prop({scrollTop:(a-1)*this.recordHeight}):f.animate({scrollTop:(a-1)*this.recordHeight},250,"linear"))}if(null!=b){for(var j=0,k=0,l=w2utils.scrollBarSize(),m=0;b>=m;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"});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"});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.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),-1==g.indexOf(c[h].index)&&g.push(c[h].index);g.sort(function(a,b){return a-b});for(var i=0;i=k;k++){var l=this.columns[k];l.hidden!==!0&&(d+=w2utils.stripTags(this.getCellHTML(j,k))+" ")}d=d.substr(0,d.length-1),d+="\n"}}else{for(var k=0;k 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(!(0>c)){var d=this.records[c]||{};d.w2ui||(d.w2ui={});for(var e=0;ec))if(null!=c&&null!=e){var d=this.records[c]||{},f=$(this.box).find("#grid_"+this.name+"_data_"+c+"_"+e);d.w2ui||(d.w2ui={}),f.replaceWith(this.getCellHTML(c,e,!1)),null==d.w2ui.style||$.isEmptyObject(d.w2ui.style)?f.attr("style",""):("string"==typeof d.w2ui.style&&$(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(d.recid)).attr("style",d.w2ui.style),$.isPlainObject(d.w2ui.style)&&"string"==typeof d.w2ui.style[e]&&f.attr("style",d.w2ui.style[e]))}else console.log("ERROR: Wrong argument for grid.update(cells), cells should be [{ index: X, column: Y }, ...]")}return(new Date).getTime()-b},refreshCell:function(a,b){var c=this.get(a,!0),d=this.records[c]&&this.records[c].recid==a?!1:!0,e=this.getColumn(b,!0),f=d?this.summary[c]:this.records[c],g=this.columns[e],h=$(this.box).find("#grid_"+this.name+"_data_"+c+"_"+e);h.replaceWith(this.getCellHTML(c,e,d)),f.w2ui&&f.w2ui.changes&&null!=f.w2ui.changes[g.field]?h.addClass("w2ui-changed"):h.removeClass("w2ui-changed"),f.w2ui&&null!=f.w2ui.style&&!$.isEmptyObject(f.w2ui.style)?("string"==typeof f.w2ui.style&&$(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(f.recid)).attr("style",f.w2ui.style),$.isPlainObject(f.w2ui.style)&&"string"==typeof f.w2ui.style[e]&&h.attr("style",f.w2ui.style[e])):h.attr("style","")},refreshRow:function(a,b){var c=$(this.box).find("#grid_"+this.name+"_frec_"+w2utils.escapeId(a)),d=$(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(a));if(c.length>0){null==b&&(b=this.get(a,!0));var e=c.attr("line"),f=this.records[b]&&this.records[b].recid==a?!1:!0,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){this.summary=[];for(var f=0;f=0;f--)this.records.splice(e[f],1)}a.scroll();var j=this.getRecordsHTML(),k=this.getColumnsHTML(),l='
    '+j[0]+'
    "+j[1]+'
    '+k[0]+'
    '+k[1]+"
    ";if($("#grid_"+this.name+"_body").html(l),this.summary.length>0){var m=this.getSummaryHTML();$("#grid_"+this.name+"_fsummary").html(m[0]).show(),$("#grid_"+this.name+"_summary").html(m[1]).show()}else $("#grid_"+this.name+"_fsummary").hide(),$("#grid_"+this.name+"_summary").hide();this.show.footer?$("#grid_"+this.name+"_footer").html(this.getFooterHTML()).show():$("#grid_"+this.name+"_footer").hide(),this.searchData.length>0?$("#grid_"+this.name+"_searchClear").show():$("#grid_"+this.name+"_searchClear").hide();var n=this.last.selection,o=this.records.length>0&&n.indexes.length==this.records.length,p=n.indexes.length>0&&0!==this.searchData.length&&n.indexes.length==this.last.searchIds.length;o||p?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status();for(var q=a.find({"w2ui.expanded":!0},!0),r=0;r0&&$(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}}},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)return;for(var b=a.target,f={x:a.offsetX-10,y:a.offsetY-10},g=!1;b&&!b.classList.contains("w2ui-grid");)"TD"==b.tagName.toUpperCase()&&(g=!0),"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;setTimeout(function(){var a=$(e.box).find("#grid_"+e.name+"_focus");a.is(":focus")||a.focus(),e.last.move&&a.css({left:e.last.move.focusX-$(e.box).find("#grid_"+e.name+"_records").scrollLeft(),top:e.last.move.focusY-$(e.box).find("#grid_"+e.name+"_records").scrollTop()}),setTimeout(function(){-1!=["INPUT","TEXTAREA","SELECT"].indexOf(h.tagName.toUpperCase())&&$(h).focus()},50)},1)}if(1==e.reorderRows){var i=a.target;if("TD"!=i.tagName.toUpperCase()&&(i=$(i).parents("td")[0]),$(i).hasClass("w2ui-col-number")){e.selectNone(),e.last.move.reorder=!0;var j=$(e.box).find(".w2ui-even.w2ui-empty-record").css("background-color"),k=$(e.box).find(".w2ui-odd.w2ui-empty-record").css("background-color");$(e.box).find(".w2ui-even td").not(".w2ui-col-number").css("background-color",j),$(e.box).find(".w2ui-odd td").not(".w2ui-col-number").css("background-color",k);var l=e.last.move;if(!l.ghost){var m=$("#grid_"+e.name+"_rec_"+l.recid),b=m.parents("table").find("tr:first-child").clone();l.offsetY=a.offsetY,l.from=l.recid,l.pos=m.position(),l.ghost=$(m).clone(!0),l.ghost.removeAttr("id"),m.find("td").remove(),m.append('');var n=$(e.box).find(".w2ui-grid-records");n.append('
    '),$("#grid_"+e.name+"_ghost").append(b).append(l.ghost)}var o=$("#grid_"+e.name+"_ghost"),n=$(e.box).find(".w2ui-grid-records");o.css({top:l.pos.top+n.scrollTop(),left:l.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)}}function c(a){var b=e.last.move;if(b&&-1!=["select","select-column"].indexOf(b.type)&&(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;q>=t;t++)if(!(e.last.searchIds.length>0&&-1==e.last.searchIds.indexOf(t)))if("row"!=e.selectType){if(r>s){var c=r;r=s,s=c}for(var c=[],u=r;s>=u;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.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 ")}b+='';var f="object"!=typeof this.url?this.url:this.url.get;f&&a.show.skipRecords&&(b+='"),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;r>q;q++)if($(a.originalEvent.target).parents().hasClass(n[q]))return;if(j.numberPreColumnsPresent=$(i.box).find(p).length,j.columnHead=h=$(a.originalEvent.target).parents(".w2ui-head"),k=parseInt(h.attr("col"),10),c=i.trigger({type:"columnDragStart",phase:"before",originalEvent:a,origColumnNumber:k,target:h[0]}),c.isCancelled===!0)return!1;f=j.columns=$(i.box).find(".w2ui-head:not(.w2ui-head-last)"),$(document).on("mouseup",e),$(document).on("mousemove",d),j.originalPos=parseInt($(a.originalEvent.target).parent(".w2ui-head").attr("col"),10),j.ghost=$(b).clone(!0),$(j.ghost).find('[col]:not([col="'+j.originalPos+'"]), .w2ui-toolbar, .w2ui-grid-header').remove(),$(j.ghost).find(o).remove(),$(j.ghost).find(".w2ui-grid-body").css({top:0}),g=$(j.ghost).find('[col="'+j.originalPos+'"]'),$(document.body).append(j.ghost),$(j.ghost).css({width:0,height:0,margin:0,position:"fixed",zIndex:999999,opacity:0}).addClass(".w2ui-grid-ghost").animate({width:g.width(),height:$(i.box).find(".w2ui-grid-body:first").height(),left:a.pageX,top:a.pageY,opacity:.8},0),j.offsets=[];for(var q=0,r=f.length;r>q;q++)j.offsets.push($(f[q]).offset().left);i.trigger($.extend(c,{phase:"after"}))}}},150)}function d(a){if(j.pressed){var b=a.originalEvent.pageX,c=a.originalEvent.pageY,d=j.offsets,e=$(".w2ui-head:not(.w2ui-head-last)").width();j.targetInt=Math.max(j.numberPreColumnsPresent,g(b,d,e)),f(j.targetInt),h(b,c)}}function e(a){j.pressed=!1;var b,c,f,g,h,k=$(".w2ui-grid-ghost");return b=i.trigger({type:"columnDragEnd",phase:"before",originalEvent:a,target:j.columnHead[0]}),b.isCancelled===!0?!1:(f=i.columns[j.originalPos],g=i.columns,h=$(j.columns[Math.min(j.lastInt,j.columns.length-1)]),c=j.lastInt
    '),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;e>d;d++){var f=b[d],g=b[d+1]||b[d]+c,h=(g-b[d])/2+b[d];if(a>f&&h>=a)return d;if(a>h&&g>=a)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(){var a=this;$(this.box).find(".w2ui-empty-record").remove();var b=$(this.box),c=$(this.box).find("> div.w2ui-grid-box"),d=$("#grid_"+this.name+"_header"),e=$("#grid_"+this.name+"_toolbar"),f=$("#grid_"+this.name+"_summary"),g=$("#grid_"+this.name+"_fsummary"),h=$("#grid_"+this.name+"_footer"),i=$("#grid_"+this.name+"_body"),j=$("#grid_"+this.name+"_columns"),k=$("#grid_"+this.name+"_fcolumns"),l=$("#grid_"+this.name+"_records"),m=$("#grid_"+this.name+"_frecords"),n=$("#grid_"+this.name+"_scroll1"),o=8*String(this.total).length+10;34>o&&(o=34),null!=this.lineNumberWidth&&(o=this.lineNumberWidth);for(var p=!1,q=!1,r=0,s=0;stable").height()+(p?w2utils.scrollBarSize():0)&&(q=!0),this.fixedBody){var u=c.height()-(this.show.header?w2utils.getSize(d,"height"):0)-(this.show.toolbar?w2utils.getSize(e,"height"):0)-("none"!=f.css("display")?w2utils.getSize(f,"height"):0)-(this.show.footer?w2utils.getSize(h,"height"):0);i.css("height",u)}else{var u=w2utils.getSize(j,"height")+w2utils.getSize($("#grid_"+a.name+"_records table"),"height")+(p?w2utils.scrollBarSize():0);a.height=u+w2utils.getSize(c,"+height")+(a.show.header?w2utils.getSize(d,"height"):0)+(a.show.toolbar?w2utils.getSize(e,"height"):0)+("none"!=f.css("display")?w2utils.getSize(f,"height"):0)+(a.show.footer?w2utils.getSize(h,"height"):0),c.css("height",a.height),i.css("height",u),b.css("height",w2utils.getSize(c,"height")+w2utils.getSize(b,"+height"))}var v=this.records.length,w="object"!=typeof this.url?this.url:this.url.get;if(0==this.searchData.length||w||(v=this.last.searchIds.length),this.fixedBody||(q=!1),p||q?(j.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show(),l.css({top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(j,"height")+"px","-webkit-overflow-scrolling":"touch","overflow-x":p?"auto":"hidden","overflow-y":q?"auto":"hidden"})):(j.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").hide(),l.css({top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(j,"height")+"px",overflow:"hidden"}),l.length>0&&(this.last.scrollTop=0,this.last.scrollLeft=0)),p?(m.css("margin-bottom",w2utils.scrollBarSize()),n.show()):(m.css("margin-bottom",0),n.hide()),m.css({overflow:"hidden",top:l.css("top")}),this.show.emptyRecords&&!q){var x=Math.floor(l.height()/this.recordHeight)+1;if(this.fixedBody)for(var y=v;x>=y;y++){var z="",A="",B="";z+='',A+='',this.show.lineNumbers&&(z+=''),this.show.selectColumn&&(z+=''),this.show.expandColumn&&(z+=''),A+='';for(var C=0;Cthis.last.colEnd)||D.frozen)&&(B='',D.frozen?z+=B:A+=B)}z+=' ',A+=' ',$("#grid_"+this.name+"_frecords > table").append(z),$("#grid_"+this.name+"_records > table").append(A)}}if(i.length>0){for(var E=parseInt(i.width())-(q?w2utils.scrollBarSize():0)-(this.show.lineNumbers?o:0)-(this.show.selectColumn?26:0)-(this.show.expandColumn?26:0)-1,F=E,G=0,H=!1,s=0;s0&&(D.gridMinWidth>F&&D.hidden!==!0&&(D.hidden=!0,H=!0),D.gridMinWidth0)for(var s=0;sparseInt(D.max)&&(D.sizeCalculated=D.max+"px"),I+=parseInt(D.sizeCalculated))}var J=parseInt(F)-parseInt(I);if(J>0&&G>0)for(var s=0;;){var D=this.columns[s];if(null!=D)if(D.hidden||"px"==D.sizeType)s++;else{if(D.sizeCalculated=parseInt(D.sizeCalculated)+1+"px",J--,0==J)break;s++}else s=0}else J>0&&j.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show();var K=1;this.show.lineNumbers&&(K+=o),this.show.selectColumn&&(K+=26),this.show.expandColumn&&(K+=26);for(var s=0;s table > tbody > tr:nth-child(1) td").add(k.find("> table > tbody > tr:nth-child(1) td")).each(function(b,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",o);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0==G?J:0)+"px")}),3==j.find("> table > tbody > tr").length&&j.find("> table > tbody > tr:nth-child(1) td").add(k.find("> table > tbody > tr:nth-child(1) td")).html("").css({height:"0px",border:"0px",padding:"0px",margin:"0px"}),l.find("> table > tbody > tr:nth-child(1) td").add(m.find("> table > tbody > tr:nth-child(1) td")).each(function(b,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",o);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0==G?J:0)+"px")}),f.find("> table > tbody > tr:nth-child(1) td").add(g.find("> table > tbody > tr:nth-child(1) td")).each(function(b,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",o);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0==G?J:0)+"px")}),this.initResize(),this.refreshRanges(),(this.last.scrollTop||this.last.scrollLeft)&&l.length>0&&(j.prop("scrollLeft",this.last.scrollLeft),l.prop("scrollTop",this.last.scrollTop),l.prop("scrollLeft",this.last.scrollLeft))},getSearchesHTML:function(){function a(a){for(var c="",d=0;d'+w2utils.lang(f)+""}return c}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"),-1!=["text","alphanumeric","combo"].indexOf(f.type))var h='";if(-1!=["int","float","money","currency","percent","date","time"].indexOf(f.type))var h='";if(-1!=["select","list","hex"].indexOf(f.type))var h='";if(-1!=["enum"].indexOf(f.type))var h='";switch(c+='"}}return c+='
    '+g+' '+(f.caption||"")+' '+h+' ',f.type){case"text":case"alphanumeric":case"hex":case"list":case"combo":case"enum":c+='";break;case"int":case"float":case"money":case"currency":case"percent":case"date":case"time":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"in":case"not in":f.w2field("clear");break;case"between":e.show(),g.w2field(d.type);break;case"not null":case"null":f.hide(),f.val("1"),f.change()}},initSearches:function(){for(var a=this,b=0;b'+j+""}else f+='"}$("#grid_"+this.name+"_field_"+b).html(f)}null!=d?("int"==d.type&&-1!=["in","not in"].indexOf(d.operator)&&$("#grid_"+this.name+"_field_"+b).w2field("clear").val(d.value),$("#grid_"+this.name+"_operator_"+b).val(d.operator).trigger("change"),$.isArray(d.value)?-1!=["in","not in"].indexOf(d.operator)?$("#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(e).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=i);else if(g.master===!0){for(var k="",l=0;l'),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;d>h;h++)e=this.getRecordHTML(h,h+1),f+=e[0],g+=e[1];return f+='
    ',g+=' ',this.last.range_start=0,this.last.range_end=d,[f,g]},getSummaryHTML:function(){if(0!=this.summary.length){for(var a="",b="",c="
    ",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&&(0>i&&(i=0),0>j&&(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(5>p&&5>q){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;i>m;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(jj;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;j>=m;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)+" "+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<=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;1>H&&(H=1),I>this.total&&(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");-1!=String(J.next().prop("id")).indexOf("_expanded_row")&&(J.next().remove(),L.next().remove()),this.total>I&&-1!=String(K.prev().prop("id")).indexOf("_expanded_row")&&(K.prev().remove(),M.prev().remove());var N=parseInt(J.next().attr("line")),O=parseInt(K.prev().attr("line"));if(H>N||1==N||this.last.pull_refresh){if(I<=O+this.last.show_extra-2&&I!=this.total)return;for(this.last.pull_refresh=!1;;){var P=f.find("#grid_"+this.name+"_frec_top").next(),Q=e.find("#grid_"+this.name+"_rec_top").next();if("bottom"==Q.attr("line"))break;if(!(parseInt(Q.attr("line"))=m;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);K.before(T[1]),M.before(T[0])}b(),setTimeout(function(){c.refreshRanges()},0)}else{if(H>=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;0>V&&(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
    ')}),-1==Y.find("td").text().indexOf("Load")&&Y.find("td").html("
    "+w2utils.lang("Load")+" "+c.limit+" "+w2utils.lang("More")+"...
    ")}E>=this.total-this.offset&&$("#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(-1==a){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);if(-1!=h.indexes.indexOf(a)&&(l=!0),f+='",g+='",this.show.lineNumbers&&(f+='"),this.show.selectColumn&&(f+='"),this.show.expandColumn){var m="";m=d.w2ui&&d.w2ui.expanded===!0?"-":"+",d.w2ui&&"none"==d.w2ui.expanded&&(m=""),d.w2ui&&"spinner"==d.w2ui.expanded&&(m='
    '),f+='"}g+='';for(var n=0,o=0;;){var p=1,j=this.columns[n];if(null==j)break;if(j.hidden)n++,o>0&&o--;else if(o>0){if(n++,null==this.columns[n])break;d.w2ui.colspan[this.columns[n].field]=0,o--}else if(!(nthis.last.colEnd)||j.frozen){if(d.w2ui&&"object"==typeof d.w2ui.colspan){var q=parseInt(d.w2ui.colspan[j.field])||null;if(q>1){for(var r=0,i=n;n+q>i&&!(i>=this.columns.length);i++)this.columns[i].hidden&&r++;p=q-r,o=q-1}}var s=this.getCellHTML(a,n,c,p);j.frozen?f+=s:g+=s,n++}else n++}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=e.editable,i="max-height: "+parseInt(this.recordHeight)+"px;",j=!c&&f&&f.w2ui&&f.w2ui.changes&&null!=f.w2ui.changes[e.field],k="",l=this.last.selection,m=!1,n="";if(-1!=l.indexes.indexOf(a)&&(m=!0),null==d&&(d=1),0==b&&f&&f.w2ui&&Array.isArray(f.w2ui.children)){for(var o=0,p=this.get(f.w2ui.parent_recid,!0);;){if(null==p)break;o++;var q=this.records[p].w2ui;if(null==q||null==q.parent_recid)break;p=this.get(q.parent_recid,!0)}for(var r=0;o>r;r++)n+='';n+='"}if(e.info===!0&&(e.info={}),null!=e.info&&(e.info.icon||(e.info.icon="w2ui-icon-info"),n+=''),null!=e.render){if("function"==typeof e.render&&(g=$.trim(e.render.call(this,f,a,b)),(g.length<4||"'+n+String(g)+"")),"object"==typeof e.render&&(g='
    '+n+(e.render[g]||"")+"
    "),"string"==typeof e.render){var s=e.render.toLowerCase().indexOf(":"),q=[];-1==s?(q[0]=e.render.toLowerCase(),q[1]=""):(q[0]=e.render.toLowerCase().substr(0,s),q[1]=e.render.toLowerCase().substr(s+1));var t=w2utils.formatters[q[0]];g='
    '+n+("function"==typeof t?t(g,q[1]):"")+"
    "}}else{if(h&&-1!=["checkbox","check"].indexOf(h.type)){var u=c?-(a+1):a;i+="text-align: center;",g='',n=""}if(this.show.recordTitles){var v=w2utils.stripTags(String(g).replace(/"/g,"''"));null!=e.title&&("function"==typeof e.title&&(v=e.title.call(this,f,a,b)),"string"==typeof e.title&&(v=e.title))}g='
    '+n+String(g)+"
    "}if(null==g&&(g=""),"string"==typeof e.render){var q=e.render.toLowerCase().split(":");-1!=["number","int","float","money","currency","percent","size"].indexOf(q[0])&&(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]+";"));var w=!1;return m&&-1!=$.inArray(b,l.columns[a])&&(w=!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(),null==d.fields&&"function"==typeof d.render&&(d.fields=d.render),this.last.bubbleEl=f,null==d.fields){d.fields=[];for(var g=0;g1&&(w2utils.formatters[i[1]]?j=w2utils.formatters[i[1]](j,i[2]||null):console.log('ERROR: w2utils.formatters["'+i[1]+'"] does not exists.')),(d.showEmpty===!0||null!=j&&""!=j)&&(null!=d.maxLength&&"string"==typeof j&&j.length>d.maxLength&&(j=j.substr(0,d.maxLength)+"..."),c+="")}else c+=''}c+="
    "+(c!==!0?this.getLineHTML(b,d):"")+"'+(c!==!0?'
    ":"")+"
    '+(c!==!0?'
    "+m+"
    ":"")+"
    1?'colspan="'+d+'"':"")+">"+g+"
    "+h.caption+""+((0===j?"0":j)||"")+"
    "}else if($.isPlainObject(d.fields)){c='';for(var k in d.fields){var l=d.fields[k];if(""!=l&&"-"!=l&&"--"!=l&&"---"!=l){var i=String(l).split(":"),h=this.getColumn(i[0]);null==h&&(h={field:i[0],caption:i[0]});var j=h?this.parseField(e,h.field):"";i.length>1&&(w2utils.formatters[i[1]]?j=w2utils.formatters[i[1]](j,i[2]||null):console.log('ERROR: w2utils.formatters["'+i[1]+'"] does not exists.')),"function"==typeof l&&(j=l(e,a,b)),(d.showEmpty===!0||null!=j&&""!=j)&&(null!=d.maxLength&&"string"==typeof j&&j.length>d.maxLength&&(j=j.substr(0,d.maxLength)+"..."),c+="")}else c+=''}c+="
    "+k+""+(j||"")+"
    "}$(f).w2tag($.extend({html:c,left:-4,position:"bottom",className:"w2ui-info-bubble",style:"",hideOnClick:!0},d.options||{}))},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&&"list"==d.editable.type&&(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=Array.prototype.slice.call(arguments,0);c.unshift(this.box),setTimeout(function(){w2utils.lock.apply(window,c)},10)},unlock:function(a){var b=this.box;setTimeout(function(){w2utils.unlock(b,a)},25)},stateSave:function(a){if(!localStorage)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=g,b.last.scrollLeft=h,b.refresh()},1)}return this.trigger($.extend(f,{phase:"after"})),!0},stateReset:function(){if(this.stateRestore(this.last.state),localStorage)try{var a=$.parseJSON(localStorage.w2ui||"{}");a.states&&a.states[this.name]&&delete a.states[this.name],localStorage.w2ui=JSON.stringify(a)}catch(b){return delete localStorage.w2ui,null}},parseField:function(a,b){var c="";try{c=a;for(var d=String(b).split("."),e=0;ed)return null;var e=this.records[a].w2ui,f=this.columns[d],g=e&&e.colspan?e.colspan[f.field]:1,h=f?f.editable:null;return null==f?null:f&&f.hidden||0==g||1==c&&(null==h||-1!=["checkbox","check"].indexOf(h.type))?this.prevCell(a,d,c):d},nextRow:function(a,b){var c=this.last.searchIds;if(a+10&&a0)for(;;){if(-1!=$.inArray(a,c)||a>this.records.length)break;a++}return a}return null},prevRow:function(a,b){var c=this.last.searchIds;if(a>0&&0==c.length||c.length>0&&a>c[0]){if(a--,c.length>0)for(;;){if(-1!=$.inArray(a,c)||0>a)break;a--}return a}return null},selectionSave:function(){return this.last._selection=this.getSelection(),this.last._selection},selectionRestore:function(){var a=(new Date).getTime();this.last.selection={indexes:[],columns:{}};for(var b=this.last.selection,c=this.last._selection,d=0;d'+a+"",buttons:'",onOpen:function(a){setTimeout(function(){$(this.box).find(".w2ui-btn").focus()},25)}}),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?!1:(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?!1:(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;j>i;i++)h.panels[i]=a.extend(!0,{},b.prototype.panel,g[i]),(a.isPlainObject(h.panels[i].tabs)||a.isArray(h.panels[i].tabs))&&e(h,g[i].type),(a.isPlainObject(h.panels[i].toolbar)||a.isArray(h.panels[i].toolbar))&&f(h,g[i].type);for(var k=0;k0&&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(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){e.resize()},100)})}this.refresh(b)}return e.trigger(a.extend(g,{phase:"after"})),e.resize(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){e.resize()},100),!0}},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(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){f.resize()},100)}),!0):!1},sizeTo:function(b,c,d){var e=this,f=e.get(b);return null==f?!1:(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?!1:(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?!1:(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?!1:c.hidden?this.show(a,b):this.hide(a,b)},set:function(b,c){var d=this.get(b,!0);return null==d?!1:(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?!0:!1,u=null!=p&&p.hidden!==!0?!0:!1,v=null!=q&&q.hidden!==!0?!0:!1,w=null!=r&&r.hidden!==!0?!0:!1,x=null!=s&&s.hidden!==!0?!0:!1,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"),-1!=window.navigator.userAgent.indexOf("MSIE")&&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"),-1!=window.navigator.userAgent.indexOf("MSIE")&&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]?!1:(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(-1==c.indexOf(a))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(-1==c.indexOf(a))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?!0:!1,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():!1}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?!1:(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?!1:(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)),b>g-10&&(b=g-10),c>h-10&&(c=h-10);var i=(h-c)/2*.6,j=(g-b)/2;a("#w2ui-popup").css(w2utils.cssPrefix({transition:f.speed+"s width, "+f.speed+"s height, "+f.speed+"s left, "+f.speed+"s top"})).css({top:i,left:j,width:b,height:c});var k=setInterval(function(){e.resizeMessages()},10);setTimeout(function(){clearInterval(k),f.width=b,f.height=c,e.resizeMessages(),"function"==typeof d&&d()},1e3*f.speed+50)},restoreTemplate:function(){var b=a("#w2ui-popup").data("options");if(null!=b){var c=w2popup._template,d=b.title,e=b.body,f=b.buttons;if(w2popup._prev?(c=w2popup._prev.template,d=w2popup._prev.title,e=w2popup._prev.body,f=w2popup._prev.buttons,delete w2popup._prev):delete w2popup._template,null!=c){var g=a(c);if(0==g.length)return;"body"==a(e).attr("rel")?(d&&g.append(d),e&&g.append(e),f&&g.append(f)):g.append(e)}}}},a.extend(w2popup,w2utils.event)}(jQuery);var w2alert=function(a,b,c){var d=jQuery;null==b&&(b=w2utils.lang("Notification")),d("#w2ui-popup").length>0&&"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()}})},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}}};!function(a){var b=function(b){this.box=null,this.name=null,this.active=null,this.flow="down",this.tooltip="top",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+'
    "+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,0>=e&&(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",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()}})),-1!=["menu","menu-radio","menu-check"].indexOf(f.type)){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)&&-1!=f.selected.indexOf(b.id)?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()}}))}-1!=["color","text-color"].indexOf(f.type)&&(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)),-1!=["check","menu","menu-radio","menu-check","drop","color","text-color"].indexOf(f.type)&&(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=e&&(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)},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)):(-1!=["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(e.type)&&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?'":"")+(-1!=["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(a.type)&&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),-1!=["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(f.type)&&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);-1==g?(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):void 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});return e.isCancelled!==!0?(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):void 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?!1:(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)),-1!=a.inArray(b.keyCode,[13,32,37,38,39,40])&&(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()||0>=f)&&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});f.isCancelled!==!0&&(e.group||e.disabled||(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(-1==["INPUT","TEXTAREA","SELECT"].indexOf(b.target.tagName.toUpperCase())){var c=a(d.box).find("#sidebar_"+d.name+"_focus");c.is(":focus")||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?!1:!0});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").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):void 0},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;return f[c]?f[c].apply(f,Array.prototype.slice.call(arguments,1)):void 0},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):!1},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(-1==["INPUT","TEXTAREA"].indexOf(this.el.tagName.toUpperCase()))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"),-1!=["text","alphanumeric","hex","bin"].indexOf(this.type)&&(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=-1!=["list","enum","file"].indexOf(this.type)?a(this.el).data("selected"):a(this.el).val()},set:function(b){-1!=["list","enum","file"].indexOf(this.type)?(a(this.el).data("selected",b).change(),this.refresh()):a(this.el).val(b)},setIndex:function(b){var c=this.options.items;return c&&c[b]?(a(this.el).data("selected",c[b]).change(),this.refresh(),!0):!1},clear:function(){var b=this.options;-1!=["money","currency"].indexOf(this.type)&&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(-1!=["list"].indexOf(this.type)&&(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?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)),-1!=["enum","file"].indexOf(this.type)){var f="";for(var g in d){var h=d[g],i="";i="function"==typeof c.renderItem?c.renderItem(h,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")){c.stopPropagation();var g=b.trigger({phase:"before",type:"click",target:b.el,originalEvent:c.originalEvent,item:f});if(g.isCancelled!==!0){if(a(c.target).hasClass("w2ui-list-remove")){if(a(b.el).attr("readonly")||a(b.el).attr("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)}if("file"==b.type&&!a(c.target).hasClass("w2ui-list-remove")){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");26>m&&(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(),-1!=["int","float","money","currency","percent"].indexOf(this.type)&&("string"==typeof b&&(c.autoFormat&&-1!=["money","currency"].indexOf(this.type)&&(b=String(b).replace(c.moneyRE,"")),c.autoFormat&&"percent"==this.type&&(b=String(b).replace(c.percentRE,"")),c.autoFormat&&-1!=["int","float"].indexOf(this.type)&&(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(-1!=["int","float","money","currency","percent"].indexOf(this.type)){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(-1!=["list","enum","file"].indexOf(this.type)&&(c.refresh(),setTimeout(function(){c.refresh()},5)),-1!=["date","time","datetime"].indexOf(this.type)){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(),-1!=["list","combo","enum"].indexOf(this.type)&&(a(this.el).is(":focus")||this.focus(b)),-1!=["date","time","color","datetime"].indexOf(this.type)&&this.updateOverlay()},focus:function(b){var c=this;this.options;if(-1!==["color","date","time","datetime"].indexOf(c.type)){if(a(c.el).attr("readonly")||a(c.el).attr("disabled"))return;a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),setTimeout(function(){c.updateOverlay()},150)}if(-1!=["list","combo","enum"].indexOf(c.type)){if(a(c.el).attr("readonly")||a(c.el).attr("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();-1!=["color","date","time","list","combo","enum","datetime"].indexOf(c.type)&&a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),-1!=["int","float","money","currency","percent"].indexOf(c.type)&&(""===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)))),-1!=["date","time","datetime"].indexOf(c.type)&&(""===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(-1!=["int","float","money","currency","percent","hex","bin","color","alphanumeric"].indexOf(b.type)){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}-1!=["date","time","datetime"].indexOf(b.type)&&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(-1!=["int","float","money","currency","percent"].indexOf(d.type)){if(!e.keyboard||a(d.el).attr("readonly"))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).attr("readonly"))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).attr("readonly"))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).attr("readonly"))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).attr("readonly"))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(-1!=["list","combo","enum"].indexOf(d.type)){if(a(d.el).attr("readonly"))return;var q=a(d.el).data("selected"),r=a(d.el),s=!1;switch(-1!=["list","enum"].indexOf(d.type)&&("list"==d.type&&(r=a(d.helpers.focus).find("input")),"enum"==d.type&&(r=a(d.helpers.multi).find("input")),-1==[37,38,39,40].indexOf(f)&&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){if("color"==this.type&&86==b.keyCode&&(b.ctrlKey||b.metaKey)&&a(this).prop("maxlength",6),-1!=["list","combo","enum"].indexOf(this.type)&&-1==[16,17,18,20,37,39,91].indexOf(b.keyCode)){var c=a(this.helpers.focus).find("input");0==c.length&&(c=a(this.el));var d=this.trigger({phase:"before",type:"search",originalEvent:b,target:c,search:c.val()});if(d.isCancelled===!0)return;this.tmp.force_hide||this.request(),1==c.val().length&&this.refresh(),(0==a("#w2ui-overlay").length||-1==[38,40].indexOf(b.keyCode))&&this.search(),this.trigger(a.extend(d,{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(j){}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)}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=i&&(c.index=-1),c.spinner=!1,b.updateOverlay(),setTimeout(function(){var b=a("#w2ui-overlay").html()||"";c.markSearch&&-1!=b.indexOf("$.fn.w2menuHandler")&&a("#w2ui-overlay").w2marker(d)},1)}else c.items.splice(0,c.cacheMax),c.spinner=!0,b.updateOverlay()},updateOverlay:function(b){var c=this,d=this.options;if("color"==this.type){if(a(c.el).attr("readonly"))return;a(this.el).w2color({color:a(this.el).val(),transparent:d.transparent},function(b){null!=b&&a(c.el).val(b).change()})}if("date"==this.type){if(a(c.el).attr("readonly"))return;0==a("#w2ui-overlay").length&&a(c.el).w2overlay('
    ',{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 n(b,d){a("#w2ui-overlay > div > div").html(c.getMonthHTML(b,d,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 b,d;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"),d=a(this).attr("name")),a(this).hasClass("w2ui-jump-year")&&(a(this).parent().find(".w2ui-jump-year").removeClass("selected"),a(this).addClass("selected"),b=a(this).attr("name")),null!=b&&null!=d&&(a("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout(function(){n(parseInt(d)+1,b)},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,n(a[0],a[1])}),a("#w2ui-overlay .next").on("mousedown",function(){var a=c.options.current.split("/");a[0]=parseInt(a[0])+1,n(a[0],a[1])})}(e,f)}if("time"==this.type){if(a(c.el).attr("readonly"))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?"":12>d?" 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)+":"+(10>d?0:"")+d+(h?"":12>b?" 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).attr("readonly"))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.isDate(a(c.el).val(),c.options.format,!0);g&&(e=g.getMonth()+1,f=g.getFullYear());var i=null;!function o(b,e){a("#w2ui-overlay > div > div").html(c.getMonthHTML(b,e,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 b,d;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"),d=a(this).attr("name")),a(this).hasClass("w2ui-jump-year")&&(a(this).parent().find(".w2ui-jump-year").removeClass("selected"),a(this).addClass("selected"),b=a(this).attr("name")),null!=b&&null!=d&&(a("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout(function(){o(parseInt(d)+1,b)},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,o(a[0],a[1])}),a("#w2ui-overlay .next").on("mousedown",function(){var a=c.options.current.split("/");a[0]=parseInt(a[0])+1,o(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(-1!=["list","combo","enum"].indexOf(this.type)){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)&&-1==d.index&&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&&i>=j&&(d=!0)}else d=!0;if(this.options.blocked&&-1!=a.inArray(b,this.options.blocked)&&(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;k>l;l++)e.getDay()==this.options.blockWeekDays[l]&&(d=!1)}}else if("time"==this.type)if(this.options.start||this.options.end){var m=this.toMin(b),n=this.toMin(this.options.start),o=this.toMin(this.options.end);n||(n=m),o||(o=m),m>=n&&o>=m&&(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&&i>=j&&(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&&-1!=e&&(c.el._tabIndex=e),c.el._tabIndex&&(e=c.el._tabIndex);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;";"enum"==b.type&&(c='
    "),"file"==b.type&&(c='
    ');var e=a(b.el).data("tmp")||{};e["old-background-color"]=a(b.el).css("background-color"),e["old-border-color"]=a(b.el).css("border-color"),a(b.el).data("tmp",e),a(b.el).before(c).css({"background-color":"transparent","border-color":"transparent"});var f=a(b.el).prev();b.helpers.multi=f,"enum"==b.type&&(a(b.el).attr("tabindex",-1),f.find("input").on("click",function(c){0==a("#w2ui-overlay").length&&b.focus(c),a(b.el).triggerHandler("click")}).on("focus",function(c){a(f).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(f).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)}),f.on("click",function(b){a(this).find("input").focus()})),"file"==b.type&&(a(b.el).css("outline","none"),f.on("click",function(c){a(b.el).focus(),a(b.el).attr("readonly")||(b.blur(c),b.resize(),setTimeout(function(){f.find("input").click()},10))}).on("dragenter",function(c){a(b.el).attr("readonly")||a(f).addClass("w2ui-file-dragover")}).on("dragleave",function(c){if(!a(b.el).attr("readonly")){var d=a(c.target).parents(".w2ui-field-helper");0==d.length&&a(f).removeClass("w2ui-file-dragover")}}).on("drop",function(c){if(!a(b.el).attr("readonly")){a(f).removeClass("w2ui-file-dragover");for(var d=c.originalEvent.dataTransfer.files,e=0,g=d.length;g>e;e++)b.addFile.call(b,d[e]);c.preventDefault(),c.stopPropagation()}}).on("dragover",function(a){a.preventDefault(),a.stopPropagation()}),f.find("input").on("click",function(a){a.stopPropagation()}).on("change",function(){if("undefined"!=typeof this.files)for(var a=0,c=this.files.length;c>a;a++)b.addFile.call(b,this.files[a])})),b.refresh()},addFile:function(b){var c,d=this,e=this.options,f=a(d.el).data("selected"),g={name:b.name,type:b.type,modified:b.lastModifiedDate,size:b.size,content:null,file:b},h=0,i=0;for(var j in f){if(f[j].name==b.name&&f[j].size==b.size)return;h+=f[j].size,i++}var k=d.trigger({phase:"before",type:"add",target:d.el,file:g,total:i,totalSize:h});if(k.isCancelled!==!0){if(0!==e.maxFileSize&&g.size>e.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){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++),(1>a||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;43>q;q++){if(0===k&&1==q){for(var r=0;6>r;r++)n+='';q+=6}else if(k>q||o>f[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;c>=g;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;24>d;d++){var e=(d>=12&&!c?d-12:d)+":00"+(c?"":12>d?" 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;60>e;e+=5){var f=(a>12&&!c?a-12:a)+":"+(10>e?0:"")+e+" "+(c?"":12>a?"am":"pm"),g=f,h=20>e?0:40>e?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='
    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]),-1!=a.indexOf("pm")&&12!=b[0]&&(b[0]+=12),60*b[0]+b[1])},fromMin:function(a){var b="";a>=1440&&(a%=1440),0>a&&(a=1440+a);var c=Math.floor(a/60),d=(10>a%60?"0":"")+a%60,e=this.options;return null==e&&(e={format:w2utils.settings.timeFormat}),b=-1!=e.format.indexOf("h24")?c+":"+d:(12>=c?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.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&&(-1==String(h.formHTML).indexOf("w2ui-page")&&(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:"Return data is not in 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,$.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});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(e){}if(!$.isEmptyObject(obj.routeData)){var info=w2utils.parseRoute(url);if(info.keys.length>0)for(var k=0;k";switch(f.type){case"pass":case"password":g='";break;case"checkbox":g='";break;case"radio":g="";var h=f.options.items?f.options.items:f.html.items;$.isArray(h)||(h=[]),h.length>0&&(h=w2obj.field.prototype.normMenu(h));for(var i=0;i '+h[i].text+"
    ";break;case"select":g='";break;case"textarea":g='";break;case"toggle":g='
    '}f.html.group&&(""!=c&&(e+="\n "),e+='\n
    '+f.html.group+'
    \n
    ',c=f.html.group),f.html.page!=a&&""!=c&&(b[b.length-1]+="\n
    ",c=""),e+='\n
    \n \n
    "+g+w2utils.lang(f.html.text)+"
    \n
    ",null==b[f.html.page]&&(b[f.html.page]=""),b[f.html.page]+=e,a=f.html.page}if(""!=c&&(b[b.length-1]+="\n "),this.tabs.tabs)for(var i=0;i'+b[j]+"\n";var k="";if(!$.isEmptyObject(this.actions)){k+='\n
    ';for(var l in this.actions){var m=this.actions[l],n={caption:"",style:"","class":""};$.isPlainObject(m)?(m.caption&&(n.caption=m.caption),m.style&&(n.style=m.style),m["class"]&&(n["class"]=m["class"])):(n.caption=l,-1!=["save","update","create"].indexOf(l.toLowerCase())?n["class"]="w2ui-btn-blue":n["class"]=""),k+='\n "}k+="\n
    "}return b.join("")+k},action:function(a,b){var c=null,d=this.actions[a],c=d;$.isPlainObject(d)&&d.onClick&&(c=d.onClick);var e=this.trigger({phase:"before",target:a,type:"action",click:c,originalEvent:b});e.isCancelled!==!0&&("function"==typeof c&&c.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;100>g;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;f>g;g++){var a=this.fields[g];null==a.name&&null!=a.field&&(a.name=a.field),null==a.field&&null!=a.name&&(a.field=a.name),a.$el=$(this.box).find('[name="'+String(a.name).replace(/\\/g,"\\\\")+'"]'),a.el=a.$el[0],null==a.el&&console.log('ERROR: Cannot associate field "'+a.name+'" with html control. Make sure html control exists with the same name.'), +a.el&&(a.el.id=a.name);var h=$(a).data("w2field");h&&h.clear(),$(a.$el).off("change").on("change",function(){var a=this.value,b=c.record[this.name]?c.record[this.name]:"",d=c.get(this.name);if(-1!=["list","enum","file"].indexOf(d.type)&&$(this).data("selected")){var e=$(this).data("selected"),f=c.record[this.name];if($.isArray(e)){a=[];for(var g=0;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;f>g;g++){var a=this.fields[g],i=null!=this.record[a.name]?this.record[a.name]:"";if(a.el)switch($(a.el).hasClass("w2ui-input")||$(a.el).addClass("w2ui-input"),a.type=String(a.type).toLowerCase(),a.options||(a.options={}),a.type){case"text":case"textarea":case"email":case"pass":case"password":a.el.value=i;break;case"int":case"float":case"money":case"currency":case"percent":a.el.value=i,$(a.el).w2field($.extend({},a.options,{type:a.type}));break;case"hex":case"alphanumeric":case"color":case"date":case"time":a.el.value=i,$(a.el).w2field($.extend({},a.options,{type:a.type}));break;case"toggle":w2utils.isFloat(i)&&(i=parseFloat(i)),$(a.el).prop("checked",i?!0:!1),this.record[a.name]=i?i:!1;break;case"list":case"combo":if("list"==a.type){var j=$.isPlainObject(i)?i.id:$.isPlainObject(a.options.selected)?a.options.selected.id:i;a.options.items||(a.options.items=[]);var k=a.options.items;$.isArray(k)&&k.length>0&&!$.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("input, select, textarea");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})),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.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)),setTimeout(function(){d.resize(),d.refresh()},150),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); \ No newline at end of file