-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw2ui-1.3.min.js
9 lines (9 loc) · 244 KB
/
w2ui-1.3.min.js
1
2
3
4
5
6
7
8
9
/* w2ui 1.3 (c) http://w2ui.com, [email protected] */
var w2ui=w2ui||{},w2obj=w2obj||{},w2utils=function(){function n(e){var t=/^[-]?[0-9]+$/;return t.test(e)}function r(e){var t=new RegExp(w2utils.settings["float"]);return t.test(e)}function i(e){var t=new RegExp(w2utils.settings.currency);return t.test(e)}function s(e){var t=/^[a-fA-F0-9]+$/;return t.test(e)}function o(e){var t=/^[a-zA-Z0-9_-]+$/;return t.test(e)}function u(e){var t=/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;return t.test(e)}function a(e,t,n){if(!e)return!1;t||(t=w2utils.settings.date_format);var r=e.replace(/-/g,"/").replace(/\./g,"/").toLowerCase().split("/"),i=t.replace(/-/g,"/").replace(/\./g,"/").toLowerCase(),s="Invalid Date",o,u,a;return i=="mm/dd/yyyy"&&(o=r[0],u=r[1],a=r[2]),i=="m/d/yyyy"&&(o=r[0],u=r[1],a=r[2]),i=="dd/mm/yyyy"&&(o=r[1],u=r[0],a=r[2]),i=="d/m/yyyy"&&(o=r[1],u=r[0],a=r[2]),i=="yyyy/dd/mm"&&(o=r[2],u=r[1],a=r[0]),i=="yyyy/d/m"&&(o=r[2],u=r[1],a=r[0]),i=="yyyy/mm/dd"&&(o=r[1],u=r[2],a=r[0]),i=="yyyy/m/d"&&(o=r[1],u=r[2],a=r[0]),s=new Date(o+"/"+u+"/"+a),typeof o=="undefined"?!1:s=="Invalid Date"?!1:s.getMonth()+1!=o||s.getDate()!=u||s.getFullYear()!=a?!1:n===!0?s:!0}function f(e){if(String(e)=="undefined")return!1;var t;e=e.toUpperCase(),e.indexOf("PM")>=0||e.indexOf("AM")>=0?t=12:t=23,e=$.trim(e.replace("AM","")),e=$.trim(e.replace("PM",""));var n=e.split(":");return n.length!=2?!1:n[0]==""||parseInt(n[0])<0||parseInt(n[0])>t||!this.isInt(n[0])?!1:n[1]==""||parseInt(n[1])<0||parseInt(n[1])>59||!this.isInt(n[1])?!1:!0}function l(e){if(e==""||typeof e=="undefined"||e==null)return"";w2utils.isInt(e)&&(e=Number(e));var t=new Date(e);w2utils.isInt(e)&&(t=new Date(Number(e)));var n=String(e).split("-");n.length==3&&(t=new Date(n[0],Number(n[1])-1,n[2]));var n=String(e).split("/");n.length==3&&(t=new Date(n[2],Number(n[0])-1,n[1]));if(t=="Invalid Time")return"";var r=new Date,i=(r.getTime()-t.getTime())/1e3,s="",o="";return i<60?(s=Math.floor(i),o="sec",i<0&&(s=0,o="sec")):i<3600?(s=Math.floor(i/60),o="min"):i<86400?(s=Math.floor(i/60/60),o="hour"):i<2592e3?(s=Math.floor(i/24/60/60),o="day"):i<31104e3?(s=Math.floor(i/30/24/60/60*10)/10,o="month"):i>=31104e3&&(s=Math.floor(i/12/30/24/60/60*10)/10,o="year"),s+" "+o+(s>1?"s":"")}function c(e){var t=w2utils.settings.shortmonths;if(e==""||typeof e=="undefined"||e==null)return"";w2utils.isInt(e)&&(e=Number(e));var n=new Date(e);w2utils.isInt(e)&&(n=new Date(Number(e)));var r=String(e).split("-");r.length==3&&(n=new Date(r[0],Number(r[1])-1,r[2]));var r=String(e).split("/");r.length==3&&(n=new Date(r[2],Number(r[0])-1,r[1]));if(n=="Invalid Date")return"";var i=new Date,s=new Date;s.setTime(s.getTime()-864e5);var o=t[n.getMonth()]+" "+n.getDate()+", "+n.getFullYear(),u=t[i.getMonth()]+" "+i.getDate()+", "+i.getFullYear(),a=t[s.getMonth()]+" "+s.getDate()+", "+s.getFullYear(),f=n.getHours()-(n.getHours()>12?12:0)+":"+(n.getMinutes()<10?"0":"")+n.getMinutes()+" "+(n.getHours()>=12?"pm":"am"),l=n.getHours()-(n.getHours()>12?12:0)+":"+(n.getMinutes()<10?"0":"")+n.getMinutes()+":"+(n.getSeconds()<10?"0":"")+n.getSeconds()+" "+(n.getHours()>=12?"pm":"am"),c=o;return o==u&&(c=f),o==a&&(c=w2utils.lang("Yesterday")),'<span title="'+o+" "+l+'">'+c+"</span>"}function h(e){if(!w2utils.isFloat(e)||e=="")return"";e=parseFloat(e);if(e==0)return 0;var t=["Bt","KB","MB","GB","TB"],n=parseInt(Math.floor(Math.log(e)/Math.log(1024)));return(Math.floor(e/Math.pow(1024,n)*10)/10).toFixed(n==0?0:1)+" "+t[n]}function p(e){var t="";if(w2utils.isFloat(e)||w2utils.isInt(e)||w2utils.isMoney(e))t=String(e).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,");return t}function d(e,t){var n=w2utils.settings.shortmonths,r=w2utils.settings.fullmonths;typeof t=="undefined"&&(t=this.settings.date_format);if(typeof e=="undefined"||e==""||e==null)return"";var i=new Date(e);w2utils.isInt(e)&&(i=new Date(Number(e)));var s=String(e).split("-");s.length==3&&(i=new Date(s[0],Number(s[1])-1,s[2]));var s=String(e).split("/");s.length==3&&(i=new Date(s[2],Number(s[0])-1,s[1]));if(i=="Invalid Date")return"";var o=i.getFullYear(),u=i.getMonth(),a=i.getDate();return t.toLowerCase().replace("month",w2utils.settings.fullmonths[u]).replace("mon",w2utils.settings.shortmonths[u]).replace(/yyyy/g,o).replace(/yyy/g,o).replace(/yy/g,String(o).substr(2)).replace(/(^|[^a-z$])y/g,"$1"+o).replace(/mm/g,(u+1<10?"0":"")+(u+1)).replace(/dd/g,(a<10?"0":"")+a).replace(/(^|[^a-z$])m/g,"$1"+(u+1)).replace(/(^|[^a-z$])d/g,"$1"+a)}function v(e,t){var n=w2utils.settings.shortmonths,r=w2utils.settings.fullmonths;typeof t=="undefined"&&(t=this.settings.time_format);if(typeof e=="undefined"||e==""||e==null)return"";var i=new Date(e);w2utils.isInt(e)&&(i=new Date(Number(e)));if(i=="Invalid Date")return"";var s="am",o=i.getHours(),u=i.getHours(),a=i.getMinutes(),f=i.getSeconds();a<10&&(a="0"+a),f<10&&(f="0"+f);if(t.indexOf("am")!=-1||t.indexOf("pm")!=-1)o>=12&&(s="pm"),o>12&&(o-=12);return t.toLowerCase().replace("am",s).replace("pm",s).replace("hh",o).replace("h24",u).replace("mm",a).replace("mi",a).replace("ss",f).replace(/(^|[^a-z$])h/g,"$1"+o).replace(/(^|[^a-z$])m/g,"$1"+a).replace(/(^|[^a-z$])s/g,"$1"+f)}function m(e,t){var n;if(typeof t!="string")var n=[this.settings.date_format,this.settings.time_format];else var n=t.split("|");return this.formatDate(e,n[0])+" "+this.formatTime(e,n[1])}function g(e){if(e==null)return e;switch(typeof e){case"number":break;case"string":e=$.trim(String(e).replace(/(<([^>]+)>)/ig,""));break;case"object":for(var t in e)e[t]=this.stripTags(e[t])}return e}function y(e){if(e==null)return e;switch(typeof e){case"number":break;case"string":e=String(e).replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/"/g,""");break;case"object":for(var t in e)e[t]=this.encodeTags(e[t])}return e}function b(e){return typeof e=="undefined"||e==""||e==null?"":String(e).replace(/([;&,\.\+\*\~'`:"\!\^#$%@\[\]\(\)=<>\|\/? {}\\])/g,"\\$1")}function w(e){function c(e){var e=String(e).replace(/\r\n/g,"\n"),t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(r&63|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(r&63|128))}return t}var t="",n,r,i,s,o,u,a,f=0,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e=c(e);while(f<e.length)n=e.charCodeAt(f++),r=e.charCodeAt(f++),i=e.charCodeAt(f++),s=n>>2,o=(n&3)<<4|r>>4,u=(r&15)<<2|i>>6,a=i&63,isNaN(r)?u=a=64:isNaN(i)&&(a=64),t=t+l.charAt(s)+l.charAt(o)+l.charAt(u)+l.charAt(a);return t}function E(e){function c(e){var t="",n=0,r=0,i=0,s=0;while(n<e.length)r=e.charCodeAt(n),r<128?(t+=String.fromCharCode(r),n++):r>191&&r<224?(s=e.charCodeAt(n+1),t+=String.fromCharCode((r&31)<<6|s&63),n+=2):(s=e.charCodeAt(n+1),c3=e.charCodeAt(n+2),t+=String.fromCharCode((r&15)<<12|(s&63)<<6|c3&63),n+=3);return t}var t="",n,r,i,s,o,u,a,f=0,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length)s=l.indexOf(e.charAt(f++)),o=l.indexOf(e.charAt(f++)),u=l.indexOf(e.charAt(f++)),a=l.indexOf(e.charAt(f++)),n=s<<2|o>>4,r=(o&15)<<4|u>>2,i=(u&3)<<6|a,t+=String.fromCharCode(n),u!=64&&(t+=String.fromCharCode(r)),a!=64&&(t+=String.fromCharCode(i));return t=c(t),t}function S(e,t,n,r){function u(e,t,n){var r=!!window.webkitURL;return!r&&typeof n!="undefined"&&(t=n),";"+e+": "+t+"; -webkit-"+e+": "+t+"; -moz-"+e+": "+t+"; "+"-ms-"+e+": "+t+"; -o-"+e+": "+t+";"}var i=$(e).width(),s=$(e).height(),o=.5;if(!e||!t){console.log("ERROR: Cannot do transition when one of the divs is null");return}e.parentNode.style.cssText+=u("perspective","700px")+"; overflow: hidden;",e.style.cssText+="; position: absolute; z-index: 1019; "+u("backface-visibility","hidden"),t.style.cssText+="; position: absolute; z-index: 1020; "+u("backface-visibility","hidden");switch(n){case"slide-left":e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; "+u("transform","translate3d("+i+"px, 0, 0)","translate("+i+"px, 0)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+";"+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),e.style.cssText+=u("transition",o+"s")+";"+u("transform","translate3d(-"+i+"px, 0, 0)","translate(-"+i+"px, 0)")},1);break;case"slide-right":e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; "+u("transform","translate3d(-"+i+"px, 0, 0)","translate(-"+i+"px, 0)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d(0px, 0, 0)","translate(0px, 0)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d("+i+"px, 0, 0)","translate("+i+"px, 0)")},1);break;case"slide-down":e.style.cssText+="overflow: hidden; z-index: 1; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; z-index: 0; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d(0, "+s+"px, 0)","translate(0, "+s+"px)")},1);break;case"slide-up":e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, "+s+"px, 0)","translate(0, "+s+"px)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)")},1);break;case"flip-left":e.style.cssText+="overflow: hidden; "+u("-transform","rotateY(0deg)"),t.style.cssText+="overflow: hidden; "+u("transform","rotateY(-180deg)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateY(0deg)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateY(180deg)")},1);break;case"flip-right":e.style.cssText+="overflow: hidden; "+u("transform","rotateY(0deg)"),t.style.cssText+="overflow: hidden; "+u("transform","rotateY(180deg)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateY(0deg)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateY(-180deg)")},1);break;case"flip-down":e.style.cssText+="overflow: hidden; "+u("transform","rotateX(0deg)"),t.style.cssText+="overflow: hidden; "+u("transform","rotateX(180deg)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateX(0deg)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateX(-180deg)")},1);break;case"flip-up":e.style.cssText+="overflow: hidden; "+u("transform","rotateX(0deg)"),t.style.cssText+="overflow: hidden; "+u("transform","rotateX(-180deg)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateX(0deg)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateX(180deg)")},1);break;case"pop-in":e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)")+"; "+u("transform","scale(.8)")+"; opacity: 0;",$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","scale(1)")+"; opacity: 1;",e.style.cssText+=u("transition",o+"s")+";"},1);break;case"pop-out":e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)")+"; "+u("transform","scale(1)")+"; opacity: 1;",t.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)")+"; opacity: 0;",$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; opacity: 1;",e.style.cssText+=u("transition",o+"s")+"; "+u("transform","scale(1.7)")+"; opacity: 0;"},1);break;default:e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)")+"; opacity: 0;",$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; opacity: 1;",e.style.cssText+=u("transition",o+"s")},1)}setTimeout(function(){n=="slide-down"&&($(e).css("z-index","1019"),$(t).css("z-index","1020")),t&&$(t).css({opacity:"1","-webkit-transition":"","-moz-transition":"","-ms-transition":"","-o-transition":"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":"","-webkit-backface-visibility":"","-moz-backface-visibility":"","-ms-backface-visibility":"","-o-backface-visibility":""}),e&&($(e).css({opacity:"1","-webkit-transition":"","-moz-transition":"","-ms-transition":"","-o-transition":"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":"","-webkit-backface-visibility":"","-moz-backface-visibility":"","-ms-backface-visibility":"","-o-backface-visibility":""}),e.parentNode&&$(e.parentNode).css({"-webkit-perspective":"","-moz-perspective":"","-ms-perspective":"","-o-perspective":""})),typeof r=="function"&&r()},o*1e3)}function x(e,t,n){!t&&t!=0&&(t=""),w2utils.unlock(e),$(e).find(">:first-child").before('<div class="w2ui-lock"></div><div class="w2ui-lock-msg"></div>'),setTimeout(function(){var r=$(e).find(".w2ui-lock"),i=$(e).find(".w2ui-lock-msg");r.data("old_opacity",r.css("opacity")).css("opacity","0").show(),i.data("old_opacity",i.css("opacity")).css("opacity","0").show(),setTimeout(function(){var r=$(e).find(".w2ui-lock"),i=$(e).find(".w2ui-lock-msg"),s=($(e).width()-w2utils.getSize(i,"width"))/2,o=($(e).height()*.9-w2utils.getSize(i,"height"))/2;r.css({opacity:r.data("old_opacity"),left:"0px",top:"0px",width:"100%",height:"100%"}),t||i.css({"background-color":"transparent",border:"0px"}),n===!0&&(t='<div class="w2ui-spinner" '+(t?"":'style="width: 30px; height: 30px"')+"></div>"+t),i.html(t).css({opacity:i.data("old_opacity"),left:s+"px",top:o+"px"})},10)},10),$().w2tag()}function T(e){$(e).find(".w2ui-lock").remove(),$(e).find(".w2ui-lock-msg").remove()}function N(e,t){var n={left:parseInt($(e).css("border-left-width"))||0,right:parseInt($(e).css("border-right-width"))||0,top:parseInt($(e).css("border-top-width"))||0,bottom:parseInt($(e).css("border-bottom-width"))||0},r={left:parseInt($(e).css("margin-left"))||0,right:parseInt($(e).css("margin-right"))||0,top:parseInt($(e).css("margin-top"))||0,bottom:parseInt($(e).css("margin-bottom"))||0},i={left:parseInt($(e).css("padding-left"))||0,right:parseInt($(e).css("padding-right"))||0,top:parseInt($(e).css("padding-top"))||0,bottom:parseInt($(e).css("padding-bottom"))||0};switch(t){case"top":return n.top+r.top+i.top;case"bottom":return n.bottom+r.bottom+i.bottom;case"left":return n.left+r.left+i.left;case"right":return n.right+r.right+i.right;case"width":return n.left+n.right+r.left+r.right+i.left+i.right+parseInt($(e).width());case"height":return n.top+n.bottom+r.top+r.bottom+i.top+i.bottom+parseInt($(e).height());case"+width":return n.left+n.right+r.left+r.right+i.left+i.right;case"+height":return n.top+n.bottom+r.top+r.bottom+i.top+i.bottom}return 0}function C(e){var t=this.settings.phrases[e];return typeof t=="undefined"?e:t}function k(e){e||(e="en-us"),e.length==5&&(e="locale/"+e+".json"),$.ajax({url:e,type:"GET",dataType:"JSON",async:!1,cache:!1,success:function(e,t,n){w2utils.settings=$.extend(!0,w2utils.settings,e)},error:function(t,n,r){console.log("ERROR: Cannot load locale "+e)}})}function L(){if(e.scrollBarSize)return e.scrollBarSize;var t='<div id="_scrollbar_width" style="position: absolute; top: -300px; width: 100px; height: 100px; overflow-y: scroll;"> <div style="height: 120px">1</div></div>';return $("body").append(t),e.scrollBarSize=100-$("#_scrollbar_width > div").width(),$("#_scrollbar_width").remove(),String(navigator.userAgent).indexOf("MSIE")>=0&&(e.scrollBarSize=e.scrollBarSize/2),e.scrollBarSize}var e={},t={settings:{locale:"en-us",date_format:"m/d/yyyy",date_display:"Mon d, yyyy",time_format:"hh:mi pm",currency:"^[$€£¥]?[-]?[0-9]*[.]?[0-9]+$",currencySymbol:"$","float":"^[-]?[0-9]*[.]?[0-9]+$",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"],RESTfull:!1,phrases:{}},isInt:n,isFloat:r,isMoney:i,isHex:s,isAlphaNumeric:o,isEmail:u,isDate:a,isTime:f,age:l,date:c,size:h,formatNumber:p,formatDate:d,formatTime:v,formatDateTime:m,stripTags:g,encodeTags:y,escapeId:b,base64encode:w,base64decode:E,transition:S,lock:x,unlock:T,lang:C,locale:k,getSize:N,scrollBarSize:L};return t}();w2utils.event={on:function(e,t){$.isPlainObject(e)||(e={type:e}),e=$.extend({type:null,execute:"before",target:null,onComplete:null},e);if(typeof e.type=="undefined"){console.log("ERROR: You must specify event type when calling .on() method of "+this.name);return}if(typeof t=="undefined"){console.log("ERROR: You must specify event handler function when calling .on() method of "+this.name);return}this.handlers.push({event:e,handler:t})},off:function(e,t){$.isPlainObject(e)||(e={type:e}),e=$.extend({},{type:null,execute:"before",target:null,onComplete:null},e);if(typeof e.type=="undefined"){console.log("ERROR: You must specify event type when calling .off() method of "+this.name);return}typeof t=="undefined"&&(t=null);var n=[];for(var r in this.handlers){var i=this.handlers[r];(i.event.type!=e.type&&e.type!="*"||i.event.target!=e.target&&e.target!=null||i.handler!=t&&t!=null)&&n.push(i)}this.handlers=n},trigger:function(e){var e=$.extend({type:null,phase:"before",target:null,isStopped:!1,isCancelled:!1},e,{preventDefault:function(){this.isCancelled=!0},stopPropagation:function(){this.isStopped=!0}});typeof e.target=="undefined"&&(e.target=null);for(var t=this.handlers.length-1;t>=0;t--){var n=this.handlers[t];if((n.event.type==e.type||n.event.type=="*")&&(n.event.target==e.target||n.event.target==null)&&(n.event.execute==e.phase||n.event.execute=="*"||n.event.phase=="*")){e=$.extend({},n.event,e);var r=[],i=RegExp(/\((.*?)\)/).exec(n.handler);i&&(r=i[1].split(/\s*,\s*/)),r.length==2?n.handler.call(this,e.target,e):n.handler.call(this,e);if(e.isStopped===!0||e.stop===!0)return e}}var s="on"+e.type.substr(0,1).toUpperCase()+e.type.substr(1);if(e.phase=="before"&&typeof this[s]=="function"){var o=this[s],r=[],i=RegExp(/\((.*?)\)/).exec(o);i&&(r=i[1].split(/\s*,\s*/)),r.length==2?o.call(this,e.target,e):o.call(this,e);if(e.isStopped===!0||e.stop===!0)return e}if(typeof e.object!="undefined"&&e.object!=null&&e.phase=="before"&&typeof e.object[s]=="function"){var o=e.object[s],r=[],i=RegExp(/\((.*?)\)/).exec(o);i&&(r=i[1].split(/\s*,\s*/)),r.length==2?o.call(this,e.target,e):o.call(this,e);if(e.isStopped===!0||e.stop===!0)return e}return e.phase=="after"&&e.onComplete!=null&&e.onComplete.call(this,e),e}},w2utils.keyboard=function(e){function n(){$(document).on("keydown",r),$(document).on("mousedown",i)}function r(e){var n=e.target.tagName;if($.inArray(n,["INPUT","SELECT","TEXTAREA"])!=-1)return;if($(e.target).prop("contenteditable")=="true")return;if(!t)return;w2ui[t]&&typeof w2ui[t].keydown=="function"&&w2ui[t].keydown.call(w2ui[t],e)}function i(e){var n=e.target.tagName,r=$(e.target).parents(".w2ui-reset");r.length>0&&(t=r.attr("name"))}function s(e){if(typeof e=="undefined")return t;t=e}function o(){t=null}function u(){}var t=null;return e.active=s,e.clear=o,e.register=u,n(),e}({}),function(){$.fn.w2render=function(e){$(this).length>0&&(typeof e=="string"&&w2ui[e]&&w2ui[e].render($(this)[0]),typeof e=="object"&&e.render($(this)[0]))},$.fn.w2destroy=function(e){!e&&this.length>0&&(e=this.attr("name")),typeof e=="string"&&w2ui[e]&&w2ui[e].destroy(),typeof e=="object"&&e.destroy()},$.fn.w2marker=function(e){return e==""||typeof e=="undefined"?$(this).each(function(e,t){t.innerHTML=t.innerHTML.replace(/\<span class=\"w2ui\-marker\"\>(.*)\<\/span\>/ig,"$1")}):$(this).each(function(t,n){typeof e=="string"&&(e=[e]),n.innerHTML=n.innerHTML.replace(/\<span class=\"w2ui\-marker\"\>(.*)\<\/span\>/ig,"$1");for(var r in e){var i=e[r];typeof i!="string"&&(i=String(i)),i=i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&").replace(/&/g,"&").replace(/</g,">").replace(/>/g,"<");var s=new RegExp(i+"(?!([^<]+)?>)","gi");n.innerHTML=n.innerHTML.replace(s,function(e){return'<span class="w2ui-marker">'+e+"</span>"})}})},$.fn.w2tag=function(e,t){$.isPlainObject(t)||(t={}),$.isPlainObject(t.css)||(t.css={}),typeof t["class"]=="undefined"&&(t["class"]="");if($(this).length==0){$(".w2ui-tag").each(function(e,t){var n=$(t).data("options");typeof n=="undefined"&&(n={}),$($(t).data("taged-el")).removeClass(n["class"]),clearInterval($(t).data("timer")),$(t).remove()});return}return $(this).each(function(n,r){var i=r.id,s=w2utils.escapeId(r.id);if(e==""||e==null||typeof e=="undefined")$("#w2ui-tag-"+s).css("opacity",0),setTimeout(function(){clearInterval($("#w2ui-tag-"+s).data("timer")),$("#w2ui-tag-"+s).remove()},300);else{clearInterval($("#w2ui-tag-"+s).data("timer")),$("#w2ui-tag-"+s).remove(),$("body").append('<div id="w2ui-tag-'+i+'" class="w2ui-tag '+($(r).parents(".w2ui-popup").length>0?"w2ui-tag-popup":"")+'" '+' style=""></div>');var o=setInterval(function(){if($(r).length==0||$(r).offset().left==0&&$(r).offset().top==0){clearInterval($("#w2ui-tag-"+s).data("timer")),a();return}$("#w2ui-tag-"+s).data("position")!=$(r).offset().left+r.offsetWidth+"x"+$(r).offset().top&&$("#w2ui-tag-"+s).css({"-webkit-transition":".2s","-moz-transition":".2s","-ms-transition":".2s","-o-transition":".2s",left:$(r).offset().left+r.offsetWidth+"px",top:$(r).offset().top+"px"}).data("position",$(r).offset().left+r.offsetWidth+"x"+$(r).offset().top)},100);setTimeout(function(){if(!$(r).offset())return;$("#w2ui-tag-"+s).css({opacity:"1",left:$(r).offset().left+r.offsetWidth+"px",top:$(r).offset().top+"px"}).html('<div style="margin-top: -2px 0px 0px -2px; white-space: nowrap;"> <div class="w2ui-tag-body">'+e+"</div> </div>").data("text",e).data("taged-el",r).data("options",t).data("position",$(r).offset().left+r.offsetWidth+"x"+$(r).offset().top).data("timer",o),$(r).off("keypress",a).on("keypress",a).off("change",a).on("change",a).css(t.css).addClass(t["class"]),typeof t.onShow=="function"&&t.onShow()},1);var u="";$(r).length>0&&(u=$(r)[0].style.cssText);function a(){if($("#w2ui-tag-"+s).length<=0)return;clearInterval($("#w2ui-tag-"+s).data("timer")),$("#w2ui-tag-"+s).remove(),$(r).off("keypress",a).removeClass(t["class"]),$(r).length>0&&($(r)[0].style.cssText=u),typeof t.onHide=="function"&&t.onHide()}}})},$.fn.w2overlay=function(e,t){function s(){var e;typeof t.onHide=="function"&&(e=t.onHide());if(e===!1)return;$("#w2ui-overlay").remove(),$(document).off("click",s)}function o(){$(document).on("click",s);if($("#w2ui-overlay > div").length>0){var e=$("#w2ui-overlay > div").height(),n=$("#w2ui-overlay> div").width(),r=window.innerHeight-$("#w2ui-overlay > div").offset().top-7;e>r&&$("#w2ui-overlay> div").height(r).width(n+w2utils.scrollBarSize()).css({"overflow-y":"auto"}),n=$("#w2ui-overlay> div").width(),r=window.innerWidth-$("#w2ui-overlay > div").offset().left-7,n>r&&$("#w2ui-overlay> div").width(r).css({"overflow-x":"auto"}),typeof t.onShow=="function"&&t.onShow()}}$.isPlainObject(t)||(t={}),$.isPlainObject(t.css)||(t.css={});if(this.length==0||e==""||typeof e=="undefined")return s(),$(this);$("#w2ui-overlay").length>0&&$(document).click(),$("body").append('<div id="w2ui-overlay" class="w2ui-reset w2ui-overlay '+($(this).parents(".w2ui-popup").length>0?"w2ui-overlay-popup":"")+'">'+" <div></div>"+"</div>");var n=this,r=$("#w2ui-overlay div");r.css(t.css).html(e),typeof t["class"]!="undefined"&&r.addClass(t["class"]),typeof t.top=="undefined"&&(t.top=0),typeof t.left=="undefined"&&(t.left=0),typeof t.width=="undefined"&&(t.width=100),typeof t.height=="undefined"&&(t.height=0);var i=r.css("background-color"),r=$("#w2ui-overlay");return typeof i!="undefined"&&i!="rgba(0, 0, 0, 0)"&&i!="transparent"&&r.css("background-color",i),r.css({display:"none",left:$(n).offset().left+t.left+"px",top:$(n).offset().top+w2utils.getSize($(n),"height")+3+t.top+"px","min-width":t.width?t.width:"auto","min-height":t.height?t.height:"auto"}).fadeIn("fast").data("position",$(n).offset().left+"x"+($(n).offset().top+n.offsetHeight)).on("click",function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}),setTimeout(o,0),$(this)},$.fn.w2menu=function(e,t){function n(){var t='<table cellspacing="0" cellpadding="0" class="w2ui-drop-menu">';for(var n=0;n<e.length;n++){var r=e[n];if(typeof r=="string"){var i=r.split("|");r={id:i[0],text:i[0],img:null,icon:null},i[1]&&(r.text=i[1]),i[2]&&(r.img=i[2]),i[3]&&(r.icon=i[3])}else typeof r.text!="undefined"&&typeof r.id=="undefined"&&(r.id=r.text),typeof r.text=="undefined"&&typeof r.id!="undefined"&&(r.text=r.id),typeof r.caption!="undefined"&&(r.text=r.caption),typeof r.img=="undefined"&&(r.img=null),typeof r.icon=="undefined"&&(r.icon=null);var s="<td> </td>";r.img&&(s='<td><div class="w2ui-tb-image w2ui-icon '+r.img+'"></div></td>'),r.icon&&(s='<td align="center"><div class="w2ui-tb-image"><span class="'+r.icon+'"></span></div></td>'),t+="<tr onmouseover=\"$(this).addClass('w2ui-selected');\" onmouseout=\"$(this).removeClass('w2ui-selected');\" onclick=\"$(document).click(); $.fn.w2menuHandler(event, '"+n+"');\">"+s+" <td>"+r.text+"</td>"+"</tr>"}return t+="</table>",t}return typeof t.select=="undefined"&&typeof t.onSelect=="function"&&(t.select=t.onSelect),typeof t.select!="function"?(console.log("ERROR: options.select is required to be a function, not "+typeof t.select+" in $().w2menu(menu, options)"),$(this)):$.isArray(e)?($.fn.w2menuHandler=function(n,r){t.select(e[r],n,r)},$(this).w2overlay(n(),t)):(console.log("ERROR: first parameter should be an array of objects or strings in $().w2menu(menu, options)"),$(this))}}(),function(){var w2grid=function(e){this.name=null,this.box=null,this.header="",this.url="",this.columns=[],this.columnGroups=[],this.records=[],this.summary=[],this.searches=[],this.searchData=[],this.sortData=[],this.postData={},this.toolbar={},this.show={header:!1,toolbar:!1,footer:!1,columnHeaders:!0,lineNumbers:!1,expandColumn:!1,selectColumn:!1,emptyRecords:!0,toolbarReload:!0,toolbarColumns:!0,toolbarSearch:!0,toolbarAdd:!1,toolbarEdit:!1,toolbarDelete:!1,toolbarSave:!1,selectionBorder:!0,recordTitles:!0},this.autoLoad=!0,this.fixedBody=!0,this.recordHeight=24,this.keyboard=!0,this.selectType="row",this.multiSearch=!0,this.multiSelect=!0,this.multiSort=!0,this.markSearchResults=!0,this.total=0,this.buffered=0,this.limit=100,this.offset=0,this.style="",this.ranges=[],this.onAdd=null,this.onEdit=null,this.onRequest=null,this.onLoad=null,this.onDelete=null,this.onDeleted=null,this.onSave=null,this.onSaved=null,this.onSelect=null,this.onUnselect=null,this.onClick=null,this.onDblClick=null,this.onColumnClick=null,this.onColumnResize=null,this.onSort=null,this.onSearch=null,this.onChange=null,this.onExpand=null,this.onCollapse=null,this.onError=null,this.onKeydown=null,this.onToolbar=null,this.onColumnOnOff=null,this.onCopy=null,this.onPaste=null,this.onSelectionExtend=null,this.onEditField=null,this.onRender=null,this.onRefresh=null,this.onReload=null,this.onResize=null,this.onDestroy=null,this.last={field:"all",caption:w2utils.lang("All Fields"),logic:"OR",search:"",searchIds:[],multi:!1,scrollTop:0,scrollLeft:0,selected:[],sortData:null,sortCount:0,xhr:null,range_start:null,range_end:null,sel_ind:null,sel_col:null,sel_type:null},this.isIOS=navigator.userAgent.toLowerCase().indexOf("iphone")!=-1||navigator.userAgent.toLowerCase().indexOf("ipod")!=-1||navigator.userAgent.toLowerCase().indexOf("ipad")!=-1?!0:!1,$.extend(!0,this,w2obj.grid,e)};$.fn.w2grid=function(e){if(typeof e=="object"||!e){if(!e||typeof e.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2grid().');return}if(typeof w2ui[e.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+e.name+").");return}if(!w2utils.isAlphaNumeric(e.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var t=e.columns,n=e.columnGroups,r=e.records,i=e.searches,s=e.searchData,o=e.sortData,u=e.postData,a=e.toolbar,f=new w2grid(e);$.extend(f,{postData:{},records:[],columns:[],searches:[],toolbar:{},sortData:[],searchData:[],handlers:[]}),f.onExpand!=null&&(f.show.expandColumn=!0),$.extend(!0,f.toolbar,a);for(var l in t)f.columns[l]=$.extend(!0,{},t[l]);for(var l in n)f.columnGroups[l]=$.extend(!0,{},n[l]);for(var l in i)f.searches[l]=$.extend(!0,{},i[l]);for(var l in s)f.searchData[l]=$.extend(!0,{},s[l]);for(var l in o)f.sortData[l]=$.extend(!0,{},o[l]);f.postData=$.extend(!0,{},u);for(var c in r){if(r[c].recid==null||typeof r[c].recid=="undefined"){console.log("ERROR: Cannot add records without recid. (obj: "+f.name+")");return}f.records[c]=$.extend(!0,{},r[c])}f.records.length>0&&(f.buffered=f.records.length);for(var h in f.columns){var p=f.columns[h];if(typeof p.searchable=="undefined"||f.getSearch(p.field)!=null)continue;var d=p.searchable,v="";p.searchable===!0&&(d="text",v='size="20"'),f.addSearch({field:p.field,caption:p.caption,type:d,attr:v})}return f.initToolbar(),$(this).length!=0&&f.render($(this)[0]),w2ui[f.name]=f,f}if(w2ui[$(this).attr("name")]){var m=w2ui[$(this).attr("name")];return m[e].apply(m,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+e+" does not exist on jQuery.w2grid")},w2grid.prototype={msgDelete:w2utils.lang("Are you sure you want to delete selected records?"),msgNotJSON:w2utils.lang("Returned data is not in valid JSON format."),msgRefresh:w2utils.lang("Refreshing..."),buttons:{reload:{type:"button",id:"reload",img:"icon-reload",hint:w2utils.lang("Reload data in the list")},columns:{type:"drop",id:"column-on-off",img:"icon-columns",hint:w2utils.lang("Show/hide columns"),arrow:!1,html:""},search:{type:"html",id:"search",html:'<div class="w2ui-icon icon-search-down w2ui-search-down" title="'+w2utils.lang("Select Search Field")+'" '+"onclick=\"var obj = w2ui[$(this).parents('div.w2ui-grid').attr('name')]; obj.searchShowFields(this);\"></div>"},"search-go":{type:"check",id:"search-advanced",caption:w2utils.lang("Search..."),hint:w2utils.lang("Open Search Fields")},add:{type:"button",id:"add",caption:w2utils.lang("Add New"),hint:w2utils.lang("Add new record"),img:"icon-add"},edit:{type:"button",id:"edit",caption:w2utils.lang("Edit"),hint:w2utils.lang("Edit selected record"),img:"icon-edit",disabled:!0},"delete":{type:"button",id:"delete",caption:w2utils.lang("Delete"),hint:w2utils.lang("Delete selected records"),img:"icon-delete",disabled:!0},save:{type:"button",id:"save",caption:w2utils.lang("Save"),hint:w2utils.lang("Save changed records"),img:"icon-save"}},add:function(e){$.isArray(e)||(e=[e]);var t=0;for(var n in e){if(e[n].recid==null||typeof e[n].recid=="undefined"){console.log("ERROR: Cannot add record without recid. (obj: "+this.name+")");continue}this.records.push(e[n]),t++}this.buffered=this.records.length;var r=typeof this.url!="object"?this.url:this.url.get;return r||(this.localSort(),this.localSearch()),this.refresh(),t},find:function(e,t){if(typeof e=="undefined"||e==null)e={};var n=[];for(var r=0;r<this.records.length;r++){var i=!0;for(var s in e){var o=this.records[r][s];String(s).indexOf(".")!=-1&&(o=this.parseField(this.records[r],s)),e[s]!=o&&(i=!1)}i&&t!==!0&&n.push(this.records[r]),i&&t===!0&&n.push(r)}return n},set:function(e,t,n){typeof e=="object"&&(n=t,t=e,e=null);if(e==null){for(var r in this.records)$.extend(!0,this.records[r],t);n!==!0&&this.refresh()}else{var i=this.get(e,!0);if(i==null)return!1;$.extend(!0,this.records[i],t);if(n!==!0){var s=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(e));if(s.length!=0){var o=s.attr("line"),u=typeof this.url!="object"?this.url:this.url.get;if(this.searchData.length>0&&!u)for(var a in this.last.searchIds)this.last.searchIds[a]==i&&(i=a);$(s).replaceWith(this.getRecordHTML(i,o))}}}return!0},get:function(e,t){for(var n=0;n<this.records.length;n++)if(this.records[n].recid==e)return t===!0?n:this.records[n];return null},remove:function(){var e=0;for(var t=0;t<arguments.length;t++
)for(var n=this.records.length-1;n>=0;n--)this.records[n].recid==arguments[t]&&(this.records.splice(n,1),e++);var r=typeof this.url!="object"?this.url:this.url.get;return r||(this.buffered=this.records.length,this.localSort(),this.localSearch()),this.refresh(),e},addColumn:function(e,t){var n=0;arguments.length==1?(t=e,e=this.columns.length):(typeof e=="string"&&(e=this.getColumn(e,!0)),e===null&&(e=this.columns.length)),$.isArray(t)||(t=[t]);for(var r in t)this.columns.splice(e,0,t[r]),e++,n++;return this.initColumnOnOff(),this.refresh(),n},removeColumn:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.columns.length-1;n>=0;n--)this.columns[n].field==arguments[t]&&(this.columns.splice(n,1),e++);return this.initColumnOnOff(),this.refresh(),e},getColumn:function(e,t){for(var n=0;n<this.columns.length;n++)if(this.columns[n].field==e)return t===!0?n:this.columns[n];return null},toggleColumn:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.columns.length-1;n>=0;n--)this.columns[n].field==arguments[t]&&(this.columns[n].hidden=!this.columns[n].hidden,e++);return this.refresh(),e},showColumn:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.columns.length-1;n>=0;n--)this.columns[n].field==arguments[t]&&this.columns[n].hidden!==!1&&(this.columns[n].hidden=!1,e++);return this.refresh(),e},hideColumn:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.columns.length-1;n>=0;n--)this.columns[n].field==arguments[t]&&this.columns[n].hidden!==!0&&(this.columns[n].hidden=!0,e++);return this.refresh(),e},addSearch:function(e,t){var n=0;arguments.length==1?(t=e,e=this.searches.length):(typeof e=="string"&&(e=this.getSearch(e,!0)),e===null&&(e=this.searches.length)),$.isArray(t)||(t=[t]);for(var r in t)this.searches.splice(e,0,t[r]),e++,n++;return this.searchClose(),n},removeSearch:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.searches.length-1;n>=0;n--)this.searches[n].field==arguments[t]&&(this.searches.splice(n,1),e++);return this.searchClose(),e},getSearch:function(e,t){for(var n=0;n<this.searches.length;n++)if(this.searches[n].field==e)return t===!0?n:this.searches[n];return null},toggleSearch:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.searches.length-1;n>=0;n--)this.searches[n].field==arguments[t]&&(this.searches[n].hidden=!this.searches[n].hidden,e++);return this.searchClose(),e},showSearch:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.searches.length-1;n>=0;n--)this.searches[n].field==arguments[t]&&this.searches[n].hidden!==!1&&(this.searches[n].hidden=!1,e++);return this.searchClose(),e},hideSearch:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.searches.length-1;n>=0;n--)this.searches[n].field==arguments[t]&&this.searches[n].hidden!==!0&&(this.searches[n].hidden=!0,e++);return this.searchClose(),e},getSearchData:function(e){for(var t in this.searchData)if(this.searchData[t].field==e)return this.searchData[t];return null},localSort:function(e){var t=typeof this.url!="object"?this.url:this.url.get;if(t){console.log("ERROR: grid.localSort can only be used on local data source, grid.url should be empty.");return}if($.isEmptyObject(this.sortData))return;var n=(new Date).getTime(),r=this;return this.records.sort(function(e,t){var n=0;for(var i in r.sortData){var s=e[r.sortData[i].field],o=t[r.sortData[i].field];String(r.sortData[i].field).indexOf(".")!=-1&&(s=r.parseField(e,r.sortData[i].field),o=r.parseField(t,r.sortData[i].field)),typeof s=="string"&&(s=$.trim(s.toLowerCase())),typeof o=="string"&&(o=$.trim(o.toLowerCase())),s>o&&(n=r.sortData[i].direction=="asc"?1:-1),s<o&&(n=r.sortData[i].direction=="asc"?-1:1),typeof s!="object"&&typeof o=="object"&&(n=-1),typeof o!="object"&&typeof s=="object"&&(n=1);if(n!=0)break}return n}),n=(new Date).getTime()-n,e!==!0&&setTimeout(function(){r.status("Sorting took "+n/1e3+" sec")},10),n},localSearch:function(e){var t=typeof this.url!="object"?this.url:this.url.get;if(t){console.log("ERROR: grid.localSearch can only be used on local data source, grid.url should be empty.");return}var n=(new Date).getTime(),r=this;this.total=this.records.length,this.last.searchIds=[];if(this.searchData.length>0&&!t){this.total=0;for(var i in this.records){var s=this.records[i],o=0;for(var u in this.searchData){var a=this.searchData[u],f=this.getSearch(a.field);if(a==null)continue;f==null&&(f={field:a.field,type:a.type});var l=String(r.parseField(s,f.field)).toLowerCase();if(typeof a.value!="undefined")if(!$.isArray(a.value))var c=String(a.value).toLowerCase();else var c=a.value[0],h=a.value[1];switch(a.operator){case"is":s[f.field]==a.value&&o++;if(f.type=="date"){var p=new Date(Number(l));l=(new Date(p.getFullYear(),p.getMonth(),p.getDate())).getTime(),c=Number(c);var h=Number(l)+864e5;c>=l&&c<=h&&o++}break;case"between":f.type=="int"&&parseInt(s[f.field])>=parseInt(c)&&parseInt(s[f.field])<=parseInt(h)&&o++,f.type=="float"&&parseFloat(s[f.field])>=parseFloat(c)&&parseFloat(s[f.field])<=parseFloat(h)&&o++;if(f.type=="date"){var p=new Date(Number(h));h=(new Date(p.getFullYear(),p.getMonth(),p.getDate())).getTime();var h=Number(h)+864e5;l>=c&&l<h&&o++}break;case"in":a.value.indexOf(l)!==-1&&o++;break;case"begins with":l.indexOf(c)==0&&o++;break;case"contains":l.indexOf(c)>=0&&o++;break;case"ends with":l.indexOf(c)==l.length-c.length&&o++}}(this.last.logic=="OR"&&o!=0||this.last.logic=="AND"&&o==this.searchData.length)&&this.last.searchIds.push(parseInt(i))}this.total=this.last.searchIds.length}return this.buffered=this.total,n=(new Date).getTime()-n,e!==!0&&setTimeout(function(){r.status("Search took "+n/1e3+" sec")},10),n},getRangeData:function(e,t){var n=this.get(e[0].recid,!0),r=this.get(e[1].recid,!0),i=e[0].column,s=e[1].column,o=[];if(i==s)for(var u=n;u<=r;u++){var a=this.records[u],f=a[this.columns[i].field]||null;t!==!0?o.push(f):o.push({data:f,column:i,index:u,record:a})}else if(n==r){var a=this.records[n];for(var l=i;l<=s;l++){var f=a[this.columns[l].field]||null;t!==!0?o.push(f):o.push({data:f,column:l,index:n,record:a})}}else for(var u=n;u<=r;u++){var a=this.records[u];o.push([]);for(var l=i;l<=s;l++){var f=a[this.columns[l].field];t!==!0?o[o.length-1].push(f):o[o.length-1].push({data:f,column:l,index:u,record:a})}}return o},addRange:function(e){var t=0;if(this.selectType=="row")return t;$.isArray(e)||(e=[e]);for(var n in e){typeof e[n]!="object"&&(e[n]={name:"selection"});if(e[n].name=="selection"){if(this.show.selectionBorder===!1)continue;var r=this.getSelection();if(r.length==0){this.removeRange(e[n].name);continue}var i=r[0],s=r[r.length-1],o=$("#grid_"+this.name+"_rec_"+i.recid+" td[col="+i.column+"]"),u=$("#grid_"+this.name+"_rec_"+s.recid+" td[col="+s.column+"]")}else var i=e[n].range[0],s=e[n].range[1],o=$("#grid_"+this.name+"_rec_"+i.recid+" td[col="+i.column+"]"),u=$("#grid_"+this.name+"_rec_"+s.recid+" td[col="+s.column+"]");if(i){var a={name:e[n].name,range:[{recid:i.recid,column:i.column},{recid:s.recid,column:s.column}],style:e[n].style||""},f=!1;for(var l in this.ranges)if(this.ranges[l].name==e[n].name){f=n;break}f!==!1?this.ranges[f]=a:this.ranges.push(a),t++}}return this.refreshRanges(),t},removeRange:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=arguments[t];$("#grid_"+this.name+"_"+n).remove();for(var r=this.ranges.length-1;r>=0;r--)this.ranges[r].name==n&&(this.ranges.splice(r,1),e++)}return e},refreshRanges:function(){function l(t){var n=e.getSelection();e.last.move={type:"expand",x:t.screenX,y:t.screenY,divX:0,divY:0,recid:n[0].recid,column:n[0].column,originalRange:[{recid:n[0].recid,column:n[0].column},{recid:n[n.length-1].recid,column:n[n.length-1].column}],newRange:[{recid:n[0].recid,column:n[0].column},{recid:n[n.length-1].recid,column:n[n.length-1].column}]},$(document).off("mousemove",c).on("mousemove",c),$(document).off("mouseup",h).on("mouseup",h)}function c(t){var n=e.last.move;if(!n||n.type!="expand")return;n.divX=t.screenX-n.x,n.divY=t.screenY-n.y;var r,i,s=t.originalEvent.target;s.tagName!="TD"&&(s=$(s).parents("td")[0]),typeof $(s).attr("col")!="undefined"&&(i=parseInt($(s).attr("col"))),s=$(s).parents("tr")[0],r=$(s).attr("recid");if(n.newRange[1].recid==r&&n.newRange[1].column==i)return;var o=$.extend({},n.newRange);n.newRange=[{recid:n.recid,column:n.column},{recid:r,column:i}],f=e.trigger($.extend(f,{originalRange:n.originalRange,newRange:n.newRange}));if(f.isCancelled===!0){n.newRange=o,f.newRange=o;return}e.removeRange("grid-selection-expand"),e.addRange({name:"grid-selection-expand",range:f.newRange,style:"background-color: rgba(100,100,100,0.1); border: 2px dotted rgba(100,100,100,0.5);"})}function h(t){e.removeRange("grid-selection-expand"),delete e.last.move,$(document).off("mousemove",c),$(document).off("mouseup",h),e.trigger($.extend(f,{phase:"after"}))}var e=this,t=(new Date).getTime(),n=$("#grid_"+this.name+"_records");for(var r in this.ranges){var i=this.ranges[r],s=i.range[0],o=i.range[1],u=$("#grid_"+this.name+"_rec_"+s.recid+" td[col="+s.column+"]"),a=$("#grid_"+this.name+"_rec_"+o.recid+" td[col="+o.column+"]");$("#grid_"+this.name+"_"+i.name).length==0?n.append('<div id="grid_'+this.name+"_"+i.name+'" class="w2ui-selection" style="'+i.style+'">'+(i.name=="selection"?'<div id="grid_'+this.name+'_resizer" class="w2ui-selection-resizer"></div>':"")+"</div>"):$("#grid_"+this.name+"_"+i.name).attr("style",i.style),u.length>0&&a.length>0&&$("#grid_"+this.name+"_"+i.name).css({left:u.position().left-1+n.scrollLeft()+"px",top:u.position().top-1+n.scrollTop()+"px",width:a.position().left-u.position().left+a.width()+3+"px",height:a.position().top-u.position().top+a.height()+3+"px"})}$(this.box).find("#grid_"+this.name+"_resizer").off("mousedown").on("mousedown",l);var f={phase:"before",type:"selectionExtend",target:e.name,originalRange:null,newRange:null};return(new Date).getTime()-t},select:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=typeof arguments[t]=="object"?arguments[t].recid:arguments[t],r=this.get(n),i=this.get(n,!0);if(r==null)continue;if(this.selectType=="row"){if(r.selected===!0)continue;var s=this.trigger({phase:"before",type:"select",target:this.name,recid:n});if(s.isCancelled===!0)continue;r.selected=!0,$("#grid_"+this.name+"_rec_"+w2utils.escapeId(n)).addClass("w2ui-selected").data("selected","yes"),$("#grid_"+this.name+"_cell_"+i+"_select_check").prop("checked",!0),e++}else{var o=arguments[t].column;if(!w2utils.isInt(o)){var u=[];for(var a in this.columns){if(this.columns[a].hidden)continue;u.push({recid:n,column:parseInt(a)})}return this.select.apply(this,u)}var f=r.selectedColumns;if($.isArray(f)&&f.indexOf(o)!=-1)continue;var s=this.trigger({phase:"before",type:"select",target:this.name,recid:n,column:o});if(s.isCancelled===!0)continue;$.isArray(f)||(r.selectedColumns=[]),r.selected=!0,r.selectedColumns.push(o),r.selectedColumns.sort(function(e,t){return e-t}),$("#grid_"+this.name+"_rec_"+w2utils.escapeId(n)+" > td[col="+o+"]").addClass("w2ui-selected"),e++,r.selected&&($("#grid_"+this.name+"_rec_"+w2utils.escapeId(n)).data("selected","yes"),$("#grid_"+this.name+"_cell_"+i+"_select_check").prop("checked",!0))}this.trigger($.extend(s,{phase:"after"}))}return $("#grid_"+this.name+"_check_all").prop("checked",!0),$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length!=0&&$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length==$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]:checked").length?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.addRange("selection"),e},unselect:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=typeof arguments[t]=="object"?arguments[t].recid:arguments[t],r=this.get(n),i=this.get(r.recid,!0);if(r==null)continue;if(this.selectType=="row"){if(r.selected!==!0)continue;var s=this.trigger({phase:"before",type:"unselect",target:this.name,recid:n});if(s.isCancelled===!0)continue;r.selected=!1;var o=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid));o.removeClass("w2ui-selected").removeData("selected"),o.length!=0&&(o[0].style.cssText="height: "+this.recordHeight+"px; "+o.attr("custom_style")),$("#grid_"+this.name+"_cell_"+i+"_select_check").prop("checked",!1),e++}else{var u=arguments[t].column;if(!w2utils.isInt(u)){var a=[];for(var f in this.columns){if(this.columns[f].hidden)continue;a.push({recid:n,column:parseInt(f)})}return this.unselect.apply(this,a)}var l=r.selectedColumns;if(!$.isArray(l)||l.indexOf(u)==-1)continue;var s=this.trigger({phase:"before",type:"unselect",target:this.name,recid:n,column:u});if(s.isCancelled===!0)continue;l.splice(l.indexOf(u),1),$("#grid_"+this.name+"_rec_"+w2utils.escapeId(n)+" > td[col="+u+"]").removeClass("w2ui-selected"),e++,l.length==0&&(r.selected=!1,$("#grid_"+this.name+"_rec_"+w2utils.escapeId(n)).removeData("selected"),$("#grid_"+this.name+"_cell_"+i+"_select_check").prop("checked",!1))}this.trigger($.extend(s,{phase:"after"}))}return $("#grid_"+this.name+"_check_all").prop("checked",!0),$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length!=0&&$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length==$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]:checked").length?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.addRange("selection"),e},selectAll:function(){if(this.multiSelect===!1)return;var e=this.trigger({phase:"before",type:"select",target:this.name,all:!0});if(e.isCancelled===!0)return;var t=[];for(var n in this.columns)t.push(parseInt(n));var r=typeof this.url!="object"?this.url:this.url.get;if(!r)if(this.searchData.length==0)this.set({selected:!0}),this.selectType=="row"?this.set({selected:!0}):this.set({selected:!0,selectedColumns:t.slice()});else{for(var i=0;i<this.last.searchIds.length;i++)this.records[this.last.searchIds[i]].selected=!0,this.selectType!="row"&&(this.records[this.last.searchIds[i]].selectedColumns=t.slice());this.refresh()}else this.selectType=="row"?this.set({selected:!0}):this.set({selected:!0,selectedColumns:t.slice()}),this.refresh();var s=this.getSelection();s.length==1?this.toolbar.enable("edit"):this.toolbar.disable("edit"),s.length>=1?this.toolbar.enable("delete"):this.toolbar.disable("delete"),this.addRange("selection"),this.trigger($.extend(e,{phase:"after"}))},selectNone:function(){var e=this.trigger({phase:"before",type:"unselect",target:this.name,all:!0});if(e.isCancelled===!0)return;this.last.selected=[];for(var t in this.records){var n=this.records[t];if(n.selected===!0){n.selected=!1;var r=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(n.recid));r.removeClass("w2ui-selected").removeData("selected"),$("#grid_"+this.name+"_cell_"+t+"_select_check").prop("checked",!1);if(this.selectType!="row"){var i=n.selectedColumns;for(var s in i)r.find(" > td[col="+i[s]+"]").removeClass("w2ui-selected");n.selectedColumns=[]}}}this.toolbar.disable("edit","delete"),this.removeRange("selection"),this.trigger($.extend(e,{phase:"after"}))},getSelection:function(e){if(this.selectType=="row"){var t=this.find({selected:!0},!0),n=[];for(var r in t)e===!0?n.push(t[r]):n.push(this.records[t[r]].recid);return n}var t=this.find({selected:!0},!0),n=[];for(var r in t){var i=this.records[t[r]];for(var s in i.selectedColumns)n.push({recid:i.recid,index:parseInt(t[r]),column:i.selectedColumns[s]})}return n},search:function(e,t){var n=this,r=typeof this.url!="object"?this.url:this.url.get,i=[],s=this.last.multi,o=this.last.logic,u=this.last.field,a=this.last.search;if(arguments.length==0){a="";for(var f in this.searches){var l=this.searches[f],c=$("#grid_"+this.name+"_operator_"+f).val(),h=$("#grid_"+this.name+"_field_"+f).val(),p=$("#grid_"+this.name+"_field2_"+f).val();if(h!=""&&h!=null||typeof p!="undefined"&&p!=""){var d={field:l.field,type:l.type,operator:c};c=="between"?$.extend(d,{value:[h,p]}):c=="in"?$.extend(d,{value:h.split(",")}):$.extend(d,{value:h});try{l.type=="date"&&c=="between"&&(d.value[0]=w2utils.isDate(h,w2utils.settings.date_format,!0).getTime(),d.value[1]=w2utils.isDate(p,w2utils.settings.date_format,!0).getTime()),l.type=="date"&&c=="is"&&(d.value=w2utils.isDate(h,w2utils.settings.date_format,!0).getTime())}catch(v){}i.push(d)}}i.length>0&&!r?(s=!0,o="AND"):(s=!0,o="AND")}if(typeof e=="string"){u=e,a=t,s=!1,o="OR";if(typeof t!="undefined")if(e.toLowerCase()=="all")if(this.searches.length>0)for(var f in this.searches){var l=this.searches[f];if(l.type=="text"||l.type=="int"&&w2utils.isInt(t)||l.type=="float"&&w2utils.isFloat(t)||l.type=="money"&&w2utils.isMoney(t)||l.type=="hex"&&w2utils.isHex(t)||l.type=="date"&&w2utils.isDate(t)||l.type=="alphaNumeric"&&w2utils.isAlphaNumeric(t)){var d={field:l.field,type:l.type,operator:l.type=="text"?"contains":"is",value:t};i.push(d)}if(l.type=="int"&&String(t).indexOf("-")!=-1){var m=String(t).split("-"),d={field:l.field,type:l.type,operator:"between",value:[m[0],m[1]]};i.push(d)}}else for(var g in this.columns){var d={field:this.columns[g].field,type:"text",operator:"contains",value:t};i.push(d)}else{var l=this.getSearch(e);l==null&&(l={field:e,type:"text"}),l.field==e&&(this.last.caption=l.caption);if(t!=""){var y="contains",b=t;w2utils.isInt(t)&&(y="is",b=t);if(l.type=="int"&&t!=""){if(String(t).indexOf("-")!=-1){var d=t.split("-");d.length==2&&(y="between",b=[parseInt(d[0]),parseInt(d[1])])}if(String(t).indexOf(",")!=-1){var d=t.split(",");y="in",b=[];for(var m in d)b.push(d[m])}}var d={field:l.field,type:l.type,operator:y,value:b};i.push(d)}}}if($.isArray(e)){var w="AND";typeof t=="string"&&(w=t.toUpperCase(),w!="OR"&&w!="AND"&&(w="AND")),a="",s=!0,o=w;for(var E in e){var S=e[E],l=this.getSearch(S.field);l==null&&(l={type:"text",operator:"contains"}),i.push($.extend(!0,{},l,S))}}var x=this.trigger({phase:"before",type:"search",target:this.name,searchData:i,searchField:e?e:"multi",searchValue:t?t:"multi"});if(x.isCancelled===!0)return;this.searchData=x.searchData,this.last.field=u,this.last.search=a,this.last.multi=s,this.last.logic=o,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selected=[],this.searchClose(),this.set({expanded:!1}),r?(this.last.xhr_offset=0,this.reload()):(this.localSearch(),this.refresh()),this.trigger($.extend(x,{phase:"after"}))},searchOpen:function(){if(!this.box)return;if(this.searches.length==0)return;var e=this;$("#tb_"+this.name+"_toolbar_item_search-advanced").w2overlay(this.getSearchesHTML(),{left:-10,"class":"w2ui-grid-searches",onShow:function(){e.last.logic=="OR"&&(e.searchData=[]),e.initSearches(),$("#w2ui-overlay .w2ui-grid-searches").data("grid-name",e.name);var t=$("#w2ui-overlay .w2ui-grid-searches *[rel=search]");t.length>0&&t[0].focus()}})},searchClose:function(){if(!this.box)return;if(this.searches.length==0)return;this.toolbar&&this.toolbar.uncheck("search-advanced"),$("#w2ui-overlay .w2ui-grid-searches").length>0&&$().w2overlay()},searchShowFields:function(e){typeof e=="undefined"&&(e=$("#grid_"+this.name+"_search_all"));var t='<div class="w2ui-select-field"><table>';for(var n=-1;n<this.searches.length;n++){var r=this.searches[n];if(n==-1){if(!this.multiSearch)continue;r={type:"text",field:"all",caption:w2utils.lang("All Fields")}}else if(this.searches[n].hidden===!0)continue;t+="<tr "+(this.isIOS?"onTouchStart":"onClick")+"=\"var obj = w2ui['"+this.name+"']; "+" if ('"+r.type+"' == 'list' || '"+r.type+"' == 'enum') {"+" obj.last.search = '';"+" obj.last.item = '';"+" $('#grid_"+this.name+"_search_all').val('')"+" }"+" if (obj.last.search != '') { "+" obj.search('"+r.field+"', obj.last.search); "+" } else { "+" obj.last.field = '"+r.field+"'; "+" obj.last.caption = '"+r.caption+"'; "+" }"+" $('#grid_"+this.name+"_search_all').attr('placeholder', '"+r.caption+"');"+' $().w2overlay();">'+'<td><input type="checkbox" tabIndex="-1" '+(r.field==this.last.field?"checked":"disabled")+"></td>"+"<td>"+r.caption+"</td>"+"</tr>"}t+="</table></div>",$(e).w2overlay(t,{left:-15,top:7})},searchReset:function(e){var t=this.trigger({phase:"before",type:"search",target:this.name,searchData:[]});if(t.isCancelled===!0)return;this.searchData=[],this.last.search="",this.last.logic="OR",this.last.multi&&(this.multiSearch?(this.last.field="all",this.last.caption=w2utils.lang("All Fields")):(this.last.field=this.searches[0].field,this.last.caption=this.searches[0].caption)),this.last.multi=!1,this.last.xhr_offset=0,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selected=[],this.searchClose(),e||this.reload(),this.trigger($.extend(t,{phase:"after"}))},clear:function(e){this.offset=0,this.total=0,this.buffered=0,this.records=[],this.summary=[],this.last.scrollTop=0,this.last.scrollLeft=0,this.last.range_start=null,this.last.range_end=null,this.last.xhr_offset=0,e||this.refresh()},reset:function(e){this.offset=0,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selected=[],this.last.range_start=null,this.last.range_end=null,this.last.xhr_offset=0,this.searchReset(e),this.last.sortData!=null&&(this.sortData=this.last.sortData),this.set({selected:!1,expanded:!1},!0),e||this.refresh()},skip:function(e){var t=typeof this.url!="object"?this.url:this.url.get;if(t){this.offset=parseInt(e);if(this.offset<0||!w2utils.isInt(this.offset))this.offset=0;this.offset>this.total&&(this.offset=this.total-this.limit),this.records=[],this.buffered=0,this.last.xhr_offset=0,this.last.pull_more=!0,this.last.scrollTop=0,this.last.scrollLeft=0,$("#grid_"+this.name+"_records").prop("scrollTop",0),this.initColumnOnOff(),this.reload()}else console.log("ERROR: grid.skip() can only be called when you have remote data source.")},load:function(e,t){if(typeof e=="undefined"){console.log('ERROR: You need to provide url argument when calling .load() method of "'+this.name+'" object.');return}this.request("get-records",{},e,t)},reload:function(e){var t=typeof this.url!="object"?this.url:this.url.get;t?(this.last.xhr_offset>0&&this.last.xhr_offset<this.buffered&&(this.last.xhr_offset=this.buffered),this.request("get-records",{},null,e)):(this.localSearch(),this.refresh(),typeof e=="function"&&e())},request:function(e,t,n,r){typeof t=="undefined"&&(t={});if(typeof n=="undefined"||n==""||n==null)n=this.url;if(n==""||n==null)return;var i={};w2utils.isInt(this.offset)||(this.offset=0),w2utils.isInt(this.last.xhr_offset)||(this.last.xhr_offset=0),i.cmd=e,i.name=this.name,i.limit=this.limit,i.offset=parseInt(this.offset)+this.last.xhr_offset,i.selected=this.getSelection(),i.search=this.searchData,i["search-logic"]=this.last.logic,i.sort=this.sortData.length!=0?this.sortData:"",$.extend(i,this.postData),$.extend(i,t);if(e=="get-records"){var s=this.trigger({phase:"before",type:"request",target:this.name,url:n,postData:i});if(s.isCancelled===!0)return typeof r=="function"&&r(),!1}else var s={url:this.url,postData:i};var o=this;this.lock(this.msgRefresh,!0);if(this.last.xhr)try{this.last.xhr.abort()}catch(u){}var a="GET",n=typeof s.url!="object"?s.url:s.url.get;i.cmd=="save-records"&&(typeof s.url=="object"&&(n=s.url.save),a="PUT"),i.cmd=="delete-records"&&(typeof s.url=="object"&&(n=s.url.remove),a="DELETE"),w2utils.settings.RESTfull||(a="POST"),this.last.xhr_cmd=i.cmd,this.last.xhr_start=(new Date).getTime(),this.last.xhr=$.ajax({type:a,url:n,data:String($.param(s.postData,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]"),dataType:"text",complete:function(t,n){o.requestComplete(n,e,r)}}),e=="get-records"&&this.trigger($.extend(s,{phase:"after"}))},requestComplete:function(status,cmd,callBack){var obj=this;this.unlock(),setTimeout(function(){obj.status(w2utils.lang("Server Response")+" "+((new Date).getTime()-obj.last.xhr_start)/1e3+" "+w2utils.lang("sec"))},10),this.last.pull_more=!1,this.last.pull_refresh=!0;var event_name="load";this.last.xhr_cmd=="save-records"&&(event_name="saved"),this.last.xhr_cmd=="delete-records"&&(event_name="deleted");var eventData=this.trigger({phase:"before",target:this.name,type:event_name,xhr:this.last.xhr,status:status});if(eventData.isCancelled===!0)return typeof callBack=="function"&&callBack(),!1;var responseText=this.last.xhr.responseText;if(status!="error"){if(typeof responseText!="undefined"&&responseText!=""){var data;if(typeof responseText=="object")data=responseText;else try{eval("data = "+responseText)}catch(e){}typeof data=="undefined"&&(data={status:"error",message:this.msgNotJSON,responseText:responseText});if(data["status"]=="error")obj.error(data.message);else{if(cmd=="get-records")if(this.last.xhr_offset==0)this.records=[],this.summary=[],delete data.status,$.extend(!0,this,data),this.buffered=this.records.length;else{var records=data.records;delete data.records,delete data.status,$.extend(!0,this,data);for(var r in records)this.records.push(records[r]);this.buffered=this.records.length}if(cmd=="delete-records"){this.reload();return}}}}else obj.error("AJAX Error. See console for more details.");var url=typeof this.url!="object"?this.url:this.url.get;url||(this.localSort(),this.localSearch()),this.total=parseInt(this.total),this.trigger($.extend(eventData,{phase:"after"})),this.last.xhr_offset==0?this.refresh():this.scroll(),typeof callBack=="function"&&callBack()},error:function(e){var t=this,n=this.trigger({target:this.name,type:"error",message:e,xhr:this.last.xhr});if(n.isCancelled===!0)return typeof callBack=="function"&&callBack(),!1;setTimeout(function(){w2alert(e,"Error")},1),this.trigger($.extend(n,{phase:"after"}))},getChanges:function(){var e=[],t=this.find({changed:!0});for(var n in t)e.push($.extend(!0,{recid:t[n].recid},t[n].changes));return e},mergeChanges:function(){var changed=this.getChanges();for(var c in changed){var record=this.get(changed[c].recid);for(var s in changed[c]){if(s=="recid")continue;try{eval("record."+s+" = changed[c][s]")}catch(e){}delete record.changed,delete record.changes}}$(this.box).find(".w2ui-editable input").removeClass("changed"),this.refresh()},save:function(){var e=this,t=this.getChanges(),n=this.trigger({phase:"before",target:this.name,type:"save",changed:t});if(n.isCancelled===!0)return!1;var r=typeof this.url!="object"?this.url:this.url.save;r?this.request("save-records",{changed:n.changed},null,function(){e.trigger($.extend(n,{phase:"after"}))}):(this.mergeChanges(),this.trigger($.extend(n,{phase:"after"})))},editField:function(e,t,n,r){var i=this,s=i.get(e,!0),o=i.records[s],u=i.columns[t],a=u.editable;if(!o||!u||!a)return;var f=i.trigger({phase:"before",type:"editField",target:i.name,recid:e,column:t,value:n,index:s,originalEvent:r});if(f.isCancelled===!0)return;n=f.value,this.selectNone(),this.select({recid:e,column:t});var l=$("#grid_"+i.name+"_rec_"+w2utils.escapeId(e)),c=l.find("[col="+t+"] > div");a.type=="enum"&&console.log("ERROR: Grid's inline editing does not support enum field type."),(a.type=="list"||a.type=="select")&&console.log("ERROR: Grid's inline editing does not support list/select field type."),typeof a.inTag=="undefined"&&(a.inTag=""),typeof a.outTag=="undefined"&&(a.outTag=""),typeof a.style=="undefined"&&(a.style=""),typeof a.items=="undefined"&&(a.items=[]);var h=o.changed&&o.changes[u.field]?w2utils.stripTags(o.changes[u.field]):w2utils.stripTags(o[u.field]);if(h==null||typeof h=="undefined")h="";typeof n!="undefined"&&n!=null&&(h=n);var p=typeof u.style!="undefined"?u.style+";":"";$.inArray(u.render,["number","int","float","money","percent"])!=-1&&(p+="text-align: right;"),c.addClass("w2ui-editable").html('<input id="grid_'+i.name+"_edit_"+e+"_"+t+'" value="'+h+'" type="text" '+' style="outline: none; '+p+a.style+'" field="'+u.field+'" recid="'+e+'" column="'+t+'" '+a.inTag+">"+a.outTag),c.find("input").w2field(a.type).on("blur",function(n){if(i.parseField(o,u.field)!=this.value){var r=i.trigger({phase:"before",type:"change",target:i.name,input_id:this.id,recid:e,column:t,value_new:this.value,value_previous:o.changes?o.changes[u.field]:i.parseField(o,u.field),value_original:i.parseField(o,u.field)});r.isCancelled!==!0&&(o.changed=!0,o.changes=o.changes||{},o.changes[u.field]=r.value_new,i.trigger($.extend(r,{phase:"after"})))}else o.changes&&delete o.changes[u.field],$.isEmptyObject(o.changes)&&delete o.changes;$(l).replaceWith(i.getRecordHTML(s,l.attr("line")))}).on("keydown",function(n){function l(e){var t=e+1;return i.columns.length==t?e:i.columns[t].hidden?l(t):t}function c(e){var t=e-1;return t<0?e:i.columns[t].hidden?c(t):t}function h(e){var t=e+1;return i.records.length==t?e:t}function p(e){var t=e-1;return t<0?e:t}var r=!1;switch(n.keyCode){case 9:r=!0;var a=n.shiftKey?c(t):l(t);a!=t&&(this.blur(),setTimeout(function(){i.selectType!="row"?(i.selectNone(),i.select({recid:e,column:a})):i.editField(e,a,null,n)},1));break;case 13:r=!0;var a=n.shiftKey?p(s):h(s);a!=s&&(this.blur(),setTimeout(function(){i.selectType!="row"?(i.selectNone(),i.select({recid:i.records[a].recid,column:t})):i.editField(i.records[a].recid,t,null,n)},1));break;case 38:r=!0;var a=p(s);a!=s&&(this.blur(),setTimeout(function(){i.selectType!="row"?(i.selectNone(),i.select({recid:i.records[a].recid,column:t})):i.editField(i.records[a].recid,t,null,n)},1));break;case 40:r=!0;var a=h(s);a!=s&&(this.blur(),setTimeout(function(){i.selectType!="row"?(i.selectNone(),i.select({recid:i.records[a].recid,column:t})):i.editField(i.records[a].recid,t,null,n)},1));break;case 27:var f=o.changed&&o.changes[u.field]?o.changes[u.field]:i.parseField(o,u.field);this.value=typeof f!="undefined"?f:"",this.blur(),setTimeout(function(){i.select({recid:e,column:t})},1)}r&&n.preventDefault&&n.preventDefault()}),typeof n=="undefined"||n==null?c.find("input").focus():c.find("input").val("").focus().val(n),i.trigger($.extend(f,{phase:"after"}))},"delete":function(e){var t=this,n=this.trigger({phase:"before",target:this.name,type:"delete",force:e});if(n.isCancelled===!0)return!1;e=n.force;var r=this.getSelection();if(r.length==0)return;if(this.msgDelete!=""&&!e){w2confirm(t.msgDelete,w2utils.lang("Delete Confirmation"),function(e){e=="Yes"&&w2ui[t.name].delete(!0)});return}var i=typeof this.url!="object"?this.url:this.url.remove;if(i)this.request("delete-records");else if(typeof r[0]!="object")this.remove.apply(this,r);else{for(var s in r){var o=this.columns[r[s].column].field,u=this.get(r[s].recid,!0);u!=null&&o!="recid"&&(this.records[u][o]="",this.records[u].changed&&(this.records[u].changes[o]=""))}this.refresh()}this.trigger($.extend(n,{phase:"after"}))},click:function(e,t){var n=(new Date).getTime(),r=null;typeof e=="object"&&(r=e.column,e=e.recid),w2utils.isInt(e)&&(e=parseInt(e)),typeof t=="undefined"&&(t={});if(n-parseInt(this.last.click_time)<250&&t.type=="click"){this.dblClick(e,t);return}this.last.click_time=n;if(r==null&&t.target){var i=t.target;i.tagName!="TD"&&(i=$(i).parents("td")[0]),typeof $(i).attr("col")!="undefined"&&(r=parseInt($(i).attr("col")))}var s=this.trigger({phase:"before",target:this.name,type:"click",recid:e,column:r,originalEvent:t});if(s.isCancelled===!0)return!1;var o=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(e)).parents("tr");if(o.length>0&&String(o.attr("id")).indexOf("expanded_row")!=-1){var u=o.parents(".w2ui-grid").attr("name");w2ui[u].selectNone(),o.parents(".w2ui-grid").find(".w2ui-expanded-row .w2ui-grid").each(function(e,t){var n=$(t).attr("name");w2ui[n]&&w2ui[n].selectNone()})}$(this.box).find(".w2ui-expanded-row .w2ui-grid").each(function(e,t){var n=$(t).attr("name");w2ui[n]&&w2ui[n].selectNone()});var a=this,f=this.getSelection();$("#grid_"+this.name+"_check_all").prop("checked",!1);var l=this.get(e,!0),c=this.records[l],h=[];a.last.sel_ind=l,a.last.sel_col=r,a.last.sel_recid=e,a.last.sel_type="click";if(t.shiftKey&&f.length>0){if(f[0].recid){var p=this.get(f[0].recid,!0),d=this.get(e,!0);if(r>f[0].column)var v=f[0].column,m=r;else var v=r,m=f[0].column;for(var g=v;g<=m;g++)h.push(g)}else var p=this.get(f[0],!0),d=this.get(e,!0);var y=[];if(p>d){var i=p;p=d,d=i}var b=typeof this.url!="object"?this.url:this.url.get;for(var w=p;w<=d;w++){if(this.searchData.length>0&&!b&&$.inArray(w,this.last.searchIds)==-1)continue;if(this.selectType=="row")y.push(this.records[w].recid);else for(var E in h)y.push({recid:this.records[w].recid,column:h[E]})}this.select.apply(this,y)}else if((!t.ctrlKey&&!t.shiftKey&&!t.metaKey||!this.multiSelect)&&!this.showSelectColumn){var S=c.selected;this.selectType!="row"&&$.inArray(r,c.selectedColumns)==-1&&(S=!1),f.length>300?this.selectNone():this.unselect.apply(this,f),S===!0?this.unselect({recid:e,column:r}):this.select({recid:e,column:r})}else{var S=c.selected;this.selectType!="row"&&$.inArray(r,c.selectedColumns)==-1&&(S=!1),S===!0?this.unselect(
{recid:e,column:r}):this.select({recid:c.recid,column:r}),setTimeout(function(){window.getSelection&&window.getSelection().removeAllRanges()},10)}this.status(),a.last.selected=this.getSelection(),a.initResize(),this.trigger($.extend(s,{phase:"after"}))},columnClick:function(e,t){var n=this.trigger({phase:"before",type:"columnClick",target:this.name,field:e,originalEvent:t});if(n.isCancelled===!0)return!1;this.sort(e,null,t&&(t.ctrlKey||t.metaKey)?!0:!1),this.trigger($.extend(n,{phase:"after"}))},keydown:function(e){function k(e){if(e+1<t.records.length&&t.last.searchIds.length==0||t.last.searchIds.length>0&&e<t.last.searchIds[t.last.searchIds.length-1]){e++;if(t.last.searchIds.length>0)for(;;){if($.inArray(e,t.last.searchIds)!=-1||e>t.records.length)break;e++}return e}return null}function L(e){if(e>0&&t.last.searchIds.length==0||t.last.searchIds.length>0&&e>t.last.searchIds[0]){e--;if(t.last.searchIds.length>0)for(;;){if($.inArray(e,t.last.searchIds)!=-1||e<0)break;e--}return e}return null}function A(e){var n=e+1;return t.columns.length==n?e:t.columns[n].hidden?findNext(n):n}function O(e){var n=e-1;return n<0?e:t.columns[n].hidden?findPrev(n):n}function M(){if(t.last.sel_type!="click")return!1;if(t.selectType!="row"){t.last.sel_type="key";if(r.length>1){for(var e in r)if(r[e].recid==t.last.sel_recid&&r[e].column==t.last.sel_col){r.splice(e,1);break}return t.unselect.apply(t,r),!0}return!1}return t.last.sel_type="key",r.length>1?(r.splice(r.indexOf(t.records[t.last.sel_ind].recid),1),t.unselect.apply(t,r),!0):!1}var t=this;if(t.keyboard!==!0)return;var n=t.trigger({phase:"before",type:"keydown",target:t.name,originalEvent:e});if(n.isCancelled===!0)return!1;var r=t.getSelection();if(r.length==0)return;var i=$("#grid_"+t.name+"_records"),s=r[0],o=[],u=r[r.length-1];if(typeof s=="object"){s=r[0].recid,o=[];var a=0;for(;;){if(!r[a]||r[a].recid!=s)break;o.push(r[a].column),a++}u=r[r.length-1].recid}var f=t.get(s,!0),l=t.get(u,!0),c=t.get(s),h=$("#grid_"+t.name+"_rec_"+w2utils.escapeId(t.records[f].recid)),p=!1;switch(e.keyCode){case 8:case 46:t.delete(),p=!0,e.stopPropagation();break;case 27:var r=t.getSelection();t.selectNone(),r.length>0&&(typeof r[0]=="object"?t.select({recid:r[0].recid,column:r[0].column}):t.select(r[0])),p=!0;break;case 13:case 32:o.length==0&&o.push(0),t.editField(s,o[0],null,e),p=!0;break;case 65:if(!e.metaKey&&!e.ctrlKey)break;t.selectAll(),p=!0;break;case 70:if(!e.metaKey&&!e.ctrlKey)break;$("#grid_"+t.name+"_search_all").focus(),p=!0;break;case 13:if(this.selectType=="row"){if(h.length<=0||t.show.expandColumn!==!0)break;t.toggle(s,e),p=!0}else o.length==0&&o.push(0),t.editField(s,o[0],null,e),p=!0;break;case 37:var d=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(t.records[f].recid)).parents("tr");if(d.length>0&&String(d.attr("id")).indexOf("expanded_row")!=-1){var s=d.prev().attr("recid"),v=d.parents(".w2ui-grid").attr("name");t.selectNone(),w2utils.keyboard.active(v),w2ui[v].set(s,{expanded:!1}),w2ui[v].collapse(s),w2ui[v].click(s),p=!0;break}if(this.selectType=="row"){if(h.length<=0||c.expanded!==!0)break;t.set(s,{expanded:!1},!0),t.collapse(s,e)}else{var m=O(o[0]);if(m!=o[0])if(e.shiftKey){if(M())return;var g=[],y=[],b=[];if(o.indexOf(this.last.sel_col)==0&&o.length>1)for(var w in r)g.indexOf(r[w].recid)==-1&&g.push(r[w].recid),b.push({recid:r[w].recid,column:o[o.length-1]});else for(var w in r)g.indexOf(r[w].recid)==-1&&g.push(r[w].recid),y.push({recid:r[w].recid,column:m});t.unselect.apply(t,b),t.select.apply(t,y)}else t.click({recid:s,column:m},e);else if(!e.shiftKey)for(var E=1;E<r.length;E++)t.unselect(r[E])}p=!0;break;case 9:case 39:if(this.selectType=="row"){if(h.length<=0||c.expanded===!0||t.show.expandColumn!==!0)break;t.expand(s,e)}else{var S=A(o[o.length-1]);if(S!=o[o.length-1])if(e.shiftKey&&e.keyCode==39){if(M())return;var g=[],y=[],b=[];if(o.indexOf(this.last.sel_col)==o.length-1&&o.length>1)for(var w in r)g.indexOf(r[w].recid)==-1&&g.push(r[w].recid),b.push({recid:r[w].recid,column:o[0]});else for(var w in r)g.indexOf(r[w].recid)==-1&&g.push(r[w].recid),y.push({recid:r[w].recid,column:S});t.unselect.apply(t,b),t.select.apply(t,y)}else t.click({recid:s,column:S},e);else if(!e.shiftKey)for(var E=0;E<r.length-1;E++)t.unselect(r[E])}p=!0;break;case 38:if(h.length<=0)break;var m=L(f);if(m!=null){if(t.records[m].expanded){var x=$("#grid_"+t.name+"_rec_"+w2utils.escapeId(t.records[m].recid)+"_expanded_row").find(".w2ui-grid");if(x.length>0&&w2ui[x.attr("name")]){t.selectNone();var v=x.attr("name"),T=w2ui[v].records;w2utils.keyboard.active(v),w2ui[v].click(T[T.length-1].recid),p=!0;break}}if(e.shiftKey){if(M())return;if(t.selectType=="row")t.last.sel_ind>m&&t.last.sel_ind!=l?t.unselect(t.records[l].recid):t.select(t.records[m].recid);else if(t.last.sel_ind>m&&t.last.sel_ind!=l){m=l;var g=[];for(var N in o)g.push({recid:t.records[m].recid,column:o[N]});t.unselect.apply(t,g)}else{var g=[];for(var N in o)g.push({recid:t.records[m].recid,column:o[N]});t.select.apply(t,g)}}else t.selectNone(),t.click({recid:t.records[m].recid,column:o[0]},e);t.scrollIntoView(m),e.preventDefault&&e.preventDefault()}else{if(!e.shiftKey)for(var E=1;E<r.length;E++)t.unselect(r[E]);var d=$("#grid_"+t.name+"_rec_"+w2utils.escapeId(t.records[f].recid)).parents("tr");if(d.length>0&&String(d.attr("id")).indexOf("expanded_row")!=-1){var s=d.prev().attr("recid"),v=d.parents(".w2ui-grid").attr("name");t.selectNone(),w2utils.keyboard.active(v),w2ui[v].click(s),p=!0;break}}break;case 40:if(h.length<=0)break;if(t.records[l].expanded){var x=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(t.records[l].recid)+"_expanded_row").find(".w2ui-grid");if(x.length>0&&w2ui[x.attr("name")]){t.selectNone();var v=x.attr("name"),T=w2ui[v].records;w2utils.keyboard.active(v),w2ui[v].click(T[0].recid),p=!0;break}}var S=k(l);if(S!=null){if(e.shiftKey){if(M())return;if(t.selectType=="row")this.last.sel_ind<S&&this.last.sel_ind!=f?t.unselect(t.records[f].recid):t.select(t.records[S].recid);else if(this.last.sel_ind<S&&this.last.sel_ind!=f){S=f;var g=[];for(var N in o)g.push({recid:t.records[S].recid,column:o[N]});t.unselect.apply(t,g)}else{var g=[];for(var N in o)g.push({recid:t.records[S].recid,column:o[N]});t.select.apply(t,g)}}else t.selectNone(),t.click({recid:t.records[S].recid,column:o[0]},e);t.scrollIntoView(S),p=!0}else{if(!e.shiftKey)for(var E=0;E<r.length-1;E++)t.unselect(r[E]);var d=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(t.records[l].recid)).parents("tr");if(d.length>0&&String(d.attr("id")).indexOf("expanded_row")!=-1){var s=d.next().attr("recid"),v=d.parents(".w2ui-grid").attr("name");t.selectNone(),w2utils.keyboard.active(v),w2ui[v].click(s),p=!0;break}}break;case 86:if(e.ctrlKey||e.metaKey)$("body").append('<textarea id="_tmp_copy_data" style="position: absolute; top: -100px; height: 1px;"></textarea>'),$("#_tmp_copy_data").focus(),setTimeout(function(){t.paste($("#_tmp_copy_data").val()),$("#_tmp_copy_data").remove()},50);break;case 88:(e.ctrlKey||e.metaKey)&&setTimeout(function(){t.delete(!0)},100);case 67:if(e.ctrlKey||e.metaKey){var C=t.copy();$("body").append('<textarea id="_tmp_copy_data" style="position: absolute; top: -100px; height: 1px;">'+C+"</textarea>"),$("#_tmp_copy_data").focus().select(),setTimeout(function(){$("#_tmp_copy_data").remove()},50)}}var g=[187,189];for(var w=48;w<=90;w++)g.push(w);if(g.indexOf(e.keyCode)!=-1&&!e.ctrlKey&&!e.metaKey&&!p){o.length==0&&o.push(0);var g=String.fromCharCode(e.keyCode);e.keyCode==187&&(g="="),e.keyCode==189&&(g="-"),e.shiftKey||(g=g.toLowerCase()),t.editField(s,o[0],g,e),p=!0}p&&e.preventDefault&&e.preventDefault(),t.trigger($.extend(n,{phase:"after"}))},scrollIntoView:function(e){if(typeof e=="undefined"){var t=this.getSelection();if(t.length==0)return;e=this.get(t[0],!0)}var n=$("#grid_"+this.name+"_records");if(n.length==0)return;var r=this.last.searchIds.length;if(n.height()>this.recordHeight*(r>0?r:this.records.length))return;r>0&&(e=this.last.searchIds.indexOf(e));var i=Math.floor(n[0].scrollTop/this.recordHeight),s=i+Math.floor(n.height()/this.recordHeight);e==i&&n.animate({scrollTop:n.scrollTop()-n.height()/1.3}),e==s&&n.animate({scrollTop:n.scrollTop()+n.height()/1.3}),(e<i||e>s)&&n.animate({scrollTop:(e-1)*this.recordHeight})},dblClick:function(e,t){window.getSelection&&window.getSelection().removeAllRanges();var n=null;typeof e=="object"&&(n=e.column,e=e.recid),typeof t=="undefined"&&(t={});if(n==null&&t.target){var r=t.target;r.tagName!="TD"&&(r=$(r).parents("td")[0]),n=parseInt($(r).attr("col"))}var i=this.trigger({phase:"before",target:this.name,type:"dblClick",recid:e,column:n,originalEvent:t});if(i.isCancelled===!0)return!1;this.selectNone();var s=this.columns[n];s&&$.isPlainObject(s.editable)?this.editField(e,n,null,t):(this.select({recid:e,column:n}),this.last.selected=this.getSelection()),this.trigger($.extend(i,{phase:"after"}))},toggle:function(e){var t=this.get(e);return t.expanded===!0?this.collapse(e):this.expand(e)},expand:function(e){function u(){var t=$("#grid_"+n.name+"_rec_"+r+"_expanded"),i=$("#grid_"+n.name+"_rec_"+r+"_expanded_row .w2ui-expanded1 > div");if(t.height()<5)return;t.css("opacity",1),i.show().css("opacity",1),$("#grid_"+n.name+"_cell_"+n.get(e,!0)+"_expand div").html("-")}var t=this.get(e),n=this,r=w2utils.escapeId(e);if($("#grid_"+this.name+"_rec_"+r+"_expanded_row").length>0)return!1;if(t.expanded=="none")return!1;var i=1+(this.show.selectColumn?1:0),s="";$("#grid_"+this.name+"_rec_"+r).after('<tr id="grid_'+this.name+"_rec_"+r+'_expanded_row" class="w2ui-expanded-row '+s+'">'+(this.show.lineNumbers?'<td class="w2ui-col-number"></td>':"")+' <td class="w2ui-grid-data w2ui-expanded1" colspan="'+i+'"><div style="display: none"></div></td>'+' <td colspan="100" class="w2ui-expanded2">'+' <div id="grid_'+this.name+"_rec_"+r+'_expanded" style="opacity: 0"></div>'+" </td>"+"</tr>");var o=this.trigger({phase:"before",type:"expand",target:this.name,recid:e,box_id:"grid_"+this.name+"_rec_"+r+"_expanded",ready:u});return o.isCancelled===!0?($("#grid_"+this.name+"_rec_"+r+"_expanded_row").remove(),!1):($("#grid_"+this.name+"_rec_"+r).attr("expanded","yes").addClass("w2ui-expanded"),$("#grid_"+this.name+"_rec_"+r+"_expanded_row").show(),$("#grid_"+this.name+"_cell_"+this.get(e,!0)+"_expand div").html('<div class="w2ui-spinner" style="width: 16px; height: 16px; margin: -2px 2px;"></div>'),t.expanded=!0,setTimeout(u,300),this.trigger($.extend(o,{phase:"after"})),this.resizeRecords(),!0)},collapse:function(e){var t=this.get(e),n=this,r=w2utils.escapeId(e);if($("#grid_"+this.name+"_rec_"+r+"_expanded_row").length==0)return!1;var i=this.trigger({phase:"before",type:"collapse",target:this.name,recid:e,box_id:"grid_"+this.name+"_rec_"+r+"_expanded"});return i.isCancelled===!0?!1:($("#grid_"+this.name+"_rec_"+r).removeAttr("expanded").removeClass("w2ui-expanded"),$("#grid_"+this.name+"_rec_"+r+"_expanded").css("opacity",0),$("#grid_"+this.name+"_cell_"+this.get(e,!0)+"_expand div").html("+"),setTimeout(function(){$("#grid_"+n.name+"_rec_"+r+"_expanded").height("0px"),setTimeout(function(){$("#grid_"+n.name+"_rec_"+r+"_expanded_row").remove(),delete t.expanded,n.trigger($.extend(i,{phase:"after"})),n.resizeRecords()},300)},200),!0)},sort:function(e,t,n){var r=this.trigger({phase:"before",type:"sort",target:this.name,field:e,direction:t,multiField:n});if(r.isCancelled===!0)return!1;if(typeof e!="undefined"){var i=this.sortData.length;for(var s in this.sortData)if(this.sortData[s].field==e){i=s;break}if(typeof t=="undefined"||t==null)if(typeof this.sortData[i]=="undefined")t="asc";else switch(String(this.sortData[i].direction)){case"asc":t="desc";break;case"desc":t="asc";break;default:t="asc"}this.multiSort===!1&&(this.sortData=[],i=0),n!=1&&(this.sortData=[],i=0),typeof this.sortData[i]=="undefined"&&(this.sortData[i]={}),this.sortData[i].field=e,this.sortData[i].direction=t}else this.sortData=[];var o=typeof this.url!="object"?this.url:this.url.get;o?(this.trigger($.extend(r,{phase:"after"})),this.last.xhr_offset=0,this.reload()):(this.localSort(),this.searchData.length>0&&this.localSearch(!0),this.trigger($.extend(r,{phase:"after"})),this.refresh())},copy:function(){var e=this.getSelection();if(e.length==0)return"";var t="";if(typeof e[0]=="object"){var n=e[0].column,r=e[0].column,i=[];for(var s in e)e[s].column<n&&(n=e[s].column),e[s].column>r&&(r=e[s].column),i.indexOf(e[s].index)==-1&&i.push(e[s].index);i.sort();for(var o in i){var u=i[o];for(var a=n;a<=r;a++){var f=this.columns[a];if(f.hidden===!0)continue;t+=w2utils.stripTags(this.getCellHTML(u,a))+" "}t=t.substr(0,t.length-1),t+="\n"}}else for(var s in e){var u=this.get(e[s],!0);for(var a in this.columns){var f=this.columns[a];if(f.hidden===!0)continue;t+=w2utils.stripTags(this.getCellHTML(u,a))+" "}t=t.substr(0,t.length-1),t+="\n"}t=t.substr(0,t.length-1);var l=this.trigger({phase:"before",type:"copy",target:this.name,text:t});return l.isCancelled===!0?"":(t=l.text,this.trigger($.extend(l,{phase:"after"})),t)},paste:function(e){var t=this.getSelection(),n=this.get(t[0].recid,!0),r=t[0].column,i=this.trigger({phase:"before",type:"paste",target:this.name,text:e,index:n,column:r});if(i.isCancelled===!0)return;e=i.text;if(this.selectType=="row"||t.length==0){console.log("ERROR: You can paste only if grid.selectType = 'cell' and when at least one cell selected."),this.trigger($.extend(i,{phase:"after"}));return}var s=[],e=e.split("\n");for(var o in e){var u=e[o].split(" "),a=0,f=this.records[n],l=[];for(var c in u){if(!this.columns[r+a])continue;var h=this.columns[r+a].field;f.changed=!0,f.changes=f.changes||{},f.changes[h]=u[c],l.push(r+a),a++}for(var p in l)s.push({recid:f.recid,column:l[p]});n++}this.selectNone(),this.select.apply(this,s),this.refresh(),this.trigger($.extend(i,{phase:"after"}))},resize:function(){var e=this,t=(new Date).getTime();window.getSelection&&window.getSelection().removeAllRanges();if(!this.box||$(this.box).attr("name")!=this.name)return;$(this.box).find("> div").css("width",$(this.box).width()).css("height",$(this.box).height());var n=this.trigger({phase:"before",type:"resize",target:this.name});return n.isCancelled===!0?!1:(e.resizeBoxes(),e.resizeRecords(),this.trigger($.extend(n,{phase:"after"})),(new Date).getTime()-t)},refresh:function(){var e=this,t=(new Date).getTime(),n=typeof this.url!="object"?this.url:this.url.get;this.total<=0&&!n&&this.searchData.length==0&&(this.total=this.records.length,this.buffered=this.total),window.getSelection&&window.getSelection().removeAllRanges(),this.toolbar.disable("edit","delete");if(!this.box)return;var r=this.trigger({phase:"before",target:this.name,type:"refresh"});if(r.isCancelled===!0)return!1;this.show.header?$("#grid_"+this.name+"_header").html(this.header+" ").show():$("#grid_"+this.name+"_header").hide();if(this.show.toolbar){if(!(this.toolbar&&this.toolbar.get("column-on-off")&&this.toolbar.get("column-on-off").checked)){$("#grid_"+this.name+"_toolbar").show();if(typeof this.toolbar=="object"){this.toolbar.refresh();var i=$("#grid_"+e.name+"_search_all");i.val(this.last.search)}}}else $("#grid_"+this.name+"_toolbar").hide();this.searchClose();var s=$("#grid_"+e.name+"_search_all");this.searches.length==0&&(this.last.field="all"),!this.multiSearch&&this.last.field=="all"&&this.searches.length>0&&(this.last.field=this.searches[0].field,this.last.caption=this.searches[0].caption);for(var o in this.searches)this.searches[o].field==this.last.field&&(this.last.caption=this.searches[o].caption);this.last.multi?s.attr("placeholder","["+w2utils.lang("Multiple Fields")+"]"):s.attr("placeholder",this.last.caption),this._focus_when_refreshed===!0&&(clearTimeout(e._focus_timer),e._focus_timer=setTimeout(function(){s.length>0&&s[0].focus(),delete e._focus_when_refreshed,delete e._focus_timer},600));var i=this.find({summary:!0},!0);if(i.length>0){for(var u in i)this.summary.push(this.records[i[u]]);for(var u=i.length-1;u>=0;u--)this.records.splice(i[u],1);this.total=this.total-i.length,this.buffered=this.buffered-i.length}var a="";a+='<div id="grid_'+this.name+'_records" class="w2ui-grid-records"'+" onscroll=\"var obj = w2ui['"+this.name+"']; "+" obj.last.scrollTop = this.scrollTop; "+" obj.last.scrollLeft = this.scrollLeft; "+" $('#grid_"+this.name+"_columns')[0].scrollLeft = this.scrollLeft;"+" $('#grid_"+this.name+"_summary')[0].scrollLeft = this.scrollLeft;"+' obj.scroll(event);">'+this.getRecordsHTML()+"</div>"+'<div id="grid_'+this.name+'_columns" class="w2ui-grid-columns">'+" <table>"+this.getColumnsHTML()+"</table>"+"</div>",$("#grid_"+this.name+"_body").html(a),this.summary.length>0?$("#grid_"+this.name+"_summary").html(this.getSummaryHTML()).show():$("#grid_"+this.name+"_summary").hide(),this.show.footer?$("#grid_"+this.name+"_footer").html(this.getFooterHTML()).show():$("#grid_"+this.name+"_footer").hide();if(this.last.selected.length>0)for(var o in this.last.selected)this.get(this.last.selected[o])!=null&&this.select(this.get(this.last.selected[o]).recid);this.searchData.length>0?$("#grid_"+this.name+"_searchClear").show():$("#grid_"+this.name+"_searchClear").hide(),$("#grid_"+this.name+"_check_all").prop("checked",!0),$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length!=0&&$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length==$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]:checked").length?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status();var f=e.find({expanded:!0},!0);for(var l in f)e.records[f[l]].expanded=!1;return setTimeout(function(){var t=$.trim($("#grid_"+e.name+"_search_all").val());t!=""&&$(e.box).find(".w2ui-grid-data > div").w2marker(t)},50),this.trigger($.extend(r,{phase:"after"})),e.resize(),e.addRange("selection"),setTimeout(function(){e.resize(),e.scroll()},1),(new Date).getTime()-t},render:function(e){function i(e){if(t.last.move&&t.last.move.type=="expand")return;t.last.move={x:e.screenX,y:e.screenY,divX:0,divY:0,recid:$(e.target).parents("tr").attr("recid"),column:e.target.tagName=="TD"?$(e.target).attr("col"):$(e.target).parents("td").attr("col"),type:"select",start:!0},$(document).on("mousemove",s),$(document).on("mouseup",o)}function s(e){if(!t.last.move||t.last.move.type!="select")return;t.last.move.divX=e.screenX-t.last.move.x,t.last.move.divY=e.screenY-t.last.move.y;if(Math.abs(t.last.move.divX)<=1&&Math.abs(t.last.move.divY)<=1)return;t.last.move.start&&(t.selectNone(),t.last.move.start=!1);var n=[],r=e.target.tagName=="TR"?$(e.target).attr("recid"):$(e.target).parents("tr").attr("recid");if(typeof r=="undefined")return;var i=t.get(t.last.move.recid,!0),s=t.get(r,!0),o=parseInt(t.last.move.column),u=parseInt(e.target.tagName=="TD"?$(e.target).attr("col"):$(e.target).parents("td").attr("col"));if(i>s){var a=i;i=s,s=a}var a="ind1:"+i+",ind2;"+s+",col1:"+o+",col2:"+u;if(t.last.move.range==a)return;t.last.move.range=a;for(var f=i;f<=s;f++){if(t.last.searchIds.length>0&&t.last.searchIds.indexOf(f)==-1)continue;if(t.selectType!="row"){if(o>u){var a=o;o=u,u=a}var a=[];for(var l=o;l<=u;l++){if(t.columns[l].hidden)continue;n.push({recid:t.records[f].recid,column:parseInt(l)})}}else n.push(t.records[f].recid)}if(t.selectType!="row"){var c=t.getSelection(),a=[];for(var h in n){var p=!1;for(var d in c)n[h].recid==c[d].recid&&n[h].column==c[d].column&&(p=!0);p||a.push({recid:n[h].recid,column:n[h].column})}t.select.apply(t,a);var a=[];for(var d in c){var p=!1;for(var h in n)n[h].recid==c[d].recid&&n[h].column==c[d].column&&(p=!0);p||a.push({recid:c[d].recid,column:c[d].column})}t.unselect.apply(t,a)}else if(t.multiSelect){var c=t.getSelection();for(var h in n)c.indexOf(n[h])==-1&&t.select(n[h]);for(var d in c)n.indexOf(c[d])==-1&&t.unselect(c[d])}}function o(e){if(!t.last.move||t.last.move.type!="select")return;delete t.last.move,$(document).off("mousemove",s),$(document).off("mouseup",o)}var t=this,n=(new Date).getTime();window.getSelection&&window.getSelection().removeAllRanges(),typeof e!="undefined"&&e!=null&&($(this.box).find("#grid_"+this.name+"_body").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-grid").html(""),this.box=e);if(!this.box)return;this.last.sortData==null&&(this.last.sortData=this.sortData);var r=this.trigger({phase:"before",target:this.name,type:"render",box:e});return r.isCancelled===!0?!1:($(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-grid").html('<div> <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+'_summary" class="w2ui-grid-body w2ui-grid-summary"></div>'+' <div id="grid_'+this.name+'_footer" class="w2ui-grid-footer"></div>'+"</div>"),this.selectType!="row"&&$(this.box).addClass("w2ui-ss"),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.initToolbar(),this.toolbar!=null&&this.toolbar.render($("#grid_"+this.name+"_toolbar")[0]),$("#grid_"+this.name+"_footer").html(this.getFooterHTML()),this.refresh(),this.reload(),$(this.box).on("mousedown",i),$(this.box).on("selectstart",function(){return!1}),this.trigger($.extend(r,{phase:"after"})),$(".w2ui-layout").length==0&&(this.tmp_resize=function(e){w2ui[t.name].resize()},$(window).off("resize",this.tmp_resize).on("resize",this.tmp_resize)),(new Date).getTime()-n)},destroy:function(){var e=this.trigger({phase:"before",target:this.name,type:"destroy"});if(e.isCancelled===!0)return!1;$(window).off("resize",this.tmp_resize),typeof this.toolbar=="object"&&this.toolbar.destroy&&this.toolbar.destroy(),$(this.box).find("#grid_"+this.name+"_body").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-grid").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"}))},initColumnOnOff:function(){if(!this.show.toolbarColumns)return;var e=this,t='<div class="w2ui-col-on-off"><table>';for(var n in this.columns){var r=this.columns[n];t+='<tr><td> <input id="grid_'+this.name+"_column_"+n+'_check" type="checkbox" tabIndex="-1" '+(r.hidden?"":"checked")+" onclick=\"w2ui['"+e.name+"'].columnOnOff(this, event, '"+r.field+"');\">"+"</td>"+"<td>"+' <label for="grid_'+this.name+"_column_"+n+'_check">'+(this.columns[n].caption==""?"- column "+(n+1)+" -":this.columns[n].caption)+"</label>"+"</td>"+"</tr>"}t+='<tr><td colspan="2"><div style="border-top: 1px solid #ddd;"></div></td></tr>';var i=typeof this.url!="object"?this.url:this.url.get;i&&(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: 45px" value="'+this.offset+'" '+" onchange=\"w2ui['"+e.name+"'].columnOnOff(this, event, 'skip', this.value);\"> "+w2utils.lang("Records")+" </div>"+"</td></tr>"),t+='<tr><td colspan="2" onclick="w2ui[\''+e.name+"'].columnOnOff(this, event, 'line-numbers');\">"+' <div style="cursor: pointer; padding: 4px 8px; cursor: default">'+w2utils.lang("Toggle Line Numbers")+"</div>"+"</td></tr>"+'<tr><td colspan="2" onclick="w2ui[\''+e.name+"'].columnOnOff(this, event, 'resize');\">"+' <div style="cursor: pointer; padding: 4px 8px; cursor: default">'+w2utils.lang("Reset Column Size")+"</div>"+"</td></tr>",t+="</table></div>",this.toolbar.get("column-on-off").html=t},columnOnOff:function(e,t,n,r){var i=this.trigger({phase:"before",target:this.name,type:"columnOnOff",checkbox:e,field:n,originalEvent:t});if(i.isCancelled===!0)return!1;var s=this;for(var o in this.records)this.records[o].expanded===!0&&(this.records[o].expanded=!1);var u=!0;if(n=="line-numbers")this.show.lineNumbers=!this.show.lineNumbers,this.refresh();else if(n=="skip")w2utils.isInt(r)||(r=0),s.skip(r);else if(n=="resize"){for(var a in this.columns)typeof this.columns[a].sizeOriginal!="undefined"&&(this.columns[a].size=this.columns[a].sizeOriginal);this.initResize(),this.resize()}else{var f=this.getColumn(n);f.hidden?($(e).prop("checked",!0),this.showColumn(f.field)):($(e).prop("checked",!1),this.hideColumn(f.field)),u=!1}this.initColumnOnOff(),u&&setTimeout(function(){$().w2overlay(),s.toolbar.uncheck("column-on-off")},100),this.trigger($.extend(i,{phase:"after"}))},initToolbar:function(){if(typeof this.toolbar["render"]=="undefined"){var e=this.toolbar.items;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.initColumnOnOff()),(this.show.toolbarReload||this.show.toolbarColumn)&&this.toolbar.items.push({type:"break",id:"break0"});if(this.show.toolbarSearch){var t='<div class="w2ui-toolbar-search"><table cellpadding="0" cellspacing="0"><tr> <td>'+this.buttons.search.html+"</td>"+" <td>"+' <input id="grid_'+this.name+'_search_all" class="w2ui-search-all" '+' placeholder="'+this.last.caption+'" value="'+this.last.search+'"'+' onkeyup="if (event.keyCode == 13) { '+" w2ui['"+this.name+"']._focus_when_refreshed = true; "+" w2ui['"+this.name+"'].search(w2ui['"+this.name+"'].last.field, this.value); "+' }">'+" </td>"+" <td>"+' <div title="'+w2utils.lang("Clear Search")+'" class="w2ui-search-clear" id="grid_'+this.name+'_searchClear" '+" onclick=\"var obj = w2ui['"+this.name+"']; obj.searchReset();\" "+" > </div>"+" </td>"+"</tr></table>"+"</div>";this.toolbar.items.push({type:"html",id:"search",html:t}),this.multiSearch&&this.searches.length>0&&this.toolbar.items.push($.extend(!0,{},this.buttons["search-go"]))}this.show.toolbarSearch&&(this.show.toolbarAdd||this.show.toolbarEdit||this.show.toolbarDelete||this.show.toolbarSave)&&this.toolbar.items.push({type:"break",id:"break1"}),this.show.toolbarAdd&&this.toolbar.items.push($.extend(!0,{},this.buttons.add)),this.show.toolbarEdit&&this.toolbar.items.push($.extend(!0,{},this.buttons.edit)),this.show.toolbarDelete&&this.toolbar.items.push($.extend(!0,{},this.buttons["delete"])),this.show.toolbarSave&&((this.show.toolbarAdd||this.show.toolbarDelete||this.show.toolbarEdit)&&this.toolbar.items.push({type:"break",id:"break2"}),this.toolbar.items.push($.extend(!0,{},this.buttons.save)));for(var n in e)this.toolbar.items.push(e[n]);var r=this;this.toolbar.on("click",function(e){var t=r.trigger({phase:"before",type:"toolbar",target:e.target,originalEvent:e});if(t.isCancelled===!0)return!1;var n=e.target;switch(n){case"reload":var i=r.trigger({phase:"before",type:"reload",target:r.name});if(i.isCancelled===!0)return!1;var s=typeof r.url!="object"?r.url:r.url.get;s?r.clear(!0):(r.last.scrollTop=0,r.last.scrollLeft=0,r.last.range_start=null,r.last.range_end=null),r.reload(),r.trigger($.extend(i,{phase:"after"}));break;case"column-on-off":for(var o in r.columns)r.columns[o].hidden?$("#grid_"+r.name+"_column_"+o+"_check").prop("checked",!1):$("#grid_"+r.name+"_column_"+o+"_check").prop("checked",!0);r.initResize(),r.resize();break;case"search-advanced":var u=this,a=this.get(n);if(a.checked)r.searchClose(),setTimeout(function(){u.uncheck(n)},1);else{r.searchOpen(),e.originalEvent.stopPropagation();function f(){u.uncheck(n),$(document).off("click","body",f)}$(document).on("click","body",f)}break;case"add":var t=r.trigger({phase:"before",target:r.name,type:"add",recid:null});r.trigger($.extend(t,{phase:"after"}));break;case"edit":var l=r.getSelection(),c=null;l.length==1&&(c=l[0]);var t=r.trigger({phase:"before",target:r.name,type:"edit",recid:c});r.trigger($.extend(t,{phase:"after"}));break;case"delete":r.delete();break;case"save":r.save()}r.trigger($.extend(t,{phase:"after"}))})}return},initSearches:function(){var e=this;for(var t in this.searches){var n=this.searches[t],r=this.getSearchData(n.field);switch(String(n.type).toLowerCase()){case"alphaNumeric":case"text":$("#grid_"+this.name+"_operator_"+t).val("begins with");break;case"int":case"float":case"hex":case"money":case"date":$("#grid_"+this.name+"_field_"+t).w2field("clear").w2field(n.type),$("#grid_"+this.name+"_field2_"+t).w2field("clear").w2field(n.type);break;case"list":var i='<option value="">--</option>';for(var s in n.items)if($.isPlainObject(n.items[s])){var o=n.items[s].id,u=n.items[s].text;typeof o=="undefined"&&typeof n.items[s].value!="undefined"&&(o=n.items[s].value),typeof u=="undefined"&&typeof n.items[s].caption!="undefined"&&(u=n.items[s].caption),o==null&&(o=""),i+='<option value="'+o+'">'+u+"</option>"}else i+='<option value="'+n.items[s]+'">'+n.items[s]+"</option>";$("#grid_"+this.name+"_field_"+t).html(i)}r!=null&&($("#grid_"+this.name+"_operator_"+t).val(r.operator).trigger("change"),$.isArray(r.value)?r.operator=="in"?$("#grid_"+this.name+"_field_"+t).val(r.value).trigger("change"):($("#grid_"+this.name+"_field_"+t).val(r.value[0]).trigger("change"),$("#grid_"+this.name+"_field2_"+t).val(r.value[1]).trigger("change")):typeof r.value!="udefined"&&$("#grid_"+this.name+"_field_"+t).val(r.value).trigger("change"))}$("#w2ui-overlay .w2ui-grid-searches *[rel=search]").on("keypress",function(t){t.keyCode==13&&e.search()})},initResize:function(){var e=this;$(this.box).find(".w2ui-resizer").off("click").on("click",function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,e.preventDefault&&e.preventDefault()}).off("mousedown").on("mousedown",function(t){t||(t=window.event),window.addEventListener||window.document.attachEvent("onselectstart",function(){return!1}),e.resizing=!0,e.last.tmp={x:t.screenX,y:t.screenY,gx:t.screenX,gy:t.screenY,col:parseInt($(this).attr("name"))},t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,t.preventDefault&&t.preventDefault();for(var n in e.columns)typeof e.columns[n].sizeOriginal=="undefined"&&(e.columns[n].sizeOriginal=e.columns[n].size),e.columns[n].size=e.columns[n].sizeCalculated;var r={phase:"before",type:"columnResize",target:e.name,column:e.last.tmp.col,field:e.columns[e.last.tmp.col].field};r=e.trigger($.extend(r,{resizeBy:0,originalEvent:t}));var i=function(t){if(e.resizing!=1)return;t||(t=window.event),r=e.trigger($.extend(r,{resizeBy:t.screenX-e.last.tmp.gx,originalEvent:t}));if(r.isCancelled===!0){r.isCancelled=!1;return}e.last.tmp.x=t.screenX-e.last.tmp.x,e.last.tmp.y=t.screenY-e.last.tmp.y,e.columns[e.last.tmp.col].size=parseInt(e.columns[e.last.tmp.col].size)+e.last.tmp.x+"px",e.resizeRecords(),e.last.tmp.x=t.screenX,e.last.tmp.y=t.screenY},s=function(t){delete e.resizing,$(document).off("mousemove","body"),$(document).off("mouseup","body"),e.resizeRecords(),e.trigger($.extend(r,{phase:"after",originalEvent:t}))};$(document).on("mousemove","body",i),$(document).on("mouseup","body",s)}).each(function(e,t){var n=$(t).parent();$(t).css({height:"25px","margin-left":n.width()-3+"px"})})},resizeBoxes:function(){var e=$(this.box).find("> div"),t=$("#grid_"+this.name+"_header"),n=$("#grid_"+this.name+"_toolbar"),r=$("#grid_"+this.name+"_summary"),i=$("#grid_"+this.name+"_footer"),s=$("#grid_"+this.name+"_body"),o=$("#grid_"+this.name+"_columns"),u=$("#grid_"+this.name+"_records");this.show.header&&t.css({top:"0px",left:"0px",right:"0px"}),this.show.toolbar&&n.css({top:0+(this.show.header?w2utils.getSize(t,"height"):0)+"px",left:"0px",right:"0px"}),this.show.footer&&i.css({bottom:"0px",left:"0px",right:"0px"}),this.summary.length>0&&r.css({bottom:0+(this.show.footer?w2utils.getSize(i,"height"):0)+"px",left:"0px",right:"0px"}),s.css({top:0+(this.show.header?w2utils.getSize(t,"height"):0)+(this.show.toolbar?w2utils.getSize(n,"height"):0)+"px",bottom:0+(this.show.footer?w2utils.getSize(i,"height"):0)+(this.summary.length>0?w2utils.getSize(r,"height"):0)+"px",left:"0px",right:"0px"})},resizeRecords:function(){var e=this;$(this.box).find(".w2ui-empty-record").remove();var t=$(this.box),n=$(this.box).find("> div"),r=$("#grid_"+this.name+"_header"),i=$("#grid_"+this.name+"_toolbar"),s=$("#grid_"+this.name+"_summary"),o=$("#grid_"+this.name+"_footer"),u=$("#grid_"+this.name+"_body"),a=$("#grid_"+this.name+"_columns"),f=$("#grid_"+this.name+"_records");if(!this.fixedBody)setTimeout(function(){var f=w2utils.getSize(a,"height")+w2utils.getSize($("#grid_"+e.name+"_records table"),"height");e.height=f+w2utils.getSize(n,"+height")+(e.show.header?w2utils.getSize(r,"height"):0)+(e.show.toolbar?w2utils.getSize(i,"height"):0)+(s.css("display")!="none"?w2utils.getSize(s,"height"):0)+(e.show.footer?w2utils.getSize(o,"height"):0),n.css("height",e.height),u.css("height",f),t.css("height",w2utils.getSize(n,"height")+w2utils.getSize(t,"+height"))},1);else{var l=n.height()-(this.show.header?w2utils.getSize(r,"height"):0)-(this.show.toolbar?w2utils.getSize(i,"height"):0)-(s.css
("display")!="none"?w2utils.getSize(s,"height"):0)-(this.show.footer?w2utils.getSize(o,"height"):0);u.css("height",l)}var c=!1,h=!1;u.width()<$(f).find(">table").width()&&(c=!0),u.height()-a.height()<$(f).find(">table").height()+(c?w2utils.scrollBarSize():0)&&(h=!0),this.fixedBody||(h=!1,c=!1),c||h?(a.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show(),f.css({top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(a,"height")+"px","-webkit-overflow-scrolling":"touch","overflow-x":c?"auto":"hidden","overflow-y":h?"auto":"hidden"})):(a.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").hide(),f.css({top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(a,"height")+"px",overflow:"hidden"}),f.length>0&&(this.last.scrollTop=0,this.last.scrollLeft=0));if(this.show.emptyRecords&&!h){var p=Math.floor(f.height()/this.recordHeight)+1;if(this.fixedBody)for(var d=this.buffered;d<=p;d++){var v="";v+='<tr class="'+(d%2?"w2ui-even":"w2ui-odd")+' w2ui-empty-record" style="height: '+this.recordHeight+'px">',this.show.lineNumbers&&(v+='<td class="w2ui-col-number"></td>'),this.show.selectColumn&&(v+='<td class="w2ui-grid-data w2ui-col-select"></td>'),this.show.expandColumn&&(v+='<td class="w2ui-grid-data w2ui-col-expand"></td>');var m=0;while(this.columns.length>0){var g=this.columns[m];if(g.hidden){m++;if(typeof this.columns[m]=="undefined")break;continue}v+='<td class="w2ui-grid-data" '+(typeof g.attr!="undefined"?g.attr:"")+' col="'+m+'"></td>',m++;if(typeof this.columns[m]=="undefined")break}v+='<td class="w2ui-grid-data-last"></td>',v+="</tr>",$("#grid_"+this.name+"_records > table").append(v)}}if(u.length>0){var y=parseInt(u.width())-(h?w2utils.scrollBarSize():0)-(this.show.lineNumbers?34:0)-(this.show.selectColumn?26:0)-(this.show.expandColumn?26:0),b=y,w=0,E=!1;for(var S=0;S<this.columns.length;S++){var g=this.columns[S];typeof g.gridMinWidth!="undefined"&&(g.gridMinWidth>b&&g.hidden!==!0&&(g.hidden=!0,E=!0),g.gridMinWidth<b&&g.hidden===!0&&(g.hidden=!1,E=!0))}if(E===!0){this.refresh();return}for(var S=0;S<this.columns.length;S++){var g=this.columns[S];if(g.hidden)continue;String(g.size).substr(String(g.size).length-2).toLowerCase()=="px"?(y-=parseFloat(g.size),this.columns[S].sizeCalculated=g.size,this.columns[S].sizeType="px"):(w+=parseFloat(g.size),this.columns[S].sizeType="%",delete g.sizeCorrected)}if(w!=100&&w>0)for(var S=0;S<this.columns.length;S++){var g=this.columns[S];if(g.hidden)continue;g.sizeType=="%"&&(g.sizeCorrected=Math.round(parseFloat(g.size)*100*100/w)/100+"%")}for(var S=0;S<this.columns.length;S++){var g=this.columns[S];if(g.hidden)continue;g.sizeType=="%"&&(typeof this.columns[S].sizeCorrected!="undefined"?this.columns[S].sizeCalculated=Math.floor(y*parseFloat(g.sizeCorrected)/100)-1+"px":this.columns[S].sizeCalculated=Math.floor(y*parseFloat(g.size)/100)-1+"px")}}var x=0;for(var S=0;S<this.columns.length;S++){var g=this.columns[S];if(g.hidden)continue;typeof g.min=="undefined"&&(g.min=20),parseInt(g.sizeCalculated)<parseInt(g.min)&&(g.sizeCalculated=g.min+"px"),parseInt(g.sizeCalculated)>parseInt(g.max)&&(g.sizeCalculated=g.max+"px"),x+=parseInt(g.sizeCalculated)}var T=parseInt(b)-parseInt(x);if(T>0&&w>0){var S=0;for(;;){var g=this.columns[S];if(typeof g=="undefined"){S=0;continue}if(g.hidden||g.sizeType=="px"){S++;continue}g.sizeCalculated=parseInt(g.sizeCalculated)+1+"px",T--;if(T==0)break;S++}}else T>0&&a.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show();a.find("> table > tbody > tr:nth-child(1) td").each(function(t,n){var r=$(n).attr("col");typeof r!="undefined"&&e.columns[r]&&$(n).css("width",e.columns[r].sizeCalculated),$(n).hasClass("w2ui-head-last")&&$(n).css("width",w2utils.scrollBarSize()+(T>0&&w==0?T:0)+"px")}),a.find("> table > tbody > tr").length==3&&a.find("> table > tbody > tr:nth-child(1) td").html("").css({height:"0px",border:"0px",padding:"0px",margin:"0px"}),f.find("> table > tbody > tr:nth-child(1) td").each(function(t,n){var r=$(n).attr("col");typeof r!="undefined"&&e.columns[r]&&$(n).css("width",e.columns[r].sizeCalculated),$(n).hasClass("w2ui-grid-data-last")&&$(n).css("width",(T>0&&w==0?T:0)+"px")}),s.find("> table > tbody > tr:nth-child(1) td").each(function(t,n){var r=$(n).attr("col");typeof r!="undefined"&&e.columns[r]&&$(n).css("width",e.columns[r].sizeCalculated),$(n).hasClass("w2ui-grid-data-last")&&$(n).css("width",w2utils.scrollBarSize()+(T>0&&w==0?T:0)+"px")}),this.initResize(),this.refreshRanges(),this.last.scrollTop!=""&&f.length>0&&(a.prop("scrollLeft",this.last.scrollLeft),f.prop("scrollTop",this.last.scrollTop),f.prop("scrollLeft",this.last.scrollLeft))},getSearchesHTML:function(){var e='<table cellspacing="0">',t=!1;for(var n=0;n<this.searches.length;n++){var r=this.searches[n];if(r.hidden)continue;var i="";t==0&&(i='<input type="button" value="X" onclick="obj = w2ui[\''+this.name+"']; if (obj) { obj.searchClose(); }\">",t=!0),typeof r.inTag=="undefined"&&(r.inTag=""),typeof r.outTag=="undefined"&&(r.outTag=""),typeof r.type=="undefined"&&(r.type="text");if(r.type=="text")var s='<select id="grid_'+this.name+"_operator_"+n+'">'+' <option value="is">'+w2utils.lang("is")+"</option>"+' <option value="begins with">'+w2utils.lang("begins with")+"</option>"+' <option value="contains">'+w2utils.lang("contains")+"</option>"+' <option value="ends with">'+w2utils.lang("ends with")+"</option>"+"</select>";if(r.type=="int"||r.type=="float"||r.type=="date")var s='<select id="grid_'+this.name+"_operator_"+n+'" '+" onchange=\"var range = $('#grid_"+this.name+"_range_"+n+"'); range.hide(); "+" var fld = $('#grid_"+this.name+"_field_"+n+"'); "+" var fld2 = fld.parent().find('span input'); "+" if ($(this).val() == 'in') fld.w2field('clear'); else fld.w2field('clear').w2field('"+r.type+"');"+" if ($(this).val() == 'between') { range.show(); fld2.w2field('clear').w2field('"+r.type+"'); }"+" var obj = w2ui['"+this.name+"'];"+" fld.on('keypress', function (evnt) { if (evnt.keyCode == 13) obj.search(); }); "+" fld2.on('keypress', function (evnt) { if (evnt.keyCode == 13) obj.search(); }); "+' ">'+' <option value="is">'+w2utils.lang("is")+"</option>"+(r.type=="date"?"":'<option value="in">'+w2utils.lang("in")+"</option>")+' <option value="between">'+w2utils.lang("between")+"</option>"+"</select>";if(r.type=="list")var s='is <input type="hidden" value="is" id="grid_'+this.name+"_operator_"+n+'">';e+='<tr> <td class="close-btn">'+i+"</td>"+' <td class="caption">'+r.caption+"</td>"+' <td class="operator">'+s+"</td>"+' <td class="value">';switch(r.type){case"alphaNumeric":case"text":e+='<input rel="search" type="text" size="40" id="grid_'+this.name+"_field_"+n+'" name="'+r.field+'" '+r.inTag+">";break;case"int":case"float":case"hex":case"money":case"date":e+='<input rel="search" type="text" size="12" id="grid_'+this.name+"_field_"+n+'" name="'+r.field+'" '+r.inTag+">"+'<span id="grid_'+this.name+"_range_"+n+'" style="display: none">'+' - <input rel="search" type="text" size="12" id="grid_'+this.name+"_field2_"+n+'" name="'+r.field+'" '+r.inTag+">"+"</span>";break;case"list":e+='<select rel="search" id="grid_'+this.name+"_field_"+n+'" name="'+r.field+'" '+r.inTag+"></select>"}e+=r.outTag+" </td>"+"</tr>"}return e+='<tr> <td colspan="4" class="actions"> <div> <input type="button" onclick="obj = w2ui[\''+this.name+'\']; if (obj) { obj.searchReset(); }" value="'+w2utils.lang("Reset")+'">'+' <input type="button" onclick="obj = w2ui[\''+this.name+'\']; if (obj) { obj.search(); }" value="'+w2utils.lang("Search")+'">'+" </div>"+" </td>"+"</tr></table>",e},getColumnsHTML:function(){function n(){var t="<tr>";e.columnGroups[e.columnGroups.length-1].caption!=""&&e.columnGroups.push({caption:""}),e.show.lineNumbers&&(t+='<td class="w2ui-head w2ui-col-number"> <div> </div></td>'),e.show.selectColumn&&(t+='<td class="w2ui-head w2ui-col-select"> <div> </div></td>'),e.show.expandColumn&&(t+='<td class="w2ui-head w2ui-col-expand"> <div> </div></td>');var n=0;for(var r=0;r<e.columnGroups.length;r++){var i=e.columnGroups[r],s=e.columns[n];if(typeof i.span=="undefined"||i.span!=parseInt(i.span))i.span=1;typeof i.colspan!="undefined"&&(i.span=i.colspan);if(i.master===!0){var o="";for(var u in e.sortData)e.sortData[u].field==s.field&&(e.sortData[u].direction=="asc"&&(o="w2ui-sort-down"),e.sortData[u].direction=="desc"&&(o="w2ui-sort-up"));var a="";s.resizable==1&&(a='<div class="w2ui-resizer" name="'+n+'"></div>'),t+='<td class="w2ui-head '+o+'" col="'+n+'" rowspan="2" colspan="'+(i.span+(r==e.columnGroups.length-1?1:0))+'" '+(s.sortable?"onclick=\"w2ui['"+e.name+"'].columnClick('"+s.field+"', event);\"":"")+">"+a+' <div class="w2ui-col-group '+o+'">'+(s.caption==""?" ":s.caption)+" </div>"+"</td>"}else t+='<td class="w2ui-head" col="'+n+'" '+' colspan="'+(i.span+(r==e.columnGroups.length-1?1:0))+'">'+' <div class="w2ui-col-group">'+(i.caption==""?" ":i.caption)+" </div>"+"</td>";n+=i.span}return t+="</tr>",t}function r(t){var n="<tr>";e.show.lineNumbers&&(n+='<td class="w2ui-head w2ui-col-number" onclick="w2ui[\''+e.name+"'].columnClick('line-number', event);\">"+" <div>#</div>"+"</td>"),e.show.selectColumn&&(n+='<td class="w2ui-head w2ui-col-select" onclick="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;"> <div> <input type="checkbox" id="grid_'+e.name+'_check_all" tabIndex="-1"'+' style="'+(e.multiSelect==0?"display: none;":"")+'"'+" onclick=\"if (this.checked) w2ui['"+e.name+"'].selectAll(); "+" else w2ui['"+e.name+"'].selectNone(); "+' if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">'+" </div>"+"</td>"),e.show.expandColumn&&(n+='<td class="w2ui-head w2ui-col-expand"> <div> </div></td>');var r=0,i=0;for(var s=0;s<e.columns.length;s++){var o=e.columns[s],u={};s==i&&(i+=typeof e.columnGroups[r]!="undefined"?parseInt(e.columnGroups[r].span):0,r++);if(typeof e.columnGroups[r-1]!="undefined")var u=e.columnGroups[r-1];if(o.hidden)continue;var a="";for(var f in e.sortData)e.sortData[f].field==o.field&&(e.sortData[f].direction=="asc"&&(a="w2ui-sort-down"),e.sortData[f].direction=="desc"&&(a="w2ui-sort-up"));if(u.master!==!0||t){var l="";o.resizable==1&&(l='<div class="w2ui-resizer" name="'+s+'"></div>'),n+='<td col="'+s+'" class="w2ui-head '+a+'" '+(o.sortable?"onclick=\"w2ui['"+e.name+"'].columnClick('"+o.field+"', event);\"":"")+">"+l+' <div class="'+a+'">'+(o.caption==""?" ":o.caption)+" </div>"+"</td>"}}return n+='<td class="w2ui-head w2ui-head-last"><div> </div></td>',n+="</tr>",n}var e=this,t="";return this.show.columnHeaders&&(this.columnGroups.length>0?t=r(!0)+n()+r(!1):t=r(!0)),t},getRecordsHTML:function(){this.buffered>300?this.show_extra=30:this.show_extra=300;var e=$("#grid_"+this.name+"_records"),t=Math.floor(e.height()/this.recordHeight)+this.show_extra+1;this.fixedBody||(t=this.buffered);var n="<table>"+this.getRecordHTML(-1,0);n+='<tr id="grid_'+this.name+'_rec_top" line="top" style="height: '+0+'px">'+' <td colspan="200"></td>'+"</tr>";for(var r=0;r<t;r++)n+=this.getRecordHTML(r,r+1);return n+='<tr id="grid_'+this.name+'_rec_bottom" line="bottom" style="height: '+(this.buffered-t)*this.recordHeight+'px">'+' <td colspan="200"></td>'+"</tr>"+'<tr id="grid_'+this.name+'_rec_more" style="display: none">'+' <td colspan="200" class="w2ui-load-more"></td>'+"</tr>"+"</table>",this.last.range_start=0,this.last.range_end=t,n},getSummaryHTML:function(){if(this.summary.length==0)return;var e="<table>";for(var t=0;t<this.summary.length;t++)e+=this.getRecordHTML(t,t+1,!0);return e+="</table>",e},scroll:function(e){function E(){if(n.markSearchResults===!1)return;clearTimeout(n.last.marker_timer),n.last.marker_timer=setTimeout(function(){var e=[];for(var t in n.searchData){var r=n.searchData[t];$.inArray(r.value,e)==-1&&e.push(r.value)}e.length>0&&$(n.box).find(".w2ui-grid-data > div").w2marker(e)},50)}var t=(new Date).getTime(),n=this,r=$("#grid_"+this.name+"_records");if(this.records.length==0||r.length==0||r.height()==0)return;this.buffered>300?this.show_extra=30:this.show_extra=300;if(r.height()<this.buffered*this.recordHeight&&r.css("overflow-y")=="hidden"){this.total>0&&this.refresh();return}var i=Math.floor(r[0].scrollTop/this.recordHeight+1),s=Math.floor(r[0].scrollTop/this.recordHeight+1)+Math.round(r.height()/this.recordHeight);i>this.buffered&&(i=this.buffered),s>this.buffered&&(s=this.buffered);var o=typeof this.url!="object"?this.url:this.url.get;$("#grid_"+this.name+"_footer .w2ui-footer-right").html(w2utils.formatNumber(this.offset+i)+"-"+w2utils.formatNumber(this.offset+s)+" "+w2utils.lang("of")+" "+w2utils.formatNumber(this.total)+(o?" ("+w2utils.lang("buffered")+" "+w2utils.formatNumber(this.buffered)+(this.offset>0?", skip "+w2utils.formatNumber(this.offset):"")+")":""));if(!o&&(!this.fixedBody||this.total<=300))return;var u=Math.floor(r[0].scrollTop/this.recordHeight)-this.show_extra,a=u+Math.floor(r.height()/this.recordHeight)+this.show_extra*2+1;u<1&&(u=1),a>this.total&&(a=this.total);var f=r.find("#grid_"+this.name+"_rec_top"),l=r.find("#grid_"+this.name+"_rec_bottom");String(f.next().prop("id")).indexOf("_expanded_row")!=-1&&f.next().remove(),String(l.prev().prop("id")).indexOf("_expanded_row")!=-1&&l.prev().remove();var c=parseInt(f.next().attr("line")),h=parseInt(l.prev().attr("line"));if(c<u||c==1||this.last.pull_refresh){if(a<=h+this.show_extra-2&&a!=this.total)return;this.last.pull_refresh=!1;for(;;){var p=r.find("#grid_"+this.name+"_rec_top").next();if(p.attr("line")=="bottom")break;if(!(parseInt(p.attr("line"))<u))break;p.remove()}var p=r.find("#grid_"+this.name+"_rec_bottom").prev(),d=p.attr("line");d=="top"&&(d=u);for(var v=parseInt(d)+1;v<=a;v++){if(!this.records[v-1])continue;this.records[v-1].expanded===!0&&(this.records[v-1].expanded=!1),l.before(this.getRecordHTML(v-1,v))}E(),setTimeout(function(){n.refreshRanges()},0)}else{if(u>=c-this.show_extra+2&&u>1)return;for(;;){var p=r.find("#grid_"+this.name+"_rec_bottom").prev();if(p.attr("line")=="top")break;if(!(parseInt(p.attr("line"))>a))break;p.remove()}var p=r.find("#grid_"+this.name+"_rec_top").next(),d=p.attr("line");d=="bottom"&&(d=a);for(var v=parseInt(d)-1;v>=u;v--){if(!this.records[v-1])continue;this.records[v-1].expanded===!0&&(this.records[v-1].expanded=!1),f.after(this.getRecordHTML(v-1,v))}E(),setTimeout(function(){n.refreshRanges()},0)}var m=(u-1)*n.recordHeight,g=(this.buffered-a)*n.recordHeight;g<0&&(g=0),f.css("height",m+"px"),l.css("height",g+"px"),n.last.range_start=u,n.last.range_end=a;var y=Math.floor(r[0].scrollTop/this.recordHeight),b=y+Math.floor(r.height()/this.recordHeight);if(b+10>this.buffered&&this.last.pull_more!==!0&&this.buffered<this.total-this.offset)if(this.autoLoad===!0)this.last.pull_more=!0,this.last.xhr_offset+=this.limit,this.request("get-records");else{var w=$("#grid_"+this.name+"_rec_more");w.css("display")=="none"&&w.show().on("click",function(){$(this).find("td").html('<div><div style="width: 20px; height: 20px;" class="w2ui-spinner"></div></div>'),n.last.pull_more=!0,n.last.xhr_offset+=n.limit,n.request("get-records")}),w.find("td").text().indexOf("Load")==-1&&w.find("td").html("<div>Load "+n.limit+" More...</div>")}this.buffered>=this.total-this.offset&&$("#grid_"+this.name+"_rec_more").hide();return},getRecordHTML:function(e,t,n){var r="";if(e==-1){r+='<tr line="0">',this.show.lineNumbers&&(r+='<td class="w2ui-col-number" style="height: 0px;"></td>'),this.show.selectColumn&&(r+='<td class="w2ui-col-select" style="height: 0px;"></td>'),this.show.expandColumn&&(r+='<td class="w2ui-col-expand" style="height: 0px;"></td>');for(var i in this.columns){if(this.columns[i].hidden)continue;r+='<td class="w2ui-grid-data" col="'+i+'" style="height: 0px;"></td>'}return r+='<td class="w2ui-grid-data-last" style="height: 0px;"></td>',r+="</tr>",r}var s=typeof this.url!="object"?this.url:this.url.get;if(n!==!0)if(this.searchData.length>0&&!s){if(e>=this.last.searchIds.length)return"";e=this.last.searchIds[e],record=this.records[e]}else{if(e>=this.records.length)return"";record=this.records[e]}else{if(e>=this.summary.length)return"";record=this.summary[e]}if(!record)return"";var o=w2utils.escapeId(record.recid),u=!1;record.selected&&this.selectType=="row"&&(u=!0),r+='<tr id="grid_'+this.name+"_rec_"+record.recid+'" recid="'+record.recid+'" line="'+t+'" '+' class="'+(t%2==0?"w2ui-even":"w2ui-odd")+(u?" w2ui-selected":"")+(record.expanded===!0?" w2ui-expanded":"")+'" '+(n!==!0?this.isIOS?" onclick = \"w2ui['"+this.name+"'].dblClick('"+record.recid+"', event);\"":" onclick = \"w2ui['"+this.name+"'].click('"+record.recid+"', event);\"":"")+' style="height: '+this.recordHeight+"px; "+(!u&&record.style?record.style:"")+'" '+(record.style?'custom_style="'+record.style+'"':"")+">",this.show.lineNumbers&&(r+='<td id="grid_'+this.name+"_cell_"+e+'_number" class="w2ui-col-number">'+(n!==!0?"<div>"+t+"</div>":"")+"</td>"),this.show.selectColumn&&(r+='<td id="grid_'+this.name+"_cell_"+e+'_select" class="w2ui-grid-data w2ui-col-select" '+' onclick="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">'+(n!==!0?' <div> <input id="grid_'+this.name+"_cell_"+e+'_select_check" class="grid_select_check" type="checkbox" tabIndex="-1"'+" "+(record.selected?'checked="checked"':"")+" onclick=\"var obj = w2ui['"+this.name+"']; "+" if (!obj.multiSelect) { obj.selectNone(); }"+" if (this.checked) obj.select('"+record.recid+"'); else obj.unselect('"+record.recid+"'); "+' if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">'+" </div>":"")+"</td>");if(this.show.expandColumn){var a="";record.expanded===!0?a="-":a="+",record.expanded=="none"&&(a=""),record.expanded=="spinner"&&(a='<div class="w2ui-spinner" style="width: 16px; margin: -2px 2px;"></div>'),r+='<td id="grid_'+this.name+"_cell_"+e+'_expand" class="w2ui-grid-data w2ui-col-expand">'+(n!==!0?' <div ondblclick="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;" onclick="w2ui[\''+this.name+"'].toggle('"+record.recid+"', event); "+' if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">'+" "+a+" </div>":"")+"</td>"}var f=0;for(;;){var l=this.columns[f];if(l.hidden){f++;if(typeof this.columns[f]=="undefined")break;continue}var c=record.changed&&record.changes[l.field],h=this.getCellHTML(e,f,n),p="";if(typeof l.render=="string"){var d=l.render.toLowerCase().split(":");$.inArray(d[0],["number","int","float","money","percent"])!=-1&&(p="text-align: right"),$.inArray(d[0],["date"])!=-1&&(p="text-align: right")}var v=!1;record.selected&&$.inArray(f,record.selectedColumns)!=-1&&(v=!0),r+='<td class="w2ui-grid-data'+(v?" w2ui-selected":"")+(c?" w2ui-changed":"")+'" col="'+f+'" '+' style="'+p+";"+(typeof l.style!="undefined"?l.style:"")+'" '+(typeof l.attr!="undefined"?l.attr:"")+">"+h+"</td>",f++;if(typeof this.columns[f]=="undefined")break}return r+='<td class="w2ui-grid-data-last"></td>',r+="</tr>",r},getCellHTML:function(e,t,n){var r=this.columns[t],i=n!==!0?this.records[e]:this.summary[e],s=this.parseField(i,r.field),o=i.changed&&i.changes[r.field];o&&(s=i.changes[r.field]);if(s==null||typeof s=="undefined")s="";if(typeof r.render!="undefined"){typeof r.render=="function"&&(s=r.render.call(this,i,e,t),s.length>=4&&s.substr(0,4)!="<div"&&(s="<div>"+s+"</div>")),typeof r.render=="object"&&(s="<div>"+r.render[s]+"</div>");if(typeof r.render=="string"){var u=r.render.toLowerCase().split(":"),a="",f="";if($.inArray(u[0],["number","int","float","money","percent"])!=-1){if(typeof u[1]=="undefined"||!w2utils.isInt(u[1]))u[1]=0;u[1]>20&&(u[1]=20),u[1]<0&&(u[1]=0),u[0]=="money"&&(u[1]=2,a=w2utils.settings.currencySymbol),u[0]=="percent"&&(f="%",u[1]!=="0"&&(u[1]=1)),u[0]=="int"&&(u[1]=0),s="<div>"+a+w2utils.formatNumber(Number(s).toFixed(u[1]))+f+"</div>"}if(u[0]=="date"){if(typeof u[1]=="undefined"||u[1]=="")u[1]=w2utils.settings.date_display;s="<div>"+a+w2utils.formatDate(s,u[1])+f+"</div>"}u[0]=="age"&&(s="<div>"+a+w2utils.age(s)+f+"</div>")}}else if(!this.show.recordTitles)var s="<div>"+s+"</div>";else{var l=String(s).replace(/"/g,"''");typeof r.title!="undefined"&&(typeof r.title=="function"&&(l=r.title.call(this,i,e,t)),typeof r.title=="string"&&(l=r.title));var s='<div title="'+l+'">'+s+"</div>"}if(s==null||typeof s=="undefined")s="";return s},getFooterHTML:function(){return'<div> <div class="w2ui-footer-left"></div> <div class="w2ui-footer-right">'+this.buffered+"</div>"+' <div class="w2ui-footer-center"></div>'+"</div>"},status:function(e){if(typeof e!="undefined")$("#grid_"+this.name+"_footer").find(".w2ui-footer-left").html(e);else{var t="",n=this.getSelection();if(n.length>0){t=String(n.length).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")+" "+w2utils.lang("selected");var r=n[0];typeof r=="object"&&(r=r.recid+", "+w2utils.lang("Column")+": "+r.column),n.length==1&&(t=w2utils.lang("Record ID")+": "+r+" ")}$("#grid_"+this.name+"_footer .w2ui-footer-left").html(t),n.length==1?this.toolbar.enable("edit"):this.toolbar.disable("edit"),n.length>=1?this.toolbar.enable("delete"):this.toolbar.disable("delete")}},lock:function(e,t){var n=$(this.box).find("> div:first-child");setTimeout(function(){w2utils.lock(n,e,t)},10)},unlock:function(){var e=this.box;setTimeout(function(){w2utils.unlock(e)},25)},parseField:function(e,t){var n="";try{n=e;var r=String(t).split(".");for(var i in r)n=n[r[i]]}catch(s){n=""}return n}},$.extend(w2grid.prototype,w2utils.event),w2obj.grid=w2grid}(),function(){var e=function(e){this.box=null,this.name=null,this.panels=[],this.tmp={},this.padding=1,this.resizer=4,this.style="",this.onShow=null,this.onHide=null,this.onResizing=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,$.extend(!0,this,w2obj.layout,e)};$.fn.w2layout=function(t){function o(e,t,n){var r=e.get(t);return r!=null&&typeof n=="undefined"&&(n=r.tabs),r==null||n==null?!1:($.isArray(n)&&(n={tabs:n}),$().w2destroy(e.name+"_"+t+"_tabs"),r.tabs=$().w2tabs($.extend({},n,{owner:e,name:e.name+"_"+t+"_tabs"})),r.show.tabs=!0,!0)}function u(e,t,n){var r=e.get(t);return r!=null&&typeof n=="undefined"&&(n=r.toolbar),r==null||n==null?!1:($.isArray(n)&&(n={items:n}),$().w2destroy(e.name+"_"+t+"_toolbar"),r.toolbar=$().w2toolbar($.extend({},n,{owner:e,name:e.name+"_"+t+"_toolbar"})),r.show.toolbar=!0,!0)}if(typeof t=="object"||!t){if(!t||typeof t.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2layout().');return}if(typeof w2ui[t.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+t.name+").");return}if(!w2utils.isAlphaNumeric(t.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=t.panels,r=new e(t);$.extend(r,{handlers:[],panels:[]});for(var i in n)r.panels[i]=$.extend(!0,{},e.prototype.panel,n[i]),($.isPlainObject(r.panels[i].tabs)||$.isArray(r.panels[i].tabs))&&o(r,n[i].type),($.isPlainObject(r.panels[i].toolbar)||$.isArray(r.panels[i].toolbar))&&u(r,n[i].type);for(var i in{top:"",left:"",main:"",preview:"",right:"",bottom:""}){if(r.get(i)!=null)continue;r.panels[i]=$.extend(!0,{},e.prototype.panel,{type:i,hidden:!0,size:50})}return $(this).length>0&&r.render($(this)[0]),w2ui[r.name]=r,r}if(w2ui[$(this).attr("name")]){var s=w2ui[$(this).attr("name")];return s[t].apply(s,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+t+" does not exist on jQuery.w2layout")},e.prototype={panel:{type:null,size:100,minSize:20,hidden:!1,resizable:!1,overflow:"auto",style:"",content:"",tabs:null,toolbar:null,width:null,height:null,show:{toolbar:!1,tabs:!1},onRefresh:null,onShow:null,onHide:null},html:function(e,t,n){return this.content(e,t,n)},content:function(e,t,n){var r=this,i=this.get(e);if(e=="css")return $("#layout_"+r.name+"_panel_css").html("<style>"+t+"</style>"),!0;if(i==null)return!1;if($("#layout_"+this.name+"_panel2_"+i.type).length>0)return!1;$("#layout_"+this.name+"_panel_"+i.type).scrollTop(0);if(t==null||typeof t=="undefined")return i.content;if(t instanceof jQuery)return console.log("ERROR: You can not pass jQuery object to w2layout.content() method"),!1;var s=$("#layout_"+this.name+"_panel_"+e+" > .w2ui-panel-content"),o=$(s).position().top;s.attr("class","w2ui-panel-content"),s.length>0&&typeof i.style!="undefined"&&(s[0].style.cssText=i.style);if(i.content=="")i.content=t,i.hidden||this.refresh(e);else{i.content=t;if(!i.hidden)if(n!=null&&n!=""&&typeof n!="undefined"){var u="layout_"+this.name+"_panel_"+i.type,a=$("#"+u+" > .w2ui-panel-content");a.after('<div class="w2ui-panel-content new-panel" style="'+a[0].style.cssText+'"></div>');var f=$("#"+u+" > .w2ui-panel-content.new-panel");a.css("top",o),f.css("top",o),typeof t=="object"?(t.box=f[0],t.render()):f.html(t),w2utils.transition(a[0],f[0],n,function(){a.remove(),f.removeClass("new-panel"),f.css("overflow",i.overflow),window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){r.resize()},100)})}else i.hidden||this.refresh(e)}return window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){r.resize()},100),!0},load:function(e,t,n,r){var i=this;return e=="css"?($.get(t,function(t,n,s){i.content(e,s.responseText),r&&r()}),!0):this.get(e)!=null?($.get(t,function(t,s,o){i.content(e,o.responseText,n),r&&r(),window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){i.resize()},100)}),!0):!1},sizeTo:function(e,t){var n=this,r=n.get(e);return r==null?!1:($(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":".35s","-moz-transition":".35s","-ms-transition":".35s","-o-transition":".35s"}),setTimeout(function(){n.set(e,{size:t})},1),setTimeout(function(){$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":"0s","-moz-transition":"0s","-ms-transition":"0s","-o-transition":"0s"}),n.resize()},500),!0)},show:function(e,t){var n=this,r=this.trigger({phase:"before",type:"show",target:e,object:this.get(e),immediate:t});if(r.isCancelled===!0)return!1;var i=n.get(e);return i==null?!1:(i.hidden=!1,t===!0?($("#layout_"+n.name+"_panel_"+e).css({opacity:"1"}),i.resizabled&&$("#layout_"+n.name+"_resizer_"+e).show(),n.trigger($.extend(r,{phase:"after"})),n.resize()):(i.resizabled&&$("#layout_"+n.name+"_resizer_"+e).show(),$("#layout_"+n.name+"_panel_"+e).css({opacity:"0"}),$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":".2s","-moz-transition":".2s","-ms-transition":".2s","-o-transition":".2s"}),setTimeout(function(){n.resize()},1),setTimeout(function(){$("#layout_"+n.name+"_panel_"+e).css({opacity:"1"})},250),setTimeout(function(){$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":"0s","-moz-transition":"0s","-ms-transition":"0s","-o-transition":"0s"}),n.trigger($.extend(r,{phase:"after"})),n.resize()},500)),!0)},hide:function(e,t){var n=this,r=this.trigger({phase:"before",type:"hide",target:e,object:this.get(e),immediate:t});if(r.isCancelled===!0)return!1;var i=n.get(e);return i==null?!1:(i.hidden=!0,t===!0?($("#layout_"+n.name+"_panel_"+e).css({opacity:"0"}),$("#layout_"+n.name+"_resizer_"+e).hide(),n.trigger($.extend(r,{phase:"after"})),n.resize()):($("#layout_"+n.name+"_resizer_"+e).hide(),$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":".2s","-moz-transition":".2s","-ms-transition":".2s","-o-transition":".2s"}),$("#layout_"+n.name+"_panel_"+e).css({opacity:"0"}),setTimeout(function(){n.resize()},1),setTimeout(function(){$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":"0s","-moz-transition":"0s","-ms-transition":"0s","-o-transition":"0s"}),n.trigger($.extend(r,{phase:"after"})),n.resize()},500)),!0)},toggle:function(e,t){var n=this.get(e);return n==null?!1:n.hidden?this.show(e,t):this.hide(e,t)},set:function(e,t){var n=this.get(e,!0);return n==null?!1:($.extend(this.panels[n],t),this.refresh(e),this.resize(),!0)},get:function(e,t){var n=null;for(var r in this.panels)if(this.panels[r].type==e)return t===!0?r:this.panels[r];return null},el:function(e){var t=$("#layout_"+this.name+"_panel_"+e+" .w2ui-panel-content");return t.length!=1?null:t[0]},hideToolbar:function(e){var t=this.get(e);if(!t)return;t.show.toolbar=!1,$("#layout_"+this.name+"_panel_"+e+" > .w2ui-panel-toolbar").hide(),this.resize()},showToolbar:function(e){var t=this.get(e);if(!t)return;t.show.toolbar=!0,$("#layout_"+this.name+"_panel_"+e+" > .w2ui-panel-toolbar").show(),this.resize()},toggleToolbar:function(e){var t=this.get(e);if(!t)return;t.show.toolbar?this.hideToolbar(e):this.showToolbar(e)},hideTabs:function(e){var t=this.get(e);if(!t)return;t.show.tabs=!1,$("#layout_"+this.name+"_panel_"+e+" > .w2ui-panel-tabs").hide(),this.resize()},showTabs:function(e){var t=this.get(e);if(!t)return;t.show.tabs=!0,$("#layout_"+this.name+"_panel_"+e+" > .w2ui-panel-tabs").show(),this.resize()},toggleTabs:function(e){var t=this.get(e);if(!t)return;t.show.tabs?this.hideTabs(e):this.showTabs(e)},render:function(e){function a(){t.tmp.events={resize:function(e){w2ui[t.name].resize()},resizeStart:f,mousemove:c,mouseup:l},$(window).on("resize",t.tmp.events.resize),$(document).on("mousemove",t.tmp.events.mousemove),$(document).on("mouseup",t.tmp.events.mouseup)}function f(e,n){if(!t.box)return;n||(n=window.event),window.addEventListener||window.document.attachEvent("onselectstart",function(){return!1}),t.tmp.resize={type:e,x:n.screenX,y:n.screenY,div_x:0,div_y:0,value:0};if(e=="left"||e=="right")t.tmp.resize.value=parseInt($("#layout_"+t.name+"_resizer_"+e)[0].style.left);if(e=="top"||e=="preview"||e=="bottom")t.tmp.resize.value=parseInt($("#layout_"+t.name+"_resizer_"+e)[0].style.top)}function l(e){if(!t.box)return;e||(e=window.event),window.addEventListener||window.document.attachEvent("onselectstart",function(){return!1});if(typeof t.tmp.resize=="undefined")return;if(t.tmp.div_x!=0||t.tmp.resize.div_y!=0){var n=t.get("top"),r=t.get("bottom"),i=t.get(t.tmp.resize.type),s=parseInt($(t.box).height()),o=parseInt($(t.box).width()),u=String(i.size);switch(t.tmp.resize.type){case"top":var a=parseInt(i.sizeCalculated)+t.tmp.resize.div_y,f=0;break;case"bottom":var a=parseInt(i.sizeCalculated)-t.tmp.resize.div_y,f=0;break;case"preview":var a=parseInt(i.sizeCalculated)-t.tmp.resize.div_y,f=(n&&!n.hidden?n.sizeCalculated:0)+(r&&!r.hidden?r.sizeCalculated:0);break;case"left":var a=parseInt(i.sizeCalculated)+t.tmp.resize.div_x,f=0;break;case"right":var a=parseInt(i.sizeCalculated)-t.tmp.resize.div_x,f=0}u.substr(u.length-1)=="%"?i.size=Math.floor(a*100/(i.type=="left"||i.type=="right"?o:s-f)*100)/100+"%":i.size=a,t.resize()}$("#layout_"+t.name+"_resizer_"+t.tmp.resize.type).removeClass("active"),delete t.tmp.resize}function c(e){if(!t.box)return;e||(e=window.event);if(typeof t.tmp.resize=="undefined")return;var n=t.get(t.tmp.resize.type),r=t.trigger({phase:"before",type:"resizing",target:t.tmp.resize.type,object:n,originalEvent:e});if(r.isCancelled===!0)return!1;var i=$("#layout_"+t.name+"_resizer_"+t.tmp.resize.type);i.hasClass("active")||i.addClass("active"),t.tmp.resize.div_x=e.screenX-t.tmp.resize.x,t.tmp.resize.div_y=e.screenY-t.tmp.resize.y,t.tmp.resizing=="left"&&t.get("left").minSize-t.tmp.resize.div_x>t.get("left").width&&(t.tmp.resize.div_x=t.get("left").minSize-t.get("left").width),t.tmp.resize.type=="left"&&t.get("main").minSize+t.tmp.resize.div_x>t.get("main").width&&(t.tmp.resize.div_x=t.get("main").width-t.get("main").minSize),t.tmp.resize.type=="right"&&t.get("right").minSize+t.tmp.resize.div_x>t.get("right").width&&(t.tmp.resize.div_x=t.get("right").width-t.get("right").minSize),t.tmp.resize.type=="right"&&t.get("main").minSize-t.tmp.resize.div_x>t.get("main").width&&(t.tmp.resize.div_x=t.get("main").minSize-t.get("main").width),t.tmp.resize.type=="top"&&t.get("top").minSize-t.tmp.resize.div_y>t.get("top").height&&(t.tmp.resize.div_y=t.get("top").minSize-t.get("top").height),t.tmp.resize.type=="top"&&t.get("main").minSize+t.tmp.resize.div_y>t.get("main").height&&(t.tmp.resize.div_y=t.get("main").height-t.get("main").minSize),t.tmp.resize.type=="bottom"&&t.get("bottom").minSize+t.tmp.resize.div_y>t.get("bottom").height&&(t.tmp.resize.div_y=t.get("bottom").height-t.get("bottom").minSize),t.tmp.resize.type=="bottom"&&t.get("main").minSize-t.tmp.resize.div_y>t.get("main").height&&(t.tmp.resize.div_y=t.get("main").minSize-t.get("main").height),t.tmp.resize.type=="preview"&&t.get("preview").minSize+t.tmp.resize.div_y>t.get("preview").height&&(t.tmp.resize.div_y=t.get("preview").height-t.get("preview").minSize),t.tmp.resize.type=="preview"&&
t.get("main").minSize-t.tmp.resize.div_y>t.get("main").height&&(t.tmp.resize.div_y=t.get("main").minSize-t.get("main").height);switch(t.tmp.resize.type){case"top":case"preview":case"bottom":t.tmp.resize.div_x=0,i.length>0&&(i[0].style.top=t.tmp.resize.value+t.tmp.resize.div_y+"px");break;case"left":case"right":t.tmp.resize.div_y=0,i.length>0&&(i[0].style.left=t.tmp.resize.value+t.tmp.resize.div_x+"px")}t.trigger($.extend(r,{phase:"after"}))}var t=this;window.getSelection&&window.getSelection().removeAllRanges();var n=(new Date).getTime(),r=t.trigger({phase:"before",type:"render",target:t.name,box:e});if(r.isCancelled===!0)return!1;typeof e!="undefined"&&e!=null&&($(t.box).find("#layout_"+t.name+"_panel_main").length>0&&$(t.box).removeAttr("name").removeClass("w2ui-layout").html(""),t.box=e);if(!t.box)return!1;$(t.box).attr("name",t.name).addClass("w2ui-layout").html("<div></div>"),$(t.box).length>0&&($(t.box)[0].style.cssText+=t.style);var i=["top","left","main","preview","right","bottom"];for(var s in i){var o=t.get(i[s]),u='<div id="layout_'+t.name+"_panel_"+i[s]+'" class="w2ui-panel">'+' <div class="w2ui-panel-tabs"></div>'+' <div class="w2ui-panel-toolbar"></div>'+' <div class="w2ui-panel-content"></div>'+"</div>"+'<div id="layout_'+t.name+"_resizer_"+i[s]+'" class="w2ui-resizer"></div>';$(t.box).find(" > div").append(u)}return $(t.box).find(" > div").append('<div id="layout_'+t.name+'_panel_css" style="position: absolute; top: 10000px;"></div'),t.refresh(),t.trigger($.extend(r,{phase:"after"})),setTimeout(function(){t.resize(),a()},0),(new Date).getTime()-n},refresh:function(e){var t=this;window.getSelection&&window.getSelection().removeAllRanges(),typeof e=="undefined"&&(e=null);var n=(new Date).getTime(),r=t.trigger({phase:"before",type:"refresh",target:typeof e!="undefined"?e:t.name,object:t.get(e)});if(r.isCancelled===!0)return;if(e!=null&&typeof e!="undefined"){var i=t.get(e);if(i==null)return;var s=$("#layout_"+t.name+"_panel_"+e).css({display:i.hidden?"none":"block"});s=s.find(".w2ui-panel-content"),s.length>0&&(s.css("overflow",i.overflow)[0].style.cssText+=";"+i.style),i.resizable===!0?$("#layout_"+this.name+"_resizer_"+e).show():$("#layout_"+this.name+"_resizer_"+e).hide(),typeof i.content=="object"&&i.content.render?(i.content.box=$("#layout_"+t.name+"_panel_"+i.type+" > .w2ui-panel-content")[0],i.content.render()):$("#layout_"+t.name+"_panel_"+i.type+" > .w2ui-panel-content").html(i.content);var o=$(t.box).find("#layout_"+t.name+"_panel_"+i.type+" .w2ui-panel-tabs");i.show.tabs?o.find("[name="+i.tabs.name+"]").length==0&&i.tabs!=null?o.w2render(i.tabs):i.tabs.refresh():o.html("").removeClass("w2ui-tabs").hide();var o=$(t.box).find("#layout_"+t.name+"_panel_"+i.type+" .w2ui-panel-toolbar");i.show.toolbar?o.find("[name="+i.toolbar.name+"]").length==0&&i.toolbar!=null?o.w2render(i.toolbar):i.toolbar.refresh():o.html("").removeClass("w2ui-toolbar").hide()}else{if($("#layout_"+t.name+"_panel_main").length<=0){t.render();return}t.resize();for(var i in this.panels)t.refresh(this.panels[i].type)}return t.trigger($.extend(r,{phase:"after"})),(new Date).getTime()-n},resize:function(){window.getSelection&&window.getSelection().removeAllRanges();if(!this.box)return!1;var e=(new Date).getTime(),t=this.trigger({phase:"before",type:"resize",target:this.name,panel:this.tmp.resizing});if(t.isCancelled===!0)return!1;this.padding<0&&(this.padding=0);var n=parseInt($(this.box).width()),r=parseInt($(this.box).height());$(this.box).find(" > div").css({width:n+"px",height:r+"px"});var i=this,s=this.get("main"),o=this.get("preview"),u=this.get("left"),a=this.get("right"),f=this.get("top"),l=this.get("bottom"),c=!0,h=o!=null&&o.hidden!=1?!0:!1,p=u!=null&&u.hidden!=1?!0:!1,d=a!=null&&a.hidden!=1?!0:!1,v=f!=null&&f.hidden!=1?!0:!1,m=l!=null&&l.hidden!=1?!0:!1;for(var g in{top:"",left:"",right:"",bottom:"",preview:""}){var y=this.get(g),b=String(y.size);if(y&&b.substr(b.length-1)=="%"){var w=r;y.type=="preview"&&(w=w-(f&&!f.hidden?f.sizeCalculated:0)-(l&&!l.hidden?l.sizeCalculated:0)),y.sizeCalculated=parseInt((y.type=="left"||y.type=="right"?n:w)*parseFloat(y.size)/100)}else y.sizeCalculated=parseInt(y.size);y.sizeCalculated<parseInt(y.minSize)&&(y.sizeCalculated=parseInt(y.minSize))}if(f!=null&&f.hidden!=1){var E=0,S=0,x=n,T=f.sizeCalculated;$("#layout_"+this.name+"_panel_top").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}).show(),f.width=x,f.height=T,f.resizable&&(S=f.sizeCalculated-(this.padding==0?this.resizer:0),T=this.resizer>this.padding?this.resizer:this.padding,$("#layout_"+this.name+"_resizer_top").show().css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px",cursor:"ns-resize"}).bind("mousedown",function(e){return w2ui[i.name].tmp.events.resizeStart("top",e),!1}))}else $("#layout_"+this.name+"_panel_top").hide();if(u!=null&&u.hidden!=1){var E=0,S=0+(v?f.sizeCalculated+this.padding:0),x=u.sizeCalculated,T=r-(v?f.sizeCalculated+this.padding:0)-(m?l.sizeCalculated+this.padding:0),N=$("#layout_"+this.name+"_panel_left");window.navigator.userAgent.indexOf("MSIE")>0&&N.length>0&&N[0].clientHeight<N[0].scrollHeight&&(x+=17),$("#layout_"+this.name+"_panel_left").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}).show(),u.width=x,u.height=T,u.resizable&&(E=u.sizeCalculated-(this.padding==0?this.resizer:0),x=this.resizer>this.padding?this.resizer:this.padding,$("#layout_"+this.name+"_resizer_left").show().css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px",cursor:"ew-resize"}).bind("mousedown",function(e){return w2ui[i.name].tmp.events.resizeStart("left",e),!1}))}else $("#layout_"+this.name+"_panel_left").hide(),$("#layout_"+this.name+"_resizer_left").hide();if(a!=null&&a.hidden!=1){var E=n-a.sizeCalculated,S=0+(v?f.sizeCalculated+this.padding:0),x=a.sizeCalculated,T=r-(v?f.sizeCalculated+this.padding:0)-(m?l.sizeCalculated+this.padding:0);$("#layout_"+this.name+"_panel_right").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}).show(),a.width=x,a.height=T,a.resizable&&(E-=this.padding,x=this.resizer>this.padding?this.resizer:this.padding,$("#layout_"+this.name+"_resizer_right").show().css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px",cursor:"ew-resize"}).bind("mousedown",function(e){return w2ui[i.name].tmp.events.resizeStart("right",e),!1}))}else $("#layout_"+this.name+"_panel_right").hide();if(l!=null&&l.hidden!=1){var E=0,S=r-l.sizeCalculated,x=n,T=l.sizeCalculated;$("#layout_"+this.name+"_panel_bottom").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}).show(),l.width=x,l.height=T,l.resizable&&(S-=this.padding==0?0:this.padding,T=this.resizer>this.padding?this.resizer:this.padding,$("#layout_"+this.name+"_resizer_bottom").show().css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px",cursor:"ns-resize"}).bind("mousedown",function(e){return w2ui[i.name].tmp.events.resizeStart("bottom",e),!1}))}else $("#layout_"+this.name+"_panel_bottom").hide();var E=0+(p?u.sizeCalculated+this.padding:0),S=0+(v?f.sizeCalculated+this.padding:0),x=n-(p?u.sizeCalculated+this.padding:0)-(d?a.sizeCalculated+this.padding:0),T=r-(v?f.sizeCalculated+this.padding:0)-(m?l.sizeCalculated+this.padding:0)-(h?o.sizeCalculated+this.padding:0),N=$("#layout_"+this.name+"_panel_main");window.navigator.userAgent.indexOf("MSIE")>0&&N.length>0&&N[0].clientHeight<N[0].scrollHeight&&(x+=17),$("#layout_"+this.name+"_panel_main").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}),s.width=x,s.height=T;if(o!=null&&o.hidden!=1){var E=0+(p?u.sizeCalculated+this.padding:0),S=r-(m?l.sizeCalculated+this.padding:0)-o.sizeCalculated,x=n-(p?u.sizeCalculated+this.padding:0)-(d?a.sizeCalculated+this.padding:0),T=o.sizeCalculated,N=$("#layout_"+this.name+"_panel_preview");window.navigator.userAgent.indexOf("MSIE")>0&&N.length>0&&N[0].clientHeight<N[0].scrollHeight&&(x+=17),$("#layout_"+this.name+"_panel_preview").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}).show(),o.width=x,o.height=T,o.resizable&&(S-=this.padding==0?0:this.padding,T=this.resizer>this.padding?this.resizer:this.padding,$("#layout_"+this.name+"_resizer_preview").show().css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px",cursor:"ns-resize"}).bind("mousedown",function(e){return w2ui[i.name].tmp.events.resizeStart("preview",e),!1}))}else $("#layout_"+this.name+"_panel_preview").hide();for(var g in{top:"",left:"",main:"",preview:"",right:"",bottom:""}){var C=this.get(g),y="#layout_"+this.name+"_panel_"+g+" > .w2ui-panel-",r=0;C.show.tabs&&(C.tabs!=null&&w2ui[this.name+"_"+g+"_tabs"]&&w2ui[this.name+"_"+g+"_tabs"].resize(),r+=w2utils.getSize($(y+"tabs").css({display:"block"}),"height")),C.show.toolbar&&(C.toolbar!=null&&w2ui[this.name+"_"+g+"_toolbar"]&&w2ui[this.name+"_"+g+"_toolbar"].resize(),r+=w2utils.getSize($(y+"toolbar").css({top:r+"px",display:"block"}),"height")),$(y+"content").css({display:"block"}).css({top:r+"px"})}var i=this;return clearTimeout(this._resize_timer),this._resize_timer=setTimeout(function(){for(var e in w2ui)if(typeof w2ui[e].resize=="function"){w2ui[e].panels=="undefined"&&w2ui[e].resize();var t=$(w2ui[e].box).parents(".w2ui-layout");t.length>0&&t.attr("name")==i.name&&w2ui[e].resize()}},100),this.trigger($.extend(t,{phase:"after"})),(new Date).getTime()-e},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});return e.isCancelled===!0?!1:typeof w2ui[this.name]=="undefined"?!1:($(this.box).find("#layout_"+this.name+"_panel_main").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-layout").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"})),this.tmp.events&&this.tmp.events.resize&&$(window).off("resize",this.tmp.events.resize),this.tmp.events&&this.tmp.events.mousemove&&$(document).off("mousemove",this.tmp.events.mousemove),this.tmp.events&&this.tmp.events.mouseup&&$(document).off("mouseup",this.tmp.events.mouseup),!0)},lock:function(e,t,n){if($.inArray(String(e),["left","right","top","bottom","preview","main"])==-1){console.log("ERROR: First parameter needs to be the a valid panel name.");return}var r="#layout_"+this.name+"_panel_"+e;w2utils.lock(r,t,n)},unlock:function(e){if($.inArray(String(e),["left","right","top","bottom","preview","main"])==-1){console.log("ERROR: First parameter needs to be the a valid panel name.");return}var t="#layout_"+this.name+"_panel_"+e;w2utils.unlock(t)}},$.extend(e.prototype,w2utils.event),w2obj.layout=e}();var w2popup={};(function(){$.fn.w2popup=function(e,t){typeof e=="undefined"&&(t={},e="open"),$.isPlainObject(e)&&(t=e,e="open"),e=e.toLowerCase(),e=="load"&&typeof t=="string"&&(t={url:t}),e=="open"&&typeof t.url!="undefined"&&(e="load"),typeof t=="undefined"&&(t={});var n={};return $(this).length>0&&($(this).find("div[rel=title], div[rel=body], div[rel=buttons]").length>0?($(this).find("div[rel=title]").length>0&&(n.title=$(this).find("div[rel=title]").html()),$(this).find("div[rel=body]").length>0&&(n.body=$(this).find("div[rel=body]").html(),n.style=$(this).find("div[rel=body]")[0].style.cssText),$(this).find("div[rel=buttons]").length>0&&(n.buttons=$(this).find("div[rel=buttons]").html())):(n.title=" ",n.body=$(this).html()),parseInt($(this).css("width"))!=0&&(n.width=parseInt($(this).css("width"))),parseInt($(this).css("height"))!=0&&(n.height=parseInt($(this).css("height")))),w2popup[e]($.extend({},n,t))},w2popup={defaults:{title:"",body:"",buttons:"",style:"",color:"#000",opacity:.4,speed:.3,modal:!1,maximized:!1,keyboard:!0,width:500,height:300,showClose:!0,showMax:!1,transition:null},handlers:[],onOpen:null,onClose:null,onMax:null,onMin:null,onKeydown:null,open:function(e){function p(e){e||(e=window.event),window.addEventListener||window.document.attachEvent("onselectstart",function(){return!1}),h.resizing=!0,h.tmp_x=e.screenX,h.tmp_y=e.screenY,e.stopPropagation?e.stopPropagation():e.cancelBubble=!0;if(!e.preventDefault)return!1;e.preventDefault()}function d(e){if(h.resizing!=1)return;e||(e=window.event),h.tmp_div_x=e.screenX-h.tmp_x,h.tmp_div_y=e.screenY-h.tmp_y,$("#w2ui-popup").css({"-webkit-transition":"none","-webkit-transform":"translate3d("+h.tmp_div_x+"px, "+h.tmp_div_y+"px, 0px)","-moz-transition":"none","-moz-transform":"translate("+h.tmp_div_x+"px, "+h.tmp_div_y+"px)","-ms-transition":"none","-ms-transform":"translate("+h.tmp_div_x+"px, "+h.tmp_div_y+"px)","-o-transition":"none","-o-transform":"translate("+h.tmp_div_x+"px, "+h.tmp_div_y+"px)"}),$("#w2ui-panel").css({"-webkit-transition":"none","-webkit-transform":"translate3d("+h.tmp_div_x+"px, "+h.tmp_div_y+"px, 0px)","-moz-transition":"none","-moz-transform":"translate("+h.tmp_div_x+"px, "+h.tmp_div_y+"px)","-ms-transition":"none","-ms-transform":"translate("+h.tmp_div_x+"px, "+h.tmp_div_y+"px","-o-transition":"none","-o-transform":"translate("+h.tmp_div_x+"px, "+h.tmp_div_y+"px)"})}function v(e){if(h.resizing!=1)return;e||(e=window.event),h.tmp_div_x=e.screenX-h.tmp_x,h.tmp_div_y=e.screenY-h.tmp_y,$("#w2ui-popup").css({"-webkit-transition":"none","-webkit-transform":"translate3d(0px, 0px, 0px)","-moz-transition":"none","-moz-transform":"translate(0px, 0px)","-ms-transition":"none","-ms-transform":"translate(0px, 0px)","-o-transition":"none","-o-transform":"translate(0px, 0px)",left:parseInt($("#w2ui-popup").css("left"))+parseInt(h.tmp_div_x)+"px",top:parseInt($("#w2ui-popup").css("top"))+parseInt(h.tmp_div_y)+"px"}),$("#w2ui-panel").css({"-webkit-transition":"none","-webkit-transform":"translate3d(0px, 0px, 0px)","-moz-transition":"none","-moz-transform":"translate(0px, 0px)","-ms-transition":"none","-ms-transform":"translate(0px, 0px)","-o-transition":"none","-o-transform":"translate(0px, 0px)",left:parseInt($("#w2ui-panel").css("left"))+parseInt(h.tmp_div_x)+"px",top:parseInt($("#w2ui-panel").css("top"))+parseInt(h.tmp_div_y)+"px"}),h.resizing=!1}var t=this,n=$("#w2ui-popup").data("options"),e=$.extend({},this.defaults,{body:""},n,e);$("#w2ui-popup").length==0&&(w2popup.handlers=[],w2popup.onMax=null,w2popup.onMin=null,w2popup.onOpen=null,w2popup.onClose=null,w2popup.onKeydown=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.onKeydown&&(w2popup.onKeydown=e.onKeydown);if(window.innerHeight==undefined){var r=document.documentElement.offsetWidth,i=document.documentElement.offsetHeight;w2utils.engine=="IE7"&&(r+=21,i+=4)}else var r=window.innerWidth,i=window.innerHeight;parseInt(r)-10<parseInt(e.width)&&(e.width=parseInt(r)-10),parseInt(i)-10<parseInt(e.height)&&(e.height=parseInt(i)-10);var s=(parseInt(i)-parseInt(e.height))/2*.6,o=(parseInt(r)-parseInt(e.width))/2;if($("#w2ui-popup").length==0){var u=this.trigger({phase:"before",type:"open",target:"popup",options:e,present:!1});if(u.isCancelled===!0)return;w2popup.lockScreen(e);var a='<div id="w2ui-popup" class="w2ui-popup" style="width: '+parseInt(e.width)+"px; height: "+parseInt(e.height)+"px; opacity: 0; "+"-webkit-transform: scale(0.8); -moz-transform: scale(0.8); -ms-transform: scale(0.8); -o-transform: scale(0.8); "+"left: "+o+"px; top: "+s+'px;">';e.title!=""&&(a+='<div class="w2ui-msg-title">'+(e.showClose?'<div class="w2ui-msg-button w2ui-msg-close" onclick="w2popup.close(); if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">Close</div>':"")+(e.showMax?'<div class="w2ui-msg-button w2ui-msg-max" onclick="w2popup.toggle()">Max</div>':"")+e.title+"</div>"),a+='<div class="w2ui-box1" style="'+(e.title==""?"top: 0px !important;":"")+(e.buttons==""?"bottom: 0px !important;":"")+'">',a+='<div class="w2ui-msg-body'+(!e.title!=""?" w2ui-msg-no-title":"")+(!e.buttons!=""?" w2ui-msg-no-buttons":"")+'" style="'+e.style+'">'+e.body+"</div>",a+="</div>",a+='<div class="w2ui-box2" style="'+(e.title==""?"top: 0px !important;":"")+(e.buttons==""?"bottom: 0px !important;":"")+'">',a+='<div class="w2ui-msg-body'+(!e.title!=""?" w2ui-msg-no-title":"")+(!e.buttons!=""?" w2ui-msg-no-buttons":"")+'" style="'+e.style+'"></div>',a+="</div>",e.buttons!=""&&(a+='<div class="w2ui-msg-buttons">'+e.buttons+"</div>"),a+="</div>",$("body").append(a),setTimeout(function(){$("#w2ui-popup .w2ui-box2").hide(),$("#w2ui-popup").css({"-webkit-transition":e.speed+"s opacity, "+e.speed+"s -webkit-transform","-webkit-transform":"scale(1)","-moz-transition":e.speed+"s opacity, "+e.speed+"s -moz-transform","-moz-transform":"scale(1)","-ms-transition":e.speed+"s opacity, "+e.speed+"s -ms-transform","-ms-transform":"scale(1)","-o-transition":e.speed+"s opacity, "+e.speed+"s -o-transform","-o-transform":"scale(1)",opacity:"1"})},1),setTimeout(function(){$("#w2ui-popup").css({"-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":""}),t.trigger($.extend(u,{phase:"after"}))},e.speed*1e3)}else{var u=this.trigger({phase:"before",type:"open",target:"popup",options:e,present:!0});if(u.isCancelled===!0)return;if(typeof n=="undefined"||n["width"]!=e["width"]||n["height"]!=e["height"])$("#w2ui-panel").remove(),w2popup.resize(e.width,e.height);var f=$("#w2ui-popup .w2ui-box2 > .w2ui-msg-body").html(e.body);f.length>0&&(f[0].style.cssText=e.style),$("#w2ui-popup .w2ui-msg-buttons").html(e.buttons),$("#w2ui-popup .w2ui-msg-title").html((e.showClose?'<div class="w2ui-msg-button w2ui-msg-close" onclick="w2popup.close()">Close</div>':"")+(e.showMax?'<div class="w2ui-msg-button w2ui-msg-max" onclick="w2popup.max()">Max</div>':"")+e.title);var l=$("#w2ui-popup .w2ui-box1")[0],c=$("#w2ui-popup .w2ui-box2")[0];w2utils.transition(l,c,e.transition),c.className="w2ui-box1",l.className="w2ui-box2",$(c).addClass("w2ui-current-box"),$("#w2ui-popup").data("prev-size",null),setTimeout(function(){t.trigger($.extend(u,{phase:"after"}))},1)}e._last_w2ui_name=w2utils.keyboard.active(),w2utils.keyboard.active(null),$("#w2ui-popup").data("options",e),e.keyboard&&$(document).on("keydown",this.keydown);var h={resizing:!1};return $("#w2ui-popup .w2ui-msg-title").on("mousedown",function(e){p(e)}).on("mousemove",function(e){d(e)}).on("mouseup",function(e){v(e)}),$("#w2ui-popup .w2ui-msg-body").on("mousemove",function(e){d(e)}).on("mouseup",function(e){v(e)}),$("#w2ui-lock").on("mousemove",function(e){d(e)}).on("mouseup",function(e){v(e)}),this},keydown:function(e){var t=$("#w2ui-popup").data("options");if(!t.keyboard)return;var n=w2popup.trigger({phase:"before",type:"keydown",target:"popup",options:t,object:w2popup,originalEvent:e});if(n.isCancelled===!0)return;switch(e.keyCode){case 27:e.preventDefault(),$("#w2ui-popup .w2ui-popup-message").length>0?w2popup.message():w2popup.close()}w2popup.trigger($.extend(n,{phase:"after"}))},close:function(e){var t=this,e=$.extend({},$("#w2ui-popup").data("options"),e),n=this.trigger({phase:"before",type:"close",target:"popup",options:e});if(n.isCancelled===!0)return;$("#w2ui-popup, #w2ui-panel").css({"-webkit-transition":e.speed+"s opacity, "+e.speed+"s -webkit-transform","-webkit-transform":"scale(0.9)","-moz-transition":e.speed+"s opacity, "+e.speed+"s -moz-transform","-moz-transform":"scale(0.9)","-ms-transition":e.speed+"s opacity, "+e.speed+"s -ms-transform","-ms-transform":"scale(0.9)","-o-transition":e.speed+"s opacity, "+e.speed+"s -o-transform","-o-transform":"scale(0.9)",opacity:"0"}),w2popup.unlockScreen(),setTimeout(function(){$("#w2ui-popup").remove(),$("#w2ui-panel").remove(),t.trigger($.extend(n,{phase:"after"}))},e.speed*1e3),w2utils.keyboard.active(e._last_w2ui_name),e.keyboard&&$(document).off("keydown",this.keydown)},toggle:function(){var e=$("#w2ui-popup").data("options");e.maximized===!0?w2popup.min():w2popup.max()},max:function(){var e=this,t=$("#w2ui-popup").data("options");if(t.maximized===!0)return;var n=this.trigger({phase:"before",type:"max",target:"popup",options:t});if(n.isCancelled===!0)return;t.maximized=!0,t.prevSize=$("#w2ui-popup").css("width")+":"+$("#w2ui-popup").css("height"),$("#w2ui-popup").data("options",t),w2popup.resize(1e4,1e4,function(){e.trigger($.extend(n,{phase:"after"}))})},min:function(){var e=this,t=$("#w2ui-popup").data("options");if(t.maximized!==!0)return;var n=t.prevSize.split(":"),r=this.trigger({phase:"before",type:"min",target:"popup",options:t});if(r.isCancelled===!0)return;t.maximized=!1,t.prevSize=null,$("#w2ui-popup").data("options",t),w2popup.resize(n[0],n[1],function(){e.trigger($.extend(r,{phase:"after"}))})},get:function(){return $("#w2ui-popup").data("options")},set:function(e){w2popup.open(e)},clear:function(){$("#w2ui-popup .w2ui-msg-title").html(""),$("#w2ui-popup .w2ui-msg-body").html(""),$("#w2ui-popup .w2ui-msg-buttons").html("")},reset:function(){w2popup.open(w2popup.defaults)},load:function(e){function s(t,n){delete e.url,$("body").append('<div id="w2ui-tmp" style="display: none">'+t+"</div>"),typeof n!="undefined"&&$("#w2ui-tmp #"+n).length>0?$("#w2ui-tmp #"+n).w2popup(e):$("#w2ui-tmp > div").w2popup(e);if($("#w2ui-tmp > style").length>0){var r=$("<div>").append($("#w2ui-tmp > style").clone()).html();$("#w2ui-popup #div-style").length==0&&$("#w2ui-ppopup").append('<div id="div-style" style="position: absolute; left: -100; width: 1px"></div>'),$("#w2ui-popup #div-style").html(r)}$("#w2ui-tmp").remove()}if(String(e.url)=="undefined"){console.log("ERROR: The url parameter is empty.");return}var t=String(e.url).split("#"),n=t[0],r=t[1];String(e)=="undefined"&&(e={});var i=$("#w2ui-popup").data(n);typeof i!="undefined"&&i!=null?s(i,r):$.get(n,function(e,t,i){s(i.responseText,r),$("#w2ui-popup").data(n,i.responseText)})},message:function(e){$().w2tag(),e||(e={width:200,height:100}),parseInt(e.width)<10&&(e.width=10),parseInt(e.height)<10&&(e.height=10),typeof e.hideOnClick=="undefined"&&(e.hideOnClick=!1);var t=$("#w2ui-popup .w2ui-msg-title");if($("#w2ui-popup .w2ui-popup-message").length==0){var n=parseInt($("#w2ui-popup").width());$("#w2ui-popup .w2ui-box1").before('<div class="w2ui-popup-message" style="display: none; '+(t.length==0?"top: 0px;":"top: "+w2utils.getSize(t,"height")+"px;")+(typeof e.width!="undefined"?"width: "+e.width+"px; left: "+(n-e.width)/2+"px;":"left: 10px; right: 10px;")+(typeof e.height!="undefined"?"height: "+e.height+"px;":"bottom: 6px;")+'-webkit-transition: .3s; -moz-transition: .3s; -ms-transition: .3s; -o-transition: .3s;"'+(e.hideOnClick===!0?'onclick="w2popup.message();"':"")+">"+"</div>"),$("#w2ui-popup .w2ui-popup-message").data("options",e)}else typeof e.width=="undefined"&&(e.width=w2utils.getSize($("#w2ui-popup .w2ui-popup-message"),"width")),typeof e.height=="undefined"&&(e.height=w2utils.getSize($("#w2ui-popup .w2ui-popup-message"),"height"));var r=$("#w2ui-popup .w2ui-popup-message").css("display");$("#w2ui-popup .w2ui-popup-message").css({"-webkit-transform":r=="none"?"translateY(-"+e.height+"px)":"translateY(0px)","-moz-transform":r=="none"?"translateY(-"+e.height+"px)":"translateY(0px)","-ms-transform":r=="none"?"translateY(-"+e.height+"px)":"translateY(0px)","-o-transform":r=="none"?"translateY(-"+e.height+"px)":"translateY(0px)"});if(r=="none")$("#w2ui-popup .w2ui-popup-message").show().html(e.html),setTimeout(function(){$("#w2ui-popup .w2ui-popup-message").css({"-webkit-transition":"0s","-moz-transition":"0s","-ms-transition":"0s","-o-transition":"0s","z-Index":1500}),w2popup.lock(),typeof e.onOpen=="function"&&e.onOpen()},300);else{$("#w2ui-popup .w2ui-popup-message").css("z-Index",250);var e=$("#w2ui-popup .w2ui-popup-message").data("options");$("#w2ui-popup .w2ui-popup-message").remove(),w2popup.unlock(),typeof e.onClose=="function"&&e.onClose()}setTimeout(function(){$("#w2ui-popup .w2ui-popup-message").css({"-webkit-transform":r=="none"?"translateY(0px)":"translateY(-"+e.height+"px)","-moz-transform":r=="none"?"translateY(0px)":"translateY(-"+e.height+"px)","-ms-transform":r=="none"?"translateY(0px)":"translateY(-"+e.height+"px)","-o-transform":r=="none"?"translateY(0px)":"translateY(-"+e.height+"px)"})},1)},lock:function(e,t){w2utils.lock($("#w2ui-popup"),e,t)},unlock:function(){w2utils.unlock($("#w2ui-popup"))},lockScreen:function(e){return $("#w2ui-lock").length>0?!1:(typeof e=="undefined"&&(e=$("#w2ui-popup").data("options")),typeof e=="undefined"&&(e={}),e=$.extend({},w2popup.defaults,e),$("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: '+(w2utils.engine=="IE5"?"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(){$("#w2ui-lock").css({"-webkit-transition":e.speed+"s opacity","-moz-transition":e.speed+"s opacity","-ms-transition":e.speed+"s opacity","-o-transition":e.speed+"s opacity",opacity:e.opacity})},1),e.modal==1?($("#w2ui-lock").on("mousedown",function(){$("#w2ui-lock").css({"-webkit-transition":".1s","-moz-transition":".1s","-ms-transition":".1s","-o-transition":".1s",opacity:"0.6"}),window.getSelection&&window.getSelection().removeAllRanges()}),$("#w2ui-lock").on("mouseup",function(){setTimeout(function(){$("#w2ui-lock").css({"-webkit-transition":".1s","-moz-transition":".1s","-ms-transition":".1s","-o-transition":".1s",opacity:e.opacity})},100),window.getSelection&&window.getSelection().removeAllRanges()})):$("#w2ui-lock").on("mouseup",function(){w2popup.close()}),!0)},unlockScreen:function(){if($("#w2ui-lock").length==0)return!1;var e=$.extend({},$("#w2ui-popup").data("options"),e);return $("#w2ui-lock").css({"-webkit-transition":e.speed+"s opacity","-moz-transition":e.speed+"s opacity","-ms-transition":e.speed+"s opacity","-o-transition":e.speed+"s opacity",opacity:0}),setTimeout(function(){$("#w2ui-lock").remove()},e.speed*1e3),!0},resize:function(e,t,n){var r=$("#w2ui-popup").data("options");parseInt($(window).width())-10<parseInt(e)&&(e=parseInt($(window).width())-10),parseInt($(window).height())-10<parseInt(t)&&(t=parseInt($(window).height())-10);var i=(parseInt($(window).height())-parseInt(t))/2*.8,s=(parseInt($(window).width())-parseInt(e))/2;$("#w2ui-popup").css({"-webkit-transition":r.speed+"s width, "+r.speed+"s height, "+r.speed+"s left, "+r.speed+"s top","-moz-transition":r.speed+"s width, "+r.speed+"s height, "+r.speed+"s left, "+r.speed+"s top","-ms-transition":r.speed+"s width, "+r.speed+"s height, "+r.speed+"s left, "+r.speed+"s top","-o-transition":r.speed+"s width, "+r.speed+"s height, "+r.speed+"s left, "+r.speed+"s top",top:i,left:s,width:e,height:t}),typeof n=="function"&&setTimeout(function(){n()},r.speed*1e3)}},$.extend(w2popup,w2utils.event)})();var w2alert=function(e,t,n){typeof t=="undefined"&&(t=w2utils.lang("Notification")),$("#w2ui-popup").length>0?w2popup.message({width:400,height:150,html:'<div style="position: absolute; top: 0px; left: 0px; right: 0px; bottom: 40px; overflow: auto"> <div class="w2ui-centered"><div style="font-size: 13px;">'+e+"</div></div>"+"</div>"+'<div style="position: absolute; bottom: 7px; left: 0px; right: 0px; text-align: center; padding: 5px">'+' <input type="button" value="Ok" onclick="w2popup.message();" class="w2ui-popup-button">'+"</div>",onClose:function(){typeof n=="function"&&n()}}):w2popup.open({width:450,height:200,showMax:!1,title:t,body:'<div class="w2ui-centered"><div style="font-size: 13px;">'+e+"</div></div>",buttons:'<input type="button" value="'+w2utils.lang("Ok")+'" class="w2ui-popup-button" onclick="w2popup.close();">',onClose:function(){typeof n=="function"&&n()}})},w2confirm=function(e,t,n){if(typeof n=="undefined"||typeof t=="function")n=t,t=w2utils.lang("Confirmation");typeof t=="undefined"&&(t=w2utils.lang("Confirmation")),$("#w2ui-popup").length>0?w2popup.message({width:400,height:150,html:'<div style="position: absolute; top: 0px; left: 0px; right: 0px; bottom: 40px; overflow: auto"> <div class="w2ui-centered"><div style="font-size: 13px;">'+e+"</div></div>"+"</div>"+'<div style="position: absolute; bottom: 7px; left: 0px; right: 0px; text-align: center; padding: 5px">'+' <input id="No" type="button" value="'+w2utils.lang("No")+'" class="w2ui-popup-button">'+' <input id="Yes" type="button" value="'+w2utils.lang("Yes")+'" class="w2ui-popup-button">'+"</div>",onOpen:function(){$("#w2ui-popup .w2ui-popup-message .w2ui-popup-button").on("click",function(e){w2popup.message(),typeof n=="function"&&n(e.target.id)})},onKeydown:function(e){switch(e.originalEvent.keyCode){case 13:typeof n=="function"&&n("Yes"),w2popup.message();break;case 27:typeof n=="function"&&n("No"),w2popup.message()}}}):w2popup.open({width:450,height:200,title:t,modal:!0,showClose:!1,body:'<div class="w2ui-centered"><div style="font-size: 13px;">'+e+"</div></div>",buttons:'<input id="No" type="button" value="'+w2utils.lang("No")+'" class="w2ui-popup-button">'+'<input id="Yes" type="button" value="'+w2utils.lang("Yes")+'" class="w2ui-popup-button">',onOpen:function(e){e.onComplete=function(){$("#w2ui-popup .w2ui-popup-button").on("click",function(e){w2popup.close(),typeof n=="function"&&n(e.target.id)})}},onKeydown:function(e){switch(e.originalEvent.keyCode){case 13:typeof n=="function"&&n("Yes"),w2popup.close();break;case 27:typeof n=="function"&&n("No"),w2popup.close()}}})};(function(){var e=function(e){this.box=null,this.name=null,this.active=null,this.tabs=[],this.right="",this.style="",this.onClick=null,this.onClose=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,$.extend(!0,this,w2obj.tabs,e)};$.fn.w2tabs=function(t){if(typeof t=="object"||!t){if(!t||typeof t.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2tabs().');return}if(typeof w2ui[t.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+t.name+").");return}if(!w2utils.isAlphaNumeric(t.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=t.tabs,r=new e(t);$.extend(r,{tabs:[],handlers:[]});for(var i in n)r.tabs[i]=$.extend({},e.prototype.tab,n[i]);return $(this).length!=0&&r.render($(this)[0]),w2ui[r.name]=r,r}if(w2ui[$(this).attr("name")]){var s=w2ui[$(this).attr("name")];return s[t].apply(s,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+t+" does not exist on jQuery.w2tabs")},e.prototype={tab:{id:null,text:"",hidden:!1,disabled:!1,closable:!1,hint:"",onClick:null,onRefresh:null,onClose:null},add:function(e){return this.insert(null,e)},insert:function(e,t){$.isArray(t)||(t=[t]);for(var n in t){if(String(t[n].id)=="undefined"){console.log('ERROR: The parameter "id" is required but not supplied. (obj: '+this.name+")");return}var r=!0;for(var i in this.tabs)if(this.tabs[i].id==t[n].id){r=!1;break}if(!r){console.log('ERROR: The parameter "id='+t[n].id+'" is not unique within the current tabs. (obj: '+this.name+")");return}if(!w2utils.isAlphaNumeric(t[n].id)){console.log('ERROR: The parameter "id='+t[n].id+'" must be alpha-numeric + "-_". (obj: '+this.name+")");return}var t=$.extend({},t,t[n]);if(e==null||typeof e=="undefined")this.tabs.push(t);else{var s=this.get(e,!0);this.tabs=this.tabs.slice(0,s).concat([t],this.tabs.slice(s))}this.refresh(t[n].id)}},remove:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)return!1;t++,this.tabs.splice(this.get(r.id,!0),1),$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(r.id)).remove()}return t},select:function(e){return this.get(e)==null||this.active==e?!1:(this.active=e,this.refresh(),!0)},set:function(e,t){var n=this.get(e,!0);return n==null?!1:($.extend(this.tabs[n],t),this.refresh(e),!0)},get:function(e,t){if(arguments.length==0){var n=[];for(var r=0;r<this.tabs.length;r++)this.tabs[r].id!=null&&n.push(this.tabs[r].id);return n}for(var r in this.tabs)if(this.tabs[r].id==e)return t===!0?r:this.tabs[r];return null},show:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(!n||n.hidden===!1)continue;n.hidden=!1,this.refresh(n.id),e++}return e},hide:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(!n||n.hidden===!0)continue;n.hidden=!0,this.refresh(n.id),e++}return e},enable:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r||r.disabled===!1)continue;r.disabled=!1,this.refresh(r.id),t++}return t},disable:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r||r.disabled===!0)continue;r.disabled=!0,this.refresh(r.id),t++}return t},refresh:function(e){var t=(new Date).getTime();window.getSelection&&
window.getSelection().removeAllRanges();if(String(e)=="undefined")for(var n in this.tabs)this.refresh(this.tabs[n].id);var r=this.trigger({phase:"before",type:"refresh",target:typeof e!="undefined"?e:this.name,object:this.get(e)});if(r.isCancelled===!0)return!1;var i=this.get(e);if(i==null)return;typeof i.caption!="undefined"&&(i.text=i.caption);var s=$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(i.id)),o=(i.closable?'<div class="w2ui-tab-close" onclick="w2ui[\''+this.name+"'].animateClose('"+i.id+"', event);\"></div>":"")+' <div class="w2ui-tab'+(this.active==i.id?" active":"")+(i.closable?" closable":"")+'" '+' title="'+(typeof i.hint!="undefined"?i.hint:"")+'"'+" onclick=\"w2ui['"+this.name+"'].click('"+i.id+"', event);\">"+i.text+"</div>";if(s.length==0){var u="";i.hidden&&(u+="display: none;"),i.disabled&&(u+="opacity: 0.2; -moz-opacity: 0.2; -webkit-opacity: 0.2; -o-opacity: 0.2; filter:alpha(opacity=20);"),html='<td id="tabs_'+this.name+"_tab_"+i.id+'" style="'+u+'" valign="middle">'+o+"</td>",this.get(e,true)!=this.tabs.length-1&&$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(e,!0))+1].id)).length>0?$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(e,!0))+1].id)).before(html):$(this.box).find("#tabs_"+this.name+"_right").before(html)}else s.html(o),i.hidden?s.css("display","none"):s.css("display",""),i.disabled?s.css({opacity:"0.2","-moz-opacity":"0.2","-webkit-opacity":"0.2","-o-opacity":"0.2",filter:"alpha(opacity=20)"}):s.css({opacity:"1","-moz-opacity":"1","-webkit-opacity":"1","-o-opacity":"1",filter:"alpha(opacity=100)"});return this.trigger($.extend(r,{phase:"after"})),(new Date).getTime()-t},render:function(e){var t=(new Date).getTime(),n=this.trigger({phase:"before",type:"render",target:this.name,box:e});if(n.isCancelled===!0)return!1;window.getSelection&&window.getSelection().removeAllRanges(),String(e)!="undefined"&&e!=null&&($(this.box).find("> table #tabs_"+this.name+"_right").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-tabs").html(""),this.box=e);if(!this.box)return;var r='<table cellspacing="0" cellpadding="1" width="100%"> <tr><td width="100%" id="tabs_'+this.name+'_right" align="right">'+this.right+"</td></tr>"+"</table>";return $(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-tabs").html(r),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.trigger($.extend(n,{phase:"after"})),this.refresh(),(new Date).getTime()-t},resize:function(){window.getSelection&&window.getSelection().removeAllRanges();var e=this.trigger({phase:"before",type:"resize",target:this.name});if(e.isCancelled===!0)return!1;this.trigger($.extend(e,{phase:"after"}))},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});if(e.isCancelled===!0)return!1;$(this.box).find("> table #tabs_"+this.name+"_right").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-tabs").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"}))},click:function(e,t){var n=this.get(e);if(n==null||n.disabled)return!1;var r=this.trigger({phase:"before",type:"click",target:e,object:this.get(e),originalEvent:t});if(r.isCancelled===!0)return!1;$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.active)+" .w2ui-tab").removeClass("active"),this.active=n.id,this.trigger($.extend(r,{phase:"after"})),this.refresh(e)},animateClose:function(e,t){var n=this.get(e);if(n==null||n.disabled)return!1;var r=this.trigger({phase:"before",type:"close",target:e,object:this.get(e),originalEvent:t});if(r.isCancelled===!0)return!1;var i=this;$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(n.id)).css({"-webkit-transition":".2s","-moz-transition":"2s","-ms-transition":".2s","-o-transition":".2s",opacity:"0"}),setTimeout(function(){var e=$(i.box).find("#tabs_"+i.name+"_tab_"+w2utils.escapeId(n.id)).width();$(i.box).find("#tabs_"+i.name+"_tab_"+w2utils.escapeId(n.id)).html('<div style="width: '+e+'px; -webkit-transition: .2s; -moz-transition: .2s; -ms-transition: .2s; -o-transition: .2s"></div>'),setTimeout(function(){$(i.box).find("#tabs_"+i.name+"_tab_"+w2utils.escapeId(n.id)).find(":first-child").css({width:"0px"})},50)},200),setTimeout(function(){i.remove(e)},450),this.trigger($.extend(r,{phase:"after"})),this.refresh()},animateInsert:function(e,t){if(this.get(e)==null)return;if(!$.isPlainObject(t))return;var n=!0;for(var r in this.tabs)if(this.tabs[r].id==t.id){n=!1;break}if(!n){console.log('ERROR: The parameter "id='+t.id+'" is not unique within the current tabs. (obj: '+this.name+")");return}var i=$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(t.id));if(i.length!=0)return;typeof t.caption!="undefined"&&(t.text=t.caption);var s='<div id="_tmp_tabs" class="w2ui-reset w2ui-tabs" style="position: absolute; top: -1000px;"><table cellspacing="0" cellpadding="1" width="100%"><tr><td id="_tmp_simple_tab" style="" valign="middle">'+(t.closable?'<div class="w2ui-tab-close"></div>':"")+' <div class="w2ui-tab '+(this.active==t.id?"active":"")+'">'+t.text+"</div>"+"</td></tr></table>"+"</div>";$("body").append(s),tabHTML='<div style="width: 1px; -webkit-transition: 0.2s; -moz-transition: 0.2s; -ms-transition: 0.2s; -o-transition: 0.2s;"> </div>';var o="";t.hidden&&(o+="display: none;"),t.disabled&&(o+="opacity: 0.2; -moz-opacity: 0.2; -webkit-opacity: 0.2; -o-opacity: 0.2; filter:alpha(opacity=20);"),html='<td id="tabs_'+this.name+"_tab_"+t.id+'" style="'+o+'" valign="middle">'+tabHTML+"</td>",this.get(e,true)!=this.tabs.length&&$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(e,!0))].id)).length>0?$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(e,!0))].id)).before(html):$(this.box).find("#tabs_"+this.name+"_right").before(html);var u=this;setTimeout(function(){var e=$("#_tmp_simple_tab").width();$("#_tmp_tabs").remove(),$("#tabs_"+u.name+"_tab_"+w2utils.escapeId(t.id)+" > div").css("width",e+"px")},1),setTimeout(function(){u.insert(e,t)},200)}},$.extend(e.prototype,w2utils.event),w2obj.tabs=e})(),function(){var e=function(e){this.box=null,this.name=null,this.items=[],this.right="",this.onClick=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,$.extend(!0,this,w2obj.toolbar,e)};$.fn.w2toolbar=function(t){if(typeof t=="object"||!t){if(!t||typeof t.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2toolbar().');return}if(typeof w2ui[t.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+t.name+").");return}if(!w2utils.isAlphaNumeric(t.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=t.items,r=new e(t);$.extend(r,{items:[],handlers:[]});for(var i in n)r.items[i]=$.extend({},e.prototype.item,n[i]);return $(this).length!=0&&r.render($(this)[0]),w2ui[r.name]=r,r}if(w2ui[$(this).attr("name")]){var s=w2ui[$(this).attr("name")];return s[t].apply(s,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+t+" does not exist on jQuery.w2toolbar")},e.prototype={item:{id:null,type:"button",text:"",html:"",img:null,icon:null,hidden:!1,disabled:!1,checked:!1,arrow:!0,hint:"",group:null,items:null,onClick:null},add:function(e){this.insert(null,e)},insert:function(t,n){$.isArray(n)||(n=[n]);for(var r in n){if(typeof n[r].type=="undefined"){console.log('ERROR: The parameter "type" is required but not supplied in w2toolbar.add() method.');return}if($.inArray(String(n[r].type),["button","check","radio","drop","menu","break","html","spacer"])==-1){console.log('ERROR: The parameter "type" should be one of the following [button, check, radio, drop, menu, break, html, spacer] in w2toolbar.add() method.');return}if(typeof n[r].id=="undefined"){console.log('ERROR: The parameter "id" is required but not supplied in w2toolbar.add() method.');return}var i=!0;for(var s=0;s<this.items.length;s++)if(this.items[s].id==n[r].id){i=!1;return}if(!i){console.log('ERROR: The parameter "id" is not unique within the current toolbar.');return}if(!w2utils.isAlphaNumeric(n[r].id)){console.log('ERROR: The parameter "id" must be alpha-numeric + "-_".');return}var o=$.extend({},e.prototype.item,n[r]);if(t==null||typeof t=="undefined")this.items.push(o);else{var u=this.get(t,!0);this.items=this.items.slice(0,u).concat([o],this.items.slice(u))}this.refresh(o.id)}},remove:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,$(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(r.id)).remove();var i=this.get(r.id,!0);i&&this.items.splice(i,1)}return t},set:function(e,t){var n=this.get(e,!0);return n==null?!1:($.extend(this.items[n],t),this.refresh(e),!0)},get:function(e,t){if(arguments.length==0){var n=[];for(var r=0;r<this.items.length;r++)this.items[r].id!=null&&n.push(this.items[r].id);return n}for(var r=0;r<this.items.length;r++)if(this.items[r].id==e)return t===!0?r:this.items[r];return null},show:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.hidden=!1,this.refresh(r.id)}return t},hide:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.hidden=!0,this.refresh(r.id)}return t},enable:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.disabled=!1,this.refresh(r.id)}return t},disable:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.disabled=!0,this.refresh(r.id)}return t},check:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.checked=!0,this.refresh(r.id)}return t},uncheck:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.checked=!1,this.refresh(r.id)}return t},render:function(e){var t=this.trigger({phase:"before",type:"render",target:this.name,box:e});if(t.isCancelled===!0)return!1;typeof e!="undefined"&&e!=null&&($(this.box).find("> table #tb_"+this.name+"_right").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-toolbar").html(""),this.box=e);if(!this.box)return;var n='<table cellspacing="0" cellpadding="0" width="100%"><tr>';for(var r=0;r<this.items.length;r++){var i=this.items[r];if(typeof i.id=="undefined"||i.id==null)i.id="item_"+r;if(i==null)continue;i.type=="spacer"?n+='<td width="100%" id="tb_'+this.name+"_item_"+i.id+'" align="right"></td>':n+='<td id="tb_'+this.name+"_item_"+i.id+'" style="'+(i.hidden?"display: none":"")+'" '+' class="'+(i.disabled?"disabled":"")+'" valign="middle">'+this.getItemHTML(i)+"</td>"}n+='<td width="100%" id="tb_'+this.name+'_right" align="right">'+this.right+"</td>",n+="</tr></table>",$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-toolbar").html(n),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.trigger($.extend(t,{phase:"after"}))},refresh:function(e){var t=(new Date).getTime();window.getSelection&&window.getSelection().removeAllRanges();var n=this.trigger({phase:"before",type:"refresh",target:typeof e!="undefined"?e:this.name,item:this.get(e)});if(n.isCancelled===!0)return!1;if(typeof e=="undefined")for(var r=0;r<this.items.length;r++){var i=this.items[r];if(typeof i.id=="undefined"||i.id==null)i.id="item_"+r;this.refresh(i.id)}var i=this.get(e);if(i==null)return;var s=$(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(i.id)),o=this.getItemHTML(i);return s.length==0?(i.type=="spacer"?o='<td width="100%" id="tb_'+this.name+"_item_"+i.id+'" align="right"></td>':o='<td id="tb_'+this.name+"_item_"+i.id+'" style="'+(i.hidden?"display: none":"")+'" '+' class="'+(i.disabled?"disabled":"")+'" valign="middle">'+o+"</td>",this.get(e,true)==this.items.length-1?$(this.box).find("#tb_"+this.name+"_right").before(o):$(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(this.items[parseInt(this.get(e,!0))+1].id)).before(o)):(s.html(o),i.hidden?s.css("display","none"):s.css("display",""),i.disabled?s.addClass("disabled"):s.removeClass("disabled")),this.trigger($.extend(n,{phase:"after"})),(new Date).getTime()-t},resize:function(){var e=(new Date).getTime();window.getSelection&&window.getSelection().removeAllRanges();var t=this.trigger({phase:"before",type:"resize",target:this.name});return t.isCancelled===!0?!1:(this.trigger($.extend(t,{phase:"after"})),(new Date).getTime()-e)},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});if(e.isCancelled===!0)return!1;$(this.box).find("> table #tb_"+this.name+"_right").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-toolbar").html(""),$(this.box).html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"}))},getItemHTML:function(e){var t="";typeof e.caption!="undefined"&&(e.text=e.caption),typeof e.hint=="undefined"&&(e.hint=""),typeof e.text=="undefined"&&(e.text="");switch(e.type){case"menu":case"button":case"check":case"radio":case"drop":var n="<td> </td>";e.img&&(n='<td><div class="w2ui-tb-image w2ui-icon '+e.img+'"></div></td>'),e.icon&&(n='<td><div class="w2ui-tb-image"><span class="'+e.icon+'"></span></div></td>'),t+='<table cellpadding="0" cellspacing="0" title="'+e.hint+'" class="w2ui-button '+(e.checked?"checked":"")+'" '+" onclick = \"var el=w2ui['"+this.name+"']; if (el) el.click('"+e.id+"', event);\" "+' onmouseover = "'+(e.disabled?"":"$(this).addClass('over');")+'"'+' onmouseout = "'+(e.disabled?"":"$(this).removeClass('over');")+'"'+' onmousedown = "'+(e.disabled?"":"$(this).addClass('down');")+'"'+' onmouseup = "'+(e.disabled?"":"$(this).removeClass('down');")+'"'+">"+"<tr><td>"+' <table cellpadding="1" cellspacing="0">'+" <tr>"+n+(e.text!=""?'<td class="w2ui-tb-caption" nowrap>'+e.text+"</td>":"")+(e.type!="drop"&&e.type!="menu"||e.arrow===!1?"":'<td class="w2ui-tb-down" nowrap> </td>')+" </tr></table>"+"</td></tr></table>";break;case"break":t+='<table cellpadding="0" cellspacing="0"><tr> <td><div class="w2ui-break"> </div></td></tr></table>';break;case"html":t+='<table cellpadding="0" cellspacing="0"><tr> <td nowrap>'+e.html+"</td>"+"</tr></table>"}var r="";return typeof e.onRender=="function"&&(r=e.onRender.call(this,e.id,t)),typeof this.onRender=="function"&&(r=this.onRender(e.id,t)),r!=""&&typeof r!="undefined"&&(t=r),t},menuClick:function(e,t,n){window.getSelection&&window.getSelection().removeAllRanges();var r=this,i=this.get(e);if(i&&!i.disabled){var s=this.trigger({phase:"before",type:"click",target:typeof e!="undefined"?e:this.name,item:this.get(e),subItem:typeof t!="undefined"&&this.get(e)?this.get(e).items[t]:null,originalEvent:n});if(s.isCancelled===!0)return!1;this.trigger($.extend(s,{phase:"after"}))}},click:function(e,t){window.getSelection&&window.getSelection().removeAllRanges();var n=this,r=this.get(e);if(r&&!r.disabled){var i=this.trigger({phase:"before",type:"click",target:typeof e!="undefined"?e:this.name,item:this.get(e),originalEvent:t});if(i.isCancelled===!0)return!1;$("#tb_"+this.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").removeClass("down");if(r.type=="radio"){for(var s=0;s<this.items.length;s++){var o=this.items[s];if(o==null||o.id==r.id||o.type!="radio")continue;o.group==r.group&&o.checked&&(o.checked=!1,this.refresh(o.id))}r.checked=!0,$("#tb_"+this.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").addClass("checked")}if(r.type=="drop"||r.type=="menu")r.checked?r.checked=!1:setTimeout(function(){function t(){r.checked=!1,r.checked?$("#tb_"+n.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").addClass("checked"):$("#tb_"+n.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").removeClass("checked"),n.refresh(r.id),$(document).off("click",t)}var e=$("#tb_"+n.name+"_item_"+w2utils.escapeId(r.id));$.isPlainObject(r.overlay)||(r.overlay={}),r.type=="drop"&&e.w2overlay(r.html,$.extend({left:(e.width()-50)/2,top:3},r.overlay)),r.type=="menu"&&e.w2menu(r.items,$.extend({left:(e.width()-50)/2,top:3},r.overlay,{select:function(e,t,i){n.menuClick(r.id,i,t)}})),$(document).on("click",t)},1);if(r.type=="check"||r.type=="drop"||r.type=="menu")r.checked=!r.checked,r.checked?$("#tb_"+this.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").addClass("checked"):$("#tb_"+this.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").removeClass("checked");this.trigger($.extend(i,{phase:"after"}))}}},$.extend(e.prototype,w2utils.event),w2obj.toolbar=e}(),function(){var e=function(e){this.name=null,this.box=null,this.sidebar=null,this.parent=null,this.nodes=[],this.menu=[],this.selected=null,this.img=null,this.icon=null,this.style="",this.topHTML="",this.bottomHTML="",this.keyboard=!0,this.onClick=null,this.onDblClick=null,this.onContextMenu=null,this.onMenuClick=null,this.onExpand=null,this.onCollapse=null,this.onKeydown=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,$.extend(!0,this,w2obj.sidebar,e)};$.fn.w2sidebar=function(t){if(typeof t=="object"||!t){if(!t||typeof t.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2sidebar().');return}if(typeof w2ui[t.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+t.name+").");return}if(!w2utils.isAlphaNumeric(t.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=t.nodes,r=new e(t);return $.extend(r,{handlers:[],nodes:[]}),typeof n!="undefined"&&r.add(r,n),$(this).length!=0&&r.render($(this)[0]),r.sidebar=r,w2ui[r.name]=r,r}if(w2ui[$(this).attr("name")]){var i=w2ui[$(this).attr("name")];return i[t].apply(i,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+t+" does not exist on jQuery.w2sidebar")},e.prototype={node:{id:null,text:"",count:"",img:null,icon:null,nodes:[],style:"",selected:!1,expanded:!1,hidden:!1,disabled:!1,group:!1,plus:!1,onClick:null,onDblClick:null,onContextMenu:null,onExpand:null,onCollapse:null,parent:null,sidebar:null},add:function(e,t){return arguments.length==1&&(t=arguments[0],e=this),typeof e=="string"&&(e=this.get(e)),this.insert(e,null,t)},insert:function(t,n,r){if(arguments.length==2){r=arguments[1],n=arguments[0];var i=this.get(n);if(i==null){var s=r[o].caption!="undefined"?r[o].caption:r[o].text;return console.log('ERROR: Cannot insert node "'+s+'" because cannot find node "'+n+'" to insert before.'),null}t=this.get(n).parent}typeof t=="string"&&(t=this.get(t)),$.isArray(r)||(r=[r]);for(var o in r){if(typeof r[o].id=="undefined"){var s=r[o].caption!="undefined"?r[o].caption:r[o].text;console.log('ERROR: Cannot insert node "'+s+'" because it has no id.');continue}if(this.get(this,r[o].id)!=null){var s=r[o].caption!="undefined"?r[o].caption:r[o].text;console.log("ERROR: Cannot insert node with id="+r[o].id+" (text: "+s+") because another node with the same id already exists.");continue}var u=$.extend({},e.prototype.node,r[o]);u.sidebar=this,u.parent=t;var a=u.nodes;u.nodes=[];if(n==null)t.nodes.push(u);else{var i=this.get(t,n,!0);if(i==null){var s=r[o].caption!="undefined"?r[o].caption:r[o].text;return console.log('ERROR: Cannot insert node "'+s+'" because cannot find node "'+n+'" to insert before.'),null}t.nodes.splice(i,0,u)}typeof a!="undefined"&&a.length>0&&this.insert(u,null,a)}return this.refresh(t.id),u},remove:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(n==null)continue;var r=this.get(n.parent,arguments[t],!0);if(r==null)continue;n.parent.nodes.splice(r,1),e++}return e>0&&arguments.length==1?this.refresh(n.parent.id):this.refresh(),e},set:function(e,t,n){arguments.length==2&&(n=t,t=e,e=this),this._tmp=null,typeof e=="string"&&(e=this.get(e));if(e.nodes==null)return null;for(var r=0;r<e.nodes.length;r++){if(e.nodes[r].id==t){var i=n.nodes;return $.extend(e.nodes[r],n,{nodes:[]}),typeof i!="undefined"&&this.add(e.nodes[r],i),this.refresh(t),!0}this._tmp=this.set(e.nodes[r],t,n);if(this._tmp)return!0}return!1},get:function(e,t,n){if(arguments.length==1||arguments.length==2&&t===!0)n=t,t=e,e=this;this._tmp=null,typeof e=="string"&&(e=this.get(e));if(e.nodes==null)return null;for(var r=0;r<e.nodes.length;r++){if(e.nodes[r].id==t)return n===!0?r:e.nodes[r];this._tmp=this.get(e.nodes[r],t,n);if(this._tmp||this._tmp===0)return this._tmp}return this._tmp},hide:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(n==null)continue;n.hidden=!0,e++}return arguments.length==1?this.refresh(arguments[0]):this.refresh(),e},show:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(n==null)continue;n.hidden=!1,e++}return arguments.length==1?this.refresh(arguments[0]):this.refresh(),e},disable:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(n==null)continue;n.disabled=!0,n.selected&&this.unselect(n.id),e++}return arguments.length==1?this.refresh(arguments[0]):this.refresh(),e},enable:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(n==null)continue;n.disabled=!1,e++}return arguments.length==1?this.refresh(arguments[0]):this.refresh(),e},select:function(e){if(this.selected==e)return!1;this.unselect(this.selected);var t=this.get(e);if(!t)return!1;$(this.box).find("#node_"+w2utils.escapeId(e)).addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected"),t.selected=!0,this.selected=e},unselect:function(e){var t=this.get(e);return t?(t.selected=!1,$(this.box).find("#node_"+w2utils.escapeId(e)).removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected"),this.selected==e&&(this.selected=null),!0):!1},toggle:function(e){var t=this.get(e);if(t==null)return;if(t.plus){this.set(e,{plus:!1}),this.expand(e),this.refresh(e);return}if(t.nodes.length==0)return;this.get(e).expanded?this.collapse(e):this.expand(e)},collapse:function(e){var t=this.get(e),n=this.trigger({phase:"before",type:"collapse",target:e,object:t});if(n.isCancelled===!0)return!1;$(this.box).find("#node_"+w2utils.escapeId(e)+"_sub").slideUp("fast"),$(this.box).find("#node_"+w2utils.escapeId(e)+" .w2ui-node-dots:first-child").html('<div class="w2ui-expand">+</div>'),t.expanded=!1,this.trigger($.extend(n,{phase:"after"})),this.resize()},collapseAll:function(e){typeof e=="undefined"&&(e=this),typeof e=="string"&&(e=this.get(e));if(e.nodes==null)return null;for(var t=0;t<e.nodes.length;t++)e.nodes[t].expanded===!0&&(e.nodes[t].expanded=!1),e.nodes[t].nodes&&e.nodes[t].nodes.length>0&&this.collapseAll(e.nodes[t]);this.refresh(e.id)},expand:function(e){var t=this.get(e),n=this.trigger({phase:"before",type:"expand",target:e,object:t});if(n.isCancelled===!0)return!1;$(this.box).find("#node_"+w2utils.escapeId(e)+"_sub").slideDown("fast"),$(this.box).find("#node_"+w2utils.escapeId(e)+" .w2ui-node-dots:first-child").html('<div class="w2ui-expand">-</div>'),t.expanded=!0,this.trigger($.extend(n,{phase:"after"})),this.resize()},expandAll:function(e){typeof e=="undefined"&&(e=this),typeof e=="string"&&(e=this.get(e));if(e.nodes==null)return null;for(var t=0;t<e.nodes.length;t++)e.nodes[t].expanded===!1&&(e.nodes[t].expanded=!0),e.nodes[t].nodes&&e.nodes[t].nodes.length>0&&this.collapseAll(e.nodes[t]);this.refresh(e.id)},expandParents:function(e){var t=this.get(e);if(t==null)return;t.parent&&(t.parent.expanded=!0,this.expandParents(t.parent.id)),this.refresh(e)},click:function(e,t){var n=this,r=this.get(e);if(r==null)return;var i=this.selected;if(r.disabled||r.group)return;$(n.box).find("#node_"+w2utils.escapeId(i)).removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected"),$(n.box).find("#node_"+w2utils.escapeId(e)).addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected"),setTimeout(function(){var s=n.trigger({phase:"before",type:"click",target:e,originalEvent:t,object:r});if(s.isCancelled===!0)return $(n.box).find("#node_"+w2utils.escapeId(e)).removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected"),$(n.box).find("#node_"+w2utils.escapeId(i)).addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected"),!1;i!=null&&(n.get(i).selected=!1),n.get(e).selected=!0,n.selected=e,n.trigger($.extend(s,{phase:"after"}))},1)},keydown:function(e){function s(e,n){if(e==null)return null;var r=e.parent,i=t.get(e.id,!0),o=null;if(e.expanded&&e.nodes.length>0&&n!==!0){var u=e.nodes[0];!u.disabled&&!u.group?o=u:o=s(u)}else r&&i+1<r.nodes.length?o=r.nodes[i+1]:o=s(r,!0);return o!=null&&(o.disabled||o.group)&&(o=s(o)),o}function o(e){if(e==null)return null;var n=e.parent,r=t.get(e.id,!0),i=null,s=!1;if(r>0){i=n.nodes[r-1];if(i.expanded&&i.nodes.length>0){var u=i.nodes[i.nodes.length-1];!u.disabled&&!u.group?i=u:i=o(u)}}else i=n,s=!0;return i!=null&&(i.disabled||i.group)&&(i=o(i)),i}var t=this,n=t.get(t.selected);if(!n||t.keyboard!==!0)return;var r=t.trigger({phase:"before",type:"keydown",target:t.name,originalEvent:e});if(r.isCancelled===!0)return!1;(e.keyCode==13||e.keyCode==32)&&n.nodes.length>0&&t.toggle(t.selected),e.keyCode==37&&(n.nodes.length>0?t.collapse(t.selected):n.parent&&!n.parent.disabled&&!n.parent.group&&(t.collapse(n.parent.id),t.click(n.parent.id),setTimeout(function(){t.scrollIntoView()},50))),e.keyCode==39&&n.nodes.length>0&&t.expand(t.selected);if(e.keyCode==38){var i=o(n);i!=null&&(t.click(i.id,e),setTimeout(function(){t.scrollIntoView()},50))}if(e.keyCode==40){var i=s(n);i!=null&&(t.click(i.id,e),setTimeout(function(){t.scrollIntoView()},50))}$.inArray(e.keyCode,[13,32,37,38,39,40])!=-1&&(e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation()),t.trigger($.extend(r,{phase:"after"}));return},scrollIntoView:function(e){typeof e=="undefined"&&(e=this.selected);var t=this.get(e);if(t==null)return;var n=$(this.box).find(".w2ui-sidebar-div"),r=$(this.box).find("#node_"+w2utils.escapeId(e)),i=r.offset().top-n.offset().top;i+r.height()>n.height()&&n.animate({scrollTop:n.scrollTop()+n.height()/1.3}),i<=0&&n.animate({scrollTop:n.scrollTop()-n.height()/1.3})},dblClick:function(e,t){window.getSelection&&window.getSelection().removeAllRanges();var n=this.get(e),r=this.trigger({phase:"before",type:"dblClick",target:e,originalEvent:t,object:n});if(r.isCancelled===!0)return!1;n.nodes.length>0&&this.toggle(e),this.trigger($.extend(r,{phase:"after"}))},contextMenu:function(e,t){var n=this,r=n.get(e);e!=n.selected&&n.click(e),setTimeout(function(){var i=n.trigger({phase:"before",type:"contextMenu",target:e,originalEvent:t,object:r});if(i.isCancelled===!0)return!1;if(r.group||r.disabled)return;n.menu.length>0&&$(n.box).find("#node_"+w2utils.escapeId(e)).w2menu(n.menu,{left:(t?t.offsetX||t.pageX:50)-25,select:function(t,r,i){n.menuClick(e,i,r)}}),n.trigger($.extend(i,{phase:"after"}))},1)},menuClick:function(e,t,n){var r=this,i=r.trigger({phase:"before",type:"menuClick",target:e,originalEvent:n,menuIndex:t,menuItem:r.menu[t]});if(i.isCancelled===!0)return!1;r.trigger($.extend(i,{phase:"after"}))},render:function(e){var t=this.trigger({phase:"before",type:"render",target:this.name,box:e});if(t.isCancelled===!0)return!1;typeof e!="undefined"&&e!=null&&($(this.box).find("> div > div.w2ui-sidebar-div").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-sidebar").html(""),this.box=e);if(!this.box)return;$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-sidebar").html('<div><div class="w2ui-sidebar-top"></div><div class="w2ui-sidebar-div"></div><div class="w2ui-sidebar-bottom"></div></div>'),$(this.box).find("> div").css({width:$(this.box).width()+"px",height:$(this.box).height()+"px"}),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.topHTML!=""&&($(this.box).find(".w2ui-sidebar-top").html(this.topHTML),$(this.box).find(".w2ui-sidebar-div").css("top",$(this.box).find(".w2ui-sidebar-top").height()+"px")),this.bottomHTML!=""&&($(this.box).find(".w2ui-sidebar-bottom").html(this.bottomHTML),$(this.box).find(".w2ui-sidebar-div").css("bottom",$(this.box).find(".w2ui-sidebar-bottom").height()+"px")),this.trigger($.extend(t,{phase:"after"})),this.refresh()},refresh:function(e){function f(e){var t="",n=e.img;n==null&&(n=this.img);var i=e.icon;i==null&&(i=this.icon);var s=e.parent,o=0;while(s&&s.parent!=null)s.group&&o--,s=s.parent,o++;typeof e.caption!="undefined"&&(e.text=e.caption);if(e.group)t='<div class="w2ui-node-group" id="node_'+e.id+'"'+" onclick=\"w2ui['"+r.name+"'].toggle('"+e.id+"'); "+" var sp=$(this).find('span:nth-child(1)'); if (sp.html() == '"+w2utils.lang("Hide")+"') sp.html('"+w2utils.lang("Show")+"'); else sp.html('"+w2utils.lang("Hide")+"');\""+" onmouseout=\"$(this).find('span:nth-child(1)').css('color', 'transparent')\" "+" onmouseover=\"$(this).find('span:nth-child(1)').css('color', 'inherit')\">"+" <span>"+(!e.hidden&&e.expanded?w2utils.lang("Hide"):w2utils.lang("Show"))+"</span>"+" <span>"+e.text+"</span>"+"</div>"+'<div class="w2ui-node-sub" id="node_'+e.id+'_sub" style="'+e.style+";"+(!e.hidden&&e.expanded?"":"display: none;")+'"></div>';else{e.selected&&!e.disabled&&(r.selected=e.id);var s="";n&&(s='<div class="w2ui-node-image w2ui-icon '+n+(e.selected&&!e.disabled?" w2ui-icon-selected":"")+'"></div>'),i&&(s='<div class="w2ui-node-image"><span class="'+i+'"></span></div>'),t='<div class="w2ui-node '+(e.selected?"w2ui-selected":"")+" "+(e.disabled?"w2ui-disabled":"")+'" id="node_'+e.id+'" style="'+(e.hidden?"display: none;":"")+'"'+" ondblclick=\"w2ui['"+r.name+"'].dblClick('"+e.id+"', event);\""+" oncontextmenu=\"w2ui['"+r.name+"'].contextMenu('"+e.id+"', event); "+' if (event.preventDefault) event.preventDefault();"'+" onClick=\"w2ui['"+r.name+"'].click('"+e.id+"', event); \">"+'<table cellpadding="0" cellspacing="0" style="margin-left:'+o*18+"px; padding-right:"+o*18+'px"><tr>'+'<td class="w2ui-node-dots" nowrap onclick="w2ui[\''+r.name+"'].toggle('"+e.id+"'); "+' if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">'+' <div class="w2ui-expand">'+(e.nodes.length>0?e.expanded?"-":"+":e.plus?"+":"")+"</div>"+"</td>"+'<td class="w2ui-node-data" nowrap>'+s+(e.count!==""?'<div class="w2ui-node-count">'+e.count+"</div>":"")+'<div class="w2ui-node-caption">'+e.text+"</div>"+"</td>"+"</tr></table>"+"</div>"+'<div class="w2ui-node-sub" id="node_'+e.id+'_sub" style="'+e.style+";"+(!e.hidden&&e.expanded?"":"display: none;")+'"></div>'}return t}var t=(new Date).getTime();window.getSelection&&window.getSelection().removeAllRanges();var n=this.trigger({phase:"before",type:"refresh",target:typeof e!="undefined"?e:this.name});if(n.isCancelled===!0)return!1;this.topHTML!=""&&($(this.box).find(".w2ui-sidebar-top").html(this.topHTML),$(this.box).find(".w2ui-sidebar-div").css("top",$(this.box).find(".w2ui-sidebar-top").height()+"px")),this.bottomHTML!=""&&($(this.box).find(".w2ui-sidebar-bottom").html(this.bottomHTML),$(this.box).find(".w2ui-sidebar-div").css("bottom",$(this.box).find(".w2ui-sidebar-bottom").height()+"px")),$(this.box).find("> div").css({width:$(this.box).width()+"px",height:$(this.box).height()+"px"});var r=this;if(typeof e=="undefined")var i=this,s=".w2ui-sidebar-div";else{var i=this.get(e);if(i==null)return;var s="#node_"+w2utils.escapeId(i.id)+"_sub"}if(i!=this){var o="#node_"+w2utils.escapeId(i.id),u=f(i);$(this.box).find(o).before('<div id="sidebar_'+this.name+'_tmp"></div>'),$(this.box).find(o).remove(),$(this.box).find(s).remove(),$("#sidebar_"+this.name+"_tmp").before(u),$("#sidebar_"+this.name+"_tmp").remove()}$(this.box).find(s).html("");for(var a=0;a<i.nodes.length;a++){var u=f(i.nodes[a]);$(this.box).find(s).append(u),i.nodes[a].nodes.length!=0&&this.refresh(i.nodes[a].id)}return this.trigger($.extend(n,{phase:"after"})),(new Date).getTime()-t},resize:function(){var e=(new Date).getTime();window.getSelection&&window.getSelection().removeAllRanges();var t=this.trigger({phase:"before",type:"resize",target:this.name});return t.isCancelled===!0?!1:($(this.box).css("overflow","hidden"),$(this.box).find("> div").css({width:$(this.box).width()+"px",height:$(this.box).height()+"px"}),this.trigger($.extend(t,{phase:"after"})),(new Date).getTime()-e)},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});if(e.isCancelled===!0)return!1;$(this.box).find("> div > div.w2ui-sidebar-div").length>0&&$(this.box).removeAttr("name"
).removeClass("w2ui-reset w2ui-sidebar").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"}))},lock:function(e,t){var n=$(this.box).find("> div:first-child");w2utils.lock(n,e,t)},unlock:function(){w2utils.unlock(this.box)}},$.extend(e.prototype,w2utils.event),w2obj.sidebar=e}(),function(e){var t=new function(){this.customTypes=[]};e.fn.w2field=function(e){if(t[e])return t[e].apply(this,Array.prototype.slice.call(arguments,1));if(typeof e=="object")return t.init.apply(this,arguments);if(typeof e=="string")return t.init.apply(this,[{type:e}]);console.log("ERROR: Method "+e+" does not exist on jQuery.w2field")},e.extend(t,{init:function(n){var r=t;return e(this).each(function(r,i){if(typeof t.customTypes[n.type.toLowerCase()]=="function"){t.customTypes[n.type.toLowerCase()].call(this,n);return}var s=n.type.toLowerCase();switch(s){case"clear":e(this).off("focus").off("blur").off("keypress").off("keydown").off("change").removeData(),e(this).prev().hasClass("w2ui-list")&&(e(this).prev().remove(),e(this).removeAttr("tabindex").css("border-color","").show()),e(this).prev().hasClass("w2ui-upload")&&(e(this).prev().remove(),e(this).removeAttr("tabindex").css("border-color","").show()),e(this).prev().hasClass("w2ui-field-helper")&&(e(this).css("padding-left",e(this).css("padding-top")),e(this).prev().remove()),e(this).next().hasClass("w2ui-field-helper")&&(e(this).css("padding-right",e(this).css("padding-top")),e(this).next().remove()),e(this).next().hasClass("w2ui-field-helper")&&e(this).next().remove();break;case"text":case"int":case"float":case"money":case"alphanumeric":case"hex":var o=this,u={min:null,max:null,arrows:!1,keyboard:!0,suffix:"",prefix:""};n=e.extend({},u,n),["text","alphanumeric","hex"].indexOf(s)!=-1&&(n.arrows=!1,n.keyboard=!1),e(this).data("options",n).on("keypress",function(t){if(t.metaKey||t.ctrlKey||t.altKey||t.charCode!=t.keyCode&&t.keyCode>0)return;t.keyCode==13&&e(this).change();var n=String.fromCharCode(t.charCode);if(!c(n,!0))return t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,!1}).on("keydown",function(t,r){if(!n.keyboard)return;var i=!1,u=e(o).val();c(u)?u=parseFloat(u):u=n.min||0;var a=t.keyCode||r.keyCode,f=1;if(t.ctrlKey||t.metaKey)f=10;switch(a){case 38:e(o).val(u+f<=n.max||n.max==null?u+f:n.max).change(),s=="money"&&e(o).val(Number(e(o).val()).toFixed(2)),i=!0;break;case 40:e(o).val(u-f>=n.min||n.min==null?u-f:n.min).change(),s=="money"&&e(o).val(Number(e(o).val()).toFixed(2)),i=!0}i&&(t.preventDefault(),setTimeout(function(){o.setSelectionRange(o.value.length,o.value.length)},0))}).on("change",function(t){var r=e(o).val(),i=!1;n.min!=null&&r!=""&&r<n.min&&(e(o).val(n.min).change(),i=!0),n.max!=null&&r!=""&&r>n.max&&(e(o).val(n.max).change(),i=!0);if(i)return t.stopPropagation(),t.preventDefault(),!1;this.value!=""&&!c(this.value)&&e(this).val(n.min!=null?n.min:"")}),e(this).val()==""&&n.min!=null&&e(this).val(n.min);if(n.prefix!=""){e(this).before('<div class="w2ui-field-helper">'+n.prefix+"</div>");var a=e(this).prev();a.css({color:e(this).css("color"),"font-family":e(this).css("font-family"),"font-size":e(this).css("font-size"),"padding-top":e(this).css("padding-top"),"padding-bottom":e(this).css("padding-bottom"),"padding-left":e(this).css("padding-left"),"padding-right":0,"margin-top":parseInt(e(this).css("margin-top"))+1+"px","margin-bottom":parseInt(e(this).css("margin-bottom"))+1+"px","margin-left":0,"margin-right":0}).on("click",function(){e(this).next().focus()}),e(this).css("padding-left",a.width()+parseInt(e(this).css("padding-left"))+5+"px")}var f=parseInt(e(this).css("padding-right"));if(n.arrows!=""){e(this).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 style="position: absolute; height: 1px; border-top: 1px solid red"></div></div>');var l=w2utils.getSize(this,"height"),a=e(this).next();a.css({color:e(this).css("color"),"font-family":e(this).css("font-family"),"font-size":e(this).css("font-size"),height:e(this).height()+parseInt(e(this).css("padding-top"))+parseInt(e(this).css("padding-bottom"))+"px",padding:"0px","margin-top":parseInt(e(this).css("margin-top"))+1+"px","margin-bottom":"0px","border-left":"1px solid silver"}).css("margin-left","-"+(a.width()+parseInt(e(this).css("margin-right"))+12)+"px").on("mousedown",function(t){function i(){clearTimeout(e("body").data("_field_update_timer")),e("body").off("mouseup",i)}function s(t){e(o).focus().trigger(e.Event("keydown"),{keyCode:e(r.target).attr("type")=="up"?38:40}),t!==!1&&e("body").data("_field_update_timer",setTimeout(s,60))}var n=this,r=t;e("body").on("mouseup",i),e("body").data("_field_update_timer",setTimeout(s,700)),s(!1)}),f+=a.width()+12,e(this).css("padding-right",f+"px")}if(n.suffix!=""){e(this).after('<div class="w2ui-field-helper">'+n.suffix+"</div>");var a=e(this).next();a.css({color:e(this).css("color"),"font-family":e(this).css("font-family"),"font-size":e(this).css("font-size"),"padding-top":e(this).css("padding-top"),"padding-bottom":e(this).css("padding-bottom"),"padding-left":"3px","padding-right":e(this).css("padding-right"),"margin-top":parseInt(e(this).css("margin-top"))+1+"px","margin-bottom":parseInt(e(this).css("margin-bottom"))+1+"px"}).on("click",function(){e(this).prev().focus()}),a.css("margin-left","-"+(a.width()+parseInt(e(this).css("padding-right"))+5)+"px"),f+=a.width()+3,e(this).css("padding-right",f+"px")}function c(e,t){switch(s){case"int":if(t&&["-"].indexOf(e)!=-1)return!0;return w2utils.isInt(e);case"float":if(t&&["-","."].indexOf(e)!=-1)return!0;return w2utils.isFloat(e);case"money":if(t&&["-",".","$","€","£","¥"].indexOf(e)!=-1)return!0;return w2utils.isMoney(e);case"hex":return w2utils.isHex(e);case"alphanumeric":return w2utils.isAlphaNumeric(e)}return!0}break;case"date":var h=this,u={format:w2utils.settings.date_format,start:"",end:"",blocked:{},colored:{}};n=e.extend({},u,n),e(this).css({transition:"none","-webkit-transition":"none","-moz-transition":"none","-ms-transition":"none","-o-transition":"none"}).data("options",n).on("focus",function(){var t=parseFloat(e(h).offset().top)+parseFloat(h.offsetHeight),r=parseFloat(e(h).offset().left);clearInterval(e(h).data("mtimer")),e("#global_calendar_div").remove(),e("body").append('<div id="global_calendar_div" style="top: '+(t+parseInt(h.offsetHeight))+"px; left: "+r+'px;" '+' class="w2ui-reset w2ui-calendar" '+' onmousedown="'+" if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; "+' if (event.preventDefault) event.preventDefault(); else return false;">'+"</div>"),e("#global_calendar_div").html(e().w2field("calendar_get",h.value,n)).css({left:r+"px",top:t+"px"}).data("el",h).show();var i=e(window).width()+e(document).scrollLeft()-1;r+e("#global_calendar_div").width()>i&&e("#global_calendar_div").css("left",i-e("#global_calendar_div").width()+"px");var s=setInterval(function(){var t=e(window).width()+e(document).scrollLeft()-1,n=e(h).offset().left;n+e("#global_calendar_div").width()>t&&(n=t-e("#global_calendar_div").width()),e("#global_calendar_div").data("position")!=e(h).offset().left+"x"+(e(h).offset().top+h.offsetHeight)&&e("#global_calendar_div").css({"-webkit-transition":".2s",left:n+"px",top:e(h).offset().top+h.offsetHeight+"px"}).data("position",e(h).offset().left+"x"+(e(h).offset().top+h.offsetHeight));if(e(h).length==0||e(h).offset().left==0&&e(h).offset().top==0){clearInterval(s),e("#global_calendar_div").remove();return}},100);e(h).data("mtimer",s)}).on("blur",function(t){e(h).val(e.trim(e(h).val())),e.trim(e(h).val())!=""&&!w2utils.isDate(e(h).val(),n.format)&&e(this).w2tag(w2utils.lang("Not a valid date")+": "+n.format),clearInterval(e(h).data("mtimer")),e("#global_calendar_div").remove()}).on("keypress",function(t){var r=this;setTimeout(function(){e("#global_calendar_div").html(e().w2field("calendar_get",r.value,n))},10)}),setTimeout(function(){w2utils.isInt(h.value)&&(h.value=w2utils.formatDate(h.value,n.format))},1);break;case"time":break;case"datetime":break;case"color":var h=this,u={prefix:"#",suffix:'<div style="margin-top: 1px; height: 12px; width: 12px;"></div>'};n=e.extend({},u,n),e(this).attr("maxlength",6).on("focus",function(){var t=parseFloat(e(h).offset().top)+parseFloat(h.offsetHeight),n=parseFloat(e(h).offset().left);clearInterval(e(h).data("mtimer")),e("#global_color_div").remove(),e("body").append('<div id="global_color_div" style="top: '+(t+parseInt(h.offsetHeight))+"px; left: "+n+'px;" '+' class="w2ui-reset w2ui-calendar" '+' onmousedown="'+" if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; "+' if (event.preventDefault) event.preventDefault(); else return false;">'+"</div>"),e("#global_color_div").html(e().w2field("getColorHTML",h.value)).css({left:n+"px",top:t+"px"}).data("el",h).show();var r=e(window).width()+e(document).scrollLeft()-1;n+e("#global_color_div").width()>r&&e("#global_color_div").css("left",r-e("#global_color_div").width()+"px");var i=setInterval(function(){var t=e(window).width()+e(document).scrollLeft()-1,n=e(h).offset().left;n+e("#global_color_div").width()>t&&(n=t-e("#global_color_div").width()),e("#global_color_div").data("position")!=e(h).offset().left+"x"+(e(h).offset().top+h.offsetHeight)&&e("#global_color_div").css({"-webkit-transition":".2s",left:n+"px",top:e(h).offset().top+h.offsetHeight+"px"}).data("position",e(h).offset().left+"x"+(e(h).offset().top+h.offsetHeight));if(e(h).length==0||e(h).offset().left==0&&e(h).offset().top==0){clearInterval(i),e("#global_color_div").remove();return}},100);e(h).data("mtimer",i)}).on("click",function(){e(this).trigger("focus")}).on("blur",function(t){e(h).val(e.trim(e(h).val())),clearInterval(e(h).data("mtimer")),e("#global_color_div").remove()}).on("keydown",function(t){if(t.keyCode==86&&(t.ctrlKey||t.metaKey)){var n=this;e(this).prop("maxlength",7),setTimeout(function(){var t=e(n).val();t.substr(0,1)=="#"&&(t=t.substr(1)),w2utils.isHex(t)||(t=""),e(n).val(t).prop("maxlength",6).change()},20)}}).on("keyup",function(t){t.keyCode==86&&(t.ctrlKey||t.metaKey)&&e(this).prop("maxlength",6)}).on("keypress",function(t){t.keyCode==13&&e(this).change();var n=String.fromCharCode(t.charCode);if(!w2utils.isHex(n,!0))return t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,!1}).on("change",function(t){var n="#"+e(this).val();e(this).val().length!=6&&e(this).val().length!=3&&(n=""),e(this).next().find("div").css("background-color",n)});if(n.prefix!=""){e(this).before('<div class="w2ui-field-helper">'+n.prefix+"</div>");var a=e(this).prev();a.css({color:e(this).css("color"),"font-family":e(this).css("font-family"),"font-size":e(this).css("font-size"),"padding-top":e(this).css("padding-top"),"padding-bottom":e(this).css("padding-bottom"),"padding-left":e(this).css("padding-left"),"padding-right":0,"margin-top":parseInt(e(this).css("margin-top"))+1+"px","margin-bottom":parseInt(e(this).css("margin-bottom"))+1+"px","margin-left":0,"margin-right":0}).on("click",function(){e(this).next().focus()}),e(this).css("padding-left",a.width()+parseInt(e(this).css("padding-left"))+2+"px")}if(n.suffix!=""){e(this).after('<div class="w2ui-field-helper">'+n.suffix+"</div>");var a=e(this).next();a.css({color:e(this).css("color"),"font-family":e(this).css("font-family"),"font-size":e(this).css("font-size"),"padding-top":e(this).css("padding-top"),"padding-bottom":e(this).css("padding-bottom"),"padding-left":"3px","padding-right":e(this).css("padding-right"),"margin-top":parseInt(e(this).css("margin-top"))+1+"px","margin-bottom":parseInt(e(this).css("margin-bottom"))+1+"px"}).on("click",function(){e(this).prev().focus()}),a.css("margin-left","-"+(a.width()+parseInt(e(this).css("padding-right"))+4)+"px");var f=a.width()+parseInt(e(this).css("padding-right"))+4;e(this).css("padding-right",f+"px"),a.find("div").css("background-color","#"+e(h).val())}break;case"select":case"list":if(this.tagName!="SELECT"){console.log("ERROR: You can only apply $().w2field('list') to a SELECT element");return}var u={url:"",items:[],value:null,showNone:!0},h=this,p=e.extend({},u,n);e(h).data("settings",p),h.refresh=function(){var n=e(h).data("settings"),r="",i=t.cleanItems(n.items);n.showNone&&(r='<option value="">- '+w2utils.lang("none")+" -</option>");for(var s in i)!n.showNone&&n.value==null&&(n.value=i[s].id),r+='<option value="'+i[s].id+'">'+i[s].text+"</option>";e(h).html(r),e(h).val(n.value),e(h).val()!=n.value&&e(h).change()},p.url!=""?e.ajax({type:"GET",dataType:"text",url:p.url,complete:function(n,r){if(r=="success"){var i=e.parseJSON(n.responseText),s=e(h).data("settings");s.items=t.cleanItems(i.items),e(h).data("settings",s),h.refresh()}}}):h.refresh();break;case"enum":if(this.tagName!="INPUT"){console.log("ERROR: You can only apply $().w2field('enum') to an INPUT element");return}var u={url:"",items:[],selected:[],max:0,maxHeight:172,showAll:!1,match:"begins with",render:null,maxCache:500,onShow:null,onHide:null,onAdd:null,onRemove:null,onItemOver:null,onItemOut:null,onItemClick:null},h=this,p=e.extend({},u,n);p.items=t.cleanItems(p.items),p.selected=t.cleanItems(p.selected),e(this).data("selected",p.selected),e(this).css({padding:"0px","border-color":"transparent","background-color":"transparent",outline:"none"}),this.add=function(t){if(e(this).attr("readonly"))return;var n=e(this).data("selected"),r=e(this).data("settings");if(typeof r.onAdd=="function"){var i=r.onAdd(t,r);if(i===!1)return}e.isArray(n)||(n=[]),r.max!=0&&r.max<=n.length&&n.splice(n.length-1,1),n.push(t),e(this).data("last_del",null),e(this).trigger("change")},this.remove=function(n){var r=e(this).data("settings");if(typeof r.onRemove=="function"){var i=r.onRemove(n,r);if(i===!1)return}if(e(this).attr("readonly"))return;e(this).data("selected").splice(n,1),e(this).parent().find("[title=Remove][index="+n+"]").remove(),this.refresh(),t.list_render.call(this),e(this).trigger("change")},this.show=function(){if(e(this).attr("readonly"))return;var n=e(this).data("settings");if(e("#w2ui-global-items").length!=0)return;e("body").append('<div id="w2ui-global-items" class="w2ui-reset w2ui-items"></div>');var r=e("#w2ui-global-items");r.css({display:"block",left:e(h).offset().left+"px",top:e(h).offset().top+h.offsetHeight+3+"px"}).width(w2utils.getSize(h,"width")).data("position",e(h).offset().left+"x"+(e(h).offset().top+h.offsetHeight)),t.list_render.call(h);var i=function(){var n=e("#w2ui-global-items");if(e(h).length==0||e(h).offset().left==0&&e(h).offset().top==0){clearInterval(e(h).data("mtimer")),hide();return}n.data("position")!=e(h).offset().left+"x"+(e(h).offset().top+h.offsetHeight)&&(n.css({"-webkit-transition":".2s",left:e(h).offset().left+"px",top:e(h).offset().top+h.offsetHeight+3+"px"}).data("position",e(h).offset().left+"x"+(e(h).offset().top+h.offsetHeight)),setTimeout(function(){t.list_render.call(h,e(h).data("last_search"))},200)),n.length>0&&e(h).data("mtimer",setTimeout(i,100))};e(h).data("mtimer",setTimeout(i,100)),typeof n.onShow=="function"&&n.onShow.call(this,n)},this.hide=function(){var t=e(this).data("settings");clearTimeout(e(h).data("mtimer")),e("#w2ui-global-items").remove(),typeof t.onHide=="function"&&t.onHide.call(this,t)},this.refresh=function(){var t=this;e(e(this).data("div")).remove();var n="margin-top: "+e(this).css("margin-top")+"; "+"margin-bottom: "+e(this).css("margin-bottom")+"; "+"margin-left: "+e(this).css("margin-left")+"; "+"margin-right: "+e(this).css("margin-right")+"; "+"width: "+(w2utils.getSize(this,"width")-parseInt(e(this).css("margin-left"))-parseInt(e(this).css("margin-right")))+"px; ",r='<div class="w2ui-list" style="'+n+';">'+'<div style="padding: 0px; margin: 0px; display: inline-block"><ul>',i=e(this).data("selected");for(var s in i)r+='<li style="'+(e(this).data("last_del")==s?"opacity: 0.5":"")+'">'+' <div title="'+w2utils.lang("Remove")+'" index="'+s+'"> </div>'+i[s].text+"</li>";r+='<li style="padding-left: 0px; padding-right: 0px" class="nomouse"> <input type="text" '+(e(this).attr("readonly")?"readonly":"")+' style="background-color: transparent">'+"</li>"+"</ul></div>"+"</div>",e(this).before(r);var o=e(this).prev()[0];e(this).data("div",o),e(o).find("li").data("mouse","out").on("click",function(n){if(e(n.target).hasClass("nomouse"))return;if(n.target.title==w2utils.lang("Remove")){t.remove(e(n.target).attr("index"));return}n.stopPropagation(),typeof p.onItemClick=="function"&&p.onItemClick.call(this,p)}).on("mouseover",function(t){var n=t.target;n.tagName!="LI"&&(n=n.parentNode);if(e(n).hasClass("nomouse"))return;e(n).data("mouse")=="out"&&typeof p.onItemOver=="function"&&p.onItemOver.call(this,p),e(n).data("mouse","over")}).on("mouseout",function(t){var n=t.target;n.tagName!="LI"&&(n=n.parentNode);if(e(n).hasClass("nomouse"))return;e(n).data("mouse","leaving"),setTimeout(function(){e(n).data("mouse")=="leaving"&&(e(n).data("mouse","out"),typeof p.onItemOut=="function"&&p.onItemOut.call(this,p))},0)}),e(o).on("click",function(t){e(this).find("input").focus()}).find("input").on("focus",function(n){e(o).css({outline:"auto 5px -webkit-focus-ring-color","outline-offset":"-2px"}),t.show(),n.stopPropagation?n.stopPropagation():n.cancelBubble=!0}).on("blur",function(n){e(o).css("outline","none"),t.hide(),n.stopPropagation?n.stopPropagation():n.cancelBubble=!0}),t.resize()},this.resize=function(){var t=e(this).data("settings"),n=e(this).prev(),r=e(n).find(">div").height();r<23&&(r=23),r>t.maxHeight&&(r=t.maxHeight),e(n).height(r+(r%23==0?0:23-r%23)),n.length>0&&(n[0].scrollTop=1e3),e(this).height(r)},e(this).data("settings",p).attr("tabindex",-1),h.refresh();break;case"upload":if(this.tagName!="INPUT"){console.log("ERROR: You can only apply $().w2field('upload') to an INPUT element");return}var u={url:"",base64:!0,hint:w2utils.lang("Attach files by dragging and dropping or Click to Select"),max:0,maxSize:0,maxFileSize:0,onAdd:null,onRemove:null,onItemClick:null,onItemDblClick:null,onItemOver:null,onItemOut:null,onProgress:null,onComplete:null},h=this,p=e.extend({},u,n);p.base64===!0&&(p.maxSize==0&&(p.maxSize=20971520),p.maxFileSize==0&&(p.maxFileSize=20971520));var d=p.selected;delete p.selected,e.isArray(d)||(d=[]),e(this).data("selected",d).data("settings",p).attr("tabindex",-1),t.upload_init.call(this),this.refresh=function(){var t=this,n=e(this).data("div"),r=e(this).data("settings"),i=e(this).data("selected");e(n).find("li").remove(),e(n).find("> span:first-child").css("line-height",e(n).height()-w2utils.getSize(n,"+height")-8+"px");for(var s in i){var o=i[s],u=e(n).find(".file-list li").length;e(n).find("> span:first-child").remove(),e(n).find(".file-list").append('<li id="file-'+u+'">'+' <div class="file-delete" onmouseover="event.stopPropagation();"> </div>'+' <span class="file-name">'+o.name+"</span>"+' <span class="file-size"> - '+w2utils.size(o.size)+"</span>"+"</li>");var a=e(n).find(".file-list #file-"+u),f="";/image/i.test(o.type)&&(f='<div style="padding: 2px;"> <img src="##FILE##" style="max-width: 300px;" onload="var w = $(this).width(); var h = $(this).height(); if (w < 300 & h < 300) return; if (w >= h && w > 300) $(this).width(300); if (w < h && h > 300) $(this).height(300);" onerror="this.style.display = \'none\'" ></div>');var l='style="padding: 3px; text-align: right; color: #777;"',c='style="padding: 3px"';f+='<div style="padding: 5px;"> <table cellpadding="2"> <tr><td '+l+">Name:</td><td "+c+">"+o.name+"</td></tr>"+" <tr><td "+l+">Size:</td><td "+c+">"+w2utils.size(o.size)+"</td></tr>"+" <tr><td "+l+">Type:</td><td "+c+">"+' <span style="width: 200px; display: block-inline; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">'+o.type+"</span>"+" </td></tr>"+" <tr><td "+l+">Modified:</td><td "+c+">"+w2utils.date(o.modified)+"</td></tr>"+" </table>"+"</div>",a.data("file",o).on("click",function(n){if(typeof r.onItemClick=="function"){var i=r.onItemClick.call(t,e(this).data("file"));if(i===!1)return}e(n.target).hasClass("file-delete")||n.stopPropagation()}).on("dblclick",function(n){if(typeof r.onItemDblClick=="function"){var i=r.onItemDblClick.call(t,e(this).data("file"));if(i===!1)return}n.stopPropagation(),document.selection?document.selection.empty():document.defaultView.getSelection().removeAllRanges()}).on("mouseover",function(n){if(typeof r.onItemOver=="function"){var i=r.onItemOver.call(t,e(this).data("file"));if(i===!1)return}var s=e(this).data("file");e(this).w2overlay(f.replace("##FILE##",s.content?"data:"+s.type+";base64,"+s.content:""),{top:-4})}).on("mouseout",function(){if(typeof r.onItemOut=="function"){var n=r.onItemOut.call(t,e(this).data("file"));if(n===!1)return}e(this).w2overlay()})}},this.refresh();break;case"slider":break;default:console.log('ERROR: w2field does not recognize "'+n.type+'" field type.')}})},addType:function(e,n){t.customTypes[String(e).toLowerCase()]=n},cleanItems:function(t){var n=[];for(var r in t){var i="",s="",o=t[r];if(o==null)continue;if(e.isPlainObject(t))i=r,s=o;else{typeof o=="object"&&(typeof o.id!="undefined"&&(i=o.id),typeof o.value!="undefined"&&(i=o.value),typeof o.txt!="undefined"&&(s=o.txt),typeof o.text!="undefined"&&(s=o.text));if(typeof o=="string"){if(String(o)=="")continue;i=o,s=o,o={}}}w2utils.isInt(i)&&(i=parseInt(i)),w2utils.isFloat(i)&&(i=parseFloat(i)),n.push(e.extend({},o,{id:i,text:s}))}return n},upload_init:function(){var n=this,r=e(this).data("settings"),i=e(n).prev();i.length>0&&i[0].tagName=="DIV"&&i.hasClass("w2ui-upload")&&i.remove();var s="margin-top: "+e(n).css("margin-top")+"; "+"margin-bottom: "+e(n).css("margin-bottom")+"; "+"margin-left: "+e(n).css("margin-left")+"; "+"margin-right: "+e(n).css("margin-right")+"; "+"width: "+(w2utils.getSize(n,"width")-parseInt(e(n).css("margin-left"))-parseInt(e(n).css("margin-right")))+"px; "+"height: "+(w2utils.getSize(n,"height")-parseInt(e(n).css("margin-top"))-parseInt(e(n).css("margin-bottom")))+"px; ",o='<div style="'+s+'" class="w2ui-upload">'+" <span>"+r.hint+"</span>"+' <ul class="file-list"></ul>'+' <input class="file-input" type="file" name="attachment" multiple style="display: none">'+"</div>";e(n).css({display1:"none","border-color":"transparent"}).before(o),e(n).data("div",e(n).prev()[0]);var u=e(n).data("div");e(u).find(".file-input").off("change").on("change",function(){if(typeof this.files!="undefined")for(var e=0,r=this.files.length;e<r;e++)t.upload_add.call(n,this.files[e])}),e(u).off("click").on("click",function(r){e(u).w2tag();if(r.target.tagName=="LI"||e(r.target).hasClass("file-size"))return;if(e(r.target).hasClass("file-delete")){t.upload_remove.call(n,r.target.parentNode);return}if(r.target.tagName!="INPUT"){var i=e(n).data("settings"),s=e(n).data("selected"),o=0;for(var a in s)o++;(o<i.max||i.max==0)&&e(u).find(".file-input").click()}}).off("dragenter").on("dragenter",function(t){e(u).addClass("dragover")}).off("dragleave").on("dragleave",function(t){e(u).removeClass("dragover")}).off("drop").on("drop",function(r){e(u).removeClass("dragover");var i=r.originalEvent.dataTransfer.files;for(var s=0,o=i.length;s<o;s++)t.upload_add.call(n,i[s]);r.preventDefault(),r.stopPropagation()}).off("dragover").on("dragover",function(e){e.preventDefault(),e.stopPropagation()})},upload_add:function(t){var n=this,r=e(n).data("div"),i=e(n).data("settings"),s=e(n).data("selected"),o={name:t.name,type:t.type,modified:t.lastModifiedDate,size:t.size,content:null},u=0,a=0;for(var f in s)u+=s[f].size,a++;if(i.maxFileSize!=0&&o.size>i.maxFileSize){var l="Maximum file size is "+w2utils.size(i.maxFileSize);e(r).w2tag(l),console.log("ERROR: "+l);return}if(i.maxSize!=0&&u+o.size>i.maxSize){var l="Maximum total size is "+w2utils.size(i.maxFileSize);e(r).w2tag(l),console.log("ERROR: "+l);return}if(i.max!=0&&a>=i.max){var l="Maximum number of files is "+i.max;e(r).w2tag(l),console.log("ERROR: "+l);return}if(typeof i.onAdd=="function"){var c=i.onAdd.call(n,o);if(c===!1)return}s.push(o);if(typeof FileReader!="undefined"&&i.base64===!0){var h=new FileReader;h.onload=function(){return function(t){var r=t.target.result,i=r.indexOf(",");o.content=r.substr(i+1),n.refresh(),e(n).trigger("change")}}(),h.readAsDataURL(t)}else n.refresh(),e(n).trigger("change")},upload_remove:function(t){var n=this,r=e(n).data("div"),i=e(n).data("settings"),s=e(n).data("selected"),o=e(t).data("file");if(typeof i.onRemove=="function"){var u=i.onRemove.call(n,o);if(u===!1)return!1}for(var a=s.length-1;a>=0;a--)s[a].name==o.name&&s[a].size==o.size&&s.splice(a,1);e(t).fadeOut("fast"),setTimeout(function(){e(t).remove(),s.length==0&&e(r).prepend("<span>"+i.hint+"</span>"),n.refresh(),e(n).trigger("change")},300)},list_render:function(n){var r=this,i=e("#w2ui-global-items"),s=e(this).data("settings"),o=s.items,u=e(this).data("selected");if(i.length==0)return;if(typeof n=="undefined"){var a="";a+='<div class="w2ui-items-list"></div>',i.html(a),n=""}e(this).data("last_search",n),(typeof e(r).data("last_index")=="undefined"||e(r).data("last_index")==null)&&e(r).data("last_index",0),typeof s.last_total=="undefined"&&(s.last_total=-1),typeof s.last_search_len=="undefined"&&(s.last_search_len=0),typeof s.last_search_match=="undefined"&&(s.last_search_match=-1);if(s.url!=""&&(o.length==0&&s.last_total!=0||n.length>s.last_search_len&&s.last_total>s.maxCache||n.length<s.last_search_match&&n.length!=s.last_search_len)){var f=!1;s.last_total<s.maxCache&&(f=!0),e.ajax({type:"GET",dataType:"text",url:s.url,data:{search:n,max:s.maxCache},complete:function(i,o){s.last_total=0;if(o=="success"){var u=e.parseJSON(i.responseText);f==0&&u.total<s.maxCache&&(s.last_search_match=n.length),s.last_search_len=n.length,s.last_total=u.total,s.items=u.items,t.list_render.call(r,n)}}})}var l=0,c="<ul>",h=[];for(var p in u)h.push(w2utils.isInt(u[p].id)?parseInt(u[p].id):String(u[p].id));var d="";for(var p in o){var v=o[p].id,m=o[p].text;if(e.inArray(w2utils.isInt(v)?parseInt(v):String(v),h)!=-1&&s.showAll!==!0)continue;var g=String(n).toLowerCase(),y=m.toLowerCase(),f=g.length<=y.length&&y.substr(0,g.length)==g;s.match.toLowerCase()=="contains"&&y.indexOf(g)!=-1&&(f=!0),f&&(typeof s["render"]=="function"&&(m=s.render(o[p],u)),m!==!1&&(typeof o[p].group!="undefined"&&o[p].group!=d&&(d=o[p].group,c+='<li class="w2ui-item-group" onmousedown="event.preventDefault()">'+d+"</li>"),c+='\n<li index="'+p+'" value="'+v+'" '+" onmouseover=\"$(this).parent().find('li').removeClass('selected'); $(this).addClass('selected'); \""+' class="'+(l%2?"w2ui-item-even":"w2ui-item-odd")+(l==e(r).data("last_index")?" selected":"")+'">'+m+"</li>",l==e(r).data("last_index")&&e(r).data("last_item",o[p]),l++))}c+="</ul>";if(l==0){c='<div class="w2ui-empty-list">'+w2utils.lang("No items found")+"</div>";var b=!0}i.find(".w2ui-items-list").html(c),e(this).data("last_max",l-1),i.find("li.selected").length>0&&i.find("li.selected")[0].scrollIntoView(!1),i.css({"-webkit-transition":"0s",height:"auto"});var w=parseInt(e(document).height())-parseInt(i.offset().top)-8;parseInt(i.height())>w&&(i.css({height:w-5+"px",overflow:"show"}),e(i).find(".w2ui-items-list").css({height:w-15+"px",overflow:"auto"})),e(i).off("mousedown").on("mousedown",function(n){var i=n.target;i.tagName!="LI"&&(i=e(i).parents("li"));var o=e(i).attr("index");if(!o)return;var u=s.items[o];if(typeof o=="undefined"){if(!n.preventDefault)return!1;n.preventDefault()}r.add(u),e(r).data("last_index",0),r.refresh(),t.list_render.call(r,"")}),e(r).prev().find("li > input").val(n).css("max-width",e(i).width()-25+"px").width((n.length+2)*6+"px").focus().on("click",function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}).off("keyup").on("keyup",function(n){var i=this;setTimeout(function(){var s=e(r).data("last_index");switch(n.keyCode){case 38:s--,s<0&&(s=0),e(r).data("last_index",s),n.preventDefault&&n.preventDefault();break;case 40:s++,s>e(r).data("last_max")&&(s=e(r).data("last_max")),e(r).data("last_index",s),n.preventDefault&&n.preventDefault();break;case 13:if(typeof e(r).data("last_item")=="undefined"||e(r).data("last_item")==null||b===!0)break;var o=e(r).data("selected");r.add(e(r).data("last_item")),s>e(r).data("last_max")-1&&(s=e(r).data("last_max")-1),e(r).data("last_index",s),e(r).data("last_item",null),e(i).val(""),r.refresh(),n.preventDefault&&n.preventDefault();break;case 8:if(String(i.value)=="")if(typeof e(r).data("last_del")=="undefined"||e(r).data("last_del")==null){var o=e(r).data("selected");e.isArray(o)||(o=[]),e(r).data("last_del",o.length-1),r.refresh()}else{var o=e(r).data("selected");r.remove(o.length-1)}break;default:e(r).data("last_index",0),e(r).data("last_del",null)}r.resize();if(n.keyCode!=8||String(i.value)!="")e(r).prev().find("li").css("opacity","1"),e(r).data("last_del",null);e.inArray(n.keyCode,[16,91,37,39])==-1&&t.list_render.call(r,i.value)},10)})},calendar_get:function(t,n){var r=new Date,i=Number(r.getMonth())+1+"/"+r.getDate()+"/"+(String(r.getYear()).length>3?r.getYear():r.getYear()+1900);if(String(t)==""||String(t)=="undefined")t=w2utils.formatDate(i,n.format);w2utils.isDate(t,n.format)||(t=w2utils.formatDate(i,n.format));var s=t.replace(/-/g,"/").replace(/\./g,"/").toLowerCase().split("/"),o=n.format.replace(/-/g,"/").replace(/\./g,"/").toLowerCase(),u=new Date;o=="mm/dd/yyyy"&&(u=new Date(s[0]+"/"+s[1]+"/"+s[2])),o=="m/d/yyyy"&&(u=new Date(s[0]+"/"+s[1]+"/"+s[2])),o=="dd/mm/yyyy"&&(u=new Date(s[1]+"/"+s[0]+"/"+s[2])),o=="d/m/yyyy"&&(u=new Date(s[1]+"/"+s[0]+"/"+s[2])),o=="yyyy/dd/mm"&&(u=new Date(s[2]+"/"+s[1]+"/"+s[0])),o=="yyyy/d/m"&&(u=new Date(s[2]+"/"+s[1]+"/"+s[0])),o=="yyyy/mm/dd"&&(u=new Date(s[1]+"/"+s[2]+"/"+s[0])),o=="yyyy/m/d"&&(u=new Date(s[1]+"/"+s[2]+"/"+s[0]));var a='<table cellpadding="0" cellspacing="0"><tr><td>'+e().w2field("calendar_month",u.getMonth()+1,u.getFullYear(),n)+"</td>"+"</tr></table>";return a},calendar_next:function(t){var n=String(t).split("/"),r=n[0],i=n[1];parseInt(r)<12?r=parseInt(r)+1:(r=1,i=parseInt(i)+1);var s=e(e("#global_calendar_div.w2ui-calendar").data("el")).data("options");e("#global_calendar_div.w2ui-calendar").html(e().w2field("calendar_get",w2utils.formatDate(r+"/1/"+i,s.format),s))},calendar_previous:function(t){var n=String(t).split("/"),r=n[0],i=n[1];parseInt(r)>1?r=parseInt(r)-1:(r=12,i=parseInt(i)-1);var s=e(e("#global_calendar_div.w2ui-calendar").data("el")).data("options");e("#global_calendar_div.w2ui-calendar").html(e().w2field("calendar_get",w2utils.formatDate(r+"/1/"+i,s.format),s))},calendar_month:function(t,n,r){var i=new Date,s=w2utils.settings.fullmonths,o=w2utils.settings.fulldays,u=["31","28","31","30","31","30","31","31","30","31","30","31"],a=Number(i.getMonth())+1+"/"+i.getDate()+"/"+(String(i.getYear()).length>3?i.getYear():i.getYear()+1900);n=Number(n),t=Number(t);if(n===null||n==="")n=String(i.getYear()).length>3?i.getYear():i.getYear()+1900;if(t===null||t==="")t=Number(i.getMonth())+1;t>12&&(t-=12,n++);if(t<1||t==0)t+=12,n--;n/4==Math.floor(n/4)?u[1]="29":u[1]="28",n==null&&(n=i.getYear()),t==null&&(t=i.getMonth()-1);var i=new Date;i.setDate(1),i.setMonth(t-1),i.setYear(n);var f=i.getDay(),l=w2utils.settings.shortdays,c="";for(var h=0,p=l.length;h<p;h++)c+="<td>"+l[h]+"</td>";var d='<div class="w2ui-calendar-title" onclick="event.stopPropagation()"> <div class="w2ui-calendar-previous" onclick="$().w2field(\'calendar_previous\', \''+t+"/"+n+"')\"> <- </div>"+" <div class=\"w2ui-calendar-next\" onclick=\"$().w2field('calendar_next', '"+t+"/"+n+"')\"> -> </div> "+s[t-1]+", "+n+"</div>"+'<table class="w2ui-calendar-days" onclick="event.stopPropagation()" cellspacing="0">'+' <tr class="w2ui-day-title">'+c+"</tr>"+" <tr>",v=1;for(var m=1;m<43;m++){if(f==0&&m==1){for(var g=0;g<6;g++)d+='<td class="w2ui-day-empty"> </td>';m+=6}else if(m<f||v>u[t-1]){d+='<td class="w2ui-day-empty"> </td>',m%7==0&&(d+="</tr><tr>");continue}var y=t+"/"+v+"/"+n,b="";m%7==6&&(b="w2ui-saturday"),m%7==0&&(b="w2ui-sunday"),y==a&&(b+=" w2ui-today");var w=v,E="",S="",x="";r.colored&&r.colored[y]!=undefined&&(tmp=r.colored[y].split(":"),S="background-color: "+tmp[0]+";",E="color: "+tmp[1]+";");var T=!1;if(r.start||r.end){var N=new Date(r.start),C=new Date(r.end),k=new Date(y);if(k<N||k>C)x=" w2ui-blocked-date",T=!0}r.blocked&&e.inArray(y,r.blocked)!=-1&&(x=" w2ui-blocked-date",T=!0),d+='<td class="'+b+x+'" style="'+E+S+'" id="'+this.name+"_date_"+y+'" date="'+y+'"',T===!1&&(d+="onclick=\"var el = $('#global_calendar_div.w2ui-calendar').data('el'); $(el).val('"+w2utils.formatDate(y,r.format)+"').trigger('change').trigger('blur'); "+" if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;"+" if (event.preventDefault) event.preventDefault(); else return false;"+'"'
),d+=">"+w+"</td>";if(m%7==0||f==0&&m==1)d+="</tr><tr>";v++}return d+="</tr></table>",d},getColorHTML:function(e){var t='<div class="w2ui-color"><table cellspacing="5">',n=[["000000","444444","666666","999999","CCCCCC","EEEEEE","F3F3F3","FFFFFF"],["FF011B","FF9838","FFFD59","01FD55","00FFFE","0424F3","9B24F4","FF21F5"],["F4CCCC","FCE5CD","FFF2CC","D9EAD3","D0E0E3","CFE2F3","D9D1E9","EAD1DC"],["EA9899","F9CB9C","FEE599","B6D7A8","A2C4C9","9FC5E8","B4A7D6","D5A6BD"],["E06666","F6B26B","FED966","93C47D","76A5AF","6FA8DC","8E7CC3","C27BA0"],["CC0814","E69138","F1C232","6AA84F","45818E","3D85C6","674EA7","A54D79"],["99050C","B45F17","BF901F","37761D","124F5C","0A5394","351C75","741B47"],["660205","783F0B","7F6011","274E12","0C343D","063762","20124D","4C1030"]];for(var r=0;r<8;r++){t+="<tr>";for(var i=0;i<8;i++)t+="<td> <div onclick=\"var el = $('#global_color_div').data('el'); $(el).val($(this).attr('name')).change(); $('#global_color_div').hide()\" style=\"background-color: #"+n[r][i]+';" name="'+n[r][i]+'">'+" "+(e==n[r][i]?"•":" ")+" </div>"+"</td>";t+="</tr>",r<2&&(t+='<tr><td style="height: 8px" colspan="8"></td></tr>')}return t+="</table></div>",t}}),w2obj.field=t}(jQuery),function(){var w2form=function(e){this.name=null,this.header="",this.box=null,this.url="",this.formURL="",this.formHTML="",this.page=0,this.recid=0,this.fields=[],this.actions={},this.record={},this.original={},this.postData={},this.toolbar={},this.tabs={},this.style="",this.focus=0,this.msgNotJSON=w2utils.lang("Return data is not in JSON format."),this.msgRefresh=w2utils.lang("Refreshing..."),this.msgSaving=w2utils.lang("Saving..."),this.onRequest=null,this.onLoad=null,this.onValidate=null,this.onSubmit=null,this.onSave=null,this.onChange=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,this.onAction=null,this.onToolbar=null,this.onError=null,this.isGenerated=!1,this.last={xhr:null},$.extend(!0,this,w2obj.form,e)};$.fn.w2form=function(e){if(typeof e=="object"||!e){var t=this;if(!e||typeof e.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2form().');return}if(typeof w2ui[e.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+e.name+").");return}if(!w2utils.isAlphaNumeric(e.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=e.record,r=e.original,i=e.fields,s=e.toolbar,o=e.tabs,u=new w2form(e);$.extend(u,{record:{},original:{},fields:[],tabs:{},toolbar:{},handlers:[]});if($.isArray(o)){$.extend(!0,u.tabs,{tabs:[]});for(var a in o){var f=o[a];typeof f=="object"?u.tabs.tabs.push(f):u.tabs.tabs.push({id:f,caption:f})}}else $.extend(!0,u.tabs,o);$.extend(!0,u.toolbar,s);for(var l in i)u.fields[l]=$.extend(!0,{},i[l]);for(var l in n)$.isPlainObject(n[l])?u.record[l]=$.extend(!0,{},n[l]):u.record[l]=n[l];for(var l in r)$.isPlainObject(r[l])?u.original[l]=$.extend(!0,{},r[l]):u.original[l]=r[l];return t.length>0&&(u.box=t[0]),u.formURL!=""?$.get(u.formURL,function(e){u.formHTML=e,u.isGenerated=!0;if($(u.box).length!=0||e.length!=0)$(u.box).html(e),u.render(u.box)}):u.formHTML==""&&($(this).length!=0&&$.trim($(this).html())!=""?u.formHTML=$(this).html():u.formHTML=u.generateHTML()),w2ui[u.name]=u,u.formURL==""&&(String(u.formHTML).indexOf("w2ui-page")==-1&&(u.formHTML='<div class="w2ui-page page-0">'+u.formHTML+"</div>"),$(u.box).html(u.formHTML),u.isGenerated=!0,u.render(u.box)),u}if(w2ui[$(this).attr("name")]){var t=w2ui[$(this).attr("name")];return t[e].apply(t,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+e+" does not exist on jQuery.w2form")},w2form.prototype={get:function(e,t){for(var n in this.fields)if(this.fields[n].name==e)return t===!0?n:this.fields[n];return null},set:function(e,t){for(var n in this.fields)if(this.fields[n].name==e)return $.extend(this.fields[n],t),this.refresh(),!0;return!1},reload:function(e){var t=typeof this.url!="object"?this.url:this.url.get;t&&this.recid!=0?this.request(e):(this.refresh(),typeof e=="function"&&e())},clear:function(){this.recid=0,this.record={};for(var e in this.fields)var t=this.fields[e];$().w2tag(),this.refresh()},error:function(e){var t=this,n=this.trigger({target:this.name,type:"error",message:e,xhr:this.last.xhr});if(n.isCancelled===!0)return typeof callBack=="function"&&callBack(),!1;setTimeout(function(){w2alert(e,"Error")},1),this.trigger($.extend(n,{phase:"after"}))},validate:function(e){typeof e=="undefined"&&(e=!0);var t=[];for(var n in this.fields){var r=this.fields[n];this.record[r.name]==null&&(this.record[r.name]="");switch(r.type){case"int":this.record[r.name]&&!w2utils.isInt(this.record[r.name])&&t.push({field:r,error:w2utils.lang("Not an integer")});break;case"float":this.record[r.name]&&!w2utils.isFloat(this.record[r.name])&&t.push({field:r,error:w2utils.lang("Not a float")});break;case"money":this.record[r.name]&&!w2utils.isMoney(this.record[r.name])&&t.push({field:r,error:w2utils.lang("Not in money format")});break;case"hex":this.record[r.name]&&!w2utils.isHex(this.record[r.name])&&t.push({field:r,error:w2utils.lang("Not a hex number")});break;case"email":this.record[r.name]&&!w2utils.isEmail(this.record[r.name])&&t.push({field:r,error:w2utils.lang("Not a valid email")});break;case"checkbox":this.record[r.name]==1?this.record[r.name]=1:this.record[r.name]=0;break;case"date":this.record[r.name]&&!w2utils.isDate(this.record[r.name],r.options.format)&&t.push({field:r,error:w2utils.lang("Not a valid date")+": "+r.options.format});break;case"select":case"list":break;case"enum":}var i=this.record[r.name];r.required&&(i===""||$.isArray(i)&&i.length==0)&&t.push({field:r,error:w2utils.lang("Required field")}),r.equalto&&this.record[r.name]!=this.record[r.equalto]&&t.push({field:r,error:w2utils.lang("Field should be equal to ")+r.equalto})}var s=this.trigger({phase:"before",target:this.name,type:"validate",errors:t});if(s.isCancelled===!0)return t;if(e)for(var o in s.errors){var u=s.errors[o];$(u.field.el).w2tag(u.error,{"class":"w2ui-error"})}return this.trigger($.extend(s,{phase:"after"})),t},request:function(postData,callBack){var obj=this;typeof postData=="function"&&(callBack=postData,postData=null);if(typeof postData=="undefined"||postData==null)postData={};if(!this.url||typeof this.url=="object"&&!this.url.get)return;if(this.recid==null||typeof this.recid=="undefined")this.recid=0;var params={};params.cmd="get-record",params.name=this.name,params.recid=this.recid,$.extend(params,this.postData),$.extend(params,postData);var eventData=this.trigger({phase:"before",type:"request",target:this.name,url:this.url,postData:params});if(eventData.isCancelled===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Request aborted."}),!1;this.record={},this.original={},this.lock(this.msgRefresh);var url=eventData.url;typeof eventData.url=="object"&&eventData.url.get&&(url=eventData.url.get);if(this.last.xhr)try{this.last.xhr.abort()}catch(e){}this.last.xhr=$.ajax({type:"GET",url:url,data:String($.param(eventData.postData,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]"),dataType:"text",complete:function(xhr,status){obj.unlock();var eventData=obj.trigger({phase:"before",target:obj.name,type:"load",xhr:xhr,status:status});if(eventData.isCancelled===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Request aborted."}),!1;var responseText=obj.last.xhr.responseText;if(status!="error"){if(typeof responseText!="undefined"&&responseText!=""){var data;if(typeof responseText=="object")data=responseText;else try{eval("data = "+responseText)}catch(e){}typeof data=="undefined"&&(data={status:"error",message:obj.msgNotJSON,responseText:responseText}),data["status"]=="error"?obj.error(data.message):(obj.record=$.extend({},data.record),obj.original=$.extend({},data.record))}}else obj.error("AJAX Error "+xhr.status+": "+xhr.statusText);obj.trigger($.extend(eventData,{phase:"after"})),obj.refresh(),typeof callBack=="function"&&callBack(data)}}),this.trigger($.extend(eventData,{phase:"after"}))},submit:function(e,t){return this.save(e,t)},save:function(postData,callBack){var obj=this;typeof postData=="function"&&(callBack=postData,postData=null);var errors=obj.validate(!0);if(errors.length!==0){obj.goto(errors[0].field.page);return}if(typeof postData=="undefined"||postData==null)postData={};if(!obj.url||typeof obj.url=="object"&&!obj.url.save){console.log("ERROR: Form cannot be saved because no url is defined.");return}obj.lock(obj.msgSaving+' <span id="'+obj.name+'_progress"></span>'),setTimeout(function(){var params={};params.cmd="save-record",params.name=obj.name,params.recid=obj.recid,$.extend(params,obj.postData),$.extend(params,postData),params.record=$.extend(!0,{},obj.record);for(var f in obj.fields){var field=obj.fields[f];switch(String(field.type).toLowerCase()){case"date":var dt=params.record[field.name];if(field.options.format.toLowerCase()=="dd/mm/yyyy"||field.options.format.toLowerCase()=="dd-mm-yyyy"||field.options.format.toLowerCase()=="dd.mm.yyyy")var tmp=dt.replace(/-/g,"/").replace(/\./g,"/").split("/"),dt=new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]);params.record[field.name]=w2utils.formatDate(dt,"yyyy-mm-dd")}}var eventData=obj.trigger({phase:"before",type:"submit",target:obj.name,url:obj.url,postData:params});if(eventData.isCancelled===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Saving aborted."}),!1;var url=eventData.url;typeof eventData.url=="object"&&eventData.url.save&&(url=eventData.url.save);if(obj.last.xhr)try{obj.last.xhr.abort()}catch(e){}obj.last.xhr=$.ajax({type:w2utils.settings.RESTfull?obj.recid==0?"POST":"PUT":"POST",url:url,data:String($.param(eventData.postData,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]"),dataType:"text",xhr:function(){var e=new window.XMLHttpRequest;return e.upload.addEventListener("progress",function(e){if(e.lengthComputable){var t=Math.round(e.loaded/e.total*100);$("#"+obj.name+"_progress").text(""+t+"%")}},!1),e},complete:function(xhr,status){obj.unlock();var eventData=obj.trigger({phase:"before",target:obj.name,type:"save",xhr:xhr,status:status});if(eventData.isCancelled===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Saving aborted."}),!1;var responseText=xhr.responseText;if(status!="error"){if(typeof responseText!="undefined"&&responseText!=""){var data;if(typeof responseText=="object")data=responseText;else try{eval("data = "+responseText)}catch(e){}typeof data=="undefined"&&(data={status:"error",message:obj.msgNotJSON,responseText:responseText}),data["status"]=="error"?obj.error(data.message):obj.original=$.extend({},obj.record)}}else obj.error("AJAX Error "+xhr.status+": "+xhr.statusText);obj.trigger($.extend(eventData,{phase:"after"})),obj.refresh(),typeof callBack=="function"&&callBack(data)}}),obj.trigger($.extend(eventData,{phase:"after"}))},50)},lock:function(e,t){var n=$(this.box).find("> div:first-child");w2utils.lock(n,e,t)},unlock:function(){var e=this;setTimeout(function(){w2utils.unlock(e.box)},25)},"goto":function(e){typeof e!="undefined"&&(this.page=e),$(this.box).data("auto-size")===!0&&$(this.box).height(0),this.refresh()},generateHTML:function(){var e=[];for(var t in this.fields){var n="",r=this.fields[t];typeof r.html=="undefined"&&(r.html={}),r.html=$.extend(!0,{caption:"",span:6,attr:"",text:"",page:0},r.html),r.html.caption==""&&(r.html.caption=r.name);var i='<input name="'+r.name+'" type="text" '+r.html.attr+"/>";r.type=="list"&&(i='<select name="'+r.name+'" '+r.html.attr+"></select>"),r.type=="checkbox"&&(i='<input name="'+r.name+'" type="checkbox" '+r.html.attr+"/>"),r.type=="textarea"&&(i='<textarea name="'+r.name+'" '+r.html.attr+"></textarea>"),n+='\n <div class="w2ui-label '+(typeof r.html.span!="undefined"?"w2ui-span"+r.html.span:"")+'">'+r.html.caption+":</div>"+'\n <div class="w2ui-field '+(typeof r.html.span!="undefined"?"w2ui-span"+r.html.span:"")+'">'+i+r.html.text+"</div>",typeof e[r.html.page]=="undefined"&&(e[r.html.page]='<div class="w2ui-page page-'+r.html.page+'">'),e[r.html.page]+=n}for(var s in e)e[s]+="\n</div>";var o="";if(!$.isEmptyObject(this.actions)){o+='\n<div class="w2ui-buttons">';for(var u in this.actions)o+='\n <input type="button" value="'+u+'" name="'+u+'">';o+="\n</div>"}return e.join("")+o},action:function(e,t){var n=this.trigger({phase:"before",target:e,type:"action",originalEvent:t});if(n.isCancelled===!0)return!1;typeof this.actions[e]=="function"&&this.actions[e].call(this,t),this.trigger($.extend(n,{phase:"after"}))},resize:function(){function l(){n.width($(e.box).width()).height($(e.box).height()),i.css("top",e.header!=""?w2utils.getSize(r,"height"):0),s.css("top",(e.header!=""?w2utils.getSize(r,"height"):0)+(e.toolbar.items.length>0?w2utils.getSize(i,"height"):0)),o.css("top",(e.header!=""?w2utils.getSize(r,"height"):0)+(e.toolbar.items.length>0?w2utils.getSize(i,"height")+5:0)+(e.tabs.tabs.length>0?w2utils.getSize(s,"height")+5:0)),o.css("bottom",f.length>0?w2utils.getSize(f,"height"):0)}var e=this,t=this.trigger({phase:"before",target:this.name,type:"resize"});if(t.isCancelled===!0)return!1;var n=$(this.box).find("> div"),r=$(this.box).find("> div .w2ui-form-header"),i=$(this.box).find("> div .w2ui-form-toolbar"),s=$(this.box).find("> div .w2ui-form-tabs"),o=$(this.box).find("> div .w2ui-page"),u=$(this.box).find("> div .w2ui-page.page-"+this.page),a=$(this.box).find("> div .w2ui-page.page-"+this.page+" > div"),f=$(this.box).find("> div .w2ui-buttons");l();if(parseInt($(this.box).height())==0||$(this.box).data("auto-size")===!0)$(this.box).height((r.length>0?w2utils.getSize(r,"height"):0)+(this.tabs.tabs.length>0?w2utils.getSize(s,"height"):0)+(this.toolbar.items.length>0?w2utils.getSize(i,"height"):0)+(o.length>0?w2utils.getSize(a,"height")+w2utils.getSize(u,"+height")+12:0)+(f.length>0?w2utils.getSize(f,"height"):0)),$(this.box).data("auto-size",!0);l(),e.trigger($.extend(t,{phase:"after"}))},refresh:function(){var e=this;if(!this.box)return;if(!this.isGenerated||typeof $(this.box).html()=="undefined")return;$(this.box).find("input, textarea, select").each(function(t,n){var r=typeof $(n).attr("name")!="undefined"?$(n).attr("name"):$(n).attr("id"),i=e.get(r);if(i){var s=$(n).parents(".w2ui-page");if(s.length>0)for(var o=0;o<100;o++)if(s.hasClass("page-"+o)){i.page=o;break}}});var t=this.trigger({phase:"before",target:this.name,type:"refresh",page:this.page});if(t.isCancelled===!0)return!1;$(this.box).find(".w2ui-page").hide(),$(this.box).find(".w2ui-page.page-"+this.page).show(),$(this.box).find(".w2ui-form-header").html(this.header),typeof this.tabs=="object"&&this.tabs.tabs.length>0?($("#form_"+this.name+"_tabs").show(),this.tabs.active=this.tabs.tabs[this.page].id,this.tabs.refresh()):$("#form_"+this.name+"_tabs").hide(),typeof this.toolbar=="object"&&this.toolbar.items.length>0?($("#form_"+this.name+"_toolbar").show(),this.toolbar.refresh()):$("#form_"+this.name+"_toolbar").hide();for(var n in this.fields){var r=this.fields[n];r.el=$(this.box).find('[name="'+String(r.name).replace(/\\/g,"\\\\")+'"]')[0],typeof r.el=="undefined"&&console.log('ERROR: Cannot associate field "'+r.name+'" with html control. Make sure html control exists with the same name.'),r.el&&(r.el.id=r.name),$(r.el).off("change").on("change",function(){var t=this.value,n=e.record[this.name]?e.record[this.name]:"",r=e.get(this.name);if((r.type=="enum"||r.type=="upload")&&$(this).data("selected")){var i=$(this).data("selected"),s=e.record[this.name],t=[],n=[];if($.isArray(i))for(var o in i)t[o]=$.extend(!0,{},i[o]);if($.isArray(s))for(var o in s)n[o]=$.extend(!0,{},s[o])}var u=e.trigger({phase:"before",target:this.name,type:"change",value_new:t,value_previous:n});if(u.isCancelled===!0)return $(this).val(e.record[this.name]),!1;var a=this.value;this.type=="checkbox"&&(a=this.checked?!0:!1),this.type=="radio"&&(a=this.checked?!0:!1),r.type=="enum"&&(a=t),r.type=="upload"&&(a=t),e.record[this.name]=a,e.trigger($.extend(u,{phase:"after"}))}),r.required?$(r.el).parent().addClass("w2ui-required"):$(r.el).parent().removeClass("w2ui-required")}$(this.box).find("button, input[type=button]").each(function(t,n){$(n).off("click").on("click",function(t){var n=this.value;this.name&&(n=this.name),this.id&&(n=this.id),e.action(n,t)})});for(var n in this.fields){var r=this.fields[n],i=typeof this.record[r.name]!="undefined"?this.record[r.name]:"";if(!r.el)continue;switch(String(r.type).toLowerCase()){case"email":case"text":case"textarea":r.el.value=i;break;case"date":r.options||(r.options={}),r.options.format||(r.options.format=w2utils.settings.date_format),r.el.value=i,this.record[r.name]=i,$(r.el).w2field($.extend({},r.options,{type:"date"}));break;case"int":r.el.value=i,$(r.el).w2field("int");break;case"float":r.el.value=i,$(r.el).w2field("float");break;case"money":r.el.value=i,$(r.el).w2field("money");break;case"hex":r.el.value=i,$(r.el).w2field("hex");break;case"alphanumeric":r.el.value=i,$(r.el).w2field("alphaNumeric");break;case"checkbox":this.record[r.name]==1||this.record[r.name]==1||this.record[r.name]=="t"?$(r.el).prop("checked",!0):$(r.el).prop("checked",!1);break;case"password":r.el.value=i;break;case"select":case"list":$(r.el).w2field($.extend({},r.options,{type:"list",value:i}));break;case"enum":if(typeof r.options=="undefined"||typeof r.options.url=="undefined"&&typeof r.options.items=="undefined"){console.log("ERROR: (w2form."+e.name+") the field "+r.name+" defined as enum but not field.options.url or field.options.items provided.");break}this.record[r.name]=w2obj.field.cleanItems(i),i=this.record[r.name],$(r.el).w2field($.extend({},r.options,{type:"enum",selected:i}));break;case"upload":$(r.el).w2field($.extend({},r.options,{type:"upload",selected:i}));break;default:console.log('ERROR: field type "'+r.type+'" is not recognized.')}}var s=$(this.box).find(".w2ui-page");for(var o=0;o<s.length;o++)$(s[o]).find("> *").length>1&&$(s[o]).wrapInner("<div></div>");this.trigger($.extend(t,{phase:"after"})),this.resize()},render:function(e){function s(){var e=$(t.box).find("input, select, textarea");e.length>t.focus&&e[t.focus].focus()}var t=this;typeof e=="object"&&($(this.box).find("#form_"+this.name+"_tabs").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),this.box=e);if(!this.isGenerated)return;var n=this.trigger({phase:"before",target:this.name,type:"render",box:typeof e!="undefined"?e:this.box});if(n.isCancelled===!0)return!1;var r="<div>"+(this.header!=""?'<div class="w2ui-form-header">'+this.header+"</div>":"")+' <div id="form_'+this.name+'_toolbar" class="w2ui-form-toolbar"></div>'+' <div id="form_'+this.name+'_tabs" class="w2ui-form-tabs"></div>'+this.formHTML+"</div>";$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-form").html(r),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),typeof this.toolbar["render"]=="undefined"&&(this.toolbar=$().w2toolbar($.extend({},this.toolbar,{name:this.name+"_toolbar",owner:this})),this.toolbar.on("click",function(e){var n=t.trigger({phase:"before",type:"toolbar",target:e.target,originalEvent:e});if(n.isCancelled===!0)return!1;t.trigger($.extend(n,{phase:"after"}))})),typeof this.toolbar=="object"&&typeof this.toolbar.render=="function"&&this.toolbar.render($("#form_"+this.name+"_toolbar")[0]),typeof this.tabs["render"]=="undefined"&&(this.tabs=$().w2tabs($.extend({},this.tabs,{name:this.name+"_tabs",owner:this})),this.tabs.on("click",function(e){t.goto(this.get(e.target,!0))})),typeof this.tabs=="object"&&typeof this.tabs.render=="function"&&this.tabs.render($("#form_"+this.name+"_tabs")[0]),this.trigger($.extend(n,{phase:"after"})),this.resize();var i=typeof this.url!="object"?this.url:this.url.get;i&&this.recid!=0?this.request():this.refresh(),$(".w2ui-layout").length==0&&(this.tmp_resize=function(e){w2ui[t.name].resize()},$(window).off("resize","body").on("resize","body",this.tmp_resize)),setTimeout(function(){t.resize(),t.refresh()},150),this.focus>=0&&setTimeout(s,500)},destroy:function(){var e=this.trigger({phase:"before",target:this.name,type:"destroy"});if(e.isCancelled===!0)return!1;typeof this.toolbar=="object"&&this.toolbar.destroy&&this.toolbar.destroy(),typeof this.tabs=="object"&&this.tabs.destroy&&this.tabs.destroy(),$(this.box).find("#form_"+this.name+"_tabs").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"})),$(window).off("resize","body")}},$.extend(w2form.prototype,w2utils.event),w2obj.form=w2form}();