1(self.webpackChunkinterewid=self.webpackChunkinterewid||[]).push([[694],{694:(e,t,i)=>{var s=i(97086),n=i(34160),l=s.w2ui;void 0===n.w2ui&&(n.w2ui=l),e.exports=s},34160:(e,t,i)=>{"use strict";e.exports=function(){if("object"==typeof globalThis)return globalThis;var e;try{e=this||new Function("return this")()}catch(e){if("object"==typeof window)return window;if("object"==typeof self)return self;if(void 0!==i.g)return i.g}return e}()},97086:function(module,exports,__webpack_require__){var jQuery=__webpack_require__(20508),__WEBPACK_AMD_DEFINE_RESULT__,w2ui=w2ui||{},w2obj=w2obj||{},w2utils=function(e){var t={};return{version:"1.5.x",settings:{locale:"en-us",dateFormat:"m/d/yyyy",timeFormat:"hh:mi pm",datetimeFormat:"m/d/yyyy|hh:mi pm",currencyPrefix:"$",currencySuffix:"",currencyPrecision:2,groupSymbol:",",decimalSymbol:".",shortmonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],fullmonths:["January","February","March","April","May","June","July","August","September","October","November","December"],shortdays:["M","T","W","T","F","S","S"],fulldays:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],weekStarts:"M",dataType:"HTTPJSON",phrases:{},dateStartYear:1950,dateEndYear:2030,macButtonOrder:!1},isBin:function(e){return/^[0-1]+$/.test(e)},isInt:i,isFloat:function(e){return"string"==typeof e&&(e=e.replace(/\s+/g,"").replace(w2utils.settings.groupSymbol,"").replace(w2utils.settings.decimalSymbol,".")),("number"==typeof e||"string"==typeof e&&""!==e)&&!isNaN(Number(e))},isMoney:function(e){var t=w2utils.settings,i=new RegExp("^"+(t.currencyPrefix?"\\"+t.currencyPrefix+"?":"")+"[-+]?"+(t.currencyPrefix?"\\"+t.currencyPrefix+"?":"")+"[0-9]*[\\"+t.decimalSymbol+"]?[0-9]+"+(t.currencySuffix?"\\"+t.currencySuffix+"?":"")+"$","i");return"string"==typeof e&&(e=e.replace(new RegExp(t.groupSymbol,"g"),"")),"object"!=typeof e&&""!==e&&i.test(e)},isHex:function(e){return/^(0x)?[0-9a-fA-F]+$/.test(e)},isAlphaNumeric:function(e){return/^[a-zA-Z0-9_-]+$/.test(e)},isEmail:function(e){return/^[a-zA-Z0-9._%\-+]+@[а-ÑÐ-Яa-zA-Z0-9.-]+\.[а-ÑÐ-Яa-zA-Z]+$/.test(e)},isIpAddress:function(e){return new RegExp("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$").test(e)},isDate:function(e,t,s){if(!e)return!1;var n,l,a,r="Invalid Date";if(null==t&&(t=w2utils.settings.dateFormat),"function"==typeof e.getFullYear)a=e.getFullYear(),n=e.getMonth()+1,l=e.getDate();else if(parseInt(e)==e&&0<parseInt(e))a=(e=new Date(parseInt(e))).getFullYear(),n=e.getMonth()+1,l=e.getDate();else{if(e=String(e),new RegExp("mon","ig").test(t)){t=t.replace(/month/gi,"m").replace(/mon/gi,"m").replace(/dd/gi,"d").replace(/[, ]/gi,"/").replace(/\/\//g,"/").toLowerCase(),e=e.replace(/[, ]/gi,"/").replace(/\/\//g,"/").toLowerCase();for(var o=0,d=w2utils.settings.fullmonths.length;o<d;o++){var u=w2utils.settings.fullmonths[o];e=e.replace(new RegExp(u,"ig"),parseInt(o)+1).replace(new RegExp(u.substr(0,3),"ig"),parseInt(o)+1)}}var c=e.replace(/-/g,"/").replace(/\./g,"/").toLowerCase().split("/"),h=t.replace(/-/g,"/").replace(/\./g,"/").toLowerCase();"mm/dd/yyyy"===h&&(n=c[0],l=c[1],a=c[2]),"m/d/yyyy"===h&&(n=c[0],l=c[1],a=c[2]),"dd/mm/yyyy"===h&&(n=c[1],l=c[0],a=c[2]),"d/m/yyyy"===h&&(n=c[1],l=c[0],a=c[2]),"yyyy/dd/mm"===h&&(n=c[2],l=c[1],a=c[0]),"yyyy/d/m"===h&&(n=c[2],l=c[1],a=c[0]),"yyyy/mm/dd"===h&&(n=c[1],l=c[2],a=c[0]),"yyyy/m/d"===h&&(n=c[1],l=c[2],a=c[0]),"mm/dd/yy"===h&&(n=c[0],l=c[1],a=c[2]),"m/d/yy"===h&&(n=c[0],l=c[1],a=parseInt(c[2])+1900),"dd/mm/yy"===h&&(n=c[1],l=c[0],a=parseInt(c[2])+1900),"d/m/yy"===h&&(n=c[1],l=c[0],a=parseInt(c[2])+1900),"yy/dd/mm"===h&&(n=c[2],l=c[1],a=parseInt(c[0])+1900),"yy/d/m"===h&&(n=c[2],l=c[1],a=parseInt(c[0])+1900),"yy/mm/dd"===h&&(n=c[1],l=c[2],a=parseInt(c[0])+1900),"yy/m/d"===h&&(n=c[1],l=c[2],a=parseInt(c[0])+1900)}return!!i(a)&&!!i(n)&&!!i(l)&&(a=+a,n=+n,l=+l,(r=new Date(a,n-1,l)).setFullYear(a),null!=n&&"Invalid Date"!==String(r)&&r.getMonth()+1===n&&r.getDate()===l&&r.getFullYear()===a&&(!0!==s||r))},isTime:function(t,i){if(null==t)return!1;var s,n,l;n=0<=(t=(t=String(t)).toUpperCase()).indexOf("AM");var a=(l=0<=t.indexOf("PM"))||n;s=a?12:24,t=t.replace("AM","").replace("PM","");var r=(t=e.trim(t)).split(":"),o=parseInt(r[0]||0),d=parseInt(r[1]||0),u=parseInt(r[2]||0);return!!(a&&1===r.length||2===r.length||3===r.length)&&!(""===r[0]||o<0||s<o||!this.isInt(r[0])||2<r[0].length)&&!(1<r.length&&(""===r[1]||d<0||59<d||!this.isInt(r[1])||2!==r[1].length))&&!(2<r.length&&(""===r[2]||u<0||59<u||!this.isInt(r[2])||2!==r[2].length))&&!!(a||s!==o||0===d&&0===u)&&(!a||1!==r.length||0!==o)&&(!0!==i||(l&&12!==o&&(o+=12),n&&12===o&&(o+=12),{hours:o,minutes:d,seconds:u}))},isDateTime:function(e,t,i){if("function"==typeof e.getFullYear)return!0!==i||e;var s=parseInt(e);if(s===e)return!(s<0)&&(!0!==i||new Date(s));var n=String(e).indexOf(" ");if(n<0)return!(String(e).indexOf("T")<0||"Invalid Date"==String(new Date(e)))&&(!0!==i||new Date(e));null==t&&(t=w2utils.settings.datetimeFormat);var l=t.split("|"),a=[e.substr(0,n),e.substr(n).trim()];l[0]=l[0].trim(),l[1]&&(l[1]=l[1].trim());var r=w2utils.isDate(a[0],l[0],!0),o=w2utils.isTime(a[1],!0);return!1!==r&&!1!==o&&(!0!==i||(r.setHours(o.hours),r.setMinutes(o.minutes),r.setSeconds(o.seconds),r))},age:function(e){var t;if(""===e||null==e)return"";if(t="function"==typeof e.getFullYear?e:parseInt(e)==e&&0<parseInt(e)?new Date(parseInt(e)):new Date(e),"Invalid Date"===String(t))return"";var i=((new Date).getTime()-t.getTime())/1e3,s="",n="";return i<0?(s=0,n="sec"):i<60?(s=Math.floor(i),n="sec",i<0&&(s=0,n="sec")):i<3600?(s=Math.floor(i/60),n="min"):i<86400?(s=Math.floor(i/60/60),n="hour"):i<2592e3?(s=Math.floor(i/24/60/60),n="day"):i<31536e3?(s=Math.floor(i/30/24/60/60*10)/10,n="month"):i<126144e3?(s=Math.floor(i/365/24/60/60*10)/10,n="year"):126144e3<=i&&(s=Math.floor(i/365.25/24/60/60*10)/10,n="year"),s+" "+n+(1<s?"s":"")},interval:function(e){return e<1e3?"< 1 sec":e<6e4?Math.floor(e/1e3)+" secs":e<36e5?Math.floor(e/6e4)+" mins":e<864e5?Math.floor(e/36e5*10)/10+" hours":e<2628e6?Math.floor(e/864e5*10)/10+" days":e<31536e6?Math.floor(e/2628e6*10)/10+" months":Math.floor(e/31536e5)/10+" years"},date:function(e){if(""===e||null==e||"object"==typeof e&&!e.getMonth)return"";var t=new Date(e);if(w2utils.isInt(e)&&(t=new Date(Number(e))),"Invalid Date"===String(t))return"";var i=w2utils.settings.shortmonths,s=new Date,n=new Date;n.setTime(n.getTime()-864e5);var l=i[t.getMonth()]+" "+t.getDate()+", "+t.getFullYear(),a=i[s.getMonth()]+" "+s.getDate()+", "+s.getFullYear(),r=i[n.getMonth()]+" "+n.getDate()+", "+n.getFullYear(),o=t.getHours()-(12<t.getHours()?12:0)+":"+(t.getMinutes()<10?"0":"")+t.getMinutes()+" "+(12<=t.getHours()?"pm":"am"),d=t.getHours()-(12<t.getHours()?12:0)+":"+(t.getMinutes()<10?"0":"")+t.getMinutes()+":"+(t.getSeconds()<10?"0":"")+t.getSeconds()+" "+(12<=t.getHours()?"pm":"am"),u=l;return l==a&&(u=o),l==r&&(u=w2utils.lang("Yesterday")),'<span title="'+l+" "+d+'">'+u+"</span>"},formatSize:function(e){if(!w2utils.isFloat(e)||""===e)return"";if(0===(e=parseFloat(e)))return 0;var t=parseInt(Math.floor(Math.log(e)/Math.log(1024)));return(Math.floor(e/Math.pow(1024,t)*10)/10).toFixed(0===t?0:1)+" "+(["Bt","KB","MB","GB","TB","PB","EB","ZB"][t]||"??")},formatNumber:function(e,t,i){if(null==e||""===e||"object"==typeof e)return"";var s={minimumFractionDigits:t,maximumFractionDigits:t,useGrouping:i};return(null==t||t<0)&&(s.minimumFractionDigits=0,s.maximumFractionDigits=20),parseFloat(e).toLocaleStr
1ing(w2utils.settings.locale,s)},formatDate:function(e,t){if(t=t||this.settings.dateFormat,""===e||null==e||"object"==typeof e&&!e.getMonth)return"";var i=new Date(e);if(w2utils.isInt(e)&&(i=new Date(Number(e))),"Invalid Date"===String(i))return"";var s=i.getFullYear(),n=i.getMonth(),l=i.getDate();return t.toLowerCase().replace("month",w2utils.settings.fullmonths[n]).replace("mon",w2utils.settings.shortmonths[n]).replace(/yyyy/g,("000"+s).slice(-4)).replace(/yyy/g,("000"+s).slice(-4)).replace(/yy/g,("0"+s).slice(-2)).replace(/(^|[^a-z$])y/g,"$1"+s).replace(/mm/g,("0"+(n+1)).slice(-2)).replace(/dd/g,("0"+l).slice(-2)).replace(/th/g,1==l?"st":"th").replace(/th/g,2==l?"nd":"th").replace(/th/g,3==l?"rd":"th").replace(/(^|[^a-z$])m/g,"$1"+(n+1)).replace(/(^|[^a-z$])d/g,"$1"+l)},formatTime:function(e,t){if(w2utils.settings.shortmonths,w2utils.settings.fullmonths,t=t||this.settings.timeFormat,""===e||null==e||"object"==typeof e&&!e.getMonth)return"";var i,s=new Date(e);if(w2utils.isInt(e)&&(s=new Date(Number(e))),w2utils.isTime(e)&&(i=w2utils.isTime(e,!0),(s=new Date).setHours(i.hours),s.setMinutes(i.minutes)),"Invalid Date"===String(s))return"";var n="am",l=s.getHours(),a=s.getHours(),r=s.getMinutes(),o=s.getSeconds();return r<10&&(r="0"+r),o<10&&(o="0"+o),-1===t.indexOf("am")&&-1===t.indexOf("pm")||(12<=l&&(n="pm"),12<l&&(l-=12),0===l&&(l=12)),t.toLowerCase().replace("am",n).replace("pm",n).replace("hhh",l<10?"0"+l:l).replace("hh24",a<10?"0"+a:a).replace("h24",a).replace("hh",l).replace("mm",r).replace("mi",r).replace("ss",o).replace(/(^|[^a-z$])h/g,"$1"+l).replace(/(^|[^a-z$])m/g,"$1"+r).replace(/(^|[^a-z$])s/g,"$1"+o)},formatDateTime:function(e,t){var i;return""===e||null==e||"object"==typeof e&&!e.getMonth?"":("string"!=typeof t?i=[this.settings.dateFormat,this.settings.timeFormat]:((i=t.split("|"))[0]=i[0].trim(),i[1]=1<i.length?i[1].trim():this.settings.timeFormat),"h12"===i[1]&&(i[1]="h:m pm"),"h24"===i[1]&&(i[1]="h24:m"),this.formatDate(e,i[0])+" "+this.formatTime(e,i[1]))},stripTags:function(t){if(null==t)return t;switch(typeof t){case"number":break;case"string":t=String(t).replace(/<(?:[^>=]|='[^']*'|="[^"]*"|=[^'"][^\s>]*)*>/gi,"");break;case"object":if(Array.isArray(t)){t=e.extend(!0,[],t);for(var i=0;i<t.length;i++)t[i]=this.stripTags(t[i])}else for(var i in t=e.extend(!0,{},t))t[i]=this.stripTags(t[i])}return t},encodeTags:s,decodeTags:function(t){if(null==t)return t;switch(typeof t){case"number":break;case"string":t=String(t).replace(/>/g,">").replace(/</g,"<").replace(/"/g,'"').replace(/&/g,"&");break;case"object":if(Array.isArray(t)){t=e.extend(!0,[],t);for(var i=0;i<t.length;i++)t[i]=this.decodeTags(t[i])}else for(var i in t=e.extend(!0,{},t))t[i]=this.decodeTags(t[i])}return t},escapeId:function(e){return""===e||null==e?"":String(e).replace(/([;&,\.\+\*\~'`:"\!\^#$%@\[\]\(\)=<>\|\/? {}\\])/g,"\\$1")},base64encode:function(e){var t,i,s,n,l,a,r,o="",d=0,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";for(e=function(e){e=String(e).replace(/\r\n/g,"\n");for(var t="",i=0;i<e.length;i++){var s=e.charCodeAt(i);s<128?t+=String.fromCharCode(s):(127<s&&s<2048?t+=String.fromCharCode(s>>6|192):(t+=String.fromCharCode(s>>12|224),t+=String.fromCharCode(s>>6&63|128)),t+=String.fromCharCode(63&s|128))}return t}(e);d<e.length;)n=(t=e.charCodeAt(d++))>>2,l=(3&t)<<4|(i=e.charCodeAt(d++))>>4,a=(15&i)<<2|(s=e.charCodeAt(d++))>>6,r=63&s,isNaN(i)?a=r=64:isNaN(s)&&(r=64),o=o+u.charAt(n)+u.charAt(l)+u.charAt(a)+u.charAt(r);return o},base64decode:function(e){var t,i,s,n,l,a,r="",o=0,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");o<e.length;)t=d.indexOf(e.charAt(o++))<<2|(n=d.indexOf(e.charAt(o++)))>>4,i=(15&n)<<4|(l=d.indexOf(e.charAt(o++)))>>2,s=(3&l)<<6|(a=d.indexOf(e.charAt(o++))),r+=String.fromCharCode(t),64!==l&&(r+=String.fromCharCode(i)),64!==a&&(r+=String.fromCharCode(s));return function(e){for(var t,i,s="",n=0,l=0;n<e.length;)(l=e.charCodeAt(n))<128?(s+=String.fromCharCode(l),n++):191<l&&l<224?(t=e.charCodeAt(n+1),s+=String.fromCharCode((31&l)<<6|63&t),n+=2):(t=e.charCodeAt(n+1),i=e.charCodeAt(n+2),s+=String.fromCharCode((1
15&l)<<12|(63&t)<<6|63&i),n+=3);return s}(r)},md5:function(e){function t(e,t,i,s,n,l){return a((r=a(a(t,e),a(s,l)))<<(o=n)|r>>>32-o,i);var r,o}function i(e,i,s,n,l,a,r){return t(i&s|~i&n,e,i,l,a,r)}function s(e,i,s,n,l,a,r){return t(i&n|s&~n,e,i,l,a,r)}function n(e,i,s,n,l,a,r){return t(i^s^n,e,i,l,a,r)}function l(e,i,s,n,l,a,r){return t(s^(i|~n),e,i,l,a,r)}function a(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i}return function(e){return function(e){for(var t,i="0123456789abcdef",s="",n=0;n<e.length;n++)t=e.charCodeAt(n),s+=i.charAt(t>>>4&15)+i.charAt(15&t);return s}(function(e){return function(e){for(var t="",i=0;i<32*e.length;i+=8)t+=String.fromCharCode(e[i>>5]>>>i%32&255);return t}(function(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var r=1732584193,o=-271733879,d=-1732584194,u=271733878,c=0;c<e.length;c+=16){var h=r,p=o,f=d,g=u;r=i(r,o,d,u,e[c+0],7,-680876936),u=i(u,r,o,d,e[c+1],12,-389564586),d=i(d,u,r,o,e[c+2],17,606105819),o=i(o,d,u,r,e[c+3],22,-1044525330),r=i(r,o,d,u,e[c+4],7,-176418897),u=i(u,r,o,d,e[c+5],12,1200080426),d=i(d,u,r,o,e[c+6],17,-1473231341),o=i(o,d,u,r,e[c+7],22,-45705983),r=i(r,o,d,u,e[c+8],7,1770035416),u=i(u,r,o,d,e[c+9],12,-1958414417),d=i(d,u,r,o,e[c+10],17,-42063),o=i(o,d,u,r,e[c+11],22,-1990404162),r=i(r,o,d,u,e[c+12],7,1804603682),u=i(u,r,o,d,e[c+13],12,-40341101),d=i(d,u,r,o,e[c+14],17,-1502002290),r=s(r,o=i(o,d,u,r,e[c+15],22,1236535329),d,u,e[c+1],5,-165796510),u=s(u,r,o,d,e[c+6],9,-1069501632),d=s(d,u,r,o,e[c+11],14,643717713),o=s(o,d,u,r,e[c+0],20,-373897302),r=s(r,o,d,u,e[c+5],5,-701558691),u=s(u,r,o,d,e[c+10],9,38016083),d=s(d,u,r,o,e[c+15],14,-660478335),o=s(o,d,u,r,e[c+4],20,-405537848),r=s(r,o,d,u,e[c+9],5,568446438),u=s(u,r,o,d,e[c+14],9,-1019803690),d=s(d,u,r,o,e[c+3],14,-187363961),o=s(o,d,u,r,e[c+8],20,1163531501),r=s(r,o,d,u,e[c+13],5,-1444681467),u=s(u,r,o,d,e[c+2],9,-51403784),d=s(d,u,r,o,e[c+7],14,1735328473),r=n(r,o=s(o,d,u,r,e[c+12],20,-1926607734),d,u,e[c+5],4,-378558),u=n(u,r,o,d,e[c+8],11,-2022574463),d=n(d,u,r,o,e[c+11],16,1839030562),o=n(o,d,u,r,e[c+14],23,-35309556),r=n(r,o,d,u,e[c+1],4,-1530992060),u=n(u,r,o,d,e[c+4],11,1272893353),d=n(d,u,r,o,e[c+7],16,-155497632),o=n(o,d,u,r,e[c+10],23,-1094730640),r=n(r,o,d,u,e[c+13],4,681279174),u=n(u,r,o,d,e[c+0],11,-358537222),d=n(d,u,r,o,e[c+3],16,-722521979),o=n(o,d,u,r,e[c+6],23,76029189),r=n(r,o,d,u,e[c+9],4,-640364487),u=n(u,r,o,d,e[c+12],11,-421815835),d=n(d,u,r,o,e[c+15],16,530742520),r=l(r,o=n(o,d,u,r,e[c+2],23,-995338651),d,u,e[c+0],6,-198630844),u=l(u,r,o,d,e[c+7],10,1126891415),d=l(d,u,r,o,e[c+14],15,-1416354905),o=l(o,d,u,r,e[c+5],21,-57434055),r=l(r,o,d,u,e[c+12],6,1700485571),u=l(u,r,o,d,e[c+3],10,-1894986606),d=l(d,u,r,o,e[c+10],15,-1051523),o=l(o,d,u,r,e[c+1],21,-2054922799),r=l(r,o,d,u,e[c+8],6,1873313359),u=l(u,r,o,d,e[c+15],10,-30611744),d=l(d,u,r,o,e[c+6],15,-1560198380),o=l(o,d,u,r,e[c+13],21,1309151649),r=l(r,o,d,u,e[c+4],6,-145523070),u=l(u,r,o,d,e[c+11],10,-1120210379),d=l(d,u,r,o,e[c+2],15,718787259),o=l(o,d,u,r,e[c+9],21,-343485551),r=a(r,h),o=a(o,p),d=a(d,f),u=a(u,g)}return Array(r,o,d,u)}(function(e){for(var t=Array(e.length>>2),i=0;i<t.length;i++)t[i]=0;for(i=0;i<8*e.length;i+=8)t[i>>5]|=(255&e.charCodeAt(i/8))<<i%32;return t}(e),8*e.length))}(function(e){for(var t,i,s="",n=-1;++n<e.length;)t=e.charCodeAt(n),i=n+1<e.length?e.charCodeAt(n+1):0,55296<=t&&t<=56319&&56320<=i&&i<=57343&&(t=65536+((1023&t)<<10)+(1023&i),n++),t<=127?s+=String.fromCharCode(t):t<=2047?s+=String.fromCharCode(192|t>>>6&31,128|63&t):t<=65535?s+=String.fromCharCode(224|t>>>12&15,128|t>>>6&63,128|63&t):t<=2097151&&(s+=String.fromCharCode(240|t>>>18&7,128|t>>>12&63,128|t>>>6&63,128|63&t));return s}(e)))}(e)},transition:function(t,i,s,n){var l=e(t).width(),a=e(t).height();if(t&&i){switch(t.parentNode.style.cssText+="perspective: 900px; overflow: hidden;",t.style.cssText+="; position: absolute; z-index: 1019; backface-visibility: hidden",i.style.cssText+="; position: absolute; z-index: 1020; backface-visibility: hidden",s){case"slide-left":t.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",i.style.cssText+="overflow: hidden; transform: translate3d("+l+"px, 0, 0)",e(i).show(),window.setTimeout((function(){i.style.cssText+="transition: 0.5s; transform: translate3d(0, 0, 0)",t.style.cssText+="transition: 0.5s; transform: translate3d(-"+l+"px, 0, 0)"}),1);break;case"slide-right":t.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",i.style.cssText+="overflow: hidden; transform: translate3d(-"+l+"px, 0, 0)",e(i).show(),window.setTimeout((function(){i.style.cssText+="transition: 0.5s; transform: translate3d(0px, 0, 0)",t.style.cssText+="transition: 0.5s; transform: translate3d("+l+"px, 0, 0)"}),1);break;case"slide-down":t.style.cssText+="overflow: hidden; z-index: 1; transform: translate3d(0, 0, 0)",i.style.cssText+="overflow: hidden; z-index: 0; transform: translate3d(0, 0, 0)",e(i).show(),window.setTimeout((function(){i.style.cssText+="transition: 0.5s; transform: translate3d(0, 0, 0)",t.style.cssText+="transition: 0.5s; transform: translate3d(0, "+a+"px, 0)"}),1);break;case"slide-up":t.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",i.style.cssText+="overflow: hidden; transform: translate3d(0, "+a+"px, 0)",e(i).show(),window.setTimeout((function(){i.style.cssText+="transition: 0.5s; transform: translate3d(0, 0, 0)",t.style.cssText+="transition: 0.5s; transform: translate3d(0, 0, 0)"}),1);break;case"flip-left":t.style.cssText+="overflow: hidden; transform: rotateY(0deg)",i.style.cssText+="overflow: hidden; transform: rotateY(-180deg)",e(i).show(),window.setTimeout((function(){i.style.cssText+="transition: 0.5s; transform: rotateY(0deg)",t.style.cssText+="transition: 0.5s; transform: rotateY(180deg)"}),1);break;case"flip-right":t.style.cssText+="overflow: hidden; transform: rotateY(0deg)",i.style.cssText+="overflow: hidden; transform: rotateY(180deg)",e(i).show(),window.setTimeout((function(){i.style.cssText+="transition: 0.5s; transform: rotateY(0deg)",t.style.cssText+="transition: 0.5s; transform: rotateY(-180deg)"}),1);break;case"flip-down":t.style.cssText+="overflow: hidden; transform: rotateX(0deg)",i.style.cssText+="overflow: hidden; transform: rotateX(180deg)",e(i).show(),window.setTimeout((function(){i.style.cssText+="transition: 0.5s; transform: rotateX(0deg)",t.style.cssText+="transition: 0.5s; transform: rotateX(-180deg)"}),1);break;case"flip-up":t.style.cssText+="overflow: hidden; transform: rotateX(0deg)",i.style.cssText+="overflow: hidden; transform: rotateX(-180deg)",e(i).show(),window.setTimeout((function(){i.style.cssText+="transition: 0.5s; transform: rotateX(0deg)",t.style.cssText+="transition: 0.5s; transform: rotateX(180deg)"}),1);break;case"pop-in":t.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",i.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); transform: scale(.8); opacity: 0;",e(i).show(),window.setTimeout((function(){i.style.cssText+="transition: 0.5s; transform: scale(1); opacity: 1;",t.style.cssText+="transition: 0.5s;"}),1);break;case"pop-out":t.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); transform: scale(1); opacity: 1;",i.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); opacity: 0;",e(i).show(),window.setTimeout((function(){i.style.cssText+="transition: 0.5s;
1 opacity: 1;",t.style.cssText+="transition: 0.5s; transform: scale(1.7); opacity: 0;"}),1);break;default:t.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",i.style.cssText+="overflow: hidden; translate3d(0, 0, 0); opacity: 0;",e(i).show(),window.setTimeout((function(){i.style.cssText+="transition: 0.5s; opacity: 1;",t.style.cssText+="transition: 0.5s"}),1)}setTimeout((function(){"slide-down"===s&&(e(t).css("z-index","1019"),e(i).css("z-index","1020")),i&&e(i).css({opacity:"1"}).css(w2utils.cssPrefix({transition:"",transform:""})),t&&e(t).css({opacity:"1"}).css(w2utils.cssPrefix({transition:"",transform:""})),"function"==typeof n&&n()}),500)}else console.log("ERROR: Cannot do transition when one of the divs is null")},lock:function(t,i,s){var n={};"object"==typeof i?n=i:(n.msg=i,n.spinner=s),n.msg||0===n.msg||(n.msg=""),w2utils.unlock(t),e(t).prepend('<div class="w2ui-lock"></div><div class="w2ui-lock-msg"></div>');var l=e(t).find(".w2ui-lock"),a=e(t).find(".w2ui-lock-msg");n.msg||a.css({"background-color":"transparent",border:"0px"}),!0===n.spinner&&(n.msg='<div class="w2ui-spinner" '+(n.msg?"":'style="width: 35px; height: 35px"')+"></div>"+n.msg),null!=n.opacity&&l.css("opacity",n.opacity),"function"==typeof l.fadeIn?(l.fadeIn(200),a.html(n.msg).fadeIn(200)):(l.show(),a.html(n.msg).show(0))},unlock:function(t,s){i(s)?(e(t).find(".w2ui-lock").fadeOut(s),setTimeout((function(){e(t).find(".w2ui-lock").remove(),e(t).find(".w2ui-lock-msg").remove()}),s)):(e(t).find(".w2ui-lock").remove(),e(t).find(".w2ui-lock-msg").remove())},message:function(t,i){var s,n,l=this;e().w2tag(),null==(i=i||{width:200,height:100}).on&&e.extend(i,w2utils.event),null==i.width&&(i.width=200),null==i.height&&(i.height=100);var a=parseInt(e(t.box).width()),r=parseInt(e(t.box).height()),o=parseInt(e(t.box).find(t.title).css("height")||0);i.width>a&&(i.width=a-10),i.height>r-o&&(i.height=r-10-o),i.originalWidth=i.width,i.originalHeight=i.height,parseInt(i.width)<0&&(i.width=a+i.width),parseInt(i.width)<10&&(i.width=10),parseInt(i.height)<0&&(i.height=r+i.height-o),parseInt(i.height)<10&&(i.height=10),null==i.hideOnClick&&(i.hideOnClick=!1);var d=e(t.box).data("options")||{};(null==i.width||i.width>d.width-10)&&(i.width=d.width-10),(null==i.height||i.height>d.height-o-5)&&(i.height=d.height-o-5),i.originalHeight<0&&(i.height=r+i.originalHeight-o),i.originalWidth<0&&(i.width=a+2*i.originalWidth);var u=e(t.box).find(t.title),c=e(t.box).find(".w2ui-message.w2ui-closing");0<e(t.box).find(".w2ui-message.w2ui-closing").length&&(clearTimeout(s),g(c,c.data("options")||{}));var h=e(t.box).find(".w2ui-message").length;if(""===e.trim(i.html)&&""===e.trim(i.body)&&""===e.trim(i.buttons)){if(0===h)return;var p=e(t.box).find("#w2ui-message"+(h-1));if(i=p.data("options")||{},!0===(n=i.trigger({phase:"before",type:"close",target:"self"})).isCancelled)return;p.css(w2utils.cssPrefix({transition:"0.15s",transform:"translateY(-"+i.height+"px)"})).addClass("w2ui-closing"),1===h?this.unlock&&(t.param?this.unlock(t.param,150):this.unlock(150)):e(t.box).find("#w2ui-message"+(h-2)).css("z-index",1500),s=setTimeout((function(){g(p,i)}),150)}else{""===e.trim(i.body)&&""===e.trim(i.buttons)||(i.html='<div class="w2ui-message-body">'+(i.body||"")+'</div><div class="w2ui-message-buttons">'+(i.buttons||"")+"</div>"),e(t.box).find(".w2ui-message").css("z-index",1390),u.data("old-z-index",u.css("z-index")),u.css("z-index",1501),e(t.box).find(t.body).before('<div id="w2ui-message'+h+'" onmousedown="event.stopPropagation();" class="w2ui-message" style="display: none; z-index: 1500; '+(0===u.length?"top: 0px;":"top: "+w2utils.getSize(u,"height")+"px;")+(null!=i.width?"width: "+i.width+"px; left: "+(a-i.width)/2+"px;":"left: 10px; right: 10px;")+(null!=i.height?"height: "+i.height+"px;":"bottom: 6px;")+w2utils.cssPrefix("transition",".3s",!0)+'"'+(!0===i.hideOnClick?t.param?'onclick="'+t.path+".message('"+t.param+"');\"":'onclick="'+t.path+'.message();"':"")+"></div>"),e(t.box).find("#w2ui-message"+h).data("options",i).data("prev_focus",e(":focus"));var f=e(t.box).find("#w2ui-message"+h).css("display");if(e(t.box).find("#w2ui-message"+h).css(w2utils.cssPrefix({transform:"none"===f?"translateY(-"+i.height+"px)":"translateY(0px)"})),"none"===f){if(e(t.box).find("#w2ui-message"+h).show().html(i.html),i.box=e(t.box).find("#w2ui-message"+h),!0===(n=i.trigger({phase:"before",type:"open",target:"self"})).isCancelled)return u.css("z-index",u.data("old-z-index")),void e(t.box).find("#w2ui-message"+h).remove();setTimeout((function(){e(t.box).find("#w2ui-message"+h).css(w2utils.cssPrefix({transform:"none"===f?"translateY(0px)":"translateY(-"+i.height+"px)"}))}),1),0===h&&this.lock&&(t.param?this.lock(t.param):this.lock()),setTimeout((function(){e(t.box).find("#w2ui-message"+h).css(w2utils.cssPrefix({transition:"0s"})),i.trigger(e.extend(n,{phase:"after"}))}),350)}}
1function g(i,s){if(null==n&&!0===(n=s.trigger({phase:"before",type:"open",target:"self"})).isCancelled)return u.css("z-index",u.data("old-z-index")),void e(t.box).find("#w2ui-message"+h).remove();var a=i.data("prev_focus");i.remove(),a&&0<a.length?a.focus():l&&l.focus&&l.focus(),u.css("z-index",u.data("old-z-index")),s.trigger(e.extend(n,{phase:"after"}))}},naturalCompare:function(e,t){var i,s,n=1,l=0,a=0,r=String.alphabet;function o(e,t,s){if(s){for(i=t;(s=o(e,i))<76&&65<s;)++i;return+e.slice(t-1,i)}return-1<(s=r&&r.indexOf(e.charAt(t)))?s+76:(s=e.charCodeAt(t)||0)<45||127<s?s:s<46?65:s<48?s-1:s<58?s+18:s<65?s-11:s<91?s+11:s<97?s-37:s<123?s+5:s-63}if((e+="")!=(t+=""))for(;n;)if(s=o(e,l++),n=o(t,a++),s<76&&n<76&&66<s&&66<n&&(s=o(e,l,l),n=o(t,a,l=i),a=i),s!=n)return s<n?-1:1;return 0},lang:function(e){var t=this.settings.phrases[e];return null==t?e:t},locale:function(t,i){"string"==typeof(t=t||"en-us")?(5===t.length&&(t="locale/"+t+".json"),w2utils.settings.phrases={},e.ajax({url:t,type:"GET",dataType:"JSON",success:function(t,s,n){w2utils.settings=e.extend(!0,w2utils.settings,t),"function"==typeof i&&i()},error:function(e,i,s){console.log("ERROR: Cannot load locale "+t)}})):w2utils.settings=e.extend(!0,w2utils.settings,t)},getSize:function(t,i){var s=e(t),n=parseInt(s.css("border-left-width"))||0,l=parseInt(s.css("border-right-width"))||0,a=parseInt(s.css("border-top-width"))||0,r=parseInt(s.css("border-bottom-width"))||0,o=parseInt(s.css("margin-left"))||0,d=parseInt(s.css("margin-right"))||0,u=parseInt(s.css("margin-top"))||0,c=parseInt(s.css("margin-bottom"))||0,h=parseInt(s.css("padding-left"))||0,p=parseInt(s.css("padding-right"))||0,f=parseInt(s.css("padding-top"))||0,g=parseInt(s.css("padding-bottom"))||0;switch(i){case"top":return a+u+f;case"bottom":return r+c+g;case"left":return n+o+h;case"right":return l+d+p;case"width":return n+l+o+d+h+p+parseInt(s.width());case"height":return a+r+u+c+f+g+parseInt(s.height());case"+width":return n+l+o+d+h+p;case"+height":return a+r+u+c+f+g}return 0},getStrWidth:function(t,i){var n,l='<div id="_tmp_width" style="position: absolute; top: -900px;'+(i||"")+'">'+s(t)+"</div>";return e("body").append(l),n=e("#_tmp_width").width(),e("#_tmp_width").remove(),n},scrollBarSize:function(){return t.scrollBarSize||(e("body").append('<div id="_scrollbar_width" style="position: absolute; top: -300px; width: 100px; height: 100px; overflow-y: scroll;"> <div style="height: 120px">1</div></div>'),t.scrollBarSize=100-e("#_scrollbar_width > div").width(),e("#_scrollbar_width").remove(),0<=String(navigator.userAgent).indexOf("MSIE")&&(t.scrollBarSize=t.scrollBarSize/2)),t.scrollBarSize},checkName:function(e,t){return e&&null!=e.name?null==w2ui[e.name]?!!w2utils.isAlphaNumeric(e.name)||(console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). '),!1):(console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+e.name+")."),!1):(console.log('ERROR: The parameter "name" is required but not supplied in $().'+t+"()."),!1)},checkUniqueId:function(t,i,s,n){e.isArray(i)||(i=[i]);for(var l=0;l<i.length;l++)if(i[l].id===t)return console.log('ERROR: The parameter "id='+t+'" is not unique within the current '+s+". (obj: "+n+")"),!1;return!0},parseRoute:function(e){var t=[],i=e.replace(/\/\(/g,"(?:/").replace(/\+/g,"__plus__").replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g,(function(e,i,s,n,l,a){return t.push({name:n,optional:!!a}),i=i||"",(a?"":i)+"(?:"+(a?i:"")+(s||"")+(l||(s?"([^/.]+?)":"([^/]+?)"))+")"+(a||"")})).replace(/([\/.])/g,"\\$1").replace(/__plus__/g,"(.+)").replace(/\*/g,"(.*)");return{path:new RegExp("^"+i+"$","i"),keys:t}},cssPrefix:function(t,i,s){var n={},l={},a="";for(var r in e.isPlainObject(t)?(n=t,!0===i&&(s=!0)):n[t]=i,n)l[r]=n[r],l["-webkit-"+r]=n[r],l["-moz-"+r]=n[r].replace("-webkit-","-moz-"),l["-ms-"+r]=n[r].replace("-webkit-","-ms-"),l["-o-"+r]=n[r].replace("-webkit-","-o-");if(!0===s)for(var r in l)a+=r+": "+l[r]+"; ";else a=l;return a},parseColor:function(e){if("string"!=typeof e)return null;"#"===(e=e.trim().toUpperCase())[0]&&(e=e.substr(1));var t={};if(3===e.length)t={r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:1};else if(6===e.length)t={r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:1};else if(8===e.length)t={r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:Math.round(parseInt(e.substr(6,2),16)/255*100)/100};else if(4<e.length&&"RGB("===e.substr(0,4)){var i=e.replace("RGB","").replace(/\(/g,"").replace(/\)/g,"").split(",");t={r:parseInt(i[0],10),g:parseInt(i[1],10),b:parseInt(i[2],10),a:1}}else{if(!(5<e.length&&"RGBA("===e.substr(0,5)))return null;i=e.replace("RGBA","").replace(/\(/g,"").replace(/\)/g,"").split(","),t={r:parseInt(i[0],10),g:parseInt(i[1],10),b:parseInt(i[2],10),a:parseFloat(i[3])}}return t},hsv2rgb:function(e,t,i,s){var n,l,a,r,o,d,u,c;switch(1===arguments.length&&(t=e.s,i=e.v,s=e.a,e=e.h),d=(i/=100)*(1-(t/=100)),u=i*(1-(o=6*(e/=360)-(r=Math.floor(6*e)))*t),c=i*(1-(1-o)*t),r%6){case 0:n=i,l=c,a=d;break;case 1:n=u,l=i,a=d;break;case 2:n=d,l=i,a=c;break;case 3:n=d,l=u,a=i;break;case 4:n=c,l=d,a=i;break;case 5:n=i,l=d,a=u}return{r:Math.round(255*n),g:Math.round(255*l),b:Math.round(255*a),a:null!=s?s:1}},rgb2hsv:function(e,t,i,s){1===arguments.length&&(t=e.g,i=e.b,s=e.a,e=e.r);var n,l=Math.max(e,t,i),a=Math.min(e,t,i),r=l-a,o=0===l?0:r/l,d=l/255;switch(l){case a:n=0;break;case e:n=t-i+r*(t<i?6:0),n/=6*r;break;case t:n=i-e+2*r,n/=6*r;break;case i:n=e-t+4*r,n/=6*r}return{h:Math.round(360*n),s:Math.round(100*o),v:Math.round(100*d),a:null!=s?s:1}},tooltip:function(e,t){var i="mouseenter",s="mouseleave";return(t=t||{}).showOn&&(i=t.showOn,delete t.showOn),t.hideOn&&(s=t.hideOn,delete t.hideOn),"on"+i+"=\"$(this).w2tag(w2utils.base64decode('"+w2utils.base64encode(e)+"'),JSON.parse(w2utils.base64decode('"+w2utils.base64encode(JSON.stringify(t))+"')))\"on"+s+'="$(this).w2tag()"'},getCursorPosition:function(e){if(null==e)return null;var t,i,s,n,l,a=0,r=e.ownerDocument||e.document,o=r.defaultView||r.parentWindow;return e.tagName&&"INPUT"===e.tagName.toUpperCase()&&e.selectionStart?a=e.selectionStart:o.getSelection?0<(t=o.getSelection()).rangeCount&&((s=(i=t.getRangeAt(0)).cloneRange()).selectNodeContents(e),s.setEnd(i.endContainer,i.endOffset),a=s.toString().length):(t=r.selection)&&"Control"!==t.type&&(n=t.createRange(),(l=r.body.createTextRange()).moveToElementText(e),l.setEndPoint("EndToEnd",n),a=l.text.length),a},setCursorPosition:function(t,i,s){var n,l=document.createRange(),a=window.getSelection();if(null!=t){for(var r=0;r<t.childNodes.length;r++){var o=e(t.childNodes[r]).text();if(t.childNodes[r].tagName&&(o=(o=e(t.childNodes[r]).html()).replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/ /g," ")),i<=o.length){(n=t.childNodes[r]).childNodes&&0<n.childNodes.length&&(n=n.childNodes[0]),n.childNodes&&0<n.childNodes.length&&(n=n.childNodes[0]);break}i-=o.length}null!=n&&(i>n.length&&(i=n.length),l.setStart(n,i),s?l.setEnd(n,s):l.collapse(!0),a.removeAllRanges(),a.addRange(l))}},testLocalStorage:n,hasLocalStorage:n(),isIOS:-1!==navigator.userAgent.toLowerCase().indexOf("iphone")||-1!==navigator.userAgent.toLowerCase().indexOf("ipod")||-1!==navigator.userAgent.toLowerCase().indexOf("ipad")||-1!==navigator.userAgent.toLowerCase().indexOf("mobile")||-1!==navigator.userAgent.toLowerCase().indexOf("android"),isIE:-1!==navigator.userAgent.toLowerCase().indexOf("msie")||-1!==navigator.userAgent.toLowerCase().indexOf("trident")};function i(e){return/^[-+]?[0-9]+$/.test(e)}function s(t){if(null==t)return t;switch(typeof t){case"number":break;case"string":t=String(t).replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/"/g,""");break;case"object":if(Array.isArray(t)){t=e.extend(!0,[],t);for(var i=0;i<t.length;i++)t[i]=this.encodeTags(t[i])}else for(var i in t=e.extend(!0,{},t))t[i]=this.encodeTags(t[i])}return t}function n(){var e="w2ui_test";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}}}(jQuery),_;w2utils.formatters={number:function(e,t){return 20<parseInt(t)&&(t=20),parseInt(t)<0&&(t=0),null==e||""===e?"":w2utils.formatNumber(parseFloat(e),t,!0)},float:function(e,t){return w2utils.formatters.number(e,t)},int:function(e,t){return w2utils.formatters.number(e,0)},money:function(e,t){if(null==e||""===e)return"";var i=w2utils.formatNumber(Number(e),w2utils.settings.currencyPrecision||2);return(w2utils.settings.currencyPrefix||"")+i+(w2utils.settings.currencySuffix||"")},currency:function(e,t){return w2utils.formatters.money(e,t)},percent:function(e,t){return null==e||""===e?"":w2utils.formatNumber(e,t||1)+"%"},size:function(e,t){return null==e||""===e?"":w2utils.formatSize(parseInt(e))},date:function(e,t){if(""===t&&(t=w2utils.settings.dateFormat),null==e||0===e||""===e)return"";var i=w2utils.isDateTime(e,t,!0);return!1===i&&(i=w2utils.isDate(e,t,!0)),'<span title="'+i+'">'+w2utils.formatDate(i,t)+"</span>"},datetime:function(e,t){if(""===t&&(t=w2utils.settings.datetimeFormat),null==e||0===e||""===e)return"";var i=w2utils.isDateTime(e,t,!0);return!1===i&&(i=w2utils.isDate(e,t,!0)),'<span title="'+i+'">'+w2utils.formatDateTime(i,t)+"</span>"},time:function(e,t){if(""===t&&(t=w2utils.settings.timeFormat),"h12"===t&&(t="hh:mi pm"),"h24"===t&&(t="h24:mi"),null==e||0===e||""===e)return"";var i=w2utils.isDateTime(e,t,!0);return!1===i&&(i=w2utils.isDate(e,t,!0)),'<span title="'+i+'">'+w2utils.formatTime(e,t)+"</span>"},timestamp:function(e,t){if(""===t&&(t=w2utils.settings.datetimeFormat),null==e||0===e||""===e)return"";var i=w2utils.isDateTime(e,t,!0);return!1===i&&(i=w2utils.isDate(e,t,!0)),i.toString?i.toString():""},gmt:function(e,t){if(""===t&&(t=w2utils.settings.datetimeFormat),null==e||0===e||""===e)return"";var i=w2utils.isDateTime(e,t,!0);return!1===i&&(i=w2utils.isDate(e,t,!0)),i.toUTCString?i.toUTCString():""},age:function(e,t){if(null==e||0===e||""===e)return"";var i=w2utils.isDateTime(e,null,!0);return!1===i&&(i=w2utils.isDate(e,null,!0)),'<span title="'+i+'">'+w2utils.age(e)+(t?" "+t:"")+"</span>"},interval:function(e,t){return null==e||0===e||""===e?"":w2utils.interval(e)+(t?" "+t:"")},toggle:function(e,t){return e?"Yes":""},password:function(e,t){for(var i="",s=0;s<e.length;s++)i+="*";return i}},w2utils.event={on:function(e,t){var i,s,n=jQuery;"string"==typeof e&&-1!==e.indexOf(".")&&(e=(s=e.split("."))[0],i=s[1]),"string"==typeof e&&-1!==e.indexOf(":")&&(s=e.split(":"),-1!==["complete","done"].indexOf(e[1])&&(e[1]="after"),e={type:s[0],execute:s[1]}),n.isPlainObject(e)||(e={type:e,scope:i}),(e=n.extend({type:null,execute:"before",target:null,onComplete:null},e)).type?t?(n.isArray(this.handlers)||(this.handlers=[]),this.handlers.push({edata:e,handler:t})):console.log("ERROR: You must specify event handler function when calling .on() method of "+this.name):console.log("ERROR: You must specify event type when calling .on() method of "+this.name)},off:function(e,t){var i,s,n=jQuery;if("string"==typeof e&&-1!==e.indexOf(".")&&(e=(s=e.split("."))[0],i=s[1],""===e&&(e="*")),"string"==typeof e&&-1!==e.indexOf(":")&&(s=e.split(":"),-1!==["complete","done"].indexOf(e[1])&&(e[1]="after"),e={type:s[0],execute:s[1]}),n.isPlainObject(e)||(e={type:e}),(e=n.extend({},{type:null,execute:null,target:null,onComplete:null},e)).type||i){t=t||null;for(var l=[],a=0,r=this.handlers.length;a<r;a++){var o=this.handlers[a];(o.edata.type!==e.type&&"*"!==e.type&&(null==o.edata.scope||""!=e.type)||o.edata.target!==e.target&&null!=e.target||o.edata.execute!==e.execute&&null!=e.execute||!(o.handler===t&&null!=t||null!=i&&o.edata.scope==i))&&l.push(o)}this.handlers=l}else console.log("ERROR: You must specify event type when calling .off() method of "+this.name)},trigger:function(e){var t,i,s,n=jQuery;"before"===(e=n.extend({type:null,phase:"before",target:null,doneHandlers:[]},e,{isStopped:!1,isCancelled:!1,done:function(e){this.doneHandlers.push(e)},preventDefault:function(){this.isCancelled=!0},stopPropagation:function(){this.isStopped=!0}})).phase&&(e.onComplete=null),null==e.target&&(e.target=null),n.isArray(this.handlers)||(this.handlers=[]);for(var l=this.handlers.length-1;0<=l;l--){var a=this.handlers[l];if(!(null==a||a.edata.type!==e.type&&"*"!==a.edata.type||a.edata.target!==e.target&&null!=a.edata.target||a.edata.execute!==e.phase&&"*"!==a.edata.execute&&"*"!==a.edata.phase)&&(e=n.extend({}
1,a.edata,e),t=[],(s=new RegExp(/\((.*?)\)/).exec(a.handler))&&(t=s[1].split(/\s*,\s*/)),2===t.length?a.handler.call(this,e.target,e):a.handler.call(this,e),!0===e.isStopped||!0===e.stop))return e}var r="on"+e.type.substr(0,1).toUpperCase()+e.type.substr(1);if("before"===e.phase&&"function"==typeof this[r]&&(i=this[r],t=[],(s=new RegExp(/\((.*?)\)/).exec(i))&&(t=s[1].split(/\s*,\s*/)),2===t.length?i.call(this,e.target,e):i.call(this,e),!0===e.isStopped||!0===e.stop))return e;if(null!=e.object&&"before"===e.phase&&"function"==typeof e.object[r]&&(i=e.object[r],t=[],(s=new RegExp(/\((.*?)\)/).exec(i))&&(t=s[1].split(/\s*,\s*/)),2===t.length?i.call(this,e.target,e):i.call(this,e),!0===e.isStopped||!0===e.stop))return e;if("after"===e.phase){"function"==typeof e.onComplete&&e.onComplete.call(this,e);for(var o=0;o<e.doneHandlers.length;o++)"function"==typeof e.doneHandlers[o]&&e.doneHandlers[o].call(this,e)}return e}},_=jQuery,_.fn.w2render=function(e){0<_(this).length&&("string"==typeof e&&w2ui[e]&&w2ui[e].render(_(this)[0]),"object"==typeof e&&e.render(_(this)[0]))},_.fn.w2destroy=function(e){!e&&0<this.length&&(e=this.attr("name")),"string"==typeof e&&w2ui[e]&&w2ui[e].destroy(),"object"==typeof e&&e.destroy()},_.fn.w2marker=function(){var e=Array.prototype.slice.call(arguments,0);return Array.isArray(e[0])&&(e=e[0]),0!==e.length&&e[0]?_(this).each((function(i,s){t(0,s);for(var n=0;n<e.length;n++){var l=e[n];"string"!=typeof l&&(l=String(l)),l=l.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&").replace(/&/g,"&").replace(/</g,">").replace(/>/g,"<");var a=new RegExp(l+"(?!([^<]+)?>)","gi");s.innerHTML=s.innerHTML.replace(a,r)}function r(e){return'<span class="w2ui-marker">'+e+"</span>"}})):_(this).each(t);function t(e,t){for(;-1!==t.innerHTML.indexOf('<span class="w2ui-marker">');)t.innerHTML=t.innerHTML.replace(/\<span class=\"w2ui\-marker\"\>((.|\n|\r)*)\<\/span\>/gi,"$1")}},_.fn.w2tag=function(e,t){if(1===arguments.length&&"object"==typeof e&&null!=(t=e).html&&(e=t.html),null!=(t=_.extend({id:null,auto:null,html:e,position:"right|top",align:"none",left:0,top:0,maxWidth:null,style:"",css:{},className:"",inputClass:"",onShow:null,onHide:null,hideOnKeyPress:!0,hideOnFocus:!1,hideOnBlur:!1,hideOnClick:!1,hideOnChange:!0},t)).name&&null==t.id&&(t.id=t.name),""!==t.class&&""===t.inputClass&&(t.inputClass=t.class),0!==_(this).length)return!0===t.auto||null!=t.showOn||null!=t.hideOn?0!=arguments.length&&e?_(this).each((function(i,s){var n="mouseenter",l="mouseleave";t.showOn&&(n=String(t.showOn).toLowerCase(),delete t.showOn),t.hideOn&&(l=String(t.hideOn).toLowerCase(),delete t.hideOn),t.potision||(t.position="top|bottom"),_(s).off(".w2tooltip").on(n+".w2tooltip",(function(){t.auto=!1,_(this).w2tag(e,t)})).on(l+".w2tooltip",(function(){_(this).w2tag()}))})):_(this).each((function(e,t){_(t).off(".w2tooltip")})):_(this).each((function(i,s){var n,l=t.id?t.id:s.id;""==l&&(l=_(s).find("input").attr("id")),l=l||"noid";var a,r=w2utils.escapeId(l);return null!=_(this).data("w2tag")?(n=_(this).data("w2tag"),_.extend(n.options,t)):n={id:l,attachedTo:s,box:_("#w2ui-tag-"+r),options:_.extend({},t),init:o,hide:function(){n.box.length<=0||(n.tmp.timer&&clearTimeout(n.tmp.timer),n.box.remove(),n.options.hideOnClick&&_("body").off(".w2tag"+(n.id||"")),_(n.attachedTo).off(".w2tag").removeClass(n.options.inputClass).removeData("w2tag"),0<_(n.attachedTo).length&&(_(n.attachedTo)[0].style.cssText=n.tmp.originalCSS),"function"==typeof n.options.onHide&&n.options.onHide())},getPos:u,isMoved:d,tmp:{}},void(""===e||null==e?n.hide():0!==n.box.length?n.box.find(".w2ui-tag-body").css(n.options.css).attr("style",n.options.style).addClass(n.options.className).html(n.options.html):(n.tmp.originalCSS="",0<_(n.attachedTo).length&&(n.tmp.originalCSS=_(n.attachedTo)[0].style.cssText),a="white-space: nowrap;",n.options.maxWidth&&w2utils.getStrWidth(e)>n.options.maxWidth&&(a="width: "+n.options.maxWidth+"px"),_("body").append('<div onclick="event.stopPropagation()" style="display: none;" id="w2ui-tag-'+n.id+'" class="w2ui-tag '+(0<_(n.attachedTo).parents(".w2ui-popup, .w2ui-overlay-popup, .w2ui-message").length?"w2ui-tag-popup":"")+'"> <div style="margin: -2px 0px 0px -2px; '+a+'"> <div class="w2ui-tag-body '+n.options.className+'" style="'+(n.options.style||"")+'">'+e+"</div> </div></div>"),n.box=_("#w2ui-tag-"+r),_(n.attachedTo).data("w2tag",n),setTimeout(o,1)));function o(){var e;n.box.css("display","block"),n&&n.box&&_(n.attachedTo).offset()&&(e=n.getPos(),n.box.css({opacity:"1",left:e.left+"px",to
1p:e.top+"px"}).data("w2tag",n).find(".w2ui-tag-body").addClass(e.posClass),n.tmp.pos=e.left+"x"+e.top,_(n.attachedTo).off(".w2tag").css(n.options.css).addClass(n.options.inputClass),n.options.hideOnKeyPress&&_(n.attachedTo).on("keypress.w2tag",n.hide),n.options.hideOnFocus&&_(n.attachedTo).on("focus.w2tag",n.hide),t.hideOnChange&&("INPUT"===s.nodeName?_(s).on("change.w2tag",n.hide):_(s).find("input").on("change.w2tag",n.hide)),n.options.hideOnBlur&&_(n.attachedTo).on("blur.w2tag",n.hide),n.options.hideOnClick&&_("body").on("click.w2tag"+(n.id||""),n.hide),"function"==typeof n.options.onShow&&n.options.onShow(),d())}function d(e){var t,i=_(n.attachedTo).offset();0===_(n.attachedTo).length||0===i.left&&0===i.top||0===n.box.find(".w2ui-tag-body").length?n.hide():(t=u(),n.tmp.pos!==t.left+"x"+t.top&&(n.box.css(w2utils.cssPrefix({transition:e?"0s":".2s"})).css({left:t.left+"px",top:t.top+"px"}),n.tmp.pos=t.left+"x"+t.top),n.tmp.timer&&clearTimeout(n.tmp.timer),n.tmp.timer=setTimeout(d,100))}function u(){var e=_(n.attachedTo).offset(),t="w2ui-tag-right",i=parseInt(e.left+n.attachedTo.offsetWidth+(n.options.left?n.options.left:0)),s=parseInt(e.top+(n.options.top?n.options.top:0)),l=n.box.find(".w2ui-tag-body"),a=l[0].offsetWidth,r=l[0].offsetHeight;if("string"==typeof n.options.position&&-1!==n.options.position.indexOf("|")&&(n.options.position=n.options.position.split("|")),"top"===n.options.position)t="w2ui-tag-top",i=parseInt(e.left+(n.options.left?n.options.left:0))-14,s=parseInt(e.top+(n.options.top?n.options.top:0))-r-10;else if("bottom"===n.options.position)t="w2ui-tag-bottom",i=parseInt(e.left+(n.options.left?n.options.left:0))-14,s=parseInt(e.top+n.attachedTo.offsetHeight+(n.options.top?n.options.top:0))+10;else if("left"===n.options.position)t="w2ui-tag-left",i=parseInt(e.left+(n.options.left?n.options.left:0))-a-20,s=parseInt(e.top+(n.options.top?n.options.top:0));else if(Array.isArray(n.options.position)){for(var o=window.innerWidth,d=window.innerHeight,u=0;u<n.options.position.length;u++){var c=n.options.position[u];if("right"===c){if(t="w2ui-tag-right",i=parseInt(e.left+n.attachedTo.offsetWidth+(n.options.left?n.options.left:0)),s=parseInt(e.top+(n.options.top?n.options.top:0)),i+a<=o)break}else if("left"===c){if(t="w2ui-tag-left",i=parseInt(e.left+(n.options.left?n.options.left:0))-a-20,s=parseInt(e.top+(n.options.top?n.options.top:0)),0<=i)break}else if("top"===c){if(t="w2ui-tag-top",i=parseInt(e.left+(n.options.left?n.options.left:0))-14,s=parseInt(e.top+(n.options.top?n.options.top:0))-r-10,i+a<=o&&0<=s)break}else if("bottom"===c&&(t="w2ui-tag-bottom",i=parseInt(e.left+(n.options.left?n.options.left:0))-14,s=parseInt(e.top+n.attachedTo.offsetHeight+(n.options.top?n.options.top:0))+10,i+a<=o&&s+r<=d))break}l.data("posClass")!==t&&l.removeClass("w2ui-tag-right w2ui-tag-left w2ui-tag-top w2ui-tag-bottom").addClass(t).data("posClass",t)}return{left:i,top:s,posClass:t}}}));_(".w2ui-tag").each((function(e,t){var i=_(t).data("w2tag");i&&i.hide()}))},_.fn.w2overlay=function(e,t){var i,s=this,n="";if(1===arguments.length&&(t="object"==typeof e?e:{html:e}),2===arguments.length&&(t.html=e),_.isPlainObject(t)||(t={}),(t=_.extend({},{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:{}},t)).name&&(n="-"+t.name),0===this.length||""===t.html||null==t.html)return 0<_("#w2ui-overlay"+n).length?"function"==typeof(i=_("#w2ui-overlay"+n)[0].hide)&&i():_("#w2ui-overlay"+n).remove(),_(this);0<_("#w2ui-overlay"+n).length&&(i=_("#w2ui-overlay"+n)[0].hide,_(document).off(".w2overlay"+n),"function"==typeof i&&i()),0<s.length&&(null==s[0].tagName||"BODY"===s[0].tagName.toUpperCase())&&(t.contextMenu=!0),t.contextMenu&&t.originalEvent&&(t.pageX=t.originalEvent.pageX,t.pageY=t.originalEvent.pageY),!t.contextMenu||null!=t.pageX&&null!=t.pageY||console.log("ERROR: to display menu at mouse location, pass options.pageX and options.pageY.");var l="";
1t.data&&Object.keys(t.data).forEach((function(e){l+="data-"+e+'="'+t.data[e]+'"'})),_("body").append('<div id="w2ui-overlay'+n+'" style="display: none; left: 0px; top: 0px; '+t.overlayStyle+'" '+l+' class="w2ui-reset w2ui-overlay '+(0<_(this).parents(".w2ui-popup, .w2ui-overlay-popup, .w2ui-message").length?"w2ui-overlay-popup":"")+'"> <style></style> <div style="min-width: 100%; '+t.style+'" class="'+t.class+'"></div></div>');var a=_("#w2ui-overlay"+n),r=a.find(" > div");r.html(t.html);var o=r.css("background-color");null!=o&&"rgba(0, 0, 0, 0)"!==o&&"transparent"!==o&&a.css({"background-color":o,"border-color":o});var d=_(s).offset()||{};return a.data("element",0<s.length?s[0]:null).data("options",t).data("position",d.left+"x"+d.top).fadeIn("fast").on("click",(function(e){_("#w2ui-overlay"+n).data("keepOpen",!0),"LABEL"===e.target.tagName.toUpperCase()&&e.stopPropagation()})).on("mousedown",(function(e){var i=e.target.tagName.toUpperCase();-1!==["INPUT","TEXTAREA","SELECT"].indexOf(i)||t.selectable||e.preventDefault()})),a[0].hide=u,a[0].resize=c,setTimeout((function(){_(document).off(".w2overlay"+n).on("click.w2overlay"+n,u),"function"==typeof t.onShow&&t.onShow(),c()}),10),function e(){var t=_("#w2ui-overlay"+n);if(t.data("element")===s[0]&&0!==t.length){var i=_(s).offset()||{},l=i.left+"x"+i.top;t.data("position")!==l?u():setTimeout(e,250)}}(),_(this);function u(e){var i,s;e&&0!==e.button||(i=_("#w2ui-overlay"+n),e&&_(_(e.target).closest(".w2ui-overlay").data("element")).closest(".w2ui-overlay")[0]===i[0]||(!0!==i.data("keepOpen")?("function"==typeof t.onHide&&(s=t.onHide()),!1!==s&&(i.remove(),_(document).off(".w2overlay"+n),clearInterval(i.data("timer")))):i.removeData("keepOpen")))}function c(){var e=_("#w2ui-overlay"+n),i=e.find(" > div"),l=_("#w2ui-overlay"+n+" div.w2ui-menu"),a={};if(0<l.length&&(l.css("overflow-y","hidden"),a.scrollTop=l.scrollTop(),a.scrollLeft=l.scrollLeft()),0<e.length){i.height("auto").width("auto");var r=!1,o=i.height(),d=i.width();t.width&&t.width<d&&(d=t.width),d<30&&(d=30),t.tmp.contentHeight&&(o=parseInt(t.tmp.contentHeight),i.height(o),setTimeout((function(){var e=i.find("div.w2ui-menu");o>e.height()&&i.find("div.w2ui-menu").css("overflow-y","hidden")}),1),setTimeout((function(){var e=i.find("div.w2ui-menu");"auto"!==e.css("overflow-y")&&e.css("overflow-y","auto")}),10)),t.tmp.contentWidth&&"both"!==t.align?(d=parseInt(t.tmp.contentWidth),i.width(d),setTimeout((function(){d>i.find("div.w2ui-menu > table").width()&&i.find("div.w2ui-menu > table").css("overflow-x","hidden")}),1),setTimeout((function(){i.find("div.w2ui-menu > table").css("overflow-x","auto")}),10)):i.find("div.w2ui-menu").css("width","100%");var u=t.left,h=t.width,p=t.tipLeft;switch(t.align){case"both":u=17,0===t.width&&(t.width=w2utils.getSize(_(s),"width")),t.maxWidth&&t.width>t.maxWidth&&(t.width=t.maxWidth);break;case"left":u=17;break;case"right":u=w2utils.getSize(_(s),"width")-d+10,p=d-40}var f,g,m,w="auto"!==(h=30!==d||h?t.width?t.width:"auto":30)?(h-17)/2:(d-17)/2;w<25&&(u=25-w,p=Math.floor(w)),m=t.contextMenu?(f=t.pageX+8,g=+t.pageY,t.pageY):(f=(25<(y=s.offset()||{}).left?y.left:25)+u,g=y.top+w2utils.getSize(s,"height")+t.top+7,y.top),e.css({left:f+"px",top:g+"px","min-width":h,"min-height":t.height?t.height:"auto"});var v,y=i.offset()||{},b=window.innerHeight+_(document).scrollTop()-y.top-7,x=window.innerWidth+_(document).scrollLeft()-y.left-7;t.contextMenu&&(b=window.innerHeight+_(document).scrollTop()-t.pageY-15,x=window.innerWidth+_(document).scrollLeft()-t.pageX),(-50<b&&b<210||!0===t.openAbove)&&!1!==t.openAbove?(v=t.contextMenu?(b=t.pageY-7,5):(b=y.top-_(document).scrollTop()-7,24),t.maxHeight&&b>t.maxHeight&&(b=t.maxHeight),b<o&&(r=!0,i.height(b).width(d).css({"overflow-y":"auto"}),o=b),e.addClass("bottom-arrow"),e.css("top",m-o-v+t.top+"px")):(t.maxHeight&&b>t.maxHeight&&(b=t.maxHeight),b<o&&(r=!0,i.height(b).width(d).css({"overflow-y":"auto"})),e.addClass("top-arrow")),e.find(">style").html("#w2ui-overlay"+n+":before { margin-left: "+parseInt(p)+"px; }#w2ui-overlay"+n+":after { margin-left: "+parseInt(p)+"px; }"),d=i.width(),x=window.innerWidth+_(document).scrollLeft()-y.left-7,t.maxWidth&&x>t.maxWidth&&(x=t.maxWidth),x<d&&"both"!==t.align&&(t.align="right",setTimeout((function(){c()}),1)),(t.contextMenu||t.noTip)&&e.find(">style").html("#w2ui-overlay"+n+":before { display: none; }#w2ui-overlay"+n+":after { display: none; }"),r&&"both"!==t.align&&i.width(d+w2utils.scrollBarSize()+2)}0<l.length&&(l.css("overflow-y","auto"),l.scrollTop(a.scrollTop),l.scrollLeft(a.scrollLeft))}},_.fn.w2menu=function(e,t){t&&"function"==typeof t.items&&(t.items=t.items());var i,s=this,n="";if("refresh"===e)_.fn.w2menuOptions&&_.fn.w2menuOptions.name&&(n="-"+_.fn.w2menuOptions.name),t.name&&(n="-"+t.name),0<_("#w2ui-overlay"+n).length?(t=_.extend(_.fn.w2menuOptions,t),d=_("#w2ui-overlay"+n+" div.w2ui-menu").scrollTop(),_("#w2ui-overlay"+n+" div.w2ui-menu").html(g()),_("#w2ui-overlay"+n+" div.w2ui-menu").scrollTop(d),p()):_(this).w2menu(t);else if("refresh-index"===e){var l,a,r=_("#w2ui-overlay"+n+" div.w2ui-menu"),o=r.find("tr[index="+t.index+"]"),d=r.scrollTop();r.find("tr.w2ui-selected").removeClass("w2ui-selected"),o.addClass("w2ui-selected"),0<o.length&&(l=o[0].offsetTop-5,a=r.height(),r.scrollTop(d),(l<d||l+o.height()>d+a)&&r.animate({scrollTop:l-(a-2*o.height())/2},200,"linear")),p()}else{1===arguments.length?t=e:t.items=e,"object"!=typeof t&&(t={}),t=_.extend({},{type:"normal",index:null,items:[],render:null,msgNoItems:"No items",onSelect:null,hideOnRemove:!1,tmp:{}},t),(_.fn.w2menuOptions=t).name&&(n="-"+t.name),"function"==typeof t.select&&"function"!=typeof t.onSelect&&(t.onSelect=t.select),"function"==typeof t.remove&&"function"!=typeof t.onRemove&&(t.onRemove=t.remove),"function"==typeof t.onRender&&"function"!=typeof t.render&&(t.render=t.onRender),_.fn.w2menuClick=function(e,i,s){var l,a,r=!1,o=_(e.target).closest("tr");
1(e.shiftKey||e.metaKey||e.ctrlKey)&&(r=!0),items=null==s?t.items:t.items[s].items,_(e.target).hasClass("remove")?("function"==typeof t.onRemove&&t.onRemove({index:i,parentIndex:s,item:items[i],keepOpen:r,originalEvent:e}),r=!t.hideOnRemove,_(e.target).closest("tr").remove(),p()):o.hasClass("has-sub-menu")?(r=!0,o.hasClass("expanded")?(items[i].expanded=!1,o.removeClass("expanded").addClass("collapsed").next().hide()):(items[i].expanded=!0,o.addClass("expanded").removeClass("collapsed").next().show()),p()):"function"==typeof t.onSelect&&(l=items,"function"==typeof items&&(l=items(t.items[s])),null!=l[i].keepOpen&&(r=l[i].keepOpen),t.onSelect({index:i,parentIndex:s,item:l[i],keepOpen:r,originalEvent:e})),null!=items[i]&&!0===items[i].keepOpen||((a=_("#w2ui-overlay"+n)).removeData("keepOpen"),0<a.length&&"function"==typeof a[0].hide&&!r&&a[0].hide())},_.fn.w2menuDown=function(e,i,s){var n=_(e.target).closest("tr"),l=_(n.get(0)).find(".w2ui-icon"),a=null==s?t.items:t.items[s].items,r=a[i];"check"!==t.type&&"radio"!==t.type||!1===r.group||_(e.target).hasClass("remove")||_(e.target).closest("tr").hasClass("has-sub-menu")||(r.checked=!r.checked,r.checked?("radio"===t.type&&l.parents("table").find(".w2ui-icon").removeClass("w2ui-icon-check").addClass("w2ui-icon-empty"),"check"===t.type&&null!=r.group&&a.forEach((function(e,t){e.id!=r.id&&e.group===r.group&&e.checked&&(l.closest("table").find("tr[index="+t+"] .w2ui-icon").removeClass("w2ui-icon-check").addClass("w2ui-icon-empty"),a[t].checked=!1)})),l.removeClass("w2ui-icon-empty").addClass("w2ui-icon-check")):"check"===t.type&&null==r.group&&!1!==r.group&&l.removeClass("w2ui-icon-check").addClass("w2ui-icon-empty")),n.parent().find("tr").removeClass("w2ui-selected"),n.addClass("w2ui-selected")};var u="";if(t.search){u+='<div style="position: absolute; top: 0px; height: 40px; left: 0px; right: 0px; border-bottom: 1px solid silver; background-color: #ECECEC; padding: 8px 5px;"> <div class="w2ui-icon icon-search" style="position: absolute; margin-top: 4px; margin-left: 6px; width: 11px; background-position: left !important;"></div> <input id="menu-search" type="text" style="width: 100%; outline: none; padding-left: 20px;" onclick="event.stopPropagation();"/></div>',t.style+=";background-color: #ECECEC";for(var c=t.index=0;c<t.items.length;c++)t.items[c].hidden=!1}u+=(t.topHTML||"")+'<div class="w2ui-menu" style="top: '+(t.search?40:0)+"px;"+(t.menuStyle||"")+'">'+g()+"</div>",i=_(this).w2overlay(u,t),setTimeout((function(){if(_("#w2ui-overlay"+n+" #menu-search").on("keyup",f).on("keydown",(function(e){9===e.keyCode&&(e.stopPropagation(),e.preventDefault())})),t.search){if(-1!==["text","password"].indexOf(_(s)[0].type)||"TEXTAREA"===_(s)[0].tagName.toUpperCase())return;_("#w2ui-overlay"+n+" #menu-search").focus()}p()}),250),p();var h=_("#w2ui-overlay"+n);0<h.length&&(h[0].mresize=p,h[0].change=f)}return i;function p(){setTimeout((function(){_("#w2ui-overlay"+n+" tr.w2ui-selected").removeClass("w2ui-selected");var e,i,s=_("#w2ui-overlay"+n+" tr[index="+t.index+"]"),l=_("#w2ui-overlay"+n+" div.w2ui-menu").scrollTop();s.addClass("w2ui-selected"),t.tmp&&(t.tmp.contentHeight=_("#w2ui-overlay"+n+" table").height()+(t.search?50:10)+(parseInt(_("#w2ui-overlay"+n+" .w2ui-menu").css("top"))||0)+(parseInt(_("#w2ui-overlay"+n+" .w2ui-menu").css("bottom"))||0),t.tmp.contentWidth=_("#w2ui-overlay"+n+" table").width()),0<_("#w2ui-overlay"+n).length&&_("#w2ui-overlay"+n)[0].resize(),0<s.length&&(e=s[0].offsetTop-5,i=_("#w2ui-overlay"+n+" div.w2ui-menu").height(),_("#w2ui-overlay"+n+" div.w2ui-menu").scrollTop(l),(e<l||e+s.height()>l+i)&&_("#w2ui-overlay"+n+" div.w2ui-menu").animate({scrollTop:e-(i-2*s.height())/2},200,"linear"))}),1)}function f(e){var i=this.value,l=!1;switch(e.keyCode){case 13:_("#w2ui-overlay"+n).remove(),_.fn.w2menuClick(e,t.index);break;case 9:case 27:_("#w2ui-overlay"+n).remove(),_.fn.w2menuClick(e,-1);break;case 38:for(t.index=w2utils.isInt(t.index)?parseInt(t.index):0,t.index--;0<t.index&&t.items[t.index].hidden;)t.index--;if(0===t.index&&t.items[t.index].hidden)for(;t.items[t.index]&&t.items[t.index].hidden;)t.index++;t.index<0&&(t.index=0),l=!0;break;case 40:for(t.index=w2utils.isInt(t.index)?parseInt(t.index):0,t.index++;t.index<t.items.length-1&&t.items[t.index].hidden;)t.index++;if(t.index===t.items.length-1&&t.items[t.index].hidden)for(;t.items[t.index]&&t.items[t.index].hidden;)t.index--;t.index>
1=t.items.length&&(t.index=t.items.length-1),l=!0}if(!l){for(var a=0,r=0;r<t.items.length;r++){var o=t.items[r],d="",u="";-1!==["is","begins with"].indexOf(t.match)&&(d="^"),-1!==["is","ends with"].indexOf(t.match)&&(u="$");try{new RegExp(d+i+u,"i").test(o.text)||"..."===o.text?o.hidden=!1:o.hidden=!0}catch(e){}"enum"===s.type&&-1!==_.inArray(o.id,ids)&&(o.hidden=!0),!0!==o.hidden&&a++}for(t.index=0;t.index<t.items.length-1&&t.items[t.index].hidden;)t.index++;a<=0&&(t.index=-1)}_(s).w2menu("refresh",t),p()}function g(e,i,s,n){if(t.spinner)return'<table><tbody><tr><td style="padding: 5px 10px 13px 10px; text-align: center"> <div class="w2ui-spinner" style="width: 18px; height: 18px; position: relative; top: 5px;"></div> <div style="display: inline-block; padding: 3px; color: #999;">'+w2utils.lang("Loading...")+"</div></td></tr></tbody></table>";var l=0,a='<table cellspacing="0" cellpadding="0" class="'+(i?" sub-menu":"")+'"><tbody>',r=null,o=null;null==e&&(e=t.items),Array.isArray(e)||(e=[]);for(var d=0;d<e.length;d++){var u,c,h,p,f,m,w,v,y=e[d];"string"==typeof y?y={id:y,text:y}:(null!=y.text&&null==y.id&&(y.id=y.text),null==y.text&&null!=y.id&&(y.text=y.id),null!=y.caption&&(y.text=y.caption),null==(r=y.img)&&(r=null),null==(o=y.icon)&&(o=null)),-1==["radio","check"].indexOf(t.type)||Array.isArray(y.items)||!1===y.group||(o=!0===y.checked?"w2ui-icon-check":"w2ui-icon-empty"),!0!==y.hidden&&(u="",c=y.text,h="","function"==typeof t.render&&(c=t.render(y,t)),"function"==typeof c&&(c=c(y,t)),r&&(u='<td class="menu-icon"><div class="w2ui-tb-image w2ui-icon '+r+'"></div></td>'),o&&(u='<td class="menu-icon" align="center"><span class="w2ui-icon '+o+'"></span></td>'),"break"!==y.type&&null!=c&&""!==c&&"--"!=String(c).substr(0,2)?(p=l%2==0?"w2ui-item-even":"w2ui-item-odd",!0!==t.altRows&&(p=""),f=1,""===u&&f++,null==y.count&&null==y.hotkey&&!0!==y.remove&&null==y.items&&f++,null==y.tooltip&&null!=y.hint&&(y.tooltip=y.hint),!(m="")===y.remove?m='<span class="remove">X</span>':null!=y.items?(w=[],"function"==typeof y.items?w=y.items(y):Array.isArray(y.items)&&(w=y.items),m="<span></span>",h='<tr style="'+(y.expanded?"":"display: none")+'"> <td colspan="3">'+g(w,!0,y.expanded,d)+"</td><tr>"):(null!=y.count&&(m+="<span>"+y.count+"</span>"),null!=y.hotkey&&(m+='<span class="hotkey">'+y.hotkey+"</span>")),a+='<tr index="'+d+'" style="'+(y.style?y.style:"")+'" '+(y.tooltip?'title="'+w2utils.lang(y.tooltip)+'"':"")+' class="'+p+(t.index===d?" w2ui-selected":"")+(!0===y.disabled?" w2ui-disabled":"")+(""!==h?" has-sub-menu"+(y.expanded?" expanded":" collapsed"):"")+'" onmousedown="if ('+(!0===y.disabled?"true":"false")+") return; jQuery.fn.w2menuDown(event, "+d+", "+n+');" onclick="event.stopPropagation(); if ('+(!0===y.disabled?"true":"false")+") return; jQuery.fn.w2menuClick(event, "+d+", "+n+');">'+(i?"<td></td>":"")+u+' <td class="menu-text" colspan="'+f+'">'+w2utils.lang(c)+'</td> <td class="menu-count">'+m+"</td></tr>"+h,l++):a+='<tr><td colspan="3" class="menu-divider '+(""!=(v=c.replace(/^-+/g,""))?"divider-text":"")+'"> <div class="line">'+v+'</div> <div class="text">'+v+"</div></td></tr>"),e[d]=y}return 0===l&&t.msgNoItems&&(a+='<tr><td style="padding: 13px; color: #999; text-align: center">'+t.msgNoItems+"</div></td></tr>"),a+"</tbody></table>"}},_.fn.w2color=function(e,t){var i,s,n,l,a,r,o,d,u,c,h,p,f,g=_(this),m=g[0];function w(e){e.color;for(var t,n='<div class="w2ui-colors" onmousedown="jQuery(this).parents(\'.w2ui-overlay\').data(\'keepOpen\', true)"><div class="w2ui-color-palette"><table cellspacing="5"><tbody>',l=0;l<s.length;l++){n+="<tr>";for(var a=0;a<s[l].length;a++)t="FFFFFF"===s[l][a]?";border: 1px solid #efefef":"",n+='<td> <div class="w2ui-color '+(""===s[l][a]?"w2ui-no-color":"")+'" style="background-color: #'+s[l][a]+t+';" name="'+s[l][a]+'" index="'+l+":"+a+'">'+(e.color==s[l][a]?"•":" ")+" </div></td>",e.color==s[l][a]&&(i=[l,a]);n+="</tr>",l<2&&(n+='<tr><td style="height: 8px" colspan="8"></td></tr>')}return n+="</tbody></table></div>",(n+='<div class="w2ui-color-advanced" style="display: none"> <div class="color-info"> <div class="color-preview-bg"><div class="color-preview"></div><div class="color-original"></div></div> <div class="color-part">
1 <span>H</span> <input name="h" maxlength="3" max="360" tabindex="101"> <span>R</span> <input name="r" maxlength="3" max="255" tabindex="104"> </div> <div class="color-part"> <span>S</span> <input name="s" maxlength="3" max="100" tabindex="102"> <span>G</span> <input name="g" maxlength="3" max="255" tabindex="105"> </div> <div class="color-part"> <span>V</span> <input name="v" maxlength="3" max="100" tabindex="103"> <span>B</span> <input name="b" maxlength="3" max="255" tabindex="106"> </div> <div class="color-part" style="margin: 30px 0px 0px 2px"> <span style="width: 40px">Opacity</span> <input name="a" maxlength="5" max="1" style="width: 32px !important" tabindex="107"> </div> </div> <div class="palette" name="palette"> <div class="palette-bg"></div> <div class="value1 move-x move-y"></div> </div> <div class="rainbow" name="rainbow"> <div class="value2 move-x"></div> </div> <div class="alpha" name="alpha"> <div class="alpha-bg"></div> <div class="value2 move-x"></div> </div></div>')+"<div class=\"w2ui-color-tabs\"> <div class=\"w2ui-color-tab selected\" onclick=\"jQuery(this).addClass('selected').next().removeClass('selected').parents('.w2ui-overlay').find('.w2ui-color-advanced').hide().parent().find('.w2ui-color-palette').show(); jQuery.fn._colorAdvanced = false; jQuery('#w2ui-overlay')[0].resize()\"><span class=\"w2ui-icon w2ui-icon-colors\"></span></div> <div class=\"w2ui-color-tab\" onclick=\"jQuery(this).addClass('selected').prev().removeClass('selected').parents('.w2ui-overlay').find('.w2ui-color-advanced').show().parent().find('.w2ui-color-palette').hide(); jQuery.fn._colorAdvanced = true; jQuery('#w2ui-overlay')[0].resize()\"><span class=\"w2ui-icon w2ui-icon-settings\"></span></div> <div style=\"padding: 8px; text-align: right;\">"+("string"==typeof e.html?e.html:"")+'</div></div></div><div style="clear: both; height: 0"></div>'}g.data("skipInit")?g.removeData("skipInit"):(i=[-1,-1],null==_.fn.w2colorPalette&&(_.fn.w2colorPalette=[["000000","333333","555555","777777","888888","999999","AAAAAA","CCCCCC","DDDDDD","EEEEEE","F7F7F7","FFFFFF"],["FF011B","FF9838","FFC300","FFFD59","86FF14","14FF7A","2EFFFC","2693FF","006CE7","9B24F4","FF21F5","FF0099"],["FFEAEA","FCEFE1","FCF4DC","FFFECF","EBFFD9","D9FFE9","E0FFFF","E8F4FF","ECF4FC","EAE6F4","FFF5FE","FCF0F7"],["F4CCCC","FCE5CD","FFF1C2","FFFDA1","D5FCB1","B5F7D0","BFFFFF","D6ECFF","CFE2F3","D9D1E9","FFE3FD","FFD9F0"],["EA9899","F9CB9C","FFE48C","F7F56F","B9F77E","84F0B1","83F7F7","B5DAFF","9FC5E8","B4A7D6","FAB9F6","FFADDE"],["E06666","F6B26B","DEB737","E0DE51","8FDB48","52D189","4EDEDB","76ACE3","6FA8DC","8E7CC3","E07EDA","F26DBD"],["CC0814","E69138","AB8816","B5B20E","6BAB30","27A85F","1BA8A6","3C81C7","3D85C6","674EA7","A14F9D","BF4990"],["99050C","B45F17","80650E","737103","395E14","10783D","13615E","094785","0A5394","351C75","780172","782C5A"]]),s=_.fn.w2colorPalette,"string"==typeof e&&(e={color:e,transparent:!0}),null==e.onSelect&&null!=t&&(e.onSelect=t),e.transparent&&"333333"==s[0][1]&&(s[0].splice(1,1),s[0].push("")),e.transparent||"333333"==s[0][1]||(s[0].splice(1,0,"333333"),s[0].pop()),e.color&&(e.color=String(e.color).toUpperCase()),"string"==typeof e.color&&"#"===e.color.substr(0,1)&&(e.color=e.color.substr(1)),null==e.fireChange&&(e.fireChange=!0),0===_("#w2ui-overlay").length?_(m).w2overlay(w(e),e):(_("#w2ui-overlay .w2ui-colors").parent().html(w(e)),_("#w2ui-overlay").show()),_("#w2ui-overlay .w2ui-color").off(".w2color").on("mousedown.w2color",(function(t){var s=_(t.originalEvent.target).attr("name");i=_(t.originalEvent.target).attr("index").split(":"),"INPUT"===m.tagName.toUpperCase()?(e.fireChange&&_(m).change(),_(m).next().find(">div").css("background-color",s)):_(m).data("_color",s),"function"==typeof e.onSelect&&e.onSelect(s)})).on("mouseup.w2color",(function(){setTimeout((function(){0<_("#w2ui-overlay").length&&_("#w2ui-overlay").removeData("keepOpen")[0].hide()}),10)})),_("#w2ui-overlay .color-original").off(".w2color").on("click.w2color",(function(e){var t=w2utils.parseColor(_(e.target).css("background-color"));null!=t&&(a=t,l=w2utils.rgb2hsv(a),r(l),o(),d())})),_("#w2ui-overlay input").off(".w2color").on("mousedown.w2color",(function(e){_("#w2ui-overlay").data("keepOpen",!0),setTimeout((function(){_("#w2ui-overlay").data("keepOpen",!0)}),10),e.stopPropagation()})).on("change.w2color",(function(){var e=_(this),t=parseFloat(e.val()),i=parseFloat(e.attr("max"));isNaN(t)&&(t=0),1<i&&(t=parseInt(t)),0<i&&i<t&&(e.val(i),t=i),t<0&&(e.val(0),t=0);var s=e.attr("name"),n={};-1!==["r","g","b","a"].indexOf(s)?(a[s]=t,l=w2utils.rgb2hsv(a)):-1!==["h","s","v"].indexOf(s)&&(n[s]=t),r(n),o(),d()})),null==(a=w2utils.parseColor(e.color))&&(a={r:140,g:150,b:160,a:1},l=w2utils.rgb2hsv(a)),l=w2utils.rgb2hsv(a),r=function(t,i){null!=t.h&&(l.h=t.h),null!=t.s&&(l.s=t.s),null!=t.v&&(l.v=t.v),null!=t.a&&(a.a=t.a,l.a=t.a);var s="rgba("+(a=w2utils.hsv2rgb(l)).r+","+a.g+","+a.b+","+a.a+")",n=[Number(a.r).toString(16).toUpperCase(),Number(a.g).toString(16).toUpperCase(),Number(a.b).toString(16).toUpperCase(),Math.round(255*Number(a.a)).toString(16).toUpperCase()];
1n.forEach((function(e,t){1===e.length&&(n[t]="0"+e)})),s=n[0]+n[1]+n[2]+n[3],1===a.a&&(s=n[0]+n[1]+n[2]),_("#w2ui-overlay .color-preview").css("background-color","#"+s),_("#w2ui-overlay input").each((function(e,t){t.name&&(null!=a[t.name]&&(t.value=a[t.name]),null!=l[t.name]&&(t.value=l[t.name]),"a"===t.name&&(t.value=a.a))})),i?_("#w2ui-overlay .color-original").css("background-color","#"+s):("INPUT"===m.tagName.toUpperCase()?(_(m).val(s).data("skipInit",!0),e.fireChange&&_(m).change(),_(m).next().find(">div").css("background-color","#"+s)):_(m).data("_color",s),"function"==typeof e.onSelect&&e.onSelect(s))},o=function(){var e=_("#w2ui-overlay .palette .value1"),t=_("#w2ui-overlay .rainbow .value2"),i=_("#w2ui-overlay .alpha .value2"),s=parseInt(e.width())/2,n=parseInt(t.width())/2;e.css({left:150*l.s/100-s,top:125*(100-l.v)/100-s}),t.css("left",l.h/2.4-n),i.css("left",150*a.a-n)},d=function(){var e=w2utils.hsv2rgb(l.h,100,100),t=e.r+","+e.g+","+e.b;_("#w2ui-overlay .palette").css("background-image","linear-gradient(90deg, rgba("+t+",0) 0%, rgba("+t+",1) 100%)")},u=function(e){var t=_(this).find(".value1, .value2"),i=parseInt(t.width())/2;t.hasClass("move-x")&&t.css({left:e.offsetX-i+"px"}),t.hasClass("move-y")&&t.css({top:e.offsetY-i+"px"}),n={$el:t,x:e.pageX,y:e.pageY,width:t.parent().width(),height:t.parent().height(),left:parseInt(t.css("left")),top:parseInt(t.css("top"))},h(e),_("body").off(".w2color").on(f,h).on(p,c)},c=function(e){_("body").off(".w2color")},h=function(e){var t=n.$el,i=e.pageX-n.x,s=e.pageY-n.y,l=n.left+i,a=n.top+s,o=parseInt(t.width())/2;l<-o&&(l=-o),a<-o&&(a=-o),l>n.width-o&&(l=n.width-o),a>n.height-o&&(a=n.height-o),t.hasClass("move-x")&&t.css({left:l+"px"}),t.hasClass("move-y")&&t.css({top:a+"px"});var u,c=t.parent().attr("name"),h=parseInt(t.css("left"))+o,p=parseInt(t.css("top"))+o;"palette"===c&&r({s:Math.round(h/n.width*100),v:Math.round(100-p/n.height*100)}),"rainbow"===c&&(u=Math.round(2.4*h),r({h:u}),d()),"alpha"===c&&r({a:parseFloat(Number(h/150).toFixed(2))})},!0!==_.fn._colorAdvanced&&!0!==e.advanced||(_("#w2ui-overlay .w2ui-color-tabs :nth-child(2)").click(),_("#w2ui-overlay").removeData("keepOpen")),r({},!0),d(),o(),p="mouseup.w2color",f="mousemove.w2color",w2utils.isIOS&&(p="touchend.w2color",f="touchmove.w2color "),_("#w2ui-overlay .palette").off(".w2color").on("mousedown.w2color",u),_("#w2ui-overlay .rainbow").off(".w2color").on("mousedown.w2color",u),_("#w2ui-overlay .alpha").off(".w2color").on("mousedown.w2color",u),m.nav=function(e){switch(e){case"up":i[0]--;break;case"down":i[0]++;break;case"right":i[1]++;break;case"left":i[1]--}return i[0]<0&&(i[0]=0),i[0]>s.length-2&&(i[0]=s.length-2),i[1]<0&&(i[1]=0),i[1]>s[0].length-1&&(i[1]=s[0].length-1),color=s[i[0]][i[1]],_(m).data("_color",color),color})},function($){var w2grid=function(e){this.name=null,this.box=null,this.columns=[],this.columnGroups=[],this.records=[],this.summary=[],this.searches=[],this.sortMap={},this.toolbar={},this.ranges=[],this.menu=[],this.searchData=[],this.sortData=[],this.total=0,this.recid=null,this.last={field:"",label:"",logic:"OR",search:"",searchIds:[],selection:{indexes:[],columns:{}},multi:!1,scrollTop:0,scrollLeft:0,colStart:0,colEnd:0,sortData:null,sortCount:0,xhr:null,loaded:!1,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),this.show=$.extend(!0,{},w2grid.prototype.show),this.postData=$.extend(!0,{},w2grid.prototype.postData),this.routeData=$.extend(!0,{},w2grid.prototype.routeData),this.httpHeaders=$.extend(!0,{},w2grid.prototype.httpHeaders),this.buttons=$.extend(!0,{},w2grid.prototype.buttons),this.operators=$.extend(!0,{},w2grid.prototype.operators),this.operatorsMap=$.extend(!0,{},w2grid.prototype.operatorsMap),this.stateColProps=$.extend(!0,{},w2grid.prototype.stateColProps),this.stateColDefaults=$.extend(!0,{},w2grid.prototype.stateColDefaults),$.extend(!0,this,e)};$.fn.w2grid=function(e){if($.isPlainObject(e)){if(!w2utils.checkName(e,"w2grid"))return;var t,i=e.columns,s=e.columnGroups,n=e.records,l=e.searches,a=e.searchData,r=e.sortData,o=new w2grid(e);if($.extend(o,{records:[],columns:[],searches:[],sortData:[],searchData:[],handlers:[]}),i)for(t=0;t<i.length;t++)o.columns[t]=$.extend(!0,{},i[t]);if(s)for(t=0;t<s.length;t++)o.columnGroups[t]=$.extend(!0,{},s[t]);if(l)for(t=0;t<l.length;t++)o.searches[t]=$.extend(!0,{},l[t]);if(a)for(t=0;t<a.length;t++)o.searchData[t]=$.extend(!0,{},a[t]);if(r)for(t=0;t<r.length;t++)o.sortData[t]=$.extend(!0,{},r[t]);if(n)for(var d=0;d<n.length;d++){if(null!=n[d][o.recid]&&(n[d].recid=n[d][o.recid]),null==n[d].recid)return void console.log("ERROR: Cannot add records without recid. (obj: "+o.name+")");o.records[d]=$.extend(!0,{},n[d])}for(var u=0;u<o.columns.length;u++){var c,h,p=o.columns[u],f=p.searchable;null!=f&&!1!==f&&null==o.getSearch(p.field)&&($.isPlainObject(f)?o.addSearch($.extend({field:p.field,label:p.text,type:"text"},f)):(c=p.searchable,!(h="")===p.searchable&&(c="text",h='size="20"'),o.addSearch({f
1ield:p.field,label:p.text,type:c,attr:h})))}return(w2ui[o.name]=o).initToolbar(),o.updateToolbar(),0!==$(this).length&&o.render($(this)[0]),o}var g=w2ui[$(this).attr("name")];return g?0<arguments.length?(g[e]&&g[e].apply(g,Array.prototype.slice.call(arguments,1)),this):g:null},w2grid.prototype={header:"",url:"",limit:100,offset:0,postData:{},routeData:{},httpHeaders:{},show:{header:!1,toolbar:!1,footer:!1,columnHeaders:!0,lineNumbers:!1,orderColumn:!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,searchHiddenMsg:!1,statusRange:!0,statusBuffered:!1,statusRecordID:!0,statusSelection:!0,statusResponse:!0,statusSort:!1,statusSearch:!1,recordTitles:!0,selectionBorder:!0,skipRecords:!0,saveRestoreState:!0},stateId:null,hasFocus:!1,autoLoad:!0,fixedBody:!0,recordHeight:24,lineNumberWidth:null,keyboard:!0,selectType:"row",multiSearch:!0,multiSelect:!0,multiSort:!0,reorderColumns:!1,reorderRows:!1,showExtraOnSearch:0,markSearch:!0,columnTooltip:"top|bottom",disableCVS:!1,textSearch:"begins",nestedFields:!0,vs_start:150,vs_extra:15,style:"",method:null,dataType:null,parser:null,stateColProps:{text:!1,field:!0,size:!0,min:!1,max:!1,gridMinWidth:!1,sizeCorrected:!1,sizeCalculated:!0,sizeOriginal:!0,sizeType:!0,hidden:!0,sortable:!1,searchable:!1,clipboardCopy:!1,resizable:!1,hideable:!1,attr:!1,style:!1,render:!1,title:!1,editable:!1,frozen:!0,info:!1},stateColDefaults:{text:"",field:"",size:null,min:20,max:null,gridMinWidth:null,sizeCorrected:null,sizeCalculated:null,sizeOriginal:null,sizeType:null,hidden:!1,sortable:!1,searchable:!1,clipboardCopy:!1,resizable:!0,hideable:!0,attr:"",style:"",render:null,title:null,editable:{},frozen:!1,info:null},msgDelete:"Are you sure you want to delete NN records?",msgDeleteBtn:"Delete",msgNotJSON:"Returned data is not in valid JSON format.",msgAJAXerror:"AJAX error. See console for more details.",msgRefresh:"Refreshing...",msgNeedReload:"Your remote data source record count has changed, reloading from the first record.",msgEmpty:"",buttons:{reload:{type:"button",id:"w2ui-reload",icon:"w2ui-icon-reload",tooltip:"Reload data in the list"},columns:{type:"drop",id:"w2ui-column-on-off",icon:"w2ui-icon-columns",tooltip:"Show/hide columns",arrow:!1,html:""},search:{type:"html",id:"w2ui-search",html:"<div class=\"w2ui-icon icon-search-down w2ui-search-down\" onclick=\"var grid = w2ui[jQuery(this).parents('div.w2ui-grid').attr('name')]; grid.searchShowFields()\"></div>"},"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:["=","between",">","<",">=","<="],date:["is","between",{oper:"less",text:"before"},{oper:"more",text:"after"}],list:["is"],hex:["is","between"],color:["is","begins","contains","ends"],enum:["in","not in"]},operatorsMap:{text:"text",int:"number",float:"number",money:"number",currency:"number",percent:"number",hex:"hex",alphanumeric:"text",color:"color",date:"date",time:"date",datetime:"date",list:"list",combo:"text",enum:"enum",file:"enum",select:"list",radio:"list",checkbox:"list",toggle:"list"},onAdd:null,onEdit:null,onRequest:null,onLoad:null,onDelete:null,onSave:null,onSelect:null,onUnselect:null,onClick:null,onDblClick:null,onContextMenu:null,onMenuClick:null,onColumnClick:null,onColumnDblClick:null,onColumnResize:null,onColumnAutoResize:null,onSort:null,onSearch:null,onSearchOpen:null,onChange:null,onRestore:null,onExpand:null,onCollapse:null,onError:null,onKeydown:null,onToolbar:null,onColumnOnOff:null,onCopy:null,onPaste:null,onSelectionExtend:null,onEditField:null,onRender:null,onRefresh:null,onReload:null,onResize:null,onDestroy:null,onStateSave:null,onStateRestore:null,onFocus:null,onBlur:null,onReorderRow:null,add:function(e,t){$.isArray(e)||(e=[e]);for(var i=0,s=0;s<e.length;s++){var n=e[s];null!=n[this.recid]&&(n.recid=n[this.recid]),null!=n.recid?(n.w2ui&&!0===n.w2ui.summary?t?this.summary.unshift(n):this.summary.push(n):t?this.records.unshift(n):this.records.push(n),i++):console.log("ERROR: Cannot add record without recid. (obj: "+this.name+")")}return("object"!=typeof this.url?this.url:this.url.get)?this.refresh():(this.total=this.records.length,this.localSort(!1,!0),this.localSearch(),this.refreshBody(),this.resizeRecords()),i},find:function(e,t){null==e&&(e={});var i=[],s=!1;for(var n in e)-1!=String(n).indexOf(".")&&(s=!0);for(var l=0;l<this.records.length;l++){var a=!0;for(var n in e){var r=this.records[l][n];s&&-1!=String(n).indexOf(".")&&(r=this.parseField(this.records[l],n)),"not-null"==e[n]?null!=r&&""!==r||(a=!1):e[n]!=r&&(a=!1)}a&&!0!==t&&i.push(this.records[l].recid),a&&!0===t&&i.push(l)}return i},set:function(e,t,i){if("object"==typeof e&&null!==e&&(i=t,t=e,e=null),null==e){for(var s=0;s<this.records.length;s++)$.extend(!0,this.records[s],t);!0!==i&&this.refresh()}else{var n=this.get(e,!0);if(null==n)return!1;this.records[n]&&this.records[n].recid==e?$.extend(!0,this.records[n],t):$.extend(!0,this.summary[n],t),!0!==i&&this.refreshRow(e,n)}return!0},get:function(e,t){if($.isArray(e)){for(var i=[],s=0;s<e.length;s++){var n=this.get(e[s],t);null!==n&&i.push(n)}return i}var l=this.last.idCache;if(l||(this.last.idCache=l={}),"number"==typeof(s=l[e])){if(0<=s&&s<this.records.length&&this.records[s].recid==e)return!0===t?s:this.records[s];if(0<=(s=~s)&&s<this.summary.length&&this.summary[s].recid==e)return!0===t?s:this.summary[s];this.last.idCache=l={}}for(s=0;s<this.records.length;s++)if(this.records[s].recid==e)return l[e]=s,!0===t?s:this.records[s];for(s=0;s<this.summary.length;s++)if(this.summary[s].recid==e)return l[e]=~s,!0===t?s:this.summary[s];return null},getFirst:function(){if(0==this.records.length)return null;var e=this.records[0].recid,t=this.last.searchIds;return 0<this.searchData.length&&(e=Array.isArray(t)&&0<t.length?this.records[t[0]].recid:null),e},remove:function(){for(var e=0,t=0;t<arguments.length;t++){for(var i=this.records.length-1;0<=i;i--)this.records[i].recid==arguments[t]&&(this.records.splice(i,1),e++);for(i=this.summary.length-1;0<=i;i--)this.summary[i].recid==arguments[t]&&(this.summary.splice(i,1),e++)}return("object"!=typeof this.url?this.url:this.url.get)||(this.localSort(!1,!0),this.localSearch()),this.refresh(),e},addColumn:function(e,t){var i=0;1==arguments.length?(t=e,e=this.columns.length):("string"==typeof e&&(e=this.getColumn(e,!0)),null==e&&(e=this.columns.length)),$.isArray(t)||(t=[t]);for(var s,n,l=0;l<t.length;l++)this.columns.splice(e,0,t[l]),t[l].searchable&&(s=t[l].searchable,!(n="")===t[l].searchable&&(s="text",n='size="20"'),this.addSearch({f
1ield:t[l].field,label:t[l].label,type:s,attr:n})),e++,i++;return this.refresh(),i},removeColumn:function(){for(var e=0,t=0;t<arguments.length;t++)for(var i=this.columns.length-1;0<=i;i--)this.columns[i].field==arguments[t]&&(this.columns[i].searchable&&this.removeSearch(arguments[t]),this.columns.splice(i,1),e++);return this.refresh(),e},getColumn:function(e,t){if(0===arguments.length){for(var i=[],s=0;s<this.columns.length;s++)i.push(this.columns[s].field);return i}for(s=0;s<this.columns.length;s++)if(this.columns[s].field==e)return!0===t?s:this.columns[s];return null},updateColumn:function(e,t){var i=this,s=0;return(e=Array.isArray(e)?e:[e]).forEach((function(e){i.columns.forEach((function(i){var n;i.field==e&&(n=$.extend(!0,{},t),Object.keys(n).forEach((function(e){"function"==typeof n[e]&&(n[e]=n[e](i)),i[e]!=n[e]&&s++})),$.extend(!0,i,n))}))})),0<s&&this.refresh(),s},toggleColumn:function(){return this.updateColumn(Array.from(arguments),{hidden:function(e){return!e.hidden}})},showColumn:function(){return this.updateColumn(Array.from(arguments),{hidden:!1})},hideColumn:function(){return this.updateColumn(Array.from(arguments),{hidden:!0})},addSearch:function(e,t){var i=0;1==arguments.length?(t=e,e=this.searches.length):("string"==typeof e&&(e=this.getSearch(e,!0)),null==e&&(e=this.searches.length)),$.isArray(t)||(t=[t]);for(var s=0;s<t.length;s++)this.searches.splice(e,0,t[s]),e++,i++;return this.searchClose(),i},removeSearch:function(){for(var e=0,t=0;t<arguments.length;t++)for(var i=this.searches.length-1;0<=i;i--)this.searches[i].field==arguments[t]&&(this.searches.splice(i,1),e++);return this.searchClose(),e},getSearch:function(e,t){if(0===arguments.length){for(var i=[],s=0;s<this.searches.length;s++)i.push(this.searches[s].field);return i}for(s=0;s<this.searches.length;s++)if(this.searches[s].field==e)return!0===t?s:this.searches[s];return null},toggleSearch:function(){for(var e=0,t=0;t<arguments.length;t++)for(var i=this.searches.length-1;0<=i;i--)this.searches[i].field==arguments[t]&&(this.searches[i].hidden=!this.searches[i].hidden,e++);return this.searchClose(),e},showSearch:function(){for(var e=0,t=0;t<arguments.length;t++)for(var i=this.searches.length-1;0<=i;i--)this.searches[i].field==arguments[t]&&!1!==this.searches[i].hidden&&(this.searches[i].hidden=!1,e++);return this.searchClose(),e},hideSearch:function(){for(var e=0,t=0;t<arguments.length;t++)for(var i=this.searches.length-1;0<=i;i--)this.searches[i].field==arguments[t]&&!0!==this.searches[i].hidden&&(this.searches[i].hidden=!0,e++);return this.searchClose(),e},getSearchData:function(e){for(var t=0;t<this.searchData.length;t++)if(this.searchData[t].field==e)return this.searchData[t];return null},localSort:function(e,t){if("object"!=typeof this.url?this.url:this.url.get)console.log("ERROR: grid.localSort can only be used on local data source, grid.url should be empty.");else if(!$.isEmptyObject(this.sortData)){var i=(new Date).getTime(),s=this;s.selectionSave(),s.prepareData(),t||s.reset();for(var n=0;n<this.sortData.length;n++){var l=this.getColumn(this.sortData[n].field);if(!l)return;"string"==typeof l.render&&(-1!=["date","age"].indexOf(l.render.split(":")[0])&&(this.sortData[n].field_=l.field+"_"),-1!=["time"].indexOf(l.render.split(":")[0])&&(this.sortData[n].field_=l.field+"_"))}return function(){for(var e=0;e<s.records.length;e++){var t=s.records[e];t.w2ui&&null!=t.w2ui.parent_recid&&(t.w2ui._path=a(t))}}(),this.records.sort((function(e,t){if(!(e.w2ui&&null!=e.w2ui.parent_recid||t.w2ui&&null!=t.w2ui.parent_recid))return r(e,t);for(var i=a(e),s=a(t),n=0;n<Math.min(i.length,s.length);n++){var l=r(i[n],s[n]);if(0!==l)return l}return i.length>s.length?1:i.length<s.length?-1:(console.log("ERROR: two paths should not be equal."),0)})),function(){for(var e=0;e<s.records.length;e++){var t=s.records[e];t.w2ui&&null!=t.w2ui.parent_recid&&(t.w2ui._path=null)}}(),s.selectionRestore(t),i=(new Date).getTime()-i,!0!==e&&s.show.statusSort&&setTimeout((function(){s.status(w2utils.lang("Sorting took")+" "+i/1e3+" "+w2utils.lang("sec"))}),10),i}function a(e){if(!e.w2ui||null==e.w2ui.parent_recid)return[e];if(e.w2ui._path)return e.w2ui._path;var t=s.get(e.w2ui.parent_recid);return t?a(t).concat(e):(console.log("ERROR: no parent record: "+e.w2ui.parent_recid),[e])}function r(e,t){if(e===t)return 0;for(var i=0;i<s.sortData.length;i++){var n=s.sortData[i].field,l=s.sortData[i].field_?s.sortData[i].field_:n,a=e[l],r=t[l];-1!=String(n).indexOf(".")&&(a=s.parseField(e,l),r=s.parseField(t,l));var d,u=s.getColumn(n);if(u&&null!=u.editable&&($.isPlainObject(a)&&a.text&&(a=a.text),$.isPlainObject(r)&&r.text&&(r=r.text)),0!==(d=o(a,r,0,s.sortData[i].direction,u.sortMode||"default")))return d}return o(e.recid,t.recid,0,"asc")}function o(e,t,i,s,n){if(e===t)return 0;if((null==e||""===e)&&null!=t&&""!==t)return 1;if(null!=e&&""!==e&&(null==t||""===t))return-1;var l="asc"===s.toLowerCase()?1:-1;if(typeof e!=typeof t)return typeof t<typeof e?l:-l;if(e.constructor.name!=t.constructor.name)return e.constructor.name>t.constructor.name?l:-l;e&&"object"==typeof e&&(e=e.valueOf()),t&&"object"==typeof t&&(t=t.valueOf());var a={}.toString;return e&&"object"==typeof e&&e.toString!=a&&(e=String(e)),t&&"object"==typeof t&&t.toString!=a&&(t=String(t)),"string"==typeof e&&(e=$.trim(e.toLowerCase())),"string"==typeof t&&(t=$.trim(t.toLowerCase())),"natural"===n&&(n=w2utils.naturalCompare),"function"==typeof n?n(e,t)*l:t<e?l:e<t?-l:0}},localSearch:function(e){var t="object"!=typeof this.url?this.url:this.url.get;if(!t){var i=(new Date).getTime(),s=this,n={}.toString,l={};if(this.total=this.records.length,this.last.searchIds=[],this.prepareData(),0<this.searchData.length&&!t){for(var a=this.total=0;a<this.records.length;a++){var r=this.records[a];if(function e(t){for(var i=0,l=!1,a=0;a<s.searchData.length;
1a++){var r=s.searchData[a],o=s.getSearch(r.field);if(null!=r){null==o&&(o={field:r.field,type:r.type});var d,u,c=s.parseField(t,o.field),h=null==c||"object"==typeof c&&c.toString==n?"":String(c).toLowerCase();switch(null!=r.value&&($.isArray(r.value)?(u=r.value[0],d=r.value[1]):u=String(r.value).toLowerCase()),r.operator){case"=":case"is":s.parseField(t,o.field)==r.value?i++:"date"==o.type?(p=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),(h=w2utils.formatDate(p,"yyyy-mm-dd"))==(u=w2utils.formatDate(w2utils.isDate(u,w2utils.settings.dateFormat,!0),"yyyy-mm-dd"))&&i++):"time"==o.type?(p=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),(h=w2utils.formatTime(p,"hh24:mi"))==(u=w2utils.formatTime(u,"hh24:mi"))&&i++):"datetime"==o.type&&(p=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),(h=w2utils.formatDateTime(p,"yyyy-mm-dd|hh24:mm:ss"))==(u=w2utils.formatDateTime(w2utils.isDateTime(u,w2utils.settings.datetimeFormat,!0),"yyyy-mm-dd|hh24:mm:ss"))&&i++);break;case"between":-1!=["int","float","money","currency","percent"].indexOf(o.type)?parseFloat(s.parseField(t,o.field))>=parseFloat(u)&&parseFloat(s.parseField(t,o.field))<=parseFloat(d)&&i++:"date"==o.type?(p=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),h=w2utils.isDate(p,w2utils.settings.dateFormat,!0),u=w2utils.isDate(u,w2utils.settings.dateFormat,!0),null!=(d=w2utils.isDate(d,w2utils.settings.dateFormat,!0))&&(d=new Date(d.getTime()+864e5)),u<=h&&h<d&&i++):"time"==o.type?(h=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),u=w2utils.isTime(u,!0),d=w2utils.isTime(d,!0),u=(new Date).setHours(u.hours,u.minutes,u.seconds?u.seconds:0,0),d=(new Date).setHours(d.hours,d.minutes,d.seconds?d.seconds:0,0),u<=h&&h<d&&i++):"datetime"==o.type&&(h=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),u=w2utils.isDateTime(u,w2utils.settings.datetimeFormat,!0),d=(d=w2utils.isDateTime(d,w2utils.settings.datetimeFormat,!0))&&new Date(d.getTime()+864e5),u<=h&&h<d&&i++);break;case"<=":l=!0;case"<":case"less":-1!=["int","float","money","currency","percent"].indexOf(o.type)?((h=parseFloat(s.parseField(t,o.field)))<(u=parseFloat(r.value))||l&&h===u)&&i++:"date"==o.type?(p=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),((h=w2utils.isDate(p,w2utils.settings.dateFormat,!0))<(u=w2utils.isDate(u,w2utils.settings.dateFormat,!0))||l&&h===u)&&i++):"time"==o.type?(p=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),((h=w2utils.formatTime(p,"hh24:mi"))<(u=w2utils.formatTime(u,"hh24:mi"))||l&&h===u)&&i++):"datetime"==o.type&&(p=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),h=w2utils.formatDateTime(p,"yyyy-mm-dd|hh24:mm:ss"),u=w2utils.formatDateTime(w2utils.isDateTime(u,w2utils.settings.datetimeFormat,!0),"yyyy-mm-dd|hh24:mm:ss"),h.length==u.length&&(h<u||l&&h===u)&&i++);break;case">=":l=!0;case">":case"more":-1!=["int","float","money","currency","percent"].indexOf(o.type)?(h=parseFloat(s.parseField(t,o.field)),((u=parseFloat(r.value))<h||l&&h===u)&&i++):"date"==o.type?(p=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),h=w2utils.isDate(p,w2utils.settings.dateFormat,!0),((u=w2utils.isDate(u,w2utils.settings.dateFormat,!0))<h||l&&h===u)&&i++):"time"==o.type?(p=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),h=w2utils.formatTime(p,"hh24:mi"),((u=w2utils.formatTime(u,"hh24:mi"))<h||l&&h===u)&&i++):"datetime"==o.type&&(p=s.parseField(t,o.field+"_")instanceof Date?s.parseField(t,o.field+"_"):s.parseField(t,o.field),h=w2utils.formatDateTime(p,"yyyy-mm-dd|hh24:mm:ss"),u=w2utils.formatDateTime(w2utils.isDateTime(u,w2utils.settings.datetimeFormat,!0),"yyyy-mm-dd|hh24:mm:ss"),h.length==u.length&&(u<h||l&&h===u)&&i++);break;case"in":var p=r.value;r.svalue&&(p=r.svalue),-1===p.indexOf(w2utils.isFloat(c)?parseFloat(c):c)&&-1===p.indexOf(h)||i++;break;case"not in":p=r.value,r.svalue&&(p=r.svalue),-1===p.indexOf(w2utils.isFloat(c)?parseFloat(c):c)&&-1===p.indexOf(h)&&i++;break;case"begins":case"begins with":0===h.indexOf(u)&&i++;break;case"contains":0<=h.indexOf(u)&&i++;break;case"null":null==s.parseField(t,o.field)&&i++;break;case"not null":null!=s.parseField(t,o.field)&&i++;break;case"ends":case"ends with":var f=h.lastIndexOf(u);-1!==f&&f==h.length-u.length&&i++}}}if("OR"==s.last.logic&&0!==i||"AND"==s.last.logic&&i==s.searchData.length)return!0;
1if(t.w2ui&&t.w2ui.children&&!0!==t.w2ui.expanded)for(var g=0;g<t.w2ui.children.length;g++)if(e(t.w2ui.children[g]))return!0;return!1}(r))if(r&&r.w2ui&&function e(t){if(void 0!==t&&!l[t]){l[t]=!0;var i=s.get(t,!0);if(null!=i&&-1==$.inArray(i,s.last.searchIds)){var n=s.records[i];n&&n.w2ui&&e(n.w2ui.parent_recid),s.last.searchIds.push(i)}}}(r.w2ui.parent_recid),0<this.showExtraOnSearch){var o=this.showExtraOnSearch,d=this.showExtraOnSearch;if(a<o&&(o=a),a+d>this.records.length&&(d=this.records.length-a),0<o)for(var u=a-o;u<a;u++)this.last.searchIds.indexOf(u)<0&&this.last.searchIds.push(u);if(this.last.searchIds.indexOf(a)<0&&this.last.searchIds.push(a),0<d)for(u=a+1;u<=a+d;u++)this.last.searchIds.indexOf(u)<0&&this.last.searchIds.push(u)}else this.last.searchIds.push(a)}this.total=this.last.searchIds.length}return i=(new Date).getTime()-i,!0!==e&&s.show.statusSearch&&setTimeout((function(){s.status(w2utils.lang("Search took")+" "+i/1e3+" "+w2utils.lang("sec"))}),10),i}console.log("ERROR: grid.localSearch can only be used on local data source, grid.url should be empty.")},getRangeData:function(e,t){var i=this.get(e[0].recid,!0),s=this.get(e[1].recid,!0),n=e[0].column,l=e[1].column,a=[];if(n==l)for(var r=i;r<=s;r++){var o=(d=this.records[r])[this.columns[n].field]||null;!0!==t?a.push(o):a.push({data:o,column:n,index:r,record:d})}else if(i==s)for(var d=this.records[i],u=n;u<=l;u++)o=d[this.columns[u].field]||null,!0!==t?a.push(o):a.push({data:o,column:u,index:i,record:d});else for(r=i;r<=s;r++)for(d=this.records[r],a.push([]),u=n;u<=l;u++)o=d[this.columns[u].field],!0!==t?a[a.length-1].push(o):a[a.length-1].push({data:o,column:u,index:r,record:d});return a},addRange:function(e){var t=0;if("row"==this.selectType)return t;$.isArray(e)||(e=[e]);for(var i=0;i<e.length;i++){if("object"!=typeof e[i]&&(e[i]={name:"selection"}),"selection"==e[i].name){if(!1===this.show.selectionBorder)continue;var s=this.getSelection();if(0===s.length){this.removeRange("selection");continue}var n=s[0],l=s[s.length-1]}else n=e[i].range[0],l=e[i].range[1];if(n){for(var a={name:e[i].name,range:[{recid:n.recid,column:n.column},{recid:l.recid,column:l.column}],style:e[i].style||""},r=!1,o=0;o<this.ranges.length;o++)if(this.ranges[o].name==e[i].name){r=o;break}!1!==r?this.ranges[r]=a:this.ranges.push(a),t++}}return this.refreshRanges(),t},removeRange:function(){for(var e=0,t=0;t<arguments.length;t++){var i=arguments[t];$("#grid_"+this.name+"_"+i).remove(),$("#grid_"+this.name+"_f"+i).remove();for(var s=this.ranges.length-1;0<=s;s--)this.ranges[s].name==i&&(this.ranges.splice(s,1),e++)}return e},refreshRanges:function(){if(0!==this.ranges.length){for(var e=this,t=(new Date).getTime(),i=$("#grid_"+this.name+"_frecords"),s=$("#grid_"+this.name+"_records"),n=0;n<this.ranges.length;n++){var l=this.ranges[n],a=l.range[0],r=l.range[1];null==a.index&&(a.index=this.get(a.recid,!0)),null==r.index&&(r.index=this.get(r.recid,!0));var o=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(a.recid)+' td[col="'+a.column+'"]'),d=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid)+' td[col="'+r.column+'"]'),u=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(a.recid)+' td[col="'+a.column+'"]'),c=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(r.recid)+' td[col="'+r.column+'"]'),h=r.column;a.column<this.last.colStart&&r.column>this.last.colStart&&(o=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(a.recid)+' td[col="start"]')),a.column<this.last.colEnd&&r.column>this.last.colEnd&&(h='"end"',d=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid)+' td[col="end"]'));var p=parseInt($("#grid_"+this.name+"_rec_top").next().attr("index")),f=parseInt($("#grid_"+this.name+"_rec_bottom").prev().attr("index")),g=parseInt($("#grid_"+this.name+"_frec_top").next().attr("index")),m=parseInt($("#grid_"+this.name+"_frec_bottom").prev().attr("index"));0===o.length&&a.index<p&&r.index>p&&(o=$("#grid_"+this.name+"_rec_top").next().find("td[col="+a.column+"]")),0===d.length&&r.index>f&&a.index<f&&(d=$("#grid_"+this.name+"_rec_bottom").prev().find("td[col="+h+"]")),0===u.length&&a.index<g&&r.index>g&&(u=$("#grid_"+this.name+"_frec_top").next().find("td[col="+a.column+"]")),0===c.length&&r.index>
1m&&a.index<m&&(c=$("#grid_"+this.name+"_frec_bottom").prev().find("td[col="+r.column+"]"));var w,v,y,b=$(this.box).find("#grid_"+this.name+"_editable").find(".w2ui-input"),x=b.attr("recid"),_=b.attr("column");"selection"==l.name&&l.range[0].recid==x&&l.range[0].column==_||(w=$("#grid_"+this.name+"_f"+l.name),0<u.length||0<c.length?(0===w.length?(i.append('<div id="grid_'+this.name+"_f"+l.name+'" class="w2ui-selection" style="'+l.style+'">'+("selection"==l.name?'<div id="grid_'+this.name+'_resizer" class="w2ui-selection-resizer"></div>':"")+"</div>"),w=$("#grid_"+this.name+"_f"+l.name)):(w.attr("style",l.style),w.find(".w2ui-selection-resizer").show()),0===c.length&&(0===(c=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(r.recid)+" td:last-child")).length&&(c=$("#grid_"+this.name+"_frec_bottom td:first-child")),w.css("border-right","0px"),w.find(".w2ui-selection-resizer").hide()),null!=a.recid&&null!=r.recid&&0<u.length&&0<c.length?(v=+u.position().left+i.scrollLeft(),y=+u.position().top+i.scrollTop(),w.show().css({left:(0<v?v:0)+"px",top:(0<y?y:0)+"px",width:c.position().left-u.position().left+c.width()+2+"px",height:c.position().top-u.position().top+c.height()+1+"px"})):w.hide()):w.hide(),w=$("#grid_"+this.name+"_"+l.name),0<o.length||0<d.length?(0===w.length?(s.append('<div id="grid_'+this.name+"_"+l.name+'" class="w2ui-selection" style="'+l.style+'">'+("selection"==l.name?'<div id="grid_'+this.name+'_resizer" class="w2ui-selection-resizer"></div>':"")+"</div>"),w=$("#grid_"+this.name+"_"+l.name)):w.attr("style",l.style),0===o.length&&0===(o=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(a.recid)+" td:first-child")).length&&(o=$("#grid_"+this.name+"_rec_top td:first-child")),0!==c.length&&w.css("border-left","0px"),null!=a.recid&&null!=r.recid&&0<o.length&&0<d.length?(v=+o.position().left+s.scrollLeft(),y=+o.position().top+s.scrollTop(),w.show().css({left:(0<v?v:0)+"px",top:(0<y?y:0)+"px",width:d.position().left-o.position().left+d.width()+2+"px",height:d.position().top-o.position().top+d.height()+1+"px"})):w.hide()):w.hide())}$(this.box).find(".w2ui-selection-resizer").off("mousedown").on("mousedown",(function(t){var i=e.getSelection();e.last.move={type:"expand",x:t.screenX,y:t.screenY,divX:0,divY:0,recid:i[0].recid,column:i[0].column,originalRange:[{recid:i[0].recid,column:i[0].column},{recid:i[i.length-1].recid,column:i[i.length-1].column}],newRange:[{recid:i[0].recid,column:i[0].column},{recid:i[i.length-1].recid,column:i[i.length-1].column}]},$(document).off(".w2ui-"+e.name).on("mousemove.w2ui-"+e.name,C).on("mouseup.w2ui-"+e.name,T),t.preventDefault()})).off("dblclick").on("dblclick",(function(t){var i=e.trigger({phase:"before",type:"resizerDblClick",target:e.name,originalEvent:t});!0!==i.isCancelled&&e.trigger($.extend(i,{phase:"after"}))}));var k={phase:"before",type:"selectionExtend",target:e.name,originalRange:null,newRange:null};return(new Date).getTime()-t}function C(t){var i,s,n=e.last.move;if(n&&"expand"==n.type){n.divX=t.screenX-n.x,n.divY=t.screenY-n.y;var l=t.originalEvent.target;if("TD"!=l.tagName.toUpperCase()&&(l=$(l).parents("td")[0]),null!=$(l).attr("col")&&(s=parseInt($(l).attr("col"))),l=$(l).parents("tr")[0],i=$(l).attr("recid"),n.newRange[1].recid!=i||n.newRange[1].column!=s){var a=$.extend({},n.newRange);if(n.newRange=[{recid:n.recid,column:n.column},{recid:i,column:s}],!0===(k=e.trigger($.extend(k,{originalRange:n.originalRange,newRange:n.newRange}))).isCancelled)return n.newRange=a,void(k.newRange=a);e.removeRange("grid-selection-expand"),e.addRange({name:"grid-selection-expand",range:k.newRange,style:"background-color: rgba(100,100,100,0.1); border: 2px dotted rgba(100,100,100,0.5);"})}}}function T(t){e.removeRange("grid-selection-expand"),delete e.last.move,$(document).off(".w2ui-"+e.name),e.trigger($.extend(k,{phase:"after"}))}},select:function(){if(0===arguments.length)return 0;(new Date).getTime();var e=0,t=this.last.selection;this.multiSelect||this.selectNone();var i=Array.prototype.slice.call(arguments);Array.isArray(i[0])&&(i=i[0]);var s={phase:"before",type:"select",target:this.name};1==i.length?(s.multiple=!1,$.isPlainObject(i[0])?(s.recid=i[0].recid,s.column=i[0].column):s.recid=i[0]):(s.multiple=!0,s.recids=i);var n=this.trigger(s);if(!0===n.isCancelled)return 0;if("row"==this.selectType)for(var l=0;l<i.length;l++){var a="object"==typeof i[l]?i[l].recid:i[l];if(null!=(h=this.get(a,!0))){var r=null,o=null;if((0!==this.searchData.length||h+1>=this.last.range_start&&h+1<=this.last.range_end)&&(r=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(a)),o=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(a))),"row"==this.selectType){if(-1!=t.indexes.indexOf(h))continue;t.indexes.push(h),r&&o&&(r.addClass("w2ui-selected").data("selected","yes").find(".w2ui-col-number").addClass("w2ui-row-selected"),o.addClass("w2ui-selected").data("selected","yes").find(".w2ui-col-number").addClass("w2ui-row-selected"),r.find(".w2ui-grid-select-check").prop("checked",!0)),e++}}}else{var d={};for(l=0;l<i.length;l++){a="object"==typeof i[l]?i[l].recid:i[l];var u="object"==typeof i[l]?i[l].column:null;if(d[a]=d[a]||[],$.isArray(u))d[a]=u;else if(w2utils.isInt(u))d[a].push(u);else for(var c=0;c<this.columns.length;c++)this.columns[c].hidden||d[a].push(parseInt(c))}var h,p=[];for(var a in d)if(null!=(h=this.get(a,!0))){r=null,o=null,h+1>=this.last.range_start&&h+1<=this.last.range_end&&(r=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(a)),o=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(a)));var f=t.columns[h]||[];-1==t.indexes.indexOf(h)&&t.indexes.push(h);for(var g=0;g<d[a].length;g++)-1==f.indexOf(d[a][g])&&f.push(d[a][g]);for(f.sort((function(e,t){return e-t})),g=0;g<d[a].length;g++){var m=d[a][g];-1==p.indexOf(m)&&p.push(m),r&&(r.find("#grid_"+this.name+"_data_"+h+"_"+m).addClass("w2ui-selected"),r.find(".w2ui-col-number").addClass("w2ui-row-selected"),r.data("selected","yes"),r.find(".w2ui-grid-select-check").prop("checked",!0)),o&&(o.find("#grid_"+this.name+"_data_"+h+"_"+m).addClass("w2ui-selected"),o.find(".w2ui-col-number").addClass("w2ui-row-selected"),o.data("selected","yes"),o.find(".w2ui-grid-select-check").prop("checked",!0)),e++}t.columns[h]=f}for(var w=0;w<p.length;w++)$(this.box).find("#grid_"+this.name+"_column_"+p[w]+" .w2ui-col-header").addClass("w2ui-col-selected")}t.indexes.sort((function(e,t){return e-t}));var v=0<this.records.length&&t.indexes.length==this.records.length,y=0<t.indexes.length&&0!==this.searchData.length&&t.indexes.length==this.last.searchIds.length;return v||y?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.addRange("selection"),this.updateToolbar(t,v),this.trigger($.extend(n,{phase:"after"})),e},unselect:function(){var e=0,t=this.last.selection,i=Array.prototype.slice.call(arguments);Array.isArray(i[0])&&(i=i[0]);var s={phase:"before",type:"unselect",target:this.name};1==i.length?(s.multiple=!1,$.isPlainObject(i[0])?(s.recid=i[0].recid,s.column=i[0].column):s.recid=i[0]):(s.multiple=!0,s.recids=i);var n=this.trigger(s);if(!0===n.isCancelled)return 0;for(var l=0;l<i.length;l++){var a="object"==typeof i[l]?i[l].recid:i[l],r=this.get(a);if(null!=r){var o=this.get(r.recid,!0),d=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(a)),u=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(a));if("row"==this.selectType){if(-1==t.indexes.indexOf(o))continue;t.indexes.splice(t.indexes.indexOf(o),1),d.removeClass("w2ui-selected w2ui-inactive").removeData("selected").find(".w2ui-col-number").removeClass("w2ui-row-selected"),u.removeClass("w2ui-selected w2ui-inactive").removeData("selected").find(".w2ui-col-number").removeClass("w2ui-row-selected"),0!=d.length&&(d[0].style.cssText="height: "+this.recordHeight+"px; "+d.attr("custom_style"),u[0].style.cssText="height: "+this.recordHeight+"px; "+u.attr("custom_style")),d.find(".w2ui-grid-select-check").prop("checked",!1),e++}else{var c=i[l].column;if(!w2utils.isInt(c)){for(var h=[],p=0;p<this.columns.length;p++)this.columns[p].hidden||h.push({recid:a,column:p});return this.unselect(h)}var f=t.columns[o];if(!$.isArray(f)||-1==f.indexOf(c))continue;f.splice(f.indexOf(c),1),$("#grid_"+this.name+"_rec_"+w2utils.escapeId(a)).find(" > td[col="+c+"]").removeClass("w2ui-selected w2ui-inactive"),$("#grid_"+this.name+"_frec_"+w2utils.escapeId(a)).find(" > td[col="+c+"]").removeClass("w2ui-selected w2ui-inactive");var g=!1,m=!1;for(s=this.getSelection(),p=0;p<s.length;p++)s[p].column==c&&(g=!0),s[p].recid==a&&(m=!0);g||$(this.box).find(".w2ui-grid-columns td[col="+c+"] .w2ui-col-header, .w2ui-grid-fcolumns td[col="+c+"] .w2ui-col-header").removeClass("w2ui-col-selected"),m||$("#grid_"+this.name+"_frec_"+w2utils.escapeId(a)).find(".w2ui-col-number").removeClass("w2ui-row-selected"),e++,0===f.length&&(delete t.columns[o],t.indexes.splice(t.indexes.indexOf(o),1),d.removeData("selected"),d.find(".w2ui-grid-select-check").prop("checked",!1),u.removeData("selected"))}}}var w=0<this.records.length&&t.indexes.length==this.records.length,v=0<t.indexes.length&&0!==this.searchData.length&&t.indexes.length==this.last.searchIds.length;return w||v?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.addRange("selection"),this.updateToolbar(t,w),this.trigger($.extend(n,{phase:"after"})),e},selectAll:function(){var e=(new Date).getTime();if(!1!==this.multiSelect){var t=this.trigger({phase:"before",type:"select",target:this.name,all:!0});if(!0!==t.isCancelled){for(var i="object"!=typeof this.url?this.url:this.url.get,s=this.last.selection,n=[],l=0;l<this.columns.length;l++)n.push(l);if(s.indexes=[],i||0===this.searchData.length){var a=this.records.length;for(0==this.searchData.length||i||(a=this.last.searchIds.length),l=0;l<a;l++)s.indexes.push(l),"row"!=this.selectType&&(s.columns[l]=n.slice())}else for(l=0;l<this.last.searchIds.length;l++)s.indexes.push(this.last.searchIds[l]),"row"!=this.selectType&&(s.columns[this.last.searchIds[l]]=n.slice());return"row"==this.selectType?($(this.box).find(".w2ui-grid-records tr").not(".w2ui-empty-record").addClass("w2ui-selected").data("selected","yes").find(".w2ui-col-number").addClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-frecords tr").not(".w2ui-empty-record").addClass("w2ui-selected").data("selected","yes").find(".w2ui-col-number").addClass("w2ui-row-selected")):($(this.box).find(".w2ui-grid-columns td .w2ui-col-header, .w2ui-grid-fcolumns td .w2ui-col-header").addClass("w2ui-col-selected"),$(this.box).find(".w2ui-grid-records tr .w2ui-col-number").addClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-records tr").not(".w2ui-empty-record").find(".w2ui-grid-data").not(".w2ui-col-select").addClass("w2ui-selected").data("selected","yes"),$(this.box).find(".w2ui-grid-frecords tr .w2ui-col-number").addClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-frecords tr").not(".w2ui-empty-record").find(".w2ui-grid-data").not(".w2ui-col-select").addClass("w2ui-selected").data("selected","yes")),$(this.box).find("input.w2ui-grid-select-check").prop("checked",!0),1==(s=this.getSelection(!0)).length?this.toolbar.enable("w2ui-edit"):this.toolbar.disable("w2ui-edit"),1<=s.length?this.toolbar.enable("w2ui-delete"):this.toolbar.disable("w2ui-delete"),this.addRange("selection"),$("#grid_"+this.name+"_check_all").prop("checked",!0),this.status(),this.updateToolbar({indexes:s},!0),this.trigger($.extend(t,{phase:"after"})),(new Date).getTime()-e}}},selectNone:function(){var e=(new Date).getTime(),t=this.trigger({phase:"before",type:"unselect",target:this.name,all:!0});if(!0!==t.isCancelled){var i=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(".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),i.indexes=[],i.columns={}
1,this.toolbar.disable("w2ui-edit","w2ui-delete"),this.removeRange("selection"),$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.updateToolbar(i,!1),this.trigger($.extend(t,{phase:"after"})),(new Date).getTime()-e}},updateToolbar:function(e,t){var i=this,s=e&&e.indexes?e.indexes.length:0;function n(t,n){0===t.batch&&(0<s?i.toolbar.enable(n+t.id):i.toolbar.disable(n+t.id)),null!=t.batch&&!isNaN(t.batch)&&0<t.batch&&(s==t.batch?i.toolbar.enable(n+t.id):i.toolbar.disable(n+t.id)),"function"==typeof t.batch&&t.batch("cell"==i.selectType?e:e?e.indexes:null)}this.toolbar.items.forEach((function(e){n(e,""),Array.isArray(e.items)&&e.items.forEach((function(t){n(t,e.id+":")}))}))},getSelection:function(e){var t=[],i=this.last.selection;if("row"==this.selectType){for(var s=0;s<i.indexes.length;s++)this.records[i.indexes[s]]&&(!0===e?t.push(i.indexes[s]):t.push(this.records[i.indexes[s]].recid));return t}for(s=0;s<i.indexes.length;s++){var n=i.columns[i.indexes[s]];if(this.records[i.indexes[s]])for(var l=0;l<n.length;l++)t.push({recid:this.records[i.indexes[s]].recid,index:parseInt(i.indexes[s]),column:n[l]})}return t},search:function(e,t){for(var i="object"!=typeof this.url?this.url:this.url.get,s=[],n=this.last.multi,l=this.last.logic,a=this.last.field,r=this.last.search,o=!1,d=0;d<this.searches.length;d++)this.searches[d].hidden&&null!=this.searches[d].value&&(s.push({field:this.searches[d].field,operator:this.searches[d].operator||"is",type:this.searches[d].type,value:this.searches[d].value||""}),o=!0);if(0===arguments.length){for(r="",d=0;d<this.searches.length;d++){var u,c,h=this.searches[d],p=$("#grid_"+this.name+"_operator_"+d).val(),f=$("#grid_"+this.name+"_field_"+d),g=$("#grid_"+this.name+"_field2_"+d),m=f.val(),w=g.val(),v=null,y=null;if(-1!=["int","float","money","currency","percent"].indexOf(h.type)&&(u=f.data("w2field"),c=g.data("w2field"),u&&(m=u.clean(m)),c&&(w=c.clean(w))),-1!=["list","enum"].indexOf(h.type))if(m=f.data("selected")||{},$.isArray(m)){v=[];for(var b=0;b<m.length;b++)v.push(w2utils.isFloat(m[b].id)?parseFloat(m[b].id):String(m[b].id).toLowerCase()),delete m[b].hidden;$.isEmptyObject(m)&&(m="")}else y=m.text||"",m=m.id||"";if(""!==m&&null!=m||null!=w&&""!==w){var x={field:h.field,type:h.type,operator:p};"between"==p?$.extend(x,{value:[m,w]}):"in"==p&&"string"==typeof m||"not in"==p&&"string"==typeof m?$.extend(x,{value:m.split(",")}):$.extend(x,{value:m}),v&&$.extend(x,{svalue:v}),y&&$.extend(x,{text:y});try{"date"==h.type&&"between"==p&&(x.value[0]=m,x.value[1]=w),"date"==h.type&&"is"==p&&(x.value=m)}catch(e){}s.push(x),n=!0}}l="AND"}if("string"==typeof e&&(1==arguments.length&&(t=e,e="all"),a=e,n=!1,l=o?"AND":"OR",null!=(r=t)))if("all"==e.toLowerCase())if(0<this.searches.length){var _;for(d=0;d<this.searches.length;d++)if(("text"==(h=this.searches[d]).type||"alphanumeric"==h.type&&w2utils.isAlphaNumeric(t)||"int"==h.type&&w2utils.isInt(t)||"float"==h.type&&w2utils.isFloat(t)||"percent"==h.type&&w2utils.isFloat(t)||("hex"==h.type||"color"==h.type)&&w2utils.isHex(t)||"currency"==h.type&&w2utils.isMoney(t)||"money"==h.type&&w2utils.isMoney(t)||"date"==h.type&&w2utils.isDate(t)||"time"==h.type&&w2utils.isTime(t)||"datetime"==h.type&&w2utils.isDateTime(t)||"datetime"==h.type&&w2utils.isDate(t)||"enum"==h.type&&w2utils.isAlphaNumeric(t)||"list"==h.type&&w2utils.isAlphaNumeric(t))&&(x={field:h.field,type:h.type,operator:null!=h.operator?h.operator:"text"==h.type?this.textSearch:"is",value:t},""!=$.trim(t)&&s.push(x)),-1!=["int","float","money","currency","percent"].indexOf(h.type)&&2==$.trim(String(t)).split("-").length&&(_=$.trim(String(t)).split("-"),x={field:h.field,type:h.type,operator:null!=h.operator?h.operator:"between",value:[_[0],_[1]]},s.push(x)),-1!=["list","enum"].indexOf(h.type)){var k=[];for(null==h.options&&(h.options={}),Array.isArray(h.options.items)||(h.options.items=[]),b=0;b<h.options.items;b++){x=h.options.items[b];try{var C=new RegExp(t,"i");C.test(x)&&k.push(b),x.text&&C.test(x.text)&&k.push(x.id)}catch(e){}}0<k.length&&(x={field:h.field,type:h.type,operator:null!=h.operator?h.operator:"in",value:k},s.push(x))}}else for(d=0;d<this.columns.length;d++)x={field:this.columns[d].field,type:"text",operator:this.textSearch,value:t},s.push(x);else{var T=$("#grid_"+this.name+"_search_all");
1if(null==(h=this.getSearch(e))&&(h={field:e,type:"text"}),h.field==e&&(this.last.label=h.label),""!==t){var S=this.textSearch,D=t;if(-1!=["date","time","datetime"].indexOf(h.type)&&(S="is"),-1!=["list","enum"].indexOf(h.type)&&(S="is",D=(x=T.data("selected"))&&!$.isEmptyObject(x)?x.id:""),"int"==h.type&&""!==t&&(S="is",-1!=String(t).indexOf("-")&&2==(x=t.split("-")).length&&(S="between",D=[parseInt(x[0]),parseInt(x[1])]),-1!=String(t).indexOf(",")))for(x=t.split(","),S="in",D=[],d=0;d<x.length;d++)D.push(x[d]);null!=h.operator&&(S=h.operator),x={field:h.field,type:h.type,operator:S,value:D},s.push(x)}}if($.isArray(e)){var O="AND";for("string"==typeof t&&"OR"!=(O=t.toUpperCase())&&"AND"!=O&&(O="AND"),n=!(r=""),l=O,d=0;d<e.length;d++){var z=e[d];"number"==typeof z.value&&(z.operator="is"),"string"==typeof z.value&&(z.operator=this.textSearch),$.isArray(z.value)&&(z.operator="in"),s.push(z)}}var I=this.trigger({phase:"before",type:"search",target:this.name,multi:0===arguments.length,searchField:e||"multi",searchValue:e?t:"multi",searchData:s,searchLogic:l});!0!==I.isCancelled&&(this.searchData=I.searchData,this.last.field=a,this.last.search=r,this.last.multi=n,this.last.logic=I.searchLogic,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selection.indexes=[],this.last.selection.columns={},this.searchClose(),i?(this.last.xhr_offset=0,this.reload()):(this.localSearch(),this.refresh()),this.trigger($.extend(I,{phase:"after"})))},searchOpen:function(){var e,t,i,s;this.box&&0!==this.searches.length&&(t=(e=this).toolbar.get("w2ui-search-advanced"),i="#tb_"+e.toolbar.name+"_item_"+w2utils.escapeId(t.id)+" table.w2ui-button",!0!==(s=this.trigger({phase:"before",type:"searchOpen",target:this.name})).isCancelled?$("#tb_"+this.name+"_toolbar_item_w2ui-search-advanced").w2overlay({html:this.getSearchesHTML(),name:this.name+"-searchOverlay",left:-10,class:"w2ui-grid-searches",onShow:function(){e.initSearches(),$("#w2ui-overlay-"+e.name+"-searchOverlay .w2ui-grid-searches").data("grid-name",e.name);var n=$("#w2ui-overlay-"+this.name+"-searchOverlay .w2ui-grid-searches *[rel=search]");0<n.length&&n[0].focus(),t.checked||(t.checked=!0,$(i).addClass("checked")),e.trigger($.extend(s,{phase:"after"}))},onHide:function(){t.checked=!1,$(i).removeClass("checked")}}):setTimeout((function(){e.toolbar.uncheck("w2ui-search-advanced")}),1))},searchClose:function(){this.box&&0!==this.searches.length&&(this.toolbar&&this.toolbar.uncheck("w2ui-search-advanced","w2ui-column-on-off"),$().w2overlay({name:this.name+"-searchOverlay"}))},searchReset:function(e){for(var t=[],i=!1,s=0;s<this.searches.length;s++)this.searches[s].hidden&&null!=this.searches[s].value&&(t.push({field:this.searches[s].field,operator:this.searches[s].operator||"is",type:this.searches[s].type,value:this.searches[s].value||""}),i=!0);var n=this.trigger({phase:"before",type:"search",reset:!0,target:this.name,searchData:t});if(!0!==n.isCancelled){if(this.searchData=n.searchData,this.last.search="",this.last.logic=i?"AND":"OR",0<this.searches.length)if(this.multiSearch&&this.show.searchAll)this.last.field="all",this.last.label=w2utils.lang("All Fields");else{for(var l=0;l<this.searches.length&&(this.searches[l].hidden||!1===this.searches[l].simple);)l++;l>=this.searches.length?(this.last.field="",this.last.label=""):(this.last.field=this.searches[l].field,this.last.label=this.searches[l].label)}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"),e||this.reload(),this.trigger($.extend(n,{phase:"after"}))}},searchShowFields:function(e){var t=$("#grid_"+this.name+"_search_all");if(!0!==e){for(var i='<div class="w2ui-select-field"><table><tbody>',s=-1;s<this.searches.length;s++){var n=this.searches[s],l=n?n.field:null,a=this.getColumn(l),r=!1,o="This column is hidden";if(1==this.show.searchHiddenMsg&&-1!=s&&(null==a||!0===a.hidden&&!1!==a.hideable)&&(r=!0,null==a&&(o="This column does not exist")),-1==s){if(!this.multiSearch||!this.show.searchAll)continue;n={field:"all",label:w2utils.lang("All Fields")}}else{if(null!=a&&!1===a.hideable)continue;if(!0===this.searches[s].hidden||!1===this.searches[s].simple)continue}null==n.label&&null!=n.caption&&(console.log("NOTICE: grid search.caption property is deprecated, please use search.label. Search ->",n),n.label=n.caption),i+='<tr style="'+(r?"color: silver":"")+'" '+(r?"onmouseenter=\"jQuery(this).w2tag({ top: 4, html: '"+o+'\' })" onmouseleave="jQuery(this).w2tag()"':"")+(w2utils.isIOS?"onTouchStart":"onClick")+"=\"event.stopPropagation(); w2ui['"+this.name+"'].initAllField('"+n.field+"'); jQuery('#grid_"+this.name+"_search_all').w2overlay({ name: '"+this.name+"-searchFields' });\" jQuery(this).addClass('w2ui-selected'); onmousedown=\"jQuery(this).parent().find('tr').removeClass('w2ui-selected'); jQuery(this).addClass('w2ui-selected')\" onmouseup=\"jQuery(this).removeClass('w2ui-selected')\" > <td>
1 <span class=\"w2ui-column-check w2ui-icon-"+(n.field==this.last.field?"check":"empty")+'"></span> </td> <td>'+n.label+"</td></tr>"}i+="</tbody></table></div>";var d=this.name+"-searchFields";1==$("#w2ui-overlay-"+d).length&&(i=""),setTimeout((function(){$(t).w2overlay({html:i,name:d,left:-10})}),1)}else $(t).w2overlay({name:this.name+"-searchFields"})},initAllField:function(e,t){var i=$("#grid_"+this.name+"_search_all");if("all"==e){var s={field:"all",label:w2utils.lang("All Fields")};i.w2field("clear")}else{if(null==(s=this.getSearch(e)))return;var n=s.type;-1!=["enum","select"].indexOf(n)&&(n="list"),i.w2field(n,$.extend({},s.options,{suffix:"",autoFormat:!1,selected:t})),-1!=["list","enum","date","time","datetime"].indexOf(s.type)&&(this.last.search="",this.last.item="",i.val(""),$("#grid_"+this.name+"_searchClear").hide())}""!=this.last.search?(this.last.label=s.label,this.search(s.field,this.last.search)):(this.last.field=s.field,this.last.label=s.label),i.attr("placeholder",w2utils.lang(s.label||s.caption||s.field)),$().w2overlay({name:this.name+"-searchFields"})},clear:function(e){this.total=0,this.records=[],this.summary=[],this.last.xhr_offset=0,this.last.idCache={},this.reset(!0),e||this.refresh()},reset:function(e){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),e||this.refresh()},skip:function(e,t){("object"!=typeof this.url?this.url:this.url.get)?(this.offset=parseInt(e),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(t)):console.log("ERROR: grid.skip() can only be called when you have remote data source.")},load:function(e,t){null!=e?(this.clear(!0),this.request("get",{},e,t)):console.log('ERROR: You need to provide url argument when calling .load() method of "'+this.name+'" object.')},reload:function(e){var t=this,i="object"!=typeof this.url?this.url:this.url.get;t.selectionSave(),i?this.load(i,(function(){t.selectionRestore(),"function"==typeof e&&e()})):(this.reset(!0),this.localSearch(),this.selectionRestore(),"function"==typeof e&&e({status:"success"}))},request:function(e,t,i,s){if(null==t&&(t={}),""!=i&&null!=i||(i=this.url),""!=i&&null!=i){w2utils.isInt(this.offset)||(this.offset=0),w2utils.isInt(this.last.xhr_offset)||(this.last.xhr_offset=0);var n={limit:this.limit,offset:parseInt(this.offset)+parseInt(this.last.xhr_offset),searchLogic:this.last.logic,search:this.searchData.map(function(e){var t=$.extend({},e);return this.searchMap&&this.searchMap[t.field]&&(t.field=this.searchMap[t.field]),t}.bind(this)),sort:this.sortData.map(function(e){var t=$.extend({},e);return this.sortMap&&this.sortMap[t.field]&&(t.field=this.sortMap[t.field]),t}.bind(this))};if(0===this.searchData.length&&(delete n.search,delete n.searchLogic),0===this.sortData.length&&delete n.sort,$.extend(n,this.postData),$.extend(n,t),"delete"!=e&&"save"!=e||(delete n.limit,delete n.offset,"delete"==(n.action=e)&&(n[this.recid||"recid"]=this.getSelection())),"get"==e){if(!0===(l=this.trigger({phase:"before",type:"request",target:this.name,url:i,postData:n,httpHeaders:this.httpHeaders})).isCancelled)return void("function"==typeof s&&s({status:"error",message:"Request aborted."}))}else var l={url:i,postData:n,httpHeaders:this.httpHeaders};var a=this;if(0===this.last.xhr_offset&&this.lock(w2utils.lang(this.msgRefresh),!0),this.last.xhr)try{this.last.xhr.abort()}catch(t){}if(i="object"!=typeof l.url?l.url:l.url.get,"save"==e&&"object"==typeof l.url&&(i=l.url.save),"delete"==e&&"object"==typeof l.url&&(i=l.url.remove),!$.isEmptyObject(a.routeData)){var r=w2utils.parseRoute(i);if(0<r.keys.length)for(var o=0;o<r.keys.length;o++)null!=a.routeData[r.keys[o].name]&&(i=i.replace(new RegExp(":"+r.keys[o].name,"g"),a.routeData[r.keys[o].name]))}var d={type:"GET",url:i,data:l.postData,headers:l.httpHeaders,dataType:"json"};switch(this.dataType||w2utils.settings.dataType){case"HTTP":d.data="object"==typeof d.data?String($.param(d.data,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]"):d.data;break;case"HTTPJSON":d.data={request:JSON.stringify(d.data)};break;case"RESTFULL":d.type="GET","save"==e&&(d.type="PUT"),"delete"==e&&(d.type="DELETE"),d.data="object"==typeof d.data?String($.param(d.data,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]"):d.data;break;case"RESTFULLJSON":d.type="GET","save"==e&&(d.type="PUT"),"delete"==e&&(d.type="DELETE"),d.data=JSON.stringify(d.data),d.contentType="application/json";break;case"JSON":d.type="POST",d.data=JSON.stringify(d.data),d.contentType="application/json"}this.method&&(d.type=this.method),this.last.xhr_cmd=e,this.last.xhr_start=(new Date).getTime(),this.last.loaded=!1,this.last.xhr=$.ajax(d).done((function(t,i,n){a.requestComplete(i,n,e,s)})).fail((function(t,i,n){var l,r={status:i,error:n,rawResponseText:t.responseText},o=a.trigger({phase:"before",type:"error",error:r,xhr:t});if(!0!==o.isCancelled){if("abort"!=i){try{l="object"==typeof t.responseJSON?t.responseJSON:$.parseJSON(t.responseText)}catch(t){}console.log("ERROR: Server communication failed.","\n EXPECTED:",{status:"success",total:5,records:[{recid:1,field:"value"}]},"\n OR:",{status:"error",message:"error message"},"\n RECEIVED:","object"==typeof l?l:t.responseText),a.requestComplete("error",t,e,s)}a.trigger($.extend(o,{phase:"after"}))}})),"get"==e&&this.trigger($.extend(l,{phase:"after"}))}},requestComplete:function(e,t,i,s){var n=this;this.unlock(),setTimeout((function(){n.show.statusResponse&&n.status(w2utils.lang("Server Response")+" "+((new Date).getTime()-n.last.xhr_start)/1e3+" "+w2utils.lang("sec"))}),10),this.last.pull_more=!1,this.last.pull_refresh=!0;var l="load";"save"==this.last.xhr_cmd&&(l="save"),"delete"==this.last.xhr_cmd&&(l="delete");var a,r=this.trigger({phase:"before",target:this.name,type:l,xhr:t,status:e});if(!0!==r.isCancelled){if("error"!=e)if("function"==typeof n.parser?"object"!=typeof(a=n.parser(t.responseJSON))&&console.log("ERROR: Your parser did not return proper object"):null==(a=t.responseJSON)?a={status:"error",message:w2utils.lang(this.msgNotJSON),responseText:t.responseText}:Array.isArray(a)&&(a={status:"success",records:a,total:a.length}),Array.isArray(a.records)&&a.records.forEach((function(e,t){n.recid&&(e.recid=n.parseField(e,n.recid)),null==e.recid&&(e.recid="recid-"+t)})),"error"==a.status)n.error(a.message);else{if("get"==i){if(null==a.total&&(a.total=-1),null==a.records&&(a.records=[]),a.records.length==this.limit?this.last.xhr_hasMore=!0:(this.last.xhr_hasMore=!1,this.total=this.offset+this.last.xhr_offset+a.records.length),0===this.last.xhr_offset)this.records=[],this.summary=[],w2utils.isInt(a.total)&&(this.total=parseInt(a.total));else if(-1!=a.total&&parseInt(a.total)!=parseInt(this.total))return void this.message(w2utils.lang(this.msgNeedReload),function(){delete this.last.xhr_offset,this.reload()}.bind(this));if(a.records)for(var o=0;o<a.records.length;o++)this.records.push(a.records[o]);if(a.summary)for(this.summary=[],o=0;o<a.summary.length;o++)this.summary.push(a.summary[o])}if("delete"==i)return this.reset(),void this.reload()}else a={status:"error",message:w2utils.lang(this.msgAJAXerror),responseText:t.responseText},n.error(w2utils.lang(this.msgAJAXerror));("object"!=typeof this.url?this.url:this.url.get)||(this.localSort(),this.localSearch()),this.total=parseInt(this.total),0===this.last.xhr_offset?this.refresh():(this.scroll(),this.resize()),"function"==typeof s&&s(a),this.trigger($.extend(r,{phase:"after"})),this.last.loaded=!0}else"function"==typeof s&&s({status:"error",message:"Request aborted."})},error:function(e){var t=this.trigger({target:this.name,type:"error",message:e,xhr:this.last.xhr});!0!==t.isCancelled?(this.message(e),this.trigger($.extend(t,{phase:"after"}))):"function"==typeof callBack&&callBack({status:"error",message:"Request aborted."})},getChanges:function(e){var t=[];void 0===e&&(e=this.records);for(var i=0;i<e.length;i++){var s,n=e[i];n.w2ui&&(null!=n.w2ui.changes&&((s={})[this.recid||"recid"]=n.recid,t.push($.extend(!0,s,n.w2ui.changes))),!0!==n.w2ui.expanded&&n.w2ui.children&&n.w2ui.children.length&&$.merge(t,this.getChanges(n.w2ui.children)))}return t},mergeChanges:function(){for(var changes=this.getChanges(),c=0;c<changes.length;c++){var record=this.get(changes[c].recid);for(var s in changes[c])if("recid"!=s){"object"==typeof changes[c][s]&&(changes[c][s]=changes[c][s].text);try{-1!=s.indexOf(".")?eval("record['"+s.replace(/\./g,"']['")+"'] = changes[c][s]"):record[s]=changes[c][s]}catch(e){console.log("ERROR: Cannot merge. ",e.message||"",e)}record.w2ui&&delete record.w2ui.changes}}this.refresh()},save:function(e){var t=this,i=this.getChanges(),s="object"!=typeof this.url?this.url:this.url.save,n=this.trigger({phase:"before",target:this.name,type:"save",changes:i});!0!==n.isCancelled?s?this.request("save",{changes:n.changes},null,(function(i){"error"!==i.status&&t.mergeChanges(),t.trigger($.extend(n,{phase:"after"})),"function"==typeof e&&e(i)})):(this.mergeChanges(),this.trigger($.extend(n,{phase:"after"}))):s&&"function"==typeof e&&e({status:"error",message:"Request aborted."})},editField:function(e,t,i,s){var n,l,a=this;if(!0!==this.last.inEditMode){var r=a.get(e,!0),o=a.getCellEditable(r,t);if(o){var d=a.records[r],u=a.columns[t],c=!0===u.frozen?"_f":"_";if(-1==["enum","file"].indexOf(o.type)){var h=a.trigger({phase:"before",type:"editField",target:a.name,recid:e,column:t,value:i,index:r,originalEvent:s});if(!0!==h.isCancelled&&(i=h.value,this.last.inEditMode=!0,this.last._edit={value:i,index:r,column:t,recid:e},this.selectNone(),this.select({recid:e,column:t}),-1==["checkbox","check"].indexOf(o.type))){var p=$("#grid_"+a.name+c+"rec_"+w2utils.escapeId(e)),f=p.find("[col="+t+"] > div");$(this.box).find("div.w2ui-edit-box").remove(),"row"!=this.selectType&&($("#grid_"+this.name+c+"selection").attr("id","grid_"+this.name+"_editable").removeClass("w2ui-selection").addClass("w2ui-edit-box").prepend('<div style="position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px;"></div>').find(".w2ui-selection-resizer").remove(),f=$("#grid_"+this.name+"_editable >div:first-child")),null==o.inTag&&(o.inTag=""),null==o.outTag&&(o.outTag=""),null==o.style&&(o.style=""),null==o.items&&(o.items=[]);var g=d.w2ui&&d.w2ui.changes&&null!=d.w2ui.changes[u.field]?w2utils.stripTags(d.w2ui.changes[u.field]):w2utils.stripTags(d[u.field]);null==g&&(g="");var m="object"!=typeof g?g:"";null!=h.old_value&&(m=h.old_value),null!=i&&(g=i);var w=null!=u.style?u.style+";":"";switch("string"==typeof u.render&&-1!=["number","int","float","money","percent","size"].indexOf(u.render.split(":")[0])&&(w+="text-align: right;"),0<o.items.length&&!$.isPlainObject(o.items[0])&&(o.items=w2obj.field.prototype.normMenu(o.items)),o.type){case"select":for(var v="",y=0;y<o.items.length;y++)v+='<option value="'+o.items[y].id+'"'+(o.items[y].id==g?' selected="selected"':"")+">"+o.items[y].text+"</option>";f.addClass("w2ui-editable").html('<select id="grid_'+a.name+"_edit_"+e+"_"+t+'" column="'+t+'" class="w2ui-input" style="width: 100%; pointer-events: auto; padding: 0 0 0 3px; margin: 0px; border-left: 0; border-right: 0; border-radius: 0px; outline: none; font-family: inherit;'+w+o.style+'" field="'+u.field+'" recid="'+e+'" '+o.inTag+">"+v+"</select>"+o.outTag),setTimeout((function(){f.find("select").on("change",(function(e){delete a.last.move})).on("blur",(function(e){1!=$(this).data("keep-open")&&a.editChange.call(a,this,r,t,e)}))}),10);break;case"div":var b="font-family: "+(_=p.find("[col="+t+"] > div")).css("font-family")+"; font-size: "+_.css("font-size")+";";f.addClass("w2ui-editable").html('<div id="grid_'+a.name+"_edit_"+e+"_"+t+'" class="w2ui-input" contenteditable style="'+b+w+o.style+'" autocorrect="off" autocomplete="off" spellcheck="false" field="'+u.field+'" recid="'+e+'" column="'+t+'" '+o.inTag+"></div>"+o.outTag),null==i&&f.find("div.w2ui-input").text("object"!=typeof g?g:"");var x=f.find("div.w2ui-input").get(0);setTimeout((function(){var e=x;$(e).on("blur",(function(i){1!=$(this).data("keep-open")&&a.editChange.call(a,e,r,t,i)}))}),10),null!=i&&$(x).text("object"!=typeof g?g:"");break;default:var _;b="font-family: "+(_=p.find("[col="+t+"] > div")).css("font-family")+"; font-size: "+_.css("font-size"),f.addClass("w2ui-editable").html('<input id="grid_'+a.name+"_edit_"+e+"_"+t+'" autocorrect="off" autocomplete="off" spellcheck="false" type="text" style="'+b+"; width: 100%; height: 100%; padding: 3px; border-color: transparent; outline: none; border-radius: 0; pointer-events: auto; "+w+o.style+'" field="'+u.field+'" recid="'+e+'" column="'+t+'" class="w2ui-input"'+o.inTag+"/>"+o.outTag),"number"==o.type&&(g=w2utils.formatNumber(g)),"date"==o.type&&(g=w2utils.formatDate(w2utils.isDate(g,o.format,!0)||new Date,o.format)),null==i&&f.find("input").val("object"!=typeof g?g:""),x=f.find("input").get(0),$(x).w2field(o.type,$.extend(o,{selected:g})),setTimeout((function(){var e=x;"list"==o.type&&(e=$($(x).data("w2field").helpers.focus).find("input"),"object"!=typeof g&&""!=g&&e.val(g).css({opacity:1}).prev().css({opacity:1}),f.find("input").on("change",(function(e){a.editChange.call(a,x,r,t,e)}))),$(e).on("blur",(function(e){1!=$(this).data("keep-open")&&a.editChange.call(a,x,r,t,e)}))}),10),null!=i&&$(x).val("object"!=typeof g?g:"")}return void setTimeout((function(){a.last.inEditMode&&(f.find("input, select, div.w2ui-input").data("old_value",m).on("mousedown",(function(e){e.stopPropagation()})).on("click",(function(e){"div"==o.type?k.call(f.find("div.w2ui-input")[0],null):k.call(f.find("input, select")[0],null)})).on("paste",(function(e){var t=e.originalEvent;e.preventDefault();var i=t.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,i)})).on("keydown",(function(i){var s=this,n="DIV"==s.tagName.toUpperCase()?$(s).text():$(s).val();switch(i.keyCode){case 8:"list"!=o.type||$(x).data("w2field")||i.preventDefault();break;case 9:case 13:i.preventDefault();break;case 37:0===w2utils.getCursorPosition(s)&&i.preventDefault();break;case 39:w2utils.getCursorPosition(s)==n.length&&(w2utils.setCursorPosition(s,n.length),i.preventDefault())}setTimeout((function(){switch(i.keyCode){case 9:var n=e,l=i.shiftKey?a.prevCell(r,t,!0):a.nextCell(r,t,!0);if(null==l){var o=i.shiftKey?a.prevRow(r,t):a.nextRow(r,t);if(null!=o&&o!=r){n=a.records[o].recid;for(var c=0;c<a.columns.length;c++){var h=a.getCellEditable(r,c);if(null!=h&&-1==["checkbox","check"].indexOf(h.type)&&(l=parseInt(c),!i.shiftKey))break}}}!1===n&&(n=e),null==l&&(l=t),s.blur(),setTimeout((function(){"row"!=a.selectType?(a.selectNone(),a.select({recid:n,column:l})):a.editField(n,l,null,i)}),1),i.preventDefault&&i.preventDefault();break;case 13:s.blur();var p=i.shiftKey?a.prevRow(r,t):a.nextRow(r,t);null!=p&&p!=r&&setTimeout((function(){"row"!=a.selectType?(a.selectNone(),a.select({recid:a.records[p].recid,column:t})):a.editField(a.records[p].recid,t,null,i)}),1),"DIV"==s.tagName.toUpperCase()&&i.preventDefault();break;case 27:var f=a.parseField(d,u.field);d.w2ui&&d.w2ui.changes&&null!=d.w2ui.changes[u.field]&&(f=d.w2ui.changes[u.field]),null!=$(s).data("old_value")&&(f=$(s).data("old_value")),"DIV"==s.tagName.toUpperCase()?$(s).text(null!=f?f:""):s.value=null!=f?f:"",s.blur(),setTimeout((function(){a.select({recid:e,column:t})}),1)}k.call(s,i)}),1)})).on("keyup",(function(e){k.call(this,e)})),setTimeout((function(){var e,t;a.last.inEditMode&&(e=f.find(".w2ui-input"),t=null!=$(e).val()?$(e).val().length:0,"div"==o.type&&(t=$(e).text().length),0<e.length&&(e.focus(),clearTimeout(a.last.kbd_timer),"SELECT"!=e[0].tagName.toUpperCase()&&w2utils.setCursorPosition(e[0],t),(e[0].resize=k).call(e[0],null)))}),50),a.trigger($.extend(h,{phase:"after",input:f.find("input, select, div.w2ui-input")})))}),5)}}else console.log('ERROR: input types "enum" and "file" are not supported in inline editing.')}}else 13==s.keyCode?(r=this.last._edit.index,t=this.last._edit.column,e=this.last._edit.recid,this.editChange({type:"custom",value:this.last._edit.value},this.get(e,!0),t,s),null!=(n=s.shiftKey?this.prevRow(r,t):this.nextRow(r,t))&&n!=r&&setTimeout((function(){"row"!=a.selectType?(a.selectNone(),a.se
1lect({recid:a.records[n].recid,column:t})):a.editField(a.records[n].recid,t,null,s)}),1),this.last.inEditMode=!1):0<(l=$(this.box).find("div.w2ui-edit-box .w2ui-input")).length&&"DIV"==l[0].tagName&&(l.text(l.text()+i),w2utils.setCursorPosition(l[0],l.text().length));function k(e){try{var t="DIV"==this.tagName.toUpperCase()?$(this).text():this.value,i=$("#grid_"+a.name+"_editable"),s="font-family: "+$(this).css("font-family")+"; font-size: "+$(this).css("font-size")+"; white-space: pre;",n=w2utils.getStrWidth(t,s);n+20>i.width()&&i.width(n+20)}catch(e){}}},editChange:function(e,t,i,s){var n=this;setTimeout((function(){var e=$(n.box).find("#grid_"+n.name+"_focus");e.is(":focus")||e.focus()}),10);var l=t<0;t=t<0?-t-1:t;var a=(l?this.summary:this.records)[t],r=this.columns[i],o=$("#grid_"+this.name+(!0===r.frozen?"_frec_":"_rec_")+w2utils.escapeId(a.recid)),d=e.tagName&&"DIV"==e.tagName.toUpperCase()?$(e).text():e.value,u=this.parseField(a,r.field),c=$(e).data("w2field");c&&("list"==c.type&&(d=$(e).data("selected")),!$.isEmptyObject(d)&&null!=d||(d=""),$.isPlainObject(d)||(d=c.clean(d))),"checkbox"==e.type&&(a.w2ui&&!1===a.w2ui.editable&&(e.checked=!e.checked),d=e.checked);var h={phase:"before",type:"change",target:this.name,input_id:e.id,recid:a.recid,index:t,column:i,originalEvent:s.originalEvent?s.originalEvent:s,value_new:d,value_previous:a.w2ui&&a.w2ui.changes&&a.w2ui.changes.hasOwnProperty(r.field)?a.w2ui.changes[r.field]:u,value_original:u};for(null!=$(s.target).data("old_value")&&(h.value_previous=$(s.target).data("old_value"));;){if("object"!=typeof(d=h.value_new)&&String(u)!=String(d)||"object"==typeof d&&d&&d.id!=u&&("object"!=typeof u||null==u||d.id!=u.id)){if(!0!==(h=this.trigger($.extend(h,{type:"change",phase:"before"}))).isCancelled){if(d!==h.value_new)continue;a.w2ui=a.w2ui||{},a.w2ui.changes=a.w2ui.changes||{},a.w2ui.changes[r.field]=h.value_new,this.trigger($.extend(h,{phase:"after"}))}}else if(!0!==(h=this.trigger($.extend(h,{type:"restore",phase:"before"}))).isCancelled){if(d!==h.value_new)continue;a.w2ui&&a.w2ui.changes&&delete a.w2ui.changes[r.field],a.w2ui&&$.isEmptyObject(a.w2ui.changes)&&delete a.w2ui.changes,this.trigger($.extend(h,{phase:"after"}))}break}var p=$(o).find("[col="+i+"]");l||(a.w2ui&&a.w2ui.changes&&null!=a.w2ui.changes[r.field]?p.addClass("w2ui-changed"):p.removeClass("w2ui-changed"),p.replaceWith(this.getCellHTML(t,i,l))),$(this.box).find("div.w2ui-edit-box").remove(),this.show.toolbarSave&&(0<this.getChanges().length?this.toolbar.enable("w2ui-save"):this.toolbar.disable("w2ui-save")),n.last.inEditMode=!1},delete:function(e){(new Date).getTime();var t=this,i=this.trigger({phase:"before",target:this.name,type:"delete",force:e});if(e&&this.message(),!0!==i.isCancelled){e=i.force,setTimeout((function(){$().w2tag()}),20);var s=this.getSelection();if(0!==s.length)if(""==this.msgDelete||e){if("object"!=typeof this.url?this.url:this.url.remove)this.request("delete");else if("object"!=typeof s[0])this.selectNone(),this.remove.apply(this,s);else{for(var n=0;n<s.length;n++){var l=this.columns[s[n].column].field,a=this.get(s[n].recid,!0),r=this.records[a];null!=a&&"recid"!=l&&(this.records[a][l]="",r.w2ui&&r.w2ui.changes&&delete r.w2ui.changes[l])}this.update()}this.trigger($.extend(i,{phase:"after"}))}else this.message({width:380,height:170,body:'<div class="w2ui-centered">'+w2utils.lang(t.msgDelete).replace("NN",s.length).replace("records",1==s.length?"record":"records")+"</div>",buttons:w2utils.settings.macButtonOrder?'<button type="button" class="w2ui-btn btn-default" onclick="w2ui[\''+this.name+"'].message()\">"+w2utils.lang("Cancel")+'</button><button type="button" class="w2ui-btn" onclick="w2ui[\''+this.name+"'].delete(true)\">"+w2utils.lang(this.msgDeleteBtn)+"</button>":'<button type="button" class="w2ui-btn" onclick="w2ui[\''+this.name+"'].delete(true)\">"+w2utils.lang(this.msgDeleteBtn)+'</button><button type="button" class="w2ui-btn btn-default" onclick="w2ui[\''+this.name+"'].message()\">"+w2utils.lang("Cancel")+"</button>",onOpen:function(e){var i=$(this.box).find("input, textarea, select, button");i.off(".message").on("blur.message",(function(e){i.index(e.target)+1===i.length&&(i.get(0).focus(),e.preventDefault())})).on("keydown.message",(function(e){27==e.keyCode&&t.message()})),setTimeout(function(){$(this.box).find(".w2ui-btn.btn-default").focus(),clearTimeout(t.last.kbd_timer)}.bind(this),50)}})}},click:function(e,t){var i=(new Date).getTime(),s=null;if(!(1==this.last.cancelClick||t&&t.altKey))if("object"==typeof e&&null!==e&&(s=e.column,e=e.recid),null==t&&(t={}),i-parseInt(this.last.click_time)<350&&this.last.click_recid==e&&"click"==t.type)this.dblClick(e,t);else{this.last.bubbleEl&&($(this.last.bubbleEl).w2tag(),this.last.bubbleEl=null),this.last.click_time=i;var n=this.last.click_recid;this.last.click_recid=e,null==s&&t.target&&("TD"!=(g=t.target).tagName.toUpperCase()&&(g=$(g).parents("td")[0]),null!=$(g).attr("col")&&(s=parseInt($(g).attr("col"))));var l=this.trigger({phase:"before",target:this.name,type:"click",recid:e,column:s,originalEvent:t});if(!0!==l.isCancelled){var a=this,r=this.getSelection();$("#grid_"+this.name+"_check_all").prop("checked",!1);var o=this.get(e,!0),d=(this.records[o],[]);if(a.last.sel_ind=o,a.last.sel_col=s,a.last.sel_recid=e,a.last.sel_type="click",t.shiftKey&&0<r.length&&a.multiSelect){if(r[0].recid){var u,c,h=this.get(r[0].recid,!0),p=this.get(e,!0);c=s>r[0].column?(u=r[0].column,s):(u=s,r[0].column);for(var f=u;f<=c;f++)d.push(f)}else h=this.get(n,!0),p=this.get(e,!0);var g,m=[];
1p<h&&(g=h,h=p,p=g);for(var w="object"!=typeof this.url?this.url:this.url.get,v=h;v<=p;v++)if(!(0<this.searchData.length)||w||-1!=$.inArray(v,this.last.searchIds))if("row"==this.selectType)m.push(this.records[v].recid);else for(var y=0;y<d.length;y++)m.push({recid:this.records[v].recid,column:d[y]});this.select(m)}else{var b,x=this.last.selection,_=-1!=x.indexes.indexOf(o),k=!1;$(t.target).parents("td").hasClass("w2ui-col-select")&&(k=!0),(t.ctrlKey||t.shiftKey||t.metaKey||k)&&this.multiSelect||this.showSelectColumn?(b=$(t.target).parents("tr").find(".w2ui-grid-select-check").is(":checked"),"row"==this.selectType||-1!=$.inArray(s,x.columns[o])||b||(_=!1),!0===_?this.unselect({recid:e,column:s}):this.select({recid:e,column:s})):("row"!=this.selectType&&-1==$.inArray(s,x.columns[o])&&(_=!1),300<r.length?this.selectNone():this.unselect(r),!0===_&&1==r.length?this.unselect({recid:e,column:s}):this.select({recid:e,column:s}))}this.status(),a.initResize(),this.trigger($.extend(l,{phase:"after"}))}}},columnClick:function(e,t){if(!0!==(i=this.trigger({phase:"before",type:"columnClick",target:this.name,field:e,originalEvent:t})).isCancelled){if("row"==this.selectType)(n=this.getColumn(e))&&n.sortable&&this.sort(e,null,!(!t||!t.ctrlKey&&!t.metaKey)),"line-number"==i.field&&(this.getSelection().length>=this.records.length?this.selectNone():this.selectAll());else if(t.altKey&&(n=this.getColumn(e))&&n.sortable&&this.sort(e,null,!(!t||!t.ctrlKey&&!t.metaKey)),"line-number"==i.field)this.getSelection().length>=this.records.length?this.selectNone():this.selectAll();else{t.shiftKey||t.metaKey||t.ctrlKey||this.selectNone();var i,s=this.getSelection(),n=this.getColumn(i.field,!0),l=[],a=[];if(0!=s.length&&t.shiftKey){var r=n,o=s[0].column;o<r&&(r=s[0].column,o=n);for(var d=r;d<=o;d++)a.push(d)}else a.push(n);if(!0!==(i=this.trigger({phase:"before",type:"columnSelect",target:this.name,columns:a})).isCancelled){for(d=0;d<this.records.length;d++)l.push({recid:this.records[d].recid,column:a});this.select(l)}this.trigger($.extend(i,{phase:"after"}))}this.trigger($.extend(i,{phase:"after"}))}},columnDblClick:function(e,t){var i=this.trigger({phase:"before",type:"columnDblClick",target:this.name,field:e,originalEvent:t});!0!==i.isCancelled&&this.trigger($.extend(i,{phase:"after"}))},focus:function(e){var t=this,i=this.trigger({phase:"before",type:"focus",target:this.name,originalEvent:e});if(!0===i.isCancelled)return!1;this.hasFocus=!0,$(this.box).removeClass("w2ui-inactive").find(".w2ui-inactive").removeClass("w2ui-inactive"),setTimeout((function(){var e=$
1(t.box).find("#grid_"+t.name+"_focus");e.is(":focus")||e.focus()}),10),this.trigger($.extend(i,{phase:"after"}))},blur:function(e){var t=this.trigger({phase:"before",type:"blur",target:this.name,originalEvent:e});if(!0===t.isCancelled)return!1;this.hasFocus=!1,$(this.box).addClass("w2ui-inactive").find(".w2ui-selected").addClass("w2ui-inactive"),$(this.box).find(".w2ui-selection").addClass("w2ui-inactive"),this.trigger($.extend(t,{phase:"after"}))},keydown:function(e){var t=this,i="object"!=typeof this.url?this.url:this.url.get;if(!0===t.keyboard){var s=t.trigger({phase:"before",type:"keydown",target:t.name,originalEvent:e});if(!0!==s.isCancelled)if(0<$(this.box).find(">.w2ui-message").length)27==e.keyCode&&this.message();else{var n=!1,l=$("#grid_"+t.name+"_records"),a=t.getSelection();0===a.length&&(n=!0);var r=a[0]||null,o=[],d=a[a.length-1];if("object"==typeof r&&null!=r){r=a[0].recid,o=[];for(var u=0;a[u]&&a[u].recid==r;)o.push(a[u].column),u++;d=a[a.length-1].recid}var c=t.get(r,!0),h=t.get(d,!0),p=(t.get(r),$("#grid_"+t.name+"_rec_"+(null!=c?w2utils.escapeId(t.records[c].recid):"none"))),f=!1,g=e.keyCode,m=e.shiftKey;switch(g){case 8:case 46:t.delete(),f=!0,e.stopPropagation();break;case 27:t.selectNone(),f=!0;break;case 65:if(!e.metaKey&&!e.ctrlKey)break;t.selectAll(),f=!0;break;case 13:if("row"==this.selectType&&!0===t.show.expandColumn){if(p.length<=0)break;t.toggle(r,e),f=!0}else{for(var w=0;w<this.columns.length;w++)if(this.getCellEditable(c,w)){o.push(parseInt(w));break}"row"==this.selectType&&this.last._edit&&this.last._edit.column&&(o=[this.last._edit.column]),0<o.length&&(t.editField(r,o[0],null,e),f=!0)}break;case 37:if(n){T();break}if("row"==this.selectType){if(p.length<=0)break;!(y=this.records[c].w2ui||{})||null==y.parent_recid||Array.isArray(y.children)&&0!==y.children.length&&y.expanded?t.collapse(r,e):(t.unselect(r),t.collapse(y.parent_recid,e),t.select(y.parent_recid))}else{var v=t.prevCell(c,o[0]);if(m||null!=v||(this.selectNone(),v=0),null!=v)if(m&&t.multiSelect){if(S())return;var y=[],b=[],x=[];if(0===o.indexOf(this.last.sel_col)&&1<o.length){for(var _=0;_<a.length;_++)-1==y.indexOf(a[_].recid)&&y.push(a[_].recid),x.push({recid:a[_].recid,column:o[o.length-1]});t.unselect(x),t.scrollIntoView(c,o[o.length-1],!0)}else{for(_=0;_<a.length;_++)-1==y.indexOf(a[_].recid)&&y.push(a[_].recid),b.push({recid:a[_].recid,column:v});t.select(b),t.scrollIntoView(c,v,!0)}}else e.metaKey=!1,t.click({recid:r,column:v},e),t.scrollIntoView(c,v,!0);else if(!m)if(1<a.length)t.selectNone();else for(var k=1;k<a.length;k++)t.unselect(a[k])}f=!0;break;case 39:if(n){T();break}if("row"==this.selectType){if(p.length<=0)break;t.expand(r,e)}else{var C=t.nextCell(c,o[o.length-1]);if(m||null!=C||(this.selectNone(),C=this.columns.length-1),null!=C)if(m&&39==g&&t.multiSelect){if(S())return;if(y=[],b=[],x=[],o.indexOf(this.last.sel_col)==o.length-1&&1<o.length){for(_=0;_<a.length;_++)-1==y.indexOf(a[_].recid)&&y.push(a[_].recid),x.push({recid:a[_].recid,column:o[0]});t.unselect(x),t.scrollIntoView(c,o[0],!0)}else{for(_=0;_<a.length;_++)-1==y.indexOf(a[_].recid)&&y.push(a[_].recid),b.push({recid:a[_].recid,column:C});t.select(b),t.scrollIntoView(c,C,!0)}}else e.metaKey=!1,t.click({recid:r,column:C},e),t.scrollIntoView(c,C,!0);else if(!m)if(1<a.length)t.selectNone();else for(k=0;k<a.length-1;k++)t.unselect(a[k])}f=!0;break;case 38:if(n&&T(),p.length<=0)break;if(v=t.prevRow(c,o[0]),m||null!=v||(v=0==this.searchData.length||i?0:this.last.searchIds[0]),null!=v){if(m&&t.multiSelect){if(S())return;if("row"==t.selectType)t.last.sel_ind>v&&t.last.sel_ind!=h?t.unselect(t.records[h].recid):t.select(t.records[v].recid);else if(t.last.sel_ind>v&&t.last.sel_ind!=h){for(v=h,y=[],w=0;w<o.length;w++)y.push({recid:t.records[v].recid,column:o[w]});t.unselect(y)}else{for(y=[],w=0;w<o.length;w++)y.push({recid:t.records[v].recid,column:o[w]});t.select(y)}}else 300<a.length?this.selectNone():this.unselect(a),t.click({recid:t.records[v].recid,column:o[0]},e);t.scrollIntoView(v),e.preventDefault&&e.preventDefault()}else if(!m)if(1<a.length)t.selectNone();else for(k=1;k<a.length;k++)t.unselect(a[k]);break;case 40:if(n&&T(),p.length<=0)break;if(C=t.nextRow(h,o[0]),m||null!=C||(C=0==this.searchData.length||i?this.records.length-1:this.last.searchIds[this.last.searchIds.length-1]),null!=C){if(m&&t.multiSelect){if(S())return;if("row"==t.selectType)this.last.sel_ind<C&&this.last.sel_ind!=c?t.unselect(t.records[c].recid):t.select(t.records[C].recid);else if(this.last.sel_ind<C&&this.last.sel_ind!=c){for(C=c,y=[],w=0;w<o.length;w++)y.push({recid:t.records[C].recid,column:o[w]});t.unselect(y)}else{for(y=[],w=0;w<o.length;w++)y.push({recid:t.records[C].recid,column:o[w]});t.select(y)}}else 300<a.length?this.selectNone():this.unselect(a),t.click({recid:t.records[C].recid,column:o[0]},e);t.scrollIntoView(C),f=!0}else if(!m)if(1<a.length)t.selectNone();else for(k=0;k<a.length-1;k++)t.unselect(a[k]);break;case 17:case 91:if(n)break;t.last.isSafari&&(t.last.copy_event=t.copy(!1,e),$("#grid_"+t.name+"_focus").val(t.last.copy_event.text).select());break;
1case 67:(e.metaKey||e.ctrlKey)&&(t.last.isSafari||(t.last.copy_event=t.copy(!1,e),$("#grid_"+t.name+"_focus").val(t.last.copy_event.text).select()),t.copy(t.last.copy_event,e));break;case 88:if(n)break;(e.ctrlKey||e.metaKey)&&(t.last.isSafari||(t.last.copy_event=t.copy(!1,e),$("#grid_"+t.name+"_focus").val(t.last.copy_event.text).select()),t.copy(t.last.copy_event,e))}for(y=[32,187,189,192,219,220,221,186,222,188,190,191],_=48;_<=111;_++)y.push(_);-1==y.indexOf(g)||e.ctrlKey||e.metaKey||f||(0===o.length&&o.push(0),f=!1,setTimeout((function(){var i=$("#grid_"+t.name+"_focus"),s=i.val();i.val(""),t.editField(r,o[0],s,e)}),1)),f&&e.preventDefault&&e.preventDefault(),t.trigger($.extend(s,{phase:"after"}))}}function T(){var e=Math.floor(l[0].scrollTop/t.recordHeight)+1;(!t.records[e]||e<2)&&(e=0),t.select({recid:t.records[e].recid,column:0})}function S(){if("click"==t.last.sel_type){if("row"==t.selectType)return t.last.sel_type="key",1<a.length?(a.splice(a.indexOf(t.records[t.last.sel_ind].recid),1),t.unselect(a),1):void 0;if(t.last.sel_type="key",1<a.length){for(var e=0;e<a.length;e++)if(a[e].recid==t.last.sel_recid&&a[e].column==t.last.sel_col){a.splice(e,1);break}return t.unselect(a),1}}}},scrollIntoView:function(e,t,i){var s=this.records.length;if(0==this.searchData.length||this.url||(s=this.last.searchIds.length),0!==s){if(null==e){var n=this.getSelection();if(0===n.length)return;$.isPlainObject(n[0])?(e=n[0].index,t=n[0].column):e=this.get(n[0],!0)}var l,a,r=$("#grid_"+this.name+"_records"),o=this.last.searchIds.length;if(0<o&&(e=this.last.searchIds.indexOf(e)),r.height()<this.recordHeight*(0<o?o:s)&&0<r.length&&(a=(l=Math.floor(r[0].scrollTop/this.recordHeight))+Math.floor(r.height()/this.recordHeight),e==l&&(!0===i?r.prop({scrollTop:r.scrollTop()-r.height()/1.3}):(r.stop(),r.animate({scrollTop:r.scrollTop()-r.height()/1.3},250,"linear"))),e==a&&(!0===i?r.prop({scrollTop:r.scrollTop()+r.height()/1.3}):(r.stop(),r.animate({scrollTop:r.scrollTop()+r.height()/1.3},250,"linear"))),(e<l||a<e)&&(!0===i?r.prop({scrollTop:(e-1)*this.recordHeight}):(r.stop(),r.animate({scrollTop:(e-1)*this.recordHeight},250,"linear")))),null!=t){for(var d=0,u=0,c=w2utils.scrollBarSize(),h=0;h<=t;h++){var p=this.columns[h];p.frozen||p.hidden||(d=u,u+=parseInt(p.sizeCalculated))}r.width()<u-r.scrollLeft()?!0===i?r.prop({scrollLeft:d-c}):r.animate({scrollLeft:d-c},250,"linear"):d<r.scrollLeft()&&(!0===i?r.prop({scrollLeft:u-r.width()+2*c}):r.animate({scrollLeft:u-r.width()+2*c},250,"linear"))}}},dblClick:function(e,t){var i,s=null;"object"==typeof e&&null!==e&&(s=e.column,e=e.recid),null==t&&(t={}),null==s&&t.target&&("TD"!=(i=t.target).tagName.toUpperCase()&&(i=$(i).parents("td")[0]),s=parseInt($(i).attr("col")));var n=this.get(e,!0),l=this.records[n],a=this.trigger({phase:"before",target:this.name,type:"dblClick",recid:e,column:s,originalEvent:t});!0!==a.isCancelled&&(this.selectNone(),this.getCellEditable(n,s)?this.editField(e,s,null,t):(this.select({recid:e,column:s}),(this.show.expandColumn||l.w2ui&&Array.isArray(l.w2ui.children))&&this.toggle(e)),this.trigger($.extend(a,{phase:"after"})))},contextMenu:function(e,t,i){var s=this;if("text"!=s.last.userSelect){null==i&&(i={offsetX:0,offsetY:0,target:$("#grid_"+s.name+"_rec_"+e)[0]}),null==i.offsetX&&(i.offsetX=i.layerX-i.target.offsetLeft,i.offsetY=i.layerY-i.target.offsetTop),w2utils.isFloat(e)&&(e=parseFloat(e));var n=this.getSelection();if("row"==this.selectType)-1==n.indexOf(e)&&s.click(e);else{var l=$(i.target);"TD"!=l[0].tagName.toUpperCase()&&(l=$(i.target).parents("td"));var a=!1;t=l.attr("col");for(var r=0;r<n.length;r++)n[r].recid!=e&&n[r].column!=t||(a=!0);a||null==e||s.click({recid:e,column:t}),a||null==t||s.columnClick(this.columns[t].field,i)}var o=s.trigger({phase:"before",type:"contextMenu",target:s.name,originalEvent:i,recid:e,column:t});!0!==o.isCancelled&&(0<s.menu.length&&$(s.box).find(i.target).w2menu(s.menu,{originalEvent:i,contextMenu:!0,onSelect:function(t){s.menuClick(e,t)}}),i.preventDefault&&i.preventDefault(),s.trigger($.extend(o,{phase:"after"})))}},menuClick:function(e,t){var i=this.trigger({phase:"before",type:"menuClick",target:this.name,originalEvent:t.originalEvent,menuEvent:t,recid:e,menuIndex:t.index,menuItem:t.item});!0!==i.isCancelled&&this.trigger($.extend(i,{phase:"after"}))},toggle:function(e){var t=this.get(e);return t.w2ui=t.w2ui||{},!0===t.w2ui.expanded?this.collapse(e):this.expand(e)},expand:function(e){var t=this.get(e,!0),i=this.records[t];i.w2ui=i.w2ui||{};var s,n=w2utils.escapeId(e),l=i.w2ui.children;if(Array.isArray(l)){if(!0===i.w2ui.expanded||0===l.length)return!1;
1if(!0===(s=this.trigger({phase:"before",type:"expand",target:this.name,recid:e})).isCancelled)return!1;i.w2ui.expanded=!0,l.forEach((function(e){e.w2ui=e.w2ui||{},e.w2ui.parent_recid=i.recid,null==e.w2ui.children&&(e.w2ui.children=[])})),this.records.splice.apply(this.records,[t+1,0].concat(l)),this.total+=l.length,("object"!=typeof this.url?this.url:this.url.get)||(this.localSort(!0,!0),0<this.searchData.length&&this.localSearch(!0)),this.refresh(),this.trigger($.extend(s,{phase:"after"}))}else{if(0<$("#grid_"+this.name+"_rec_"+n+"_expanded_row").length||!0!==this.show.expandColumn)return!1;if("none"==i.w2ui.expanded)return!1;if($("#grid_"+this.name+"_rec_"+n).after('<tr id="grid_'+this.name+"_rec_"+e+'_expanded_row" class="w2ui-expanded-row"> <td colspan="100" class="w2ui-expanded2"> <div id="grid_'+this.name+"_rec_"+e+'_expanded"></div> </td> <td class="w2ui-grid-data-last"></td></tr>'),$("#grid_"+this.name+"_frec_"+n).after('<tr id="grid_'+this.name+"_frec_"+e+'_expanded_row" class="w2ui-expanded-row">'+(this.show.lineNumbers?'<td class="w2ui-col-number"></td>':"")+' <td class="w2ui-grid-data w2ui-expanded1" colspan="100"> <div id="grid_'+this.name+"_frec_"+e+'_expanded"></div> </td></tr>'),!0===(s=this.trigger({phase:"before",type:"expand",target:this.name,recid:e,box_id:"grid_"+this.name+"_rec_"+e+"_expanded",fbox_id:"grid_"+this.name+"_frec_"+n+"_expanded"})).isCancelled)return $("#grid_"+this.name+"_rec_"+n+"_expanded_row").remove(),$("#grid_"+this.name+"_frec_"+n+"_expanded_row").remove(),!1;var a=$(this.box).find("#grid_"+this.name+"_rec_"+e+"_expanded"),r=$(this.box).find("#grid_"+this.name+"_frec_"+e+"_expanded"),o=a.find("> div:first-child").height();a.height()<o&&a.css({height:o+"px"}),r.height()<o&&r.css({height:o+"px"}),$("#grid_"+this.name+"_rec_"+n).attr("expanded","yes").addClass("w2ui-expanded"),$("#grid_"+this.name+"_frec_"+n).attr("expanded","yes").addClass("w2ui-expanded"),$("#grid_"+this.name+"_cell_"+this.get(e,!0)+"_expand div").html("-"),i.w2ui.expanded=!0,this.trigger($.extend(s,{phase:"after"})),this.resizeRecords()}return!0},collapse:function(e){var t=this,i=this.get(e,!0),s=this.records[i];s.w2ui=s.w2ui||{};var n,l=w2utils.escapeId(e),a=s.w2ui.children;if(Array.isArray(a)){if(!0!==s.w2ui.expanded)return!1;if(!0===(n=this.trigger({phase:"before",type:"collapse",target:this.name,recid:e})).isCancelled)return!1;!function e(t){t.w2ui.expanded=!1;for(var i=0;i<t.w2ui.children.length;i++){var s=t.w2ui.children[i];s.w2ui.expanded&&e(s)}}(s);for(var r=[],o=s;null!=o;o=this.get(o.w2ui.parent_recid))r.push(o.w2ui.parent_recid);for(var d=i+1,u=d;!(this.records.length<=u+1||null==this.records[u+1].w2ui||0<=r.indexOf(this.records[u+1].w2ui.parent_recid));)u++;this.records.splice(d,u-d+1),this.total-=u-d+1,("object"!=typeof this.url?this.url:this.url.get)||0<this.searchData.length&&this.localSearch(!0),this.refresh(),t.trigger($.extend(n,{phase:"after"}))}else{if(0===$("#grid_"+this.name+"_rec_"+l+"_expanded_row").length||!0!==this.show.expandColumn)return!1;if(!0===(n=this.trigger({phase:"before",type:"collapse",target:this.name,recid:e,box_id:"grid_"+this.name+"_rec_"+l+"_expanded",fbox_id:"grid_"+this.name+"_frec_"+l+"_expanded"})).isCancelled)return!1;$("#grid_"+this.name+"_rec_"+l).removeAttr("expanded").removeClass("w2ui-expanded"),$("#grid_"+this.name+"_frec_"+l).removeAttr("expanded").removeClass("w2ui-expanded"),$("#grid_"+this.name+"_cell_"+this.get(e,!0)+"_expand div").html("+"),$("#grid_"+t.name+"_rec_"+l+"_expanded").css("height","0px"),$("#grid_"+t.name+"_frec_"+l+"_expanded").css("height","0px"),setTimeout((function(){$("#grid_"+t.name+"_rec_"+l+"_expanded_row").remove(),$("#grid_"+t.name+"_frec_"+l+"_expanded_row").remove(),s.w2ui.expanded=!1,t.trigger($.extend(n,{phase:"after"})),t.resizeRecords()}),300)}return!0},sort:function(e,t,i){var s=this.trigger({phase:"before",type:"sort",target:this.name,field:e,direction:t,multiField:i});if(!0!==s.isCancelled){if(null!=e){for(var n=this.sortData.length,l=0;l<this.sortData.length;l++)if(this.sortData[l].field==e){n=l;break}null==t&&(t=null==this.sortData[n]?"asc":"asc"===(null==this.sortData[n].direction&&(this.sortData[n].direction=""),this.sortData[n].direction.toLowerCase())?"desc":"asc"),!1===this.multiSort&&(this.sortData=[],n=0),1!=i&&(this.sortData=[],n=0),null==this.sortData[n]&&(this.sortData[n]={}),this.sortData[n].field=e,this.sortData[n].direction=t}else this.sortData=[];("object"!=typeof this.url?this.url:this.url.get)?(this.trigger($.extend(s,{phase:"after",direction:t})),this.last.xhr_offset=0,this.reload()):(this.localSort(!0,!0),0<this.searchData.length&&this.localSearch(!0),this.last.scrollTop=0,$("#grid_"+this.name+"_records").prop("scrollTop",0),this.trigger($.extend(s,{phase:"after",direction:t})),this.refresh())}},copy:function(e,t){if($.isPlainObject(e))return this.trigger($.extend(e,{phase:"after"})),e.text;var i=this.getSelection();if(0===i.length)return"";var s,n="";if("object"==typeof i[0]){for(var l=i[0].column,a=i[0].column,r=[],o=0;o<i.length;o++)i[o].column<l&&(l=i[o].column),i[o].column>a&&(a=i[o].column),-1==r.indexOf(i[o].index)&&r.push(i[o].index);r.sort((function(e,t){return e-t}));for(var d=0;d<r.length;d++){for(var u=r[d],c=l;c<=a;c++)!0!==(p=this.columns[c]).hidden&&(n+=this.getCellCopy(u,c)+"\t");n=n.substr(0,n.length-1),n+="\n"}}else{var h;for(c=0;c<this.columns.length;c++)!0!==(p=this.columns[c]).hidden&&(h=p.text?p.text:p.field,p.text&&p.text.length<3&&p.tooltip&&(h=p.tooltip),n+='"'+w2utils.stripTags(h)+'"\t');for(n=n.substr(0,n.length-1),n+="\n",o=0;o<i.length;o++){var p;for(u=this.get(i[o],!0),c=0;c<this.columns.length;c++)!0!==(p=this.columns[c]).hidden&&(n+='"'+this.getCellCopy(u,c)+'"\t');
1n=n.substr(0,n.length-1),n+="\n"}}return n=n.substr(0,n.length-1),null==e?!0===(s=this.trigger({phase:"before",type:"copy",target:this.name,text:n,cut:88==t.keyCode,originalEvent:t})).isCancelled?"":(n=s.text,this.trigger($.extend(s,{phase:"after"})),n):!1===e?!0===(s=this.trigger({phase:"before",type:"copy",target:this.name,text:n,cut:88==t.keyCode,originalEvent:t})).isCancelled?"":(n=s.text,s):void 0},getCellCopy:function(e,t){return w2utils.stripTags(this.getCellHTML(e,t))},paste:function(e){var t=this.getSelection(),i=this.get(t[0].recid,!0),s=t[0].column,n=this.trigger({phase:"before",type:"paste",target:this.name,text:e,index:i,column:s});if(!0!==n.isCancelled){if(e=n.text,"row"==this.selectType||0===t.length)return console.log("ERROR: You can paste only if grid.selectType = 'cell' and when at least one cell selected."),void this.trigger($.extend(n,{phase:"after"}));for(var l=[],a=(e=e.split("\n"),0);a<e.length;a++){var r=e[a].split("\t"),o=0,d=this.records[i],u=[];if(null!=d){for(var c=0;c<r.length;c++)this.columns[s+o]&&(this.setCellPaste(d,s+o,r[c]),u.push(s+o),o++);for(var h=0;h<u.length;h++)l.push({recid:d.recid,column:u[h]});i++}}this.selectNone(),this.select(l),this.refresh(),this.trigger($.extend(n,{phase:"after"}))}},setCellPaste:function(e,t,i){var s=this.columns[t].field;e.w2ui=e.w2ui||{},e.w2ui.changes=e.w2ui.changes||{},e.w2ui.changes[s]=i},resize:function(){var e=this,t=(new Date).getTime();if(this.box&&$(this.box).attr("name")==this.name){$(this.box).find("> div.w2ui-grid-box").css("width",$(this.box).width()).css("height",$(this.box).height());var i=this.trigger({phase:"before",type:"resize",target:this.name});if(!0!==i.isCancelled)return e.resizeBoxes(),e.resizeRecords(),e.toolbar&&e.toolbar.resize&&e.toolbar.resize(),this.trigger($.extend(i,{phase:"after"})),(new Date).getTime()-t}},update:function(e){var t=(new Date).getTime();if(null==this.box)return 0;if(null==e){for(var i=this.last.range_start-1;i<=this.last.range_end-1;i++)if(!(i<0)){(a=this.records[i]||{}).w2ui||(a.w2ui={});for(var s=0;s<this.columns.length;s++){var n=$(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(a.recid));(r=$(this.box).find("#grid_"+this.name+"_data_"+i+"_"+s)).replaceWith(this.getCellHTML(i,s,!1)),r=$(this.box).find("#grid_"+this.name+"_data_"+i+"_"+s),null==a.w2ui.style||$.isEmptyObject(a.w2ui.style)?r.attr("style",""):("string"==typeof a.w2ui.style&&n.attr("style",a.w2ui.style),$.isPlainObject(a.w2ui.style)&&"string"==typeof a.w2ui.style[s]&&r.attr("style",a.w2ui.style[s])),null==a.w2ui.class||$.isEmptyObject(a.w2ui.class)||("string"==typeof a.w2ui.class&&n.addClass(a.w2ui.class),$.isPlainObject(a.w2ui.class)&&"string"==typeof a.w2ui.class[s]&&r.addClass(a.w2ui.class[s]))}}}else for(var l=0;l<e.length;l++){var a,r;i=e[l].index,s=e[l].column,i<0||(null!=i&&null!=s?(a=this.records[i]||{},n=$(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(a.recid)),r=$(this.box).find("#grid_"+this.name+"_data_"+i+"_"+s),a.w2ui||(a.w2ui={}),r.replaceWith(this.getCellHTML(i,s,!1)),r=$(this.box).find("#grid_"+this.name+"_data_"+i+"_"+s),null==a.w2ui.style||$.isEmptyObject(a.w2ui.style)?r.attr("style",""):("string"==typeof a.w2ui.style&&n.attr("style",a.w2ui.style),$.isPlainObject(a.w2ui.style)&&"string"==typeof a.w2ui.style[s]&&r.attr("style",a.w2ui.style[s])),null==a.w2ui.class||$.isEmptyObject(a.w2ui.class)||("string"==typeof a.w2ui.class&&n.addClass(a.w2ui.class),$.isPlainObject(a.w2ui.class)&&"string"==typeof a.w2ui.class[s]&&r.addClass(a.w2ui.class[s]))):console.log("ERROR: Wrong argument for grid.update(cells), cells should be [{ index: X, column: Y }, ...]"))}return(new Date).getTime()-t},refreshCell:function(e,t){var i=this.get(e,!0),s=this.getColumn(t,!0),n=!this.records[i]||this.records[i].recid!=e,l=$(this.box).find((n?".w2ui-grid-summary ":"")+"#grid_"+this.name+"_data_"+i+"_"+s);if(0==l.length)return!1;l.replaceWith(this.getCellHTML(i,s,n))},refreshRow:function(e,t){var i=$(this.box).find("#grid_"+this.name+"_frec_"+w2utils.escapeId(e)),s=$(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(e));if(0<i.length){null==t&&(t=this.get(e,!0));var n=i.attr("line"),l=!this.records[t]||this.records[t].recid!=e,a="object"!=typeof this.url?this.url:this.url.get;if(0<this.searchData.length&&!a)for(var r=0;r<this.last.searchIds.length;r++)this.last.searchIds[r]==t&&(t=r);var o=this.getRecordHTML(t,n,l);$(i).replaceWith(o[0]),$(s).replaceWith(o[1]);var d=this.records[t].w2ui?this.records[t].w2ui.style:"";"string"==typeof d&&(i=$(this.box).find("#grid_"+this.name+"_frec_"+w2utils.escapeId(e)),s=$(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(e)),i.attr("custom_style",d),s.attr("custom_style",d),i.hasClass("w2ui-selected")&&(d=d.replace("background-color","none")),i[0].style.cssText="height: "+this.recordHeight+"px;"+d,s[0].style.cssText="height: "+this.recordHeight+"px;"+d),l&&this.resize()}},refresh:function(){var e=this,t=(new Date).getTime(),i="object"!=typeof this.url?this.url:this.url.get;if(this.total<=0&&!i&&0===this.searchData.length&&(this.total=this.records.length),this.toolbar.disable("w2ui-edit","
1w2ui-delete"),this.box){var s=this.trigger({phase:"before",target:this.name,type:"refresh"});if(!0!==s.isCancelled){if(this.show.header?$("#grid_"+this.name+"_header").html(this.header+" ").show():$("#grid_"+this.name+"_header").hide(),this.show.toolbar){if(!(this.toolbar&&this.toolbar.get("w2ui-column-on-off")&&this.toolbar.get("w2ui-column-on-off").checked)&&($("#grid_"+this.name+"_toolbar").show(),"object"==typeof this.toolbar))for(var n=this.toolbar.items,l=0;l<n.length;l++)"w2ui-search"!=n[l].id&&"break"!=n[l].type&&this.toolbar.refresh(n[l].id)}else $("#grid_"+this.name+"_toolbar").hide();this.searchClose();var a=$("#grid_"+e.name+"_search_all");!this.multiSearch&&"all"==this.last.field&&0<this.searches.length&&(this.last.field=this.searches[0].field,this.last.label=this.searches[0].label);for(var r,o=0;o<this.searches.length;o++)this.searches[o].field==this.last.field&&(this.last.label=this.searches[o].label);this.last.multi?(a.attr("placeholder","["+w2utils.lang("Multiple Fields")+"]"),a.w2field("clear")):a.attr("placeholder",w2utils.lang(this.last.label)),a.val()!=this.last.search&&(r=this.last.search,(n=a.data("w2field"))&&(r=n.format(r)),a.val(r)),e.refreshBody(),this.show.footer?$("#grid_"+this.name+"_footer").html(this.getFooterHTML()).show():$("#grid_"+this.name+"_footer").hide();var d=$("#grid_"+this.name+"_searchClear");d.hide(),this.searchData.some((function(t){var i=e.getSearch(t.field);if(e.last.multi||i&&!i.hidden&&-1==["list","enum"].indexOf(i.type))return d.show(),!0}));var u=this.last.selection,c=0<this.records.length&&u.indexes.length==this.records.length,h=0<u.indexes.length&&0!==this.searchData.length&&u.indexes.length==this.last.searchIds.length;c||h?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status();for(var p=e.find({"w2ui.expanded":!0},!0),f=0;f<p.length;f++)(n=e.records[p[f]].w2ui)&&!Array.isArray(n.children)&&(n.expanded=!1);return e.markSearch&&setTimeout((function(){for(var t=[],i=0;i<e.searchData.length;i++){var s,n=e.searchData[i],l=e.getSearch(n.field);l&&!l.hidden&&(s=e.getColumn(n.field,!0),t.push({field:n.field,search:n.value,col:s}))}0<t.length&&t.forEach((function(t){$(e.box).find('td[col="'+t.col+'"]').not(".w2ui-head").w2marker(t.search)}))}),50),this.show.toolbarSave&&(0<this.getChanges().length?this.toolbar.enable("w2ui-save"):this.toolbar.disable("w2ui-save")),this.trigger($.extend(s,{phase:"after"})),e.resize(),e.addRange("selection"),setTimeout((function(){e.resize(),e.scroll()}),1),e.reorderColumns&&!e.last.columnDrag?e.last.columnDrag=e.initColumnDrag():!e.reorderColumns&&e.last.columnDrag&&e.last.columnDrag.remove(),(new Date).getTime()-t}}},refreshBody:function(){var e=this,t=this.find({"w2ui.summary":!0},!0);if(0<t.length){for(var i=0;i<t.length;i++)this.summary.push(this.records[t[i]]);for(i=t.length-1;0<=i;i--)this.records.splice(t[i],1)}this.scroll();var s,n=this.getRecordsHTML(),l=this.getColumnsHTML(),a='<div id="grid_'+this.name+'_frecords" class="w2ui-grid-frecords" style="margin-bottom: '+(w2utils.scrollBarSize()-1)+'px;">'+n[0]+'</div><div id="grid_'+this.name+'_records" class="w2ui-grid-records" onscroll="w2ui[\''+this.name+"'].scroll(event);\">"+n[1]+'</div><div id="grid_'+this.name+'_scroll1" class="w2ui-grid-scroll1" style="height: '+w2utils.scrollBarSize()+'px"></div><div id="grid_'+this.name+'_fcolumns" class="w2ui-grid-fcolumns"> <table><tbody>'+l[0]+'</tbody></table></div><div id="grid_'+this.name+'_columns" class="w2ui-grid-columns"> <table><tbody>'+l[1]+"</tbody></table></div>",r=$("#grid_"+this.name+"_body",e.box).html(a),o=$("#grid_"+this.name+"_records",e.box),d=$("#grid_"+this.name+"_frecords",e.box),u=this;"row"==this.selectType&&(o.on("mouseover mouseout","tr",(function(e){$("#grid_"+u.name+"_frec_"+w2utils.escapeId($(this).attr("recid"))).toggleClass("w2ui-record-hover","mouseover"==e.type)})),d.on("mouseover mouseout","tr",(function(e){$("#grid_"+u.name+"_rec_"+w2utils.escapeId($(this).attr("recid"))).toggleClass("w2ui-record-hover","mouseover"==e.type)}))),w2utils.isIOS?o.add(d).on("click","tr",(function(e){u.dblClick($(this).attr("recid"),e)})):o.add(d).on("click","tr",(function(e){u.click($(this).attr("recid"),e)})).on("contextmenu","tr",(function(e){u.contextMenu($(this).attr("recid"),null,e)})),r.data("scrolldata",{lastTime:0,lastDelta:0,time:0}).find(".w2ui-grid-frecords").on("mousewheel DOMMouseScroll ",(function(t){t.preventDefault();var i=t.originalEvent,s=r.data("scrolldata"),n=$(this).siblings(".w2ui-grid-records").addBack().filter(".w2ui-grid-records"),l=null!=typeof i.wheelDelta?-1*i.wheelDelta/120:(i.detail||i.deltaY)/3,a=n.scrollTop();s.time=+new Date,s.lastTime<s.time-150&&(s.lastDelta=0),s.lastTime=s.time,s.lastDelta+=l,l=Math.abs(s.lastDelta)<1?0:Math.round(s.lastDelta),r.data("scrolldata",s),l*=(Math.round(o.height()/e.recordHeight)-1)*e.recordHeight/4,n.stop().animate({scrollTop:a+l},250,"linear")})),0===this.records.length&&this.msgEmpty?$("#grid_"+this.name+"_body").append('<div id="grid_'+this.name+'_empty_msg" class="w2ui-grid-empty-msg"><div>'+this.msgEmpty+"</div></div>"):0<$("#grid_"+this.name+"_empty_msg").length&&$("#grid_"+this.name+"_empty_msg").remove(),0<this.summary.length?(s=this.getSummaryHTML(),$("#grid_"+this.name+"_fsummary").html(s[0]).show(),$("#grid_"+this.name+"_summary").html(s[1]).show()):($("#grid_"+this.name+"_fsummary").hide(),$("#grid_"+this.name+"_summary").hide())},render:function(e){var t=this,i=(new Date).getTime();if(null!=e&&(0<$(this.box).find("#grid_"+this.name+"_body").length&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-grid w2ui-inactive").html(""),this.box=e),this.box){var s,n="object"!=typeof this.url?this.url:this.url.get,l=this.trigger({phase:"before",target:this.name,type:"render",box:e});if(!0!==l.isCancelled){if(this.reset(!0),!this.last.field)if(this.multiSearch&&this.show.searchAll)this.last.field="all",this.last.label=w2utils.lang("All Fields");else{for(var a=0;a<this.searches.length&&(this.searches[a].hidden||!1===this.searches[a].simple);)a++;a>=this.searches.length?(this.last.field="",this.last.label=""):(this.last.field=this.searches[a].field,this.last.label=this.searches[a].label)}$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-grid w2ui-inactive").html('<div class="w2ui-grid-box"> <div id="grid_'+this.name+'_header" class="w2ui-grid-header"></div> <div id="grid_'+this.name+'_toolbar" class="w2ui-grid-toolbar"></div> <div id="grid_'+this.name+'_body" class="w2ui-grid-body"></div> <div id="grid_'+this.name+'_fsummary" class="w2ui-grid-body w2ui-grid-summary"></div> <div id="grid_'+this.name+'_summary" class="w2ui-grid-body w2ui-grid-summary"></div> <div id="grid_'+this.name+'_footer" class="w2ui-grid-footer"></div> <textarea id="grid_'+this.name+'_focus" class="w2ui-grid-focus-input" '+(w2utils.isIOS?"readonly":"")+"></textarea></div>"),"row"!=this.selectType&&$(this.box).addClass("w2ui-ss"),0<$(this.box).length&&($(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&&(s=this.searchData,setTimeout((function(){t.initAllField(t.last.field,1==s.length?s[0].value:null)}),1)),$("#grid_"+this.name+"_footer").html(this.getFooterHTML()),this.last.state||(this.last.state=this.stateSave(!0)),this.stateRestore(),n&&(this.clear(),this.refresh());for(var r,o=!1,d=0;d<this.searches.length;d++)if(this.searches[d].hidden){o=!0;break}return o?(this.searchReset(!1),n||setTimeout((function(){t.searchReset()}),1)):this.reload(),$(this.box).find("#grid_"+this.name+"_focus").on("focus",(function(e){clearTimeout(t.last.kbd_timer),t.hasFocus||t.focu
1s()})).on("blur",(function(e){clearTimeout(t.last.kbd_timer),t.last.kbd_timer=setTimeout((function(){t.hasFocus&&t.blur()}),100)})).on("paste",(function(e){var i,s,n=e.originalEvent.clipboardData?e.originalEvent.clipboardData:null;n&&n.types&&-1!=n.types.indexOf("text/plain")?(e.preventDefault(),-1!=(i=n.getData("text/plain")).indexOf("\r")&&-1==i.indexOf("\n")&&(i=i.replace(/\r/g,"\n")),w2ui[t.name].paste(i)):(s=this,setTimeout((function(){w2ui[t.name].paste(s.value),s.value=""}),1))})).on("keydown",(function(e){w2ui[t.name].keydown.call(w2ui[t.name],e)})),$(this.box).off("mousedown").on("mousedown",(function(e){if(1==e.which&&("text"==t.last.userSelect&&(delete t.last.userSelect,$(t.box).find(".w2ui-grid-body").css(w2utils.cssPrefix("user-select","none"))),!("row"==t.selectType&&($(e.target).parents().hasClass("w2ui-head")||$(e.target).hasClass("w2ui-head"))||t.last.move&&"expand"==t.last.move.type))){if(e.altKey)$(t.box).find(".w2ui-grid-body").css(w2utils.cssPrefix("user-select","text")),t.selectNone(),t.last.move={type:"text-select"},t.last.userSelect="text";else{for(var i=e.target,s={x:e.offsetX-10,y:e.offsetY-10},n=!1;i&&(!i.classList||!i.classList.contains("w2ui-grid"));)i.tagName&&"TD"==i.tagName.toUpperCase()&&(n=!0),i.tagName&&"TR"!=i.tagName.toUpperCase()&&1==n&&(s.x+=i.offsetLeft,s.y+=i.offsetTop),i=i.parentNode;t.last.move={x:e.screenX,y:e.screenY,divX:0,divY:0,focusX:s.x,focusY:s.y,recid:$(e.target).parents("tr").attr("recid"),column:parseInt("TD"==e.target.tagName.toUpperCase()?$(e.target).attr("col"):$(e.target).parents("td").attr("col")),type:"select",ghost:!1,start:!0},null==t.last.move.recid&&(t.last.move.type="select-column");var l,a,r,o=e.target,d=$(t.box).find("#grid_"+t.name+"_focus");t.last.move&&(l=t.last.move.focusX,a=t.last.move.focusY,((r=$(o).parents("table").parent()).hasClass("w2ui-grid-records")||r.hasClass("w2ui-grid-frecords")||r.hasClass("w2ui-grid-columns")||r.hasClass("w2ui-grid-fcolumns")||r.hasClass("w2ui-grid-summary"))&&(l=t.last.move.focusX-$(t.box).find("#grid_"+t.name+"_records").scrollLeft(),a=t.last.move.focusY-$(t.box).find("#grid_"+t.name+"_records").scrollTop()),($(o).hasClass("w2ui-grid-footer")||0<$(o).parents("div.w2ui-grid-footer").length)&&(a=$(t.box).find("#grid_"+t.name+"_footer").position().top),r.hasClass("w2ui-scroll-wrapper")&&r.parent().hasClass("w2ui-toolbar")&&(l=t.last.move.focusX-r.scrollLeft()),d.css({left:l-10,top:a})),setTimeout((function(){-1!=["INPUT","TEXTAREA","SELECT"].indexOf(o.tagName.toUpperCase())?$(o).focus():d.is(":focus")||d.focus()}),50),t.multiSelect||t.reorderRows||"drag"!=t.last.move.type||delete t.last.move}var h,p,f,g,m,w,v;1==t.reorderRows&&("TD"!=(h=e.target).tagName.toUpperCase()&&(h=$(h).parents("td")[0]),$(h).hasClass("w2ui-col-number")||$(h).hasClass("w2ui-col-order")?(t.selectNone(),t.last.move.reorder=!0,p=$(t.box).find(".w2ui-even.w2ui-empty-record").css("background-color"),f=$(t.box).find(".w2ui-odd.w2ui-empty-record").css("background-color"),$(t.box).find(".w2ui-even td").not(".w2ui-col-number").css("background-color",p),$(t.box).find(".w2ui-odd td").not(".w2ui-col-number").css("background-color",f),(g=t.last.move).ghost||(i=(m=$("#grid_"+t.name+"_rec_"+g.recid)).parents("table").find("tr:first-child").clone(),g.offsetY=e.offsetY,g.from=g.recid,g.pos=m.position(),g.ghost=$(m).clone(!0),g.ghost.removeAttr("id"),m.find("td").remove(),m.append('<td colspan="1000"><div style="height: '+t.recordHeight+'px; background-color: #eee; border-bottom: 1px dashed #aaa; border-top: 1px dashed #aaa;"></div></td>'),(v=$(t.box).find(".w2ui-grid-records")).append('<div id="grid_'+t.name+'_ghost_line" style="position: absolute; z-index: 999999; pointer-events: none; width: 100%;"></div>'),v.append('<table id="grid_'+t.name+'_ghost" style="position: absolute; z-index: 999998; opacity: 0.9; pointer-events: none;"></table>'),$("#grid_"+t.name+"_ghost").append(i).append(g.ghost)),w=$("#grid_"+t.name+"_ghost"),v=$(t.box).find(".w2ui-grid-records"),w.css({top:g.pos.top+v.scrollTop(),left:g.pos.left,"border-top":"1px solid #aaa","border-bottom":"1px solid #aaa"})):t.last.move.reorder=!1),$(document).on("mousemove.w2ui-"+t.name,u).on("mouseup.w2ui-"+t.name,c),e.stopPropagation()}})),this.updateToolbar(),this.trigger($.extend(l,{phase:"after"})),0===$(".w2ui-layout").length&&$(window).off("resize.w2ui-"+t.name).on("resize.w2ui-"+t.name,(function(e){null==w2ui[t.name]?$(window).off("resize.w2ui-"+t.name):w2ui[t.name].resize()})),(new Date).getTime()-i}}function u(e){var i=t.last.move;if(i&&-1!=["select","select-column"].indexOf(i.type)&&(i.divX=e.screenX-i.x,i.divY=e.screenY-i.y,!(Math.abs(i.divX)<=1&&Math.abs(i.divY)<=1))){if(t.last.cancelClick=!0,1==t.reorderRows&&t.last.move.reorder){var s,n,l,a=$(t.box).find(".w2ui-grid-records");return"-none-"==(o=(p=$(e.target).parents("tr")).attr("recid"))&&(o="bottom"),o!=i.from&&($("#grid_"+t.name+"_rec_"+i.recid),s=$("#grid_"+t.name+"_rec_"+o),$(t.box).find(".insert-before"),s.addClass("insert-before"),i.lastY=e.screenY,i.to=o,n=s.position(),l=$("#grid_"+t.name+"_ghost_line"),n?l.css({top:n.top+a.scrollTop(),left:i.pos.left,"border-top":"2px solid #769EFC"}):l.css({"border-top":"2px solid transparent"})),void $("#grid_"+t.name+"_ghost").css({top:i.pos.top+i.divY+a.scrollTop(),left:i.pos.left})}i.start&&i.recid&&(t.selectNone(),i.start=!1);var o,d=[];if(null==(o="TR"==e.target.tagName.toUpperCase()?$(e.target).attr("recid"):$(e.target).parents("tr").attr("recid"))){if
1("row"==t.selectType)return;if(t.last.move&&"select"==t.last.move.type)return;var u=parseInt($(e.target).parents("td").attr("col"));if(isNaN(u))t.removeRange("column-selection"),$(t.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected"),$(t.box).find(".w2ui-col-number").removeClass("w2ui-row-selected"),delete i.colRange;else{var c=u+"-"+u;i.column<u&&(c=i.column+"-"+u),i.column>u&&(c=u+"-"+i.column);for(var h=[],p=c.split("-"),f=parseInt(p[0]);f<=parseInt(p[1]);f++)h.push(f);if(i.colRange!=c&&!0!==(r=t.trigger({phase:"before",type:"columnSelect",target:t.name,columns:h,isCancelled:!1})).isCancelled){null==i.colRange&&t.selectNone(),p=c.split("-"),$(t.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected");for(var g=parseInt(p[0]);g<=parseInt(p[1]);g++)$(t.box).find("#grid_"+t.name+"_column_"+g+" .w2ui-col-header").addClass("w2ui-col-selected");$(t.box).find(".w2ui-col-number").not(".w2ui-head").addClass("w2ui-row-selected"),i.colRange=c,t.removeRange("column-selection"),t.addRange({name:"column-selection",range:[{recid:t.records[0].recid,column:p[0]},{recid:t.records[t.records.length-1].recid,column:p[1]}],style:"background-color: rgba(90, 145, 234, 0.1)"})}}}else{var m=t.get(i.recid,!0);if(null==m||t.records[m]&&t.records[m].recid!=i.recid)return;var w=t.get(o,!0);if(null==w)return;var v=parseInt(i.column),y=parseInt("TD"==e.target.tagName.toUpperCase()?$(e.target).attr("col"):$(e.target).parents("td").attr("col"));if(isNaN(v)&&isNaN(y)&&(v=0,y=t.columns.length-1),w<m&&(p=m,m=w,w=p),p="ind1:"+m+",ind2;"+w+",col1:"+v+",col2:"+y,i.range==p)return;i.range=p;for(var b=m;b<=w;b++)if(!(0<t.last.searchIds.length&&-1==t.last.searchIds.indexOf(b)))if("row"!=t.selectType){y<v&&(p=v,v=y,y=p),p=[];for(var x=v;x<=y;x++)t.columns[x].hidden||d.push({recid:t.records[b].recid,column:parseInt(x)})}else d.push(t.records[b].recid);if("row"!=t.selectType){for(var _=t.getSelection(),k=(p=[],0);k<d.length;k++){for(var C=!1,T=0;T<_.length;T++)d[k].recid==_[T].recid&&d[k].column==_[T].column&&(C=!0);C||p.push({recid:d[k].recid,column:d[k].column})}for(t.select(p),p=[],T=0;T<_.length;T++){for(C=!1,k=0;k<d.length;k++)d[k].recid==_[T].recid&&d[k].column==_[T].column&&(C=!0);C||p.push({recid:_[T].recid,column:_[T].column})}t.unselect(p)}else if(t.multiSelect){for(_=t.getSelection(),k=0;k<d.length;k++)-1==_.indexOf(d[k])&&t.select(d[k]);for(T=0;T<_.length;T++)-1==d.indexOf(_[T])&&t.unselect(_[T])}}}}function c(e){var i=t.last.move;if(setTimeout((function(){delete t.last.cancelClick}
1),1),!$(e.target).parents().hasClass(".w2ui-head")&&!$(e.target).hasClass(".w2ui-head")){if(i&&-1!=["select","select-column"].indexOf(i.type)){if(null!=i.colRange&&!0!==r.isCancelled){for(var s=i.colRange.split("-"),n=[],l=0;l<t.records.length;l++){for(var a=[],o=parseInt(s[0]);o<=parseInt(s[1]);o++)a.push(o);n.push({recid:t.records[l].recid,column:a})}t.removeRange("column-selection"),t.trigger($.extend(r,{phase:"after"})),t.select(n)}if(1==t.reorderRows&&t.last.move.reorder){var d=t.trigger({phase:"before",target:t.name,type:"reorderRow",recid:i.from,moveAfter:i.to});if(!0===d.isCancelled)return $("#grid_"+t.name+"_ghost").remove(),$("#grid_"+t.name+"_ghost_line").remove(),t.refresh(),void delete t.last.move;var u=t.get(i.from,!0),c=t.get(i.to,!0);"bottom"==i.to&&(c=t.records.length),s=t.records[u],null!=u&&null!=c&&(t.records.splice(u,1),c<u?t.records.splice(c,0,s):t.records.splice(c-1,0,s)),$("#grid_"+t.name+"_ghost").remove(),$("#grid_"+t.name+"_ghost_line").remove(),t.refresh(),t.trigger($.extend(d,{phase:"after"}))}}delete t.last.move,$(document).off(".w2ui-"+t.name)}}},destroy:function(){var e=this.trigger({phase:"before",target:this.name,type:"destroy"});!0!==e.isCancelled&&($(this.box).off(),"object"==typeof this.toolbar&&this.toolbar.destroy&&this.toolbar.destroy(),0<$(this.box).find("#grid_"+this.name+"_body").length&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-grid w2ui-inactive").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"})))},initColumnOnOff:function(){if(this.show.toolbarColumns){for(var e=this,t='<div class="w2ui-col-on-off"><table><tbody><tr id="grid_'+this.name+'_column_ln_check" onclick="w2ui[\''+e.name+'\'].columnOnOff(event, \'line-numbers\'); event.stopPropagation();"> <td style="width: 30px; text-align: center; padding-right: 3px; color: #888;"> <span class="w2ui-column-check w2ui-icon-'+(e.show.lineNumbers?"check":"empty")+'"></span> </td> <td> <label>'+w2utils.lang("Line #")+"</label> </td></tr>",i=0;i<this.columns.length;i++){var s=this.columns[i],n=this.columns[i].text;!1!==s.hideable&&(!n&&this.columns[i].tooltip&&(n=this.columns[i].tooltip),n=n||"- column "+(parseInt(i)+1)+" -",t+='<tr id="grid_'+this.name+"_column_"+i+'_check" onclick="w2ui[\''+e.name+"'].columnOnOff(event, '"+s.field+'\'); event.stopPropagation();"> <td style="width: 30px; text-align: center; padding-right: 3px; color: #888;"> <span class="w2ui-column-check w2ui-icon-'+(s.hidden?"empty":"check")+'"></span> </td> <td> <label>'+w2utils.stripTags(n)+"</label> </td></tr>")}var l="object"!=typeof this.url?this.url:this.url.get;(l&&e.show.skipRecords||e.show.saveRestoreState)&&(t+='<tr style="pointer-events: none"><td colspan="2"><div style="border-top: 1px solid #ddd;"></div></td></tr>'),l&&e.show.skipRecords&&(t+='<tr><td colspan="2" style="padding: 0px"> <div style="cursor: pointer; padding: 2px 8px; cursor: default">'+w2utils.lang("Skip")+' <input type="text" style="width: 60px" value="'+this.offset+'" onkeydown="if ([48,49,50,51,52,53,54,55,56,57,58,13,8,46,37,39].indexOf(event.keyCode) == -1) { event.preventDefault() }" onkeypress="if (event.keyCode == 13) { w2ui[\''+e.name+"'].skip(this.value); jQuery('.w2ui-overlay')[0].hide(); }\"/> "+w2utils.lang("Records")+" </div></td></tr>"),e.show.saveRestoreState&&(t+='<tr><td colspan="2" onclick="var obj = w2ui[\''+e.name+"']; obj.toolbar.uncheck('w2ui-column-on-off'); obj.stateSave();\"> <div style=\"cursor: pointer; padding: 4px 8px; cursor: default\">"+w2utils.lang("Save Grid State")+'</div></td></tr><tr><td colspan="2" onclick="var obj = w2ui[\''+e.name+"']; obj.toolbar.uncheck('w2ui-column-on-off'); obj.stateReset();\"> <div style=\"cursor: pointer; padding: 4px 8px; cursor: default\">"+w2utils.lang("Restore Default State")+"</div></td></tr>"),t+="</tbody></table></div>",this.toolbar.get("w2ui-column-on-off").html=t}},initColumnDrag:function(e){if(this.columnGroups&&this.columnGroups.length)throw"Draggable columns are not currently supported with column groups.";var t=this,i={};function s(){i.pressed=!1,clearTimeout(i.timeout)}function n(e){i.timeout&&clearTimeout(i.timeout);var s=this;i.pressed=!0,i.timeout=setTimeout((function(){if(i.pressed&&0!==i.numberPreColumnsPresent){var n,r,o,d,u,c=["w2ui-col-number","w2ui-col-expand","w2ui-col-select"].concat(["w2ui-head-last"]);if($(e.originalEvent.target).parents().hasClass("w2ui-head")){for(var h=0,p=c.length;h<p;h++)if($(e.originalEvent.target).parents().hasClass(c[h]))return;if(i.numberPreColumnsPresent=$(t.box).find(".w2ui-head.w2ui-col-number, .w2ui-head.w2ui-col-expand, .w2ui-head.w2ui-col-select").length,i.columnHead=d=$(e.originalEvent.target).parents(".w2ui-head"),i.originalPos=u=parseInt(d.attr("col"),10),!0===(n=t.trigger({type:"columnDragStart",phase:"before",originalEvent:e,origColumnNumber:u,target:d[0]})).isCancelled)return!1;for(r=i.columns=$(t.box).find(".w2ui-head:not(.w2ui-head-last)"),$(document).on("mouseup",a),$(document).on("mousemove",l),i.ghost=$(s).clone(!0),$(i.ghost).find('[col]:not([col="'+i.originalPos+'"]), .w2ui-toolbar, .w2ui-grid-header').remove(),$(i.ghost).find(".w2ui-col-number, .w2ui-col-expand, .w2ui-col-select").remove(),$(i.ghost).find(".w2ui-grid-body").css({top:0}),o=$(i.ghost).find('[col="'+i.originalPos+'"]'),$(document.body).append(i.ghost),$(i.ghost).css({width:0,height:0,margin:0,position:"fixed",zIndex:999999,opacity:0}
1).addClass(".w2ui-grid-ghost").animate({width:o.width(),height:$(t.box).find(".w2ui-grid-body:first").height(),left:e.pageX,top:e.pageY,opacity:.8},0),i.offsets=[],h=0,p=r.length;h<p;h++)i.offsets.push($(r[h]).offset().left);t.trigger($.extend(n,{phase:"after"}))}}}),150)}function l(e){var t,s,n,l,a,r;i.pressed&&(t=e.originalEvent.pageX,s=e.originalEvent.pageY,n=i.offsets,l=$(".w2ui-head:not(.w2ui-head-last)").width(),i.targetInt=Math.max(i.numberPreColumnsPresent,function(e,t,i){if(e<=t[0])return 0;if(e>=t[t.length-1]+i)return t.length;for(var s=0,n=t.length;s<n;s++){var l=t[s],a=t[s+1]||t[s]+i,r=(a-t[s])/2+t[s];if(l<e&&e<=r)return s;if(r<e&&e<=a)return s+1}return intersection}(t,n,l)),function(e){i.marker||i.markerLeft||(i.marker=$('<div class="col-intersection-marker"><div class="top-marker"></div><div class="bottom-marker"></div></div>'),i.markerLeft=$('<div class="col-intersection-marker"><div class="top-marker"></div><div class="bottom-marker"></div></div>')),i.lastInt&&i.lastInt===e||(i.lastInt=e,i.marker.remove(),i.markerLeft.remove(),$(".w2ui-head").removeClass("w2ui-col-intersection"),e>=i.columns.length?($(i.columns[i.columns.length-1]).children("div:last").append(i.marker.addClass("right").removeClass("left")),$(i.columns[i.columns.length-1]).addClass("w2ui-col-intersection")):e<=i.numberPreColumnsPresent?($(i.columns[i.numberPreColumnsPresent]).prepend(i.marker.addClass("left").removeClass("right")).css({position:"relative"}),$(i.columns[i.numberPreColumnsPresent]).prev().addClass("w2ui-col-intersection")):($(i.columns[e]).children("div:last").prepend(i.marker.addClass("left").removeClass("right")),$(i.columns[e]).prev().children("div:last").append(i.markerLeft.addClass("right").removeClass("left")).css({position:"relative"}),$(i.columns[e-1]).addClass("w2ui-col-intersection")))}(i.targetInt),a=t,r=s,$(i.ghost).css({left:a-10,top:r-10}))}function a(e){i.pressed=!1;var s,n,r,o,d=$(".w2ui-grid-ghost"),u=t.trigger({type:"columnDragEnd",phase:"before",originalEvent:e,target:i.columnHead[0]});if(!0===u.isCancelled)return!1;n=t.columns[i.originalPos],r=t.columns,o=$(i.columns[Math.min(i.lastInt,i.columns.length-1)]),(s=i.lastInt<i.columns.length?parseInt(o.attr("col")):r.length)!==i.originalPos+1&&s!==i.originalPos&&o&&o.length?($(i.ghost).animate({top:$(t.box).offset().top,left:o.offset().left,width:0,height:0,opacity:.2},300,(function(){$(this).remove(),d.remove()})),r.splice(s,0,$.extend({},n)),r.splice(r.indexOf(n),1)):($(i.ghost).remove(),d.remove()),$(document).off("mouseup",a),$(document).off("mousemove",l),i.marker&&i.marker.remove(),i={},t.refresh(),t.trigger($.extend(u,{phase:"after",targetColumnNumber:s-1}))}return i.lastInt=null,i.pressed=!1,i.timeout=null,i.columnHead=null,$(t.box).on("mousedown",n),$(t.box).on("mouseup",s),{remove:function(){$(t.box).off("mousedown",n),$(t.box).off("mouseup",s),$(t.box).find(".w2ui-head").removeAttr("draggable"),t.last.columnDrag=!1}}},columnOnOff:function(e,t){var i=$(e.target).parents("tr").find(".w2ui-column-check"),s=this.trigger({phase:"before",target:this.name,type:"columnOnOff",field:t,originalEvent:e});if(!0!==s.isCancelled){for(var n,l=this,a=!(e.shiftKey||e.metaKey||e.ctrlKey||$(e.target).hasClass("w2ui-column-check")),r=l.find({"w2ui.expanded":!0},!0),o=0;o<r.length;o++){var d=this.records[o].w2ui;d&&!Array.isArray(d.children)&&(this.records[o].w2ui.expanded=!1)}"line-numbers"==t?(this.show.lineNumbers=!this.show.lineNumbers,this.show.lineNumbers?i.addClass("w2ui-icon-check").removeClass("w2ui-icon-empty"):i.addClass("w2ui-icon-empty").removeClass("w2ui-icon-check"),this.refreshBody(),this.resizeRecords()):(n=this.getColumn(t)).hidden?(i.addClass("w2ui-icon-check").removeClass("w2ui-icon-empty"),setTimeout((function(){l.showColumn(n.field)}),a?0:50)):(i.addClass("w2ui-icon-empty").removeClass("w2ui-icon-check"),setTimeout((function(){l.hideColumn(n.field)}),a?0:50)),a&&setTimeout((function(){$().w2overlay({name:l.name+"_toolbar"})}),40),this.trigger($.extend(s,{phase:"after"}))}},scrollToColumn:function(e){if(null!=e){for(var t=0,i=!1,s=0;s<this.columns.length;s++){var n=this.columns[s];if(n.field==e){i=!0;break}n.frozen||n.hidden||(t+=parseInt(n.sizeCalculated?n.sizeCalculated:n.size))}i&&(this.last.scrollLeft=t+1,this.scroll())}},initToolbar:function(){if(null==this.toolbar.render){var e,t=this.toolbar.items||[];if(this.toolbar.items=[],this.toolbar=$().w2toolbar($.extend(!0,{},this.toolbar,{name:this.name+"_toolbar",owner:this})),this.show.toolbarReload&&this.toolbar.items.push($.extend(!0,{},this.buttons.reload)),this.show.toolbarColumns&&this.toolbar.items.push($.extend(!0,{},this.buttons.columns)),(this.show.toolbarReload||this.show.toolbarColumns)&&this.toolbar.items.push({type:"break",i
1d:"w2ui-break0"}),this.show.toolbarInput&&(e='<div class="w2ui-toolbar-search"><table cellpadding="0" cellspacing="0"><tbody><tr> <td>'+this.buttons.search.html+'</td> <td> <input type="text" id="grid_'+this.name+'_search_all" class="w2ui-search-all" tabindex="-1" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" placeholder="'+w2utils.lang(this.last.label)+'" value="'+this.last.search+'" onfocus="var grid = w2ui[\''+this.name+'\']; clearTimeout(grid.last.kbd_timer); grid.searchShowFields(true); grid.searchClose()" onkeydown="if (event.keyCode == 13 && w2utils.isIE) this.onchange();" onchange=" var grid = w2ui[\''+this.name+"']; var val = this.value; var sel = jQuery(this).data('selected'); var fld = jQuery(this).data('w2field'); if (fld) val = fld.clean(val); if (fld && fld.type == 'list' && sel && typeof sel.id == 'undefined') { grid.searchReset(); } else { grid.search(grid.last.field, val); } \"/> </td> <td> <div class=\"w2ui-search-clear\" id=\"grid_"+this.name+'_searchClear" onclick="var obj = w2ui[\''+this.name+'\']; obj.searchReset();" style="display: none" >  </div> </td></tr></tbody></table></div>',this.toolbar.items.push({type:"html",id:"w2ui-search",html:e})),this.show.toolbarSearch&&this.multiSearch&&0<this.searches.length&&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&&Array.isArray(t)&&-1==t.map((function(e){return e.id})).indexOf(this.buttons.add.id)&&this.toolbar.items.push($.extend(!0,{},this.buttons.add)),this.show.toolbarEdit&&Array.isArray(t)&&-1==t.map((function(e){return e.id})).indexOf(this.buttons.edit.id)&&this.toolbar.items.push($.extend(!0,{},this.buttons.edit)),this.show.toolbarDelete&&Array.isArray(t)&&-1==t.map((function(e){return e.id})).indexOf(this.buttons.delete.id)&&this.toolbar.items.push($.extend(!0,{},this.buttons.delete)),this.show.toolbarSave&&Array.isArray(t)&&-1==t.map((function(e){return e.id})).indexOf(this.buttons.save.id)&&((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))),t)for(var i=0;i<t.length;i++)this.toolbar.items.push(t[i]);var s=this;this.toolbar.on("click",(function(e){var t=s.trigger({phase:"before",type:"toolbar",target:e.target,originalEvent:e});if(!0!==t.isCancelled){var i=e.target;switch(i){case"w2ui-reload":if(!0===(n=s.trigger({phase:"before",type:"reload",target:s.name})).isCancelled)return!1;s.reload(),s.trigger($.extend(n,{phase:"after"}));break;case"w2ui-column-on-off":s.initColumnOnOff(),s.initResize(),s.resize();break;case"w2ui-search-advanced":this.get(i).checked?s.searchClose():s.searchOpen(),s.toolbar.tooltipHide("w2ui-search-advanced"),e.preventDefault();break;case"w2ui-add":if(!0===(n=s.trigger({phase:"before",target:s.name,type:"add",recid:null})).isCancelled)return!1;s.trigger($.extend(n,{phase:"after"})),setTimeout((function(){$().w2tag()}),20);break;case"w2ui-edit":var n,l=s.getSelection(),a=null;if(1==l.length&&(a=l[0]),!0===(n=s.trigger({phase:"before",target:s.name,type:"edit",recid:a})).isCancelled)return!1;s.trigger($.extend(n,{phase:"after"})),setTimeout((function(){$().w2tag()}),20);break;case"w2ui-delete":s.delete();break;case"w2ui-save":s.save()}s.trigger($.extend(t,{phase:"after"}))}})),this.toolbar.on("refresh",(function(e){var t;"w2ui-search"==e.target&&(t=s.searchData,setTimeout((function(){s.initAllField(s.last.field,1==t.length?t[0].value:null)}),1))}))}},initResize:function(){var e=this;$(this.box).find(".w2ui-resizer").off(".grid-col-resize").on("click.grid-col-resize",(function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,e.preventDefault&&e.preventDefault()})).on("mousedown.grid-col-resize",(function(t){t=t||window.event,e.resizing=!0,e.last.tmp={x:t.screenX,y:t.screenY,gx:t.screenX,gy:t.screenY,col:parseInt($(this).attr("name"))}
1,e.last.tmp.tds=$("#grid_"+e.name+"_body table tr:first-child td[col="+e.last.tmp.col+"]"),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,t.preventDefault&&t.preventDefault();for(var i=0;i<e.columns.length;i++)e.columns[i].hidden||(null==e.columns[i].sizeOriginal&&(e.columns[i].sizeOriginal=e.columns[i].size),e.columns[i].size=e.columns[i].sizeCalculated);var s,n={phase:"before",type:"columnResize",target:e.name,column:e.last.tmp.col,field:e.columns[e.last.tmp.col].field};n=e.trigger($.extend(n,{resizeBy:0,originalEvent:t})),$(document).off(".grid-col-resize").on("mousemove.grid-col-resize",(function(t){var i;1==e.resizing&&(t=t||window.event,!0!==(n=e.trigger($.extend(n,{resizeBy:t.screenX-e.last.tmp.gx,originalEvent:t}))).isCancelled?(e.last.tmp.x=t.screenX-e.last.tmp.x,e.last.tmp.y=t.screenY-e.last.tmp.y,i=parseInt(e.columns[e.last.tmp.col].size)+e.last.tmp.x+"px",e.columns[e.last.tmp.col].size=i,s&&clearTimeout(s),s=setTimeout((function(){e.resizeRecords(),e.scroll()}),100),e.last.tmp.tds.css({width:i}),e.last.tmp.x=t.screenX,e.last.tmp.y=t.screenY):n.isCancelled=!1)})).on("mouseup.grid-col-resize",(function(t){delete e.resizing,$(document).off(".grid-col-resize"),e.resizeRecords(),e.scroll(),e.trigger($.extend(n,{phase:"after",originalEvent:t}))}))})).on("dblclick.grid-col-resize",(function(t){var i=parseInt($(this).attr("name")),s=e.columns[i],n=0;if(!1===s.autoResize)return!0;t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,t.preventDefault&&t.preventDefault(),$('.w2ui-grid-records td[col="'+i+'"] > div',e.box).each((function(){var e=this.offsetWidth-this.scrollWidth;e<n&&(n=e-3)}));var l={phase:"before",type:"columnAutoResize",target:e.name,column:s,field:s.field};!0!==(l=e.trigger($.extend(l,{resizeBy:Math.abs(n),originalEvent:t}))).isCancelled?(n<0&&(s.size=Math.min(parseInt(s.size)+Math.abs(n),s.max||1/0)+"px",e.resizeRecords(),e.resizeRecords(),e.scroll()),e.trigger($.extend(l,{phase:"after",originalEvent:t}))):l.isCancelled=!1})).each((function(e,t){var i=$(t).parent();$(t).css({height:i.height(),"margin-left":i.width()-3+"px"})}))}
1,resizeBoxes:function(){var e=$("#grid_"+this.name+"_header"),t=$("#grid_"+this.name+"_toolbar"),i=$("#grid_"+this.name+"_fsummary"),s=$("#grid_"+this.name+"_summary"),n=$("#grid_"+this.name+"_footer"),l=$("#grid_"+this.name+"_body");this.show.header&&e.css({top:"0px",left:"0px",right:"0px"}),this.show.toolbar&&t.css({top:0+(this.show.header?w2utils.getSize(e,"height"):0)+"px",left:"0px",right:"0px"}),0<this.summary.length&&(i.css({bottom:0+(this.show.footer?w2utils.getSize(n,"height"):0)+"px"}),s.css({bottom:0+(this.show.footer?w2utils.getSize(n,"height"):0)+"px",right:"0px"})),this.show.footer&&n.css({bottom:"0px",left:"0px",right:"0px"}),l.css({top:0+(this.show.header?w2utils.getSize(e,"height"):0)+(this.show.toolbar?w2utils.getSize(t,"height"):0)+"px",bottom:0+(this.show.footer?w2utils.getSize(n,"height"):0)+(0<this.summary.length?w2utils.getSize(s,"height"):0)+"px",left:"0px",right:"0px"})},resizeRecords:function(){var e=this;$(this.box).find(".w2ui-empty-record").remove();var t=$(this.box),i=$(this.box).find("> div.w2ui-grid-box"),s=$("#grid_"+this.name+"_header"),n=$("#grid_"+this.name+"_toolbar"),l=$("#grid_"+this.name+"_summary"),a=$("#grid_"+this.name+"_fsummary"),r=$("#grid_"+this.name+"_footer"),o=$("#grid_"+this.name+"_body"),d=$("#grid_"+this.name+"_columns"),u=$("#grid_"+this.name+"_fcolumns"),c=$("#grid_"+this.name+"_records"),h=$("#grid_"+this.name+"_frecords"),p=$("#grid_"+this.name+"_scroll1"),f=8*String(this.total).length+10;f<34&&(f=34),null!=this.lineNumberWidth&&(f=this.lineNumberWidth);for(var g,m=!1,w=!1,v=0,y=0;y<e.columns.length;y++)e.columns[y].frozen||e.columns[y].hidden||(v+=parseInt(e.columns[y].sizeCalculated?e.columns[y].sizeCalculated:e.columns[y].size));c.width()<v&&(m=!0),o.height()-d.height()<$(c).find(">table").height()+(m?w2utils.scrollBarSize():0)&&(w=!0),this.fixedBody?(g=i.height()-(this.show.header?w2utils.getSize(s,"height"):0)-(this.show.toolbar?w2utils.getSize(n,"height"):0)-("none"!=l.css("display")?w2utils.getSize(l,"height"):0)-(this.show.footer?w2utils.getSize(r,"height"):0),o.css("height",g)):(g=w2utils.getSize(d,"height")+w2utils.getSize($("#grid_"+e.name+"_records table"),"height")+(m?w2utils.scrollBarSize():0),e.height=g+w2utils.getSize(i,"+height")+(e.show.header?w2utils.getSize(s,"height"):0)+(e.show.toolbar?w2utils.getSize(n,"height"):0)+("none"!=l.css("display")?w2utils.getSize(l,"height"):0)+(e.show.footer?w2utils.getSize(r,"height"):0),i.css("height",e.height),o.css("height",g),t.css("height",w2utils.getSize(i,"height")+w2utils.getSize(t,"+height")));var b=this.records.length,x="object"!=typeof this.url?this.url:this.url.get;if(0==this.searchData.length||x||(b=this.last.searchIds.length),this.fixedBody||(w=!1),m||w?(d.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show(),c.css({top:(0<this.columnGroups.length&&this.show.columns?1:0)+w2utils.getSize(d,"height")+"px","-webkit-overflow-scrolling":"touch","overflow-x":m?"auto":"hidden","overflow-y":w?"auto":"hidden"})):(d.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").hide(),c.css({top:(0<this.columnGroups.length&&this.show.columns?1:0)+w2utils.getSize(d,"height")+"px",overflow:"hidden"}),0<c.length&&(this.last.scrollTop=0,this.last.scrollLeft=0)),m?(h.css("margin-bottom",w2utils.scrollBarSize()),p.show()):(h.css("margin-bottom",0),p.hide()),h.css({overflow:"hidden",top:c.css("top")}),this.show.emptyRecords&&!w){var _=Math.floor(c.height()/this.recordHeight)-1,k=0;if(c[0]&&(k=c[0].scrollHeight-_*this.recordHeight),k>=this.recordHeight&&(k-=this.recordHeight,_++),this.fixedBody){for(var C=b;C<_;C++)T(C,this.recordHeight,this);T(_,k,this)}}function T(e,t,i){var s,n="",l="";n+='<tr class="'+(e%2?"w2ui-even":"w2ui-odd")+' w2ui-empty-record" recid="-none-" style="height: '+t+'px">',l+='<tr class="'+(e%2?"w2ui-even":"w2ui-odd")+' w2ui-empty-record" recid="-none-" style="height: '+t+'px">',i.show.lineNumbers&&(n+='<td class="w2ui-col-number"></td>'),i.show.selectColumn&&(n+='<td class="w2ui-grid-data w2ui-col-select"></td>'),i.show.expandColumn&&(n+='<td class="w2ui-grid-data w2ui-col-expand"></td>'),l+='<td class="w2ui-grid-data-spacer" col="start" style="border-right: 0"></td>',i.show.orderColumn&&(l+='<td class="w2ui-grid-data w2ui-col-order" col="order"></td>');for(var a=0;a<i.columns.length;a++){var r=i.columns[a];(r.hidden||a<i.last.colStart||a>i.last.colEnd)&&!r.frozen||(s='<td class="w2ui-grid-data" '+(null!=r.attr?r.attr:"")+' col="'+a+'"></td>',r.frozen?n+=s:l+=s)}n+='<td class="w2ui-grid-data-last"></td> </tr>',l+='<td class="w2ui-grid-data-last" col="end"></td> </tr>',$("#grid_"+i.name+"_frecords > table").append(n),$("#grid_"+i.name+"_records > table").append(l)}if(0<o.length){var S=parseInt(o.width())-(w?w2utils.scrollBarSize():0)-(this.show.lineNumbers?f:0)-(this.show.selectColumn?26:0)-(this.show.expandColumn?26:0)-1,D=S,O=0,z=!1;for(y=0;y<this.columns.length;y++)0<(E=this.columns[y]).gridMinWidth&&(E.gridMinWidth>D&&!0!==E.hidden&&(z=E.hidden=!0),E.gridMinWidth<D&&!0===E.hidden&&(z=!(E.hidden=!1)));if(!0===z)return void this.refresh();for(y=0;y<this.columns.length;y++)(E=this.columns[y]).hidden||("px"==String(E.size).substr(String(E.size).length-2).toLowerCase()?(S-=parseFloat(E.size),this.columns[y].sizeCalculated=E.size,this.columns[y].sizeType="px"):(O+=parseFloat(E.size),this.columns[y].sizeType="%",delete E.sizeCorrected));if(100!=O&&0<O)for(y=0;y<this.columns.length;y++)(E=this.columns[y]).hidden||"%"==E.sizeType&&(E.sizeCorrected=Math.round(100*parseFloat(E.size)*100/O)/100+"%");for(y=0;y<this.columns.length;y++)(E=this.columns[y]).hidden||"%"==E.sizeType&&(null!=this.columns[y].sizeCorrected?this.columns[y].sizeCalculated=Math.floor(S*parseFloat(E.sizeCorrected)/100)-1+"px":this.columns[y].sizeCalculated=Math.floor(S*parseFloat(E.size)/100)-1+"px")}var I=0;for(y=0;y<this.columns.length;y++)(E=this.columns[y]).hidden||(null==E.min&&(E.min=20),parseInt(E.sizeCalculated)<parseInt(E.min)&&(E.sizeCalculated=E.min+"px"),parseInt(E.sizeCalculated)>parseInt(E.max)&&(E.sizeCalculated=E.max+"px"),I+=parseInt(E.sizeCalculated));var E,R=parseInt(D)-parseInt(I);if(0<R&&0<O)for(y=0;;)if(null!=(E=this.columns[y]))if(E.hidden||"px"==E.sizeType)y++;else{if(E.sizeCalculated=parseInt(E.sizeCalculated)+1+"px",0==--R)break;y++}else y=0;
1else 0<R&&d.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show();var F=1;for(this.show.lineNumbers&&(F+=f),this.show.selectColumn&&(F+=26),this.show.expandColumn&&(F+=26),y=0;y<this.columns.length;y++)this.columns[y].hidden||this.columns[y].frozen&&(F+=parseInt(this.columns[y].sizeCalculated));u.css("width",F),h.css("width",F),a.css("width",F),p.css("width",F),d.css("left",F),c.css("left",F),l.css("left",F),d.find("> table > tbody > tr:nth-child(1) td").add(u.find("> table > tbody > tr:nth-child(1) td")).each((function(t,i){$(i).hasClass("w2ui-col-number")&&$(i).css("width",f);var s=$(i).attr("col");if(null!=s){if("start"==s){for(var n=0,l=0;l<e.last.colStart;l++)!e.columns[l]||e.columns[l].frozen||e.columns[l].hidden||(n+=parseInt(e.columns[l].sizeCalculated));$(i).css("width",n+"px")}e.columns[s]&&$(i).css("width",e.columns[s].sizeCalculated)}if($(i).hasClass("w2ui-head-last"))if(e.last.colEnd+1<e.columns.length){for(n=0,l=e.last.colEnd+1;l<e.columns.length;l++)!e.columns[l]||e.columns[l].frozen||e.columns[l].hidden||(n+=parseInt(e.columns[l].sizeCalculated));$(i).css("width",n+"px")}else $(i).css("width",w2utils.scrollBarSize()+(0<R&&0===O?R:0)+"px")})),3==d.find("> table > tbody > tr").length&&d.find("> table > tbody > tr:nth-child(1) td").add(u.find("> table > tbody > tr:nth-child(1) td")).html("").css({height:"0px",border:"0px",padding:"0px",margin:"0px"}),c.find("> table > tbody > tr:nth-child(1) td").add(h.find("> table > tbody > tr:nth-child(1) td")).each((function(t,i){$(i).hasClass("w2ui-col-number")&&$(i).css("width",f);var s=$(i).attr("col");if(null!=s){if("start"==s){for(var n=0,l=0;l<e.last.colStart;l++)!e.columns[l]||e.columns[l].frozen||e.columns[l].hidden||(n+=parseInt(e.columns[l].sizeCalculated));$(i).css("width",n+"px")}e.columns[s]&&$(i).css("width",e.columns[s].sizeCalculated)}if($(i).hasClass("w2ui-grid-data-last")&&0===$(i).parents(".w2ui-grid-frecords").length)if(e.last.colEnd+1<e.columns.length){for(n=0,l=e.last.colEnd+1;l<e.columns.length;l++)!e.columns[l]||e.columns[l].frozen||e.columns[l].hidden||(n+=parseInt(e.columns[l].sizeCalculated));$(i).css("width",n+"px")}else $(i).css("width",(0<R&&0===O?R:0)+"px")})),l.find("> table > tbody > tr:nth-child(1) td").add(a.find("> table > tbody > tr:nth-child(1) td")).each((function(t,i){$(i).hasClass("w2ui-col-number")&&$(i).css("width",f);var s=$(i).attr("col");if(null!=s){if("start"==s){for(var n=0,l=0;l<e.last.colStart;l++)!e.columns[l]||e.columns[l].frozen||e.columns[l].hidden||(n+=parseInt(e.columns[l].sizeCalculated));$(i).css("width",n+"px")}e.columns[s]&&$(i).css("width",e.columns[s].sizeCalculated)}$(i).hasClass("w2ui-grid-data-last")&&0===$(i).parents(".w2ui-grid-frecords").length&&$(i).css("width",w2utils.scrollBarSize()+(0<R&&0===O?R:0)+"px")})),this.initResize(),this.refreshRanges(),(this.last.scrollTop||this.last.scrollLeft)&&0<c.length&&(d.prop("scrollLeft",this.last.scrollLeft),c.prop("scrollTop",this.last.scrollTop),c.prop("scrollLeft",this.last.scrollLeft))},getSearchesHTML:function(){for(var e=this,t='<table cellspacing="0"><tbody>',i=!1,s=0;s<this.searches.length;s++){var n=this.searches[s];if(n.type=String(n.type).toLowerCase(),!n.hidden){var l="";0==i&&(l='<button type="button" class="w2ui-btn close-btn" onclick="obj = w2ui[\''+this.name+"']; if (obj) obj.searchClose()\">X</button>",i=!0),null==n.inTag&&(n.inTag=""),null==n.outTag&&(n.outTag=""),null==n.style&&(n.style=""),null==n.type&&(n.type="text"),null==n.label&&null!=n.caption&&(console.log("NOTICE: grid search.caption property is deprecated, please use search.label. Search ->",n),n.label=n.caption);var a='<select id="grid_'+this.name+"_operator_"+s+'" class="w2ui-input" onchange="w2ui[\''+this.name+"'].initOperator(this, "+s+')">'+function(t,i){var s="",n=e.operators[e.operatorsMap[t]];null!=i&&(n=i);for(var l=0;l<n.length;l++){var a=n[l],r=a;Array.isArray(a)?(r=a[1],a=a[0],null==r&&(r=a)):$.isPlainObject(a)&&(r=a.text,a=a.oper),s+='<option value="'+a+'">'+w2utils.lang(r)+"</option>\n"}return s}(n.type,n.operators)+"</select>";switch(t+='<tr> <td class="close-btn">'+l+'</td> <td class="caption">'+(n.label||"")+'</td> <td class="operator">'+a+'</td> <td class="value">',n.type){case"text":case"alphanumeric":case"hex":case"color":case"list":case"combo":case"enum":var r="width: 250px;";-1!=["hex","color"].indexOf(n.type)&&(r="width: 90px;"),t+='<input rel="search" type="text" id="grid_'+this.name+"_field_"+s+'" name="'+n.field+'" class="w2ui-input" style="'+r+n.style+'" '+n.inTag+"/>";break;case"int":case"float":case"money":case"currency":case"percent":case"date":case"time":case"datetime":r="width: 90px;","datetime"==n.type&&(r="width: 140px;"),t+='<input rel="search" type="text" class="w2ui-input" style="'+r+n.style+'" id="grid_'+this.name+"_field_"+s+'" name="'+n.field+'" '+n.inTag+'/><span id="grid_'+this.name+"_range_"+s+'" style="display: none"> -  <input rel="search" type="text" class="w2ui-input" style="'+r+n.style+'" id="grid_'+this.name+"_field2_"+s+'" name="'+n.field+'" '+n.inTag+"/></span>";break;case"select":t+='<select rel="search" class="w2ui-input" style="'+n.style+'" id="grid_'+this.name+"_field_"+s+'" name="'+n.field+'" '+n.inTag+"></select>"}t+=n.outTag+" </td></tr>"}}return t+'<tr> <td colspan="4" class="actions"> <div> <button type="button" class="w2ui-btn" onclick="obj = w2ui[\''+this.name+"']; if (obj) { obj.searchReset(); }\">"+w2utils.lang("Reset")+'</button> <button type="button" class="w2ui-btn w2ui-btn-blue" onclick="obj = w2ui[\''+this.name+"']; if (obj) { obj.search(); }\">"+w2utils.lang("Search")+"</button> </div> </td></tr></tbody></table>"},initOperator:function(e,t){var i=this.searches[t],s=$("#grid_"+this.name+"_range_"+t),n=$("#grid_"+this.name+"_field_"+t),l=n.parent().find("span input");switch(n.show(),s.hide(),$(e).val()){case"between":s.show(),l.w2field(i.type,i.options);break;case"not null":case"null":n.hide(),n.val("1"),n.change()}},initSearches:function(){for(var e=this,t=0;t<this.searches.length;t++){var i=this.searches[t],s=this.getSearchData(i.field);i.type=String(i.type).toLowerCase();var n=e.operators[e.operatorsMap[i.type]];i.operators&&(n=i.operators);var l=n[0];$.isPlainObject(l)&&(l=l.oper),"object"!=typeof i.options&&(i.options={}),"text"==i.type&&(l=this.textSearch);for(var a=0;a<n.length;a++){var r=n[a];if($.isPlainObject(r)&&(r=r.oper),i.operator==r){l=i.operator;break}}switch(i.type){case"text":case"alphanumeric":$("#grid_"+this.name+"_field_"+t).w2field(i.type,i.options);break;case"int":case"float":case"hex":case"color":case"money":case"currency":case"percent":case"date":case"time":case"datetime":$("#grid_"+this.name+"_field_"+t).w2field(i.type,i.options),$("#grid_"+this.name+"_field2_"+t).w2field(i.type,i.options),setTimeout((function(){$("#grid_"+e.n
1ame+"_field_"+t).keydown(),$("#grid_"+e.name+"_field2_"+t).keydown()}),1);break;case"list":case"combo":case"enum":var o=i.options;"list"==i.type&&(o.selected={}),"enum"==i.type&&(o.selected=[]),s&&(o.selected=s.value),$("#grid_"+this.name+"_field_"+t).w2field(i.type,$.extend({openOnFocus:!0},o)),s&&null!=s.text&&$("#grid_"+this.name+"_field_"+t).data("selected",{id:s.value,text:s.text});break;case"select":for(o='<option value="">--</option>',a=0;a<i.options.items.length;a++){var d,u,c=i.options.items[a];$.isPlainObject(i.options.items[a])?(d=c.id,u=c.text,null==d&&null!=c.value&&(d=c.value),null==u&&null!=c.text&&(u=c.text),null==d&&(d=""),o+='<option value="'+d+'">'+u+"</option>"):o+='<option value="'+c+'">'+c+"</option>"}$("#grid_"+this.name+"_field_"+t).html(o)}null!=s?("int"==s.type&&-1!=["in","not in"].indexOf(s.operator)&&$("#grid_"+this.name+"_field_"+t).w2field("clear").val(s.value),$("#grid_"+this.name+"_operator_"+t).val(s.operator).trigger("change"),$.isArray(s.value)?-1!=["in","not in"].indexOf(s.operator)?$("#grid_"+this.name+"_field_"+t).val(s.value).trigger("change"):($("#grid_"+this.name+"_field_"+t).val(s.value[0]).trigger("change"),$("#grid_"+this.name+"_field2_"+t).val(s.value[1]).trigger("change")):null!=s.value&&$("#grid_"+this.name+"_field_"+t).val(s.value).trigger("change")):$("#grid_"+this.name+"_operator_"+t).val(l).trigger("change")}$("#w2ui-overlay-"+this.name+"-searchOverlay .w2ui-grid-searches *[rel=search]").on("keypress",(function(t){13==t.keyCode&&(e.search(),$().w2overlay({name:e.name+"-searchOverlay"}))}))},getColumnsHTML:function(){var e,t,i,s,n=this,l="",a="";return this.show.columnHeaders&&(a=0<this.columnGroups.length?(e=r(!0),t=function(){var e="<tr>",t="<tr>",i="",s=n.columnGroups.length-1;null==n.columnGroups[s].text&&null!=n.columnGroups[s].caption&&(console.log("NOTICE: grid columnGroup.caption property is deprecated, please use columnGroup.text. Group -> ",n.columnGroups[s]),n.columnGroups[s].text=n.columnGroups[s].caption),""!=n.columnGroups[n.columnGroups.length-1].text&&n.columnGroups.push({text:""}),n.show.lineNumbers&&(e+='<td class="w2ui-head w2ui-col-number"> <div style="height: '+(n.recordHeight+1)+'px"> </div></td>'),n.show.selectColumn&&(e+='<td class="w2ui-head w2ui-col-select"> <div style="height: 25px"> </div></td>'),n.show.expandColumn&&(e+='<td class="w2ui-head w2ui-col-expand"> <div style="height: 25px"> </div></td>');var l=0;t+='<td id="grid_'+n.name+'_column_start" class="w2ui-head" col="start" style="border-right: 0"></td>',n.show.orderColumn&&(t+='<td class="w2ui-head w2ui-col-order" col="order"> <div style="height: 25px"> </div></td>');for(var a=0;a<n.columnGroups.length;a++){var r=n.columnGroups[a],o=n.columns[l];null!=r.colspan&&(r.span=r.colspan),null!=r.span&&r.span==parseInt(r.span)||(r.span=1),null==o.text&&null!=o.caption&&(console.log("NOTICE: grid column.caption property is deprecated, please use column.text. Column ->",o),o.text=o.caption);for(var d=0,u=l;u<l+r.span;u++)n.columns[u]&&!n.columns[u].hidden&&d++;if(a==n.columnGroups.length-1&&(d=100),!(d<=0))if(!0===r.master){for(var c="",h=0;h<n.sortData.length;h++)n.sortData[h].field==o.field&&("asc"===(n.sortData[h].direction||"").toLowerCase()&&(c="w2ui-sort-up"),"desc"===(n.sortData[h].direction||"").toLowerCase()&&(c="w2ui-sort-down"));var p="";!1!==o.resizable&&(p='<div class="w2ui-resizer" name="'+l+'"></div>');var f="function"==typeof o.text?o.text(o):o.text;i='<td id="grid_'+n.name+"_column_"+l+'" class="w2ui-head '+c+'" col="'+l+'" rowspan="2" colspan="'+d+'" oncontextmenu = "w2ui[\''+n.name+"'].contextMenu(null, "+l+', event);" onclick="w2ui[\''+n.name+"'].columnClick('"+o.field+"', event);\" ondblclick=\"w2ui['"+n.name+"'].columnDblClick('"+o.field+"', event);\">"+p+' <div class="w2ui-col-group w2ui-col-header '+(c?"w2ui-col-sorted":"")+'"> <div class="'+c+'"></div>'+(f||" ")+" </div></td>",o&&o.frozen?e+=i:t+=i}else{var g="function"==typeof r.text?r.text(r):r.text;i='<td id="grid_'+n.name+"_column_"+l+'" class="w2ui-head" col="'+l+'" colspan="'+d+'"> <div class="w2ui-col-group">'+(g||" ")+" </div></td>",o&&o.frozen?e+=i:t+=i}l+=r.span}return[e+="<td></td></tr>",t+='<td id="grid_'+n.name+'_column_end" class="w2ui-head" col="end"></td></tr>']}(),i=r(!1),l=e[0]+t[0]+i[0],e[1]+t[1]+i[1]):(l=(s=r(!0))[0],s[1])),[l,a];function r(e){var t="<tr>",i="<tr>";n.show.lineNumbers&&(t+='<td class="w2ui-head w2ui-col-number" onclick="w2ui[\''+n.name+"'].columnClick('line-number', event);\" ondblclick=\"w2ui['"+n.name+"'].columnDblClick('line-number', event);\"> <div>#</div></td>"),n.show.selectColumn&&(t+='<td class="w2ui-head w2ui-col-select" onclick="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;"> <div> <input type="checkbox" id="grid_'+n.name+'_check_all" tabindex="-1" style="'+(0==n.multiSelect?"display: none;":"")+'" onmousedown="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;" onclick="var grid = w2ui[\''+n.name+"']; if (this.checked) grid.selectAll(); else grid.selectNone(); if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; clearTimeout(grid.last.kbd_timer); /* keep focus */ \"/> </div></td>"),n.show.expandColumn&&(t+='<td class="w2ui-head w2ui-col-expand"> <div> </div></td>');var s,l=0,a=0;i+='<td id="grid_'+n.name+'_column_start" class="w2ui-head" col="start" style="border-right: 0"></td>',n.show.orderColumn&&(i+='<td class="w2ui-head w2ui-col-order" col="order"> <div> </div></td>');for(var r=0;r<n.columns.length;r++){var o,d=n.columns[r];null==d.text&&null!=d.caption&&(console.log("NOTICE: grid column.caption property is deprecated, please use column.text. Column -> ",d),d.text=d.caption),null==d.size&&(d.size="100%"),r==a&&(a+=(s=n.columnGroups[l++]||{}).span),(r<n.last.colStart||r>n.last.colEnd)&&!d.frozen||d.hidden||!0===s.master&&!e||(o=n.getColumnCellHTML(r),d&&d.frozen?t+=o:i+=o)}return t+='<td class="w2ui-head w2ui-head-last"><div> </div></td>',i+='<td class="w2ui-head w2ui-head-last" col="end"><div> </div></td>',[t+="</tr>",i+="</tr>"]}},getColumnCellHTML:function(e){var t=this.columns[e];if(null==t)return"";for(var i=!this.reorderColumns||this.columnGroups&&this.columnGroups.length?"":" w2ui-reorder-cols-head ",s="",n=0;n<this.sortData.length;n++)this.sortData[n].field==t.field&&("asc"===(this.sortData[n].direction||"").toLowerCase()&&(s="w2ui-sort-up"),"desc"===(this.sortData[n].direction||"").toLowerCase()&&(s="w2ui-sort-down"));var l=this.last.selection.columns,a=!1;for(var r in l)for(n=0;n<l[r].length;n++)l[r][n]==e&&(a=!0);var o="function"==typeof t.text?t.text(t):t.text;return'<td id="grid_'+this.name+"_column_"+e+'" col="'+e+'" class="w2ui-head '+s+i+'" '+("normal"==this.columnTooltip&&t.tooltip?'title="'+t.tooltip+'" ':"")+" onmouseEnter = \"w2ui['"+this.name+"'].columnTooltipShow('"+e+"', event);\" onmouseLeave = \"w2ui['"+this.name+"'].columnTooltipHide('"+e+"', event);\" oncontextmenu = \"w2ui['"+this.name+"'].contextMenu(null, "+e+', event);" onclick="w2ui[\''+this.name+"'].columnClick('"+t.field+"', event);\" ondblclick=\"w2ui['"+this.name+"'].columnDblClick('"+t.field+"', event);\">"+(!1!==t.resizable?'<div class="w2ui-resizer" name="'+e+'"></div>':"")+' <div class="w2ui-col-header '+(s?"w2ui-col-sorted":"")+" "+(a?"w2ui-col-selected":"")+'"> <div class="'+s+'"></div>'+(o||" ")+" </div></td>"},columnTooltipShow:function(e){var t,i,s;"normal"!=this.columnTooltip&&(t=$(this.box).find("#grid_"+this.name+"_column_"+e),i=this.columns[e],s=this.columnTooltip,t.prop("_mouse_over",!0),setTimeout((function(){!0===t.prop("_mouse_over")&&!0!==t.prop("_mouse_tooltip")&&(t.prop("_mouse_tooltip",!0),t.w2tag(i.tooltip,{position:s,top:5}))}),1))},columnTooltipHide:function(e){var t;"normal"!=this.columnTooltip&&(t=$(this.box).find("#grid_"+this.name+"_column_"+e),this.columns[e],t.removeProp("_mouse_over"),setTimeout((function(){!0!==t.prop("_mouse_over")&&!0===t.prop("_mouse_tooltip")&&(t.removeProp("_mouse_tooltip"),t.w2tag())}),1))},getRecordsHTML:function(){var e=this.records.length,t="object"!=typeof this.url?this.url:this.url.get;0==this.searchData.length||t||(e=this.last.searchIds.length),e>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start;var i=$("#grid_"+this.name+"_records"),s=Math.floor((i.height()||0)/this.recordHeight)+this.last.show_extra+1;(!this.fixedBody||e<s)&&(s=e);var n=this.getRecordHTML(-1,0),l="<table><tbody>"+n[0],a="<table><tbody>"+n[1];l+='<tr id="grid_'+this.name+'_frec_top" line="top" style="height: 0px"> <td colspan="2000"></td></tr>',a+='<tr id="grid_'+this.name+'_rec_top" line="top" style="height: 0px"> <td colspan="2000"></td></tr>';for(var r=0;r<s;r++)l+=(n=this.getRecordHTML(r,r+1))[0],a+=n[1];var o=(e-s)*this.recordHeight;return l+='<tr id="grid_'+this.name+'_frec_bottom" rec="bottom" line="bottom" style="height: '+o+'px; vertical-align: top"> <td colspan="2000" style="border-right: 1px solid #D6D5D7;"></td></tr><tr id="grid_'+this.name+'_frec_more" style="display: none; "> <td colspan="2000" class="w2ui-load-more"></td></tr></tbody></table>',a+='<tr id="grid_'+this.name+'_rec_bottom" rec="bottom" line="bottom" style="height: '+o+'px; vertical-align: top"> <td colspan="2000" style="border: 0"></td></tr><tr id="grid_'+this.name+'_rec_more" style="display: none"> <td colspan="2000" class="w2ui-load-more"></td></tr></tbody></table>',this.last.range_start=0,this.last.range_end=s,[l,a]},getSummaryHTML:function(){if(0!==this.summary.length){for(var e=this.getRecordHTML(-1,0),t="<table><tbody>"+e[0],i="<table><tbody>"+e[1],s=0;s<this.summary.length;s++)t+=(e=this.getRecordHTML(s,s+1,!0))[0],i+=e[1];return[t+="</tbody></table>",i+="</tbody></table>"]}},scroll:function(e){(new Date).getTime();var t,i,s=this,n="object"!=typeof this.url?this.url:this.url.get,l=$("#grid_"+this.name+"_records"),a=$("#grid_"+this.name+"_frecords");e&&(t=e.target.scrollTop,i=e.target.scrollLeft,s.last.scrollTop=t,s.last.scrollLeft=i,$("#grid_"+s.name+"_columns")[0].scrollLeft=i,$("#grid_"+s.name+"_summary")[0].scrollLeft=i,a[0].scrollTop=t),this.last.bubbleEl&&($(this.last.bubbleEl).w2tag(),this.last.bubbleEl=null);var r=null,o=null;if(s.disableCVS||0<s.columnGroups.length)r=0,o=s.columns.length-1;else{for(var d,u=l.width(),c=0,h=0;h<s.columns.length;h++)s.columns[h].frozen||s.columns[h].hidden||(c+(d=parseInt(s.columns[h].sizeCalculated?s.columns[h].sizeCalculated:s.columns[h].size))+30>s.last.scrollLeft&&null==r&&(r=h),c+d-30>s.last.scrollLeft+u&&null==o&&(o=h),c+=d);null==o&&(o=s.columns.length-1)}if(null!=r&&(r<0&&(r=0),o<0&&(o=0),r==o&&(0<r?r--:o++),r!=s.last.colStart||o!=s.last.colEnd)){var p=$(s.box),f=Math.abs(r-s.last.colStart),g=Math.abs(o-s.last.colEnd);if(f<5&&g<5){var m=p.find(".w2ui-grid-columns #grid_"+s.name+"_column_start"),w=p.find(".w2ui-grid-columns .w2ui-head-last"),v=p.find("#grid_"+s.name+"_records .w2ui-grid-data-spacer"),y=p.find("#grid_"+s.name+"_records .w2ui-grid-data-last"),b=p.find("#grid_"+s.name+"_summary .w2ui-grid-data-spacer"),x=p.find("#grid_"+s.name+"_summary .w2ui-grid-data-last");if(r>s.last.colStart)for(h=s.last.colStart;h<r;h++)p.find("#grid_"+s.name+"_columns #grid_"+s.name+"_column_"+h).remove(),p.find("#grid_"+s.name+'_records td[col="'+h+'"]').remove(),p.find("#grid_"+s.name+'_summary td[col="'+h+'"]').remove();if(o<s.last.colEnd)for(h=s.last.colEnd;o<h;h--)p.find("#grid_"+s.name+"_columns #grid_"+s.name+"_column_"+h).remove(),p.find("#grid_"+s.name+'_records td[col="'+h+'"]').remove(),p.find("#grid_"+s.name+'_summary td[col="'+h+'"]').remove();if(r<s.last.colStart)for(h=s.last.colStart-1;r<=h;h--)s.columns[h]&&(s.columns[h].frozen||s.columns[h].hidden)||(m.after(s.getColumnCellHTML(h)),v.each((function(e,t){var i=$(t).parent().attr("index"),n='<td class="w2ui-grid-data" col="'+h+'" style="height: 0px"></td>';null!=i&&(n=s.getCellHTML(parseInt(i),h,!1)),$(t).after(n)})),b.each((function(e,t){var i=$(t).parent().attr("index"),n='<td class="w2ui-grid-data" col="'+h+'" style="height: 0px"></td>';null!=i&&(n=s.getCellHTML(parseInt(i),h,!0)),$(t).after(n)})));if(o>s.last.colEnd)for(h=s.last.colEnd+1;h<=o;h++)s.columns[h]&&(s.columns[h].frozen||s.columns[h].hidden)||(w.before(s.getColumnCellHTML(h)),y.each((function(e,t){var i=$(t).parent().attr("index"),n='<td class="w2ui-grid-data" col="'+h+'" style="height: 0px"></td>';null!=i&&(n=s.getCellHTML(parseInt(i),h,!1)),$(t).before(n)})),x.each((function(e,t){var i=$(t).parent().attr("index")||-1,n=s.getCellHTML(parseInt(i),h,!0);$(t).before(n)})));s.last.colStart=r,s.last.colEnd=o,s.resizeRecords()}else{s.last.colStart=r,s.last.colEnd=o;var _=this.getColumnsHTML(),k=this.getRecordsHTML(),C=this.getSummaryHTML(),T=p.find("#grid_"+this.name+"_columns"),S=p.find("#grid_"+this.name+"_records"),D=p.find("#grid_"+this.name+"_frecords"),O=p.find("#grid_"+this.name+"_summary");T.find("tbody").html(_[1]),D.html(k[0]),S.prepend(k[1]),null!=C&&O.html(C[1]),setTimeout((function(){S.find("> table").not("table:first-child").remove(),O[0]&&(O[0].scrollLeft=s.last.scrollLeft)}),1),s.resizeRecords()}}var z=this.records.length;if(z>this.total&&(z=this.total),0==this.searchData.length||n||(z=this.last.searchIds.length),0!==z&&0!==l.length&&0!==l.height()){z>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start;var I=Math.round(l[0].scrollTop/this.recordHeight+1),E=I+(Math.round(l.height()/this.recordHeight)-1);if(z<I&&(I=z),z-1<=E&&(E=z),$("#grid_"+this.name+"_footer .w2ui-footer-right").html((s.show.statusRange?w2utils.formatNumber(this.offset+I)+"-"+w2utils.formatNumber(this.offset+E)+(-1!=this.total?" "+w2utils.lang("of")+" "+w2utils.formatNumber(this.total):""):"")+(n&&s.show.statusBuffered?" ("+w2utils.lang("buffered")+" "+w2utils.formatNumber(z)+(0<this.offset?", skip "+w2utils.formatNumber(this.offset):"")+")":"")),n||this.fixedBody&&!(-1!=this.total&&this.total<=this.vs_start)){var R=Math.floor(l[0].scrollTop/this.recordHeight)-this.last.show_extra,F=R+Math.floor(l.height()/this.recordHeight)+2*this.last.show_extra+1;R<1&&(R=1),F>this.total&&-1!=this.total&&(F=this.total);var j=l.find("#grid_"+this.name+"_rec_top"),A=l.find("#grid_"+this.name+"_rec_bottom"),M=a.find("#grid_"+this.name+"_frec_top"),N=a.find("#grid_"+this.name+"_frec_bottom");-1!=String(j.next().prop("id")).indexOf("_expanded_row")&&(j.next().remove(),M.next().remove()),this.total>F&&-1!=String(A.prev().prop("id")).indexOf("_expanded_row")&&(A.prev().remove(),N.prev().remove());var L,P=parseInt(j.next().attr("line")),H=parseInt(A.prev().attr("line"));if(P<R||1==P||this.last.pull_refresh){if(F<=H+this.last.show_extra-2&&F!=this.total)return;for(this.last.pull_refresh=!1;;){var B=a.find("#grid_"+this.name+"_frec_top").next();if("bottom"==(Y=l.find("#grid_"+this.name+"_rec_top").next()).attr("line"))break;if(!(parseInt(Y.attr("line"))<R))break;B.remove(),Y.remove()}for("top"==(L=l.find("#grid_"+this.name+"_rec_bottom").prev().attr("line"))&&(L=R),h=parseInt(L)+1;h<=F;h++)this.records[h-1]&&((Y=this.records[h-1].w2ui)&&!Array.isArray(Y.children)&&(Y.expanded=!1),W=this.getRecordHTML(h-1,h),A.before(W[1]),N.before(W[0]));U(),setTimeout((function(){s.refreshRanges()}),0)}else{if(R>=P-this.last.show_extra+2&&1<R)return;for(;B=a.find("#grid_"+this.name+"_frec_bottom").prev(),"top"!=(Y=l.find("#grid_"+this.name+"_rec_bottom").prev()).attr("line")&&parseInt(Y.attr("line"))>F;)B.remove(),Y.remove();var Y,W;for("bottom"==(L=l.find("#grid_"+this.name+"_rec_top").next().attr("line"))&&(L=F),h=parseInt(L)-1;R<=h;h--)this.records[h-1]&&((Y=this.records[h-1].w2ui)&&!Array.isArray(Y.children)&&(Y.expanded=!1),W=this.getRecordHTML(h-1,h),j.after(W[1]),M.after(W[0])
1);U(),setTimeout((function(){s.refreshRanges()}),0)}var X=(R-1)*s.recordHeight,K=(z-F)*this.recordHeight;K<0&&(K=0),j.css("height",X+"px"),M.css("height",X+"px"),A.css("height",K+"px"),N.css("height",K+"px"),s.last.range_start=R,s.last.range_end=F,z<Math.floor(l[0].scrollTop/this.recordHeight)+Math.floor(l.height()/this.recordHeight)+10&&!0!==this.last.pull_more&&(z<this.total-this.offset||-1==this.total&&this.last.xhr_hasMore)&&(!0===this.autoLoad&&(this.last.pull_more=!0,this.last.xhr_offset+=this.limit,this.request("get")),$("#grid_"+this.name+"_rec_more, #grid_"+this.name+"_frec_more").show().eq(1).off(".load-more").on("click.load-more",(function(){$(this).find("td").html('<div><div style="width: 20px; height: 20px;" class="w2ui-spinner"></div></div>'),s.last.pull_more=!0,s.last.xhr_offset+=s.limit,s.request("get")})).find("td").html(s.autoLoad?'<div><div style="width: 20px; height: 20px;" class="w2ui-spinner"></div></div>':'<div style="padding-top: 15px">'+w2utils.lang("Load")+" "+s.limit+" "+w2utils.lang("More")+"...</div>"))}}function U(){s.markSearch&&(clearTimeout(s.last.marker_timer),s.last.marker_timer=setTimeout((function(){for(var e=[],t=0;t<s.searchData.length;t++){var i,n=s.searchData[t],l=s.getSearch(n.field);l&&!l.hidden&&(i=s.getColumn(n.field,!0),e.push({field:n.field,search:n.value,col:i}))}0<e.length&&e.forEach((function(e){$(s.box).find('td[col="'+e.col+'"]').not(".w2ui-head").w2marker(e.search)}))}),50))}},getRecordHTML:function(e,t,i){var s,n="",l="",a=this.last.selection;if(-1==e){n+='<tr line="0">',l+='<tr line="0">',this.show.lineNumbers&&(n+='<td class="w2ui-col-number" style="height: 0px;"></td>'),this.show.selectColumn&&(n+='<td class="w2ui-col-select" style="height: 0px;"></td>'),this.show.expandColumn&&(n+='<td class="w2ui-col-expand" style="height: 0px;"></td>'),l+='<td class="w2ui-grid-data w2ui-grid-data-spacer" col="start" style="height: 0px; width: 0px;"></td>',this.show.orderColumn&&(l+='<td class="w2ui-col-order" style="height: 0px;" col="order"></td>');for(var r=0;r<this.columns.length;r++){var o='<td class="w2ui-grid-data" col="'+r+'" style="height: 0px;"></td>';if((w=this.columns[r]).frozen&&!w.hidden)n+=o;else{if(w.hidden||r<this.last.colStart||r>this.last.colEnd)continue;l+=o}}return n+='<td class="w2ui-grid-data-last" style="height: 0px"></td>',l+='<td class="w2ui-grid-data-last" col="end" style="height: 0px"></td>',[n+="</tr>",l+="</tr>"]}var d,u="object"!=typeof this.url?this.url:this.url.get;if(!0!==i)if(0<this.searchData.length&&!u){if(e>=this.last.searchIds.length)return"";e=this.last.searchIds[e],s=this.records[e]}else{if(e>=this.records.length)return"";s=this.records[e]}else{if(e>=this.summary.length)return"";s=this.summary[e]}if(!s)return"";null!=s.recid||null==this.recid||null!=(d=this.parseField(s,this.recid))&&(s.recid=d),w2utils.escapeId(s.recid);var c=!1;-1!=a.indexes.indexOf(e)&&(c=!0);var h=s.w2ui?s.w2ui.style:"";null!=h&&"string"==typeof h||(h="");var p,f=s.w2ui?s.w2ui.class:"";null!=f&&"string"==typeof f||(f=""),n+='<tr id="grid_'+this.name+"_frec_"+s.recid+'" recid="'+s.recid+'" line="'+t+'" index="'+e+'" class="'+(t%2==0?"w2ui-even":"w2ui-odd")+" w2ui-record "+f+(c&&"row"==this.selectType?" w2ui-selected":"")+(s.w2ui&&!1===s.w2ui.editable?" w2ui-no-edit":"")+(s.w2ui&&!0===s.w2ui.expanded?" w2ui-expanded":"")+'" style="height: '+this.recordHeight+"px; "+(c||""==h?h.replace("background-color","none"):h)+'" '+(""!=h?'custom_style="'+h+'"':"")+">",l+='<tr id="grid_'+this.name+"_rec_"+s.recid+'" recid="'+s.recid+'" line="'+t+'" index="'+e+'" class="'+(t%2==0?"w2ui-even":"w2ui-odd")+" w2ui-record "+f+(c&&"row"==this.selectType?" w2ui-selected":"")+(s.w2ui&&!1===s.w2ui.editable?" w2ui-no-edit":"")+(s.w2ui&&!0===s.w2ui.expanded?" w2ui-expanded":"")+'" style="height: '+this.recordHeight+"px; "+(c||""==h?h.replace("background-color","none"):h)+'" '+(""!=h?'custom_style="'+h+'"':"")+">",this.show.lineNumbers&&(n+='<td id="grid_'+this.name+"_cell_"+e+"_number"+(i?"_s":"")+'" class="w2ui-col-number '+(c?" w2ui-row-selected":"")+'"'+(this.reorderRows?' style="cursor: move"':"")+">"+(!0!==i?this.getLineHTML(t,s):"")+"</td>"),this.show.selectColumn&&(s&&s.w2ui&&s.w2ui.hideCheckBox,n+='<td id="grid_'+this.name+"_cell_"+e+"_select"+(i?"_s":"")+'" class="w2ui-grid-data w2ui-col-select">'+(!0===i||s.w2ui&&!0===s.w2ui.hideCheckBox?"":' <div> <input class="w2ui-grid-select-check" type="checkbox" tabindex="-1" '+(c?'checked="checked"':"")+' style="pointer-events: none"/> </div>')+"</td>"),this.show.expandColumn&&(p="",p=s.w2ui&&!0===s.w2ui.expanded?"-":"+",s.w2ui&&"none"==s.w2ui.expanded&&(p=""),s.w2ui&&"spinner"==s.w2ui.expanded&&(p='<div class="w2ui-spinner" style="width: 16px; margin: -2px 2px;"></div>'),n+='<td id="grid_'+this.name+"_cell_"+e+"_expand"+(i?"_s":"")+'" class="w2ui-grid-data w2ui-col-expand">'+(!0!==i?' <div ondblclick="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;" onclick="w2ui[\''+this.name+"'].toggle(jQuery(this).parents('tr').attr('recid')); if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;\"> "+p+" </div>":"")+"</td>"),l+='<td class="w2ui-grid-data-spacer" col="start" style="border-right: 0"></td>',this.show.orderColumn&&(l+='<td id="grid_'+this.name+"_cell_"+e+"_order"+(i?"_s":"")+'" class="w2ui-grid-data w2ui-col-order" col="order">'+(!0!==i?'<div title="Drag to reorder"> </div>':"")+"</td>");for(var g=0,m=0;;){var w,v,y,b=1;if(null==(w=this.columns[g]))break;if(w.hidden)g++,0<m&&m--;else if(0<m){if(g++,null==this.columns[g])break;s.w2ui.colspan[this.columns[g-1].field]=0,m--}else if(s.w2ui&&(v=s.w2ui.colspan,y=this.columns[g].field,v&&0===v[y]&&delete v[y]),!(g<this.last.colStart||g>this.last.colEnd)||w.frozen){if(s.w2ui&&"object"==typeof s.w2ui.colspan){var x=parseInt(s.w2ui.colspan[w.field])||null;if(1<x){var _=0;for(r=g;r<g+x&&!(r>=this.columns.length);r++)this.columns[r].hidden&&_++;b=x-_,m=x-1}}var k=this.getCellHTML(e,g,i,b);w.frozen?n+=k:l+=k,g++}else g++}return n+='<td class="w2ui-grid-data-last"></td>',l+='<td class="w2ui-grid-data-last" col="end"></td>',[n+="</tr>",l+="</tr>"]},getLineHTML:function(e){return"<div>"+e+"</div>"},getCellHTML:function(e,t,i,s){var n=this,l=this.columns[t];if(null==l)return"";var a,r,o,d,u,c,h,p=!0!==i?this.records[e]:this.summary[e],f=-1!==e?this.getCellValue(e,t,i):"",g=-1!==e?this.getCellEditable(e,t):"",m="max-height: "+parseInt(this.recordHeight)+"px;"+(l.clipboardCopy?"margin-right: 20px":""),w=!i&&p&&p.w2ui&&p.w2ui.changes&&null!=p.w2ui.changes[l.field],v="",y="",b=this.last.selection,x=!1,_="";if(-1!=b.indexes.indexOf(e)&&(x=!0),null==s&&(s=p&&p.w2ui&&p.w2ui.colspan&&p.w2ui.colspan[l.field]?p.w2ui.colspan[l.field]:1),0===t&&p&&p.w2ui&&Array.isArray(p.w2ui.children)){for(var k,C=0,T=this.get(p.w2ui.parent_recid,!0);null!=T&&(C++,null!=(k=this.records[T].w2ui)&&null!=k.parent_recid);)T=this.get(k.parent_recid,!0);if(p.w2ui.parent_recid)for(var S=0;S<C;S++)_+='<span class="w2ui-show-children w2ui-icon-empty"></span>';
1_+='<span class="w2ui-show-children '+(0<p.w2ui.children.length?p.w2ui.expanded?"w2ui-icon-collapse":"w2ui-icon-expand":"w2ui-icon-empty")+'" onclick="event.stopPropagation(); w2ui[\''+this.name+"'].toggle(jQuery(this).parents('tr').attr('recid'))\"></span>"}!0===l.info&&(l.info={}),null!=l.info&&(a="w2ui-icon-info","function"==typeof l.info.icon?a=l.info.icon(p):"object"==typeof l.info.icon?a=l.info.icon[this.parseField(p,l.field)]||"":"string"==typeof l.info.icon&&(a=l.info.icon),r=l.info.style||"","function"==typeof l.info.style?r=l.info.style(p):"object"==typeof l.info.style?r=l.info.style[this.parseField(p,l.field)]||"":"string"==typeof l.info.style&&(r=l.info.style),_+='<span class="w2ui-info '+a+'" style="'+r+'" '+(null!=l.info.showOn?"on"+l.info.showOn:"onclick")+"=\"event.stopPropagation(); w2ui['"+this.name+"'].showBubble("+e+", "+t+')"'+(null!=l.info.hideOn?"on"+l.info.hideOn:"")+"=\"var grid = w2ui['"+this.name+"']; if (grid.last.bubbleEl) { $(grid.last.bubbleEl).w2tag() } grid.last.bubbleEl = null;\"></span>"),null!=l.render&&-1!==e?("function"==typeof l.render&&(null!=(o=l.render.call(this,p,e,t,f))&&"object"==typeof o?(f=$.trim(o.html||""),y=o.class||"",v=o.style||""):f=$.trim(o),(f.length<4||"<div"!=f.substr(0,4).toLowerCase())&&(f='<div style="'+m+'" title="'+I(f)+'">'+_+String(f)+"</div>")),"object"==typeof l.render&&(null!=(d=l.render[f])&&""!==d||(d=f),f='<div style="'+m+'" title="'+I(d)+'">'+_+String(d)+"</div>"),"string"==typeof l.render&&(k=[],-1==(u=l.render.toLowerCase().indexOf(":"))?(k[0]=l.render.toLowerCase(),k[1]=""):(k[0]=l.render.toLowerCase().substr(0,u),k[1]=l.render.toLowerCase().substr(u+1)),c=w2utils.formatters[k[0]],l.options&&!1===l.options.autoFormat&&(c=null),f='<div style="'+m+'" title="'+I(f="function"==typeof c?c(f,k[1],p):"")+'">'+_+String(f)+"</div>")):(g&&-1!=["checkbox","check"].indexOf(g.type)&&(h=i?-(e+1):e,m+="text-align: center;",f='<input tabindex="-1" type="checkbox" '+(f?'checked="checked"':"")+" onclick=\" var obj = w2ui['"+this.name+"']; obj.editChange.call(obj, this, "+h+", "+t+', event); "/>',_=""),f='<div style="'+m+'" title="'+I(f)+'">'+_+String(f)+"</div>"),null==f&&(f=""),"string"==typeof l.render&&(k=l.render.toLowerCase().split(":"),-1!=["number","int","float","money","currency","percent","size"].indexOf(k[0])&&(v+="text-align: right;")),p&&p.w2ui&&("object"==typeof p.w2ui.style&&("string"==typeof p.w2ui.style[t]&&(v+=p.w2ui.style[t]+";"),"string"==typeof p.w2ui.style[l.field]&&(v+=p.w2ui.style[l.field]+";")),"object"==typeof p.w2ui.class&&("string"==typeof p.w2ui.class[t]&&(y+=p.w2ui.class[t]+" "),"string"==typeof p.w2ui.class[l.field]&&(y+=p.w2ui.class[l.field]+" ")));var D=!1;x&&-1!=$.inArray(t,b.columns[e])&&(D=!0);var O="string"==typeof l.clipboardCopy?l.clipboardCopy:"Copy to clipboard",z="<span onmouseEnter=\"jQuery(this).w2tag('"+O+"', { position: 'top|bottom' })\"onclick=\"w2ui['"+this.name+"'].clipboardCopy("+e+", "+t+'); jQuery(this).w2tag(\'Copied\', { position: \'top|bottom\' }); event.stopPropagation();" onmouseLeave="jQuery(this).w2tag()" class="w2ui-clipboard-copy w2ui-icon-paste"></span>';return f='<td class="w2ui-grid-data'+(D?" w2ui-selected":"")+" "+y+(w?" w2ui-changed":"")+'" id="grid_'+this.name+"_data_"+e+"_"+t+'" col="'+t+'" style="'+v+(null!=l.style?l.style:"")+'" '+(null!=l.attr?l.attr:"")+(1<s?'colspan="'+s+'"':"")+">"+f+(""!=w2utils.stripTags(f)&&l.clipboardCopy&&O?z:"")+"</td>",-1===e&&!0===i&&(f='<td class="w2ui-grid-data" col="'+t+'" style="height: 0px; '+v+'" '+(1<s?'colspan="'+s+'"':"")+"></td>"),f;function I(i){var s="";return n.show.recordTitles&&(null!=l.title?("function"==typeof l.title&&(s=l.title.call(n,p,e,t)),"string"==typeof l.title&&(s=l.title)):s=w2utils.stripTags(String(i).replace(/"/g,"''"))),null!=s?String(s):""}},clipboardCopy:function(e,t){var i=this.records[e],s=this.columns[t],n=s?this.parseField(i,s.field):"";"function"==typeof s.clipboardCopy&&(n=s.clipboardCopy(i)),$("#grid_"+this.name+"_focus").text(n).select(),document.execCommand("copy")},showBubble:function(e,t){var i="",s=this.columns[t].info,n=this.records[e],l=$(this.box).find("#grid_"+this.name+"_data_"+e+"_"+t+" .w2ui-info");if(this.last.bubbleEl&&$(this.last.bubbleEl).w2tag(),this.last.bubbleEl=l,null==s.fields){s.fields=[];for(var a=0;a<this.columns.length;a++){var r=this.columns[a];s.fields.push(r.field+("string"==typeof r.render?":"+r.render:""))}}var o=s.fields;if("function"==typeof o&&(o=o(n,e,t)),"function"==typeof s.render)i=s.render(n,e,t);else if($.isArray(o)){for(i='<table cellpadding="0" cellspacing="0">',a=0;a<o.length;a++)""!=(u=String(o[a]).split(":"))[0]&&"-"!=u[0]&&"--"!=u[0]&&"---"!=u[0]?(null==(r=this.getColumn(u[0]))&&(r={field:u[0],caption:u[0]}),c=r?this.parseField(n,r.field):"",1<u.length&&(w2utils.formatters[u[1]]?c=w2utils.formatters[u[1]](c,u[2]||null,
1n):console.log('ERROR: w2utils.formatters["'+u[1]+'"] does not exists.')),(!0===s.showEmpty||null!=c&&""!=c)&&(null!=s.maxLength&&"string"==typeof c&&c.length>s.maxLength&&(c=c.substr(0,s.maxLength)+"..."),i+="<tr><td>"+r.text+"</td><td>"+((0===c?"0":c)||"")+"</td></tr>")):i+='<tr><td colspan=2><div style="border-top: '+(""==u[0]?"0":"1")+'px solid #C1BEBE; margin: 6px 0px;"></div></td></tr>';i+="</table>"}else if($.isPlainObject(o)){for(var d in i='<table cellpadding="0" cellspacing="0">',o){var u,c,h=o[d];""!=h&&"-"!=h&&"--"!=h&&"---"!=h?(u=String(h).split(":"),null==(r=this.getColumn(u[0]))&&(r={field:u[0],caption:u[0]}),c=r?this.parseField(n,r.field):"",1<u.length&&(w2utils.formatters[u[1]]?c=w2utils.formatters[u[1]](c,u[2]||null,n):console.log('ERROR: w2utils.formatters["'+u[1]+'"] does not exists.')),"function"==typeof h&&(c=h(n,e,t)),(!0===s.showEmpty||null!=c&&""!=c)&&(null!=s.maxLength&&"string"==typeof c&&c.length>s.maxLength&&(c=c.substr(0,s.maxLength)+"..."),i+="<tr><td>"+d+"</td><td>"+(c||"")+"</td></tr>")):i+='<tr><td colspan=2><div style="border-top: '+(""==h?"0":"1")+'px solid #C1BEBE; margin: 6px 0px;"></div></td></tr>'}i+="</table>"}$(l).w2tag($.extend({html:i,left:-4,position:"bottom|top",className:"w2ui-info-bubble",style:"",hideOnClick:!0},s.options||{}))},getCellEditable:function(e,t){var i=this.columns[t],s=this.records[e];if(!s||!i)return null;var n,l=s.w2ui?s.w2ui.editable:null;return!1===l?null:(null!=l&&!0!==l||"function"==typeof(l=i?i.editable:null)&&(n=this.getCellValue(e,t,!1),l=l.call(this,s,e,t,n)),l)},getCellValue:function(e,t,i){var s=this.columns[t],n=!0!==i?this.records[e]:this.summary[e],l=this.parseField(n,s.field);return n&&n.w2ui&&n.w2ui.changes&&null!=n.w2ui.changes[s.field]&&(l=n.w2ui.changes[s.field]),$.isPlainObject(l)&&(s.options&&s.options.items?(val=s.options.items.find((function(e){return e.id==l.id})),l=val?val.text:l.id):(null!=l.text&&(l=l.text),null!=l.id&&(l=l.id))),null==l&&(l=""),l},getFooterHTML:function(){return'<div> <div class="w2ui-footer-left"></div> <div class="w2ui-footer-right"></div> <div class="w2ui-footer-center"></div></div>'},status:function(e){var t,i,s;null!=e?$("#grid_"+this.name+"_footer").find(".w2ui-footer-left").html(e):(t="",0<(i=this.getSelection()).length&&(this.show.statusSelection&&1<i.length&&(t=String(i.length).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")+" "+w2utils.lang("selected")),this.show.statusRecordID&&1==i.length&&("object"==typeof(s=i[0])&&(s=s.recid+", "+w2utils.lang("Column")+": "+s.column),t=w2utils.lang("Record ID")+": "+s+" ")),$("#grid_"+this.name+"_footer .w2ui-footer-left").html(t),1==i.length?this.toolbar.enable("w2ui-edit"):this.toolbar.disable("w2ui-edit"),1<=i.length?this.toolbar.enable("w2ui-delete"):this.toolbar.disable("w2ui-delete"))},lock:function(e,t){var i=this,s=Array.prototype.slice.call(arguments,0);s.unshift(this.box),setTimeout((function(){$(i.box).find("#grid_"+i.name+"_empty_msg").remove(),w2utils.lock.apply(window,s)}),10)},unlock:function(e){var t=this.box;setTimeout((function(){0<$(t).find(".w2ui-message").not(".w2ui-closing").length||w2utils.unlock(t,e)}),25)},stateSave:function(e){var t=this;if(!w2utils.hasLocalStorage)return null;for(var i,s={columns:[],show:$.extend({},this.show),last:{search:this.last.search,multi:this.last.multi,logic:this.last.logic,label:this.last.label,field:this.last.field,scrollTop:this.last.scrollTop,scrollLeft:this.last.scrollLeft},sortData:[],searchData:[]},n=0;n<this.columns.length;n++){var l=t.columns[n],a={};Object.keys(t.stateColProps).forEach((function(e,s){t.stateColProps[e]&&(i=void 0!==l[e]?l[e]:t.stateColDefaults[e]||null,a[e]=i)})),s.columns.push(a)}for(n=0;n<this.sortData.length;n++)s.sortData.push($.extend({},this.sortData[n]));for(n=0;n<this.searchData.length;n++)s.searchData.push($.extend({},this.searchData[n]));if(!0!==e){var r=this.trigger({phase:"before",type:"stateSave",target:this.name,state:s});if(!0===r.isCancelled)return void("function"==typeof callBack&&callBack({status:"error",message:"Request aborted."}));try{var o=$.parseJSON(localStorage.w2ui||"{}");(o=o||{}).states||(o.states={}),o.states[this.stateId||this.name]=s,localStorage.w2ui=JSON.stringify(o)}catch(e){return delete localStorage.w2ui,null}this.trigger($.extend(r,{phase:"after"}))}return s},stateRestore:function(e){var t=this,i="object"!=typeof this.url?this.url:this.url.get;if(!e)try{if(!w2utils.hasLocalStorage)return!1;(r=(r=$.parseJSON(localStorage.w2ui||"{}"))||{}).states||(r.states={}),e=r.states[this.stateId||this.name]}catch(e){return delete localStorage.w2ui,null}var s=this.trigger({phase:"before",type:"stateRestore",target:this.name,state:e});if(!0!==s.isCancelled){if($.isPlainObject(e)){$.extend(this.show,e.show),$.extend(this.last,e.last);for(var n=this.last.scrollTop,l=this.last.scrollLeft,a=0;a<e.columns.length;a++){var r=e.columns[a],o=this.getColumn(r.field,!0);null!==o&&($.extend(this.columns[o],r),a!==o&&this.columns.splice(a,0,this.columns.splice(o,1)[0]))}for(this.sortData.splice(0,this.sortData.length),a=0;a<e.sortData.length;a++)this.sortData.push(e.sortData[a]);for(this.searchData.splice(0,this.searchData.length),a=0;a<e.searchData.length;a++)this.searchData.push(e.searchData[a]);setTimeout((function(){i||(0<t.sortData.length&&t.localSort(),0<t.searchData.length&&t.localSearch()),t.last.scrollTop=n,t.last.scrollLeft=l,t.refresh()}),1)}return this.trigger($.extend(s,{phase:"after"})),!0}"function"==typeof callBack&&callBack({status:"error",message:"Request aborted."})},stateReset:function(){if(this.stateRestore(this.last.state),w2utils.hasLocalStorage)try{var e=$.parseJSON(localStorage.w2ui||"{}");e.states&&e.states[this.stateId||this.name]&&delete e.states[this.stateId||this.name],localStorage.w2ui=JSON.stringify(e)}catch(e){return delete localStorage.w2ui,null}},parseField:function(e,t){if(this.nestedFields){var i="";try{i=e;for(var s=String(t).split("."),n=0;n<s.length;n++)i=i[s[n]]}catch(e){i=""}return i}return e?e[t]:""},prepareData:function(){for(var e=this,t=0;t<this.records.length;t++)!function t(i){for(var s=0;s<e.columns.length;s++){var n,l,a=e.columns[s];null!=i[a.field]&&"string"==typeof a.render&&(-1!=["number","int","float","money","currency","percent"].indexOf(a.render.split(":")[0])&&"number"!=typeof i[a.field]&&(i[a.field]=parseFloat(i[a.field])),-1!=["date","age"].indexOf(a.render.split(":")[0])&&(i[a.field+"_"]||(l=i[a.field],w2utils.isInt(l)&&(l=parseInt(l)),i[a.field+"_"]=new Date(l))),-1!=["time"].indexOf(a.render)&&(w2utils.isTime(i[a.field])?(n=w2utils.isTime(i[a.field],!0),(l=new Date).setHours(n.hours,n.minutes,n.seconds?n.seconds:0,0)):(n=i[a.field],w2utils.isInt(n)&&(n=parseInt(n)),n=null!=n?new Date(n):new Date,(l=new Date).setHours(n.getHours(),n.getMinutes(),n.getSeconds(),0)),i[a.field+"_"]||(i[a.field+"_"]=l)))}if(i.w2ui&&i.w2ui.children&&!0!==i.w2ui.expanded)for(var r=0;r<i.w2ui.children.length;r++)t(i.w2ui.children[r])}(this.records[t])},nextCell:function(e,t,i){var s=t+1;if(s>=this.columns.length)return null;var n=this.records[e].w2ui,l=(this.columns[t],this.columns[s]),a=n&&n.colspan&&!isNaN(n.colspan[l.field])?parseInt(n.colspan[l.field]):1;if(null==l)return null;if(l&&l.hidden||0===a)return this.nextCell(e,s,i);if(i){var r=this.getCellEditable(e,t);if(null==r||-1!=["checkbox","check"].indexOf(r.type))return this.nextCell(e,s,i)}return s},prevCell:function(e,t,i){var s=t-1;if(s<0)return null;var n=this.records[e].w2ui,l=this.columns[s],a=n&&n.colspan&&!isNaN(n.colspan[l.field])?parseInt(n.colspan[l.field]):1;if(null==l)return null;if(l&&l.hidden||0===a)return this.prevCell(e,s,i);if(i){var r=this.getCellEditable(e,t);if(null==r||-1!=["checkbox","check"].indexOf(r.type))return this.prevCell(e,s,i)}return s},nextRow:function(e,t){var i=this.last.searchIds,s=null;if(e+1<this.records.length&&0===i.length||0<i.length&&e<i[i.length-1]){if(e++,0<i.length)for(;!(-1!=$.inArray(e,i)||e>this.records.length);)e++;var n=this.records[e].w2ui,l=this.columns[t];s=0===(n&&n.colspan&&null!=l&&!isNaN(n.colspan[l.field])?parseInt(n.colspan[l.field]):1)?this.nextRow(e,t):e}return s},prevRow:function(e,t){var i=this.last.searchIds,s=null;if(0<e&&0===i.length||0<i.length&&e>i[0]){if(e--,0<i.length)for(;!(-1!=$.inArray(e,i)||e<0);)e--;var n=this.records[e].w2ui,l=this.columns[t];s=0===(n&&n.colspan&&null!=l&&!isNaN(n.colspan[l.field])?parseInt(n.colspan[l.field]):1)?this.prevRow(e,t):e}return s},selectionSave:function(){return this.last._selection=this.getSelection(),this.last._selection},selectionRestore:function(e){var t=(new Date).getTime();this.last.selection={indexes:[],columns:{}};var i,s=this.last.selection,n=this.last._selection;if(n)for(var l=0;l<n.length;l++)$.isPlainObject(n[l])?null!=(i=this.get(n[l].recid,!0))&&(-1==s.indexes.indexOf(i)&&s.indexes.push(i),s.columns[i]||(s.columns[i]=[]),s.columns[i].push(n[l].column)):null!=(i=this.get(n[l],!0))&&s.indexes.push(i);return delete this.last._selection,!0!==e&&this.refresh(),(new Date).getTime()-t},message:function(e,t){"string"==typeof e&&(e={width:e.length<300?350:550,height:e.length<300?170:250,body:'<div class="w2ui-centered">'+e+"</div>",buttons:'<button type="button" class="w2ui-btn" onclick="w2ui[\''+this.name+"'].message()\">Ok</button>",onOpen:function(e){setTimeout((function(){$(this.box).find(".w2ui-btn").focus()}),25)},onClose:function(e){"function"==typeof t&&t()}}),w2utils.message.call(this,{box:this.box,path:"w2ui."+this.name,title:".w2ui-grid-header:visible",body:".w2ui-grid-box"},e)}},$.extend(w2grid.prototype,w2utils.event),w2obj.grid=w2grid}(jQuery),function(e){function t(t){this.box=null,this.name=null,this.panels=[],this.tmp={},this.padding=1,this.resizer=4,this.style="",e.extend(!0,this,w2obj.layout,t)}var i=["top","left","main","preview","right","bottom"];
1e.fn.w2layout=function(s){if(e.isPlainObject(s)){if(!w2utils.checkName(s,"w2layout"))return;var n=s.panels||[],l=new t(s);e.extend(l,{handlers:[],panels:[]});for(var a=0,r=n.length;a<r;a++)l.panels[a]=e.extend(!0,{},t.prototype.panel,n[a]),(e.isPlainObject(l.panels[a].tabs)||e.isArray(l.panels[a].tabs))&&function(t,i,s){var n=t.get(i);null!=n&&null==s&&(s=n.tabs),null!=n&&null!=s&&(e.isArray(s)&&(s={tabs:s}),e().w2destroy(t.name+"_"+i+"_tabs"),n.tabs=e().w2tabs(e.extend({},s,{owner:t,name:t.name+"_"+i+"_tabs"})),n.show.tabs=!0)}(l,n[a].type),(e.isPlainObject(l.panels[a].toolbar)||e.isArray(l.panels[a].toolbar))&&function(t,i,s){var n=t.get(i);null!=n&&null==s&&(s=n.toolbar),null!=n&&null!=s&&(e.isArray(s)&&(s={items:s}),e().w2destroy(t.name+"_"+i+"_toolbar"),n.toolbar=e().w2toolbar(e.extend({},s,{owner:t,name:t.name+"_"+i+"_toolbar"})),n.show.toolbar=!0)}(l,n[a].type);for(var o=0;o<i.length;o++)null==l.get(i[o])&&l.panels.push(e.extend(!0,{},t.prototype.panel,{type:i[o],hidden:"main"!==i[o],size:50}));return w2ui[l.name]=l,0<e(this).length&&l.render(e(this)[0]),l}var d=w2ui[e(this).attr("name")];return d?0<arguments.length?(d[s]&&d[s].apply(d,Array.prototype.slice.call(arguments,1)),this):d:null},t.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},callBack:null,onRefresh:null,onShow:null,onHide:null},content:function(e,t,i){return console.log("NOTICE: layout.content method is deprecated, please use layout.html() instead"),this.html(e,t,i)},html:function(t,i,s){var n=this,l=this.get(t),a={panel:t,html:l.content,error:!1,cancelled:!1,removed:function(e){"function"==typeof e&&(l.callBack=e)}};if("function"==typeof l.callBack&&(l.callBack({panel:t,content:l.content,new_content:i,transition:s||"none"}),l.callBack=null),"css"==t)return e("#layout_"+n.name+"_panel_css").html("<style>"+i+"</style>"),a.status=!0,a;if(null==l)return console.log("ERROR: incorrect panel name. Panel name can be main, left, right, top, bottom, preview or css"),a.error=!0,a;if(null==i)return a;var r=this.trigger({phase:"before",type:"content",target:t,object:l,content:i,transition:s});if(!0===r.isCancelled)return a.cancelled=!0,a;if(i instanceof jQuery)return console.log("ERROR: You can not pass jQuery object to w2layout.content() method"),a;var o,d,u="#layout_"+this.name+"_panel_"+l.type,c=e(u+"> .w2ui-panel-content"),h=0;return 0<c.length&&(e(u).scrollTop(0),h=e(c).position().top),""===l.content?l.content=i:(l.content=i,l.hidden||null!=s&&""!==s&&((o=e(u+"> .w2ui-panel-content")).after('<div class="w2ui-panel-content new-panel" style="'+o[0].style.cssText+'"></div>'),d=e(u+"> .w2ui-panel-content.new-panel"),o.css("top",h),d.css("top",h),"object"==typeof i?(i.box=d[0],i.render()):d.html(i),w2utils.transition(o[0],d[0],s,(function(){o.remove(),d.removeClass("new-panel"),d.css("overflow",l.overflow),e(u+"> .w2ui-panel-content").slice(1).remove(),n.resize(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout((function(){n.resize()}),100)})))),this.refresh(t),n.trigger(e.extend(r,{phase:"after"})),n.resize(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout((function(){n.resize()}),100),a},message:function(t,i){var s=this;"string"==typeof i&&(i={width:i.length<300?350:550,height:i.length<300?170:250,body:'<div class="w2ui-centered">'+i+"</div>",buttons:'<button class="w2ui-btn" onclick="w2ui[\''+this.name+"'].message('"+t+"')\">Ok</button>",onOpen:function(t){setTimeout((function(){e(this.box).find(".w2ui-btn").focus()}),25)}});var n,l=this.get(t),a=e("#layout_"+this.name+"_panel_"+l.type).css("overflow");i&&(i.onClose&&(n=i.onClose),i.onClose=function(t){"function"==typeof n&&n(t),t.done((function(){e("#layout_"+s.name+"_panel_"+l.type).css("overflow",a)}))}),e("#layout_"+this.name+"_panel_"+l.type).css("overflow","hidden"),w2utils.message.call(this,{box:e("#layout_"+this.name+"_panel_"+l.type),param:t,path:"w2ui."+this.name,title:".w2ui-panel-title:visible",body:".w2ui-panel-content"},i)},load:function(t,i,s,n){var l=this;return"css"==t?(e.get(i,(function(e,i,s){l.html(t,s.responseText),n&&n()})),!0):null!=this.get(t)&&(e.get(i,(function(e,i,a){l.html(t,a.responseText,s),n&&n(),l.resize(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout((function(){l.resize()}),100)})),!0)},sizeTo:function(t,i,s){var n=this;return null!=n.get(t)&&(e(n.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",!0!==s?".2s":"0s")),setTimeout((function(){n.set(t,{size:i})}),1),setTimeout((function(){e(n.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),n.resize()}),500),!0)},show:function(t,i){var s=this,n=this.trigger({phase:"before",type:"show",target:t,object:this.get(t),immediate:i});if(!0!==n.isCancelled){var l=s.get(t);return null!=l&&(!(l.hidden=!1)===i?(e("#layout_"+s.name+"_panel_"+t).css({opacity:"1"}),s.trigger(e.extend(n,{phase:"after"})),s.resize()):(e("#layout_"+s.name+"_panel_"+t).css({opacity:"0"}),e(s.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",".2s")),setTimeout((function(){s.resize()}),1),setTimeout((function(){e("#layout_"+s.name+"_panel_"+t).css({opacity:"1"})}),250),setTimeout((function(){e(s.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),s.trigger(e.extend(n,{phase:"after"})),s.resize()}),500)),!0)}},hide:function(t,i){var s=this,n=this.trigger({phase:"before",type:"hide",target:t,object:this.get(t),immediate:i});if(!0!==n.isCancelled){var l=s.get(t);return null!=l&&((l.hidden=!0)===i?(e("#layout_"+s.name+"_panel_"+t).css({opacity:"0"}),s.trigger(e.extend(n,{phase:"after"})),s.resize()):(e(s.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",".2s")),e("#layout_"+s.name+"_panel_"+t).css({opacity:"0"}),setTimeout((function(){s.resize()}),1),setTimeout((function(){e(s.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),s.trigger(e.extend(n,{phase:"after"})),s.resize()}),500)),!0)}},toggle:function(e,t){var i=this.get(e);return null!=i&&(i.hidden?this.show(e,t):this.hide(e,t))},set:function(t,i){var s=this.get(t,!0);return null!=s&&(e.extend(this.panels[s],i),null==i.content&&null==i.resizable||this.refresh(t),this.resize(),!0)},get:function(e,t){for(var i=0;i<this.panels.length;i++)if(this.panels[i].type==e)return!0===t?i:this.panels[i];return null},el:function(t){var i=e("#layout_"+this.name+"_panel_"+t+"> .w2ui-panel-content");return 1!=i.length?null:i[0]},hideToolbar:function(t){var i=this.get(t);i&&(i.show.toolbar=!1,e("#layout_"+this.name+"_panel_"+t+"> .w2ui-panel-toolbar").hide(),this.resize())},showToolbar:function(t){var i=this.get(t);i&&(i.show.toolbar=!0,e("#layout_"+this.name+"_panel_"+t+"> .w2ui-panel-toolbar").show(),this.resize())},toggleToolbar:function(e){var t=this.get(e);t&&(t.show.toolbar?this.hideToolbar(e):this.showToolbar(e))},assignToolbar:function(t,i){"string"==typeof i&&null!=w2ui[i]&&(i=w2ui[i]);var s=this.get(t);s.toolbar=i;var n=e(this.box).find(t+"> .w2ui-panel-toolbar");null!=s.toolbar?(0===n.find("[name="+s.toolbar.name+"]").length?n.w2render(s.toolbar):null!=s.toolbar&&s.toolbar.refresh(),(i.owner=this).showToolbar(t),this.refresh(t)):(n.html(""),this.hideToolbar(t))},hideTabs:function(t){var i=this.get(t);i&&(i.show.tabs=!1,e("#layout_"+this.name+"_panel_"+t+"> .w2ui-panel-tabs").hide(),this.resize())},showTabs:function(t){var i=this.get(t);i&&(i.show.tabs=!0,e("#layout_"+this.name+"_panel_"+t+"> .w2ui-panel-tabs").show(),this.resize())},toggleTabs:function(e){var t=this.get(e);t&&(t.show.tabs?this.hideTabs(e):this.showTabs(e))},render:function(t){var s=this,n=(new Date).getTime(),l=s.trigger({phase:"before",type:"render",target:s.name,box:t});if(!0!==l.isCancelled){if(null!=t&&(0<e(s.box).find("#layout_"+s.name+"_panel_main").length&&e(s.box).removeAttr("name").removeClass("w2ui-layout").html(""),s.box=t),!s.box)return!1;e(s.box).attr("name",s.name).addClass("w2ui-layout").html("<div></div>"),0<e(s.box).length&&(e(s.box)[0].style.cssText+=s.style);for(var a=0;a<i.length;a++){s.get(i[a]);var r='<div id="layout_'+s.name+"_panel_"+i[a]+'" class="w2ui-panel"> <div class="w2ui-panel-title"></div> <div class="w2ui-panel-tabs"></div> <div class="w2ui-panel-toolbar"></div> <div class="w2ui-panel-content"></div></div><div id="layout_'+s.name+"_resizer_"+i[a]+'" class="w2ui-resizer"></div>';e(s.box).find(" > div").append(r)}return e(s.box).find(" > div").append('<div id="layout_'+s.name+'_panel_css" style="position: absolute; top: 10000px;"></div>'),s.refresh(),s.trigger(e.extend(l,{phase:"after"})),setTimeout((function(){s.tmp.events={resize:function(t){null==w2ui[s.name]?e(window).off("resize.w2ui-"+s.name):w2ui[s.name].resize()},resizeStart:o,mouseMove:u,mouseUp:d},e(window).on("resize.w2ui-"+s.name,s.tmp.events.resize),s.resize()}),0),(new Date).getTime()-n}function o(t,n){if(s.box){n=n||window.event,e(document).off("mousemove",s.tmp.events.mouseMove).on("mousemove",s.tmp.events.mouseMove),e(document).off("mouseup",s.tmp.events.mouseUp).on("mouseup",s.tmp.events.mouseUp),s.tmp.resize={type:t,x:n.screenX,y:n.screenY,diff_x:0,diff_y:0,value:0};for(var l=0;l<i.length;l++){var a=e(s.el(i[l])).parent().find(".w2ui-lock");0<a.length?a.attr("locked","previous"):s.lock(i[l],{opacity:0}
1)}"left"!=t&&"right"!=t||(s.tmp.resize.value=parseInt(e("#layout_"+s.name+"_resizer_"+t)[0].style.left)),"top"!=t&&"preview"!=t&&"bottom"!=t||(s.tmp.resize.value=parseInt(e("#layout_"+s.name+"_resizer_"+t)[0].style.top))}}function d(t){if(s.box&&(t=t||window.event,e(document).off("mousemove",s.tmp.events.mouseMove),e(document).off("mouseup",s.tmp.events.mouseUp),null!=s.tmp.resize)){for(var n=0;n<i.length;n++){var l=e(s.el(i[n])).parent().find(".w2ui-lock");"previous"==l.attr("locked")?l.removeAttr("locked"):s.unlock(i[n])}if(0!==s.tmp.diff_x||0!==s.tmp.resize.diff_y){var a,r,o=s.get("top"),d=s.get("bottom"),u=s.get(s.tmp.resize.type),c=parseInt(e(s.box).height()),h=parseInt(e(s.box).width()),p=String(u.size);switch(s.tmp.resize.type){case"top":a=parseInt(u.sizeCalculated)+s.tmp.resize.diff_y,r=0;break;case"bottom":a=parseInt(u.sizeCalculated)-s.tmp.resize.diff_y,r=0;break;case"preview":a=parseInt(u.sizeCalculated)-s.tmp.resize.diff_y,r=(o&&!o.hidden?o.sizeCalculated:0)+(d&&!d.hidden?d.sizeCalculated:0);break;case"left":a=parseInt(u.sizeCalculated)+s.tmp.resize.diff_x,r=0;break;case"right":a=parseInt(u.sizeCalculated)-s.tmp.resize.diff_x,r=0}"%"==p.substr(p.length-1)?u.size=Math.floor(100*a/("left"==u.type||"right"==u.type?h:c-r)*100)/100+"%":"-"==String(u.size).substr(0,1)?u.size=parseInt(u.size)-u.sizeCalculated+a:u.size=a,s.resize()}e("#layout_"+s.name+"_resizer_"+s.tmp.resize.type).removeClass("active"),delete s.tmp.resize}}function u(t){if(s.box&&(t=t||window.event,null!=s.tmp.resize)){var i=s.get(s.tmp.resize.type),n=s.tmp.resize,l=s.trigger({phase:"before",type:"resizing",target:s.name,object:i,originalEvent:t,panel:n?n.type:"all",diff_x:n?n.diff_x:0,diff_y:n?n.diff_y:0});if(!0!==l.isCancelled){var a=e("#layout_"+s.name+"_resizer_"+n.type),r=t.screenX-n.x,o=t.screenY-n.y,d=s.get("main");switch(a.hasClass("active")||a.addClass("active"),n.type){case"left":i.minSize-r>i.width&&(r=i.minSize-i.width),i.maxSize&&i.width+r>i.maxSize&&(r=i.maxSize-i.width),d.minSize+r>d.width&&(r=d.width-d.minSize);break;case"right":i.minSize+r>i.width&&(r=i.width-i.minSize),i.maxSize&&i.width-r>i.maxSize&&(r=i.width-i.maxSize),d.minSize-r>d.width&&(r=d.minSize-d.width);break;case"top":i.minSize-o>i.height&&(o=i.minSize-i.height),i.maxSize&&i.height+o>i.maxSize&&(o=i.maxSize-i.height),d.minSize+o>d.height&&(o=d.height-d.minSize);break;case"preview":case"bottom":i.minSize+o>i.height&&(o=i.height-i.minSize),i.maxSize&&i.height-o>i.maxSize&&(o=i.height-i.maxSize),d.minSize-o>d.height&&(o=d.minSize-d.height)}switch(n.diff_x=r,n.diff_y=o,n.type){case"top":case"preview":case"bottom":(n.diff_x=0)<a.length&&(a[0].style.top=n.value+n.diff_y+"px");break;case"left":case"right":(n.diff_y=0)<a.length&&(a[0].style.left=n.value+n.diff_x+"px")}s.trigger(e.extend(l,{phase:"after"}))}}}},refresh:function(t){var i=this;null==t&&(t=null);var s=(new Date).getTime(),n=i.trigger({phase:"before",type:"refresh",target:null!=t?t:i.name,object:i.get(t)});if(!0!==n.isCancelled){if("string"==typeof t){var l=i.get(t);if(null==l)return;var a="#layout_"+i.name+"_panel_"+l.type,r="#layout_"+i.name+"_resizer_"+l.type;e(a).css({display:l.hidden?"none":"block"}),l.resizable?e(r).show():e(r).hide(),"object"==typeof l.content&&"function"==typeof l.content.render?(l.content.box=e(a+"> .w2ui-panel-content")[0],setTimeout((function(){0<e(a+"> .w2ui-panel-content").length&&(e(a+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").css("overflow",l.overflow)[0].style.cssText+=";"+l.style),l.content&&"function"==typeof l.content.render&&l.content.render()}),1)):0<e(a+"> .w2ui-panel-content").length&&(e(a+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").html(l.content).css("overflow",l.overflow)[0].style.cssText+=";"+l.style);var o=e(i.box).find(a+"> .w2ui-panel-tabs");l.show.tabs?0===o.find("[name="+l.tabs.name+"]").length&&null!=l.tabs?o.w2render(l.tabs):l.tabs.refresh():o.html("").removeClass("w2ui-tabs").hide(),o=e(i.box).find(a+"> .w2ui-panel-toolbar"),l.show.toolbar?0===o.find("[name="+l.toolbar.name+"]").length&&null!=l.toolbar?o.w2render(l.toolbar):l.toolbar.refresh():o.html("").removeClass("w2ui-toolbar").hide(),o=e(i.box).find(a+"> .w2ui-panel-title"),l.title?o.html(l.title).show():o.html("").hide()}else{if(0===e("#layout_"+i.name+"_panel_main").length)return void i.render();i.resize();for(var d=0;d<this.panels.length;d++)i.refresh(this.panels[d].type)}return i.trigger(e.extend(n,{phase:"after"})),(new Date).getTime()-s}},resize:function(){if(!this.box)return!1;var t=(new Date).getTime(),s=this.tmp.resize,n=this.trigger({phase:"before",type:"resize",target:this.name,panel:s?s.type:"all",diff_x:s?s.diff_x:0,diff_y:s?s.diff_y:0});if(!0!==n.isCancelled){this.padding<0&&(this.padding=0);var l=parseInt(e(this.box).width()),a=parseInt(e(this.box).height());e(this.box).find(" > div").css({width:l+"px",height:a+"px"});for(var r,o,d,u,c,h,p,f=this,g=this.get("main"),m=this.get("preview"),w=this.get("left"),v=this.get("right"),y=this.get("top"),b=this.get("bottom"),x=null!=m&&!0!==m.hidden,_=null!=w&&!0!==w.hidden,k=null!=v&&!0!==v.hidden,C=null!=y&&!0!==y.hidden,T=null!=b&&!0!==b.hidden,S=0;S<i.length;
1S++)"main"!==i[S]&&(s=this.get(i[S]))&&("%"==(h=String(s.size||0)).substr(h.length-1)?(p=a,"preview"==s.type&&(p=p-(y&&!y.hidden?y.sizeCalculated:0)-(b&&!b.hidden?b.sizeCalculated:0)),s.sizeCalculated=parseInt(("left"==s.type||"right"==s.type?l:p)*parseFloat(s.size)/100)):s.sizeCalculated=parseInt(s.size),s.sizeCalculated=Math.max(s.sizeCalculated,parseInt(s.minSize)));"-"==String(v.size).substr(0,1)&&(_&&"-"==String(w.size).substr(0,1)?console.log("ERROR: you cannot have both left panel.size and right panel.size be negative."):v.sizeCalculated=l-(_?w.sizeCalculated:0)+parseInt(v.size)),"-"==String(w.size).substr(0,1)&&(k&&"-"==v.size.substr(0,1)?console.log("ERROR: you cannot have both left panel.size and right panel.size be negative."):w.sizeCalculated=l-(k?v.sizeCalculated:0)+parseInt(w.size)),null!=y&&!0!==y.hidden?(o=r=0,d=l,u=y.sizeCalculated,e("#layout_"+this.name+"_panel_top").css({display:"block",left:r+"px",top:o+"px",width:d+"px",height:u+"px"}).show(),y.width=d,y.height=u,y.resizable&&(o=y.sizeCalculated-(0===this.padding?this.resizer:0),u=this.resizer>this.padding?this.resizer:this.padding,e("#layout_"+this.name+"_resizer_top").show().css({display:"block",left:r+"px",top:o+"px",width:d+"px",height:u+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",(function(t){var i=f.trigger({phase:"before",type:"resizerClick",target:"top",originalEvent:t});if(!0!==i.isCancelled)return w2ui[f.name].tmp.events.resizeStart("top",t),f.trigger(e.extend(i,{phase:"after"})),!1})))):(e("#layout_"+this.name+"_panel_top").hide(),e("#layout_"+this.name+"_resizer_top").hide()),null!=w&&!0!==w.hidden?(o=(r=0)+(C?y.sizeCalculated+this.padding:0),d=w.sizeCalculated,u=a-(C?y.sizeCalculated+this.padding:0)-(T?b.sizeCalculated+this.padding:0),c=e("#layout_"+this.name+"_panel_left"),-1!=window.navigator.userAgent.indexOf("MSIE")&&0<c.length&&c[0].clientHeight<c[0].scrollHeight&&(d+=17),c.css({display:"block",left:r+"px",top:o+"px",width:d+"px",height:u+"px"}).show(),w.width=d,w.height=u,w.resizable&&(r=w.sizeCalculated-(0===this.padding?this.resizer:0),d=this.resizer>this.padding?this.resizer:this.padding,e("#layout_"+this.name+"_resizer_left").show().css({display:"block",left:r+"px",top:o+"px",width:d+"px",height:u+"px",cursor:"ew-resize"}).off("mousedown").on("mousedown",(function(t){var i=f.trigger({phase:"before",type:"resizerClick",target:"left",originalEvent:t});if(!0!==i.isCancelled)return w2ui[f.name].tmp.events.resizeStart("left",t),f.trigger(e.extend(i,{phase:"after"})),!1})))):(e("#layout_"+this.name+"_panel_left").hide(),e("#layout_"+this.name+"_resizer_left").hide()),null!=v&&!0!==v.hidden?(r=l-v.sizeCalculated,o=0+(C?y.sizeCalculated+this.padding:0),d=v.sizeCalculated,u=a-(C?y.sizeCalculated+this.padding:0)-(T?b.sizeCalculated+this.padding:0),e("#layout_"+this.name+"_panel_right").css({display:"block",left:r+"px",top:o+"px",width:d+"px",height:u+"px"}).show(),v.width=d,v.height=u,v.resizable&&(r-=this.padding,d=this.resizer>this.padding?this.resizer:this.padding,e("#layout_"+this.name+"_resizer_right").show().css({display:"block",left:r+"px",top:o+"px",width:d+"px",height:u+"px",cursor:"ew-resize"}).off("mousedown").on("mousedown",(function(t){var i=f.trigger({phase:"before",type:"resizerClick",target:"right",originalEvent:t});if(!0!==i.isCancelled)return w2ui[f.name].tmp.events.resizeStart("right",t),f.trigger(e.extend(i,{phase:"after"})),!1})))):(e("#layout_"+this.name+"_panel_right").hide(),e("#layout_"+this.name+"_resizer_right").hide()),null!=b&&!0!==b.hidden?(r=0,o=a-b.sizeCalculated,d=l,u=b.sizeCalculated,e("#layout_"+this.name+"_panel_bottom").css({display:"block",left:r+"px",top:o+"px",width:d+"px",height:u+"px"}).show(),b.width=d,b.height=u,b.resizable&&(o-=0===this.padding?0:this.padding,u=this.resizer>this.padding?this.resizer:this.padding,e("#layout_"+this.name+"_resizer_bottom").show().css({display:"block",left:r+"px",top:o+"px",width:d+"px",height:u+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",(function(t){var i=f.trigger({phase:"before",type:"resizerClick",target:"bottom",originalEvent:t});if(!0!==i.isCancelled)return w2ui[f.name].tmp.events.resizeStart("bottom",t),f.trigger(e.extend(i,{phase:"after"})),!1})))):(e("#layout_"+this.name+"_panel_bottom").hide(),e("#layout_"+this.name+"_resizer_bottom").hide()),r=0+(_?w.sizeCalculated+this.padding:0),o=0+(C?y.sizeCalculated+this.padding:0),d=l-(_?w.sizeCalculated+this.padding:0)-(k?v.sizeCalculated+this.padding:0),u=a-(C?y.sizeCalculated+this.padding:0)-(T?b.sizeCalculated+this.padding:0)-(x?m.sizeCalculated+this.padding:0),c=e("#layout_"+this.name+"_panel_main"),-1!=window.navigator.userAgent.indexOf("MSIE")&&0<c.length&&c[0].clientHeight<c[0].scrollHeight&&(d+=17),c.css({display:"block",left:r+"px",to
1p:o+"px",width:d+"px",height:u+"px"}),g.width=d,g.height=u,null!=m&&!0!==m.hidden?(r=0+(_?w.sizeCalculated+this.padding:0),o=a-(T?b.sizeCalculated+this.padding:0)-m.sizeCalculated,d=l-(_?w.sizeCalculated+this.padding:0)-(k?v.sizeCalculated+this.padding:0),u=m.sizeCalculated,c=e("#layout_"+this.name+"_panel_preview"),-1!=window.navigator.userAgent.indexOf("MSIE")&&0<c.length&&c[0].clientHeight<c[0].scrollHeight&&(d+=17),c.css({display:"block",left:r+"px",top:o+"px",width:d+"px",height:u+"px"}).show(),m.width=d,m.height=u,m.resizable&&(o-=0===this.padding?0:this.padding,u=this.resizer>this.padding?this.resizer:this.padding,e("#layout_"+this.name+"_resizer_preview").show().css({display:"block",left:r+"px",top:o+"px",width:d+"px",height:u+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",(function(t){var i=f.trigger({phase:"before",type:"resizerClick",target:"preview",originalEvent:t});if(!0!==i.isCancelled)return w2ui[f.name].tmp.events.resizeStart("preview",t),f.trigger(e.extend(i,{phase:"after"})),!1})))):(e("#layout_"+this.name+"_panel_preview").hide(),e("#layout_"+this.name+"_resizer_preview").hide());for(var $=0;$<i.length;$++){var D=this.get(i[$]),O="#layout_"+this.name+"_panel_"+i[$]+" > .w2ui-panel-",z=0;D&&(D.title&&(z+=w2utils.getSize(e(O+"title").css({top:z+"px",display:"block"}),"height")),D.show.tabs&&(null!=D.tabs&&w2ui[this.name+"_"+i[$]+"_tabs"]&&w2ui[this.name+"_"+i[$]+"_tabs"].resize(),z+=w2utils.getSize(e(O+"tabs").css({top:z+"px",display:"block"}),"height")),D.show.toolbar&&(null!=D.toolbar&&w2ui[this.name+"_"+i[$]+"_toolbar"]&&w2ui[this.name+"_"+i[$]+"_toolbar"].resize(),z+=w2utils.getSize(e(O+"toolbar").css({top:z+"px",display:"block"}),"height"))),e(O+"content").css({display:"block"}).css({top:z+"px"})}return clearTimeout(this._resize_timer),this._resize_timer=setTimeout((function(){for(var t in w2ui){var i;"function"==typeof w2ui[t].resize&&(null==w2ui[t].panels&&w2ui[t].resize(),0<(i=e(w2ui[t].box).parents(".w2ui-layout")).length&&i.attr("name")==f.name&&w2ui[t].resize())}}),100),this.trigger(e.extend(n,{phase:"after"})),(new Date).getTime()-t}},destroy:function(){var t=this.trigger({phase:"before",type:"destroy",target:this.name});if(!0!==t.isCancelled)return null!=w2ui[this.name]&&(0<e(this.box).find("#layout_"+this.name+"_panel_main").length&&e(this.box).removeAttr("name").removeClass("w2ui-layout").html(""),delete w2ui[this.name],this.trigger(e.extend(t,{phase:"after"})),this.tmp.events&&this.tmp.events.resize&&e(window).off("resize",this.tmp.events.resize),!0)},lock:function(e,t,s){var n;-1!=i.indexOf(e)?((n=Array.prototype.slice.call(arguments,0))[0]="#layout_"+this.name+"_panel_"+e,w2utils.lock.apply(window,n)):console.log("ERROR: First parameter needs to be the a valid panel name.")},unlock:function(e,t){var s;-1!=i.indexOf(e)?(s="#layout_"+this.name+"_panel_"+e,w2utils.unlock(s,t)):console.log("ERROR: First parameter needs to be the a valid panel name.")}},e.extend(t.prototype,w2utils.event),w2obj.layout=t}(jQuery);var w2popup={},m;m=jQuery,w2popup={defaults:{title:"",body:"",buttons:"",style:"",color:"#000",opacity:.4,speed:.3,modal:!(m.fn.w2popup=function(e,t){null==e&&(t={},e="open"),m.isPlainObject(e)&&(t=e,e="open"),"load"===(e=e.toLowerCase())&&"string"==typeof t&&(t=m.extend({url:t},2<arguments.length?arguments[2]:{})),"open"===e&&null!=t.url&&(e="load"),t=t||{};var i,s,n={};return 0<m(this).length&&"open"==e&&(0<m(this).find("div[rel=title], div[rel=body], div[rel=buttons]").length?(0<m("#w2ui-popup").length&&(i=m("#w2ui-popup").data("options"),w2popup._prev={template:w2popup._template,title:i.title,body:i.body,buttons:i.buttons}),w2popup._template=this,0<m(this).find("div[rel=title]").length&&(n.title=m(this).find("div[rel=title]")),0<m(this).find("div[rel=body]").length&&(n.body=m(this).find("div[rel=body]"),n.style=m(this).find("div[rel=body]")[0].style.cssText),0<m(this).find("div[rel=buttons]").length&&(n.buttons=m(this).find("div[rel=buttons]"))):(n.title=" ",n.body=m(this).html()),0!==parseInt(m(this).css("width"))&&(n.width=parseInt(m(this).css("width"))),s=t.title||t.showClose||void 0===t.showClose||t.showMax||void 0===t.showMax,0!==parseInt(m(this).css("height"))&&(n.height=parseInt(m(this).css("height"))+(s?32:0))),w2popup[e](m.extend({},n,t))}),maximized:!1,keyboard:!0,width:500,height:300,showClose:!0,showMax:!1,transition:null,multiple:!1},status:"closed",handlers:[],onOpen:null,onClose:null,onMax:null,onMin:null,onToggle:null,onKeydown:null,open:function(e){var t=this,i=m.extend(!0,{},e);if("closing"!=w2popup.status){var s,n,l=m("#w2ui-popup").data("options");e=m.extend({},this.defaults,l,{title:"",body:"",buttons:""},e,{maximized:!1}),setTimeout((function(){m("#w2ui-popup").data("options",e)}),100),0===m("#w2ui-popup").length&&(w2popup.onMax=null,w2popup.onMin=null,w2popup.onToggle=null,w2popup.onOpen=null,w2popup.onClose=null,w2popup.onKeydown=null,w2popup.onAction=null),e.onOpen&&(w2popup.onOpen=e.onOpen),e.onClose&&(w2popup.onClose=e.onClose),e.onMax&&(w2popup.onMax=e.onMax),e.onMin&&(w2popup.onMin=e.onMin),e.onToggle&&(w2popup.onToggle=e.onToggle),e.onKeydown&&(w2popup.onKeydown=e.onKeydown),e.onAction&&(w2popup.onAction=e.onAction),e.width=parseInt(e.width),e.height=parseInt(e.height),null==window.innerHeight?(s=parseInt(document.documentElement.offsetWidth),n=parseInt(document.documentElement.offsetHeight),"IE7"===w2utils.engine&&(s+=21,n+=4)):(s=parseInt(window.innerWidth),n=parseInt(window.innerHeight)),s-10<e.width&&(e.width=s-10),n-10<e.height&&(e.height=n-10);var a,r=(n-e.height)/2*.6,o=(s-e.width)/2;
1if(null!=e.actions&&(e.buttons="",Object.keys(e.actions).forEach((function(t){var i=e.actions[t];"function"==typeof i&&(e.buttons+='<button class="w2ui-btn" onclick="w2popup.action(\''+t+"')\">"+t+"</button>"),"object"==typeof i&&(e.buttons+='<button class="w2ui-btn '+(i.class||"")+'" style="'+(i.style||"")+'"onclick="w2popup.action(\''+t+"')\">"+(i.text||t)+"</button>"),"string"==typeof i&&(e.buttons+=i)}))),0===m("#w2ui-popup").length){if(!0===(a=this.trigger({phase:"before",type:"open",target:"popup",options:e,present:!1})).isCancelled)return;w2popup.status="opening",w2popup.lockScreen(e);var d="";e.showClose&&(d+='<div class="w2ui-popup-button w2ui-popup-close" onmousedown="event.stopPropagation()" onclick="w2popup.close()">Close</div>'),e.showMax&&(d+='<div class="w2ui-popup-button w2ui-popup-max" onmousedown="event.stopPropagation()" onclick="w2popup.toggle()">Max</div>');var u='<div id="w2ui-popup" class="w2ui-popup w2ui-popup-opening" style="left: '+o+"px; top: "+r+"px; width: "+parseInt(e.width)+"px; height: "+parseInt(e.height)+'px;"></div>';m("body").append(u);var c=m("#w2ui-popup");0<c.find("div[rel=title], div[rel=body], div[rel=buttons]").length&&(0<(g=c.find("div[rel=title]")).length&&(e.title=g.html(),g.remove()),0<(g=c.find("div[rel=buttons]")).length&&(e.buttons=g.html(),g.remove()),0<(g=c.find("div[rel=body]")).length?e.body=g.html():e.body=c.html()),u='<div class="w2ui-popup-title" style="'+(e.title?"":"display: none")+'">'+d+'</div><div class="w2ui-box" style="'+(e.title?"":"top: 0px !important;")+(e.buttons?"":"bottom: 0px !important;")+'"> <div class="w2ui-popup-body'+(e.title?"":" w2ui-popup-no-title")+(e.buttons?"":" w2ui-popup-no-buttons")+'" style="'+e.style+'"> </div></div><div class="w2ui-popup-buttons" style="'+(e.buttons?"":"display: none")+'"></div><input class="w2ui-popup-hidden" style="position: absolute; top: -100px"/>',m("#w2ui-popup").html(u),e.title&&m("#w2ui-popup .w2ui-popup-title").append(e.title),e.buttons&&m("#w2ui-popup .w2ui-popup-buttons").append(e.buttons),e.body&&m("#w2ui-popup .w2ui-popup-body").append(e.body),setTimeout((function(){m("#w2ui-popup").css(w2utils.cssPrefix({transition:e.speed+"s opacity, "+e.speed+"s -webkit-transform"})).removeClass("w2ui-popup-opening"),t.focus()}),1),setTimeout((function(){m("#w2ui-popup").css(w2utils.cssPrefix("transform",""))}),1e3*e.speed),w2popup.status="open",t.trigger(m.extend(a,{phase:"after"}))}else if(!0===e.multiple)w2popup.message(i);else{if(null==w2popup._prev&&null!=w2popup._template&&t.restoreTemplate(),!0===(a=this.trigger({phase:"before",type:"open",target:"popup",options:e,present:!0})).isCancelled)return;w2popup.status="opening",null!=l&&(l.maximized||l.width==e.width&&l.height==e.height||w2popup.resize(e.width,e.height),e.prevSize=e.width+"px:"+e.height+"px",e.maximized=l.maximized);var h=m("#w2ui-popup .w2ui-box").clone();h.removeClass("w2ui-box").addClass("w2ui-box-temp").find(".w2ui-popup-body").empty().append(e.body),"string"==typeof e.body&&0<h.find("div[rel=title], div[rel=body], div[rel=buttons]").length&&(0<(g=h.find("div[rel=title]")).length&&(e.title=g.html(),g.remove()),0<(g=h.find("div[rel=buttons]")).length&&(e.buttons=g.html(),g.remove()),0<(g=h.find("div[rel=body]")).length?e.body=g.html():e.body=h.html(),h.html(e.body)),m("#w2ui-popup .w2ui-box").after(h),e.buttons?(m("#w2ui-popup .w2ui-popup-buttons").show().html("").append(e.buttons),m("#w2ui-popup .w2ui-popup-body").removeClass("w2ui-popup-no-buttons"),m("#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp").css("bottom","")):(m("#w2ui-popup .w2ui-popup-buttons").hide().html(""),m("#w2ui-popup .w2ui-popup-body").addClass("w2ui-popup-no-buttons"),m("#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp").css("bottom","0px")),e.title?(m("#w2ui-popup .w2ui-popup-title").show().html((e.showClose?'<div class="w2ui-popup-button w2ui-popup-close" onmousedown="event.stopPropagation()" onclick="w2popup.close()">Close</div>':"")+(e.showMax?'<div class="w2ui-popup-button w2ui-popup-max" onmousedown="event.stopPropagation()" onclick="w2popup.toggle()">Max</div>':"")).append(e.title),m("#w2ui-popup .w2ui-popup-body").removeClass("w2ui-popup-no-title"),m("#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp").css("top","")):(m("#w2ui-popup .w2ui-popup-title").hide().html(""),m("#w2ui-popup .w2ui-popup-body").addClass("w2ui-popup-no-title"),m("#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp").css("top","0px"));var p=m("#w2ui-popup .w2ui-box")[0],f=m("#w2ui-popup .w2ui-box-temp")[0];w2utils.transition(p,f,e.transition,(function(){t.restoreTemplate(),m(p).remove(),m(f).removeClass("w2ui-box-temp").addClass("w2ui-box");var i=m(f).find(".w2ui-popup-body");1==i.length&&(i[0].style.cssText=e.style),m("#w2ui-popup").data("prev-size",null),t.focu
1s()})),w2popup.status="open",t.trigger(m.extend(a,{phase:"after"}))}e._last_focus=m(":focus"),e.keyboard&&m(document).on("keydown",this.keydown);var g={resizing:!1,mvMove:function(e){if(1==g.resizing){e=e||window.event,g.div_x=e.screenX-g.x,g.div_y=e.screenY-g.y;var t=w2popup.trigger({phase:"before",type:"move",target:"popup",div_x:g.div_x,div_y:g.div_y});!0!==t.isCancelled&&(m("#w2ui-popup").css(w2utils.cssPrefix({transition:"none",transform:"translate3d("+g.div_x+"px, "+g.div_y+"px, 0px)"})),w2popup.trigger(m.extend(t,{phase:"after"})))}},mvStop:function(e){1==g.resizing&&(e=e||window.event,w2popup.status="open",g.div_x=e.screenX-g.x,g.div_y=e.screenY-g.y,m("#w2ui-popup").css({left:g.pos_x+g.div_x+"px",top:g.pos_y+g.div_y+"px"}).css(w2utils.cssPrefix({transition:"none",transform:"translate3d(0px, 0px, 0px)"})),g.resizing=!1,m(document).off("mousemove",g.mvMove),m(document).off("mouseup",g.mvStop),g.isLocked||w2popup.unlock())}};return m("#w2ui-popup .w2ui-popup-title").on("mousedown",(function(e){w2popup.get().maximized||function(e){e=e||window.event,w2popup.status="moving",g.resizing=!0,g.isLocked=1==m("#w2ui-popup > .w2ui-lock").length,g.x=e.screenX,g.y=e.screenY,g.pos_x=m("#w2ui-popup").position().left,g.pos_y=m("#w2ui-popup").position().top,g.isLocked||w2popup.lock({opacity:0}),m(document).on("mousemove",g.mvMove),m(document).on("mouseup",g.mvStop),e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,e.preventDefault&&e.preventDefault()}(e)})),this}setTimeout((function(){t.open.call(t,e)}),100)},action:function(e,t){var i=this,s=m("#w2ui-popup").data("options");null!=t&&(i={parent:this,options:s=m("#w2ui-message"+t).data("options"),close:function(){w2popup.message({msgId:t})}});var n=s.actions[e],l=n;m.isPlainObject(n)&&n.onClick&&(l=n.onClick);var a=this.trigger({phase:"before",target:e,msgId:t,type:"action",action:n,originalEvent:event});!0!==a.isCancelled&&("function"==typeof l&&l.call(i,event),this.trigger(m.extend(a,{phase:"after"})))},keydown:function(e){var t,i=m("#w2ui-popup").data("options");i&&!i.keyboard||!0!==(t=w2popup.trigger({phase:"before",type:"keydown",target:"popup",options:i,originalEvent:e})).isCancelled&&(27===e.keyCode&&(e.preventDefault(),0<m("#w2ui-popup .w2ui-message").length?w2popup.message():w2popup.close()),w2popup.trigger(m.extend(t,{phase:"after"})))},close:function(e){var t,i=this;e=m.extend({},m("#w2ui-popup").data("options"),e),0!==m("#w2ui-popup").length&&"closed"!=this.status&&("opening"!=this.status?!0!==(t=this.trigger({phase:"before",type:"close",target:"popup",options:e})).isCancelled&&(w2popup.status="closing",m("#w2ui-popup").css(w2utils.cssPrefix({transition:e.speed+"s opacity, "+e.speed+"s -webkit-transform"})).addClass("w2ui-popup-closing"),w2popup.unlockScreen(e),setTimeout((function(){i.restoreTemplate(),m("#w2ui-popup").remove(),w2popup.status="closed",e._last_focus&&0<e._last_focus.length&&e._last_focus.focus(),i.trigger(m.extend(t,{phase:"after"}))}),1e3*e.speed),e.keyboard&&m(document).off("keydown",this.keydown)):setTimeout((function(){w2popup.close()}),100))},toggle:function(){var e=this,t=m("#w2ui-popup").data("options"),i=this.trigger({phase:"before",type:"toggle",target:"popup",options:t});!0!==i.isCancelled&&(!0===t.maximized?w2popup.min():w2popup.max(),setTimeout((function(){e.trigger(m.extend(i,{phase:"after"}))}),1e3*t.speed+50))},max:function(){var e,t=this,i=m("#w2ui-popup").data("options");!0===i.maximized||!0!==(e=this.trigger({phase:"before",type:"max",target:"popup",options:i})).isCancelled&&(w2popup.status="resizing",i.prevSize=m("#w2ui-popup").css("width")+":"+m("#w2ui-popup").css("height"),w2popup.resize(1e4,1e4,(function(){w2popup.status="open",i.maximized=!0,t.trigger(m.extend(e,{phase:"after"})),m("#w2ui-popup .w2ui-grid, #w2ui-popup .w2ui-form, #w2ui-popup .w2ui-layout").each((function(){var e=m(this).attr("name");w2ui[e]&&w2ui[e].resize&&w2ui[e].resize()}))})))},min:function(){var e,t,i=this,s=m("#w2ui-popup").data("options");!0===s.maximized&&(e=s.prevSize.split(":"),!0!==(t=this.trigger({phase:"before",type:"min",target:"popup",options:s})).isCancelled&&(w2popup.status="resizing",w2popup.resize(parseInt(e[0]),parseInt(e[1]),(function(){w2popup.status="open",s.maximized=!1,s.prevSize=null,i.trigger(m.extend(t,{phase:"after"})),m("#w2ui-popup .w2ui-grid, #w2ui-popup .w2ui-form, #w2ui-popup .w2ui-layout").each((function(){var e=m(this).attr("name");w2ui[e]&&w2ui[e].resize&&w2ui[e].resize()}))}))))}
1,get:function(){return m("#w2ui-popup").data("options")},set:function(e){w2popup.open(e)},clear:function(){m("#w2ui-popup .w2ui-popup-title").html(""),m("#w2ui-popup .w2ui-popup-body").html(""),m("#w2ui-popup .w2ui-popup-buttons").html("")},reset:function(){w2popup.open(w2popup.defaults)},load:function(e){var t,i,s,n;function l(t,i){var s;delete e.url,m("body").append('<div id="w2ui-tmp" style="display: none">'+t+"</div>"),null!=i&&0<m("#w2ui-tmp #"+i).length?m("#w2ui-tmp #"+i).w2popup(e):m("#w2ui-tmp > div").w2popup(e),0<m("#w2ui-tmp > style").length&&(s=m("<div>").append(m("#w2ui-tmp > style").clone()).html(),0===m("#w2ui-popup #div-style").length&&m("#w2ui-popup").append('<div id="div-style" style="position: absolute; left: -100; width: 1px"></div>'),m("#w2ui-popup #div-style").html(s)),m("#w2ui-tmp").remove()}w2popup.status="loading",null!=e.url?(t=String(e.url).split("#"),i=t[0],s=t[1],null==e&&(e={}),null!=(n=m("#w2ui-popup").data(i))?l(n,s):m.get(i,(function(e,t,n){l(n.responseText,s),m("#w2ui-popup").data(i,n.responseText)}))):console.log("ERROR: The url parameter is empty.")},message:function(e){var t=this;m().w2tag(),e=e||{width:200,height:100};var i=parseInt(m("#w2ui-popup").width()),s=parseInt(m("#w2ui-popup").height());e.originalWidth=e.width,e.originalHeight=e.height,parseInt(e.width)<10&&(e.width=10),parseInt(e.height)<10&&(e.height=10),null==e.hideOnClick&&(e.hideOnClick=!1);var n=m("#w2ui-popup").data("options")||{},l=parseInt(m("#w2ui-popup > .w2ui-popup-title").css("height"));(null==e.width||e.width>n.width-10)&&(e.width=n.width-10),(null==e.height||e.height>n.height-l-5)&&(e.height=n.height-l-5),e.originalHeight<0&&(e.height=s+e.originalHeight-l),e.originalWidth<0&&(e.width=i+2*e.originalWidth);var a=m("#w2ui-popup .w2ui-popup-title"),r=m("#w2ui-popup .w2ui-message").length;if(null!=e.actions&&(e.buttons="",Object.keys(e.actions).forEach((function(t){var i=e.actions[t];"function"==typeof i&&(e.buttons+='<button class="w2ui-btn" onclick="w2popup.action(\''+t+"', "+r+')">'+t+"</button>"),"object"==typeof i&&(e.buttons+='<button class="w2ui-btn '+(i.class||"")+'" style="'+(i.style||"")+'"onclick="w2popup.action(\''+t+"', "+r+')">'+(i.text||t)+"</button>"),"string"==typeof i&&(e.buttons+=i)}))),""===m.trim(e.html)&&""===m.trim(e.body)&&""===m.trim(e.buttons)){var o=m("#w2ui-popup .w2ui-message").last();if(null!=e.msgId&&(o=m("#w2ui-message"+e.msgId)),e=o.data("options")||{},!0===(u=t.trigger({phase:"before",type:"msgClose",msgId:o.attr("data-msgId"),target:"popup",options:e})).isCancelled)return;o.css(w2utils.cssPrefix({transition:"0.15s",transform:"translateY(-"+e.height+"px)"}));var d=m("#w2ui-popup .w2ui-message");(d=m(d[d.length-2]).css("z-index",1500).data("msg-focus"))&&0<d.length?d.focus():t.focus(),1==r&&w2popup.unlock(150),setTimeout((function(){o.remove(),"function"==typeof e.onClose&&e.onClose(u),t.trigger(m.extend(u,{phase:"after"}))}),150)}else{""===m.trim(e.body)&&""===m.trim(e.buttons)||(e.html='<div class="w2ui-message-body">'+e.body+'</div><div class="w2ui-message-buttons">'+e.buttons+"</div>"),m("#w2ui-popup .w2ui-message").css("z-index",1390).data("msg-focus",m(":focus")),a.css("z-index",1501),null==e.close&&(e.close=function(){w2popup.message({msgId:r})}),m("#w2ui-popup .w2ui-box").before('<div id="w2ui-message'+r+'" class="w2ui-message" style="display: none; z-index: 1500; '+(0===a.length?"top: 0px;":"top: "+w2utils.getSize(a,"height")+"px;")+(null!=e.width?"width: "+e.width+"px; left: "+(i-e.width)/2+"px;":"left: 10px; right: 10px;")+(null!=e.height?"height: "+e.height+"px;":"bottom: 6px;")+w2utils.cssPrefix("transition","0s",!0)+'" data-msgId="'+r+'" '+(!0===e.hideOnClick?'onclick="w2popup.message();"':"")+"></div>"),m("#w2ui-popup #w2ui-message"+r).data("options",e);var u,c=m("#w2ui-popup #w2ui-message"+r).css("display");if(m("#w2ui-popup #w2ui-message"+r).css(w2utils.cssPrefix({transform:"none"==c?"translateY(-"+e.height+"px)":"translateY(0px)"})),"none"==c){if(m("#w2ui-popup #w2ui-message"+r).show().html(e.html),setTimeout((function(){m("#w2ui-popup #w2ui-message"+r).css(m.extend(w2utils.cssPrefix("transition",".3s",!1),w2utils.cssPrefix({transform:"none"==c?"translateY(0px)":"translateY(-"+e.height+"px)"})))}),1),0===r&&w2popup.lock(),!0===(u=t.trigger({phase:"before",type:"msgOpen",msgId:r,target:"popup",options:e})).isCancelled)return;setTimeout((function(){t.focus(),m("#w2ui-popup #w2ui-message"+r).css(w2utils.cssPrefix({transition:"0s"})),"function"==typeof e.onOpen&&e.onOpen(u),t.trigger(m.extend(u,{phase:"after"}))}),350)}}}
1,focus:function(){var e=null,t=m("#w2ui-popup"),i="input:visible, button:visible, select:visible, textarea:visible, [contentEditable], .w2ui-input";m(t).find(i).off(".keep-focus");var s,n=m("#w2ui-popup .w2ui-message").length-1,l=m("#w2ui-popup #w2ui-message"+n);0<l.length?(0<(s=m(l[l.length-1]).find("button")).length&&s[0].focus(),e=l):0<t.length&&(0<(s=t.find(".w2ui-popup-buttons button")).length&&s[0].focus(),e=t),m(e).find(i).on("blur.keep-focus",(function(t){setTimeout((function(){var t,s=m(":focus");!(0<s.length&&!m(e).find(i).is(s)||s.hasClass("w2ui-popup-hidden"))||0<(t=m(e).find(i)).length&&t[0].focus()}),1)}))},lock:function(e,t){var i=Array.prototype.slice.call(arguments,0);i.unshift(m("#w2ui-popup")),w2utils.lock.apply(window,i)},unlock:function(e){w2utils.unlock(m("#w2ui-popup"),e)},lockScreen:function(e){return!(0<m("#w2ui-lock").length||(null==e&&(e=m("#w2ui-popup").data("options")),null==e&&(e={}),e=m.extend({},w2popup.defaults,e),m("body").append('<div id="w2ui-lock" onmousewheel="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; if (event.preventDefault) event.preventDefault(); else return false;" style="position: '+("IE5"==w2utils.engine?"absolute":"fixed")+"; z-Index: 1199; left: 0px; top: 0px; padding: 0px; margin: 0px; background-color: "+e.color+'; width: 100%; height: 100%; opacity: 0;"></div>'),setTimeout((function(){m("#w2ui-lock").css("opacity",e.opacity).css(w2utils.cssPrefix("transition",e.speed+"s opacity"))}),1),1==e.modal?(m("#w2ui-lock").on("mousedown",(function(){m("#w2ui-lock").css("opacity","0.6").css(w2utils.cssPrefix("transition",".1s"))})),m("#w2ui-lock").on("mouseup",(function(){setTimeout((function(){m("#w2ui-lock").css("opacity",e.opacity).css(w2utils.cssPrefix("transition",".1s"))}),100)}))):m("#w2ui-lock").on("mousedown",(function(){w2popup.close()})),0))},unlockScreen:function(e){return 0!==m("#w2ui-lock").length&&(null==e&&(e=m("#w2ui-popup").data("options")),null==e&&(e={}),e=m.extend({},w2popup.defaults,e),m("#w2ui-lock").css("opacity","0").css(w2utils.cssPrefix("transition",e.speed+"s opacity")),setTimeout((function(){m("#w2ui-lock").remove()}),1e3*e.speed),!0)},resizeMessages:function(){m("#w2ui-popup").data("options"),m("#w2ui-popup .w2ui-message").each((function(){var e=m(this).data("options"),t=m("#w2ui-popup");parseInt(e.width)<10&&(e.width=10),parseInt(e.height)<10&&(e.height=10);var i=parseInt(t.find("> .w2ui-popup-title").css("height")),s=parseInt(t.width()),n=parseInt(t.height());e.width=e.originalWidth,e.width>s-10&&(e.width=s-10),e.height=e.originalHeight,e.height>n-i-5&&(e.height=n-i-5),e.originalHeight<0&&(e.height=n+e.originalHeight-i),e.originalWidth<0&&(e.width=s+2*e.originalWidth),m(this).css({left:(s-e.width)/2+"px",width:e.width+"px",height:e.height+"px"})}))},resize:function(e,t,i){var s,n,l=this,a=m("#w2ui-popup").data("options")||{};null==a.speed&&(a.speed=0),e=parseInt(e),t=parseInt(t),null==window.innerHeight?(s=parseInt(document.documentElement.offsetWidth),n=parseInt(document.documentElement.offsetHeight),"IE7"===w2utils.engine&&(s+=21,n+=4)):(s=parseInt(window.innerWidth),n=parseInt(window.innerHeight)),s-10<e&&(e=s-10),n-10<t&&(t=n-10);var r=(n-t)/2*.6,o=(s-e)/2;m("#w2ui-popup").css(w2utils.cssPrefix({transition:a.speed+"s width, "+a.speed+"s height, "+a.speed+"s left, "+a.speed+"s top"})).css({top:r,left:o,width:e,height:t});var d=setInterval((function(){l.resizeMessages()}),10);setTimeout((function(){clearInterval(d),a.width=e,a.height=t,l.resizeMessages(),"function"==typeof i&&i()}),1e3*a.speed+50)},restoreTemplate:function(){var e=m("#w2ui-popup").data("options");if(null!=e){var t=w2popup._template,i=e.title,s=e.body,n=e.buttons;if(w2popup._prev?(t=w2popup._prev.template,i=w2popup._prev.title,s=w2popup._prev.body,n=w2popup._prev.buttons,delete w2popup._prev):delete w2popup._template,null!=t){var l=m(t);if(0===l.length)return;"body"==m(s).attr("rel")?(i&&l.append(i),s&&l.append(s),n&&l.append(n)):l.append(s)}}}},m.extend(w2popup,w2utils.event);var w2alert=function(e,t,i){var s=jQuery;return null==t&&(t=w2utils.lang("Notification")),0<s("#w2ui-popup").length&&"closing"!=w2popup.status?w2popup.message({width:400,height:170,body:'<div class="w2ui-centered w2ui-alert-msg" style="font-size: 13px;">'+e+"</div>",buttons:'<button onclick="w2popup.message();" class="w2ui-popup-btn w2ui-btn">'+w2utils.lang("Ok")+"</button>",onOpen:function(){s("#w2ui-popup .w2ui-message .w2ui-popup-btn").focus()},onClose:function(){"function"==typeof i&&i()}}):w2popup.open({width:450,height:220,showMax:!1,showClose:!1,title:t,body:'<div class="w2ui-centered w2ui-alert-msg" style="font-size: 13px;">'+e+"</div>",buttons:'<button onclick="w2popup.close();" class="w2ui-popup-btn w2ui-btn">'+w2utils.lang("Ok")+"</button>",onOpen:function(e){setTimeout((function(){s("#w2ui-popup .w2ui-popup-btn").focus()}),1)},onKeydown:function(e){s("#w2ui-popup .w2ui-popup-btn").focus().addClass("clicked")},onClose:function(){"function"==typeof i&&i()}}),{ok:function(e){return i=e,this},done:function(e){return i=e,this}}},w2confirm=function(e,t,i){var s=jQuery,n={},l={msg:"",title:w2utils.lang("Confirmation"),width:0<s("#w2ui-popup").length?400:450,height:0<s("#w2ui-popup").length?170:220,yes_text:"Yes",yes_class:"",yes_style:"",yes_callBack:null,no_text:"No",no_class:"",no_style:"",no_callBack:null,focus_to_no:!1,callBack:null};return 1==arguments.length&&"object"==typeof e?s.extend(n,l,e):"function"==typeof t?s.extend(n,l,{msg:e,callBack:t}):s.extend(n,l,{msg:e,title:t,callBack:i}),"object"==typeof n.btn_yes&&(n.yes_text=n.btn_yes.text||n.yes_text,n.yes_class=n.btn_yes.class||n.yes_class,n.yes_style=n.btn_yes.style||n.yes_style,n.yes_callBack=n.btn_yes.callBack||n.yes_callBack),"object"==typeof n.btn_no&&(n.no_text=n.btn_no.text||n.no_text,n.no_class=n.btn_no.class||n.no_class,n.no_style=n.btn_no.style||n.no_style,n.no_callBack=n.btn_no.callBack||n.no_callBack),0<s("#w2ui-popup").length&&"closing"!=w2popup.status&&w2popup.get()?(n.width>w2popup.get().width&&(n.width=w2popup.get().width),n.height>w2popup.get().height-50&&(n.height=w2popup.get().height-50),w2popup.message({width:n.width,height:n.height,body:'<div class="w2ui-centered w2ui-confirm-msg" style="font-size: 13px;">'+n.msg+"</div>",buttons:w2utils.settings.macButtonOrder?'<button id="No" class="w2ui-popup-btn w2ui-btn '+n.no_class+'" style="'+n.no_style+'">'+w2utils.lang(n.no_text)+'</button><button id="Yes" class="w2ui-popup-btn w2ui-btn '+n.yes_class+'" style="'+n.yes_style+'">'+w2utils.lang(n.yes_text)+"</button>":'<button id="Yes" class="w2ui-popup-btn w2ui-btn '+n.yes_class+'" style="'+n.yes_style+'">'+w2utils.lang(n.yes_text)+'</button><button id="No" class="w2ui-popup-btn w2ui-btn '+n.no_class+'" style="'+n.no_style+'">'+w2utils.lang(n.no_text)+"</button>",onOpen:function(e){s("#w2ui-popup .w2ui-message .w2ui-btn").on("click.w2confirm",(function(e){w2popup._confirm_btn=e.target.id,w2popup.message()})),"function"==typeof n.onOpen&&n.onOpen()},onClose:function(e){s("#w2ui-popup .w2ui-message .w2ui-btn").off("
1click.w2confirm"),setTimeout((function(){"function"==typeof n.callBack&&n.callBack(w2popup._confirm_btn),"Yes"==w2popup._confirm_btn&&"function"==typeof n.yes_callBack&&n.yes_callBack(),"No"==w2popup._confirm_btn&&"function"==typeof n.no_callBack&&n.no_callBack()}),300),"function"==typeof n.onClose&&n.onClose()}})):(w2utils.isInt(n.height)||(n.height=n.height+50),w2popup.open({width:n.width,height:n.height,title:n.title,modal:!0,showClose:!1,body:'<div class="w2ui-centered w2ui-confirm-msg" style="font-size: 13px;">'+n.msg+"</div>",buttons:w2utils.settings.macButtonOrder?'<button id="No" class="w2ui-popup-btn w2ui-btn '+n.no_class+'" style="'+n.no_style+'">'+w2utils.lang(n.no_text)+'</button><button id="Yes" class="w2ui-popup-btn w2ui-btn '+n.yes_class+'" style="'+n.yes_style+'">'+w2utils.lang(n.yes_text)+"</button>":'<button id="Yes" class="w2ui-popup-btn w2ui-btn '+n.yes_class+'" style="'+n.yes_style+'">'+w2utils.lang(n.yes_text)+'</button><button id="No" class="w2ui-popup-btn w2ui-btn '+n.no_class+'" style="'+n.no_style+'">'+w2utils.lang(n.no_text)+"</button>",onOpen:function(e){setTimeout((function(){s("#w2ui-popup .w2ui-popup-btn").on("click",(function(e){w2popup.close(),"function"==typeof n.callBack&&n.callBack(e.target.id),"Yes"==e.target.id&&"function"==typeof n.yes_callBack&&n.yes_callBack(),"No"==e.target.id&&"function"==typeof n.no_callBack&&n.no_callBack()})),n.focus_to_no?s("#w2ui-popup .w2ui-popup-btn#No").focus():s("#w2ui-popup .w2ui-popup-btn#Yes").focus(),"function"==typeof n.onOpen&&n.onOpen()}),1)},onClose:function(e){"function"==typeof n.onClose&&n.onClose()},onKeydown:function(e){if(0===s("#w2ui-popup .w2ui-message").length)switch(e.originalEvent.keyCode){case 13:s("#w2ui-popup .w2ui-popup-btn#Yes").focus().addClass("clicked"),w2popup.close();break;case 27:s("#w2ui-popup .w2ui-popup-btn#No").focus().click(),w2popup.close()}}})),{yes:function(e){return n.yes_callBack=e,this},no:function(e){return n.no_callBack=e,this}}},w2prompt=function(e,t,i){var s=jQuery,n={},l={title:w2utils.lang("Notification"),width:0<s("#w2ui-popup").length?400:450,height:0<s("#w2ui-popup").length?170:220,label:"",value:"",attrs:"",textarea:!1,ok_text:w2utils.lang("Ok"),ok_class:"",cancel_text:w2utils.lang("Cancel"),cancel_class:"",callBack:null,onOpen:null,onClose:null};function a(e,t){"ok"==e&&"function"==typeof n.ok_callBack&&n.ok_callBack(t),"cancel"==e&&"function"==typeof n.cancel_callBack&&n.cancel_callBack(t),"function"==typeof n.callBack&&n.callBack(e,t)}return w2popup.tmp=w2popup.tmp||{},1==arguments.length&&"object"==typeof e?s.extend(n,l,e):"function"==typeof t?s.extend(n,l,{label:e,callBack:t}):s.extend(n,l,{label:e,title:t,callBack:i}),0<s("#w2ui-popup").length&&"closing"!=w2popup.status&&w2popup.get()?(n.width>w2popup.get().width&&(n.width=w2popup.get().width),n.height>w2popup.get().height-50&&(n.height=w2popup.get().height-50),w2popup.message({width:n.width,height:n.height,body:n.textarea?'<div class="w2ui-prompt textarea"> <div>'+n.label+'</div> <textarea id="w2prompt" class="w2ui-input" '+n.attrs+"></textarea></div>":'<div class="w2ui-prompt w2ui-centered"> <label>'+n.label+'</label> <input id="w2prompt" class="w2ui-input" '+n.attrs+"></div>",buttons:w2utils.settings.macButtonOrder?'<button id="Cancel" class="w2ui-popup-btn w2ui-btn '+n.cancel_class+'">'+n.cancel_text+'</button><button id="Ok" class="w2ui-popup-btn w2ui-btn '+n.ok_class+'">'+n.ok_text+"</button>":'<button id="Ok" class="w2ui-popup-btn w2ui-btn '+n.ok_class+'">'+n.ok_text+'</button><button id="Cancel" class="w2ui-popup-btn w2ui-btn '+n.cancel_class+'">'+n.cancel_text+"</button>",onOpen:function(){s("#w2prompt").val(n.value).off(".w2prompt").on("keydown.w2prompt",(function(e){13==e.keyCode&&s("#w2ui-popup .w2ui-message .w2ui-btn#Ok").click()})),s("#w2ui-popup .w2ui-message .w2ui-btn#Ok").off(".w2prompt").on("click.w2prompt",(function(e){w2popup.tmp.btn="ok",w2popup.tmp.value=s("#w2prompt").val(),w2popup.message()})),s("#w2ui-popup .w2ui-message .w2ui-btn#Cancel").off(".w2prompt").on("click.w2prompt",(function(e){w2popup.tmp.btn="cancel",w2popup.tmp.value=null,w2popup.message()})),setTimeout((function(){s("#w2prompt").focus()}),100),"function"==typeof n.onOpen&&n.onOpen()},onClose:function(){s("#w2ui-popup .w2ui-message .w2ui-btn").off("
1click.w2prompt"),setTimeout((function(){a(w2popup.tmp.btn,w2popup.tmp.value)}),300),"function"==typeof n.onClose&&n.onClose()}})):(w2utils.isInt(n.height)||(n.height=n.height+50),w2popup.open({width:n.width,height:n.height,title:n.title,modal:!0,showClose:!1,body:n.textarea?'<div class="w2ui-prompt"> <div>'+n.label+'</div> <textarea id="w2prompt" class="w2ui-input" '+n.attrs+"></textarea></div>":'<div class="w2ui-prompt w2ui-centered" style="font-size: 13px;"> <label>'+n.label+'</label> <input id="w2prompt" class="w2ui-input" '+n.attrs+"></div>",buttons:w2utils.settings.macButtonOrder?'<button id="Cancel" class="w2ui-popup-btn w2ui-btn '+n.cancel_class+'">'+n.cancel_text+'</button><button id="Ok" class="w2ui-popup-btn w2ui-btn '+n.ok_class+'">'+n.ok_text+"</button>":'<button id="Ok" class="w2ui-popup-btn w2ui-btn '+n.ok_class+'">'+n.ok_text+'</button><button id="Cancel" class="w2ui-popup-btn w2ui-btn '+n.cancel_class+'">'+n.cancel_text+"</button>",onOpen:function(e){setTimeout((function(){s("#w2prompt").val(n.value),s("#w2prompt").w2field("text"),s("#w2ui-popup .w2ui-popup-btn#Ok").on("click",(function(e){w2popup.tmp.btn="ok",w2popup.tmp.value=s("#w2prompt").val(),w2popup.close()})),s("#w2ui-popup .w2ui-popup-btn#Cancel").on("click",(function(e){w2popup.tmp.btn="cancel",w2popup.tmp.value=null,w2popup.close()})),s("#w2ui-popup .w2ui-popup-btn#Ok"),setTimeout((function(){s("#w2prompt").focus()}),100),"function"==typeof n.onOpen&&n.onOpen()}),1)},onClose:function(e){a(w2popup.tmp.btn,w2popup.tmp.value),"function"==typeof n.onClose&&n.onClose()},onKeydown:function(e){if(0===s("#w2ui-popup .w2ui-message").length)switch(e.originalEvent.keyCode){case 13:s("#w2ui-popup .w2ui-popup-btn#Ok").focus().addClass("clicked");break;case 27:w2popup.tmp.btn="cancel",w2popup.tmp.value=null}}})),{change:function(e){return s("#w2prompt").on("keyup",e).keyup(),this},ok:function(e){return n.ok_callBack=e,this},cancel:function(e){return n.cancel_callBack=e,this}}},t;!function(e){function t(t){this.box=null,this.name=null,this.active=null,this.reorder=!1,this.flow="down",this.tooltip="top|left",this.tabs=[],this.routeData={},this.tmp={},this.right="",this.style="",e.extend(this,{handlers:[]}),e.extend(!0,this,w2obj.tabs,t)}e.fn.w2tabs=function(i){if(e.isPlainObject(i)){if(!w2utils.checkName(i,"w2tabs"))return;for(var s=i.tabs||[],n=new t(i),l=0;l<s.length;l++)n.tabs[l]=e.extend({},t.prototype.tab,s[l]);return w2ui[n.name]=n,0!==e(this).length&&n.render(e(this)[0]),n}var a=w2ui[e(this).attr("name")];return a?0<arguments.length?(a[i]&&a[i].apply(a,Array.prototype.slice.call(arguments,1)),this):a:null},t.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(e){return this.insert(null,e)},insert:function(i,s){e.isArray(s)||(s=[s]);for(var n=0;n<s.length;n++){if(null==s[n].id)return void console.log('ERROR: The parameter "id" is required but not supplied. (obj: '+this.name+")");if(!w2utils.checkUniqueId(s[n].id,this.tabs,"tabs",this.name))return;var l,a,r=e.extend({},t.prototype.tab,s[n]);null==i?this.tabs.push(r):(l=this.get(i,!0),a=this.tabs[l].id,this.insertTabHTML(a,r))}},remove:function(){for(var t=0,i=0;i<arguments.length;i++){var s=this.get(arguments[i]);if(!s)return!1;t++,this.tabs.splice(this.get(s.id,!0),1),e(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(s.id)).remove()}return this.resize(),t},select:function(e){return this.active!=e&&null!=this.get(e)&&(this.active=e,this.refresh(),!0)},set:function(t,i){var s=this.get(t,!0);return null!=s&&(e.extend(this.tabs[s],i),this.refresh(t),!0)},get:function(e,t){if(0===arguments.length){for(var i=[],s=0;s<this.tabs.length;s++)null!=this.tabs[s].id&&i.push(this.tabs[s].id);return i}for(var n=0;n<this.tabs.length;n++)if(this.tabs[n].id==e)return!0===t?n:this.tabs[n];return null},show:function(){for(var e=this,t=0,i=[],s=0;s<arguments.length;s++){var n=this.get(arguments[s]);n&&!1!==n.hidden&&(t++,n.hidden=!1,i.push(n.id))}return setTimeout((function(){for(var t=0;t<i.length;t++)e.refresh(i[t]);e.resize()}),15),t},hide:function(){for(var e=this,t=0,i=[],s=0;s<arguments.length;s++){var n=this.get(arguments[s]);n&&!0!==n.hidden&&(t++,n.hidden=!0,i.push(n.id))}return setTimeout((function(){for(var t=0;t<i.length;t++)e.refresh(i[t]);e.resize()}),15),t},enable:function(){for(var e=this,t=0,i=[],s=0;s<arguments.length;s++){var n=this.get(arguments[s]);n&&!1!==n.disabled&&(t++,n.disabled=!1,i.push(n.id))}return setTimeout((function(){for(var t=0;t<i.length;t++)e.refresh(i[t])}),15),t},disable:function(){for(var e=this,t=0,i=[],s=0;s<arguments.length;s++){var n=this.get(arguments[s]);n&&!0!==n.disabled&&(t++,n.disabled=!0,i.push(n.id))}return setTimeout((function(){for(var t=0;t<i.length;t++)e.refresh(i[t])}),15),t},dragMove:function(t){if(this.tmp.reordering){var i=this,s=this.tmp.moving,n=this.tabs[s.index],l=p(s.index,1),a=p(s.index,-1),r=e("#tabs_"+this.name+"_tab_"+w2utils.escapeId(n.id));if(0<s.divX&&l){var o=e("#tabs_"+this.name+"_tab_"+w2utils.escapeId(l.id)),d=parseInt(r.css("width")),u=parseInt(o.css("width"));if(u-=d=d<u?Math.floor(d/3):Math.floor(u/3),s.divX>u){var c=this.tabs.indexOf(l);return this.tabs.splice(s.index,0,this.tabs.splice(c,1)[0]),s.$tab.before(o),s.$tab.css("opacity",0),void Object.assign(this.tmp.moving,{index:c,divX:-d,x:t.pageX+d,left:s.left+s.divX+d})}}if(s.divX<0&&a){var h=e("#tabs_"+this.name+"_tab_"+w2utils.escapeId(a.id));if(d=parseInt(r.css("width")),u=parseInt(h.css("width")),u-=d=d<u?Math.floor(d/3):Math.floor(u/3),Math.abs(s.divX)>u)return c=this.tabs.indexOf(a),this.tabs.splice(s.index,0,this.tabs.splice(c,1)[0]),h.before(s.$tab),s.$tab.css("opacity",0),void Object.assign(s,{index:c,divX:d,x:t.pageX-d,left:s.left+s.divX-d})}}function p(e,t){e+=t;var s=i.tabs[e];return s&&s.hidden&&(s=p(e,t)),s}},tooltipShow:function(t,i,s){var n,l,a=this.get(t),r=e(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(t));null==this.tooltip||a.disabled||this.tmp.reordering||(n=this.tooltip,"function"==typeof(l=a.tooltip)&&(l=l.call(this,a)),r.prop("_mouse_over",!0),setTimeout((function(){!0===r.prop("_mouse_over")&&!0!==r.prop("_mouse_tooltip")&&(r.prop("_mouse_tooltip",!0),r.w2tag(w2utils.lang(l),{position:n})),1==s&&r.w2tag(w2utils.lang(l),{position:n})}),1))},tooltipHide:function(t){var i=this.get(t),s=e(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(t));null==this.tooltip||i.disabled||this.tmp.reordering||(s.removeProp("_mouse_over"),setTimeout((function(){!0!==s.prop("_mouse_over")&&!0===s.prop("_mouse_tooltip")&&(s.removeProp("_mouse_tooltip"),s.w2tag())}),1))},getTabHTML:function(e){var t=this.get(e,!0),i=this.tabs[t];if(null==i)return!1;null==i.text&&null!=i.caption&&(i.text=i.caption),null==i.tooltip&&null!=i.hint&&(i.tooltip=i.hint),null!=i.caption&&console.log("NOTICE: tabs tab.caption property is deprecated, please use tab.text. Tab -> ",i),null!=i.hint&&console.log("NOTICE: tabs tab.hint property is deprecated, please use tab.tooltip. Tab -> ",i);var s=i.text;"function"==typeof s&&(s=s.call(this,i)),null==s&&(s="");var n="",l="";return i.hidden&&(l+="display: none;"),i.disabled&&(l+="opacity: 0.2;"),i.closable&&!i.disabled&&(n='<div class="w2ui-tab-close'+(this.active===i.id?" active":"")+'" onmouseover= "w2ui[\''+this.name+"'].tooltipShow('"+i.id+"', event)\" onmouseout = \"w2ui['"+this.name+"'].tooltipHide('"+i.id+'\', event)" onmousedown= "event.stopPropagation()" onmouseup = "w2ui[\''+this.name+"'].animateClose('"+i.id+"', event); event.stopPropagation()\"></div>"),'<div id="tabs_'+this.name+"_tab_"+i.id+'" style="'+l+" "+i.style+'" class="w2ui-tab'+(this.active===i.id?" active":"")+(i.closable?" closable":"")+(i.class?" "+i.class:"")+'" onmouseover = "w2ui[\''+this.name+"'].tooltipShow('"+i.id+"', event)\" onmouseout = \"w2ui['"+this.name+"'].tooltipHide('"+i.id+"', event)\" onmousedown = \"w2ui['"+this.name+"'].initReorder('"+i.id+"', event)\" onclick = \"w2ui['"+this.name+"'].click('"+i.id+"', event)\">"+w2utils.lang(s)+n+"</div>"},refresh:function(t){var i=(new Date).getTime();"up"==this.flow?e(this.box).addClass("w2ui-tabs-up"):e(this.box).removeClass("w2ui-tabs-up");var s=this.trigger({phase:"before",type:"refresh",target:null!=t?t:this.name,object:this.get(t)});if(!0!==s.isCancelled){if(null==t)for(var n=0;n<this.tabs.length;n++)this.refresh(this.tabs[n].id);else{var l=e(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(t)),a=this.getTabHTML(t);0===l.length?e(this.box).find("#tabs_"+this.name+"_right").before(a):l.replaceWith(a)}return e("#tabs_"+this.name+"_right").html(this.right),this.trigger(e.extend(s,{phase:"after"})),(new Date).getTime()-i}},render:function(t){var i=(new Date).getTime(),s=this.trigger({phase:"before",type:"render",target:this.name,box:t});if(!0!==s.isCancelled){if(null!=t&&(0<e(this.box).find("#tabs_"+this.name+"_right").length&&e(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-tabs").html(""),this.box=t),!this.box)return!1;var n='<div class="w2ui-scroll-wrapper" onmousedown="var el=w2ui[\''+this.name+'\']; if (el) el.resize();"> <div class="w2ui-tabs-line"></div> <div id="tabs_'+this.name+'_right" class="w2ui-tabs-right">'+this.right+'</div></div><div class="w2ui-scroll-left" onclick="var el=w2ui[\''+this.name+"']; if (el) el.scroll('left');\"></div><div class=\"w2ui-scroll-right\" onclick=\"var el=w2ui['"+this.name+"']; if (el) el.scroll('right');\"></div>";return e(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-tabs").html(n),0<e(this.box).length&&(e(this.box)[0].style.cssText+=this.style),this.trigger(e.extend(s,{phase:"after"})),this.refresh(),this.resize(),(new Date).getTime()-i}},initReorder:function(t,i){var s,n,l,a,r;this.reorder&&(n=e("#tabs_"+(s=this).name+"_tab_"+w2utils.escapeId(t)),l=this.get(t,!0),(a=n.clone()).attr("id","#tabs_"+this.name+"_tab_ghost"),this.tmp.moving={index:l,indexFrom:l,$tab:n,$ghost:a,divX:0,left:n.offset().left,parentX:e(this.box).offset().left,x:i.pageX,opacity:n.css("opacity")},e("body").off(".w2uiTabReorder").on("mousemove.w2uiTabReorder",(function(t){if(!s.tmp.reordering){if(!0===(r=s.trigger({phase:"before",type:"reorder",target:s.tabs[l].id,indexFrom:l,tab:s.tabs[l]})).isCancelled)return;e().w2tag(),s.tmp.reordering=!0,a.addClass("moving"),a.css({"pointer-events":"none",position:"absolute",left:n.offset().left}),n.css("opacity",0),e(s.box).find(".w2ui-scroll-wrapper").append(a),e(s.box).find(".w2ui-tab-close").hide()}s.tmp.moving.divX=t.pageX-s.tmp.moving.x,a.css("left",s.tmp.moving.left-s.tmp.moving.parentX+s.tmp.moving.divX+"px"),s.dragMove(t)})).on("mouseup.w2uiTabReorder",(function(){e("body").off(".w2uiTabReorder"),a.css({transition:"0.1s",left:s.tmp.moving.$tab.offset().left-s.tmp.moving.parentX}),e(s.box).find(".w2ui-tab-close").show(),setTimeout((function(){a.remove(),n.css({opacity:s.tmp.moving.opacity}),s.tmp.reordering&&(s.trigger(e.extend(r,{phase:"after",indexTo:s.tmp.moving.index})),!0===r.isCancelled)||(s.tmp.reordering=!1)}),100)})))},scroll:function(t){var i,s=e(this.box),n=this,l=s.find(".w2ui-scroll-wrapper"),a=l.scrollLeft(),r=e(this.box).find(".w2ui-tabs-right"),o=l.outerWidth(),d=a+parseInt(r.offset().left)+parseInt(r.width());switch(t){case"left":(i=a-o+50)<=0&&(i=0),l.animate({scrollLeft:i},300);break;case"right":d-o<=(i=a+o-50)&&(i=d-o),l.animate({scrollLeft:i},300)}setTimeout((function(){n.resize()}),350)},resize:function(){var t=(new Date).getTime(),i=this.trigger({phase:"before",type:"resize",target:this.name});if(!0!==i.isCancelled){var s=e(this.box);s.find(".w2ui-scroll-left, .w2ui-scroll-right").hide();var n,l=s.find(".w2ui-scroll-wrapper"),a=e(this.box).find(".w2ui-tabs-right"),r=l.outerWidth(),o=0<a.length?a[0].offsetLeft+a[0].clientWidth:0;return r<o&&(0<l.scrollLeft()&&s.find(".w2ui-scroll-left").show(),n=parseInt(l.css("padding-right")),r<o-l.scrollLeft()-n&&s.find(".w2ui-scroll-right").show()),this.trigger(e.extend(i,{phase:"after"})),(new Date).getTime()-t}},destroy:function(){var t=this.trigger({phase:"before",type:"destroy",target:this.name});!0!==t.isCancelled&&(0<e(this.box).find("#tabs_"+this.name+"_right").length&&e(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-tabs").html(""),delete w2ui[this.name],this.trigger(e.extend(t,{phase:"after"})))},click:function(t,i){var s=this.get(t);if(null==s||s.disabled||this.tmp.reordering)return!1;var n=this.trigger({phase:"before",type:"click",target:t,tab:s,object:s,originalEvent:i});if(!0!==n.isCancelled){if(e(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.active)).removeClass("active"),e(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.active)).removeClass("active"),this.active=s.id,"string"==typeof s.route){var l=""!==s.route?String("/"+s.route).replace(/\/{2,}/g,"/"):"",a=w2utils.parseRoute(l);
1if(0<a.keys.length)for(var r=0;r<a.keys.length;r++)null!=this.routeData[a.keys[r].name]&&(l=l.replace(new RegExp(":"+a.keys[r].name,"g"),this.routeData[a.keys[r].name]));setTimeout((function(){window.location.hash=l}),1)}this.trigger(e.extend(n,{phase:"after"})),this.refresh(t)}},animateClose:function(t,i){var s=this.get(t);if(null==s||s.disabled)return!1;var n,l,a=this.trigger({phase:"before",type:"close",target:t,object:this.get(t),originalEvent:i});!0!==a.isCancelled&&((l=e((n=this).box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(s.id))).css({opacity:0,transition:".25s"}).find(".w2ui-tab-close").remove(),l.css({"padding-left":0,"padding-right":0,"text-overflow":"clip",overflow:"hidden",width:"0px"}),setTimeout((function(){n.remove(t),n.trigger(e.extend(a,{phase:"after"})),n.refresh()}),250))},insertTabHTML:function(t,i){var s=this.get(t,!0);this.tabs=this.tabs.slice(0,s).concat([i],this.tabs.slice(s));var n=e(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(t)),l=e(this.getTabHTML(i.id));n.before(l),this.resize()}},e.extend(t.prototype,w2utils.event),w2obj.tabs=t}(jQuery),function(e){function t(t){this.box=null,this.name=null,this.routeData={},this.items=[],this.right="",this.tooltip="top|left",e.extend(!0,this,w2obj.toolbar,t)}e.fn.w2toolbar=function(i){if(e.isPlainObject(i)){if(!w2utils.checkName(i,"w2toolbar"))return;var s=i.items||[],n=new t(i);e.extend(n,{items:[],handlers:[]});for(var l=0;l<s.length;l++)if(n.items[l]=e.extend({},t.prototype.item,s[l]),"menu-check"==n.items[l].type){var a=n.items[l];if(Array.isArray(a.selected)||(a.selected=[]),Array.isArray(a.items))for(var r=0;r<a.items.length;r++)(o=a.items[r]).checked&&-1==a.selected.indexOf(o.id)&&a.selected.push(o.id),o.checked||-1==a.selected.indexOf(o.id)||(o.checked=!0),null==o.checked&&(o.checked=!1)}else if("menu-radio"==n.items[l].type&&(a=n.items[l],Array.isArray(a.items))){var o;for(r=0;r<a.items.length;r++)(o=a.items[r]).checked&&null==a.selected?a.selected=o.id:o.checked=!1,o.checked||a.selected!=o.id||(o.checked=!0),null==o.checked&&(o.checked=!1)}return w2ui[n.name]=n,0!==e(this).length&&n.render(e(this)[0]),n}var d=w2ui[e(this).attr("name")];return d?0<arguments.length?(d[i]&&d[i].apply(d,Array.prototype.slice.call(arguments,1)),this):d:null},t.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,group:null,items:null,selected:null,overlay:{},color:null,options:{advanced:!1,transparent:!0,html:""},onClick:null,onRefresh:null},add:function(e){this.insert(null,e)},insert:function(i,s){e.isArray(s)||(s=[s]);for(var n=0;n<s.length;n++){if(null==s[n].type)return void console.log('ERROR: The parameter "type" is required but not supplied in w2toolbar.add() method.');if(-1==e.inArray(String(s[n].type),["button","check","radio","drop","menu","menu-radio","menu-check","color","text-color","break","html","spacer"]))return void console.log('ERROR: The parameter "type" should be one of the following [button, check, radio, drop, menu, break, html, spacer] in w2toolbar.add() method.');if(null==s[n].id&&"break"!=s[n].type&&"spacer"!=s[n].type)return void console.log('ERROR: The parameter "id" is required but not supplied in w2toolbar.add() method.');if(!w2utils.checkUniqueId(s[n].id,this.items,"toolbar items",this.name))return;var l,a=e.extend({},t.prototype.item,s[n]);null==i?this.items.push(a):(l=this.get(i,!0),this.items=this.items.slice(0,l).concat([a],this.items.slice(l))),this.refresh(a.id),this.resize()}},remove:function(){for(var t=0,i=0;i<arguments.length;i++){var s,n=this.get(arguments[i]);n&&-1==String(arguments[i]).indexOf(":")&&(t++,e(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(n.id)).remove(),null!=(s=this.get(n.id,!0))&&this.items.splice(s,1))}return this.resize(),t},set:function(t,i){var s=this.get(t);return null!=s&&(e.extend(s,i),this.refresh(String(t).split(":")[0]),!0)},get:function(e,t){if(0===arguments.length){for(var i=[],s=0;s<this.items.length;s++)null!=this.items[s].id&&i.push(this.items[s].id);return i}for(var n=String(e).split(":"),l=0;l<this.items.length;l++){var a=this.items[l];if(-1!=["menu","menu-radio","menu-check"].indexOf(a.type)&&2==n.length&&a.id==n[0]){var r=a.items;"function"==typeof r&&(r=r(this));for(var o=0;o<r.length;o++){var d=r[o];if(d.id==n[1]||null==d.id&&d.text==n[1])return 1==t?o:d;if(Array.isArray(d.items))for(var u=0;u<d.items.length;u++)if(d.items[u].id==n[1]||null==d.items[u].id&&d.items[u].text==n[1])return 1==t?o:d.items[u]}}else if(a.id==n[0])return 1==t?l:a}return null},show:function(){for(var e=this,t=0,i=[],s=0;s<arguments.length;s++){var n=this.get(arguments[s]);n&&(t++,n.hidden=!1,i.push(String(arguments[s]).split(":")[0]))}return setTimeout((function(){for(var t=0;t<i.length;t++)e.refresh(i[t]);e.resize()}),15),t},hide:function(){for(var e=this,t=0,i=[],s=0;s<arguments.length;s++){var n=this.get(arguments[s]);n&&(t++,n.hidden=!0,i.push(String(arguments[s]).split(":")[0]))}return setTimeout((function(){for(var t=0;t<i.length;t++)e.refresh(i[t]),e.tooltipHide(i[t]);e.resize()}),15),t},enable:function(){for(var e=this,t=0,i=[],s=0;s<arguments.length;s++){var n=this.get(arguments[s]);n&&(t++,n.disabled=!1,i.push(String(arguments[s]).split(":")[0]))}return setTimeout((function(){for(var t=0;t<i.length;t++)e.refresh(i[t])}),15),t},disable:function(){for(var e=this,t=0,i=[],s=0;s<arguments.length;s++){var n=this.get(arguments[s]);n&&(t++,n.disabled=!0,i.push(String(arguments[s]).split(":")[0]))}return setTimeout((function(){for(var t=0;t<i.length;t++)e.refresh(i[t]),e.tooltipHide(i[t])}),15),t},check:function(){for(var e=this,t=0,i=[],s=0;s<arguments.length;s++){var n=this.get(arguments[s]);n&&-1==String(arguments[s]).indexOf(":")&&(t++,n.checked=!0,i.push(String(arguments[s]).split(":")[0]))}return setTimeout((function(){for(var t=0;t<i.length;t++)e.refresh(i[t])}),15),t},uncheck:function(){for(var t=this,i=0,s=[],n=0;n<arguments.length;n++){var l=this.get(arguments[n]);l&&-1==String(arguments[n]).indexOf(":")&&(-1!=["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(l.type)&&l.checked&&setTimeout((function(){e("#tb_"+t.name+"_item_"+w2utils.escapeId(l.id)).w2overlay({name:t.name,data:{"tb-item":l.id}})}),1),i++,l.checked=!1,s.push(String(arguments[n]).split(":")[0]))}return setTimeout((function(){for(var e=0;e<s.length;e++)t.refresh(s[e])}),15),i},click:function(t,i){var s=this,n=String(t).split(":"),l=this.get(n[0]),a=l&&l.items?w2obj.field.prototype.normMenu.call(this,l.items,l):[];if(1<n.length){var r=this.get(t);r&&!r.disabled&&s.menuClick({name:s.name,item:l,subItem:r,originalEvent:i})}else if(l&&!l.disabled){var o=this.trigger({phase:"before",type:"click",target:null!=t?t:this.name,item:l,object:l,originalEvent:i});if(!0===o.isCancelled)return;var d="#tb_"+this.name+"_item_"+w2utils.escapeId(l.id)+" table.w2ui-button";if(e(d).removeClass("down"),"radio"==l.type){for(var u=0;u<this.items.length;u++){var c=this.items[u];null!=c&&c.id!=l.id&&"radio"===c.type&&c.group==l.group&&c.checked&&(c.checked=!1,this.refresh(c.id))}l.checked=!0,e(d).addClass("checked")}if(-1!=["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(l.type)&&(s.tooltipHide(t),l.checked?setTimeout((function(){e("#tb_"+s.name+"_item_"+w2utils.escapeId(l.id)).w2overlay({name:s.name,data:{"tb-item":l.id}}),l.checked=!1,s.refresh(l.id)}),1):setTimeout((function(){var t=e("#tb_"+s.name+"_item_"+w2utils.escapeId(l.id));e.isPlainObject(l.overlay)||(l.overlay={});var i,n=(t.width()-50)/2;function r(){l.checked=!1,e(d).removeClass("checked")}19<n&&(n=19),"drop"==l.type&&t.w2overlay(l.html,e.extend({name:s.name,left:n,top:3,data:{"tb-item":l.id}}
1,l.overlay,{onHide:function(e){r()}})),-1!=["menu","menu-radio","menu-check"].indexOf(l.type)&&(i="normal","menu-radio"==l.type&&(i="radio",a.forEach((function(e){l.selected==e.id?e.checked=!0:e.checked=!1}))),"menu-check"==l.type&&(i="check",a.forEach((function(t){e.isArray(l.selected)&&-1!=l.selected.indexOf(t.id)?t.checked=!0:t.checked=!1}))),t.w2menu(e.extend({name:s.name,items:a,left:n,top:3,data:{"tb-item":l.id}},l.overlay,{type:i,remove:function(e){s.menuClick({name:s.name,remove:!0,item:l,subItem:e.item,originalEvent:e.originalEvent,keepOpen:e.keepOpen})},select:function(e){s.menuClick({name:s.name,item:l,subItem:e.item,originalEvent:e.originalEvent,keepOpen:e.keepOpen})},onHide:function(e){r()}}))),-1!=["color","text-color"].indexOf(l.type)&&e(t).w2color(e.extend({color:l.color,onHide:function(e){r(),s._tmpColor&&s.colorClick({name:s.name,item:l,color:s._tmpColor,final:!0}),delete s._tmpColor},onSelect:function(e){null!=e&&(s.colorClick({name:s.name,item:l,color:e}),s._tmpColor=e)}},l.options))}),1)),-1!=["check","menu","menu-radio","menu-check","drop","color","text-color"].indexOf(l.type)&&(l.checked=!l.checked,l.checked?e(d).addClass("checked"):e(d).removeClass("checked")),l.route){var h=String("/"+l.route).replace(/\/{2,}/g,"/"),p=w2utils.parseRoute(h);
1if(0<p.keys.length)for(var f=0;f<p.keys.length;f++)h=h.replace(new RegExp(":"+p.keys[f].name,"g"),this.routeData[p.keys[f].name]);setTimeout((function(){window.location.hash=h}),1)}i&&-1!=["button","check","radio"].indexOf(l.type)&&this.tooltipShow(t,i,!0),this.trigger(e.extend(o,{phase:"after"}))}},scroll:function(t){var i,s,n,l=e(this.box),a=this,r=l.find(".w2ui-scroll-wrapper"),o=r.scrollLeft();switch(t){case"left":i=r.outerWidth(),s=r.find(":first").outerWidth(),(n=o-i+50)<=0&&(n=0),r.animate({scrollLeft:n},300);break;case"right":i=r.outerWidth(),(s=r.find(":first").outerWidth())-i<=(n=o+i-50)&&(n=s-i),r.animate({scrollLeft:n},300)}setTimeout((function(){a.resize()}),350)},render:function(t){var i=(new Date).getTime(),s=this.trigger({phase:"before",type:"render",target:this.name,box:t});if(!0!==s.isCancelled&&(null!=t&&(0<e(this.box).find("> table #tb_"+this.name+"_right").length&&e(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-toolbar").html(""),this.box=t),this.box)){for(var n='<div class="w2ui-scroll-wrapper" onmousedown="var el=w2ui[\''+this.name+'\']; if (el) el.resize();"><table cellspacing="0" cellpadding="0" width="100%"><tbody><tr>',l=0;l<this.items.length;l++){var a=this.items[l];null!=a&&(null==a.id&&(a.id="item_"+l),null!=a.caption&&console.log("NOTICE: toolbar item.caption property is deprecated, please use item.text. Item -> ",a),null!=a.hint&&console.log("NOTICE: toolbar item.hint property is deprecated, please use item.tooltip. Item -> ",a),"spacer"==a.type?n+='<td width="100%" id="tb_'+this.name+"_item_"+a.id+'" align="right"></td>':"new-line"==a.type?n+='<td width="100%"></td></tr></tbody></table><div class="w2ui-toolbar-new-line"></div><table cellspacing="0" cellpadding="0" width="100%"><tbody><tr>':n+='<td id="tb_'+this.name+"_item_"+a.id+'" style="'+(a.hidden?"display: none":"")+'" class="'+(a.disabled?"disabled":"")+'" valign="middle"></td>')}return n+='<td width="100%" id="tb_'+this.name+'_right" align="right">'+this.right+"</td>",n+='</tr></tbody></table></div><div class="w2ui-scroll-left" onclick="var el=w2ui[\''+this.name+"']; if (el) el.scroll('left');\"></div><div class=\"w2ui-scroll-right\" onclick=\"var el=w2ui['"+this.name+"']; if (el) el.scroll('right');\"></div>",e(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-toolbar").html(n),0<e(this.box).length&&(e(this.box)[0].style.cssText+=this.style),this.refresh(),this.resize(),this.trigger(e.extend(s,{phase:"after"})),(new Date).getTime()-i}},refresh:function(t){var i=(new Date).getTime(),s=this.trigger({phase:"before",type:"refresh",target:null!=t?t:this.name,item:this.get(t)});if(!0!==s.isCancelled){if(null!=t){var n=this.get(t);if(null==n)return!1;if("function"==typeof n.onRefresh){var l=this.trigger({phase:"before",type:"refresh",target:t,item:n,object:n});if(!0===l.isCancelled)return}var a,r=e(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(n.id)),o=this.getItemHTML(n);return this.tooltipHide(t,{}),0===r.length?(o="spacer"==n.type?'<td width="100%" id="tb_'+this.name+"_item_"+n.id+'" align="right"></td>':'<td id="tb_'+this.name+"_item_"+n.id+'" style="'+(n.hidden?"display: none":"")+'" class="'+(n.disabled?"disabled":"")+'" valign="middle">'+o+"</td>",this.get(t,!0)==this.items.length-1?e(this.box).find("#tb_"+this.name+"_right").before(o):e(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(this.items[parseInt(this.get(t,!0))+1].id)).before(o)):(-1==["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(n.type)||0<(a=e("#w2ui-overlay-"+this.name)).length&&(0==n.checked?a[0].hide():-1!=["menu","menu-radio","menu-check"].indexOf(n.type)&&a.w2menu("refresh",{items:n.items})),r.html(o),n.hidden?r.css("display","none"):r.css("display",""),n.disabled?r.addClass("disabled"):r.removeClass("disabled")),"function"==typeof n.onRefresh&&this.trigger(e.extend(l,{phase:"after"})),this.trigger(e.extend(s,{phase:"after"})),(new Date).getTime()-i}for(var d=0;d<this.items.length;d++){var u=this.items[d];null==u.id&&(u.id="item_"+d),this.refresh(u.id)}}},resize:function(){var t=(new Date).getTime(),i=this.trigger({phase:"before",type:"resize",target:this.name});if(!0!==i.isCancelled){var s=e(this.box);s.find(".w2ui-scroll-left, .w2ui-scroll-right").hide();var n=s.find(".w2ui-scroll-wrapper");return n.find(":first").outerWidth()>n.outerWidth()&&(0<n.scrollLeft()&&s.find(".w2ui-scroll-left").show(),n.scrollLeft()<n.find(":first").outerWidth()-n.outerWidth()&&s.find(".w2ui-scroll-right").show()),this.trigger(e.extend(i,{phase:"after"})),(new Date).getTime()-t}},destroy:function(){var t=this.trigger({phase:"before",type:"destroy",target:this.name});!0!==t.isCancelled&&(0<e(this.box).find("> table #tb_"+this.name+"_right").length&&e(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-toolbar").html(""),e(this.box).html(""),delete w2ui[this.name],this.trigger(e.extend(t,{phase:"after"})))},getItemHTML:function(e){var t="";null!=e.caption&&null==e.text&&(e.text=e.caption),null==e.text&&(e.text=""),null==e.tooltip&&null!=e.hint&&(e.tooltip=e.hint),null==e.tooltip&&(e.tooltip=""),"function"==typeof e.get||!Array.isArray(e.items)&&"function"!=typeof e.items||(e.get=function(t){var i=e.items;return"function"==typeof i&&(i=e.items(e)),i.find((function(e){return e.id==t}))});var i="<td> </td>",s="function"==typeof e.text?e.text.call(this,e):e.text;if(e.img&&(i='<td><div class="w2ui-tb-image w2ui-icon '+e.img+'"></div></td>'),e.icon&&(i='<td><div class="w2ui-tb-image"><span class="'+("function"==typeof e.icon?e.icon.call(this,e):e.icon)+'"></span></div></td>'),""===t)switch(e.type){case"color":case"text-color":"string"==typeof e.color&&("#"==e.color.substr(0,1)&&(e.color=e.color.substr(1)),3!=e.color.length&&6!=e.color.length||(e.color="#"+e.color)),"color"==e.type&&(s='<div style="height: 12px; width: 12px;
1 margin-top: 1px; border: 1px solid #8A8A8A; border-radius: 1px; box-shadow: 0px 0px 1px #fff; background-color: '+(null!=e.color?e.color:"#fff")+'; float: left;"></div>'+(e.text?'<div style="margin-left: 17px;">'+w2utils.lang(e.text)+"</div>":"")),"text-color"==e.type&&(s='<div style="color: '+(null!=e.color?e.color:"#444")+';">'+(e.text?w2utils.lang(e.text):"<b>Aa</b>")+"</div>");case"menu":case"menu-check":case"menu-radio":case"button":case"check":case"radio":case"drop":t+='<table cellpadding="0" cellspacing="0" class="w2ui-button '+(e.checked?"checked":"")+" "+(e.class?e.class:"")+'" onclick = "var el=w2ui[\''+this.name+"']; if (el) el.click('"+e.id+'\', event);" onmouseenter = "'+(e.disabled?"":"jQuery(this).addClass('over'); w2ui['"+this.name+"'].tooltipShow('"+e.id+"', event);")+'" onmouseleave = "'+(e.disabled?"":"jQuery(this).removeClass('over').removeClass('down'); w2ui['"+this.name+"'].tooltipHide('"+e.id+"', event);")+'" onmousedown = "'+(e.disabled?"":"jQuery(this).addClass('down');")+'" onmouseup = "'+(e.disabled?"":"jQuery(this).removeClass('down');")+'"><tbody><tr><td> <table cellpadding="1" cellspacing="0"><tbody> <tr>'+i+(""!==s?'<td class="w2ui-tb-text w2ui-tb-caption" nowrap="nowrap" style="'+(e.style?e.style:"")+'">'+w2utils.lang(s)+"</td>":"")+(null!=e.count?'<td class="w2ui-tb-count" nowrap="nowrap"><span>'+e.count+"</span></td>":"")+(-1!=["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(e.type)&&!1!==e.arrow?'<td class="w2ui-tb-down" nowrap="nowrap"><div></div></td>':"")+" </tr></tbody></table></td></tr></tbody></table>";break;case"break":t+='<table cellpadding="0" cellspacing="0"><tbody><tr> <td><div class="w2ui-break"> </div></td></tr></tbody></table>';break;case"html":t+='<table cellpadding="0" cellspacing="0"><tbody><tr> <td nowrap="nowrap">'+("function"==typeof e.html?e.html.call(this,e):e.html)+"</td></tr></tbody></table>"}return"<div>"+t+"</div>"},tooltipShow:function(t,i,s){var n,l,a,r;null!=this.tooltip&&(n=e(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(t)),l=this.get(t),a=this.tooltip,"function"==typeof(r=l.tooltip)&&(r=r.call(this,l)),clearTimeout(this._tooltipTimer),this._tooltipTimer=setTimeout((function(){if(!0!==n.prop("_mouse_tooltip")){if(n.prop("_mouse_tooltip",!0),-1!=["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(l.type)&&1==l.checked)return;n.w2tag(w2utils.lang(r),{position:a})}}),0),n.prop("_mouse_tooltip")&&1==s&&n.w2tag(w2utils.lang(r),{position:a}))},tooltipHide:function(t,i){var s;null!=this.tooltip&&(s=e(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(t)),this.get(t),clearTimeout(this._tooltipTimer),setTimeout((function(){!0===s.prop("_mouse_tooltip")&&(s.removeProp("_mouse_tooltip"),s.w2tag())}),1))},menuClick:function(t){if(t.item&&!t.item.disabled){var i=this.trigger({phase:"before",type:!0!==t.remove?"click":"remove",target:t.item.id+":"+t.subItem.id,item:t.item,subItem:t.subItem,originalEvent:t.originalEvent});if(!0===i.isCancelled)return;var s,n,l=t.subItem,a=this.get(t.item.id),r=a.items;if("function"==typeof r&&(r=a.items()),"menu-radio"==a.type&&(a.selected=l.id,Array.isArray(r)&&r.forEach((function(e){!0===e.checked&&delete e.checked,Array.isArray(e.items)&&e.items.forEach((function(e){!0===e.checked&&delete e.checked}))})),l.checked=!0),"menu-check"==a.type&&(e.isArray(a.selected)||(a.selected=[]),null==l.group?-1==(n=a.selected.indexOf(l.id))?(a.selected.push(l.id),l.checked=!0):(a.selected.splice(n,1),l.checked=!1):!1===l.group||(s=[],function e(t){t.forEach((function(t){var i;t.group!==l.group||-1!=(i=a.selected.indexOf(t.id))&&(t.id!=l.id&&s.push(t.id),a.selected.splice(i,1)),Array.isArray(t.items)&&e(t.items)}))}(r),-1==(n=a.selected.indexOf(l.id))&&(a.selected.push(l.id),l.checked=!0))),"string"==typeof l.route){var o=""!==l.route?String("/"+l.route).replace(/\/{2,}/g,"/"):"",d=w2utils.parseRoute(o);if(0<d.keys.length)for(var u=0;u<d.keys.length;u++)null!=this.routeData[d.keys[u].name]&&(o=o.replace(new RegExp(":"+d.keys[u].name,"g"),this.routeData[d.keys[u].name]));setTimeout((function(){window.location.hash=o}),1)}this.refresh(t.item.id),this.trigger(e.extend(i,{phase:"after"}))}},colorClick:function(t){if(t.item&&!t.item.disabled){var i=this.trigger({phase:"before",type:"click",target:t.item.id,item:t.item,color:t.color,final:t.final,originalEvent:t.originalEvent});if(!0===i.isCancelled)return;t.item.color=t.color,this.refresh(t.item.id),this.trigger(e.extend(i,{phase:"after"}))}}},e.extend(t.prototype,w2utils.event),w2obj.toolbar=t}(jQuery),function(e){function t(t){this.name=null,this.box=null,this.sidebar=null,this.parent=null,this.nodes=[],this.menu=[],this.routeData={},this.selected=null,this.img=null,this.icon=null,this.style="",this.topHTML="",this.bottomHTML="",this.flatButton=!1,this.keyboard=!0,this.flat=!1,this.hasFocus=!1,e.extend(!0,this,w2obj.sidebar,t)}
1e.fn.w2sidebar=function(i){if(e.isPlainObject(i)){if(!w2utils.checkName(i,"w2sidebar"))return;var s=i.nodes,n=new t(i);return e.extend(n,{handlers:[],nodes:[]}),null!=s&&n.add(n,s),n.sidebar=n,w2ui[n.name]=n,0!==e(this).length&&n.render(e(this)[0]),n}var l=w2ui[e(this).attr("name")];return l?0<arguments.length?(l[i]&&l[i].apply(l,Array.prototype.slice.call(arguments,1)),this):l:null},t.prototype={levelPadding:12,handle:{size:0,style:"",content:""},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:!1,plus:!1,onClick:null,onDblClick:null,onContextMenu:null,onExpand:null,onCollapse:null,parent:null,sidebar:null},add:function(e,t){return 1==arguments.length&&(t=arguments[0],e=this),"string"==typeof e&&(e=this.get(e)),this.insert(e,null,t)},insert:function(i,s,n){var l,a,r,o,d;if(2==arguments.length)if(n=arguments[1],null!=(s=arguments[0])){if(null==(a=this.get(s)))return e.isArray(n)||(n=[n]),null!=n[0].caption&&null==n[0].text&&(console.log("NOTICE: sidebar node.caption property is deprecated, please use node.text. Node -> ",n[0]),n[0].text=n[0].caption),l=n[0].text,console.log('ERROR: Cannot insert node "'+l+'" because cannot find node "'+s+'" to insert before.'),null;i=this.get(s).parent}else i=this;"string"==typeof i&&(i=this.get(i)),e.isArray(n)||(n=[n]);for(var u=0;u<n.length;u++)if(null!=typeof(o=n[u]).id)if(null==this.get(this,o.id)){if((r=e.extend({},t.prototype.node,o)).sidebar=this,r.parent=i,d=r.nodes||[],r.nodes=[],null==s)i.nodes.push(r);else{if(null==(a=this.get(i,s,!0)))return console.log('ERROR: Cannot insert node "'+o.text+'" because cannot find node "'+s+'" to insert before.'),null;i.nodes.splice(a,0,r)}0<d.length&&this.insert(r,null,d)}
1else console.log("ERROR: Cannot insert node with id="+o.id+" (text: "+o.text+") because another node with the same id already exists.");else null!=o.caption&&null==o.text&&(console.log("NOTICE: sidebar node.caption property is deprecated, please use node.text"),o.text=o.caption),l=o.text,console.log('ERROR: Cannot insert node "'+l+'" because it has no id.');return this.refresh(i.id),r},remove:function(){for(var e,t,i=0,s=0;s<arguments.length;s++)null!=(e=this.get(arguments[s]))&&(null!=this.selected&&this.selected===e.id&&(this.selected=null),null!=(t=this.get(e.parent,arguments[s],!0))&&(e.parent.nodes[t].selected&&e.sidebar.unselect(e.id),e.parent.nodes.splice(t,1),i++));return 0<i&&1==arguments.length?this.refresh(e.parent.id):this.refresh(),i},set:function(t,i,s){if(2==arguments.length&&(s=i,i=t,t=this),"string"==typeof t&&(t=this.get(t)),null==t.nodes)return null;for(var n=0;n<t.nodes.length;n++){if(t.nodes[n].id===i){var l,a=this.update(i,s);return 0!=Object.keys(a).length&&(l=s.nodes,e.extend(t.nodes[n],s,{nodes:[]}),null!=l&&this.add(t.nodes[n],l),this.refresh(i)),!0}if(this.set(t.nodes[n],i,s))return!0}return!1},get:function(e,t,i){if(0===arguments.length){for(var s=[],n=this.find({}),l=0;l<n.length;l++)null!=n[l].id&&s.push(n[l].id);return s}if((1==arguments.length||2==arguments.length&&!0===t)&&(i=t,t=e,e=this),"string"==typeof e&&(e=this.get(e)),null==e.nodes)return null;for(var a=0;a<e.nodes.length;a++){if(e.nodes[a].id==t)return!0===i?a:e.nodes[a];var r=this.get(e.nodes[a],t,i);if(r||0===r)return r}return null},find:function(e,t,i){if(1==arguments.length&&(t=e,e=this),i=i||[],"string"==typeof e&&(e=this.get(e)),null==e.nodes)return i;for(var s=0;s<e.nodes.length;s++){var n=!0;for(var l in t)e.nodes[s][l]!=t[l]&&(n=!1);n&&i.push(e.nodes[s]),0<e.nodes[s].nodes.length&&(i=this.find(e.nodes[s],t,i))}return i},hide:function(){for(var e=0,t=0;t<arguments.length;t++){var i=this.get(arguments[t]);null!=i&&!0!==i.hidden&&(i.hidden=!0,e++)}return 0<e&&(1==arguments.length?this.refresh(arguments[0]):this.refresh()),e},show:function(){for(var e=0,t=0;t<arguments.length;t++){var i=this.get(arguments[t]);null!=i&&!1!==i.hidden&&(i.hidden=!1,e++)}return 0<e&&(1==arguments.length?this.refresh(arguments[0]):this.refresh()),e},disable:function(){for(var e=0,t=0;t<arguments.length;t++){var i=this.get(arguments[t]);null!=i&&!0!==i.disabled&&(i.disabled=!0,i.selected&&this.unselect(i.id),e++)}return 0<e&&(1==arguments.length?this.refresh(arguments[0]):this.refresh()),e},enable:function(){for(var e=0,t=0;t<arguments.length;t++){var i=this.get(arguments[t]);null!=i&&!1!==i.disabled&&(i.disabled=!1,e++)}return 0<e&&(1==arguments.length?this.refresh(arguments[0]):this.refresh()),e},select:function(t){var i=this.get(t);if(!i)return!1;if(this.selected==t&&i.selected)return!1;this.unselect(this.selected);var s=e(this.box).find("#node_"+w2utils.escapeId(t));return s.addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected"),0<s.length&&this.scrollIntoView(t,!0),i.selected=!0,this.selected=t,!0},unselect:function(t){0===arguments.length&&(t=this.selected);var i=this.get(t);return!!i&&(i.selected=!1,e(this.box).find("#node_"+w2utils.escapeId(t)).removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected"),this.selected==t&&(this.selected=null),!0)},toggle:function(e){var t=this.get(e);return null!=t&&(t.plus?(this.set(e,{plus:!1}),this.expand(e),void this.refresh(e)):0!==t.nodes.length&&!!t.collapsible&&(this.get(e).expanded?this.collapse(e):this.expand(e)))},collapse:function(t){var i=this,s=this.get(t);if(null==s)return!1;var n=this.trigger({phase:"before",type:"collapse",target:t,object:s});return!0!==n.isCancelled?(e(this.box).find("#node_"+w2utils.escapeId(t)+"_sub").slideUp(200),e(this.box).find("#node_"+w2utils.escapeId(t)+" .w2ui-expanded").removeClass("w2ui-expanded").addClass("w2ui-collapsed"),s.expanded=!1,this.trigger(e.extend(n,{phase:"after"})),setTimeout((function(){i.refresh(t)}),200),!0):void 0},collapseAll:function(e){if(null==e&&(e=this),"string"==typeof e&&(e=this.get(e)),null==e.nodes)return!1;for(var t=0;t<e.nodes.length;
1t++)!0===e.nodes[t].expanded&&(e.nodes[t].expanded=!1),e.nodes[t].nodes&&0<e.nodes[t].nodes.length&&this.collapseAll(e.nodes[t]);return this.refresh(e.id),!0},expand:function(t){var i=this,s=this.get(t),n=this.trigger({phase:"before",type:"expand",target:t,object:s});if(!0!==n.isCancelled)return e(this.box).find("#node_"+w2utils.escapeId(t)+"_sub").slideDown(200),e(this.box).find("#node_"+w2utils.escapeId(t)+" .w2ui-collapsed").removeClass("w2ui-collapsed").addClass("w2ui-expanded"),s.expanded=!0,this.trigger(e.extend(n,{phase:"after"})),setTimeout((function(){i.refresh(t)}),200),!0},expandAll:function(e){if(null==e&&(e=this),"string"==typeof e&&(e=this.get(e)),null==e.nodes)return!1;for(var t=0;t<e.nodes.length;t++)!1===e.nodes[t].expanded&&(e.nodes[t].expanded=!0),e.nodes[t].nodes&&0<e.nodes[t].nodes.length&&this.expandAll(e.nodes[t]);this.refresh(e.id)},expandParents:function(e){var t=this.get(e);return null!=t&&(t.parent&&(t.parent.expanded||(t.parent.expanded=!0,this.refresh(t.parent.id)),this.expandParents(t.parent.id)),!0)},click:function(t,i){var s,n,l=this,a=this.get(t);null!=a&&(a.disabled||a.group||(e(l.box).find(".w2ui-node.w2ui-selected").each((function(t,i){var s=e(i).attr("id").replace("node_",""),n=l.get(s);null!=n&&(n.selected=!1),e(i).removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected")})),s=e(l.box).find("#node_"+w2utils.escapeId(t)),n=e(l.box).find("#node_"+w2utils.escapeId(l.selected)),s.addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected"),setTimeout((function(){var r=l.trigger({phase:"before",type:"click",target:t,originalEvent:i,node:a,object:a});if(!0===r.isCancelled)return s.removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected"),void n.addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected");if(null!=n&&(n.selected=!1),l.get(t).selected=!0,l.selected=t,"string"==typeof a.route){var o=""!==a.route?String("/"+a.route).replace(/\/{2,}/g,"/"):"",d=w2utils.parseRoute(o);if(0<d.keys.length)for(var u=0;u<d.keys.length;u++)null!=l.routeData[d.keys[u].name]&&(o=o.replace(new RegExp(":"+d.keys[u].name,"g"),l.routeData[d.keys[u].name]));setTimeout((function(){window.location.hash=o}),1)}l.trigger(e.extend(r,{phase:"after"}))}),1)))},focus:function(t){var i=this,s=this.trigger({phase:"before",type:"focus",target:this.name,originalEvent:t});if(!0===s.isCancelled)return!1;this.hasFocus=!0,e(this.box).find(".w2ui-sidebar-body").addClass("w2ui-focus"),setTimeout((function(){var t=e(i.box).find("#sidebar_"+i.name+"_focus");t.is(":focus")||t.focus()}),10),this.trigger(e.extend(s,{phase:"after"}))},blur:function(t){var i=this.trigger({phase:"before",type:"blur",target:this.name,originalEvent:t});if(!0===i.isCancelled)return!1;this.hasFocus=!1,e(this.box).find(".w2ui-sidebar-body").removeClass("w2ui-focus"),this.trigger(e.extend(i,{phase:"after"}))},keydown:function(t){var i,s=this,n=s.get(s.selected);function l(e,t){null==e||e.hidden||e.disabled||e.group||(s.click(e.id,t),setTimeout((function(){s.scrollIntoView()}),50))}function a(e,t){for(e=t(e);null!=e&&(e.hidden||e.disabled)&&!e.group;)e=t(e);return e}!0===s.keyboard&&(n=n||s.nodes[0],!0!==(i=s.trigger({phase:"before",type:"keydown",target:s.name,originalEvent:t})).isCancelled&&(13!=t.keyCode&&32!=t.keyCode||0<n.nodes.length&&s.toggle(s.selected),37==t.keyCode&&(0<n.nodes.length&&n.expanded?s.collapse(s.selected):(l(n.parent),n.parent.group||s.collapse(n.parent.id))),39==t.keyCode&&(0<n.nodes.length||n.plus)&&!n.expanded&&s.expand(s.selected),38==t.keyCode&&(null==s.get(s.selected)?l(this.nodes[0]||null):l(a(n,(function e(t){if(null==t)return null;var i=t.parent,n=s.get(t.id,!0),l=0<n?function t(i){if(i.expanded&&0<i.nodes.length){var s=i.nodes[i.nodes.length-1];return(s.hidden||s.disabled||s.group?e:t)(s)}return i}(i.nodes[n-1]):i;return null!=l&&(l.hidden||l.disabled||l.group)&&(l=e(l)),l})))),40==t.keyCode&&(null==s.get(s.selected)?l(this.nodes[0]||null):l(a(n,(function e(t,i){if(null==t)return null;var n,l=t.parent,a=s.get(t.id,!0),r=null;return null!=(r=t.expanded&&0<t.nodes.length&&!0!==i?(n=t.nodes[0]).hidden||n.disabled||n.group?e(n):n:l&&a+1<l.nodes.length?l.nodes[a+1]:e(l,!0))&&(r.hidden||r.disabled||r.group)&&(r=e(r)),r})))),-1!=e.inArray(t.keyCode,[13,32,37,38,39,40])&&(t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()),s.trigger(e.extend(i,{phase:"after"}))))},scrollIntoView:function(t,i){var s,n,l;null==t&&(t=this.selected),null!=this.get(t)&&(s=e(this.box).find(".w2ui-sidebar-body"),((l=(n=e(this.box).find("#no
1de_"+w2utils.escapeId(t))).offset().top-s.offset().top)+n.height()>s.height()||l<=0)&&s.animate({scrollTop:s.scrollTop()+l-s.height()/2+n.height()},i?0:250,"linear"))},dblClick:function(t,i){var s=this.get(t),n=this.trigger({phase:"before",type:"dblClick",target:t,originalEvent:i,object:s});!0!==n.isCancelled&&(this.toggle(t),this.trigger(e.extend(n,{phase:"after"})))},contextMenu:function(t,i){var s=this,n=s.get(t);t!=s.selected&&s.click(t);var l=s.trigger({phase:"before",type:"contextMenu",target:t,originalEvent:i,object:n,allowOnDisabled:!1});!0!==l.isCancelled&&(n.disabled&&!l.allowOnDisabled||(0<s.menu.length&&e(s.box).find("#node_"+w2utils.escapeId(t)).w2menu({items:s.menu,contextMenu:!0,originalEvent:i,onSelect:function(e){s.menuClick(t,parseInt(e.index),e.originalEvent)}}),i.preventDefault&&i.preventDefault(),s.trigger(e.extend(l,{phase:"after"}))))},menuClick:function(t,i,s){var n=this.trigger({phase:"before",type:"menuClick",target:t,originalEvent:s,menuIndex:i,menuItem:this.menu[i]});!0!==n.isCancelled&&this.trigger(e.extend(n,{phase:"after"}))},goFlat:function(){var t=this.trigger({phase:"before",type:"flat",goFlat:!this.flat});!0!==t.isCancelled&&(this.flat=!this.flat,this.refresh(),this.trigger(e.extend(t,{phase:"after"})))},render:function(t){var i=(new Date).getTime(),s=this,n=this.trigger({phase:"before",type:"render",target:this.name,box:t});if(!0!==n.isCancelled&&(null!=t&&(0<e(this.box).find("> div > div.w2ui-sidebar-body").length&&e(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-sidebar").html(""),this.box=t),this.box)){e(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-sidebar").html('<div><input id="sidebar_'+this.name+'_focus" style="position: absolute; top: 0; right: 0; width: 1px; z-index: -1; opacity: 0" '+(w2utils.isIOS?"readonly":"")+'/><div class="w2ui-sidebar-top"></div><div class="w2ui-sidebar-body"></div><div class="w2ui-sidebar-bottom"></div></div>'),e(this.box).find("> div").css({width:e(this.box).width()+"px",height:e(this.box).height()+"px"}),0<e(this.box).length&&(e(this.box)[0].style.cssText+=this.style);var l,a="";return 1==this.flatButton&&(a='<div class="w2ui-flat-'+(this.flat?"right":"left")+'" onclick="w2ui[\''+this.name+"'].goFlat()\"></div>"),""===this.topHTML&&""===a||(e(this.box).find(".w2ui-sidebar-top").html(this.topHTML+a),e(this.box).find(".w2ui-sidebar-body").css("top",e(this.box).find(".w2ui-sidebar-top").height()+"px")),""!==this.bottomHTML&&(e(this.box).find(".w2ui-sidebar-bottom").html(this.bottomHTML),e(this.box).find(".w2ui-sidebar-body").css("bottom",e(this.box).find(".w2ui-sidebar-bottom").height()+"px")),e(this.box).find("#sidebar_"+this.name+"_focus").on("focus",(function(e){clearTimeout(l),s.hasFocus||s.focus(e)})).on("blur",(function(e){l=setTimeout((function(){s.hasFocus&&s.blur(e)}),100)})).on("keydown",(function(e){9!=e.keyCode&&w2ui[s.name].keydown.call(w2ui[s.name],e)})),e(this.box).off("mousedown").on("mousedown",(function(t){setTimeout((function(){var i,n;-1==["INPUT","TEXTAREA","SELECT"].indexOf(t.target.tagName.toUpperCase())&&((i=e(s.box).find("#sidebar_"+s.name+"_focus")).is(":focus")||(e(t.target).hasClass("w2ui-node")&&(n=e(t.target).position().top+e(s.box).find(".w2ui-sidebar-top").height()+t.offsetY,i.css({top:n+"px",left:"0px"})),i.focus()))}),1)})),this.trigger(e.extend(n,{phase:"after"})),this.refresh(),(new Date).getTime()-i}},update:function(t,i){var s,n,l,a,r=this.get(t);return r&&(n=e(this.box).find("#node_"+r.id),r.group?(i.text&&(r.text=i.text,n.find(".w2ui-group-text").replaceWith("function"==typeof r.text?r.text.call(this,r):'<span class="w2ui-group-text">'+r.text+"</span>"),delete i.text),i.class&&(r.class=i.class,s=n.data("level"),n[0].className="w2ui-node-group w2ui-level-"+s+(r.class?" "+r.class:""),delete i.class),i.style&&(r.style=i.style,n.next()[0].style=r.style+";"+(!r.hidden&&r.expanded?"":"display: none;"),delete i.style)):(!i.icon||0<(l=n.find(".w2ui-node-image > span")).length&&(r.icon=i.icon,l[0].className="function"==typeof r.icon?r.icon.call(this,r):r.icon,delete i.icon),i.count&&(r.count=i.count,n.find(".w2ui-node-count").html(r.count),0<n.find(".w2ui-node-count").length&&delete i.count),i.class&&0<n.length&&(r.class=i.class,s=n.data("level"),n[0].className="w2ui-node w2ui-level-"+s+(r.selected?" w2ui-selected":"")+(r.disabled?" w2ui-disabled":"")+(r.class?" "+r.class:""),delete i.class),i.text&&(r.text=i.text,n.find(".w2ui-node-text").html("function"==typeof r.text?r.text.call(this,r):r.text),delete i.text),i.style&&0<n.length&&(a=n.find(".w2ui-node-text"),r.style=i.style,a[0].style=r.style,delete i.style))),i},refresh:function(t){var i=(new Date).getTime(),s=this.trigger({phase:"before",type:"refresh",target:null!=t?t:this.name,fullRefresh:null==t});if(!0!==s.isCancelled){var n="";1==this.flatButton&&(n='<div class="w2ui-flat-'+(this.flat?"right":"left")+'" onclick="w2ui[\''+this.name+"'].goFlat(
1)\"></div>"),""===this.topHTML&&""===n||(e(this.box).find(".w2ui-sidebar-top").html(this.topHTML+n),e(this.box).find(".w2ui-sidebar-body").css("top",e(this.box).find(".w2ui-sidebar-top").height()+"px")),""!==this.bottomHTML&&(e(this.box).find(".w2ui-sidebar-bottom").html(this.bottomHTML),e(this.box).find(".w2ui-sidebar-body").css("bottom",e(this.box).find(".w2ui-sidebar-bottom").height()+"px")),e(this.box).find("> div").removeClass("w2ui-sidebar-flat").addClass(this.flat?"w2ui-sidebar-flat":"").css({width:e(this.box).width()+"px",height:e(this.box).height()+"px"}),0<this.nodes.length&&null==this.nodes[0].parent&&(o=this.nodes,this.nodes=[],this.add(this,o));var l,a,r,o,d,u=this;if(null==t)l=this,r=".w2ui-sidebar-body";else{if(null==(l=this.get(t)))return;r="#node_"+w2utils.escapeId(l.id)+"_sub"}l!==this&&(o="#node_"+w2utils.escapeId(l.id),d=f(l),e(this.box).find(o).before('<div id="sidebar_'+this.name+'_tmp"></div>'),e(this.box).find(o).remove(),e(this.box).find(r).remove(),e("#sidebar_"+this.name+"_tmp").before(d),e("#sidebar_"+this.name+"_tmp").remove());var c={top:e(this.box).find(r).scrollTop(),left:e(this.box).find(r).scrollLeft()};e(this.box).find(r).html("");for(var h=0;h<l.nodes.length;h++)if(d=f(a=l.nodes[h]),e(this.box).find(r).append(d),0!==a.nodes.length)this.refresh(a.id);else{var p=this.trigger({phase:"before",type:"refresh",target:a.id});if(!0===p.isCancelled)return;this.trigger(e.extend(p,{phase:"after"}))}return e(this.box).find(r).scrollLeft(c.left).scrollTop(c.top),this.trigger(e.extend(s,{phase:"after"})),(new Date).getTime()-i}function f(e){var t="",i=e.img,s=e.icon;null==s&&null==i&&(null==s&&(s=u.icon),null==i&&(i=u.img));for(var n,l,a,r=e.parent,o=0;r&&null!=r.parent;)r=r.parent,o++;return null!=e.caption&&null==e.text&&(e.text=e.caption),null!=e.caption&&(console.log("NOTICE: sidebar node.caption property is deprecated, please use node.text. Node -> ",e),e.text=e.caption),Array.isArray(e.nodes)&&0<e.nodes.length&&(e.collapsible=!0),e.group?(t='<div class="w2ui-node-group w2ui-level-'+o+(e.class?" "+e.class:"")+'" id="node_'+e.id+'" data-level="'+o+'" style="'+(e.hidden?"display: none":"")+'" onclick="w2ui[\''+u.name+"'].toggle('"+e.id+"')\" oncontextmenu=\"w2ui['"+u.name+"'].contextMenu('"+e.id+"', event);\" onmouseout=\"jQuery(this).find('span:nth-child(1)').css('color', 'transparent')\" onmouseover=\"jQuery(this).find('span:nth-child(1)').css('color', 'inherit')\">"+(e.groupShowHide&&e.collapsible?"<span>"+(!e.hidden&&e.expanded?w2utils.lang("Hide"):w2utils.lang("Show"))+"</span>":"<span></span>")+("function"==typeof e.text?e.text.call(u,e):'<span class="w2ui-group-text">'+e.text+"</span>")+'</div><div class="w2ui-node-sub" id="node_'+e.id+'_sub" style="'+e.style+";"+(!e.hidden&&e.expanded?"":"display: none;")+'"></div>',u.flat&&(t='<div class="w2ui-node-group" id="node_'+e.id+'"><span> </span></div><div id="node_'+e.id+'_sub" style="'+e.style+";"+(!e.hidden&&e.expanded?"":"display: none;")+'"></div>')):(e.selected&&!e.disabled&&(u.selected=e.id),r="",i&&(r='<div class="w2ui-node-image w2ui-icon '+i+(e.selected&&!e.disabled?" w2ui-icon-selected":"")+'"></div>'),s&&(r='<div class="w2ui-node-image"><span class="'+("function"==typeof s?s.call(u,e):s)+'"></span></div>'),n=e.text,l="",a=null!=e.count?'<div class="w2ui-node-count">'+e.count+"</div>":"",!0===e.collapsible&&(l='<div class="w2ui-'+(e.expanded?"expanded":"collapsed")+'"><span></span></div>'),"function"==typeof e.text&&(n=e.text.call(u,e)),t='<div class="w2ui-node w2ui-level-'+o+(e.selected?" w2ui-selected":"")+(e.disabled?" w2ui-disabled":"")+(e.class?" "+e.class:"")+'" id="node_'+e.id+'" data-level="'+o+'" style="position: relative; '+(e.hidden?"display: none;":"")+'" ondblclick="w2ui[\''+u.name+"'].dblClick('"+e.id+"', event);\" oncontextmenu=\"w2ui['"+u.name+"'].contextMenu('"+e.id+"', event);\" onClick=\"w2ui['"+u.name+"'].click('"+e.id+"', event); \">"+(u.handle.content?'<div class="w2ui-node-handle" style="width: '+u.handle.size+"px; "+u.handle.style+'">'+u.handle.content+"</div>":"")+' <div class="w2ui-node-data" style="margin-left:'+(o*u.levelPadding+u.handle.size)+'px">'+l+r+a+'<div class="w2ui-node-text w2ui-node-caption" style="'+(e.style||"")+'">'+n+'</div> </div></div><div class="w2ui-node-sub" id="node_'+e.id+'_sub" style="'+e.style+";"+(!e.hidden&&e.expanded?"":"display: none;")+'"></div>',u.flat&&(t='<div class="w2ui-node w2ui-level-'+o+" "+(e.selected?"w2ui-selected":"")+" "+(e.disabled?"w2ui-disabled":"")+(e.class?" "+e.class:"")+'" id="node_'+e.id+'" style="'+(e.hidden?"display: none;":"")+"\" onmouseover=\"jQuery(this).find('.w2ui-node-data').w2tag(w2utils.base64decode('"+w2utils.base64encode(n+(e.count||0===e.count?' - <span class="w2ui-node-count">'+e.count+"</span>":""))+"'), { id: '"+e.id+"', left: -5 })\" onmouseout=\"jQuery(this).find('.w2ui-node-data').w2tag(null, { id: '"+e.id+"' })\" ondblclick=\"w2ui['"+u.name+"'].dblClick('"+e.id+"', event);\" oncontextmenu=\"w2ui['"+u.name+"'].contextMenu('"+e.id+"', event);\" onClick=\"w2ui['"+u.name+"'].click('"+e.id+'\', event); "><div class="w2ui-node-data w2ui-node-flat">'+r+'</div></div><div class="w2ui-node-sub" id="node_'+e.id+'_sub" style="'+e.style+";"+(!e.hidden&&e.expanded?"":"display: none;")+'"></div>')),t}},resize:function(){var t=(new Date).getTime(),i=this.trigger({phase:"before",type:"resize",target:this.name});if(!0!==i.isCancelled)return e(this.box).css("overflow","hidden"),e(this.box).find("> div").css({width:e(this.box).width()+"px",height:e(this.box).height()+"px"}),this.trigger(e.extend(i,{phase:"after"})),(new Date).getTime()-t},destroy:function(){var t=this.trigger({phase:"before",type:"destroy",target:this.name});!0!==t.isCancelled&&(0<e(this.box).find("> div > div.w2ui-sidebar-body").length&&e(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-sidebar").html(""),delete w2ui[this.name],this.trigger(e.extend(t,{phase:"after"})))},lock:function(e,t){var i=Array.prototype.slice.call(arguments,0);i.unshift(this.box),w2utils.lock.apply(window,i)},unlock:function(e){w2utils.unlock(this.box,e)}},e.extend(t.prototype,w2utils.event),w2obj.sidebar=t}(jQuery),function(e){function t(t){this.el=null,this.helpers={},this.type=t.type||"text",this.options=e.extend(!0,{},t),this.onSearch=t.onSearch||null,this.onRequest=t.onRequest||null,this.onLoad=t.onLoad||null,this.onError=t.onError||null,this.onClick=t.onClick||null,this.onAdd=t.onAdd||null,this.onNew=t.onNew||null,this.onRemove=t.onRemove||null,this.onMouseOver=t.onMouseOver||null,this.onMouseOut=t.onMouseOut||null,this.onIconClick=t.onIconClick||null,this.onScroll=t.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,e.extend(!0,this,w2obj.field)}e.fn.w2field=function(i,s){if(0!==this.length)return 0===arguments.length?e(this).data("w2field"):("string"==typeof i&&"object"==typeof s&&(i=e.extend(!0,{},s,{type:i})),"string"==typeof i&&null==s&&(i={type:i}),i&&(i.type=String(i.type).toLowerCase()),this.each((function(s,n){var l=e(n).data("w2field");return null==l?(l=new t(i),e.extend(l,{handlers:[]}
1),n&&(l.el=e(n)[0]),l.init(),e(n).data("w2field",l),l):(l.clear(),"clear"!==i.type?(l=new t(i),e.extend(l,{handlers:[]}),n&&(l.el=e(n)[0]),l.init(),e(n).data("w2field",l),l):void 0)})));var n=t.prototype;return n[i]?n[i].apply(n,Array.prototype.slice.call(arguments,1)):void 0},t.prototype={custom:{},addType:function(e,t){return e=String(e).toLowerCase(),this.custom[e]=t,!0},removeType:function(e){return e=String(e).toLowerCase(),!!this.custom[e]&&(delete this.custom[e],!0)},init:function(){var t,i=this,s=this.options;if("function"!=typeof this.custom[this.type])if(-1!=["INPUT","TEXTAREA"].indexOf(this.el.tagName.toUpperCase())){switch(this.type){case"text":case"int":case"float":case"money":case"currency":case"percent":case"alphanumeric":case"bin":case"hex":t={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=e.extend(!0,{},t,s),(s=this.options).numberRE=new RegExp("["+s.groupSymbol+"]","g"),s.moneyRE=new RegExp("["+s.currencyPrefix+s.currencySuffix+s.groupSymbol+"]","g"),s.percentRE=new RegExp("["+s.groupSymbol+"%]","g"),-1!==["text","alphanumeric","hex","bin"].indexOf(this.type)&&(s.arrows=!1,s.keyboard=!1),this.addPrefix(),this.addSuffix();break;case"color":t={prefix:"",suffix:'<div style="width: '+(parseInt(e(this.el).css("font-size"))||12)+'px"> </div>',arrows:!1,keyboard:!1,advanced:null,transparent:!0},this.options=e.extend(!0,{},t,s),s=this.options,this.addPrefix(),this.addSuffix(),""!==e(this.el).val()&&setTimeout((function(){i.change()}),1);break;case"date":t={format:w2utils.settings.dateFormat,keyboard:!0,silent:!0,start:"",end:"",blocked:{},colored:{},blockWeekDays:null},this.options=e.extend(!0,{},t,s),s=this.options,null==e(this.el).attr("placeholder")&&e(this.el).attr("placeholder",s.format);break;case"time":t={format:w2utils.settings.timeFormat,keyboard:!0,silent:!0,start:"",end:"",noMinutes:!1},this.options=e.extend(!0,{},t,s),s=this.options,null==e(this.el).attr("placeholder")&&e(this.el).attr("placeholder",s.format);break;case"datetime":t={format:w2utils.settings.dateFormat+" | "+w2utils.settings.timeFormat,keyboard:!0,silent:!0,start:"",end:"",blocked:[],colored:{},placeholder:null,btn_now:!0,noMinutes:!1},this.options=e.extend(!0,{},t,s),s=this.options,null==e(this.el).attr("placeholder")&&e(this.el).attr("placeholder",s.placeholder||s.format);break;case"list":case"combo":if(t={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:"",align:"both",altRows:!0,onSearch:null,onRequest:null,onLoad:null,onError:null,onIconClick:null,renderDrop:null,compare:null,filter:!0,prefix:"",suffix:"",openOnFocus:!1,markSearch:!1},"function"==typeof s.items&&(s._items_fun=s.items),s.items=w2obj.field.prototype.normMenu.call(this,s.items),"list"===this.type){if(t.openOnFocus=!0,e(this.el).addClass("w2ui-select"),!e.isPlainObject(s.selected)&&Array.isArray(s.items))for(var n=0;n<s.items.length;n++){var l=s.items[n];if(l&&l.id===s.selected){s.selected=e.extend(!0,{},l);break}}this.watchSize()}s=e.extend({},t,s),this.options=s,e.isPlainObject(s.selected)||(s.selected={}),e(this.el).data("selected",s.selected),s.url&&(s.items=[],this.request(0)),"list"===this.type&&this.addFocus(),this.addPrefix(),this.addSuffix(),setTimeout((function(){i.refresh()}),10),e(this.el).attr("autocapitalize","off").attr("autocomplete","off").attr("autocorrect","off").attr("spellcheck","false"),null!=s.selected.text&&e(this.el).val(s.selected.text);break;case"enum":t={items:[],selected:[],max:0,url:null,recId:null,recText:null,interval:350,method:null,postData:{},minLength:1,cacheMax:250,maxWidth:250,maxHeight:350,maxDropHeight:350,maxDropWidth:null,match:"contains",silent:!0,align:"both",altRows:!0,openOnFocus:!1,markSearch:!0,renderDrop:null,renderItem:null,compare:null,filter:!0,style:"",onSearch:null,onRequest:null,onLoad:null,onError:null,onClick:null,onAdd:null,onNew:null,onRemove:null,onMouseOver:null,onMouseOut:null,onScroll:null},"function"==typeof(s=e.extend({},t,s,{suffix:""})).items&&(s._items_fun=s.items),s.items=w2obj.field.prototype.normMenu.call(this,s.items),s.selected=w2obj.field.prototype.normMenu.call(this,s.selected),this.options=s,e.isArray(s.selected)||(s.selected=[]),e(this.el).data("selected",s.selected),s.url&&(s.items=[],this.request(0)),this.addSuffix(),this.addMulti(),this.watchSize();break;case"file":t={selected:[],max:0,maxSize:0,maxFileSize:0,maxWidth:250,maxHeight:350,maxDropHeight:350,maxDropWidth:null,readContent:!0,silent:!0,align:"both",altRows:!0,renderItem:null,style:"",onClick:null,onAdd:null,onRemove:null,onMouseOver:null,onMouseOut:null},s=e.extend({},t,s),this.options=s,e.isArray(s.selected)||(s.selected=[]),e(this.el).data("selected",s.selected),null==e(this.el).attr("placeholder")&&e(this.el).attr("placeholder",w2utils.lang("Attach files by dragging and dropping or Click to Select")),this.addMulti(),this.watchSize()}this.tmp={onChange:function(e){i.change.call(i,e)},onClick:function(e){i.click.call(i,e)},onFocus:function(e){i.focus.call(i,e)},onBlur:function(e){i.blur.call(i,e)},onKeydown:function(e){i.keyDown.call(i,e)},onKeyup:function(e){i.keyUp.call(i,e)},onKeypress:function(e){i.keyPress.call(i,e)}},e(this.el).addClass("w2field w2ui-input").data("w2field",this).on("change.w2field",this.tmp.onChange).on("click.w2field",this.tmp.onClick).on("focus.w2field",this.tmp.onFocus).on("blur.w2field",this.tmp.onBlur).on("keydown.w2field",this.tmp.onKeydown).on("keyup.w2field",this.tmp.onKeyup).on("keypress.w2field",this.tmp.onKeypress).css(w2utils.cssPrefix("box-sizing","border-box")),this.change(e.Event("change"))}else console.log("ERROR: w2field could only be applied to INPUT or TEXTAREA.",this.el);else this.custom[this.type].call(this,s)},watchSize:function(){var t=this,i=e(t.el).data("tmp")||{};i.sizeTimer=setInterval((function(){0<e(t.el).parents("body").length?t.resize():clearInterval(i.sizeTimer)}),200),e(t.el).data("tmp",i)},get:function(){return-1!==["list","enum","file"].indexOf(this.type)?e(this.el).data("selected"):e(this.el).val()},set:function(t,i){var s;-1!==["list","enum","file"].indexOf(this.type)?("list"!==this.type&&i?(null==e(this.el).data("selected")&&e(this.el).data("selected",[]),e(this.el).data("selected").push(t),e(this.el).trigger("input").change()):(s="enum"===this.type?[t]:t,e(this.el).data("selected",s).trigger("input").change()),this.refresh()):e(this.el).val(t)},setIndex:function(t,i){if(-1!==["list","enum"].indexOf(this.type)){var s,n=this.options.items;if(n&&n[t])return"list"!==this.type&&i?(null==e(this.el).data("selected")&&e(this.el).data("selected",[]),e(this.el).data("selected").push(n[t]),e(this.el).trigger("input").change()):(s="enum"===this.type?[n[t]]:n[t],e(this.el).data("selected",s).trigger("input").change()),this.refresh(),!0}return!1},clear:function(){var t=this.options;-1!==["money","currency"].indexOf(this.type)&&e(this.el).val(e(this.el).val().replace(t.moneyRE,"")),"percent"===this.type&&e(this.el).val(e(this.el).val().replace(/%/g,"")),"list"===this.type&&e(this.el).removeClass("w2ui-select"),this.type="clear";var i=e(this.el).data("tmp");if(this.tmp){for(var s in null!=i&&(e(this.el).height("auto"),i&&i["old-padding-left"]&&e(this.el).css("padding-left",i["old-padding-left"]),i&&i["old-padding-right"]&&e(this.el).css("padding-right",i["old-padding-right"]),i&&i["old-background-color"]&&e(this.el).css("background-color",i["old-background-color"]),i&&i["old-border-color"]&&e(this.el).css("border-color",i["old-border-color"]),clearInterval(i.sizeTimer)),e(this.el).val(this.clean(e(this.el).val())).removeClass("w2field").removeData().off(".w2field"),this.helpers)e(this.helpers[s]).remove();this.helpers={}}},refresh:function(){var t=this,i=this.options,s=e(this.el).data("selected"),n=(new Date).getTime();if(-1!==["list"].indexOf(this.type)&&(e(t.el).parent().css("white-space","nowrap"),t.helpers.prefix&&t.helpers.prefix.hide(),setTimeout((function(){var n;t.helpers.focus&&(!e.isEmptyObject(s)&&i.icon?i.prefix='<span class="w2ui-icon '+i.icon+'"style="cursor: pointer; font-size: 14px; display: inline-block;
1 margin-top: -1px; color: #7F98AD;'+i.iconStyle+'"></span>':i.prefix="",t.addPrefix(),n=t.helpers.focus.find("input"),""===e(n).val()?(e(n).css("text-indent","-9999em").prev().css("opacity",0),e(t.el).val(s&&null!=s.text?w2utils.lang(s.text):"")):(e(n).css("text-indent",0).prev().css("opacity",1),e(t.el).val(""),setTimeout((function(){t.helpers.prefix&&t.helpers.prefix.hide();var s="position: absolute; opacity: 0; margin: 4px 0px 0px 2px; background-position: left !important;";i.icon?(e(n).css("margin-left","17px"),e(t.helpers.focus).find(".icon-search").attr("style",s+"width: 11px !important; opacity: 1; display: block")):(e(n).css("margin-left","0px"),e(t.helpers.focus).find(".icon-search").attr("style",s+"width: 0px !important; opacity: 0; display: none"))}),1)),e(t.el).prop("readonly")||e(t.el).prop("disabled")?setTimeout((function(){e(t.helpers.prefix).css("opacity","0.6"),e(t.helpers.suffix).css("opacity","0.6")}),1):setTimeout((function(){e(t.helpers.prefix).css("opacity","1"),e(t.helpers.suffix).css("opacity","1")}),1))}),1)),-1!==["enum","file"].indexOf(this.type)){var l="";if(s)for(var a=0;a<s.length;a++){var r=s[a],o="function"==typeof i.renderItem?i.renderItem(r,a,'<div class="w2ui-list-remove" title="'+w2utils.lang("Remove")+'" index="'+a+'">  </div>'):'<div class="w2ui-list-remove" title="'+w2utils.lang("Remove")+'" index="'+a+'">  </div>'+("enum"===t.type?r.text:r.name+'<span class="file-size"> - '+w2utils.formatSize(r.size)+"</span>");l+='<li index="'+a+'" style="max-width: '+parseInt(i.maxWidth)+"px; "+(r.style?r.style:"")+'">'+o+"</li>"}var d,u=t.helpers.multi,c=u.find("ul");u.attr("style",u.attr("style")+";"+i.style),e(t.el).css("z-index","-1"),e(t.el).prop("readonly")||e(t.el).prop("disabled")?setTimeout((function(){u[0].scrollTop=0,u.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(){u.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),u.find(".w2ui-enum-placeholder").remove(),c.find("li").not("li.nomouse").remove(),""!==l?c.prepend(l):null!=e(t.el).attr("placeholder")&&""===u.find("input").val()&&(d="padding-top: "+e(this.el).css("padding-top")+";padding-left: "+e(this.el).css("padding-left")+"; box-sizing: "+e(this.el).css("box-sizing")+"; line-height: "+e(this.el).css("line-height")+"; font-size: "+e(this.el).css("font-size")+"; font-family: "+e(this.el).css("font-family")+"; ",u.prepend('<div class="w2ui-enum-placeholder" style="'+d+'">'+e(t.el).attr("placeholder")+"</div>")),u.off("scroll.w2field").on("scroll.w2field",(function(i){var s=t.trigger({phase:"before",type:"scroll",target:t.el,originalEvent:i});!0!==s.isCancelled&&t.trigger(e.extend(s,{phase:"after"}))})).find("li").data("mouse","out").on("click",(function(i){var n,l,a,r,o="LI"===i.target.tagName.toUpperCase()?i.target:e(i.target).parents("LI"),d=s[e(o).attr("index")];if(!e(o).hasClass("nomouse"))if(i.stopPropagation(),e(i.target).hasClass("w2ui-list-remove")){if(e(t.el).prop("readonly")||e(t.el).prop("disabled"))return;if(!0===(n=t.trigger({phase:"before",type:"remove",target:t.el,originalEvent:i.originalEvent,item:d})).isCancelled)return;e().w2overlay(),s.splice(e(i.target).attr("index"),1),e(t.el).trigger("input").trigger("change"),e(i.target).parent().fadeOut("fast"),setTimeout((function(){t.refresh(),t.trigger(e.extend(n,{phase:"after"}))}),300)}else{if(!0===(n=t.trigger({phase:"before",type:"click",target:t.el,originalEvent:i.originalEvent,item:d})).isCancelled)return;"file"===t.type&&(l="",/image/i.test(d.type)&&(l='<div style="padding: 3px;"> <img src="'+(d.content?"data:"+d.type+";base64,"+d.content:"")+'" style="max-width: 300px;" onload="var w = jQuery(this).width(); var h = jQuery(this).height(); if (w < 300 & h < 300) return; if (w >= h && w > 300) jQuery(this).width(300); if (w < h && h > 300) jQuery(this).height(300);" onerror="this.style.display = \'none\'" ></div>'),r='style="padding: 3px"',l+='<div style="padding: 8px;"> <table cellpadding="2"><tbody> <tr><td '+(a='style="padding: 3px; text-align: right; color: #777;"')+">"+w2utils.lang("Name")+":</td><td "+r+">"+d.name+"</td></tr> <tr><td "+a+">"+w2utils.lang("Size")+":</td><td "+r+">"+w2utils.formatSize(d.size)+"</td></tr> <tr><td "+a+">"+w2utils.lang("Type")+":</td><td "+r+'>
1 <span style="width: 200px; display: block-inline; overflow: hidden; text-overflow: ellipsis; white-space: nowrap="nowrap";">'+d.type+"</span> </td></tr> <tr><td "+a+">"+w2utils.lang("Modified")+":</td><td "+r+">"+w2utils.date(d.modified)+"</td></tr> </tbody></table></div>",e("#w2ui-overlay").remove(),e(o).w2overlay(l)),t.trigger(e.extend(n,{phase:"after"}))}})).on("mouseover",(function(i){var n="LI"===i.target.tagName.toUpperCase()?i.target:e(i.target).parents("LI");if(!e(n).hasClass("nomouse")){if("out"===e(n).data("mouse")){var l=s[e(i.target).attr("index")],a=t.trigger({phase:"before",type:"mouseOver",target:t.el,originalEvent:i.originalEvent,item:l});if(!0===a.isCancelled)return;t.trigger(e.extend(a,{phase:"after"}))}e(n).data("mouse","over")}})).on("mouseout",(function(i){var n="LI"===i.target.tagName.toUpperCase()?i.target:e(i.target).parents("LI");e(n).hasClass("nomouse")||(e(n).data("mouse","leaving"),setTimeout((function(){if("leaving"===e(n).data("mouse")){e(n).data("mouse","out");var l=s[e(i.target).attr("index")],a=t.trigger({phase:"before",type:"mouseOut",target:t.el,originalEvent:i.originalEvent,item:l});if(!0===a.isCancelled)return;t.trigger(e.extend(a,{phase:"after"}))}}),0))})),e(this.el).height("auto");var h=e(u).find("> div.w2ui-multi-items").height()+2*w2utils.getSize(u,"+height");h<26&&(h=26),h>i.maxHeight&&(h=i.maxHeight),0<u.length&&(u[0].scrollTop=1e3);var p,f=w2utils.getSize(e(this.el),"height")-2;h<f&&(h=f),e(u).css({height:h+"px",overflow:h==i.maxHeight?"auto":"hidden"}),h<i.maxHeight&&e(u).prop("scrollTop",0),e(this.el).css({height:h+0+"px"}),"enum"===t.type&&(p=t.helpers.multi.find("input")).width(8*(p.val().length+2)+"px")}return(new Date).getTime()-n},reset:function(){var e=this.type;this.clear(),this.type=e,this.init()},resize:function(){var t,i,s,n,l,a=this,r=e(a.el).width(),o=e(a.el).height();a.tmp.current_width==r&&0<o||(t=this.helpers.focus,i=this.helpers.multi,s=this.helpers.suffix,n=this.helpers.prefix,t&&t.width(e(a.el).width()),i&&(l=w2utils.getSize(a.el,"width")-parseInt(e(a.el).css("margin-left"),10)-parseInt(e(a.el).css("margin-right"),10),e(i).width(l)),s&&(a.options.suffix='<div class="arrow-down" style="margin-top: '+(parseInt(e(a.el).height())-6)/2+'px;"></div>',a.addSuffix()),n&&a.addPrefix(),a.tmp.current_width=r)},clean:function(t){if("number"==typeof t)return t;var i=this.options;return t=String(t).trim(),-1!==["int","float","money","currency","percent"].indexOf(this.type)&&("string"==typeof t&&(i.autoFormat&&-1!==["money","currency"].indexOf(this.type)&&(t=String(t).replace(i.moneyRE,"")),i.autoFormat&&"percent"===this.type&&(t=String(t).replace(i.percentRE,"")),i.autoFormat&&-1!==["int","float"].indexOf(this.type)&&(t=String(t).replace(i.numberRE,"")),t=t.replace(/\s+/g,"").replace(w2utils.settings.groupSymbol,"").replace(w2utils.settings.decimalSymbol,".")),parseFloat(t)==t&&(null!=i.min&&t<i.min&&(t=i.min,e(this.el).val(i.min)),null!=i.max&&t>i.max&&(t=i.max,e(this.el).val(i.max))),t=""!==t&&w2utils.isFloat(t)?Number(t):""),t},format:function(e){var t=this.options;if(t.autoFormat&&""!==e)switch(this.type){case"money":case"currency":""!==(e=w2utils.formatNumber(e,t.currencyPrecision,t.groupSymbol))&&(e=t.currencyPrefix+e+t.currencySuffix);break;case"percent":""!==(e=w2utils.formatNumber(e,t.precision,t.groupSymbol))&&(e+="%");break;case"float":e=w2utils.formatNumber(e,t.precision,t.groupSymbol);break;case"int":e=w2utils.formatNumber(e,0,t.groupSymbol)}return e},change:function(t){var i,s,n,l=this,a=l.options;if(-1!==["int","float","money","currency","percent"].indexOf(this.type)){var r=e(this.el).val(),o=this.format(this.clean(e(this.el).val()));if(""!==r&&r!=o)return e(this.el).val(o).trigger("input").change(),t.stopPropagation(),t.preventDefault(),!1}"color"===this.type&&("rgb"!==(i=e(this.el).val()).substr(0,3).toLowerCase()&&(i="#"+i,8!==(s=e(this.el).val().length)&&6!==s&&3!==s&&(i="")),e(this.el).next().find("div").css("background-color",i),e(this.el).hasClass("has-focus")&&!0!==e(this.el).data("skipInit")&&this.updateOverlay()),-1!==["list","enum","file"].indexOf(this.type)&&(l.refresh(),setTimeout((function(){l.refresh()}),5)),-1!==["date","time","datetime"].indexOf(this.type)&&(n=parseInt(l.el.value),w2utils.isInt(l.el.value)&&3e3<n&&("time"===this.type&&e(l.el).val(w2utils.formatTime(new Date(n),a.format)).trigger("input").change(),"date"===this.type&&e(l.el).val(w2utils.formatDate(new Date(n),a.format)).trigger("input").change(),"datetime"===this.type&&e(l.el).val(w2utils.formatDateTime(new Date(n),a.format)).trigger("input").change()))},click:function(t){t.stopPropagation(),-1!==["list","combo","enum"].indexOf(this.type)&&(e(this.el).hasClass("has-focus")||this.focus(t)),-1!==["date","time","color","datetime"].indexOf(this.type)&&this.updateOverlay()},focus:function(t){var i=this;if(e(i.el).addClass("has-focus"),-1!==["color","date","time","datetime"].indexOf(i.type)){if(e(i.el).prop("readonly")||e(i.el).prop("disabled"))return;0<e("#w2ui-overlay").length&&e("#w2ui-overlay")[0].hide(),setTimeout((function(){i.updateOverlay()}),150)}if(-1!==["list","combo","enum"].indexOf(i.type)){if(e(i.el).prop("readonly")||e(i.el).prop("disabled"))return;0<e("#w2ui-overlay").length&&e("#w2ui-overlay")[0].hide(),i.resize(),setTimeout((function(){"list"===i.type&&e(i.el).is(":focus")?e(i.helpers.focus).find("input").focus():(i.search(),setTimeout((function(){i.updateOverlay()}),1))}),1),"function"==typeof i.options._items_fun&&(i.options.items=w2obj.field.prototype.normMenu.call(this,i.options._items_fun))}"file"===i.type&&e(i.helpers.multi).css({outline:"auto 5px #7DB4F3","outline-offset":"2px"})},blur:function(t){var i,s=this,n=s.options,l=e(s.el).val().trim(),a=e("#w2ui-overlay");e(s.el).removeClass("has-focus"),-1!==["color","date","time","list","combo","enum","datetime"].indexOf(s.type)&&(i=window.setTimeout((function(){!0!==a.data("keepOpen")&&a.hide()}),0),e(".menu",a).one("focus",(function(){clearTimeout(i),e(this).one("focusout",(function(e){a.hide()}))}))),-1!==["int","float","money","currency","percent"].indexOf(s.type)&&(""===l||s.checkType(l)||(e(s.el).val("").trigger("input").change(),!1===n.silent&&(e(s.el).w2tag("Not a valid number"),setTimeout((function(){e(s.el).w2tag("")}),3e3)))),-1!==["date","time","datetime"].indexOf(s.type)&&(""===l||s.inRange(s.el.value)?"date"!==s.type||""===l||w2utils.isDate(s.el.value,n.format)?"time"!==s.type||""===l||w2utils.isTime(s.el.value)?"datetime"!==s.type||""===l||w2utils.isDateTime(s.el.value,n.format)||(e(s.el).val("").removeData("selected").trigger("input").change(),!1===n.silent&&(e(s.el).w2tag("Not a valid date"),setTimeout((function(){e(s.el).w2tag("")}),3e3))):(e(s.el).val("").removeData("selected").trigger("input").change(),!1===n.silent&&(e(s.el).w2tag("Not a valid time"),setTimeout((function(){e(s.el).w2tag("")}),3e3))):(e(s.el).val("").removeData("selected").trigger("input").change(),!1===n.silent&&(e(s.el).w2tag("Not a valid date"),setTimeout((function(){e(s.el).w2tag("")}),3e3))):(e(s.el).val("").removeData("selected").trigger("input").change(),!1===n.silent&&(e(s.el).w2tag("Not in range"),setTimeout((function(){e(s.el).w2tag("")}),3e3)))),"enum"===s.type&&e(s.helpers.multi).find("input").val("").width(20),"f
1ile"===s.type&&e(s.helpers.multi).css({outline:"none"})},keyPress:function(e){var t=this;if(t.options,-1!==["int","float","money","currency","percent","hex","bin","color","alphanumeric"].indexOf(t.type)){if(e.metaKey||e.ctrlKey||e.altKey||e.charCode!=e.keyCode&&0<e.keyCode)return;var i=String.fromCharCode(e.charCode);if(!t.checkType(i,!0)&&13!=e.keyCode)return e.preventDefault(),e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}-1!==["date","time","datetime"].indexOf(t.type)&&9!==e.keyCode&&setTimeout((function(){t.updateOverlay()}),1)},keyDown:function(t,i){var s=this,n=s.options,l=t.keyCode||i&&i.keyCode,a=!1;if(-1!==["int","float","money","currency","percent"].indexOf(s.type)){if(!n.keyboard||e(s.el).prop("readonly")||e(s.el).prop("disabled"))return;var r=parseFloat(e(s.el).val().replace(n.moneyRE,""))||0,o=n.step;switch((t.ctrlKey||t.metaKey)&&(o=10),l){case 38:if(t.shiftKey)break;var d=r+o<=n.max||null==n.max?Number((r+o).toFixed(12)):n.max;e(s.el).val(d).trigger("input").change(),a=!0;break;case 40:if(t.shiftKey)break;d=r-o>=n.min||null==n.min?Number((r-o).toFixed(12)):n.min,e(s.el).val(d).trigger("input").change(),a=!0}
1a&&(t.preventDefault(),setTimeout((function(){s.el.setSelectionRange(s.el.value.length,s.el.value.length)}),0))}if("date"===s.type){if(!n.keyboard||e(s.el).prop("readonly")||e(s.el).prop("disabled"))return;var u=864e5;switch(o=1,(t.ctrlKey||t.metaKey)&&(o=10),(p=w2utils.isDate(e(s.el).val(),n.format,!0))||(p=new Date,u=0),l){case 38:if(t.shiftKey)break;var c=w2utils.formatDate(p.getTime()+u,n.format);10==o&&(c=w2utils.formatDate(new Date(p.getFullYear(),p.getMonth()+1,p.getDate()),n.format)),e(s.el).val(c).trigger("input").change(),a=!0;break;case 40:if(t.shiftKey)break;c=w2utils.formatDate(p.getTime()-u,n.format),10==o&&(c=w2utils.formatDate(new Date(p.getFullYear(),p.getMonth()-1,p.getDate()),n.format)),e(s.el).val(c).trigger("input").change(),a=!0}a&&(t.preventDefault(),setTimeout((function(){s.el.setSelectionRange(s.el.value.length,s.el.value.length),s.updateOverlay()}),0))}if("time"===s.type){if(!n.keyboard||e(s.el).prop("readonly")||e(s.el).prop("disabled"))return;o=t.ctrlKey||t.metaKey?60:1,r=e(s.el).val();var h=s.toMin(r)||s.toMin((new Date).getHours()+":"+((new Date).getMinutes()-1));switch(l){case 38:if(t.shiftKey)break;h+=o,a=!0;break;case 40:if(t.shiftKey)break;h-=o,a=!0}a&&(e(s.el).val(s.fromMin(h)).trigger("input").change(),t.preventDefault(),setTimeout((function(){s.el.setSelectionRange(s.el.value.length,s.el.value.length)}),0))}if("datetime"===s.type){if(!n.keyboard||e(s.el).prop("readonly")||e(s.el).prop("disabled"))return;u=864e5,o=1,(t.ctrlKey||t.metaKey)&&(o=10);var p,f=e(s.el).val();switch((p=w2utils.isDateTime(f,this.options.format,!0))||(p=new Date,u=0),l){case 38:if(t.shiftKey)break;c=w2utils.formatDateTime(p.getTime()+u,n.format),10==o&&(c=w2utils.formatDateTime(new Date(p.getFullYear(),p.getMonth()+1,p.getDate()),n.format)),e(s.el).val(c).trigger("input").change(),a=!0;break;case 40:if(t.shiftKey)break;c=w2utils.formatDateTime(p.getTime()-u,n.format),10==o&&(c=w2utils.formatDateTime(new Date(p.getFullYear(),p.getMonth()-1,p.getDate()),n.format)),e(s.el).val(c).trigger("input").change(),a=!0}
1a&&(t.preventDefault(),setTimeout((function(){s.el.setSelectionRange(s.el.value.length,s.el.value.length),s.updateOverlay()}),0))}if("color"===s.type){if(e(s.el).prop("readonly")||e(s.el).prop("disabled"))return;if((t.ctrlKey||t.metaKey)&&!t.shiftKey){var g,m=null;switch(l){case 38:m="up";break;case 40:m="down";break;case 39:m="right";break;case 37:m="left"}s.el.nav&&null!=m&&(g=s.el.nav(m),e(s.el).val(g).trigger("input").change(),t.preventDefault())}}if(-1!==["list","combo","enum"].indexOf(s.type)){if(e(s.el).prop("readonly")||e(s.el).prop("disabled"))return;var w=e(s.el).data("selected"),v=e(s.el),y=!1;switch(-1!==["list","enum"].indexOf(s.type)&&("list"===s.type&&(v=e(s.helpers.focus).find("input")),"enum"===s.type&&(v=e(s.helpers.multi).find("input")),-1==[37,38,39,40].indexOf(l)&&setTimeout((function(){s.refresh()}),1),86==t.keyCode&&(t.ctrlKey||t.metaKey)&&setTimeout((function(){s.refresh(),s.search(),s.request()}),50)),l){case 27:"list"===s.type&&(""!==v.val()&&v.val(""),t.stopPropagation());break;case 37:case 39:break;case 13:if(0===e("#w2ui-overlay").length)break;var b=n.items[n.index];if("enum"===s.type)if(null!=b){if(!0===(x=s.trigger({phase:"before",type:"add",target:s.el,originalEvent:t.originalEvent,item:b})).isCancelled)return;b=x.item,w.length>=n.max&&0<n.max&&w.pop(),delete b.hidden,delete s.tmp.force_open,w.push(b),e(s.el).trigger("input").change(),v.val("").width(20),s.refresh(),s.trigger(e.extend(x,{phase:"after"}))}else{if(b={id:v.val(),text:v.val()},!0===(x=s.trigger({phase:"before",type:"new",target:s.el,originalEvent:t.originalEvent,item:b})).isCancelled)return;b=x.item,"function"==typeof s.onNew&&(w.length>=n.max&&0<n.max&&w.pop(),delete s.tmp.force_open,w.push(b),e(s.el).trigger("input").change(),v.val("").width(20),s.refresh()),s.trigger(e.extend(x,{phase:"after"}))}else b&&e(s.el).data("selected",b).val(b.text).trigger("input").change(),""===e(s.el).val()&&e(s.el).data("selected")&&e(s.el).removeData("selected").val("").trigger("input").change(),"list"===s.type&&(v.val(""),s.refresh()),s.tmp.force_hide=!0;break;case 8:case 46:if("enum"===s.type&&8===l&&""===v.val()&&0<w.length){var x;if(b=w[w.length-1],!0===(x=s.trigger({phase:"before",type:"remove",target:s.el,originalEvent:t.originalEvent,item:b})).isCancelled)return;w.pop(),e(s.el).trigger("input").trigger("change"),s.refresh(),s.trigger(e.extend(x,{phase:"after"}))}"list"===s.type&&""===v.val()&&(e(s.el).data("selected",{}).trigger("input").change(),s.refresh());break;case 38:for(n.index=w2utils.isInt(n.index)?parseInt(n.index):0,n.index--;0<n.index&&(n.items[n.index].hidden||n.items[n.index].disabled);)n.index--;if(0===n.index&&(n.items[n.index].hidden||n.items[n.index].disabled))for(;n.items[n.index]&&(n.items[n.index].hidden||n.items[n.index].disabled);)n.index++;y=!0;break;case 40:for(n.index=w2utils.isInt(n.index)?parseInt(n.index):-1,n.index++;n.index<n.items.length-1&&(n.items[n.index].hidden||n.items[n.index].disabled);)n.index++;if(n.index==n.items.length-1&&(n.items[n.index].hidden||n.items[n.index].disabled))for(;n.items[n.index]&&(n.items[n.index].hidden||n.items[n.index].disabled);)n.index--;""===v.val()&&0===e("#w2ui-overlay").length?s.tmp.force_open=!0:y=!0}if(y)return n.index<0&&(n.index=0),n.index>=n.items.length&&(n.index=n.items.length-1),s.updateOverlay(y),t.preventDefault(),void setTimeout((function(){var e;"enum"===s.type||"list"===s.type?(e=v.get(0)).setSelectionRange(e.value.length,e.value.length):s.el.setSelectionRange(s.el.value.length,s.el.value.length)}),0);"enum"===s.type&&v.width(8*(v.val().length+2)+"px")}},keyUp:function(t){if(-1!==["list","combo","enum"].indexOf(this.type)){if(e(this.el).prop("readonly")||e(this.el).prop("disabled"))return;if(-1==[16,17,18,20,37,39,91].indexOf(t.keyCode)){var i=e(this.helpers.focus).find("input");0===i.length&&(i=e(this.el));var s=this.trigger({phase:"before",type:"search",originalEvent:t,target:i,search:i.val()});if(!0===s.isCancelled)return;this.tmp.force_hide||this.request(),1==i.val().length&&this.refresh(),0!==e("#w2ui-overlay").length&&-1!=[38,40].indexOf(t.keyCode)||this.search(),this.trigger(e.extend(s,{phase:"after"}))}}},clearCache:function(){this.options.items=[],this.tmp.xhr_loading=!1,this.tmp.xhr_search="",this.tmp.xhr_total=-1},request:function(t){var i,s=this,n=this.options,l=e(s.el).val()||"";if(n.url){if("enum"===s.type&&(l=0===(i=e(s.helpers.multi).find("input")).length?"":i.val()),"list"===s.type&&(i=e(s.helpers.focus).find("input"),l=0===i.length?"":i.val()),0!==n.minLength&&l.length<n.minLength)return n.items=[],void this.updateOverlay();if(null==t&&(t=n.interval),null==s.tmp.xhr_search&&(s.tmp.xhr_search=""),null==s.tmp.xhr_total&&(s.tmp.xhr_total=-1),n.url&&(0===n.items.length&&0!==s.tmp.xhr_total||s.tmp.xhr_total==n.
1cacheMax&&l.length>s.tmp.xhr_search.length||l.length>=s.tmp.xhr_search.length&&l.substr(0,s.tmp.xhr_search.length)!==s.tmp.xhr_search||l.length<s.tmp.xhr_search.length)){if(s.tmp.xhr)try{s.tmp.xhr.abort()}catch(t){}s.tmp.xhr_loading=!0,s.search(),clearTimeout(s.tmp.timeout),s.tmp.timeout=setTimeout((function(){var t=n.url,i={search:l,max:n.cacheMax};e.extend(i,n.postData);var a,r=s.trigger({phase:"before",type:"request",search:l,target:s.el,url:t,postData:i});!0!==r.isCancelled&&(a={type:"GET",url:r.url,data:i=r.postData,dataType:"JSON"},n.method&&(a.type=n.method),"JSON"===w2utils.settings.dataType&&(a.type="POST",a.data=JSON.stringify(a.data),a.contentType="application/json"),"HTTPJSON"===w2utils.settings.dataType&&(a.data={request:JSON.stringify(a.data)}),null!=n.method&&(a.type=n.method),s.tmp.xhr=e.ajax(a).done((function(t,a,r){var o,d,u=s.trigger({phase:"before",type:"load",target:s.el,search:i.search,data:t,xhr:r});!0!==u.isCancelled&&("string"==typeof(t=u.data)&&(t=JSON.parse(t)),null==t.records&&null!=t.items&&(t.records=t.items,delete t.items),"success"===t.status&&null==t.records&&(t.records=[]),"success"===t.status&&Array.isArray(t.records)?(t.records.length>n.cacheMax&&t.records.splice(n.cacheMax,1e5),null==n.recId&&null!=n.recid&&(n.recId=n.recid),(n.recId||n.recText)&&t.records.forEach((function(e){"string"==typeof n.recId&&(e.id=e[n.recId]),"function"==typeof n.recId&&(e.id=n.recId(e)),"string"==typeof n.recText&&(e.text=e[n.recText]),"function"==typeof n.recText&&(e.text=n.recText(e))})),s.tmp.xhr_loading=!1,s.tmp.xhr_search=l,s.tmp.xhr_total=t.records.length,s.tmp.lastError="",n.items=s.normMenu(t.records),""===l&&0===t.records.length?s.tmp.emptySet=!0:s.tmp.emptySet=!1,(o=e(s.el).data("find_selected"))&&(Array.isArray(o)?(d=[],o.forEach((function(t){var i=!1;n.items.forEach((function(s){(s.id==t||t&&t.id==s.id)&&(d.push(e.extend(!0,{},s)),i=!0)})),i||d.push(t)}))):(d=o,n.items.forEach((function(e){(e.id==o||o&&o.id==e.id)&&(d=e)}))),e(s.el).data("selected",d).removeData("find_selected").trigger("input").change()),s.search(),s.trigger(e.extend(u,{phase:"after"}))):console.log("ERROR: server did not return proper structure. It should return",{status:"success",records:[{id:1,text:"item"}]}))})).fail((function(t,i,a){var r,o={status:i,error:a,rawResponseText:t.responseText},d=s.trigger({phase:"before",type:"error",target:s.el,search:l,error:o,xhr:t});if(!0!==d.isCancelled){if("abort"!==i){try{r=e.parseJSON(t.responseText)}catch(t){}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 r?r:t.responseText)}s.tmp.xhr_loading=!1,s.tmp.xhr_search=l,s.tmp.xhr_total=0,s.tmp.emptySet=!0,s.tmp.lastError=d.error||"Server communication failed",n.items=[],s.clearCache(),s.search(),s.updateOverlay(!1),s.trigger(e.extend(d,{phase:"after"}))}})),s.trigger(e.extend(r,{phase:"after"})))}),t)}}},search:function(){var t=this,i=this.options,s=e(t.el).val(),n=t.el,l=[],a=e(t.el).data("selected");if("enum"===t.type)for(var r in n=e(t.helpers.multi).find("input"),s=n.val(),a)a[r]&&l.push(a[r].id);else if("list"===t.type)for(var r in n=e(t.helpers.focus).find("input"),s=n.val(),a)a[r]&&l.push(a[r].id);var o=i.items;if(!0!==t.tmp.xhr_loading){for(var d=0,u=0;u<o.length;u++){var c=o[u];if(null!=i.compare)"function"==typeof i.compare&&(c.hidden=!1===i.compare.call(this,c,s));else{var h="",p="";-1!==["is","begins"].indexOf(i.match)&&(h="^"),-1!==["is","ends"].indexOf(i.match)&&(p="$");try{new RegExp(h+s+p,"i").test(c.text)||"..."===c.text?c.hidden=!1:c.hidden=!0}catch(t){}}!1===i.filter&&(c.hidden=!1),"enum"===t.type&&-1!==e.inArray(c.id,l)&&(c.hidden=!0),!0!==c.hidden&&(d++,delete c.hidden)}for(i.index=-1;o[i.index]&&o[i.index].hidden;)i.index++;d<=0&&(i.index=-1),i.spinner=!1,t.updateOverlay(),setTimeout((function(){var t=e("#w2ui-overlay").html()||"";i.markSearch&&-1!==t.indexOf("$.fn.w2menuHandler")&&e("#w2ui-overlay").w2marker(s)}),1)}else o.splice(0,i.cacheMax),i.spinner=!0,t.updateOverlay()},updateOverlay:function(t){var i,s,n,l=this,a=this.options;if("color"===this.type){if(e(l.el).prop("readonly")||e(l.el).prop("disabled"))return;e(this.el).w2color({color:e(this.el).val(),transparent:a.transparent,advanced:a.advanced},(function(t){null!=t&&e(l.el).val(t).trigger("input").change()}))}if("date"===this.type){if(e(l.el).prop("readonly")||e(l.el).prop("disabled"))return;0===e("#w2ui-overlay").length&&e(l.el).w2overlay('<div class="w2ui-reset w2ui-calendar"></div>',{css:{"background-color":"#f5f5f5"},onShow:function(t){w2utils.isIE&&e(".w2ui-calendar").on("mousedown",(function(t){var i=e(t.target);1===i.length&&"w2ui-jump-year"===i[0].id&&e("#w2ui-overlay").data("keepOpen",!0)}))}}),(n=w2utils.isDate(e(l.el).val(),l.options.format,!0))&&(i=n.getMonth()+1,s=n.getFullYear()),function t(i,s){e("#
1w2ui-overlay > div > div").html(l.getMonthHTML(i,s,e(l.el).val())),e("#w2ui-overlay .w2ui-calendar-title").on("mousedown",(function(){var i,s;e(this).next().hasClass("w2ui-calendar-jump")?e(this).next().remove():(e(this).after('<div class="w2ui-calendar-jump" style=""></div>'),e(this).next().hide().html(l.getYearHTML()).fadeIn(200),setTimeout((function(){e("#w2ui-overlay .w2ui-calendar-jump").find(".w2ui-jump-month, .w2ui-jump-year").on("click",(function(){e(this).hasClass("w2ui-jump-month")&&(e(this).parent().find(".w2ui-jump-month").removeClass("selected"),e(this).addClass("selected"),s=e(this).attr("name")),e(this).hasClass("w2ui-jump-year")&&(e(this).parent().find(".w2ui-jump-year").removeClass("selected"),e(this).addClass("selected"),i=e(this).attr("name")),null!=i&&null!=s&&(e("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout((function(){t(parseInt(s)+1,i)}),100))})),e("#w2ui-overlay .w2ui-calendar-jump >:last-child").prop("scrollTop",2e3)}),1))})),e("#w2ui-overlay .w2ui-date").on("mousedown",(function(){var t=e(this).attr("date");e(l.el).val(t).trigger("input").change(),e(this).css({"background-color":"#B6D5FB","border-color":"#aaa"})})).on("mouseup",(function(){setTimeout((function(){0<e("#w2ui-overlay").length&&e("#w2ui-overlay").removeData("keepOpen")[0].hide()}),10)})),e("#w2ui-overlay .previous").on("mousedown",(function(){var e=l.options.current.split("/");e[0]=parseInt(e[0])-1,t(e[0],e[1])})),e("#w2ui-overlay .next").on("mousedown",(function(){var e=l.options.current.split("/");e[0]=parseInt(e[0])+1,t(e[0],e[1])}))}(i,s)}if("time"===this.type){if(e(l.el).prop("readonly")||e(l.el).prop("disabled"))return;0===e("#w2ui-overlay").length&&e(l.el).w2overlay('<div class="w2ui-reset w2ui-calendar-time" onclick="event.stopPropagation();"></div>',{css:{"background-color":"#fff"}});var r="h24"===this.options.format;e("#w2ui-overlay > div").html(l.getHourHTML()),e("#w2ui-overlay .w2ui-time").on("mousedown",(function(t){e(this).css({"background-color":"#B6D5FB","border-color":"#aaa"});var i=e(this).attr("hour");e(l.el).val((12<i&&!r?i-12:i)+":00"+(r?"":i<12?" am":" pm")).trigger("input").change()})),null==this.options.noMinutes||!1===this.options.noMinutes?e("#w2ui-overlay .w2ui-time").on("mouseup",(function(){var t=e(this).attr("hour");0<e("#w2ui-overlay").length&&e("#w2ui-overlay")[0].hide(),e(l.el).w2overlay('<div class="w2ui-reset w2ui-calendar-time"></div>',{css:{"background-color":"#fff"}}),e("#w2ui-overlay > div").html(l.getMinHTML(t)),e("#w2ui-overlay .w2ui-time").on("mousedown",(function(){e(this).css({"background-color":"#B6D5FB","border-color":"#aaa"});var i=e(this).attr("min");e(l.el).val((12<t&&!r?t-12:t)+":"+(i<10?0:"")+i+(r?"":t<12?" am":" pm")).trigger("input").change()})).on("mouseup",(function(){setTimeout((function(){0<e("#w2ui-overlay").length&&e("#w2ui-overlay").removeData("keepOpen")[0].hide()}),10)}))})):e("#w2ui-overlay .w2ui-time").on("mouseup",(function(){setTimeout((function(){0<e("#w2ui-overlay").length&&e("#w2ui-overlay").removeData("keepOpen")[0].hide()}),10)}))}if("datetime"===this.type){if(e(l.el).prop("readonly")||e(l.el).prop("disabled"))return;0<e("#w2ui-overlay .w2ui-time").length&&e("#w2ui-overlay")[0].hide(),0===e("#w2ui-overlay").length&&e(l.el).w2overlay('<div class="w2ui-reset w2ui-calendar" onclick="event.stopPropagation();"></div>',{css:{"background-color":"#f5f5f5"},onShow:function(t){w2utils.isIE&&e(".w2ui-calendar").on("mousedown",(function(t){var i=e(t.target);1===i.length&&"w2ui-jump-year"===i[0].id&&e("#w2ui-overlay").data("keepOpen",!0)}))}}),(n=w2utils.isDateTime(e(l.el).val(),l.options.format,!0))&&(i=n.getMonth()+1,s=n.getFullYear());var o=null;!function t(i,s){e("#w2ui-overlay > div > div").html(l.getMonthHTML(i,s,e(l.el).val())+(a.btn_now?'<div class="w2ui-calendar-now now">'+w2utils.lang("Current Date & Time")+"</div>":"")),e("#w2ui-overlay .w2ui-calendar-title").on("mousedown",(function(){var i,s;e(this).next().hasClass("w2ui-calendar-jump")?e(this).next().remove():(e(this).after('<div class="w2ui-calendar-jump" style=""></div>'),e(this).next().hide().html(l.getYearHTML()).fadeIn(200),setTimeout((function(){e("#w2ui-overlay .w2ui-calendar-jump").find(".w2ui-jump-month, .w2ui-jump-year").on("click",(function(){e(this).hasClass("w2ui-jump-month")&&(e(this).parent().find(".w2ui-jump-month").removeClass("selected"),e(this).addClass("selected"),s=e(this).attr("name")),e(this).hasClass("w2ui-jump-year")&&(e(this).parent().find(".w2ui-jump-year").removeClass("selected"),e(this).addClass("selected"),i=e(this).attr("name")),null!=i&&null!=s&&(e("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout((function(){t(parseInt(s)+1,i)}),100))})),e("#w2ui-overlay .w2ui-calendar-jump >:last-child").prop("scrollTop",2e3)}),1))})),e("#w2ui-overlay .w2ui-date").on("mousedown",(function(){var t=e(this).attr("date");e(l.el).val(t).trigger("input").change(),e(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),o=new Date(e(this).attr("data-date"))})).on("mouseup",(function(){var t,i;0<e("#w2ui-overlay").length&&e("#w2ui-overlay")[0].hide(),e(l.el).w2overlay('<div class="w2ui-reset w2ui-calendar-time"></div>',{css:{"background-color":"#fff"}}
1),l.options.format,e("#w2ui-overlay > div").html(l.getHourHTML()),e("#w2ui-overlay .w2ui-time").on("mousedown",(function(i){e(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),t=e(this).attr("hour"),o.setHours(t);var s=w2utils.formatDateTime(o,l.options.format);e(l.el).val(s).trigger("input").change()})),null==l.options.noMinutes||!1===l.options.noMinutes?e("#w2ui-overlay .w2ui-time").on("mouseup",(function(){var s=e(this).attr("hour");0<e("#w2ui-overlay").length&&e("#w2ui-overlay")[0].hide(),e(l.el).w2overlay('<div class="w2ui-reset w2ui-calendar-time"></div>',{css:{"background-color":"#fff"}}),e("#w2ui-overlay > div").html(l.getMinHTML(s)),e("#w2ui-overlay .w2ui-time").on("mousedown",(function(){e(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),i=e(this).attr("min"),o.setHours(t,i);var s=w2utils.formatDateTime(o,l.options.format);e(l.el).val(s).trigger("input").change()})).on("mouseup",(function(){setTimeout((function(){0<e("#w2ui-overlay").length&&e("#w2ui-overlay").removeData("keepOpen")[0].hide()}),10)}))})):e("#w2ui-overlay .w2ui-time").on("mouseup",(function(){setTimeout((function(){0<e("#w2ui-overlay").length&&e("#w2ui-overlay").removeData("keepOpen")[0].hide()}),10)}))})),e("#w2ui-overlay .previous").on("mousedown",(function(){var e=l.options.current.split("/");e[0]=parseInt(e[0])-1,t(e[0],e[1])})),e("#w2ui-overlay .next").on("mousedown",(function(){var e=l.options.current.split("/");e[0]=parseInt(e[0])+1,t(e[0],e[1])})),e("#w2ui-overlay .now").on("mousedown",(function(){var t=w2utils.formatDateTime(new Date,l.options.format);return e(l.el).val(t).trigger("input").change(),!1})).on("mouseup",(function(){setTimeout((function(){0<e("#w2ui-overlay").length&&e("#w2ui-overlay").removeData("keepOpen")[0].hide()}),10)}))}(i,s)}if(-1!==["list","combo","enum"].indexOf(this.type)){var d,u=this.el,c=this.el;if("enum"===this.type&&(u=e(this.helpers.multi),c=e(u).find("input")),"list"===this.type&&(d=e(c).data("selected"),e.isPlainObject(d)&&!e.isEmptyObject(d)&&-1==a.index&&a.items.forEach((function(e,t){e.id===d.id&&(a.index=t)})),c=e(this.helpers.focus).find("input")),e(this.el).hasClass("has-focus")){if(!1===a.openOnFocus&&""===e(c).val()&&!0!==l.tmp.force_open)return void e().w2overlay();if(l.tmp.force_hide)return e().w2overlay(),void setTimeout((function(){delete l.tmp.force_hide}),1);""!==e(c).val()&&delete l.tmp.force_open;var h,p=w2utils.lang("No matches");null!=a.url&&String(e(c).val()).length<a.minLength&&!0!==l.tmp.emptySet&&(p=a.minLength+" "+w2utils.lang("letters or more...")),null!=a.url&&""===e(c).val()&&!0!==l.tmp.emptySet&&(p=w2utils.lang(a.msgSearch||"Type to search...")),null==a.url&&0===a.items.length&&(p=w2utils.lang("Empty list")),null!=a.msgNoItems&&(h={search:e(c).val(),options:e.extend(!0,{},a)},a.url&&(h.remote={url:a.url,empty:!!l.tmp.emptySet,error:l.tmp.lastError,minLength:a.minLength}),p="function"==typeof a.msgNoItems?a.msgNoItems(h):a.msgNoItems),l.tmp.lastError&&(p=l.tmp.lastError),p=p&&'<div style="white-space: normal; line-height: 1.3">'+p+"</div>";var f=e.extend(!0,{},a,{search:!1,render:a.renderDrop,maxHeight:a.maxDropHeight,maxWidth:a.maxDropWidth,msgNoItems:p,onSelect:function(t){if("enum"===l.type){var i=e(l.el).data("selected");if(t.item){var s,n=l.trigger({phase:"before",type:"add",target:l.el,originalEvent:t.originalEvent,item:t.item});if(!0===n.isCancelled)return;i.length>=a.max&&0<a.max&&i.pop(),delete t.item.hidden,i.push(t.item),e(l.el).data("selected",i).trigger("input").change(),e(l.helpers.multi).find("input").val("").width(20),l.refresh(),!0!==t.keepOpen?0<e("#w2ui-overlay").length&&e("#w2ui-overlay")[0].hide():(f.items.forEach((function(e,i){e.id==t.item.id&&(s=i)})),null!=s&&f.items.splice(s,1),f.selected=i,e(u).w2menu("refresh",f)),l.trigger(e.extend(n,{phase:"after"}))}}else e(l.el).data("selected",t.item).val(t.item.text).trigger("input").change(),l.helpers.focus&&l.helpers.focus.find("input").val("")}});e(u).w2menu(t?"refresh-index":"refresh",f)}}},inRange:function(t,i){var s,n,l,a,r,o,d,u,c,h=!1;if("date"===this.type){if((a=w2utils.isDate(t,this.options.format,!0))&&(this.options.start||this.options.end?(d="string"==typeof this.options.start?this.options.start:e(this.options.start).val(),u="string"==typeof this.options.end?this.options.end:e(this.options.end).val(),r=w2utils.isDate(d,this.options.format,!0),o=w2utils.isDate(u,this.options.format,!0),c=new Date(a),o=o||c,(r=r||c)<=c&&c<=o&&(h=!0)):h=!0,this.options.blocked&&-1!==e.inArray(t,this.options.blocked)&&(h=!1),null!==this.options.blockWeekDays&&void 0!==this.options.blockWeekDays&&null!=this.options.blockWeekDays.length))for(var p=this.options.blockWeekDays.length,f=0;f<p;f++)a.getDay()==this.options.blockWeekDays[f]&&(h=!1)}else if("time"===this.type)this.options.start||this.options.end?(s=this.toMin(t),n=this.toMin(this.options.start),l=(l=this.toMin(this.options.end))||s,(n=n||s)<=s&&s<=l&&(h=!0)):h=!0;else if("datetime"===this.type&&(a=w2utils.isDateTime(t,this.options.format,!0))&&(this.options.start||this.options.end?(c=a,r=(r="object"==typeof this.options.start&&this.options.start instanceof Date?this.options.start:""!==(d="string"==typeof this.options.start?this.options.start:e(this.options.start).val()).trim()?w2utils.isDateTime(d,this.options.format,!0):"")||c,o=(o="object"==typeof this.options.end&&this.options.end instanceof Date?this.options.end:""!==(u="string"==typeof this.options.end?this.options.end:e(this.options.end).val()).trim()?w2utils.isDateTime(u,this.options.format,!0):"")||c,i&&r instanceof Date&&(r.setHours(0),r.setMinutes(0),r.setSeconds(0)),r<=c&&c<=o&&(h=!0)):h=!0,h&&this.options.blocked))for(f=0;f<this.options.blocked.length;f++){var g=this.options.blocked[f];if("string"==typeof g&&(g=w2utils.isDateTime(g,this.options.format,!0)),"object"==typeof g&&g instanceof Date&&g.getFullYear()==a.getFullYear()&&g.getMonth()==a.getMonth()&&g.getDate()==a.getDate()){h=!1;break}}return h},checkType:function(e,t){var i=this;switch(i.type){case"int":return!(!t||-1===["-",i.options.groupSymbol].indexOf(e))||w2utils.isInt(e.replace(i.options.numberRE,""));case"percent":e=e.replace(/%/g,"");case"float":return!(!t||-1===["-",w2utils.settings.decimalSymbol,i.options.groupSymbol].indexOf(e))||w2utils.isFloat(e.replace(i.options.numberRE,""));case"money":case"currency":return!(!t||-1===["-",i.options.decimalSymbol,i.options.groupSymbol,i.options.currencyPrefix,i.options.currencySuffix].indexOf(e))||w2utils.isFloat(e.replace(i.options.moneyRE,""));case"bin":return w2utils.isBin(e);case"hex":return w2utils.isHex(e);case"alphanumeric":return w2utils.isAlphaNumeric(e)}return!0},addPrefix:function(){var t=this;setTimeout((function(){var i,s;"clear"!==t.type&&((s=e(t.el).data("tmp")||{})["old-padding-left"]&&e(t.el).css("padding-left",s["old-padding-left"]),s["old-padding-left"]=e(t.el).css("padding-left"),e(t.el).data("tmp",s),t.helpers.prefix&&e(t.helpers.prefix).remove(),""!==t.options.prefix&&(e(t.el).before('<div class="w2ui-field-helper">'+t.options.prefix+"</div>"),(i=e(t.el).prev()).css({color:e(t.el).css("color"),"font-family":e(t.el).css("font-family"),"font-size":e(t.el).css("font-size"),"padding-top":e(t.el).css("padding-top"),"padding-bottom":e(t.el).css("padding-bottom"),"padding-left":e(t.el).css("padding-left"),"padding-right":0,"margin-top":parseInt(e(t.el).css("margin-top"),10)+2+"px","margin-bottom":parseInt(e(t.el).css("margin-bottom"),10)+1+"px","margin-left":e(t.el).css("margin-left"),"margin-right":0}).on("click",(function(i){if(t.options.icon&&"function"==typeof t.onIconClick){var s=t.trigger({phase:"before",type:"iconClick",target:t.el,el:e(this).find("span.w2ui-icon")[0]});if(!0===s.isCancelled)return;t.trigger(e.extend(s,{phase:"after"}))}else"list"===t.type?e(t.helpers.focus).find("input").focus():e(t.el).focus()})),e(t.el).css("padding-left",i.width()+parseInt(e(t.el).css("padding-left"),10)+"px"),t.helpers.prefix=i))}),1)},addSuffix:function(){var t,i,s=this;setTimeout((function(){var n;"clear"!==s.type&&((n=e(s.el).data("tmp")||{})["old-padding-right"]&&e(s.el).css("padding-right",n["old-padding-right"]),n["old-padding-right"]=e(s.el).css("padding-right"),e(s.el).data("tmp",n),i=parseInt(e(s.el).css("padding-right"),10),s.options.arrows&&(s.helpers.arrows&&e(s.helpers.arrows).remove(),e(s.el).after('<div class="w2ui-field-helper" style="border: 1px solid transparent">  <div class="w2ui-field-up" type="up"> <div class="arrow-up" type="up"></div> </div> <div class="w2ui-field-down" type="down"> <div class="arrow-down" type="down"></div> </div></div>'),(t=e(s.el).next()).css({color:e(s.el).css("color"),"font-family":e(s.el).css("font-family"),"font-size":e(s.el).css("font-size"),height:e(s.el).height()+parseInt(e(s.el).css("padding-top"),10)+parseInt(e(s.el).css("padding-bottom"),10)+"px",padding:0,"margin-top":parseInt(e(s.el).css("margin-top"),10)+1+"px","margin-bottom":0,"border-left":"1px solid silver"}).css("margin-left","-"+(t.width()+parseInt(e(s.el).css("margin-right"),10)+12)+"px").on("mousedown",(function(t){var i=e("body");function n(i){e(s.el).focus(),s.keyDown(e.Event("keydown"),{keyCode:"up"===e(t.target).attr("type")?38:40}),!1!==i&&e("body").data("_field_update_timer",setTimeout(n,60))}i.on("mouseup",(function e(){clearTimeout(i.data("_field_update_timer")),i.off("mouseup",e)})),i.data("_field_update_timer",setTimeout(n,700)),n(!1)})),i+=t.width()+12,e(s.el).css("padding-right",i+"px"),s.helpers.arrows=t),""!==s.options.suffix&&(s.helpers.suffix&&e(s.helpers.suffix).remove(),e(s.el).after('<div class="w2ui-field-helper">'+s.options.suffix+"</div>"),(t=e(s.el).next()).css({color:e(s.el).css("color"),"font-family":e(s.el).css("font-family"),"font-size":e(s.el).css("font-size"),"padding-top":e(s.el).css("padding-top"),"padding-bottom":e(s.el).css("padding-bottom"),"padding-left":"3px","padding-right":e(s.el).css("padding-right"),"margin-top":parseInt(e(s.el).css("margin-top"),10)+2+"px","margin-bottom":parseInt(e(s.el).css("margin-bottom"),10)+1+"px"}).on("click",(function(t){"list"===s.type?e(s.helpers.focus).find("input").focus():e(s.el).focus()})),t.css("margin-left","-"+(w2utils.getSize(t,"width")+parseInt(e(s.el).css("margin-right"),10)+2)+"px"),i+=t.width()+3,e(s.el).css("padding-right",i+"px"),s.helpers.suffix=t))}),1)},addFocus:function(){var t,i=this;this.options,e(i.helpers.focus).remove();var s=parseInt(e(i.el).attr("tabIndex"));isNaN(s)||-1===s||(i.el._tabIndex=s),i.el._tabIndex&&(s=i.el._tabIndex),null==s&&(s=-1),isNaN(s)&&(s=0);var n="";null!=e(i.el).attr("id")&&(n='id="'+e(i.el).attr("id")+'_search"');var l='<div class="w2ui-field-helper"> <div class="w2ui-icon icon-search" style="opacity: 0; display: none"></div> <input '+n+' type="text" tabIndex="'+s+'" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false"/></div>';e(i.el).attr("tabindex",-1).before(l);var a=e(i.el).prev();(i.helpers.focus=a).css({width:e(i.el).width(),"margin-top":e(i.el).css("margin-top"),"margin-left":parseInt(e(i.el).css("margin-left"))+parseInt(e(i.el).css("padding-left"))+"px","margin-bottom":e(i.el).css("margin-bottom"),"margin-right":e(i.el).css("margin-right")}).find("input").css({cursor:"default",width:"100%",outline:"none",opacity:1,margin:0,border:"1px solid transparent",padding:e(i.el).css("padding-top"),"padding-left":0,"margin-left":0,"background-color":"transparent"}),a.find("input").on("click",(function(t){0===e("#w2ui-overlay").length&&i.focus(t),t.stopPropagation()})).on("focus",(function(s){t=e(i.el).attr("placeholder"),e(i.el).css({outline:"auto 5px #7DB4F3","outline-offset":"2px"}),e(this).val(""),e(i.el).triggerHandler("focus"),s.stopPropagation?s.stopPropagation():s.cancelBubble=!0})).on("blur",(function(s){e(i.el).css("outline","none"),e(this).val(""),i.refresh(),e(i.el).triggerHandler("blur"),s.stopPropagation?s.stopPropagation():s.cancelBubble=!0,null!=t&&e(i.el).attr("placeholder",t)})).on("keydown",(function(s){var n=this;i.keyDown(s),setTimeout((function(){""===n.value?e(i.el).attr("placeholder",t):e(i.el).attr("placeholder","")}),10)})).on("keyup",(function(e){i.keyUp(e)})).on("keypress",(function(e){i.keyPress(e)})),a.on("click",(function(t){e(this).find("input").focus()})),i.refresh()},addMulti:function(){var t=this;this.options,e(t.helpers.multi).remove();var i,s="",n="margin-top : 0px; margin-bottom : 0px; margin-left : "+e(t.el).css("margin-left")+"; margin-right : "+e(t.el).css("margin-right")+"; width : "+(w2utils.getSize(t.el,"width")-parseInt(e(t.el).css("margin-left"),10)-parseInt(e(t.el).css("margin-right"),10))+"px;",l="";null!=e(t.el).attr("id")&&(l='id="'+e(t.el).attr("id")+'_search" '),"enum"===t.type&&((i=e(t.el).attr("tabIndex"))&&-1!==i&&(t.el._tabIndex=i),t.el._tabIndex&&(i=t.el._tabIndex),null==i&&(i=0),s='<div class="w2ui-field-helper w2ui-list" style="'+n+'; box-sizing: border-box"> <div style="padding: 0px; margin: 0px; display: inline-block" class="w2ui-multi-items"> <ul> <li style="padding-left: 0px; padding-right: 0px" class="nomouse">
1 <input '+l+' type="text" style="width: 20px; margin: -3px 0 0; padding: 2px 0; border-color: white" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false"'+(e(t.el).prop("readonly")?' readonly="readonly"':"")+(e(t.el).prop("disabled")?' disabled="disabled"':"")+' tabindex="'+i+'"/> </li> </ul> </div></div>'),"file"===t.type&&(s='<div class="w2ui-field-helper w2ui-list" style="'+n+'; box-sizing: border-box"> <div style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px;"> <input '+l+' name="attachment" class="file-input" type="file" style="width: 100%; height: 100%; opacity: 0;" tabindex="-1"'+(1!==t.options.max?' multiple="multiple"':"")+(e(t.el).prop("readonly")?' readonly="readonly"':"")+(e(t.el).prop("disabled")?' disabled="disabled"':"")+(e(t.el).attr("accept")?' accept="'+e(t.el).attr("accept")+'"':"")+'/> </div> <div style="position: absolute; padding: 0px; margin: 0px; display: inline-block" class="w2ui-multi-items"> <ul><li style="padding-left: 0px; padding-right: 0px" class="nomouse"></li></ul> </div></div>');var a=e(t.el).data("tmp")||{};a["old-background-color"]=e(t.el).css("background-color"),a["old-border-color"]=e(t.el).css("border-color"),e(t.el).data("tmp",a),e(t.el).before(s).css({"background-color":"transparent","border-color":"transparent"});var r=e(t.el).prev();t.helpers.multi=r,"enum"===t.type&&(e(t.el).attr("tabindex",-1),r.find("input").on("click",(function(i){0===e("#w2ui-overlay").length&&t.focus(i),e(t.el).triggerHandler("click")})).on("focus",(function(i){e(r).css({outline:"auto 5px #7DB4F3","outline-offset":"2px"}),e(t.el).triggerHandler("focus"),i.stopPropagation?i.stopPropagation():i.cancelBubble=!0})).on("blur",(function(i){e(r).css("outline","none"),e(t.el).triggerHandler("blur"),i.stopPropagation?i.stopPropagation():i.cancelBubble=!0})).on("keyup",(function(e){t.keyUp(e)})).on("keydown",(function(e){t.keyDown(e)})).on("keypress",(function(e){t.keyPress(e)})),r.on("click",(function(t){e(this).find("input").focus()}))),"file"===t.type&&(e(t.el).css("outline","none"),r.find("input").off(".drag").on("click.drag",(function(i){i.stopPropagation(),e(t.el).prop("readonly")||e(t.el).prop("disabled")||e(t.el).focus()})).on("dragenter.drag",(function(i){e(t.el).prop("readonly")||e(t.el).prop("disabled")||e(r).addClass("w2ui-file-dragover")})).on("dragleave.drag",(function(i){e(t.el).prop("readonly")||e(t.el).prop("disabled")||e(r).removeClass("w2ui-file-dragover")})).on("drop.drag",(function(i){if(!e(t.el).prop("readonly")&&!e(t.el).prop("disabled")){e(r).removeClass("w2ui-file-dragover");for(var s=i.originalEvent.dataTransfer.files,n=0,l=s.length;n<l;n++)t.addFile.call(t,s[n]);e(t.el).focus(),i.preventDefault(),i.stopPropagation()}})).on("dragover.drag",(function(e){e.preventDefault(),e.stopPropagation()})).on("change.drag",(function(){if(e(t.el).focus(),void 0!==this.files)for(var i=0,s=this.files.length;i<s;i++)t.addFile.call(t,this.files[i])}))),t.refresh()},addFile:function(t){var i,s=this,n=this.options,l=e(s.el).data("selected"),a={name:t.name,type:t.type,modified:t.lastModifiedDate,size:t.size,content:null,file:t},r=0,o=0;if(l)for(var d=0;d<l.length;d++){if(l[d].name==t.name&&l[d].size==t.size)return;r+=l[d].size,o++}var u,c=s.trigger({phase:"before",type:"add",target:s.el,file:a,total:o,totalSize:r});if(!0!==c.isCancelled){if(0!==n.maxFileSize&&a.size>n.maxFileSize)return i="Maximum file size is "+w2utils.formatSize(n.maxFileSize),!1===n.silent&&e(s.el).w2tag(i),void console.log("ERROR: "+i);if(0!==n.maxSize&&r+a.size>n.maxSize)return i=w2utils.lang("Maximum total size is")+" "+w2utils.formatSize(n.maxSize),void(!1===n.silent?e(s.el).w2tag(i):console.log("ERROR: "+i));if(0!==n.max&&o>=n.max)return i=w2utils.lang("Maximum number of files is")+" "+n.max,void(!1===n.silent?e(s.el).w2tag(i):console.log("ERROR: "+i));l.push(a),"undefined"!=typeof FileReader&&!0===n.readContent?((u=new FileReader).onload=function(t){var i=t.target.result,n=i.indexOf(",");a.content=i.substr(n+1),s.refresh(),e(s.el).trigger("input").trigger("change"),s.trigger(e.extend(c,{phase:"after"}))}
1,u.readAsDataURL(t)):(s.refresh(),e(s.el).trigger("input").trigger("change"),s.trigger(e.extend(c,{phase:"after"})))}},normMenu:function(t,i){if(e.isArray(t)){for(var s=0;s<t.length;s++)"string"==typeof t[s]?t[s]={id:t[s],text:t[s]}:null!=t[s]?(null!=t[s].text&&null==t[s].id&&(t[s].id=t[s].text),null==t[s].text&&null!=t[s].id&&(t[s].text=t[s].id),null!=t[s].caption&&(t[s].text=t[s].caption)):t[s]={id:null,text:"null"};return t}if("function"==typeof t)return w2obj.field.prototype.normMenu.call(this,t.call(this,i));if("object"==typeof t){var n=[];for(var s in t)n.push({id:s,text:t[s]});return n}},getMonthHTML:function(e,t,i){var s=new Date,n=w2utils.settings.fullmonths,l=["31","28","31","30","31","30","31","31","30","31","30","31"],a=s.getFullYear()+"/"+(Number(s.getMonth())+1)+"/"+s.getDate(),r=w2utils.settings.fulldays.slice(),o=w2utils.settings.shortdays.slice();"M"!==w2utils.settings.weekStarts&&(r.unshift(r.pop()),o.unshift(o.pop()));var d=this.options;null==d&&(d={}),t=w2utils.isInt(t)?parseInt(t):s.getFullYear(),12<(e=w2utils.isInt(e)?parseInt(e):s.getMonth()+1)&&(e-=12,t++),(e<1||0===e)&&(e+=12,t--),t/4==Math.floor(t/4)?l[1]="29":l[1]="28",d.current=e+"/"+t;for(var u=(s=new Date(t,e-1,1)).getDay(),c="",h=0;h<o.length;h++)c+='<td title="'+r[h]+'">'+o[h]+"</td>";var p,f='<div class="w2ui-calendar-title title"> <div class="w2ui-calendar-previous previous"> <div></div> </div> <div class="w2ui-calendar-next next"> <div></div> </div> '+n[e-1]+", "+t+'</div><table class="w2ui-calendar-days" cellspacing="0"><tbody> <tr class="w2ui-day-title">'+c+"</tr> <tr>",g=1;"M"!==w2utils.settings.weekStarts&&u++,"datetime"===this.type&&(p=w2utils.isDateTime(i,d.format,!0),i=w2utils.formatDate(p,w2utils.settings.dateFormat));for(var m=1;m<43;m++){if(0===u&&1==m){for(var w=0;w<6;w++)f+='<td class="w2ui-day-empty"> </td>';m+=6}else if(m<u||g>l[e-1]){f+='<td class="w2ui-day-empty"> </td>',m%7==0&&(f+="</tr><tr>");continue}var v=t+"/"+e+"/"+g,y=new Date(v),b="";6===y.getDay()&&(b=" w2ui-saturday"),0===y.getDay()&&(b=" w2ui-sunday"),v==a&&(b+=" w2ui-today");var x,_,k=g,C="",T="",S="datetime"===this.type?(x=w2utils.formatDateTime(v,d.format),w2utils.formatDate(v,w2utils.settings.dateFormat)):x=w2utils.formatDate(v,d.format);d.colored&&void 0!==d.colored[S]&&(T="background-color: "+(_=d.colored[S].split(":"))[0]+";",C="color: "+_[1]+";"),f+='<td class="'+(this.inRange(x,!0)?"w2ui-date "+(S==i?"w2ui-date-selected":""):"w2ui-blocked")+b+'" style="'+C+T+'" date="'+x+'" data-date="'+y+'">'+k+"</td>",(m%7==0||0===u&&1==m)&&(f+="</tr><tr>"),g++}return f+"</tr></tbody></table>"},getYearHTML:function(){for(var e=w2utils.settings.shortmonths,t=w2utils.settings.dateStartYear,i=w2utils.settings.dateEndYear,s="",n="",l=0;l<e.length;l++)s+='<div class="w2ui-jump-month" name="'+l+'">'+e[l]+"</div>";for(var a=t;a<=i;a++)n+='<div class="w2ui-jump-year" name="'+a+'">'+a+"</div>";return'<div id="w2ui-jump-month">'+s+'</div><div id="w2ui-jump-year">'+n+"</div>"},getHourHTML:function(){var e=[],t=this.options;null==t&&(t={format:w2utils.settings.timeFormat});for(var i=-1<t.format.indexOf("h24"),s=0;s<24;s++){var n=12!=s||i?(12<=s&&!i?s-12:s)+":00"+(i?"":s<12?" am":" pm"):"12:00 pm";e[Math.floor(s/8)]||(e[Math.floor(s/8)]="");var l,a,r=this.fromMin(this.toMin(n)),o=this.fromMin(this.toMin(n)+59);"datetime"===this.type&&(l=w2utils.isDateTime(this.el.value,t.format,!0),a=t.format.split("|")[0].trim(),r=w2utils.formatDate(l,a)+" "+r,o=w2utils.formatDate(l,a)+" "+o),e[Math.floor(s/8)]+='<div class="'+(this.inRange(r)||this.inRange(o)?"w2ui-time ":"w2ui-blocked")+'" hour="'+s+'">'+n+"</div>"}return'<div class="w2ui-calendar"> <div class="w2ui-calendar-title">'+w2utils.lang("Select Hour")+'</div> <div class="w2ui-calendar-time"><table><tbody><tr> <td>'+e[0]+"</td> <td>"+e[1]+"</td> <td>"+e[2]+"</td> </tr></tbody></table></div></div>"},getMinHTML:function(e){null==e&&(e=0);var t=this.options;null==t&&(t={format:w2utils.settings.timeFormat});for(var i=-1<t.format.indexOf("h24"),s=[],n=0;n<60;n+=5){var l,a,r=(12<e&&!i?e-12:e)+":"+(n<10?0:"")+n+" "+(i?"":e<12?"am":"pm"),o=r,d=n<20?0:n<40?1:2;
1s[d]||(s[d]=""),"datetime"===this.type&&(l=w2utils.isDateTime(this.el.value,t.format,!0),a=t.format.split("|")[0].trim(),o=w2utils.formatDate(l,a)+" "+o),s[d]+='<div class="'+(this.inRange(o)?"w2ui-time ":"w2ui-blocked")+'" min="'+n+'">'+r+"</div>"}return'<div class="w2ui-calendar"> <div class="w2ui-calendar-title">'+w2utils.lang("Select Minute")+'</div> <div class="w2ui-calendar-time"><table><tbody><tr> <td>'+s[0]+"</td> <td>"+s[1]+"</td> <td>"+s[2]+"</td> </tr></tbody></table></div></div>"},toMin:function(e){if("string"!=typeof e)return null;var t=e.split(":");return 2!==t.length?null:(t[0]=parseInt(t[0]),t[1]=parseInt(t[1]),-1!==e.indexOf("pm")&&12!==t[0]&&(t[0]+=12),60*t[0]+t[1])},fromMin:function(e){1440<=e&&(e%=1440),e<0&&(e=1440+e);var t=Math.floor(e/60),i=(e%60<10?"0":"")+e%60,s=this.options;return null==s&&(s={format:w2utils.settings.timeFormat}),-1!==s.format.indexOf("h24")?t+":"+i:(t<=12?t:t-12)+":"+i+" "+(12<=t?"pm":"am")}},e.extend(t.prototype,w2utils.event),w2obj.field=t}(jQuery),function(e){function t(t){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=null,this.postData={},this.httpHeaders={},this.method=null,this.toolbar={},this.tabs={},this.style="",this.focus=0,this.autosize=!0,this.nestedFields=!0,this.multipart=!1,this.tabindexBase=0,this.isGenerated=!1,this.last={xhr:null,errors:[]},e.extend(!0,this,w2obj.form,t)}e.fn.w2form=function(i){if(e.isPlainObject(i)){var s=this;if(!w2utils.checkName(i,"w2form"))return;var n=i.record,l=i.original,a=i.fields,r=i.toolbar,o=i.tabs,d=new t(i);if(e.extend(d,{record:{},original:null,fields:[],tabs:{},toolbar:{},handlers:[]}),e.isArray(o)){e.extend(!0,d.tabs,{tabs:[]});for(var u=0;u<o.length;u++){var c=o[u];"object"==typeof c?(d.tabs.tabs.push(c),!0===c.active&&(d.tabs.active=c.id)):d.tabs.tabs.push({id:c,text:c})}}else e.extend(!0,d.tabs,o);if(e.extend(!0,d.toolbar,r),a)for(var h=0;h<a.length;h++){var p=e.extend(!0,{},a[h]);null==p.field&&null!=p.name&&(console.log("NOTICE: form field.name property is deprecated, please use field.field. Field ->",p),p.field=p.name),d.fields[h]=p}for(var h in n)e.isPlainObject(n[h])?d.record[h]=e.extend(!0,{},n[h]):d.record[h]=n[h];for(var h in l)e.isPlainObject(l[h])?d.original[h]=e.extend(!0,{},l[h]):d.original[h]=l[h];return 0<s.length&&(d.box=s[0]),""!==d.formURL?e.get(d.formURL,(function(t){d.formHTML=t,d.isGenerated=!0,0===e(d.box).length&&0===t.length||(e(d.box).html(t),d.render(d.box))})):""!==d.formHTML||(0!==e(this).length&&""!==e.trim(e(this).html())?d.formHTML=e(this).html():d.formHTML=d.generateHTML()),""===(w2ui[d.name]=d).formURL&&(-1===String(d.formHTML).indexOf("w2ui-page")&&(d.formHTML='<div class="w2ui-page page-0" style="'+(d.pageStyle||"")+'">'+d.formHTML+"</div>"),e(d.box).html(d.formHTML),d.isGenerated=!0,d.render(d.box)),d}return(s=w2ui[e(this).attr("name")])?0<arguments.length?(s[i]&&s[i].apply(s,Array.prototype.slice.call(arguments,1)),this):s:null},t.prototype={onRequest:null,onLoad:null,onValidate:null,onSubmit:null,onProgress:null,onSave:null,onChange:null,onInput:null,onRender:null,onRefresh:null,onResize:null,onDestroy:null,onAction:null,onToolbar:null,onError:null,msgNotJSON:"Returned data is not in valid JSON format.",msgAJAXerror:"AJAX error. See console for more details.",msgRefresh:"Loading...",msgSaving:"Saving...",get:function(e,t){if(0===arguments.length){for(var i=[],s=0;s<this.fields.length;s++)null!=this.fields[s].field&&i.push(this.fields[s].field);return i}for(var n=0;n<this.fields.length;n++)if(this.fields[n].field==e)return!0===t?n:this.fields[n];return null},set:function(t,i){for(var s=0;s<this.fields.length;s++)if(this.fields[s].field==t)return e.extend(this.fields[s],i),this.refresh(t),!0;return!1},getValue:function(e){if(this.nestedFields){var t=void 0;try{var i=this.record;t=String(e).split(".").reduce((function(e,t){return e[t]}),i)}catch(e){}return t}return this.record[e]},setValue:function(e,t){if(!this.nestedFields)return this.record[e]=t,!0;try{var i=this.record;return String(e).split(".").map((function(e,s,n){n.length-1!==s?(i[e]||(i[e]={}),i=i[e]):i[e]=t})),!0}catch(e){return!1}},show:function(){for(var e=[],t=0;t<arguments.length;t++){var i=this.get(arguments[t]);i&&i.hidden&&(i.hidden=!1,e.push(i.field))}return 0<e.length&&this.refresh.apply(this,e),this.updateEmptyGroups(),e.length},hide:function(){for(var e=[],t=0;t<arguments.length;t++){var i=this.get(arguments[t]);i&&!i.hidden&&(i.hidden=!0,e.push(i.field))}return 0<e.length&&this.refresh.apply(this,e),this.updateEmptyGroups(),e.length},updateEmptyGroups:function(){e(this.box).find(".w2ui-group").each((function(t,i){var s,n;s=e(i).find(".w2ui-field"),n=!0,s.each((function(e,t){"none"!=t.style.display&&(n=!1)})),n?e(i).hide():e(i).show()}))},enable:function(){for(var e=[],t=0;t<arguments.length;t++){var i=this.get(arguments[t]);i&&i.disabled&&(i.disabled=!1,e.push(i.field))}return 0<e.length&&this.refresh.apply(this,e),e.length},disable:function(){for(var e=[],t=0;t<arguments.length;t++){var i=this.get(arguments[t]);i&&!i.disabled&&(i.disabled=!0,e.push(i.field))}return 0<e.length&&this.refresh.apply(this,e),e.length}
1,change:function(){Array.from(arguments).forEach(function(e){var t=this.get(e);t.$el&&t.$el.change()}.bind(this))},reload:function(e){("object"!=typeof this.url?this.url:this.url.get)&&0!==this.recid&&null!=this.recid?this.request(e):"function"==typeof e&&e()},clear:function(){0!=arguments.length?Array.from(arguments).forEach(function(e){var t=this.record;String(e).split(".").map((function(e,i,s){s.length-1!==i?t=t[e]:delete t[e]})),this.refresh(e)}.bind(this)):(this.recid=0,this.record={},this.original=null,this.refresh()),e().w2tag()},error:function(t){var i=this,s=this.trigger({target:this.name,type:"error",message:t,xhr:this.last.xhr});!0!==s.isCancelled?(setTimeout((function(){i.message(t)}),1),this.trigger(e.extend(s,{phase:"after"}))):"function"==typeof callBack&&callBack()},message:function(t){"string"==typeof t&&(t={width:t.length<300?350:550,height:t.length<300?170:250,body:'<div class="w2ui-centered">'+t+"</div>",buttons:'<button class="w2ui-btn" onclick="w2ui[\''+this.name+"'].message()\">Ok</button>",onOpen:function(t){setTimeout((function(){e(t.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"},t)},validate:function(t){null==t&&(t=!0),e().w2tag();for(var i=[],s=0;s<this.fields.length;s++){var n=this.fields[s];switch(null==this.getValue(n.field)&&this.setValue(n.field,""),n.type){case"int":this.getValue(n.field)&&!w2utils.isInt(this.getValue(n.field))&&i.push({field:n,error:w2utils.lang("Not an integer")});break;case"float":this.getValue(n.field)&&!w2utils.isFloat(this.getValue(n.field))&&i.push({field:n,error:w2utils.lang("Not a float")});break;case"money":this.getValue(n.field)&&!w2utils.isMoney(this.getValue(n.field))&&i.push({field:n,error:w2utils.lang("Not in money format")});break;case"color":case"hex":this.getValue(n.field)&&!w2utils.isHex(this.getValue(n.field))&&i.push({field:n,error:w2utils.lang("Not a hex number")});break;case"email":this.getValue(n.field)&&!w2utils.isEmail(this.getValue(n.field))&&i.push({field:n,error:w2utils.lang("Not a valid email")});break;case"checkbox":1==this.getValue(n.field)?this.setValue(n.field,1):this.setValue(n.field,0);break;case"date":n.options.format||(n.options.format=w2utils.settings.dateFormat),this.getValue(n.field)&&!w2utils.isDate(this.getValue(n.field),n.options.format)&&i.push({field:n,error:w2utils.lang("Not a valid date")+": "+n.options.format})}var l=this.getValue(n.field);n.required&&!0!==n.hidden&&-1==["div","custom","html","empty"].indexOf(n.type)&&(""===l||e.isArray(l)&&0===l.length||e.isPlainObject(l)&&e.isEmptyObject(l))&&i.push({field:n,error:w2utils.lang("Required field")}),n.options&&!0!==n.hidden&&0<n.options.minLength&&-1==["enum","list","combo"].indexOf(n.type)&&this.getValue(n.field).length<n.options.minLength&&i.push({field:n,error:w2utils.lang("Field should be at least "+n.options.minLength+" characters.")})}var a=this.trigger({phase:"before",target:this.name,type:"validate",errors:i});if(!0!==a.isCancelled)return this.last.errors=i,t&&this.showErrors(),this.trigger(e.extend(a,{phase:"after"})),i},showErrors:function(){var t=this.last.errors;if(0<t.length){var i=t[0];this.goto(t[0].field.page),e(i.field.$el).parents(".w2ui-field")[0].scrollIntoView(!0);for(var s=0;s<t.length;s++){i=t[s];var n=e.extend({class:"w2ui-error",hideOnFocus:!0},i.options);null!=i.field&&("radio"===i.field.type?e(e(i.field.el).closest("div")[0]).w2tag(i.error,n):-1!==["enum","file"].indexOf(i.field.type)?function(t){setTimeout((function(){var i=e(t.field.el).data("w2field").helpers.multi;e(t.field.el).w2tag(t.error,t.options),e(i).addClass("w2ui-error")}),1)}(i):e(i.field.el).w2tag(i.error,n))}setTimeout((function(){var i=t[0];e(i.field.$el).parents(".w2ui-page").off(".hideErrors").on("scroll.hideErrors",(function(s){for(var n=0;n<t.length;n++)i=t[n],e(i.field.el).w2tag();e(i.field.$el).parents(".w2ui-page").off(".hideErrors")}))}),300)}},getChanges:function(){var t={};return null==this.original||"object"!=typeof this.original||e.isEmptyObject(this.record)||(t=function t(i,s,n){for(var l in i)null!=i[l]&&"object"==typeof i[l]?(n[l]=t(i[l],s[l]||{},{}),(!n[l]||e.isEmptyObject(n[l])&&e.isEmptyObject(s[l]))&&delete n[l]):(i[l]!=s[l]||null==i[l]&&null!=s[l])&&(n[l]=i[l]);return e.isEmptyObject(n)?null:n}(this.record,this.original,{})),t},getCleanRecord:function(t){var i=e.extend(!0,{},this.record);return this.fields.forEach(function(t){var s,n;-1!=["list","combo","enum"].indexOf(t.type)&&(s={nestedFields:!0,record:i},n=this.getValue.call(s,t.field),e.isPlainObject(n)&&null!=n.id&&this.setValue.call(s,t.field,n.id),Array.isArray(n)&&n.forEac
1h((function(t,i){e.isPlainObject(t)&&t.id&&(n[i]=t.id)}))),"map"==t.type&&(s={nestedFields:!0,record:i},(n=this.getValue.call(s,t.field))._order&&delete n._order)}.bind(this)),!0===t&&Object.keys(i).forEach(function(e){this.get(e)||delete i[e]}.bind(this)),i},request:function(t,i){var s=this;if("function"==typeof t&&(i=t,t=null),null==t&&(t={}),this.url&&("object"!=typeof this.url||this.url.get)){null==this.recid&&(this.recid=0);var n={cmd:"get"};n.recid=this.recid,n.name=this.name,e.extend(n,this.postData),e.extend(n,t);var l=this.trigger({phase:"before",type:"request",target:this.name,url:this.url,postData:n,httpHeaders:this.httpHeaders});if(!0!==l.isCancelled){this.record={},this.original=null,this.lock(w2utils.lang(this.msgRefresh));var a=l.url;if("object"==typeof l.url&&l.url.get&&(a=l.url.get),this.last.xhr)try{this.last.xhr.abort()}catch(t){}if(!e.isEmptyObject(s.routeData)){var r=w2utils.parseRoute(a);if(0<r.keys.length)for(var o=0;o<r.keys.length;o++)null!=s.routeData[r.keys[o].name]&&(a=a.replace(new RegExp(":"+r.keys[o].name,"g"),s.routeData[r.keys[o].name]))}var d={type:"POST",url:a,data:l.postData,headers:l.httpHeaders,dataType:"json"},u=s.dataType||w2utils.settings.dataType;switch(l.dataType&&(u=l.dataType),u){case"HTTP":d.data=String(e.param(d.data,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]");break;case"HTTPJSON":d.data={request:JSON.stringify(d.data)};break;case"RESTFULL":d.type="GET",d.data=String(e.param(d.data,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]");break;case"RESTFULLJSON":d.type="GET",d.data=JSON.stringify(d.data),d.contentType="application/json";break;case"JSON":d.type="POST",d.data=JSON.stringify(d.data),d.contentType="application/json"}this.method&&(d.type=this.method),l.method&&(d.type=l.method),this.last.xhr=e.ajax(d).done((function(t,n,l){s.unlock(),null==(t=l.responseJSON)&&(t={status:"error",message:w2utils.lang(s.msgNotJSON),responseText:l.responseText});var a=s.trigger({phase:"before",target:s.name,type:"load",data:t,xhr:l});!0!==a.isCancelled?("error"===a.data.status?s.error(w2utils.lang(a.data.message)):s.record=e.extend({},a.data.record),s.trigger(e.extend(a,{phase:"after"})),s.refresh(),s.applyFocus(),"function"==typeof i&&i(a.data)):"function"==typeof i&&i({status:"error",message:"Request aborted."})})).fail((function(t,i,n){var l,a={status:i,error:n,rawResponseText:t.responseText},r=s.trigger({phase:"before",type:"error",error:a,xhr:t});if(!0!==r.isCancelled){if("abort"!==i){try{l="object"==typeof t.responseJSON?t.responseJSON:e.parseJSON(t.responseText)}catch(t){}console.log("ERROR: Server communication failed.","\n EXPECTED:",{status:"success",items:[{id:1,text:"item"}]},"\n OR:",{status:"error",message:"error message"},"\n RECEIVED:","object"==typeof l?l:t.responseText),s.unlock()}s.trigger(e.extend(r,{phase:"after"}))}})),this.trigger(e.extend(l,{phase:"after"}))}else"function"==typeof i&&i({status:"error",message:"Request aborted."})}},submit:function(e,t){return this.save(e,t)},save:function(t,i){var s=this;e(this.box).find(":focus").change(),"function"==typeof t&&(i=t,t=null),0===s.validate(!0).length&&(null==t&&(t={}),s.url&&("object"!=typeof s.url||s.url.save)?(s.lock(w2utils.lang(s.msgSaving)+' <span id="'+s.name+'_progress"></span>'),setTimeout((function(){var n={cmd:"save"};n.recid=s.recid,n.name=s.name,e.extend(n,s.postData),e.extend(n,t),s.multipart||s.fields.forEach((function(e){"file"===e.type&&Array.isArray(s.getValue(e.field))&&s.getValue(e.field).forEach((function(e){delete e.file}))})),n.record=e.extend(!0,{},s.record);var l=s.trigger({phase:"before",type:"submit",target:s.name,url:s.url,postData:n,httpHeaders:s.httpHeaders});if(!0!==l.isCancelled){var a=l.url;if("object"==typeof l.url&&l.url.save&&(a=l.url.save),s.last.xhr)try{s.last.xhr.abort()}catch(n){}if(!e.isEmptyObject(s.routeData)){var r=w2utils.parseRoute(a);if(0<r.keys.length)for(var o=0;o<r.keys.length;o++)null!=s.routeData[r.keys[o].name]&&(a=a.replace(new RegExp(":"+r.keys[o].name,"g"),s.routeData[r.keys[o].name]))}var d,u={type:"POST",url:a,data:l.postData,headers:l.httpHeaders,dataType:"json",xhr:function(){var t=new window.XMLHttpRequest;return t.upload.addEventListener("progress",(function(t){if(t.lengthComputable){var i=s.trigger({phase:"before",type:"progress",total:t.total,loaded:t.loaded,originalEvent:t});if(!0===i.isCancelled)return;var n=Math.round(t.loaded/t.total*100);(n&&100!=n||""!=e("#"+s.name+"_progress").text())&&e("#"+s.name+"_progress").text(n+"%"),s.trigger(e.extend(i,{phase:"after"}))}}),!1),t}},c=s.dataType||w2utils.settings.dataType;switch(l.dataType&&(c=l.dataType),c){case"HTTP":u.data=String(e.param(u.data,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]");break;case"HTTPJSON":u.data={request:JSON.stringify(u.data)};break;case"RESTFULL":0!==s.recid&&null!=s.recid&&(u.type="PUT"),u.data=String(e.param(u.data,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]");break;case"RESTFULLJSON":0!==s.recid&&null!=s.recid&&(u.type="PUT"),u.data=JSON.stringify(u.data),u.contentType="application/json";break;case"JSON":u.type="POST",u.contentType="application/json",s.multipart?((d=new FormData).append("__body",JSON.stringify(u.data)),function e(t,i,s,n){for(var l in null==n&&(n=""),i){var a=""==n?l:"${p}[${prop}]",r=s?s[l]:s;!function i(s,n,l){if("object"==typeof s&&s instanceof File&&t.append(l,s),"object"==typeof s)if(s&&s.constructor===Array)for(var a=0;a<s.length;a++){var r=n?n[a]:n;i(s[a],r,l+"["+a+"]")}else e(t,s,n,l)}(i[l],r,a)}}(d,u.data),u.data=d,u.contentType=!1,u.processData=!1):u.data=JSON.stringify(u.data)}this.method&&(u.type=this.method),l.method&&(u.type=l.method),s.last.xhr=e.ajax(u).done((function(t,n,l){s.unlock();var a=s.trigger({phase:"before",target:s.name,type:"save",xhr:l,status:n,data:t});!0!==a.isCancelled&&(null==(t=l.responseJSON)&&(t={status:"error",message:w2utils.lang(s.msgNotJSON),responseText:l.responseText}),"error"===t.status?s.error(w2utils.lang(t.message)):s.original=null,s.trigger(e.extend(a,{phase:"after"})),s.refresh(),"function"==typeof i&&i(t,l))})).fail((function(t,i,n){var l={status:i,error:n,rawResponseText:t.responseText},a=s.trigger({phase:"before",type:"error",error:l,xhr:t});!0!==a.isCancelled&&(console.log("ERROR: server communication failed. The server should return",{status:"success"},"OR",{status:"error",message:"error message"},", instead the AJAX request produced this: ",l),s.unlock(),s.trigger(e.extend(a,{phase:"after"})))})),s.trigger(e.extend(l,{phase:"after"}))}}),50)):console.log("ERROR: Form cannot be saved because no url is defined."))},lock:function(e,t){var i=Array.prototype.slice.call(arguments,0);i.unshift(this.box),setTimeout((function(){w2utils.lock.apply(window,i)}),10)},unlock:function(e){var t=this.box;setTimeout((function(){w2utils.unlock(t,e)}),25)},lockPage:function(t,i){var s=e(this.box).find(".page-"+t);return!!s.length&&(w2utils.lock(s,i),!0)},unlockPage:function(t,i){var s=e(this.box).find(".page-"+t);return!!s.length&&(w2utils.unlock(s,i),!0)},goto:function(t){this.page!==t&&(null!=t&&(this.page=t),!0===e(this.box).data("auto-size")&&e(this.box).height(0),this.refresh())},generateHTML:function(){for(var t,i,s,n,l,a=[],r="",o=0;o<this.fields.length;o++){s="",l=' tabindex="'+(n=this.tabindexBase+o+1)+'"';var d=this.fields[o];null==d.html&&(d.html={}),null==d.options&&(d.options={}),null!=d.html.caption&&null==d.html.label&&(console.log("NOTICE: form field.html.caption property is deprecated, please use field.html.label. Field ->",d),d.html.label=d.html.caption),null==d.html.label&&(d.html.label=d.field),d.html=e.extend(!0,{label:"",span:6,attr:"",text:"",style:"",page:0,column:0},d.html),null==t&&(t=d.html.page),null==i&&(i=d.html.column);var u,c,h,p='<input id="'+d.field+'" name="'+d.field+'" class="w2ui-input" type="text" '+d.html.attr+l+">";switch(d.type){case"pass":case"password":p='<input id="'+d.field+'" name="'+d.field+'" class="w2ui-input" type = "password" '+d.html.attr+l+">";break;case"check":case"checks":null==d.options.items&&null!=d.html.items&&(d.options.items=d.html.items);var f=d.options.items;p="",e.isArray(f)||(f=[]),0<f.length&&(f=w2obj.field.prototype.normMenu.call(this,f,d));for(var g=0;g<f.length;g++)p+='<label class="w2ui-box-label"> <input id="'+d.field+g+'" name="'+d.field+'" class="w2ui-input" type="checkbox" '+d.html.attr+(0===g?l:"")+' data-value="'+f[g].id+'" data-index="'+g+'"><span> '+f[g].text+"</span></label><br>";break;case"checkbox":p='<label class="w2ui-box-label"> <input id="'+d.field+'" name="'+d.field+'" class="w2ui-input" type="checkbox" '+d.html.attr+l+"> <span>"+d.html.label+"</span></label>";break;case"radio":for(p="",null==d.options.items&&null!=d.html.items&&(d.options.items=d.html.items),f=d.options.items,e.isArray(f)||(f=[]),0<f.length&&(f=w2obj.field.prototype.normMenu.call(this,f,d)),g=0;g<f.length;g++)p+='<label class="w2ui-box-label"> <input id="'+d.field+g+'" name="'+d.field+'" class="w2ui-input" type = "radio" '+d.html.attr+(0===g?l:"")+' value="'+f[g].id+'"><span> '+f[g].text+"</span></label><br>";break;case"select":for(p='<select id="'+d.field+'" name="'+d.field+'" class="w2ui-input" '+d.html.attr+l+">",null==d.options.items&&null!=d.html.items&&(d.options.items=d.html.items),f=d.options.items,e.isArray(f)||(f=[]),0<f.length&&(f=w2obj.field.prototype.normMenu.call(this,f,d)),g=0;g<f.length;g++)p+='<option value="'+f[g].id+'">'+f[g].text+"</option>";p+="</select>";break;case"textarea":p='<textarea id="'+d.field+'" name="'+d.field+'" class="w2ui-input" '+d.html.attr+l+"></textarea>";break;case"toggle":p='<input id="'+d.field+'" name="'+d.field+'" type="checkbox" '+d.html.attr+l+' class="w2ui-input w2ui-toggle"><div><div></div></div>';break;case"map":case"array":d.html.key=d.html.key||{},d.html.value=d.html.value||{},d.html.tabindex_str=l,p='<span style="float: right">'+(d.html.text||"")+'</span><input id="'+d.field+'" name="'+d.field+'" type="hidden" '+d.html.attr+l+'><div class="w2ui-map-container"></div>';break;
1case"html":case"div":case"custom":p='<div id="'+d.field+'" name="'+d.field+'" '+d.html.attr+l+">"+(d&&d.html&&d.html.html?d.html.html:"")+"</div>";break;case"empty":p=d&&d.html?(d.html.html||"")+(d.html.text||""):""}""!==r&&(t!=d.html.page||i!=d.html.column||d.html.group&&r!=d.html.group)&&(a[t][i]+="\n </div>\n </div>",r=""),d.html.group&&r!=d.html.group&&(u="",d.html.groupCollapsable&&(u='<span class="w2ui-icon-collapse" style="width: 15px; display: inline-block; position: relative; top: -2px;"></span>'),s+='\n <div class="w2ui-group">\n <div class="w2ui-group-title" style="'+(d.html.groupTitleStyle||"")+(""!=u?"cursor: pointer; user-select: none":"")+'"'+(""!=u?'data-group="'+w2utils.base64encode(d.html.group)+'"':"")+(""!=u?"onclick=\"w2ui['"+this.name+"'].toggleGroup('"+d.html.group+"')\"":"")+">"+u+d.html.group+'</div>\n <div class="w2ui-group-fields" style="'+(d.html.groupStyle||"")+'">',r=d.html.group),null==d.html.anchor?(c=null!=d.html.span?"w2ui-span"+d.html.span:"",-1==d.html.span&&(c="w2ui-span-none"),h="<label"+("none"==c?' style="display: none"':"")+">"+w2utils.lang("checkbox"!=d.type?d.html.label:d.html.text)+"</label>",d.html.label||(h=""),s+='\n <div class="w2ui-field '+c+'" style="'+(d.hidden?"display: none;":"")+d.html.style+'">\n '+h+("empty"===d.type?p:"\n <div>"+p+("array"!=d.type&&"map"!=d.type?w2utils.lang("checkbox"!=d.type?d.html.text:""):"")+"</div>")+"\n </div>"):(a[d.html.page].anchors=a[d.html.page].anchors||{},a[d.html.page].anchors[d.html.anchor]='<div class="w2ui-field w2ui-field-inline" style="'+(d.hidden?"display: none;":"")+d.html.style+'">'+("empty"===d.type?p:"<div>"+w2utils.lang("checkbox"!=d.type?d.html.label:d.html.text)+p+w2utils.lang("checkbox"!=d.type?d.html.text:"")+"</div>")+"</div>"),null==a[d.html.page]&&(a[d.html.page]={}),null==a[d.html.page][d.html.column]&&(a[d.html.page][d.html.column]=""),a[d.html.page][d.html.column]+=s,t=d.html.page,i=d.html.column}if(""!==r&&(a[t][i]+="\n </div>\n </div>"),this.tabs.tabs)for(g=0;g<this.tabs.tabs.length;g++)null==a[g]&&(a[g]=[]);var m="";if(!e.isEmptyObject(this.actions)){for(var w in m+='\n<div class="w2ui-buttons">',n=this.tabindexBase+this.fields.length+1,this.actions){var v=this.actions[w],y={text:"",style:"",class:""};e.isPlainObject(v)?(null==v.text&&null!=v.caption&&(console.log("NOTICE: form action.caption property is deprecated, please use action.text. Action ->",v),v.text=v.caption),v.text&&(y.text=v.text),v.style&&(y.style=v.style),v.class&&(y.class=v.class)):(y.text=w,-1!==["save","update","create"].indexOf(w.toLowerCase())?y.class="w2ui-btn-blue":y.class=""),m+='\n <button name="'+w+'" class="w2ui-btn '+y.class+'" style="'+y.style+'" tabindex="'+n+'">'+w2utils.lang(y.text)+"</button>",n++}m+="\n</div>"}s="";for(var b=0;b<a.length;b++)s+='<div class="w2ui-page page-'+b+'" style="'+(0!==b?"display: none;":"")+this.pageStyle+'">',a[b].before&&(s+=a[b].before),s+='<div class="w2ui-column-container">',Object.keys(a[b]).sort().forEach((function(e,t){e==parseInt(e)&&(s+='<div class="w2ui-column col-'+e+'">'+(a[b][e]||"")+"\n</div>")})),s+="\n</div>",a[b].after&&(s+=a[b].after),s+="\n</div>",a[b].anchors&&Object.keys(a[b].anchors).forEach((function(e,t){s=s.replace(e,a[b].anchors[e])}));return s+=m},toggleGroup:function(t,i){var s,n=e(this.box).find('.w2ui-group-title[data-group="'+w2utils.base64encode(t)+'"]');"none"==n.next().css("display")&&!0!==i?(n.next().slideDown(300),n.next().next().remove(),n.find("span").addClass("w2ui-icon-collapse").removeClass("w2ui-icon-expand")):(n.next().slideUp(300),s="width: "+n.next().css("width")+";padding-left: "+n.next().css("padding-left")+";padding-right: "+n.next().css("padding-right")+";margin-left: "+n.next().css("margin-left")+";margin-right: "+n.next().css("margin-right")+";",setTimeout((function(){n.next().after('<div style="height: 5px;'+s+'"></div>')}),100),n.find("span").addClass("w2ui-icon-expand").removeClass("w2ui-icon-collapse"))},action:function(t,i){var s=this.actions[t],n=s;e.isPlainObject(s)&&s.onClick&&(n=s.onClick);var l=this.trigger({phase:"before",target:t,type:"action",action:s,originalEvent:i});!0!==l.isCancelled&&("function"==typeof n&&n.call(this,i),this.trigger(e.extend(l,{phase:"after"})))},resize:function(){var t,i,s,n,l,a,r,o,d=this,u=this.trigger({phase:"before",target:this.name,type:"resize"});function c(){t.width(e(d.box).width()).height(e(d.box).height()),s.css("top",""!==d.header?w2utils.getSize(i,"height"):0),n.css("top",(""!==d.header?w2utils.getSize(i,"height"):0)+("object"==typeof d.toolbar&&e.
1isArray(d.toolbar.items)&&0<d.toolbar.items.length?w2utils.getSize(s,"height"):0)),l.css("top",(""!==d.header?w2utils.getSize(i,"height"):0)+("object"==typeof d.toolbar&&e.isArray(d.toolbar.items)&&0<d.toolbar.items.length?w2utils.getSize(s,"height")+5:0)+("object"==typeof d.tabs&&e.isArray(d.tabs.tabs)&&0<d.tabs.tabs.length?w2utils.getSize(n,"height")+5:0)),l.css("bottom",0<o.length?w2utils.getSize(o,"height"):0)}!0!==u.isCancelled&&(t=e(this.box).find("> div.w2ui-form-box"),i=e(this.box).find("> div .w2ui-form-header"),s=e(this.box).find("> div .w2ui-form-toolbar"),n=e(this.box).find("> div .w2ui-form-tabs"),l=e(this.box).find("> div .w2ui-page"),a=e(this.box).find("> div .w2ui-page.page-"+this.page),r=e(this.box).find("> div .w2ui-page.page-"+this.page+" > div"),o=e(this.box).find("> div .w2ui-buttons"),c(),this.autosize&&(0!==parseInt(e(this.box).height())&&!0!==e(this.box).data("auto-size")||(e(this.box).height((0<i.length?w2utils.getSize(i,"height"):0)+("object"==typeof this.tabs&&e.isArray(this.tabs.tabs)&&0<this.tabs.tabs.length?w2utils.getSize(n,"height"):0)+("object"==typeof this.toolbar&&e.isArray(this.toolbar.items)&&0<this.toolbar.items.length?w2utils.getSize(s,"height"):0)+(0<l.length?w2utils.getSize(r,"height")+w2utils.getSize(a,"+height")+12:0)+(0<o.length?w2utils.getSize(o,"height"):0)),e(this.box).data("auto-size",!0)),c()),this.toolbar&&this.toolbar.resize&&this.toolbar.resize(),this.tabs&&this.tabs.resize&&this.tabs.resize(),d.trigger(e.extend(u,{phase:"after"})))},refresh:function(){var t=(new Date).getTime(),i=this;if(this.box&&this.isGenerated&&null!=e(this.box).html()){var s=this.trigger({phase:"before",target:this.name,type:"refresh",page:this.page,field:r,fields:arguments});if(!0!==s.isCancelled){var n=Array.from(this.fields.keys());0<arguments.length?n=Array.from(arguments).map(function(e,t){return"string"!=typeof e&&console.log("ERROR: Arguments in refresh functions should be field names"),this.get(e,!0)}.bind(this)).filter((function(e,t){return null!=e})):(e(this.box).find("input, textarea, select").each((function(t,s){var n=null!=e(s).attr("name")?e(s).attr("name"):e(s).attr("id"),l=i.get(n);if(l){var a=e(s).closest(".w2ui-page");if(0<a.length)for(var r=0;r<100;r++)if(a.hasClass("page-"+r)){l.page=r;break}}})),e(this.box).find(".w2ui-page").hide(),e(this.box).find(".w2ui-page.page-"+this.page).show(),e(this.box).find(".w2ui-form-header").html(this.header),"object"==typeof this.tabs&&e.isArray(this.tabs.tabs)&&0<this.tabs.tabs.length?(e("#form_"+this.name+"_tabs").show(),this.tabs.active=this.tabs.tabs[this.page].id,this.tabs.refresh()):e("#form_"+this.name+"_tabs").hide(),"object"==typeof this.toolbar&&e.isArray(this.toolbar.items)&&0<this.toolbar.items.length?(e("#form_"+this.name+"_toolbar").show(),this.toolbar.refresh()):e("#form_"+this.name+"_toolbar").hide());for(var l,a=0;a<n.length;a++)null==(r=this.fields[n[a]]).name&&null!=r.field&&(r.name=r.field),null==r.field&&null!=r.name&&(r.field=r.name),r.$el=e(this.box).find('[name="'+String(r.name).replace(/\\/g,"\\\\")+'"]'),r.el=r.$el[0],r.el&&(r.el.id=r.name),(w=e(r).data("w2field"))&&w.clear(),e(r.$el).off(".w2form").on("change.w2form",(function(t){var s=this,n=i.get(this.name);if(null!=n)if(1!=e(this).data("skip_change")){var l,a,r,o,d=this.value,u=i.getValue(this.name);if(null==u&&(u=""),-1!==["list","enum","file"].indexOf(n.type)&&e(this).data("selected")){var c=e(this).data("selected"),h=i.getValue(this.name);if(e.isArray(c)){d=[];for(var p=0;p<c.length;p++)d[p]=e.extend(!0,{},c[p])}if(e.isPlainObject(c)&&(d=e.extend(!0,{},c)),e.isArray(h))for(u=[],p=0;p<h.length;p++)u[p]=e.extend(!0,{},h[p]);e.isPlainObject(h)&&(u=e.extend(!0,{},h))}-1!==["toggle","checkbox"].indexOf(n.type)&&(d=!!e(this).prop("checked")&&("on"===e(this).prop("value")||e(this).prop("value"))),-1!==["check","checks"].indexOf(n.type)&&(Array.isArray(u)||(u=[]),d=u.slice(),l=n.options.items[e(this).attr("data-index")],e(this).prop("checked")?d.push(l.id):d.splice(d.indexOf(l.id),1)),-1!==["int","float","percent","money","currency"].indexOf(n.type)&&(d=e(this).data("w2field").clean(d)),d!==u&&(!0===(a=i.trigger({phase:"before",target:this.name,type:"change",value_new:d,value_previous:u,originalEvent:t})).isCancelled&&(a.value_new=i.getValue(this.name),e(this).val()!==a.value_new&&(e(this).data("skip_change",!0),setTimeout((function(){e(s).data("skip_change",!1)}),10)),e(this).val(a.value_new)),r=a.value_new,-1!==["enum","file"].indexOf(n.type)&&0<r.length&&(o=e(n.el).data("w2field").helpers.multi,e(o).removeClass("w2ui-error")),(""===r||null==r||e.isArray(r)&&0===r.length||e.isPlainObject(r)&&e.isEmptyObject(r))&&(r=null),i.setValue(this.name,r),i.trigger(e.extend(a,{phase:"after"})))}else e(this).data("skip_change",!1)})).on("input.w2form",(function(t){var s=this.value;"checkbox"==t.target.type&&(s=t.target.checked),null==i.original&&(e.isEmptyObject(i.record)?i.original={}:i.original=e.extend(!0,{},i.record));var n=i.trigger({phase:"before",target:this.name,type:"input",value_new:s,originalEvent:t});!0!==n.isCancelled&&i.trigger(e.extend(n,{phase:"after"}))})),r.required?e(r.el).parent().parent().addClass("w2ui-required"):e(r.el).parent().parent().removeClass("w2ui-required"),null!=r.disabled&&(l=e(r.el),r.disabled?(null==l.data("w2ui-tabIndex")&&l.data("w2ui-tabIndex",l.prop("tabIndex")),e(r.el).prop("readonly",!0).prop("tabindex",-1).closest(".w2ui-field").addClass("w2ui-disabled")):e(r.el).prop("readonly",!1).prop("tabIndex",l.data("w2ui-tabIndex")).closest(".w2ui-field").removeClass("w2ui-disabled")),w=(w=r.el)||e(this.box).find("#"+r.field),r.hidden?e(w).closest(".w2ui-field").hide():e(w).closest(".w2ui-field").show();for(e(this.box).find("button, input[type=button]").each((function(t,s){e(s).off("click").on("click",(function(e){var t=this.value;
1this.id&&(t=this.id),this.name&&(t=this.name),i.action(t,e)}))})),a=0;a<n.length;a++){var r=this.fields[n[a]],o=null!=this.getValue(r.name)?this.getValue(r.name):"";if(r.el)switch(e(r.el).hasClass("w2ui-input")||e(r.el).addClass("w2ui-input"),r.type=String(r.type).toLowerCase(),r.options||(r.options={}),r.type){case"text":case"textarea":case"email":case"pass":case"password":r.el.value=o;break;case"int":case"float":case"money":case"currency":case"percent":case"hex":case"alphanumeric":case"color":case"date":case"time":r.el.value=o,e(r.el).w2field(e.extend({},r.options,{type:r.type}));break;case"toggle":w2utils.isFloat(o)&&(o=parseFloat(o)),e(r.el).prop("checked",!!o),this.setValue(r.name,o||!1);break;case"radio":e(r.$el).prop("checked",!1).each((function(t,i){e(i).val()==o&&e(i).prop("checked",!0)}));break;case"checkbox":e(r.el).prop("checked",!!o),!0!==r.disabled&&!1!==r.disabled||e(r.el).prop("disabled",!!r.disabled);break;case"check":case"checks":Array.isArray(o)&&o.forEach((function(t){e(r.el).closest("div").find('[data-value="'+t+'"]').prop("checked",!0)})),r.disabled?e(r.el).closest("div").find("input[type=checkbox]").prop("disabled",!0):e(r.el).closest("div").find("input[type=checkbox]").removeProp("disabled");break;case"list":case"combo":if("list"===r.type){var d,u=e.isPlainObject(o)?o.id:e.isPlainObject(r.options.selected)?r.options.selected.id:o;r.options.items||(r.options.items=[]),"function"==typeof(d=r.options.items)&&(d=d());var c=!1;if(Array.isArray(d))for(var h=0;h<d.length;h++){var p=d[h];if(p.id==u){o=e.extend(!0,{},p),i.setValue(r.name,o),c=!0;break}}c||null==o||""===o||r.$el.data("find_selected",o)}else"combo"!==r.type||e.isPlainObject(o)?e.isPlainObject(o)&&null!=o.text?r.el.value=o.text:r.el.value="":r.el.value=o;e.isPlainObject(o)||(o={}),e(r.el).w2field(e.extend({},r.options,{type:r.type,selected:o}));break;case"enum":case"file":var f=[];c=!1,e.isArray(o)||(o=[]),"function"!=typeof r.options.items&&(e.isArray(r.options.items)||(r.options.items=[]),o.forEach((function(t){r.options.items.forEach((function(i){i&&(i.id==t||e.isPlainObject(t)&&i.id==t.id)&&(f.push(e.isPlainObject(i)?e.extend(!0,{},i):i),c=!0)}))}))),c||null==o||0===o.length||(r.$el.data("find_selected",o),f=o);var g=e.extend({},r.options,{type:r.type,selected:f});Object.keys(r.options).forEach((function(e){"function"==typeof r.options[e]&&(g[e]=r.options[e])})),e(r.el).w2field(g);break;case"select":if(null!=(d=r.options.items)&&0<d.length){d=w2obj.field.prototype.normMenu.call(this,d,r),e(r.el).html("");for(var m=0;m<d.length;m++)e(r.el).append('<option value="'+d[m].id+'">'+d[m].text+"</option")}e(r.el).val(o);break;case"map":case"array":"map"!=r.type||null!=o&&e.isPlainObject(o)||(this.setValue(r.field,{}),o=this.getValue(r.field)),"array"!=r.type||null!=o&&Array.isArray(o)||(this.setValue(r.field,[]),o=this.getValue(r.field)),function(t,i){i.el.mapAdd=function(e,t,i){var s=(e.disabled?" readOnly ":"")+(e.html.tabindex_str||""),n='<div class="w2ui-map-field" style="margin-bottom: 5px"><input id="'+e.field+"_key_"+i+'" data-cnt="'+i+'" type="text" '+e.html.key.attr+s+' class="w2ui-input w2ui-map key">'+(e.html.key.text||"")+'<input id="'+e.field+"_value_"+i+'" data-cnt="'+i+'" type="text" '+e.html.value.attr+s+' class="w2ui-input w2ui-map value">'+(e.html.value.text||"")+"</div>";t.append(n)},i.el.mapRefresh=function(s,n){var l,a,r,o=1;"map"==i.type&&(e.isPlainObject(s)||(s={}),null==s._order&&(s._order=Object.keys(s)),l=s._order),"array"==i.type&&(Array.isArray(s)||(s=[]),l=s.map((function(e){return e.key}))),l.forEach((function(e){a=n.find("#"+w2utils.escapeId(i.name)+"_key_"+o),r=n.find("#"+w2utils.escapeId(i.name)+"_value_"+o),0!=a.length&&0!=r.length||(i.el.mapAdd(i,n,o),a=n.find("#"+w2utils.escapeId(i.name)+"_key_"+o),r=n.find("#"+w2utils.escapeId(i.name)+"_value_"+o));var t,l=s[e];"array"!=i.type||0<(t=s.filter((function(t){return t.key==e}))).length&&(l=t[0].value),a.val(e),r.val(l),!0!==i.disabled&&!1!==i.disabled||(a.prop("readOnly",!!i.disabled),r.prop("readOnly",!!i.disabled)),a.parents(".w2ui-map-field").attr("data-key",e),o++}));var d=n.find("#"+w2utils.escapeId(i.name)+"_key_"+o).parent(),u=n.find("#"+w2utils.escapeId(i.name)+"_key_"+(o+1)).parent();0!==d.length||a&&(!0===a.prop("readOnly")||!0===a.prop("disabled"))||i.el.mapAdd(i,n,o),1==d.length&&1==u.length&&(d.removeAttr("data-key"),d.find(".key").val(u.find(".key").val()),d.find(".value").val(u.find(".value").val()),u.remove()),!0!==i.disabled&&!1!==i.disabled||(d.find(".key").prop("readOnly",!!i.disabled),d.find(".value").prop("readOnly",!!i.disabled)),e(i.el).next().find("input.w2ui-map").off(".mapChange").on("keyup.mapChange",(function(t){var i=e(t.target).parents(".w2ui-map-field");
113==t.keyCode&&i.next().find("input.key").focus()})).on("change.mapChange",(function(){var l=e(event.target).parents(".w2ui-map-field"),a=l.attr("data-key"),r=l.find(".key").val(),o=l.find(".value").val(),d={},u={},c=null,h=null;d[r]=o,"array"==i.type&&(s.forEach((function(e,t){e.key==a&&(h=t)})),c=s[h]),null!=a&&"map"==i.type&&(u[a]=s[a]),null!=a&&"array"==i.type&&(u[a]=c.value);var p=t.trigger({phase:"before",target:i.field,type:"change",originalEvent:event,value_new:d,value_previous:u});if(!0!==p.isCancelled){if("map"==i.type){delete s[a];var f=s._order.indexOf(a);if(""!=r){if(null!=s[r]){for(var g,m=0;g=r+ ++m,null!=s[g];);r=g,l.find(".key").val(g)}s[r]=o,l.attr("data-key",r),-1!=f?s._order[f]=r:s._order.push(r)}else s._order.splice(f,1),l.find(".value").val("")}else"array"==i.type&&(""!=r?null==c?s.push({key:r,value:o}):(c.key=r,c.value=o):s.splice(h,1));t.setValue(i.field,s),i.el.mapRefresh(s,n),t.trigger(e.extend(p,{phase:"after"}))}}))},i.el.mapRefresh(o,e(i.el).parent().find(".w2ui-map-container"))}(this,r);break;case"div":case"custom":e(r.el).html(o);break;case"html":case"empty":break;default:e(r.el).val(o),e(r.el).w2field(e.extend({},r.options,{type:r.type}))}}var w=e(this.box).find(".w2ui-page");for(h=0;h<w.length;h++)1<e(w[h]).find("> *").length&&e(w[h]).wrapInner("<div></div>");return this.trigger(e.extend(s,{phase:"after"})),this.resize(),(new Date).getTime()-t}}},render:function(t){var i=(new Date).getTime(),s=this;if("object"==typeof t&&(0<e(this.box).find("#form_"+this.name+"_tabs").length&&e(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),this.box=t),this.isGenerated&&this.box){var n=this.trigger({phase:"before",target:this.name,type:"render",box:null!=t?t:this.box});if(!0!==n.isCancelled){var l='<div class="w2ui-form-box">'+(""!==this.header?'<div class="w2ui-form-header">'+this.header+"</div>":"")+' <div id="form_'+this.name+'_toolbar" class="w2ui-form-toolbar" style="display: none"></div> <div id="form_'+this.name+'_tabs" class="w2ui-form-tabs" style="display: none"></div>'+this.formHTML+"</div>";return e(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-form").html(l),0<e(this.box).length&&(e(this.box)[0].style.cssText+=this.style),"function"!=typeof this.toolbar.render&&(this.toolbar=e().w2toolbar(e.extend({},this.toolbar,{name:this.name+"_toolbar",owner:this})),this.toolbar.on("click",(function(t){var i=s.trigger({phase:"before",type:"toolbar",target:t.target,originalEvent:t});!0!==i.isCancelled&&s.trigger(e.extend(i,{phase:"after"}))}))),"object"==typeof this.toolbar&&"function"==typeof this.toolbar.render&&this.toolbar.render(e("#form_"+this.name+"_toolbar")[0]),"function"!=typeof this.tabs.render&&(this.tabs=e().w2tabs(e.extend({},this.tabs,{name:this.name+"_tabs",owner:this,active:this.tabs.active})),this.tabs.on("click",(function(e){s.goto(this.get(e.target,!0))}))),"object"==typeof this.tabs&&"function"==typeof this.tabs.render&&(this.tabs.render(e("#form_"+this.name+"_tabs")[0]),this.tabs.active&&this.tabs.click(this.tabs.active)),this.trigger(e.extend(n,{phase:"after"})),this.resize(),("object"!=typeof this.url?this.url:this.url.get)&&0!==this.recid&&null!=this.recid?this.request():this.refresh(),0===e(".w2ui-layout").length&&(this.tmp_resize=function(t){null==w2ui[s.name]?e(window).off("resize.w2uiResize",s.tmp_resize):w2ui[s.name].resize()},e(window).off("resize.w2uiResize").on("resize.w2uiResize",s.tmp_resize)),-1!=this.focus&&setTimeout((function(){0===e(s.box).find("input, select, textarea").length?setTimeout(focusEl,500):s.applyFocus()}),50),(new Date).getTime()-i}}},applyFocus:function(){for(var t=this.focus,i=e(this.box).find("div:not(.w2ui-field-helper) > input, select, textarea, div > label:nth-child(1) > :radio").not(".file-input");e(i[t]).is(":hidden")&&i.length>=t;)t++;i[t]&&i[t].focus()},destroy:function(){var t=this.trigger({phase:"before",target:this.name,type:"destroy"});!0!==t.isCancelled&&("object"==typeof this.toolbar&&this.toolbar.destroy&&this.toolbar.destroy(),"object"==typeof this.tabs&&this.tabs.destroy&&this.tabs.destroy(),0<e(this.box).find("#form_"+this.name+"_tabs").length&&e(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),delete w2ui[this.name],this.trigger(e.extend(t,{phase:"after"})),e(window).off("resize","body"))}},e.extend(t.prototype,w2utils.event),w2obj.form=t}(jQuery),t={w2ui,w2obj,w2utils,w2popup,w2alert,w2confirm,w2prompt},void 0===(__WEBPACK_AMD_DEFINE_RESULT__=function(){return t}.call(exports,__webpack_require__,exports,module))||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.