From 5f7e5986e9327ebbc8075f126fc62acb2901e475 Mon Sep 17 00:00:00 2001 From: Ruslan Makarsky Date: Tue, 7 May 2019 18:11:04 -0700 Subject: [PATCH] Small fixes --- dist/w2ui.js | 138 +++++++++++++++++++++++++++++++++++++++-------- dist/w2ui.min.js | 10 ++-- src/w2form.js | 128 ++++++++++++++++++++++++++++++++++++------- src/w2grid.js | 10 ++-- test/form2.html | 31 +++++++++-- 5 files changed, 262 insertions(+), 55 deletions(-) diff --git a/dist/w2ui.js b/dist/w2ui.js index a87ebd719..6ca823b4d 100644 --- a/dist/w2ui.js +++ b/dist/w2ui.js @@ -3731,7 +3731,7 @@ w2utils.event = { info : null // info bubble, can be bool/object }, - msgDelete : 'Are you sure you want to delete selected records?', + msgDelete : 'Are you sure you want to delete NN records?', msgNotJSON : 'Returned data is not in valid JSON format.', msgAJAXerror : 'AJAX error. See console for more details.', msgRefresh : 'Refreshing...', @@ -5706,8 +5706,6 @@ w2utils.event = { if (!w2utils.isInt(this.last.xhr_offset)) this.last.xhr_offset = 0; // add list params var params = { - cmd : cmd, - selected : this.getSelection(), limit : this.limit, offset : parseInt(this.offset) + parseInt(this.last.xhr_offset), searchLogic : this.last.logic, @@ -6491,9 +6489,11 @@ w2utils.event = { if (recs.length === 0) return; if (this.msgDelete != '' && !force) { this.message({ - width : 350, + width : 380, height : 170, - body : '
' + w2utils.lang(obj.msgDelete) + '
', + body : '
' + + w2utils.lang(obj.msgDelete).replace('NN', recs.length).replace('records', (recs.length == 1 ? 'record' : 'records')) + + '
', buttons : (w2utils.settings.macButtonOrder ? '' + '' @@ -19212,6 +19212,11 @@ var w2prompt = function (label, title, callBack) { }) } } + if (fld.type == 'map') { + var tmp = { nestedFields: true, record: data }; + var val = this.getValue.call(tmp, fld.field); + if (val._order) delete val._order + } }.bind(this)) return data; }, @@ -19681,6 +19686,7 @@ var w2prompt = function (label, title, callBack) { input = '
'; break; case 'map': + case 'array': field.html.key = field.html.key || {}; field.html.value = field.html.value || {}; input = ''+ @@ -20140,8 +20146,18 @@ var w2prompt = function (label, title, callBack) { $(field.el).val(value); break; case 'map': + case 'array': + // init map + if (field.type == 'map' && (value == null || !$.isPlainObject(value))) { + this.setValue(field.field, {}) + value = this.getValue(field.field) + } + if (field.type == 'array' && (value == null || !Array.isArray(value))) { + this.setValue(field.field, []) + value = this.getValue(field.field) + } // need closure - (function (field) { + (function (obj, field) { field.el.mapAdd = function (field, div, cnt) { var html = '
'+ ''+ @@ -20154,7 +20170,17 @@ var w2prompt = function (label, title, callBack) { field.el.mapRefresh = function (map, div) { // generate options var cnt = 1; - Object.keys(map).forEach(function (item) { + var names; + if (field.type == 'map') { + if (!$.isPlainObject(map)) map = {} + if (map._order == null) map._order = Object.keys(map) + names = map._order + } + if (field.type == 'array') { + if (!Array.isArray(map)) map = [] + names = map.map(function (item) { return item.key }) + } + names.forEach(function (item) { var $k = div.find('#' + field.name + '_key_' + cnt) var $v = div.find('#' + field.name + '_value_' + cnt) if ($k.length == 0 || $v.length == 0) { @@ -20162,32 +20188,98 @@ var w2prompt = function (label, title, callBack) { $k = div.find('#' + field.name + '_key_' + cnt) $v = div.find('#' + field.name + '_value_' + cnt) } + var val = map[item]; + if (field.type == 'array') { + var tmp = map.filter(function(it) { return it.key == item ? true : false}) + if (tmp.length > 0) val = tmp[0].value + } $k.val(item) - $v.val(map[item]) - $k.parent().attr('data-key', item) + $v.val(val) + $k.parents('.w2ui-map-field').attr('data-key', item) cnt++ }) - field.el.mapAdd(field, div, cnt); + var curr = div.find('#' + field.name + '_key_' + cnt).parent() + var next = div.find('#' + field.name + '_key_' + (cnt + 1)).parent() + if (curr.length == 0) { + field.el.mapAdd(field, div, cnt); + } + if (curr.length == 1 && next.length == 1) { + curr.removeAttr('data-key') + curr.find('.key').val(next.find('.key').val()); + curr.find('.value').val(next.find('.value').val()); + next.remove() + } // attach events $(field.el).next().find('input.w2ui-map') .off('.mapChange') - .on('input.mapChange', function (event) { - var $cont = $(event.target).parents('.w2ui-field') - var $input = $cont.find('input') - var old_key = $(event.target).parents('.w2ui-map-field').attr('data-key') - var key = $(event.target).parents('.w2ui-map-field').find('.key').val() - var value = $(event.target).parents('.w2ui-map-field').find('.value').val() - delete map[old_key]; - map[key] = value; - console.log('change', map); - }) - .on('blur.mapChange', function () { - console.log('blue') + .on('change.mapChange', function () { + var $div = $(event.target).parents('.w2ui-map-field') + var old = $div.attr('data-key') + var key = $div.find('.key').val() + var value = $div.find('.value').val() + // event before + var value_new = {} + var value_previous = {} + var aMap = null + var aIndex = null + value_new[key] = value + if (field.type == 'array') { + map.forEach(function (it, ind) { + if (it.key == old) aIndex = ind + }) + aMap = map[aIndex] + } + if (old != null && field.type == 'map') { + value_previous[old] = map[old] + } + if (old != null && field.type == 'array') { + value_previous[old] = aMap.value + } + var edata = obj.trigger({ phase: 'before', target: field.field, type: 'change', originalEvent: event, value_new: value_new, value_previous: value_previous }) + if (edata.isCancelled === true) { + return; + } + if (field.type == 'map') { + delete map[old]; + var ind = map._order.indexOf(old) + if (key != '') { + if (map[key] != null) { + var newKey, more = 0 + do { more++; newKey = key + more } while (map[newKey] != null) + key = newKey + $div.find('.key').val(newKey) + } + map[key] = value; + $div.attr('data-key', key) + if (ind != -1) { + map._order[ind] = key + } else { + map._order.push(key) + } + } else { + map._order.splice(ind, 1) + $div.find('.value').val('') + } + } else if (field.type == 'array') { + if (key != '') { + if (aMap == null) { + map.push({ key: key, value: value }) + } else { + aMap.key = key + aMap.value = value + } + } else { + map.splice(aInd, 1) + } + } + obj.setValue(field.field, map) field.el.mapRefresh(map, div) + // event after + obj.trigger($.extend(edata, { phase: 'after' })); }) } field.el.mapRefresh(value, $(field.el).parent().find('.w2ui-map-container')) - })(field) + })(this, field) break; case 'radio': $(field.$el).prop('checked', false).each(function (index, el) { diff --git a/dist/w2ui.min.js b/dist/w2ui.min.js index c48add3e9..c845a0d3b 100644 --- a/dist/w2ui.min.js +++ b/dist/w2ui.min.js @@ -1,9 +1,9 @@ /* w2ui 1.5.x (nightly) (c) http://w2ui.com, vitmalina@gmail.com */ var w2ui=w2ui||{},w2obj=w2obj||{},w2utils=function(a){function b(a){var b=/^[0-1]+$/;return b.test(a)}function c(a){var b=/^[-+]?[0-9]+$/;return b.test(a)}function d(a){return"string"==typeof a&&(a=a.replace(/\s+/g,"").replace(w2utils.settings.groupSymbol,"").replace(w2utils.settings.decimalSymbol,".")),("number"==typeof a||"string"==typeof a&&""!==a)&&!isNaN(Number(a))}function e(a){var b=w2utils.settings,c=new RegExp("^"+(b.currencyPrefix?"\\"+b.currencyPrefix+"?":"")+"[-+]?"+(b.currencyPrefix?"\\"+b.currencyPrefix+"?":"")+"[0-9]*[\\"+b.decimalSymbol+"]?[0-9]+"+(b.currencySuffix?"\\"+b.currencySuffix+"?":"")+"$","i");return"string"==typeof a&&(a=a.replace(new RegExp(b.groupSymbol,"g"),"")),"object"!=typeof a&&""!==a&&c.test(a)}function f(a){var b=/^(0x)?[0-9a-fA-F]+$/;return b.test(a)}function g(a){var b=/^[a-zA-Z0-9_-]+$/;return b.test(a)}function h(a){var b=/^[a-zA-Z0-9._%\-+]+@[а-яА-Яa-zA-Z0-9.-]+\.[а-яА-Яa-zA-Z]+$/;return b.test(a)}function i(a){var b=new RegExp("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");return b.test(a)}function j(a,b,d){if(!a)return!1;var e,f,g,h="Invalid Date";if(null==b&&(b=w2utils.settings.dateFormat),"function"==typeof a.getFullYear)g=a.getFullYear(),e=a.getMonth()+1,f=a.getDate();else if(parseInt(a)==a&&parseInt(a)>0)a=new Date(parseInt(a)),g=a.getFullYear(),e=a.getMonth()+1,f=a.getDate();else{if("Invalid Date"!=String(new Date(a)))return a=new Date(a),d!==!0||a;if(a=String(a),new RegExp("mon","ig").test(b)){b=b.replace(/month/gi,"m").replace(/mon/gi,"m").replace(/dd/gi,"d").replace(/[, ]/gi,"/").replace(/\/\//g,"/").toLowerCase(),a=a.replace(/[, ]/gi,"/").replace(/\/\//g,"/").toLowerCase();for(var i=0,j=w2utils.settings.fullmonths.length;i=0,f=b.indexOf("PM")>=0;var g=f||e;d=g?12:24,b=b.replace("AM","").replace("PM",""),b=a.trim(b);var h=b.split(":"),i=parseInt(h[0]||0),j=parseInt(h[1]||0),k=parseInt(h[2]||0);return!!(g&&1===h.length||2===h.length||3===h.length)&&(!(""===h[0]||i<0||i>d||!this.isInt(h[0])||h[0].length>2)&&(!(h.length>1&&(""===h[1]||j<0||j>59||!this.isInt(h[1])||2!==h[1].length))&&(!(h.length>2&&(""===h[2]||k<0||k>59||!this.isInt(h[2])||2!==h[2].length))&&(!!(g||d!==i||0===j&&0===k)&&((!g||1!==h.length||0!==i)&&(c!==!0||(f&&12!==i&&(i+=12),e&&12===i&&(i+=12),{hours:i,minutes:j,seconds:k})))))))}function l(a,b,c){null==b&&(b=w2utils.settings.datetimeFormat);var d=b.split("|");if("function"==typeof a.getFullYear)return c!==!0||a;if(parseInt(a)===a&&parseInt(a)>=0)return a=new Date(parseInt(a)),c!==!0||a;if(parseInt(a)===a&&parseInt(a)<0)return!1;if("Invalid Date"!=String(new Date(a)))return a=new Date(a),c!==!0||a;var e=String(a).indexOf(" "),f=[a.substr(0,e),a.substr(e).trim()];d[0]=d[0].trim(),d[1]&&(d[1]=d[1].trim());var g=w2utils.isDate(f[0],d[0],!0),h=w2utils.isTime(f[1],!0);return g!==!1&&h!==!1&&(c!==!0||(g.setHours(h.hours),g.setMinutes(h.minutes),g.setSeconds(h.seconds),g))}function m(a){var b;if(""===a||null==a)return"";if(b="function"==typeof a.getFullYear?a:parseInt(a)==a&&parseInt(a)>0?new Date(parseInt(a)):new Date(a),"Invalid Date"===String(b))return"";var c=new Date,d=(c.getTime()-b.getTime())/1e3,e="",f="";return d<0?(e=0,f="sec"):d<60?(e=Math.floor(d),f="sec",d<0&&(e=0,f="sec")):d<3600?(e=Math.floor(d/60),f="min"):d<86400?(e=Math.floor(d/60/60),f="hour"):d<2592e3?(e=Math.floor(d/24/60/60),f="day"):d<31536e3?(e=Math.floor(d/30/24/60/60*10)/10,f="month"):d<126144e3?(e=Math.floor(d/365/24/60/60*10)/10,f="year"):d>=126144e3&&(e=Math.floor(d/365.25/24/60/60*10)/10,f="year"),e+" "+f+(e>1?"s":"")}function n(a){var b="";return b=a<1e3?"< 1 sec":a<6e4?Math.floor(a/1e3)+" secs":a<36e5?Math.floor(a/6e4)+" mins":a<864e5?Math.floor(a/36e5*10)/10+" hours":a<2628e6?Math.floor(a/864e5*10)/10+" days":a<31536e6?Math.floor(a/2628e6*10)/10+" months":Math.floor(a/31536e5)/10+" years"}function o(a){if(""===a||null==a||"object"==typeof a&&!a.getMonth)return"";var b=new Date(a);if(w2utils.isInt(a)&&(b=new Date(Number(a))),"Invalid Date"===String(b))return"";var c=w2utils.settings.shortmonths,d=new Date,e=new Date;e.setTime(e.getTime()-864e5);var f=c[b.getMonth()]+" "+b.getDate()+", "+b.getFullYear(),g=c[d.getMonth()]+" "+d.getDate()+", "+d.getFullYear(),h=c[e.getMonth()]+" "+e.getDate()+", "+e.getFullYear(),i=b.getHours()-(b.getHours()>12?12:0)+":"+(b.getMinutes()<10?"0":"")+b.getMinutes()+" "+(b.getHours()>=12?"pm":"am"),j=b.getHours()-(b.getHours()>12?12:0)+":"+(b.getMinutes()<10?"0":"")+b.getMinutes()+":"+(b.getSeconds()<10?"0":"")+b.getSeconds()+" "+(b.getHours()>=12?"pm":"am"),k=f;return f===g&&(k=i),f===h&&(k=w2utils.lang("Yesterday")),''+k+""}function p(a){if(!w2utils.isFloat(a)||""===a)return"";if(a=parseFloat(a),0===a)return 0;var b=["Bt","KB","MB","GB","TB","PB","EB","ZB"],c=parseInt(Math.floor(Math.log(a)/Math.log(1024)));return(Math.floor(a/Math.pow(1024,c)*10)/10).toFixed(0===c?0:1)+" "+(b[c]||"??")}function q(a,b,c){if(null==a||""===a||"object"==typeof a)return"";var d={minimumFractionDigits:b,maximumFractionDigits:b,useGrouping:c};return(null==b||b<0)&&(d.minimumFractionDigits=0,d.maximumFractionDigits=20),parseFloat(a).toLocaleString(w2utils.settings.locale,d)}function r(a,b){if(b||(b=this.settings.dateFormat),""===a||null==a||"object"==typeof a&&!a.getMonth)return"";var c=new Date(a);if(w2utils.isInt(a)&&(c=new Date(Number(a))),"Invalid Date"===String(c))return"";var d=c.getFullYear(),e=c.getMonth(),f=c.getDate();return b.toLowerCase().replace("month",w2utils.settings.fullmonths[e]).replace("mon",w2utils.settings.shortmonths[e]).replace(/yyyy/g,d).replace(/yyy/g,d).replace(/yy/g,d>2e3?100+parseInt(String(d).substr(2)):String(d).substr(2)).replace(/(^|[^a-z$])y/g,"$1"+d).replace(/mm/g,(e+1<10?"0":"")+(e+1)).replace(/dd/g,(f<10?"0":"")+f).replace(/th/g,1==f?"st":"th").replace(/th/g,2==f?"nd":"th").replace(/th/g,3==f?"rd":"th").replace(/(^|[^a-z$])m/g,"$1"+(e+1)).replace(/(^|[^a-z$])d/g,"$1"+f)}function s(a,b){w2utils.settings.shortmonths,w2utils.settings.fullmonths;if(b||(b=this.settings.timeFormat),""===a||null==a||"object"==typeof a&&!a.getMonth)return"";var c=new Date(a);if(w2utils.isInt(a)&&(c=new Date(Number(a))),w2utils.isTime(a)){var d=w2utils.isTime(a,!0);c=new Date,c.setHours(d.hours),c.setMinutes(d.minutes)}if("Invalid Date"===String(c))return"";var e="am",f=c.getHours(),g=c.getHours(),h=c.getMinutes(),i=c.getSeconds();return h<10&&(h="0"+h),i<10&&(i="0"+i),b.indexOf("am")===-1&&b.indexOf("pm")===-1||(f>=12&&(e="pm"),f>12&&(f-=12),0===f&&(f=12)),b.toLowerCase().replace("am",e).replace("pm",e).replace("hhh",f<10?"0"+f:f).replace("hh24",g<10?"0"+g:g).replace("h24",g).replace("hh",f).replace("mm",h).replace("mi",h).replace("ss",i).replace(/(^|[^a-z$])h/g,"$1"+f).replace(/(^|[^a-z$])m/g,"$1"+h).replace(/(^|[^a-z$])s/g,"$1"+i)}function t(a,b){var c;return""===a||null==a||"object"==typeof a&&!a.getMonth?"":("string"!=typeof b?c=[this.settings.dateFormat,this.settings.timeFormat]:(c=b.split("|"),c[0]=c[0].trim(),c[1]=c.length>1?c[1].trim():this.settings.timeFormat),"h12"===c[1]&&(c[1]="h:m pm"),"h24"===c[1]&&(c[1]="h24:m"),this.formatDate(a,c[0])+" "+this.formatTime(a,c[1]))}function u(b){if(null==b)return b;switch(typeof b){case"number":break;case"string":b=String(b).replace(/(<([^>]+)>)/gi,"");break;case"object":if(Array.isArray(b)){b=a.extend(!0,[],b);for(var c=0;c/g,">").replace(/").replace(/</g,"<").replace(/"/g,'"').replace(/&/g,"&");break;case"object":if(Array.isArray(b)){b=a.extend(!0,[],b);for(var c=0;c\|\/? {}\\])/g,"\\$1")}function y(a){function b(a){a=String(a).replace(/\r\n/g,"\n");for(var b="",c=0;c127&&d<2048?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b}var c,d,e,f,g,h,i,j="",k=0,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";for(a=b(a);k>2,g=(3&c)<<4|d>>4,h=(15&d)<<2|e>>6,i=63&e,isNaN(d)?h=i=64:isNaN(e)&&(i=64),j=j+l.charAt(f)+l.charAt(g)+l.charAt(h)+l.charAt(i);return j}function z(a){function b(a){for(var b,c,d="",e=0,f=0;e191&&f<224?(b=a.charCodeAt(e+1),d+=String.fromCharCode((31&f)<<6|63&b),e+=2):(b=a.charCodeAt(e+1),c=a.charCodeAt(e+2),d+=String.fromCharCode((15&f)<<12|(63&b)<<6|63&c),e+=3);return d}var c,d,e,f,g,h,i,j="",k=0,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(c),64!==h&&(j+=String.fromCharCode(d)),64!==i&&(j+=String.fromCharCode(e));return j=b(j)}function A(a){function b(a){return d(c(e(a)))}function c(a){return g(h(f(a),8*a.length))}function d(a){try{}catch(a){p=0}for(var b,c=p?"0123456789ABCDEF":"0123456789abcdef",d="",e=0;e>>4&15)+c.charAt(15&b);return d}function e(a){for(var b,c,d="",e=-1;++e>>6&31,128|63&b):b<=65535?d+=String.fromCharCode(224|b>>>12&15,128|b>>>6&63,128|63&b):b<=2097151&&(d+=String.fromCharCode(240|b>>>18&7,128|b>>>12&63,128|b>>>6&63,128|63&b));return d}function f(a){for(var b=Array(a.length>>2),c=0;c>5]|=(255&a.charCodeAt(c/8))<>5]>>>c%32&255);return b}function h(a,b){a[b>>5]|=128<>>9<<4)+14]=b;for(var c=1732584193,d=-271733879,e=-1732584194,f=271733878,g=0;g>16)+(b>>16)+(c>>16);return d<<16|65535&c}function o(a,b){return a<>>32-b}var p=0;return b(a)}function B(b,c,d,e){var f=a(b).width(),g=a(b).height(),h=.5;if(!b||!c)return void console.log("ERROR: Cannot do transition when one of the divs is null");switch(b.parentNode.style.cssText+="perspective: 900px; overflow: hidden;",b.style.cssText+="; position: absolute; z-index: 1019; backface-visibility: hidden",c.style.cssText+="; position: absolute; z-index: 1020; backface-visibility: hidden",d){case"slide-left":b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; transform: translate3d("+f+"px, 0, 0)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: translate3d(0, 0, 0)",b.style.cssText+="transition: "+h+"s; transform: translate3d(-"+f+"px, 0, 0)"},1);break;case"slide-right":b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; transform: translate3d(-"+f+"px, 0, 0)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: translate3d(0px, 0, 0)",b.style.cssText+="transition: "+h+"s; transform: translate3d("+f+"px, 0, 0)"},1);break;case"slide-down":b.style.cssText+="overflow: hidden; z-index: 1; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; z-index: 0; transform: translate3d(0, 0, 0)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: translate3d(0, 0, 0)",b.style.cssText+="transition: "+h+"s; transform: translate3d(0, "+g+"px, 0)"},1);break;case"slide-up":b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; transform: translate3d(0, "+g+"px, 0)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: translate3d(0, 0, 0)",b.style.cssText+="transition: "+h+"s; transform: translate3d(0, 0, 0)"},1);break;case"flip-left":b.style.cssText+="overflow: hidden; transform: rotateY(0deg)",c.style.cssText+="overflow: hidden; transform: rotateY(-180deg)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: rotateY(0deg)",b.style.cssText+="transition: "+h+"s; transform: rotateY(180deg)"},1);break;case"flip-right":b.style.cssText+="overflow: hidden; transform: rotateY(0deg)",c.style.cssText+="overflow: hidden; transform: rotateY(180deg)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: rotateY(0deg)",b.style.cssText+="transition: "+h+"s; transform: rotateY(-180deg)"},1);break;case"flip-down":b.style.cssText+="overflow: hidden; transform: rotateX(0deg)",c.style.cssText+="overflow: hidden; transform: rotateX(180deg)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: rotateX(0deg)",b.style.cssText+="transition: "+h+"s; transform: rotateX(-180deg)"},1);break;case"flip-up":b.style.cssText+="overflow: hidden; transform: rotateX(0deg)",c.style.cssText+="overflow: hidden; transform: rotateX(-180deg)",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: rotateX(0deg)",b.style.cssText+="transition: "+h+"s; transform: rotateX(180deg)"},1);break;case"pop-in":b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); transform: scale(.8); opacity: 0;",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; transform: scale(1); opacity: 1;",b.style.cssText+="transition: "+h+"s;"},1);break;case"pop-out":b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); transform: scale(1); opacity: 1;",c.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); opacity: 0;",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; opacity: 1;",b.style.cssText+="transition: "+h+"s; transform: scale(1.7); opacity: 0;"},1);break;default:b.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",c.style.cssText+="overflow: hidden; translate3d(0, 0, 0); opacity: 0;",a(c).show(),window.setTimeout(function(){c.style.cssText+="transition: "+h+"s; opacity: 1;",b.style.cssText+="transition: "+h+"s"},1)}setTimeout(function(){"slide-down"===d&&(a(b).css("z-index","1019"),a(c).css("z-index","1020")),c&&a(c).css({opacity:"1"}).css(w2utils.cssPrefix({transition:"",transform:""})),b&&a(b).css({opacity:"1"}).css(w2utils.cssPrefix({transition:"",transform:""})),"function"==typeof e&&e()},1e3*h)}function C(b,c,d){var e={};"object"==typeof c?e=c:(e.msg=c,e.spinner=d),e.msg||0===e.msg||(e.msg=""),w2utils.unlock(b),a(b).prepend('
');var f=a(b).find(".w2ui-lock"),g=a(b).find(".w2ui-lock-msg");e.msg||g.css({"background-color":"transparent",border:"0px"}),e.spinner===!0&&(e.msg='
"+e.msg),null!=e.opacity&&f.css("opacity",e.opacity),"function"==typeof f.fadeIn?(f.fadeIn(200),g.html(e.msg).fadeIn(200)):(f.show(),g.html(e.msg).show(0))}function D(b,d){c(d)?(a(b).find(".w2ui-lock").fadeOut(d),setTimeout(function(){a(b).find(".w2ui-lock").remove(),a(b).find(".w2ui-lock-msg").remove()},d)):(a(b).find(".w2ui-lock").remove(),a(b).find(".w2ui-lock-msg").remove())}function E(b,c){function d(c,d){if(null==f&&(f=d.trigger({phase:"before",type:"open",target:"self"}),f.isCancelled===!0))return l.css("z-index",l.data("old-z-index")),void a(b.box).find("#w2ui-message"+n).remove();var e=c.data("prev_focus");c.remove(),e&&e.length>0?e.focus():g&&g.focus&&g.focus(),l.css("z-index",l.data("old-z-index")),d.trigger(a.extend(f,{phase:"after"}))}var e,f,g=this;a().w2tag(),c||(c={width:200,height:100}),null==c.on&&a.extend(c,w2utils.event),null==c.width&&(c.width=200),null==c.height&&(c.height=100);var h=parseInt(a(b.box).width()),i=parseInt(a(b.box).height()),j=parseInt(a(b.box).find(b.title).css("height")||0);c.width>h&&(c.width=h-10),c.height>i-j&&(c.height=i-10-j),c.originalWidth=c.width,c.originalHeight=c.height,parseInt(c.width)<0&&(c.width=h+c.width),parseInt(c.width)<10&&(c.width=10),parseInt(c.height)<0&&(c.height=i+c.height-j),parseInt(c.height)<10&&(c.height=10),null==c.hideOnClick&&(c.hideOnClick=!1);var k=a(b.box).data("options")||{};(null==c.width||c.width>k.width-10)&&(c.width=k.width-10),(null==c.height||c.height>k.height-j-5)&&(c.height=k.height-j-5),c.originalHeight<0&&(c.height=i+c.originalHeight-j),c.originalWidth<0&&(c.width=h+2*c.originalWidth);var l=a(b.box).find(b.title),m=a(b.box).find(".w2ui-message.w2ui-closing");a(b.box).find(".w2ui-message.w2ui-closing").length>0&&(clearTimeout(e),d(m,m.data("options")||{}));var n=a(b.box).find(".w2ui-message").length;if(""===a.trim(c.html)&&""===a.trim(c.body)&&""===a.trim(c.buttons)){if(0===n)return;var o=a(b.box).find("#w2ui-message"+(n-1)),c=o.data("options")||{};if(f=c.trigger({phase:"before",type:"close",target:"self"}),f.isCancelled===!0)return;o.css(w2utils.cssPrefix({transition:"0.15s",transform:"translateY(-"+c.height+"px)"})).addClass("w2ui-closing"),1===n?this.unlock&&(b.param?this.unlock(b.param,150):this.unlock(150)):a(b.box).find("#w2ui-message"+(n-2)).css("z-index",1500),e=setTimeout(function(){d(o,c)},150)}else{""===a.trim(c.body)&&""===a.trim(c.buttons)||(c.html='
'+(c.body||"")+'
'+(c.buttons||"")+"
"),a(b.box).find(".w2ui-message").css("z-index",1390),l.data("old-z-index",l.css("z-index")),l.css("z-index",1501),a(b.box).find(b.body).before('"),a(b.box).find("#w2ui-message"+n).data("options",c).data("prev_focus",a(":focus"));var p=a(b.box).find("#w2ui-message"+n).css("display");if(a(b.box).find("#w2ui-message"+n).css(w2utils.cssPrefix({transform:"none"===p?"translateY(-"+c.height+"px)":"translateY(0px)"})),"none"===p){if(a(b.box).find("#w2ui-message"+n).show().html(c.html),c.box=a(b.box).find("#w2ui-message"+n),f=c.trigger({phase:"before",type:"open",target:"self"}),f.isCancelled===!0)return l.css("z-index",l.data("old-z-index")),void a(b.box).find("#w2ui-message"+n).remove();setTimeout(function(){a(b.box).find("#w2ui-message"+n).css(w2utils.cssPrefix({transform:"none"===p?"translateY(0px)":"translateY(-"+c.height+"px)"}))},1),0===n&&this.lock&&(b.param?this.lock(b.param):this.lock()),setTimeout(function(){a(b.box).find("#w2ui-message"+n).css(w2utils.cssPrefix({transition:"0s"})),c.trigger(a.extend(f,{phase:"after"}))},350)}}}function F(b,c){var d=a(b),e={left:parseInt(d.css("border-left-width"))||0,right:parseInt(d.css("border-right-width"))||0,top:parseInt(d.css("border-top-width"))||0,bottom:parseInt(d.css("border-bottom-width"))||0},f={left:parseInt(d.css("margin-left"))||0,right:parseInt(d.css("margin-right"))||0,top:parseInt(d.css("margin-top"))||0,bottom:parseInt(d.css("margin-bottom"))||0},g={left:parseInt(d.css("padding-left"))||0,right:parseInt(d.css("padding-right"))||0,top:parseInt(d.css("padding-top"))||0,bottom:parseInt(d.css("padding-bottom"))||0};switch(c){case"top":return e.top+f.top+g.top;case"bottom":return e.bottom+f.bottom+g.bottom;case"left":return e.left+f.left+g.left;case"right":return e.right+f.right+g.right;case"width":return e.left+e.right+f.left+f.right+g.left+g.right+parseInt(d.width());case"height":return e.top+e.bottom+f.top+f.bottom+g.top+g.bottom+parseInt(d.height());case"+width":return e.left+e.right+f.left+f.right+g.left+g.right;case"+height":return e.top+e.bottom+f.top+f.bottom+g.top+g.bottom}return 0}function G(b,c){var d,e='
'+v(b)+"
";return a("body").append(e),d=a("#_tmp_width").width(),a("#_tmp_width").remove(),d}function H(a){var b=this.settings.phrases[a];return null==b?a:b}function I(b,c){return b||(b="en-us"),"string"!=typeof b?void(w2utils.settings=a.extend(!0,w2utils.settings,b)):(5===b.length&&(b="locale/"+b+".json"),w2utils.settings.phrases={},void a.ajax({url:b,type:"GET",dataType:"JSON",success:function(b,d,e){w2utils.settings=a.extend(!0,w2utils.settings,b),"function"==typeof c&&c()},error:function(a,c,d){console.log("ERROR: Cannot load locale "+b)}}))}function J(){if(V.scrollBarSize)return V.scrollBarSize;var b='
1
';return a("body").append(b),V.scrollBarSize=100-a("#_scrollbar_width > div").width(),a("#_scrollbar_width").remove(),String(navigator.userAgent).indexOf("MSIE")>=0&&(V.scrollBarSize=V.scrollBarSize/2),V.scrollBarSize}function K(a,b){return a&&null!=a.name?null!=w2ui[a.name]?(console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+a.name+")."),!1):!!w2utils.isAlphaNumeric(a.name)||(console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). '),!1):(console.log('ERROR: The parameter "name" is required but not supplied in $().'+b+"()."),!1)}function L(b,c,d,e){a.isArray(c)||(c=[c]);for(var f=0;f0){var f=b.getRangeAt(0),g=f.cloneRange();g.selectNodeContents(a),g.setEnd(f.endContainer,f.endOffset),c=g.toString().length}}else if((b=d.selection)&&"Control"!==b.type){var h=b.createRange(),i=d.body.createTextRange();i.moveToElementText(a),i.setEndPoint("EndToEnd",h),c=i.text.length}return c}function P(b,c,d){var e,f=document.createRange(),g=window.getSelection();if(null!=b){for(var h=0;h").replace(/&/g,"&").replace(/"/g,'"').replace(/ /g," ")),c<=i.length){e=b.childNodes[h],e.childNodes&&e.childNodes.length>0&&(e=e.childNodes[0]),e.childNodes&&e.childNodes.length>0&&(e=e.childNodes[0]);break}c-=i.length}null!=e&&(c>e.length&&(c=e.length),f.setStart(e,c),d?f.setEnd(e,d):f.collapse(!0),g.removeAllRanges(),g.addRange(f))}}function Q(){var a="w2ui_test";try{return localStorage.setItem(a,a),localStorage.removeItem(a),!0}catch(a){return!1}}function R(a){if("string"!=typeof a)return null;a=a.trim().toUpperCase(),"#"===a[0]&&(a=a.substr(1));var b={};if(3===a.length)b={r:parseInt(a[0]+a[0],16),g:parseInt(a[1]+a[1],16),b:parseInt(a[2]+a[2],16),a:1};else if(6===a.length)b={r:parseInt(a.substr(0,2),16),g:parseInt(a.substr(2,2),16),b:parseInt(a.substr(4,2),16),a:1};else if(a.length>4&&"RGB("===a.substr(0,4)){var c=a.replace("RGB","").replace(/\(/g,"").replace(/\)/g,"").split(",");b={r:parseInt(c[0],10),g:parseInt(c[1],10),b:parseInt(c[2],10),a:1}}else{if(!(a.length>5&&"RGBA("===a.substr(0,5)))return null;var c=a.replace("RGBA","").replace(/\(/g,"").replace(/\)/g,"").split(",");b={r:parseInt(c[0],10),g:parseInt(c[1],10),b:parseInt(c[2],10),a:parseFloat(c[3])}}return b}function S(a,b,c,d){var e,f,g,h,i,j,k,l;switch(1===arguments.length&&(b=a.s,c=a.v,d=a.a,a=a.h),a/=360,b/=100,c/=100,h=Math.floor(6*a),i=6*a-h,j=c*(1-b),k=c*(1-i*b),l=c*(1-(1-i)*b),h%6){case 0:e=c,f=l,g=j;break;case 1:e=k,f=c,g=j;break;case 2:e=j,f=c,g=l;break;case 3:e=j,f=k,g=c;break;case 4:e=l,f=j,g=c;break;case 5:e=c,f=j,g=k}return{r:Math.round(255*e),g:Math.round(255*f),b:Math.round(255*g),a:null!=d?d:1}}function T(a,b,c,d){1===arguments.length&&(b=a.g,c=a.b,d=a.a,a=a.r);var e,f=Math.max(a,b,c),g=Math.min(a,b,c),h=f-g,i=0===f?0:h/f,j=f/255;switch(f){case g:e=0;break;case a:e=b-c+h*(b65;)++d;return+a.slice(b-1,d)}return e=i&&i.indexOf(a.charAt(b)),e>-1?e+76:(e=a.charCodeAt(b)||0,e<45||e>127?e:e<46?65:e<48?e-1:e<58?e+18:e<65?e-11:e<91?e+11:e<97?e-37:e<123?e+5:e-63)}var d,e,f=1,g=0,h=0,i=String.alphabet;if((a+="")!=(b+=""))for(;f;)if(e=c(a,g++),f=c(b,h++),e<76&&f<76&&e>66&&f>66&&(e=c(a,g,g),f=c(b,h,g=d),h=d),e!=f)return e20&&(b=20),parseInt(b)<0&&(b=0),null==a||""===a?"":w2utils.formatNumber(parseFloat(a),b,!0)},float:function(a,b){return w2utils.formatters.number(a,b)},int:function(a,b){return w2utils.formatters.number(a,0)},money:function(a,b){if(null==a||""===a)return"";var c=w2utils.formatNumber(Number(a),w2utils.settings.currencyPrecision||2);return(w2utils.settings.currencyPrefix||"")+c+(w2utils.settings.currencySuffix||"")},currency:function(a,b){return w2utils.formatters.money(a,b)},percent:function(a,b){return null==a||""===a?"":w2utils.formatNumber(a,b||1)+"%"},size:function(a,b){return null==a||""===a?"":w2utils.formatSize(parseInt(a))},date:function(a,b){if(""===b&&(b=w2utils.settings.dateFormat),null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,b,!0);return c===!1&&(c=w2utils.isDate(a,b,!0)),''+w2utils.formatDate(c,b)+""},datetime:function(a,b){if(""===b&&(b=w2utils.settings.datetimeFormat),null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,b,!0);return c===!1&&(c=w2utils.isDate(a,b,!0)),''+w2utils.formatDateTime(c,b)+""},time:function(a,b){if(""===b&&(b=w2utils.settings.timeFormat),"h12"===b&&(b="hh:mi pm"),"h24"===b&&(b="h24:mi"),null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,b,!0);return c===!1&&(c=w2utils.isDate(a,b,!0)),''+w2utils.formatTime(a,b)+""},timestamp:function(a,b){if(""===b&&(b=w2utils.settings.datetimeFormat),null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,b,!0);return c===!1&&(c=w2utils.isDate(a,b,!0)),c.toString?c.toString():""},gmt:function(a,b){if(""===b&&(b=w2utils.settings.datetimeFormat),null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,b,!0);return c===!1&&(c=w2utils.isDate(a,b,!0)),c.toUTCString?c.toUTCString():""},age:function(a,b){if(null==a||0===a||""===a)return"";var c=w2utils.isDateTime(a,null,!0);return c===!1&&(c=w2utils.isDate(a,null,!0)),''+w2utils.age(a)+(b?" "+b:"")+""},interval:function(a,b){return null==a||0===a||""===a?"":w2utils.interval(a)+(b?" "+b:"")},toggle:function(a,b){return a?"Yes":""},password:function(a,b){for(var c="",d=0;d=0;f--){var g=this.handlers[f];if(!(g.edata.type!==a.type&&"*"!==g.edata.type||g.edata.target!==a.target&&null!=g.edata.target||g.edata.execute!==a.phase&&"*"!==g.edata.execute&&"*"!==g.edata.phase)&&(a=b.extend({},g.edata,a),c=[],e=new RegExp(/\((.*?)\)/).exec(g.handler),e&&(c=e[1].split(/\s*,\s*/)),2===c.length?g.handler.call(this,a.target,a):g.handler.call(this,a),a.isStopped===!0||a.stop===!0))return a}var h="on"+a.type.substr(0,1).toUpperCase()+a.type.substr(1);if("before"===a.phase&&"function"==typeof this[h]&&(d=this[h],c=[],e=new RegExp(/\((.*?)\)/).exec(d),e&&(c=e[1].split(/\s*,\s*/)),2===c.length?d.call(this,a.target,a):d.call(this,a),a.isStopped===!0||a.stop===!0))return a;if(null!=a.object&&"before"===a.phase&&"function"==typeof a.object[h]&&(d=a.object[h],c=[],e=new RegExp(/\((.*?)\)/).exec(d),e&&(c=e[1].split(/\s*,\s*/)),2===c.length?d.call(this,a.target,a):d.call(this,a),a.isStopped===!0||a.stop===!0))return a;if("after"===a.phase){"function"==typeof a.onComplete&&a.onComplete.call(this,a);for(var i=0;i0&&("string"==typeof b&&w2ui[b]&&w2ui[b].render(a(this)[0]),"object"==typeof b&&b.render(a(this)[0]))},a.fn.w2destroy=function(a){!a&&this.length>0&&(a=this.attr("name")),"string"==typeof a&&w2ui[a]&&w2ui[a].destroy(),"object"==typeof a&&a.destroy()},a.fn.w2marker=function(){function b(a,b){for(;b.innerHTML.indexOf('')!==-1;)b.innerHTML=b.innerHTML.replace(/\((.|\n|\r)*)\<\/span\>/gi,"$1")}var c=Array.prototype.slice.call(arguments,0);return Array.isArray(c[0])&&(c=c[0]),0!==c.length&&c[0]?a(this).each(function(a,d){function e(a){return''+a+""}b(a,d);for(var f=0;f/g,"<");var h=new RegExp(g+"(?!([^<]+)?>)","gi");d.innerHTML=d.innerHTML.replace(h,e)}}):a(this).each(b)},a.fn.w2tag=function(b,c){return 1===arguments.length&&"object"==typeof b&&(c=b,null!=c.html&&(b=c.html)),c=a.extend({id:null,html:b,position:"right|top",align:"none",left:0,top:0,style:"",css:{},className:"",inputClass:"",onShow:null,onHide:null,hideOnKeyPress:!0,hideOnBlur:!1,hideOnClick:!1,hideOnChange:!0},c),null!=c.name&&null==c.id&&(c.id=c.name),""!==c.class&&""===c.inputClass&&(c.inputClass=c.class),0===a(this).length?void a(".w2ui-tag").each(function(b,c){var d=a(c).data("w2tag");d&&d.hide()}):a(this).each(function(d,e){function f(){if(j.box.css("display","block"),j&&j.box&&a(j.attachedTo).offset()){var b=j.getPos();j.box.css({opacity:"1",left:b.left+"px",top:b.top+"px"}).data("w2tag",j).find(".w2ui-tag-body").addClass(b.posClass),j.tmp.pos=b.left+"x"+b.top,a(j.attachedTo).off(".w2tag").css(j.options.css).addClass(j.options.inputClass),j.options.hideOnKeyPress&&a(j.attachedTo).on("keypress.w2tag",j.hide),c.hideOnChange&&("INPUT"===e.nodeName?a(e).on("change.w2tag",j.hide):a(e).find("input").on("change.w2tag",j.hide)),j.options.hideOnBlur&&a(j.attachedTo).on("blur.w2tag",j.hide),j.options.hideOnClick&&a(document).on("click.w2tag",j.hide),"function"==typeof j.options.onShow&&j.options.onShow(),h()}}function g(){j.box.length<=0||(j.tmp.timer&&clearTimeout(j.tmp.timer),j.box.remove(),j.options.hideOnClick&&a(document).off(".w2tag"),a(j.attachedTo).off(".w2tag").removeClass(j.options.inputClass).removeData("w2tag"),a(j.attachedTo).length>0&&(a(j.attachedTo)[0].style.cssText=j.tmp.originalCSS),"function"==typeof j.options.onHide&&j.options.onHide())}function h(b){var c=a(j.attachedTo).offset();if(0===a(j.attachedTo).length||0===c.left&&0===c.top||0===j.box.find(".w2ui-tag-body").length)return void j.hide();var d=i();j.tmp.pos!==d.left+"x"+d.top&&(j.box.css(w2utils.cssPrefix({transition:b?"0s":".2s"})).css({left:d.left+"px",top:d.top+"px"}),j.tmp.pos=d.left+"x"+d.top),j.tmp.timer&&clearTimeout(j.tmp.timer),j.tmp.timer=setTimeout(h,100)}function i(){var b=a(j.attachedTo).offset(),c="w2ui-tag-right",d=parseInt(b.left+j.attachedTo.offsetWidth+(j.options.left?j.options.left:0)),e=parseInt(b.top+(j.options.top?j.options.top:0)),f=j.box.find(".w2ui-tag-body"),g=f[0].offsetWidth,h=f[0].offsetHeight;if("string"==typeof j.options.position&&j.options.position.indexOf("|")!==-1&&(j.options.position=j.options.position.split("|")),"top"===j.options.position)c="w2ui-tag-top",d=parseInt(b.left+(j.options.left?j.options.left:0))-14,e=parseInt(b.top+(j.options.top?j.options.top:0))-h-10;else if("bottom"===j.options.position)c="w2ui-tag-bottom",d=parseInt(b.left+(j.options.left?j.options.left:0))-14,e=parseInt(b.top+j.attachedTo.offsetHeight+(j.options.top?j.options.top:0))+10;else if("left"===j.options.position)c="w2ui-tag-left",d=parseInt(b.left+(j.options.left?j.options.left:0))-g-20,e=parseInt(b.top+(j.options.top?j.options.top:0));else if(Array.isArray(j.options.position)){for(var i=window.innerWidth,k=window.innerHeight,l=0;l=0)break}else if("top"===m){if(c="w2ui-tag-top",d=parseInt(b.left+(j.options.left?j.options.left:0))-14,e=parseInt(b.top+(j.options.top?j.options.top:0))-h-10,d+g<=i&&e>=0)break}else if("bottom"===m&&(c="w2ui-tag-bottom",d=parseInt(b.left+(j.options.left?j.options.left:0))-14,e=parseInt(b.top+j.attachedTo.offsetHeight+(j.options.top?j.options.top:0))+10,d+g<=i&&e+h<=k))break}f.data("posClass")!==c&&f.removeClass("w2ui-tag-right w2ui-tag-left w2ui-tag-top w2ui-tag-bottom").addClass(c).data("posClass",c)}return{left:d,top:e,posClass:c}}var j,k=c.id?c.id:e.id;""==k&&(k=a(e).find("input").attr("id")),k||(k="noid");var l=w2utils.escapeId(k);null!=a(this).data("w2tag")?(j=a(this).data("w2tag"),a.extend(j.options,c)):j={id:k,attachedTo:e,box:a("#w2ui-tag-"+l),options:a.extend({},c),init:f,hide:g,getPos:i,isMoved:h,tmp:{}},""===b||null==b?j.hide():0!==j.box.length?j.box.find(".w2ui-tag-body").css(j.options.css).attr("style",j.options.style).addClass(j.options.className).html(j.options.html):(j.tmp.originalCSS="",a(j.attachedTo).length>0&&(j.tmp.originalCSS=a(j.attachedTo)[0].style.cssText),a("body").append('"),j.box=a("#w2ui-tag-"+l),a(j.attachedTo).data("w2tag",j),setTimeout(f,1))})},a.fn.w2overlay=function(b,c){function d(){var b=a("#w2ui-overlay"+h);if(b.data("element")===g[0]&&0!==b.length){var c=a(g).offset()||{},f=c.left+"x"+c.top;b.data("position")!==f?e():setTimeout(d,250)}}function e(b){if(!b||0===b.button){var d=a("#w2ui-overlay"+h);if(!b||a(a(b.target).closest(".w2ui-overlay").data("element")).closest(".w2ui-overlay")[0]!==d[0]){if(d.data("keepOpen")===!0)return void d.removeData("keepOpen");var e;"function"==typeof c.onHide&&(e=c.onHide()),e!==!1&&(d.remove(),a(document).off(".w2overlay"+h),clearInterval(d.data("timer")))}}}function f(){var b=a("#w2ui-overlay"+h),d=b.find(" > div"),e=a("#w2ui-overlay"+h+" div.menu");if(e.css("overflow-y","hidden"),b.length>0){d.height("auto").width("auto");var i=!1,j=d.height(),k=d.width();c.width&&c.widtha.height()&&d.find("div.menu").css("overflow-y","hidden")},1),setTimeout(function(){var a=d.find("div.menu");"auto"!==a.css("overflow-y")&&a.css("overflow-y","auto")},10)),c.tmp.contentWidth&&"both"!==c.align&&(k=parseInt(c.tmp.contentWidth),d.width(k),setTimeout(function(){k>d.find("div.menu > table").width()&&d.find("div.menu > table").css("overflow-x","hidden")},1),setTimeout(function(){d.find("div.menu > table").css("overflow-x","auto")},10));var l=c.left,m=c.width,n=c.tipLeft;switch(c.align){case"both":l=17,0===c.width&&(c.width=w2utils.getSize(a(g),"width")),c.maxWidth&&c.width>c.maxWidth&&(c.width=c.maxWidth);break;case"left":l=17;break;case"right":l=w2utils.getSize(a(g),"width")-k+10,n=k-40}m=30!==k||m?c.width?c.width:"auto":30;var o=(k-17)/2;"auto"!==m&&(o=(m-17)/2),o<25&&(l=25-o,n=Math.floor(o));var p,q,r;if(c.contextMenu)p=c.pageX+8,q=c.pageY-0,r=c.pageY;else{var s=g.offset()||{};p=(s.left>25?s.left:25)+l,q=s.top+w2utils.getSize(g,"height")+c.top+7,r=s.top}b.css({left:p+"px",top:q+"px","min-width":m,"min-height":c.height?c.height:"auto"});var s=d.offset()||{},t=window.innerHeight+a(document).scrollTop()-s.top-7,u=window.innerWidth+a(document).scrollLeft()-s.left-7;if(c.contextMenu&&(t=window.innerHeight+a(document).scrollTop()-c.pageY-15,u=window.innerWidth+a(document).scrollLeft()-c.pageX),t>-50&&t<210||c.openAbove===!0){var v;c.contextMenu?(t=c.pageY-7,v=5):(t=s.top-a(document).scrollTop()-7,v=24),c.maxHeight&&t>c.maxHeight&&(t=c.maxHeight),j>t&&(i=!0,d.height(t).width(k).css({"overflow-y":"auto"}),j=t),b.addClass("bottom-arrow"),b.css("top",r-j-v+c.top+"px"),b.find(">style").html("#w2ui-overlay"+h+":before { margin-left: "+parseInt(n)+"px; }#w2ui-overlay"+h+":after { margin-left: "+parseInt(n)+"px; }")}else c.maxHeight&&t>c.maxHeight&&(t=c.maxHeight),j>t&&(i=!0,d.height(t).width(k).css({"overflow-y":"auto"})),b.addClass("top-arrow"),b.find(">style").html("#w2ui-overlay"+h+":before { margin-left: "+parseInt(n)+"px; }#w2ui-overlay"+h+":after { margin-left: "+parseInt(n)+"px; }");k=d.width(),u=window.innerWidth+a(document).scrollLeft()-s.left-7,c.maxWidth&&u>c.maxWidth&&(u=c.maxWidth),k>u&&"both"!==c.align&&(c.align="right",setTimeout(function(){f()},1)),(c.contextMenu||c.noTip)&&b.find(">style").html("#w2ui-overlay"+h+":before { display: none; }#w2ui-overlay"+h+":after { display: none; }"),i&&"both"!==c.align&&d.width(k+w2utils.scrollBarSize()+2)}e.css("overflow-y","auto")}var g=this,h="",i={name:null,html:"",align:"none",left:0,top:0,tipLeft:30,noTip:!1,selectable:!1,width:0,height:0,maxWidth:null,maxHeight:null,contextMenu:!1,pageX:null,pageY:null,originalEvent:null,style:"",class:"",overlayStyle:"",onShow:null,onHide:null,openAbove:!1,tmp:{}};1===arguments.length&&(c="object"==typeof b?b:{html:b}),2===arguments.length&&(c.html=b),a.isPlainObject(c)||(c={}),c=a.extend({},i,c),c.name&&(h="-"+c.name);var j;if(0===this.length||""===c.html||null==c.html)return a("#w2ui-overlay"+h).length>0?(j=a("#w2ui-overlay"+h)[0].hide,"function"==typeof j&&j()):a("#w2ui-overlay"+h).remove(),a(this);a("#w2ui-overlay"+h).length>0&&(j=a("#w2ui-overlay"+h)[0].hide,a(document).off(".w2overlay"+h),"function"==typeof j&&j()),g.length>0&&(null==g[0].tagName||"BODY"===g[0].tagName.toUpperCase())&&(c.contextMenu=!0),c.contextMenu&&c.originalEvent&&(c.pageX=c.originalEvent.pageX,c.pageY=c.originalEvent.pageY),!c.contextMenu||null!=c.pageX&&null!=c.pageY||console.log("ERROR: to display menu at mouse location, pass options.pageX and options.pageY."),a("body").append('');var k=a("#w2ui-overlay"+h),l=k.find(" > div");l.html(c.html);var m=l.css("background-color");null!=m&&"rgba(0, 0, 0, 0)"!==m&&"transparent"!==m&&k.css({"background-color":m,"border-color":m});var n=a(g).offset()||{};return k.data("element",g.length>0?g[0]:null).data("options",c).data("position",n.left+"x"+n.top).fadeIn("fast").on("click",function(b){a("#w2ui-overlay"+h).data("keepOpen",!0),"LABEL"===b.target.tagName.toUpperCase()&&b.stopPropagation()}).on("mousedown",function(a){var b=a.target.tagName.toUpperCase();["INPUT","TEXTAREA","SELECT"].indexOf(b)!==-1||c.selectable||a.preventDefault()}),k[0].hide=e,k[0].resize=f,setTimeout(function(){a(document).off(".w2overlay"+h).on("click.w2overlay"+h,e),"function"==typeof c.onShow&&c.onShow(),f()},10),d(),a(this)},a.fn.w2menu=function(b,c){function d(){setTimeout(function(){a("#w2ui-overlay"+i+" tr.w2ui-selected").removeClass("w2ui-selected");var b=a("#w2ui-overlay"+i+" tr[index="+c.index+"]"),d=a("#w2ui-overlay"+i+" div.menu").scrollTop();if(b.addClass("w2ui-selected"),c.tmp&&(c.tmp.contentHeight=a("#w2ui-overlay"+i+" table").height()+(c.search?50:10)),c.tmp&&(c.tmp.contentWidth=a("#w2ui-overlay"+i+" table").width()+1),a("#w2ui-overlay"+i).length>0&&a("#w2ui-overlay"+i)[0].resize(),b.length>0){var e=b[0].offsetTop-5,f=a("#w2ui-overlay"+i+" div.menu"),g=f.height();a("#w2ui-overlay"+i+" div.menu").scrollTop(d),(ed+g)&&a("#w2ui-overlay"+i+" div.menu").animate({scrollTop:e-(g-2*b.height())/2},200,"linear")}},1)}function e(b){var e=this.value,f=b.keyCode,g=!1;switch(f){case 13:a("#w2ui-overlay"+i).remove(),a.fn.w2menuClick(b,c.index);break;case 9:case 27:a("#w2ui-overlay"+i).remove(),a.fn.w2menuClick(b,-1);break;case 38:for(c.index=w2utils.isInt(c.index)?parseInt(c.index):0,c.index--;c.index>0&&c.items[c.index].hidden;)c.index--;if(0===c.index&&c.items[c.index].hidden)for(;c.items[c.index]&&c.items[c.index].hidden;)c.index++;c.index<0&&(c.index=0),g=!0;break;case 40:for(c.index=w2utils.isInt(c.index)?parseInt(c.index):0,c.index++;c.index=c.items.length&&(c.index=c.items.length-1),g=!0}if(!g){for(var j=0,k=0;k
'+w2utils.lang("Loading...")+"
";for(var a=0,b='',d=null,e=null,f=0;f
'),e&&(h='
'),"break"===g.type||null==i||""===i||/^-+$/.test(i))b+='';else{var j=a%2===0?"w2ui-item-even":"w2ui-item-odd";c.altRows!==!0&&(j="");var k=1;""===h&&k++,null==g.count&&null==g.hotkey&&k++,null==g.tooltip&&null!=g.hint&&(g.tooltip=g.hint),b+='"+h+' ",a++}}c.items[f]=g}return 0===a&&(b+='"),b+="
'+c.msgNoItems+"
"}c&&"function"==typeof c.items&&(c.items=c.items());var g={type:"normal",index:null,items:[],render:null,msgNoItems:"No items",onSelect:null,tmp:{}},h=this,i="";if("refresh"===b)if(a("#w2ui-overlay"+i).length>0){c=a.extend(a.fn.w2menuOptions,c);var j=a("#w2ui-overlay"+i+" div.menu").scrollTop();a("#w2ui-overlay"+i+" div.menu").html(f()),a("#w2ui-overlay"+i+" div.menu").scrollTop(j),d()}else a(this).w2menu(c);else{if("refresh-index"!==b){1===arguments.length?c=b:c.items=b,"object"!=typeof c&&(c={}),c=a.extend({},g,c),a.fn.w2menuOptions=c,c.name&&(i="-"+c.name),"function"==typeof c.select&&"function"!=typeof c.onSelect&&(c.onSelect=c.select),"function"==typeof c.onRender&&"function"!=typeof c.render&&(c.render=c.onRender),a.fn.w2menuClick=function(b,d){var e=!1;["radio","check"].indexOf(c.type)!==-1&&(b.shiftKey||b.metaKey||b.ctrlKey)&&(e=!0),"function"==typeof c.onSelect&&c.onSelect({index:d,item:c.items[d],keepOpen:e,originalEvent:b});var f=a("#w2ui-overlay"+i);f.removeData("keepOpen"),f.length>0&&"function"==typeof f[0].hide&&!e&&f[0].hide()},a.fn.w2menuDown=function(b,d){var e=a(b.target).parents("tr"),f=e.find(".w2ui-icon");if("check"===c.type||"radio"===c.type){var g=c.items[d];g.checked=!g.checked,g.checked?("radio"===c.type&&f.parents("table").find(".w2ui-icon").removeClass("w2ui-icon-check").addClass("w2ui-icon-empty"),"check"===c.type&&null!=g.group&&c.items.forEach(function(a,b){a.group===g.group&&a.checked&&(f.parents("table").find("tr[index="+b+"] .w2ui-icon").removeClass("w2ui-icon-check").addClass("w2ui-icon-empty"),a.checked=!1)}),f.removeClass("w2ui-icon-empty").addClass("w2ui-icon-check")):"check"===c.type&&null==g.group&&f.removeClass("w2ui-icon-check").addClass("w2ui-icon-empty")}e.parent().find("tr").removeClass("w2ui-selected"),e.addClass("w2ui-selected")};var k="";if(c.search){k+='
',c.style+=";background-color: #ECECEC",c.index=0;for(var l=0;l'+f()+"
";var m=a(this).w2overlay(k,c);return setTimeout(function(){if(a("#w2ui-overlay"+i+" #menu-search").on("keyup",e).on("keydown",function(a){9===a.keyCode&&(a.stopPropagation(),a.preventDefault())}),c.search){if(["text","password"].indexOf(a(h)[0].type)!==-1||"TEXTAREA"===a(h)[0].tagName.toUpperCase())return;a("#w2ui-overlay"+i+" #menu-search").focus()}d()},200),d(),m}var n=a("#w2ui-overlay"+i+" div.menu"),o=n.find("tr[index="+c.index+"]"),j=n.scrollTop();if(n.find("tr.w2ui-selected").removeClass("w2ui-selected"),o.addClass("w2ui-selected"),o.length>0){var p=o[0].offsetTop-5,q=n.height();n.scrollTop(j),(pj+q)&&n.animate({scrollTop:p-(q-2*o.height())/2},200,"linear")}d()}},a.fn.w2color=function(b,c){function d(a){for(var b,c=(a.color,'
'),d=0;d";for(var e=0;e'+(a.color==h[d][e]?"•":" ")+" ",a.color==h[d][e]&&(g=[d,e]);c+="",d<2&&(c+='')}return c+="
",c+='',c+="
"+("string"==typeof a.html?a.html:"")+'
'}var e=a(this),f=e[0];if(e.data("skipInit"))return void e.removeData("skipInit");var g=[-1,-1];null==a.fn.w2colorPalette&&(a.fn.w2colorPalette=[["000000","333333","555555","777777","888888","999999","AAAAAA","CCCCCC","DDDDDD","EEEEEE","F7F7F7","FFFFFF"],["FF011B","FF9838","FFC300","FFFD59","86FF14","14FF7A","2EFFFC","2693FF","006CE7","9B24F4","FF21F5","FF0099"],["FFEAEA","FCEFE1","FCF4DC","FFFECF","EBFFD9","D9FFE9","E0FFFF","E8F4FF","ECF4FC","EAE6F4","FFF5FE","FCF0F7"],["F4CCCC","FCE5CD","FFF1C2","FFFDA1","D5FCB1","B5F7D0","BFFFFF","D6ECFF","CFE2F3","D9D1E9","FFE3FD","FFD9F0"],["EA9899","F9CB9C","FFE48C","F7F56F","B9F77E","84F0B1","83F7F7","B5DAFF","9FC5E8","B4A7D6","FAB9F6","FFADDE"],["E06666","F6B26B","DEB737","E0DE51","8FDB48","52D189","4EDEDB","76ACE3","6FA8DC","8E7CC3","E07EDA","F26DBD"],["CC0814","E69138","AB8816","B5B20E","6BAB30","27A85F","1BA8A6","3C81C7","3D85C6","674EA7","A14F9D","BF4990"],["99050C","B45F17","80650E","737103","395E14","10783D","13615E","094785","0A5394","351C75","780172","782C5A"]]);var h=a.fn.w2colorPalette;"string"==typeof b&&(b={color:b,transparent:!0}),null==b.onSelect&&null!=c&&(b.onSelect=c),b.transparent&&"333333"==h[0][1]&&(h[0].splice(1,1),h[0].push("")),b.transparent||"333333"==h[0][1]||(h[0].splice(1,0,"333333"),h[0].pop()),b.color&&(b.color=String(b.color).toUpperCase()),"string"==typeof b.color&&"#"===b.color.substr(0,1)&&(b.color=b.color.substr(1)),null==b.fireChange&&(b.fireChange=!0),0===a("#w2ui-overlay").length?a(f).w2overlay(d(b),b):(a("#w2ui-overlay .w2ui-color").parent().html(d(b)),a("#w2ui-overlay").show()),a("#w2ui-overlay .color").off(".w2color").on("mousedown.w2color",function(c){var d=a(c.originalEvent.target).attr("name");g=a(c.originalEvent.target).attr("index").split(":"),"INPUT"===f.tagName.toUpperCase()?(b.fireChange&&a(f).change(),a(f).next().find(">div").css("background-color",d)):a(f).data("_color",d),"function"==typeof b.onSelect&&b.onSelect(d)}).on("mouseup.w2color",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)}),a("#w2ui-overlay .color-original").off(".w2color").on("click.w2color",function(b){var c=w2utils.parseColor(a(b.target).css("background-color"));null!=c&&(k=c,j=w2utils.rgb2hsv(k),l(j),m(),n())}),a("#w2ui-overlay input").off(".w2color").on("mousedown.w2color",function(b){a("#w2ui-overlay").data("keepOpen",!0),setTimeout(function(){a("#w2ui-overlay").data("keepOpen",!0)},10),b.stopPropagation()}).on("change.w2color",function(){var b=a(this),c=parseFloat(b.val()),d=parseFloat(b.attr("max"));isNaN(c)&&(c=0),d>1&&(c=parseInt(c)),d>0&&c>d&&(b.val(d),c=d),c<0&&(b.val(0),c=0);var e=b.attr("name"),f={};["r","g","b","a"].indexOf(e)!==-1?(k[e]=c,j=w2utils.rgb2hsv(k)):["h","s","v"].indexOf(e)!==-1&&(f[e]=c),l(f),m(),n()});var i,j,k=w2utils.parseColor(b.color);null==k&&(k={r:140,g:150,b:160,a:1},j=w2utils.rgb2hsv(k)),j=w2utils.rgb2hsv(k);var l=function(c,d){null!=c.h&&(j.h=c.h),null!=c.s&&(j.s=c.s),null!=c.v&&(j.v=c.v),null!=c.a&&(k.a=c.a,j.a=c.a),k=w2utils.hsv2rgb(j);var e="rgba("+k.r+","+k.g+","+k.b+","+k.a+")",g=[Number(k.r).toString(16).toUpperCase(),Number(k.g).toString(16).toUpperCase(),Number(k.b).toString(16).toUpperCase()];g.forEach(function(a,b){1===a.length&&(g[b]="0"+a)}),1===k.a&&(e=g[0]+g[1]+g[2]),a("#w2ui-overlay .color-preview").css("background-color",e),a("#w2ui-overlay input").each(function(a,b){b.name&&(null!=k[b.name]&&(b.value=k[b.name]),null!=j[b.name]&&(b.value=j[b.name]),"a"===b.name&&(b.value=k.a))}),d?a("#w2ui-overlay .color-original").css("background-color",e):("INPUT"===f.tagName.toUpperCase()?(a(f).val(e).data("skipInit",!0),b.fireChange&&a(f).change(),a(f).next().find(">div").css("background-color",e)):a(f).data("_color",e),"function"==typeof b.onSelect&&b.onSelect(e))},m=function(){var b=a("#w2ui-overlay .palette .value1"),c=a("#w2ui-overlay .rainbow .value2"),d=a("#w2ui-overlay .alpha .value2"),e=parseInt(b.width())/2,f=parseInt(c.width())/2;b.css({left:150*j.s/100-e,top:125*(100-j.v)/100-e}),c.css("left",j.h/2.4-f),d.css("left",150*k.a-f)},n=function(){var b=w2utils.hsv2rgb(j.h,100,100),c=b.r+","+b.g+","+b.b;a("#w2ui-overlay .palette").css("background-image","linear-gradient(90deg, rgba("+c+",0) 0%, rgba("+c+",1) 100%)")},o=function(b){var c=a(this).find(".value1, .value2"),d=parseInt(c.width())/2;c.hasClass("move-x")&&c.css({left:b.offsetX-d+"px"}),c.hasClass("move-y")&&c.css({top:b.offsetY-d+"px"}),i={$el:c,x:b.pageX,y:b.pageY,width:c.parent().width(),height:c.parent().height(),left:parseInt(c.css("left")),top:parseInt(c.css("top"))},q(b),a("body").off(".w2color").on(t,q).on(s,p)},p=function(b){a("body").off(".w2color")},q=function(a){var b=i.$el,c=a.pageX-i.x,d=a.pageY-i.y,e=i.left+c,f=i.top+d,g=parseInt(b.width())/2;e<-g&&(e=-g),f<-g&&(f=-g), -e>i.width-g&&(e=i.width-g),f>i.height-g&&(f=i.height-g),b.hasClass("move-x")&&b.css({left:e+"px"}),b.hasClass("move-y")&&b.css({top:f+"px"});var h=b.parent().attr("name"),j=parseInt(b.css("left"))+g,k=parseInt(b.css("top"))+g;if("palette"===h&&l({s:Math.round(j/i.width*100),v:Math.round(100-k/i.height*100)}),"rainbow"===h){var m=Math.round(2.4*j);l({h:m}),n()}"alpha"===h&&l({a:parseFloat(Number(j/150).toFixed(2))})};a.fn._colorAdvanced!==!0&&b.advanced!==!0||(a("#w2ui-overlay .w2ui-color-tabs :nth-child(2)").click(),a("#w2ui-overlay").removeData("keepOpen")),l({},!0),n(),m();var r="mousedown.w2color",s="mouseup.w2color",t="mousemove.w2color";w2utils.isIOS&&(r="touchstart.w2color",s="touchend.w2color",t="touchmove.w2color "),a("#w2ui-overlay .palette").off(".w2color").on("mousedown.w2color",o),a("#w2ui-overlay .rainbow").off(".w2color").on("mousedown.w2color",o),a("#w2ui-overlay .alpha").off(".w2color").on("mousedown.w2color",o),f.nav=function(b){switch(b){case"up":g[0]--;break;case"down":g[0]++;break;case"right":g[1]++;break;case"left":g[1]--}return g[0]<0&&(g[0]=0),g[0]>h.length-2&&(g[0]=h.length-2),g[1]<0&&(g[1]=0),g[1]>h[0].length-1&&(g[1]=h[0].length-1),color=h[g[0]][g[1]],a(f).data("_color",color),color}}}(jQuery),function($){var w2grid=function(a){this.name=null,this.box=null,this.columns=[],this.columnGroups=[],this.records=[],this.summary=[],this.searches=[],this.sortMap={},this.toolbar={},this.total=0,this.recid=null,this.last={field:"",label:"",logic:"OR",search:"",searchIds:[],selection:{indexes:[],columns:{}},multi:!1,scrollTop:0,scrollLeft:0,colStart:0,colEnd:0,sortData:null,sortCount:0,xhr:null,range_start:null,range_end:null,sel_ind:null,sel_col:null,sel_type:null,edit_col:null,isSafari:/^((?!chrome|android).)*safari/i.test(navigator.userAgent)},$.extend(!0,this,w2obj.grid),this.show=$.extend(!0,{},w2grid.prototype.show),this.postData=$.extend(!0,{},w2grid.prototype.postData),this.httpHeaders=$.extend(!0,{},w2grid.prototype.httpHeaders),this.buttons=$.extend(!0,{},w2grid.prototype.buttons),this.operators=$.extend(!0,{},w2grid.prototype.operators),this.operatorsMap=$.extend(!0,{},w2grid.prototype.operatorsMap),this.stateColProps=$.extend(!0,{},w2grid.prototype.stateColProps),this.stateColDefaults=$.extend(!0,{},w2grid.prototype.stateColDefaults),$.extend(!0,this,a)};$.fn.w2grid=function(a){if($.isPlainObject(a)){if(!w2utils.checkName(a,"w2grid"))return;var b=a.columns,c=a.columnGroups,d=a.records,e=a.searches,f=a.searchData,g=a.sortData,h=new w2grid(a);$.extend(h,{records:[],columns:[],searches:[],sortData:[],searchData:[],handlers:[]});var i;if(b)for(i=0;i0?(p[a]&&p[a].apply(p,Array.prototype.slice.call(arguments,1)),this):p:null},w2grid.prototype={header:"",url:"",limit:100,offset:0,searchData:[],sortData:[],routeData:{},postData:{},httpHeaders:{},show:{header:!1,toolbar:!1,footer:!1,columnHeaders:!0,lineNumbers:!1,expandColumn:!1,selectColumn:!1,emptyRecords:!0,toolbarReload:!0,toolbarColumns:!0,toolbarSearch:!0,toolbarInput:!0,toolbarAdd:!1,toolbarEdit:!1,toolbarDelete:!1,toolbarSave:!1,searchAll:!0,statusRange:!0,statusBuffered:!1,statusRecordID:!0,statusSelection:!0,statusResponse:!0,statusSort:!1,statusSearch:!1,recordTitles:!0,selectionBorder:!0,skipRecords:!0,saveRestoreState:!0},stateId:null,hasFocus:!1,autoLoad:!0,fixedBody:!0,recordHeight:24,lineNumberWidth:null,keyboard:!0,selectType:"row",multiSearch:!0,multiSelect:!0,multiSort:!0,reorderColumns:!1,reorderRows:!1,showExtraOnSearch:0,markSearch:!0,columnTooltip:"normal",disableCVS:!1,textSearch:"begins",nestedFields:!0,vs_start:150,vs_extra:15,style:"",ranges:[],menu:[],method:null,dataType:null,parser:null,stateColProps:{text:!1,field:!0,size:!0,min:!1,max:!1,gridMinWidth:!1,sizeCorrected:!1,sizeCalculated:!0,sizeOriginal:!0,sizeType:!0,hidden:!0,sortable:!1,searchable:!1,resizable:!1,hideable:!1,attr:!1,style:!1,render:!1,title:!1,editable:!1,frozen:!0,info:!1},stateColDefaults:{text:"",field:"",size:null,min:20,max:null,gridMinWidth:null,sizeCorrected:null,sizeCalculated:null,sizeOriginal:null,sizeType:null,hidden:!1,sortable:!1,searchable:!1,resizable:!0,hideable:!0,attr:"",style:"",render:null,title:null,editable:{},frozen:!1,info:null},msgDelete:"Are you sure you want to delete selected records?",msgNotJSON:"Returned data is not in valid JSON format.",msgAJAXerror:"AJAX error. See console for more details.",msgRefresh:"Refreshing...",msgNeedReload:"Your remote data source record count has changed, reloading from the first record.",msgEmpty:"",buttons:{reload:{type:"button",id:"w2ui-reload",icon:"w2ui-icon-reload",tooltip:"Reload data in the list"},columns:{type:"drop",id:"w2ui-column-on-off",icon:"w2ui-icon-columns",tooltip:"Show/hide columns",arrow:!1,html:""},search:{type:"html",id:"w2ui-search",html:"
"},"search-go":{type:"drop",id:"w2ui-search-advanced",icon:"w2ui-icon-search",text:"Search",tooltip:"Open Search Fields"},add:{type:"button",id:"w2ui-add",text:"Add New",tooltip:"Add new record",icon:"w2ui-icon-plus"},edit:{type:"button",id:"w2ui-edit",text:"Edit",tooltip:"Edit selected record",icon:"w2ui-icon-pencil",disabled:!0},delete:{type:"button",id:"w2ui-delete",text:"Delete",tooltip:"Delete selected records",icon:"w2ui-icon-cross",disabled:!0},save:{type:"button",id:"w2ui-save",text:"Save",tooltip:"Save changed records",icon:"w2ui-icon-check"}},operators:{text:["is","begins","contains","ends"],number:["is","between",{oper:"less",text:"less than"},{oper:"more",text:"more than"}],date:["is","between",{oper:"less",text:"before"},{oper:"more",text:"after"}],list:["is"],hex:["is","between"],color:["is","begins","contains","ends"],enum:["in","not in"]},operatorsMap:{text:"text",int:"number",float:"number",money:"number",currency:"number",percent:"number",hex:"hex",alphanumeric:"text",color:"color",date:"date",time:"date",datetime:"date",list:"list",combo:"text",enum:"enum",file:"enum",select:"list",radio:"list",checkbox:"list",toggle:"list"},onAdd:null,onEdit:null,onRequest:null,onLoad:null,onDelete:null,onSave:null,onSelect:null,onUnselect:null,onClick:null,onDblClick:null,onContextMenu:null,onMenuClick:null,onColumnClick:null,onColumnDblClick:null,onColumnResize:null,onColumnAutoResize:null,onSort:null,onSearch:null,onSearchOpen:null,onChange:null,onRestore:null,onExpand:null,onCollapse:null,onError:null,onKeydown:null,onToolbar:null,onColumnOnOff:null,onCopy:null,onPaste:null,onSelectionExtend:null,onEditField:null,onRender:null,onRefresh:null,onReload:null,onResize:null,onDestroy:null,onStateSave:null,onStateRestore:null,onFocus:null,onBlur:null,onReorderRow:null,add:function(a,b){$.isArray(a)||(a=[a]);for(var c=0,d=0;d=0&&d=0&&d0&&(a=Array.isArray(b)&&b.length>0?this.records[b[0]].recid:null),a},remove:function(){for(var a=0,b=0;b=0;c--)this.records[c].recid==arguments[b]&&(this.records.splice(c,1),a++);for(var c=this.summary.length-1;c>=0;c--)this.summary[c].recid==arguments[b]&&(this.summary.splice(c,1),a++)}var d="object"!=typeof this.url?this.url:this.url.get;return d||(this.localSort(!1,!0),this.localSearch()),this.refresh(),a},addColumn:function(a,b){var c=0;1==arguments.length?(b=a,a=this.columns.length):("string"==typeof a&&(a=this.getColumn(a,!0)),null==a&&(a=this.columns.length)),$.isArray(b)||(b=[b]);for(var d=0;d=0;c--)this.columns[c].field==arguments[b]&&(this.columns[c].searchable&&this.removeSearch(arguments[b]),this.columns.splice(c,1),a++);return this.refresh(),a},getColumn:function(a,b){if(0===arguments.length){for(var c=[],d=0;d=0;c--)this.searches[c].field==arguments[b]&&(this.searches.splice(c,1),a++);return this.searchClose(),a},getSearch:function(a,b){if(0===arguments.length){for(var c=[],d=0;d=0;c--)this.searches[c].field==arguments[b]&&(this.searches[c].hidden=!this.searches[c].hidden,a++);return this.searchClose(),a},showSearch:function(){for(var a=0,b=0;b=0;c--)this.searches[c].field==arguments[b]&&this.searches[c].hidden!==!1&&(this.searches[c].hidden=!1,a++);return this.searchClose(),a},hideSearch:function(){for(var a=0,b=0;b=0;c--)this.searches[c].field==arguments[b]&&this.searches[c].hidden!==!0&&(this.searches[c].hidden=!0,a++);return this.searchClose(),a},getSearchData:function(a){for(var b=0;bd.length?1:c.lengthtypeof b?f:-f;if(a.constructor.name!=b.constructor.name)return a.constructor.name>b.constructor.name?f:-f;a&&"object"==typeof a&&(a=a.valueOf()),b&&"object"==typeof b&&(b=b.valueOf());var g={}.toString;switch(a&&"object"==typeof a&&a.toString!=g&&(a=String(a)),b&&"object"==typeof b&&b.toString!=g&&(b=String(b)),"string"==typeof a&&(a=$.trim(a.toLowerCase())),"string"==typeof b&&(b=$.trim(b.toLowerCase())),e){case"natural":e=w2utils.naturalCompare}return"function"==typeof e?e(a,b)*f:a>b?f:a=parseFloat(k)&&parseFloat(f.parseField(a,h.field))<=parseFloat(l)&&c++;else if("date"==h.type){var m=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),j=w2utils.isDate(m,w2utils.settings.dateFormat,!0),k=w2utils.isDate(k,w2utils.settings.dateFormat,!0),l=w2utils.isDate(l,w2utils.settings.dateFormat,!0);null!=l&&(l=new Date(l.getTime()+864e5)),j>=k&&j=k&&j=k&&j=parseFloat(e.value)&&c++;else if("date"==h.type){var m=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),j=w2utils.isDate(m,w2utils.settings.dateFormat,!0),k=w2utils.isDate(k,w2utils.settings.dateFormat,!0);j>=k&&c++}else if("time"==h.type){var m=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),j=w2utils.formatTime(m,"hh24:mi"),k=w2utils.formatTime(k,"hh24:mi");j>=k&&c++}else if("datetime"==h.type){var m=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),j=w2utils.formatDateTime(m,"yyyy-mm-dd|hh24:mm:ss"),k=w2utils.formatDateTime(w2utils.isDateTime(k,w2utils.settings.datetimeFormat,!0),"yyyy-mm-dd|hh24:mm:ss");j.length==k.length&&j>=k&&c++}break;case"in":var m=e.value;e.svalue&&(m=e.svalue),m.indexOf(w2utils.isFloat(i)?parseFloat(i):i)===-1&&m.indexOf(j)===-1||c++;break;case"not in":var m=e.value;e.svalue&&(m=e.svalue),m.indexOf(w2utils.isFloat(i)?parseFloat(i):i)===-1&&m.indexOf(j)===-1&&c++;break;case"begins":case"begins with":0===j.indexOf(k)&&c++;break;case"contains":j.indexOf(k)>=0&&c++;break;case"null":null==f.parseField(a,h.field)&&c++;break;case"not null":null!=f.parseField(a,h.field)&&c++;break;case"ends":case"ends with":var n=j.lastIndexOf(k);n!==-1&&n==j.length-k.length&&c++}}}if("OR"==f.last.logic&&0!==c||"AND"==f.last.logic&&c==f.searchData.length)return!0;if(a.w2ui&&a.w2ui.children&&a.w2ui.expanded!==!0)for(var o=0;o0&&!d){this.total=0;for(var i=0;i0){var l=this.showExtraOnSearch,m=this.showExtraOnSearch;if(ithis.records.length&&(m=this.records.length-i),l>0)for(var n=i-l;n0)for(var n=i+1;n<=i+m;n++)this.last.searchIds.indexOf(n)<0&&this.last.searchIds.push(n)}else this.last.searchIds.push(i)}this.total=this.last.searchIds.length}return e=(new Date).getTime()-e,a!==!0&&f.show.statusSearch&&setTimeout(function(){f.status(w2utils.lang("Search took")+" "+e/1e3+" "+w2utils.lang("sec"))},10),e},getRangeData:function(a,b){var c=this.get(a[0].recid,!0),d=this.get(a[1].recid,!0),e=a[0].column,f=a[1].column,g=[];if(e==f)for(var h=c;h<=d;h++){var i=this.records[h],j=i[this.columns[e].field]||null;b!==!0?g.push(j):g.push({data:j,column:e,index:h,record:i})}else if(c==d)for(var i=this.records[c],k=e;k<=f;k++){var j=i[this.columns[k].field]||null;b!==!0?g.push(j):g.push({data:j,column:k,index:c,record:i})}else for(var h=c;h<=d;h++){var i=this.records[h];g.push([]);for(var k=e;k<=f;k++){var j=i[this.columns[k].field];b!==!0?g[g.length-1].push(j):g[g.length-1].push({data:j,column:k,index:h,record:i})}}return g},addRange:function(a){var b=0;if("row"==this.selectType)return b;$.isArray(a)||(a=[a]);for(var c=0;c=0;d--)this.ranges[d].name==c&&(this.ranges.splice(d,1),a++)}return a},refreshRanges:function(){function a(a){var e=d.getSelection();d.last.move={type:"expand",x:a.screenX,y:a.screenY,divX:0,divY:0,recid:e[0].recid,column:e[0].column,originalRange:[{recid:e[0].recid,column:e[0].column},{recid:e[e.length-1].recid,column:e[e.length-1].column}],newRange:[{recid:e[0].recid,column:e[0].column},{recid:e[e.length-1].recid,column:e[e.length-1].column}]},$(document).off(".w2ui-"+d.name).on("mousemove.w2ui-"+d.name,b).on("mouseup.w2ui-"+d.name,c),a.preventDefault()}function b(a){var b=d.last.move;if(b&&"expand"==b.type){b.divX=a.screenX-b.x,b.divY=a.screenY-b.y;var c,e,f=a.originalEvent.target;if("TD"!=f.tagName.toUpperCase()&&(f=$(f).parents("td")[0]),null!=$(f).attr("col")&&(e=parseInt($(f).attr("col"))),f=$(f).parents("tr")[0],c=$(f).attr("recid"),b.newRange[1].recid!=c||b.newRange[1].column!=e){var g=$.extend({},b.newRange);return b.newRange=[{recid:b.recid,column:b.column},{recid:c,column:e}],B=d.trigger($.extend(B,{originalRange:b.originalRange,newRange:b.newRange})),B.isCancelled===!0?(b.newRange=g,void(B.newRange=g)):(d.removeRange("grid-selection-expand"),void d.addRange({name:"grid-selection-expand",range:B.newRange,style:"background-color: rgba(100,100,100,0.1); border: 2px dotted rgba(100,100,100,0.5);"}))}}}function c(a){d.removeRange("grid-selection-expand"),delete d.last.move,$(document).off(".w2ui-"+d.name),d.trigger($.extend(B,{phase:"after"}))}if(0!==this.ranges.length){for(var d=this,e=(new Date).getTime(),f=$("#grid_"+this.name+"_frecords"),g=$("#grid_"+this.name+"_records"),h=0;hthis.last.colStart&&(l=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(j.recid)+' td[col="start"]')),j.columnthis.last.colEnd&&(p='"end"',m=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(k.recid)+' td[col="end"]'));var q=parseInt($("#grid_"+this.name+"_rec_top").next().attr("index")),r=parseInt($("#grid_"+this.name+"_rec_bottom").prev().attr("index")),s=parseInt($("#grid_"+this.name+"_frec_top").next().attr("index")),t=parseInt($("#grid_"+this.name+"_frec_bottom").prev().attr("index"));0===l.length&&j.indexq&&(l=$("#grid_"+this.name+"_rec_top").next().find("td[col="+j.column+"]")),0===m.length&&k.index>r&&j.indexs&&(n=$("#grid_"+this.name+"_frec_top").next().find("td[col="+j.column+"]")),0===o.length&&k.index>t&&j.index0||o.length>0)if(0===y.length?(f.append('
'+("selection"==i.name?'
':"")+"
"),y=$("#grid_"+this.name+"_f"+i.name)):(y.attr("style",i.style),y.find(".w2ui-selection-resizer").show()),0===o.length&&(o=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(k.recid)+" td:last-child"),0===o.length&&(o=$("#grid_"+this.name+"_frec_bottom td:first-child")),y.css("border-right","0px"),y.find(".w2ui-selection-resizer").hide()),null!=j.recid&&null!=k.recid&&n.length>0&&o.length>0){var z=n.position().left-1+f.scrollLeft(),A=n.position().top-1+f.scrollTop();y.show().css({left:(z>0?z:0)+"px",top:(A>0?A:0)+"px",width:o.position().left-n.position().left+o.width()+3+"px",height:o.position().top-n.position().top+o.height()+3+"px"})}else y.hide();else y.hide();var y=$("#grid_"+this.name+"_"+i.name);if(l.length>0||m.length>0)if(0===y.length?(g.append('
'+("selection"==i.name?'
':"")+"
"),y=$("#grid_"+this.name+"_"+i.name)):y.attr("style",i.style),0===l.length&&(l=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(j.recid)+" td:first-child"),0===l.length&&(l=$("#grid_"+this.name+"_rec_top td:first-child"))),0!==o.length&&y.css("border-left","0px"),null!=j.recid&&null!=k.recid&&l.length>0&&m.length>0){var z=l.position().left-1+g.scrollLeft(),A=l.position().top-1+g.scrollTop();y.show().css({left:(z>0?z:0)+"px",top:(A>0?A:0)+"px",width:m.position().left-l.position().left+m.width()+3+"px",height:m.position().top-l.position().top+m.height()+3+"px"})}else y.hide();else y.hide()}}$(this.box).find(".w2ui-selection-resizer").off("mousedown").on("mousedown",a).off("dblclick").on("dblclick",function(a){var b=d.trigger({phase:"before",type:"resizerDblClick",target:d.name,originalEvent:a});b.isCancelled!==!0&&d.trigger($.extend(b,{phase:"after"}))});var B={phase:"before",type:"selectionExtend",target:d.name,originalRange:null,newRange:null};return(new Date).getTime()-e}},select:function(){if(0===arguments.length)return 0;var a=((new Date).getTime(),0),b=this.last.selection;this.multiSelect||this.selectNone();var c={phase:"before",type:"select",target:this.name};1==arguments.length?(c.multiple=!1,$.isPlainObject(arguments[0])?(c.recid=arguments[0].recid,c.column=arguments[0].column):c.recid=arguments[0]):(c.multiple=!0,c.recids=Array.prototype.slice.call(arguments,0));var d=this.trigger(c);if(d.isCancelled===!0)return 0;if("row"==this.selectType)for(var e=0;e=this.last.range_start&&g+1<=this.last.range_end)&&(h=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(f)),i=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(f))),"row"==this.selectType){if(b.indexes.indexOf(g)!=-1)continue;b.indexes.push(g),h&&i&&(h.addClass("w2ui-selected").data("selected","yes").find(".w2ui-col-number").addClass("w2ui-row-selected"),i.addClass("w2ui-selected").data("selected","yes").find(".w2ui-col-number").addClass("w2ui-row-selected"),h.find(".w2ui-grid-select-check").prop("checked",!0)),a++}}}else{for(var j={},e=0;e=this.last.range_start&&g+1<=this.last.range_end&&(h=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(f)),i=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(f)));var n=b.columns[g]||[];b.indexes.indexOf(g)==-1&&b.indexes.push(g);for(var o=0;o0&&b.indexes.length==this.records.length,s=b.indexes.length>0&&0!==this.searchData.length&&b.indexes.length==this.last.searchIds.length;return r||s?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.addRange("selection"),this.trigger($.extend(d,{phase:"after"})),a},unselect:function(){for(var a=0,b=this.last.selection,c=0;c td[col="+j+"]").removeClass("w2ui-selected w2ui-inactive"),$("#grid_"+this.name+"_frec_"+w2utils.escapeId(d)).find(" > td[col="+j+"]").removeClass("w2ui-selected w2ui-inactive");for(var n=!1,o=!1,p=this.getSelection(),l=0;l0&&b.indexes.length==this.records.length,r=b.indexes.length>0&&0!==this.searchData.length&&b.indexes.length==this.last.searchIds.length;return q||r?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.addRange("selection"),a},selectAll:function(){var a=(new Date).getTime();if(this.multiSelect!==!1){var b=this.trigger({phase:"before",type:"select",target:this.name,all:!0});if(b.isCancelled!==!0){for(var c="object"!=typeof this.url?this.url:this.url.get,d=this.last.selection,e=[],f=0;f=1?this.toolbar.enable("w2ui-delete"):this.toolbar.disable("w2ui-delete"),this.addRange("selection"),$("#grid_"+this.name+"_check_all").prop("checked",!0),this.status(),this.trigger($.extend(b,{phase:"after"})),(new Date).getTime()-a}}},selectNone:function(){var a=(new Date).getTime(),b=this.trigger({phase:"before",type:"unselect",target:this.name,all:!0});if(b.isCancelled!==!0){var c=this.last.selection;return"row"==this.selectType?($(this.box).find(".w2ui-grid-records tr.w2ui-selected").removeClass("w2ui-selected w2ui-inactive").removeData("selected").find(".w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-frecords tr.w2ui-selected").removeClass("w2ui-selected w2ui-inactive").removeData("selected").find(".w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find("input.w2ui-grid-select-check").prop("checked",!1)):($(this.box).find(".w2ui-grid-columns td .w2ui-col-header, .w2ui-grid-fcolumns td .w2ui-col-header").removeClass("w2ui-col-selected"),$(this.box).find(".w2ui-grid-records tr .w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-frecords tr .w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-data.w2ui-selected").removeClass("w2ui-selected w2ui-inactive").removeData("selected"),$(this.box).find("input.w2ui-grid-select-check").prop("checked",!1)),c.indexes=[],c.columns={},this.toolbar.disable("w2ui-edit","w2ui-delete"),this.removeRange("selection"),$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.trigger($.extend(b,{phase:"after"})),(new Date).getTime()-a}},getSelection:function(a){var b=[],c=this.last.selection;if("row"==this.selectType){for(var d=0;d0)for(var j=0;j0){var v={field:k.field,type:k.type,operator:null!=k.operator?k.operator:"in",value:x};d.push(v)}}}else for(var j=0;j0&&e[0].focus(),b.checked||(b.checked=!0,$(c).addClass("checked")),a.trigger($.extend(d,{phase:"after"}))},onHide:function(){b.checked=!1,$(c).removeClass("checked")}})}},searchClose:function(){this.box&&0!==this.searches.length&&(this.toolbar&&this.toolbar.uncheck("w2ui-search-advanced"),$().w2overlay({name:this.name+"-searchOverlay"}))},searchReset:function(a){for(var b=[],c=!1,d=0;d0)if(this.multiSearch&&this.show.searchAll)this.last.field="all",this.last.label=w2utils.lang("All Fields");else{for(var f=0;f=this.searches.length?(this.last.field="",this.last.label=""):(this.last.field=this.searches[f].field,this.last.label=this.searches[f].label)}this.last.multi=!1,this.last.xhr_offset=0,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selection.indexes=[],this.last.selection.columns={},this.searchClose(),$("#grid_"+this.name+"_search_all").val("").removeData("selected"),a||this.reload(),this.trigger($.extend(e,{phase:"after"}))}},searchShowFields:function(){for(var a=this,b=$("#grid_"+this.name+"_search_all"),c='
',d=-1;d",e),e.label=e.caption),c+=""}c+="
'+e.label+"
",setTimeout(function(){$(b).w2overlay({html:c,name:a.name+"-searchFields",left:-10})},1)},initAllField:function(a,b){var c=$("#grid_"+this.name+"_search_all");if("all"==a){var d={field:"all",label:w2utils.lang("All Fields")};c.w2field("clear"),c.change()}else{var d=this.getSearch(a);if(null==d)return;var e=d.type;["enum","select"].indexOf(e)!=-1&&(e="list"),c.w2field(e,$.extend({},d.options,{suffix:"",autoFormat:!1,selected:b})),["list","enum","date","time","datetime"].indexOf(d.type)!=-1&&(this.last.search="",this.last.item="",c.val(""))}""!=this.last.search?(this.last.label=d.label,this.search(d.field,this.last.search)):(this.last.field=d.field,this.last.label=d.label),c.attr("placeholder",w2utils.lang(d.label||d.caption||d.field)),$().w2overlay({name:this.name+"-searchFields"})},clear:function(a){this.total=0,this.records=[],this.summary=[],this.last.xhr_offset=0,this.last.idCache={},this.reset(!0),a||this.refresh()},reset:function(a){this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selection={indexes:[],columns:{}},this.last.range_start=null,this.last.range_end=null,$("#grid_"+this.name+"_records").prop("scrollTop",0),a||this.refresh()},skip:function(a,b){var c="object"!=typeof this.url?this.url:this.url.get;c?(this.offset=parseInt(a),this.offset>this.total&&(this.offset=this.total-this.limit),(this.offset<0||!w2utils.isInt(this.offset))&&(this.offset=0),this.clear(!0),this.reload(b)):console.log("ERROR: grid.skip() can only be called when you have remote data source.")},load:function(a,b){return null==a?void console.log('ERROR: You need to provide url argument when calling .load() method of "'+this.name+'" object.'):(this.clear(!0),void this.request("get",{},a,b))},reload:function(a){var b=this,c="object"!=typeof this.url?this.url:this.url.get;b.selectionSave(),c?this.load(c,function(){b.selectionRestore(),"function"==typeof a&&a()}):(this.reset(!0),this.localSearch(),this.selectionRestore(),"function"==typeof a&&a({status:"success"}))},request:function(a,b,c,d){if(null==b&&(b={}),""!=c&&null!=c||(c=this.url),""!=c&&null!=c){w2utils.isInt(this.offset)||(this.offset=0),w2utils.isInt(this.last.xhr_offset)||(this.last.xhr_offset=0);var e={cmd:a,selected:this.getSelection(),limit:this.limit,offset:parseInt(this.offset)+parseInt(this.last.xhr_offset),searchLogic:this.last.logic,search:this.searchData.map(function(a){var b=$.extend({},a);return this.searchMap&&this.searchMap[b.field]&&(b.field=this.searchMap[b.field]),b}.bind(this)),sort:this.sortData.map(function(a){var b=$.extend({},a);return this.sortMap&&this.sortMap[b.field]&&(b.field=this.sortMap[b.field]),b}.bind(this))};if(0===this.searchData.length&&(delete e.search,delete e.searchLogic),0===this.sortData.length&&delete e.sort,$.extend(e,this.postData),$.extend(e,b),"get"==a){var f=this.trigger({phase:"before",type:"request",target:this.name,url:c,postData:e,httpHeaders:this.httpHeaders});if(f.isCancelled===!0)return void("function"==typeof d&&d({status:"error",message:"Request aborted."}))}else var f={url:c,postData:e,httpHeaders:this.httpHeaders};var g=this;if(0===this.last.xhr_offset)g.lock(w2utils.lang(g.msgRefresh),!0);else{var h=$("#grid_"+this.name+"_rec_more, #grid_"+this.name+"_frec_more");this.autoLoad===!0?h.show().find("td").html('
'):h.find("td").html("
"+w2utils.lang("Load")+" "+g.limit+" "+w2utils.lang("More")+"...
")}if(this.last.xhr)try{this.last.xhr.abort()}catch(a){}if(c="object"!=typeof f.url?f.url:f.url.get,"save"==e.cmd&&"object"==typeof f.url&&(c=f.url.save),"delete"==e.cmd&&"object"==typeof f.url&&(c=f.url.remove),!$.isEmptyObject(g.routeData)){var i=w2utils.parseRoute(c);if(i.keys.length>0)for(var j=0;jc.width()&&c.width(e+20)}catch(a){}}var f=this;if(this.last.inEditMode!==!0){var g=f.get(a,!0),h=f.getCellEditable(g,b);if(h){var i=f.records[g],j=f.columns[b],k=j.frozen===!0?"_f":"_";if(["enum","file"].indexOf(h.type)!=-1)return void console.log('ERROR: input types "enum" and "file" are not supported in inline editing.');var l=f.trigger({phase:"before",type:"editField",target:f.name,recid:a,column:b,value:c,index:g,originalEvent:d});if(l.isCancelled!==!0&&(c=l.value,this.last.inEditMode=!0,this.last._edit={value:c,index:g,column:b,recid:a},this.selectNone(),this.select({recid:a,column:b}),["checkbox","check"].indexOf(h.type)==-1)){var m=$("#grid_"+f.name+k+"rec_"+w2utils.escapeId(a)),n=m.find("[col="+b+"] > div");$(this.box).find("div.w2ui-edit-box").remove(),"row"!=this.selectType&&($("#grid_"+this.name+k+"selection").attr("id","grid_"+this.name+"_editable").removeClass("w2ui-selection").addClass("w2ui-edit-box").prepend('
').find(".w2ui-selection-resizer").remove(),n=$("#grid_"+this.name+"_editable >div:first-child")),null==h.inTag&&(h.inTag=""),null==h.outTag&&(h.outTag=""),null==h.style&&(h.style=""),null==h.items&&(h.items=[]);var o=i.w2ui&&i.w2ui.changes&&null!=i.w2ui.changes[j.field]?w2utils.stripTags(i.w2ui.changes[j.field]):w2utils.stripTags(i[j.field]);null==o&&(o="");var p="object"!=typeof o?o:"";null!=l.old_value&&(p=l.old_value),null!=c&&(o=c);var q=null!=j.style?j.style+";":"";switch("string"==typeof j.render&&["number","int","float","money","percent","size"].indexOf(j.render.split(":")[0])!=-1&&(q+="text-align: right;"),h.items.length>0&&!$.isPlainObject(h.items[0])&&(h.items=w2obj.field.prototype.normMenu(h.items)),h.type){case"select":for(var r="",s=0;s"+h.items[s].text+"";n.addClass("w2ui-editable").html('"+h.outTag),setTimeout(function(){n.find("select").on("change",function(a){delete f.last.move}).on("blur",function(a){1!=$(this).data("keep-open")&&f.editChange.call(f,this,g,b,a)})},10);break;case"div":var t=m.find("[col="+b+"] > div"),u="font-family: "+t.css("font-family")+"; font-size: "+t.css("font-size")+";";n.addClass("w2ui-editable").html('
"+h.outTag),null==c&&n.find("div.w2ui-input").text("object"!=typeof o?o:"");var v=n.find("div.w2ui-input").get(0);setTimeout(function(){var a=v;$(a).on("blur",function(c){1!=$(this).data("keep-open")&&f.editChange.call(f,a,g,b,c)})},10),null!=c&&$(v).text("object"!=typeof o?o:"");break;default:var t=m.find("[col="+b+"] > div"),u="font-family: "+t.css("font-family")+"; font-size: "+t.css("font-size");n.addClass("w2ui-editable").html('"+h.outTag),"number"==h.type&&(o=w2utils.formatNumber(o)),"date"==h.type&&(o=w2utils.formatDate(w2utils.isDate(o,h.format,!0)||new Date,h.format)),null==c&&n.find("input").val("object"!=typeof o?o:"");var v=n.find("input").get(0);$(v).w2field(h.type,$.extend(h,{selected:o})),setTimeout(function(){var a=v;"list"==h.type&&(a=$($(v).data("w2field").helpers.focus).find("input"),"object"!=typeof o&&""!=o&&a.val(o).css({opacity:1}).prev().css({opacity:1}),n.find("input").on("change",function(a){f.editChange.call(f,v,g,b,a)})),$(a).on("blur",function(a){1!=$(this).data("keep-open")&&f.editChange.call(f,v,g,b,a)})},10),null!=c&&$(v).val("object"!=typeof o?o:"")}setTimeout(function(){f.last.inEditMode&&(n.find("input, select, div.w2ui-input").data("old_value",p).on("mousedown",function(a){a.stopPropagation()}).on("click",function(a){"div"==h.type?e.call(n.find("div.w2ui-input")[0],null):e.call(n.find("input, select")[0],null)}).on("paste",function(a){var b=a.originalEvent;a.preventDefault();var c=b.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,c)}).on("keydown",function(c){var d=this,k="DIV"==d.tagName.toUpperCase()?$(d).text():$(d).val();switch(c.keyCode){case 8:"list"!=h.type||$(v).data("w2field")||c.preventDefault();break;case 9:case 13:c.preventDefault();break;case 37:0===w2utils.getCursorPosition(d)&&c.preventDefault();break;case 39:w2utils.getCursorPosition(d)==k.length&&(w2utils.setCursorPosition(d,k.length),c.preventDefault())}setTimeout(function(){switch(c.keyCode){case 9:var h=a,k=c.shiftKey?f.prevCell(g,b,!0):f.nextCell(g,b,!0);if(null==k){var l=c.shiftKey?f.prevRow(g,b):f.nextRow(g,b);if(null!=l&&l!=g){h=f.records[l].recid;for(var m=0;m0&&(a.focus(),clearTimeout(f.last.kbd_timer),"SELECT"!=a[0].tagName.toUpperCase()&&w2utils.setCursorPosition(a[0],b),a[0].resize=e,e.call(a[0],null))}},50),f.trigger($.extend(l,{phase:"after",input:n.find("input, select, div.w2ui-input")})))},5)}}}else if(13==d.keyCode){var g=this.last._edit.index,b=this.last._edit.column,a=this.last._edit.recid;this.editChange({type:"custom",value:this.last._edit.value},this.get(a,!0),b,d);var w=d.shiftKey?this.prevRow(g,b):this.nextRow(g,b);null!=w&&w!=g&&setTimeout(function(){"row"!=f.selectType?(f.selectNone(),f.select({recid:f.records[w].recid,column:b})):f.editField(f.records[w].recid,b,null,d)},1),this.last.inEditMode=!1}else{var x=$(this.box).find("div.w2ui-edit-box .w2ui-input");x.length>0&&"DIV"==x[0].tagName&&(x.text(x.text()+c),w2utils.setCursorPosition(x[0],x.text().length))}},editChange:function(a,b,c,d){ -var e=this;setTimeout(function(){var a=$(e.box).find("#grid_"+e.name+"_focus");a.is(":focus")||a.focus()},10);var f=b<0;b=b<0?-b-1:b;var g=f?this.summary:this.records,h=g[b],i=this.columns[c],j=$("#grid_"+this.name+(i.frozen===!0?"_frec_":"_rec_")+w2utils.escapeId(h.recid)),k=a.tagName&&"DIV"==a.tagName.toUpperCase()?$(a).text():a.value,l=this.parseField(h,i.field),m=$(a).data("w2field");m&&("list"==m.type&&(k=$(a).data("selected")),($.isEmptyObject(k)||null==k)&&(k=""),$.isPlainObject(k)||(k=m.clean(k))),"checkbox"==a.type&&(h.w2ui&&h.w2ui.editable===!1&&(a.checked=!a.checked),k=a.checked);var n={phase:"before",type:"change",target:this.name,input_id:a.id,recid:h.recid,index:b,column:c,originalEvent:d.originalEvent?d.originalEvent:d,value_new:k,value_previous:h.w2ui&&h.w2ui.changes&&h.w2ui.changes.hasOwnProperty(i.field)?h.w2ui.changes[i.field]:l,value_original:l};for(null!=$(d.target).data("old_value")&&(n.value_previous=$(d.target).data("old_value"));;){if(k=n.value_new,"object"!=typeof k&&String(l)!=String(k)||"object"==typeof k&&k&&k.id!=l&&("object"!=typeof l||null==l||k.id!=l.id)){if(n=this.trigger($.extend(n,{type:"change",phase:"before"})),n.isCancelled!==!0){if(k!==n.value_new)continue;h.w2ui=h.w2ui||{},h.w2ui.changes=h.w2ui.changes||{},h.w2ui.changes[i.field]=n.value_new,this.trigger($.extend(n,{phase:"after"}))}}else if(n=this.trigger($.extend(n,{type:"restore",phase:"before"})),n.isCancelled!==!0){if(k!==n.value_new)continue;h.w2ui&&h.w2ui.changes&&delete h.w2ui.changes[i.field],h.w2ui&&$.isEmptyObject(h.w2ui.changes)&&delete h.w2ui.changes,this.trigger($.extend(n,{phase:"after"}))}break}var o=$(j).find("[col="+c+"]");f||(h.w2ui&&h.w2ui.changes&&null!=h.w2ui.changes[i.field]?o.addClass("w2ui-changed"):o.removeClass("w2ui-changed"),o.replaceWith(this.getCellHTML(b,c,f))),$(this.box).find("div.w2ui-edit-box").remove(),this.show.toolbarSave&&(this.getChanges().length>0?this.toolbar.enable("w2ui-save"):this.toolbar.disable("w2ui-save")),e.last.inEditMode=!1},delete:function(a){var b=((new Date).getTime(),this),c=this.trigger({phase:"before",target:this.name,type:"delete",force:a});if(a&&this.message(),c.isCancelled!==!0){a=c.force,setTimeout(function(){$().w2tag()},20);var d=this.getSelection();if(0!==d.length){if(""!=this.msgDelete&&!a)return void this.message({width:350,height:170,body:'
'+w2utils.lang(b.msgDelete)+"
",buttons:w2utils.settings.macButtonOrder?'":'",onOpen:function(a){var c=$(this.box).find("input, textarea, select, button");c.off(".message").on("blur.message",function(a){c.index(a.target)+1===c.length&&(c.get(0).focus(),a.preventDefault())}).on("keydown.message",function(a){27==a.keyCode&&b.message()}),setTimeout(function(){$(this.box).find(".w2ui-btn.btn-default").focus(),clearTimeout(b.last.kbd_timer)}.bind(this),50)}});var e="object"!=typeof this.url?this.url:this.url.remove;if(e)this.request("delete");else if("object"!=typeof d[0])this.selectNone(),this.remove.apply(this,d);else{for(var f=0;f0&&e.multiSelect){if(i[0].recid){var l=this.get(i[0].recid,!0),m=this.get(a,!0);if(d>i[0].column)var n=i[0].column,o=d;else var n=d,o=i[0].column;for(var p=n;p<=o;p++)k.push(p)}else var l=this.get(f,!0),m=this.get(a,!0);var q=[];if(l>m){var g=l;l=m,m=g}for(var r="object"!=typeof this.url?this.url:this.url.get,s=l;s<=m;s++)if(!(this.searchData.length>0)||r||$.inArray(s,this.last.searchIds)!=-1)if("row"==this.selectType)q.push(this.records[s].recid);else for(var t=0;t300?this.selectNone():this.unselect.apply(this,i),v===!0&&1==i.length?this.unselect({recid:a,column:d}):this.select({recid:a,column:d})}this.status(),e.initResize(),this.trigger($.extend(h,{phase:"after"}))}}},columnClick:function(a,b){var c=this.trigger({phase:"before",type:"columnClick",target:this.name,field:a,originalEvent:b});if(c.isCancelled!==!0){if("row"==this.selectType){var d=this.getColumn(a);d&&d.sortable&&this.sort(a,null,!(!b||!b.ctrlKey&&!b.metaKey)),"line-number"==c.field&&(this.getSelection().length>=this.records.length?this.selectNone():this.selectAll())}else{if(b.altKey){var d=this.getColumn(a);d&&d.sortable&&this.sort(a,null,!(!b||!b.ctrlKey&&!b.metaKey))}if("line-number"==c.field)this.getSelection().length>=this.records.length?this.selectNone():this.selectAll();else{b.shiftKey||b.metaKey||b.ctrlKey||this.selectNone();var e=this.getSelection(),d=this.getColumn(c.field,!0),f=[],g=[];if(0!=e.length&&b.shiftKey){var h=d,i=e[0].column;h>i&&(h=e[0].column,i=d);for(var j=h;j<=i;j++)g.push(j)}else g.push(d);var c=this.trigger({phase:"before",type:"columnSelect",target:this.name,columns:g});if(c.isCancelled!==!0){for(var j=0;j1){for(var a=0;a1&&(i.splice(i.indexOf(d.records[d.last.sel_ind].recid),1),d.unselect.apply(d,i),!0)}var d=this,e="object"!=typeof this.url?this.url:this.url.get;if(d.keyboard===!0){var f=d.trigger({phase:"before",type:"keydown",target:d.name,originalEvent:a});if(f.isCancelled!==!0){if($(this.box).find(">.w2ui-message").length>0)return void(27==a.keyCode&&this.message());var g=!1,h=$("#grid_"+d.name+"_records"),i=d.getSelection();0===i.length&&(g=!0);var j=i[0]||null,k=[],l=i[i.length-1];if("object"==typeof j&&null!=j){j=i[0].recid,k=[];for(var m=0;;){if(!i[m]||i[m].recid!=j)break;k.push(i[m].column),m++}l=i[i.length-1].recid}var n=d.get(j,!0),o=d.get(l,!0),p=(d.get(j),$("#grid_"+d.name+"_rec_"+(null!=n?w2utils.escapeId(d.records[n].recid):"none"))),q=!1,r=a.keyCode,s=a.shiftKey;switch(r){case 8:case 46:var t=this.toolbar.get("w2ui-delete");t&&t.hidden!==!0&&d.delete(),q=!0,a.stopPropagation();break;case 27:d.selectNone(),q=!0;break;case 65:if(!a.metaKey&&!a.ctrlKey)break;d.selectAll(),q=!0;break;case 13:if("row"==this.selectType&&d.show.expandColumn===!0){if(p.length<=0)break;d.toggle(j,a),q=!0}else{for(var u=0;u0&&(d.editField(j,k[0],null,a),q=!0)}break;case 37:if(g){b();break}if("row"==this.selectType){if(p.length<=0)break;var w=this.records[n].w2ui||{};!w||null==w.parent_recid||Array.isArray(w.children)&&0!==w.children.length&&w.expanded?d.collapse(j,a):(d.unselect(j),d.collapse(w.parent_recid,a),d.select(w.parent_recid))}else{var x=d.prevCell(n,k[0]);if(s||null!=x||(this.selectNone(),x=0),null!=x)if(s&&d.multiSelect){if(c())return;var w=[],y=[],z=[];if(0===k.indexOf(this.last.sel_col)&&k.length>1){for(var A=0;A1)d.selectNone();else for(var B=1;B1){for(var A=0;A1)d.selectNone();else for(var B=0;Bx&&d.last.sel_ind!=o?d.unselect(d.records[o].recid):d.select(d.records[x].recid);else if(d.last.sel_ind>x&&d.last.sel_ind!=o){x=o;for(var w=[],u=0;u300?this.selectNone():this.unselect.apply(this,i),d.click({recid:d.records[x].recid,column:k[0]},a);d.scrollIntoView(x),a.preventDefault&&a.preventDefault()}else if(!s)if(i.length>1)d.selectNone();else for(var B=1;B300?this.selectNone():this.unselect.apply(this,i),d.click({recid:d.records[C].recid,column:k[0]},a);d.scrollIntoView(C),q=!0}else if(!s)if(i.length>1)d.selectNone();else for(var B=0;B0&&(a=this.last.searchIds.indexOf(a)),f.height()0?g:d)&&f.length>0){var h=Math.floor(f[0].scrollTop/this.recordHeight),i=h+Math.floor(f.height()/this.recordHeight);a==h&&(c===!0?f.prop({scrollTop:f.scrollTop()-f.height()/1.3}):(f.stop(),f.animate({scrollTop:f.scrollTop()-f.height()/1.3},250,"linear"))),a==i&&(c===!0?f.prop({scrollTop:f.scrollTop()+f.height()/1.3}):(f.stop(),f.animate({scrollTop:f.scrollTop()+f.height()/1.3},250,"linear"))),(ai)&&(c===!0?f.prop({scrollTop:(a-1)*this.recordHeight}):(f.stop(),f.animate({scrollTop:(a-1)*this.recordHeight},250,"linear")))}if(null!=b){for(var j=0,k=0,l=w2utils.scrollBarSize(),m=0;m<=b;m++){var n=this.columns[m];n.frozen||n.hidden||(j=k,k+=parseInt(n.sizeCalculated))}f.width()0&&$(d.box).find(c.target).w2menu(d.menu,{originalEvent:c,contextMenu:!0,onSelect:function(b){d.menuClick(a,parseInt(b.index),b.originalEvent)}}),c.preventDefault&&c.preventDefault(),d.trigger($.extend(i,{phase:"after"})))}},menuClick:function(a,b,c){var d=this,e=d.trigger({phase:"before",type:"menuClick",target:d.name,originalEvent:c,recid:a,menuIndex:b,menuItem:d.menu[b]});e.isCancelled!==!0&&d.trigger($.extend(e,{phase:"after"}))},toggle:function(a){var b=this.get(a);return b.w2ui=b.w2ui||{},b.w2ui.expanded===!0?this.collapse(a):this.expand(a)},expand:function(a){var b=this.get(a,!0),c=this.records[b];c.w2ui=c.w2ui||{};var d=w2utils.escapeId(a),e=c.w2ui.children;if(Array.isArray(e)){if(c.w2ui.expanded===!0||0===e.length)return!1;var f=this.trigger({phase:"before",type:"expand",target:this.name,recid:a});if(f.isCancelled===!0)return!1;c.w2ui.expanded=!0,e.forEach(function(a){a.w2ui=a.w2ui||{},a.w2ui.parent_recid=c.recid,null==a.w2ui.children&&(a.w2ui.children=[])}),this.records.splice.apply(this.records,[b+1,0].concat(e)),this.total+=e.length;var g="object"!=typeof this.url?this.url:this.url.get;g||(this.localSort(!0,!0),this.searchData.length>0&&this.localSearch(!0)),this.refresh(),this.trigger($.extend(f,{phase:"after"}))}else{if($("#grid_"+this.name+"_rec_"+d+"_expanded_row").length>0||this.show.expandColumn!==!0)return!1;if("none"==c.w2ui.expanded)return!1;$("#grid_"+this.name+"_rec_"+d).after('
'),$("#grid_"+this.name+"_frec_"+d).after(''+(this.show.lineNumbers?'':"")+'
');var f=this.trigger({phase:"before",type:"expand",target:this.name,recid:a,box_id:"grid_"+this.name+"_rec_"+a+"_expanded",fbox_id:"grid_"+this.name+"_frec_"+d+"_expanded"});if(f.isCancelled===!0)return $("#grid_"+this.name+"_rec_"+d+"_expanded_row").remove(),$("#grid_"+this.name+"_frec_"+d+"_expanded_row").remove(),!1;var h=$(this.box).find("#grid_"+this.name+"_rec_"+a+"_expanded"),i=$(this.box).find("#grid_"+this.name+"_frec_"+a+"_expanded"),j=h.find("> div:first-child").height();h.height()=0)break;l++}this.records.splice(k,l-k+1),this.total-=l-k+1;var m="object"!=typeof this.url?this.url:this.url.get;m||this.searchData.length>0&&this.localSearch(!0),this.refresh(),c.trigger($.extend(h,{phase:"after"}))}else{if(0===$("#grid_"+this.name+"_rec_"+f+"_expanded_row").length||this.show.expandColumn!==!0)return!1;var h=this.trigger({phase:"before",type:"collapse",target:this.name,recid:a,box_id:"grid_"+this.name+"_rec_"+f+"_expanded",fbox_id:"grid_"+this.name+"_frec_"+f+"_expanded"});if(h.isCancelled===!0)return!1;$("#grid_"+this.name+"_rec_"+f).removeAttr("expanded").removeClass("w2ui-expanded"),$("#grid_"+this.name+"_frec_"+f).removeAttr("expanded").removeClass("w2ui-expanded"),$("#grid_"+this.name+"_cell_"+this.get(a,!0)+"_expand div").html("+"),$("#grid_"+c.name+"_rec_"+f+"_expanded").css("height","0px"),$("#grid_"+c.name+"_frec_"+f+"_expanded").css("height","0px"),setTimeout(function(){$("#grid_"+c.name+"_rec_"+f+"_expanded_row").remove(),$("#grid_"+c.name+"_frec_"+f+"_expanded_row").remove(),e.w2ui.expanded=!1,c.trigger($.extend(h,{phase:"after"})),c.resizeRecords()},300)}return!0},sort:function(a,b,c){var d=this.trigger({phase:"before",type:"sort",target:this.name,field:a,direction:b,multiField:c});if(d.isCancelled!==!0){if(null!=a){for(var e=this.sortData.length,f=0;f0&&this.localSearch(!0),this.last.scrollTop=0,$("#grid_"+this.name+"_records").prop("scrollTop",0),this.trigger($.extend(d,{phase:"after",direction:b})),this.refresh())}},copy:function(a,b){if($.isPlainObject(a))return this.trigger($.extend(a,{phase:"after"})),a.text;var c=this.getSelection();if(0===c.length)return"";var d="";if("object"==typeof c[0]){for(var e=c[0].column,f=c[0].column,g=[],h=0;hf&&(f=c[h].column),g.indexOf(c[h].index)==-1&&g.push(c[h].index);g.sort(function(a,b){return a-b});for(var i=0;i div.w2ui-grid-box").css("width",$(this.box).width()).css("height",$(this.box).height());var c=this.trigger({phase:"before",type:"resize",target:this.name});if(c.isCancelled!==!0)return a.resizeBoxes(),a.resizeRecords(),a.toolbar&&a.toolbar.resize&&a.toolbar.resize(),this.trigger($.extend(c,{phase:"after"})),(new Date).getTime()-b}},update:function(a){var b=(new Date).getTime();if(null==this.box)return 0;if(null==a){for(var c=this.last.range_start-1;c<=this.last.range_end-1;c++)if(!(c<0)){var d=this.records[c]||{};d.w2ui||(d.w2ui={});for(var e=0;e0){null==b&&(b=this.get(a,!0));var e=c.attr("line"),f=!this.records[b]||this.records[b].recid!=a,g="object"!=typeof this.url?this.url:this.url.get;if(this.searchData.length>0&&!g)for(var h=0;h0&&(this.last.field=this.searches[0].field,this.last.label=this.searches[0].label);for(var h=0;h0&&k.indexes.length==this.records.length,m=k.indexes.length>0&&0!==this.searchData.length&&k.indexes.length==this.last.searchIds.length;l||m?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status();for(var n=a.find({"w2ui.expanded":!0},!0),o=0;o0&&b.forEach(function(b){$(a.box).find('td[col="'+b.col+'"]').not(".w2ui-head").w2marker(b.search)})},50),this.show.toolbarSave&&(this.getChanges().length>0?this.toolbar.enable("w2ui-save"):this.toolbar.disable("w2ui-save")),this.trigger($.extend(d,{phase:"after"})),a.resize(),a.addRange("selection"),setTimeout(function(){a.resize(),a.scroll()},1),a.reorderColumns&&!a.last.columnDrag?a.last.columnDrag=a.initColumnDrag():!a.reorderColumns&&a.last.columnDrag&&a.last.columnDrag.remove(), +e>i.width-g&&(e=i.width-g),f>i.height-g&&(f=i.height-g),b.hasClass("move-x")&&b.css({left:e+"px"}),b.hasClass("move-y")&&b.css({top:f+"px"});var h=b.parent().attr("name"),j=parseInt(b.css("left"))+g,k=parseInt(b.css("top"))+g;if("palette"===h&&l({s:Math.round(j/i.width*100),v:Math.round(100-k/i.height*100)}),"rainbow"===h){var m=Math.round(2.4*j);l({h:m}),n()}"alpha"===h&&l({a:parseFloat(Number(j/150).toFixed(2))})};a.fn._colorAdvanced!==!0&&b.advanced!==!0||(a("#w2ui-overlay .w2ui-color-tabs :nth-child(2)").click(),a("#w2ui-overlay").removeData("keepOpen")),l({},!0),n(),m();var r="mousedown.w2color",s="mouseup.w2color",t="mousemove.w2color";w2utils.isIOS&&(r="touchstart.w2color",s="touchend.w2color",t="touchmove.w2color "),a("#w2ui-overlay .palette").off(".w2color").on("mousedown.w2color",o),a("#w2ui-overlay .rainbow").off(".w2color").on("mousedown.w2color",o),a("#w2ui-overlay .alpha").off(".w2color").on("mousedown.w2color",o),f.nav=function(b){switch(b){case"up":g[0]--;break;case"down":g[0]++;break;case"right":g[1]++;break;case"left":g[1]--}return g[0]<0&&(g[0]=0),g[0]>h.length-2&&(g[0]=h.length-2),g[1]<0&&(g[1]=0),g[1]>h[0].length-1&&(g[1]=h[0].length-1),color=h[g[0]][g[1]],a(f).data("_color",color),color}}}(jQuery),function($){var w2grid=function(a){this.name=null,this.box=null,this.columns=[],this.columnGroups=[],this.records=[],this.summary=[],this.searches=[],this.sortMap={},this.toolbar={},this.total=0,this.recid=null,this.last={field:"",label:"",logic:"OR",search:"",searchIds:[],selection:{indexes:[],columns:{}},multi:!1,scrollTop:0,scrollLeft:0,colStart:0,colEnd:0,sortData:null,sortCount:0,xhr:null,range_start:null,range_end:null,sel_ind:null,sel_col:null,sel_type:null,edit_col:null,isSafari:/^((?!chrome|android).)*safari/i.test(navigator.userAgent)},$.extend(!0,this,w2obj.grid),this.show=$.extend(!0,{},w2grid.prototype.show),this.postData=$.extend(!0,{},w2grid.prototype.postData),this.httpHeaders=$.extend(!0,{},w2grid.prototype.httpHeaders),this.buttons=$.extend(!0,{},w2grid.prototype.buttons),this.operators=$.extend(!0,{},w2grid.prototype.operators),this.operatorsMap=$.extend(!0,{},w2grid.prototype.operatorsMap),this.stateColProps=$.extend(!0,{},w2grid.prototype.stateColProps),this.stateColDefaults=$.extend(!0,{},w2grid.prototype.stateColDefaults),$.extend(!0,this,a)};$.fn.w2grid=function(a){if($.isPlainObject(a)){if(!w2utils.checkName(a,"w2grid"))return;var b=a.columns,c=a.columnGroups,d=a.records,e=a.searches,f=a.searchData,g=a.sortData,h=new w2grid(a);$.extend(h,{records:[],columns:[],searches:[],sortData:[],searchData:[],handlers:[]});var i;if(b)for(i=0;i0?(p[a]&&p[a].apply(p,Array.prototype.slice.call(arguments,1)),this):p:null},w2grid.prototype={header:"",url:"",limit:100,offset:0,searchData:[],sortData:[],routeData:{},postData:{},httpHeaders:{},show:{header:!1,toolbar:!1,footer:!1,columnHeaders:!0,lineNumbers:!1,expandColumn:!1,selectColumn:!1,emptyRecords:!0,toolbarReload:!0,toolbarColumns:!0,toolbarSearch:!0,toolbarInput:!0,toolbarAdd:!1,toolbarEdit:!1,toolbarDelete:!1,toolbarSave:!1,searchAll:!0,statusRange:!0,statusBuffered:!1,statusRecordID:!0,statusSelection:!0,statusResponse:!0,statusSort:!1,statusSearch:!1,recordTitles:!0,selectionBorder:!0,skipRecords:!0,saveRestoreState:!0},stateId:null,hasFocus:!1,autoLoad:!0,fixedBody:!0,recordHeight:24,lineNumberWidth:null,keyboard:!0,selectType:"row",multiSearch:!0,multiSelect:!0,multiSort:!0,reorderColumns:!1,reorderRows:!1,showExtraOnSearch:0,markSearch:!0,columnTooltip:"normal",disableCVS:!1,textSearch:"begins",nestedFields:!0,vs_start:150,vs_extra:15,style:"",ranges:[],menu:[],method:null,dataType:null,parser:null,stateColProps:{text:!1,field:!0,size:!0,min:!1,max:!1,gridMinWidth:!1,sizeCorrected:!1,sizeCalculated:!0,sizeOriginal:!0,sizeType:!0,hidden:!0,sortable:!1,searchable:!1,resizable:!1,hideable:!1,attr:!1,style:!1,render:!1,title:!1,editable:!1,frozen:!0,info:!1},stateColDefaults:{text:"",field:"",size:null,min:20,max:null,gridMinWidth:null,sizeCorrected:null,sizeCalculated:null,sizeOriginal:null,sizeType:null,hidden:!1,sortable:!1,searchable:!1,resizable:!0,hideable:!0,attr:"",style:"",render:null,title:null,editable:{},frozen:!1,info:null},msgDelete:"Are you sure you want to delete NN records?",msgNotJSON:"Returned data is not in valid JSON format.",msgAJAXerror:"AJAX error. See console for more details.",msgRefresh:"Refreshing...",msgNeedReload:"Your remote data source record count has changed, reloading from the first record.",msgEmpty:"",buttons:{reload:{type:"button",id:"w2ui-reload",icon:"w2ui-icon-reload",tooltip:"Reload data in the list"},columns:{type:"drop",id:"w2ui-column-on-off",icon:"w2ui-icon-columns",tooltip:"Show/hide columns",arrow:!1,html:""},search:{type:"html",id:"w2ui-search",html:"
"},"search-go":{type:"drop",id:"w2ui-search-advanced",icon:"w2ui-icon-search",text:"Search",tooltip:"Open Search Fields"},add:{type:"button",id:"w2ui-add",text:"Add New",tooltip:"Add new record",icon:"w2ui-icon-plus"},edit:{type:"button",id:"w2ui-edit",text:"Edit",tooltip:"Edit selected record",icon:"w2ui-icon-pencil",disabled:!0},delete:{type:"button",id:"w2ui-delete",text:"Delete",tooltip:"Delete selected records",icon:"w2ui-icon-cross",disabled:!0},save:{type:"button",id:"w2ui-save",text:"Save",tooltip:"Save changed records",icon:"w2ui-icon-check"}},operators:{text:["is","begins","contains","ends"],number:["is","between",{oper:"less",text:"less than"},{oper:"more",text:"more than"}],date:["is","between",{oper:"less",text:"before"},{oper:"more",text:"after"}],list:["is"],hex:["is","between"],color:["is","begins","contains","ends"],enum:["in","not in"]},operatorsMap:{text:"text",int:"number",float:"number",money:"number",currency:"number",percent:"number",hex:"hex",alphanumeric:"text",color:"color",date:"date",time:"date",datetime:"date",list:"list",combo:"text",enum:"enum",file:"enum",select:"list",radio:"list",checkbox:"list",toggle:"list"},onAdd:null,onEdit:null,onRequest:null,onLoad:null,onDelete:null,onSave:null,onSelect:null,onUnselect:null,onClick:null,onDblClick:null,onContextMenu:null,onMenuClick:null,onColumnClick:null,onColumnDblClick:null,onColumnResize:null,onColumnAutoResize:null,onSort:null,onSearch:null,onSearchOpen:null,onChange:null,onRestore:null,onExpand:null,onCollapse:null,onError:null,onKeydown:null,onToolbar:null,onColumnOnOff:null,onCopy:null,onPaste:null,onSelectionExtend:null,onEditField:null,onRender:null,onRefresh:null,onReload:null,onResize:null,onDestroy:null,onStateSave:null,onStateRestore:null,onFocus:null,onBlur:null,onReorderRow:null,add:function(a,b){$.isArray(a)||(a=[a]);for(var c=0,d=0;d=0&&d=0&&d0&&(a=Array.isArray(b)&&b.length>0?this.records[b[0]].recid:null),a},remove:function(){for(var a=0,b=0;b=0;c--)this.records[c].recid==arguments[b]&&(this.records.splice(c,1),a++);for(var c=this.summary.length-1;c>=0;c--)this.summary[c].recid==arguments[b]&&(this.summary.splice(c,1),a++)}var d="object"!=typeof this.url?this.url:this.url.get;return d||(this.localSort(!1,!0),this.localSearch()),this.refresh(),a},addColumn:function(a,b){var c=0;1==arguments.length?(b=a,a=this.columns.length):("string"==typeof a&&(a=this.getColumn(a,!0)),null==a&&(a=this.columns.length)),$.isArray(b)||(b=[b]);for(var d=0;d=0;c--)this.columns[c].field==arguments[b]&&(this.columns[c].searchable&&this.removeSearch(arguments[b]),this.columns.splice(c,1),a++);return this.refresh(),a},getColumn:function(a,b){if(0===arguments.length){for(var c=[],d=0;d=0;c--)this.searches[c].field==arguments[b]&&(this.searches.splice(c,1),a++);return this.searchClose(),a},getSearch:function(a,b){if(0===arguments.length){for(var c=[],d=0;d=0;c--)this.searches[c].field==arguments[b]&&(this.searches[c].hidden=!this.searches[c].hidden,a++);return this.searchClose(),a},showSearch:function(){for(var a=0,b=0;b=0;c--)this.searches[c].field==arguments[b]&&this.searches[c].hidden!==!1&&(this.searches[c].hidden=!1,a++);return this.searchClose(),a},hideSearch:function(){for(var a=0,b=0;b=0;c--)this.searches[c].field==arguments[b]&&this.searches[c].hidden!==!0&&(this.searches[c].hidden=!0,a++);return this.searchClose(),a},getSearchData:function(a){for(var b=0;bd.length?1:c.lengthtypeof b?f:-f;if(a.constructor.name!=b.constructor.name)return a.constructor.name>b.constructor.name?f:-f;a&&"object"==typeof a&&(a=a.valueOf()),b&&"object"==typeof b&&(b=b.valueOf());var g={}.toString;switch(a&&"object"==typeof a&&a.toString!=g&&(a=String(a)),b&&"object"==typeof b&&b.toString!=g&&(b=String(b)),"string"==typeof a&&(a=$.trim(a.toLowerCase())),"string"==typeof b&&(b=$.trim(b.toLowerCase())),e){case"natural":e=w2utils.naturalCompare}return"function"==typeof e?e(a,b)*f:a>b?f:a=parseFloat(k)&&parseFloat(f.parseField(a,h.field))<=parseFloat(l)&&c++;else if("date"==h.type){var m=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),j=w2utils.isDate(m,w2utils.settings.dateFormat,!0),k=w2utils.isDate(k,w2utils.settings.dateFormat,!0),l=w2utils.isDate(l,w2utils.settings.dateFormat,!0);null!=l&&(l=new Date(l.getTime()+864e5)),j>=k&&j=k&&j=k&&j=parseFloat(e.value)&&c++;else if("date"==h.type){var m=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),j=w2utils.isDate(m,w2utils.settings.dateFormat,!0),k=w2utils.isDate(k,w2utils.settings.dateFormat,!0);j>=k&&c++}else if("time"==h.type){var m=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),j=w2utils.formatTime(m,"hh24:mi"),k=w2utils.formatTime(k,"hh24:mi");j>=k&&c++}else if("datetime"==h.type){var m=f.parseField(a,h.field+"_")instanceof Date?f.parseField(a,h.field+"_"):f.parseField(a,h.field),j=w2utils.formatDateTime(m,"yyyy-mm-dd|hh24:mm:ss"),k=w2utils.formatDateTime(w2utils.isDateTime(k,w2utils.settings.datetimeFormat,!0),"yyyy-mm-dd|hh24:mm:ss");j.length==k.length&&j>=k&&c++}break;case"in":var m=e.value;e.svalue&&(m=e.svalue),m.indexOf(w2utils.isFloat(i)?parseFloat(i):i)===-1&&m.indexOf(j)===-1||c++;break;case"not in":var m=e.value;e.svalue&&(m=e.svalue),m.indexOf(w2utils.isFloat(i)?parseFloat(i):i)===-1&&m.indexOf(j)===-1&&c++;break;case"begins":case"begins with":0===j.indexOf(k)&&c++;break;case"contains":j.indexOf(k)>=0&&c++;break;case"null":null==f.parseField(a,h.field)&&c++;break;case"not null":null!=f.parseField(a,h.field)&&c++;break;case"ends":case"ends with":var n=j.lastIndexOf(k);n!==-1&&n==j.length-k.length&&c++}}}if("OR"==f.last.logic&&0!==c||"AND"==f.last.logic&&c==f.searchData.length)return!0;if(a.w2ui&&a.w2ui.children&&a.w2ui.expanded!==!0)for(var o=0;o0&&!d){this.total=0;for(var i=0;i0){var l=this.showExtraOnSearch,m=this.showExtraOnSearch;if(ithis.records.length&&(m=this.records.length-i),l>0)for(var n=i-l;n0)for(var n=i+1;n<=i+m;n++)this.last.searchIds.indexOf(n)<0&&this.last.searchIds.push(n)}else this.last.searchIds.push(i)}this.total=this.last.searchIds.length}return e=(new Date).getTime()-e,a!==!0&&f.show.statusSearch&&setTimeout(function(){f.status(w2utils.lang("Search took")+" "+e/1e3+" "+w2utils.lang("sec"))},10),e},getRangeData:function(a,b){var c=this.get(a[0].recid,!0),d=this.get(a[1].recid,!0),e=a[0].column,f=a[1].column,g=[];if(e==f)for(var h=c;h<=d;h++){var i=this.records[h],j=i[this.columns[e].field]||null;b!==!0?g.push(j):g.push({data:j,column:e,index:h,record:i})}else if(c==d)for(var i=this.records[c],k=e;k<=f;k++){var j=i[this.columns[k].field]||null;b!==!0?g.push(j):g.push({data:j,column:k,index:c,record:i})}else for(var h=c;h<=d;h++){var i=this.records[h];g.push([]);for(var k=e;k<=f;k++){var j=i[this.columns[k].field];b!==!0?g[g.length-1].push(j):g[g.length-1].push({data:j,column:k,index:h,record:i})}}return g},addRange:function(a){var b=0;if("row"==this.selectType)return b;$.isArray(a)||(a=[a]);for(var c=0;c=0;d--)this.ranges[d].name==c&&(this.ranges.splice(d,1),a++)}return a},refreshRanges:function(){function a(a){var e=d.getSelection();d.last.move={type:"expand",x:a.screenX,y:a.screenY,divX:0,divY:0,recid:e[0].recid,column:e[0].column,originalRange:[{recid:e[0].recid,column:e[0].column},{recid:e[e.length-1].recid,column:e[e.length-1].column}],newRange:[{recid:e[0].recid,column:e[0].column},{recid:e[e.length-1].recid,column:e[e.length-1].column}]},$(document).off(".w2ui-"+d.name).on("mousemove.w2ui-"+d.name,b).on("mouseup.w2ui-"+d.name,c),a.preventDefault()}function b(a){var b=d.last.move;if(b&&"expand"==b.type){b.divX=a.screenX-b.x,b.divY=a.screenY-b.y;var c,e,f=a.originalEvent.target;if("TD"!=f.tagName.toUpperCase()&&(f=$(f).parents("td")[0]),null!=$(f).attr("col")&&(e=parseInt($(f).attr("col"))),f=$(f).parents("tr")[0],c=$(f).attr("recid"),b.newRange[1].recid!=c||b.newRange[1].column!=e){var g=$.extend({},b.newRange);return b.newRange=[{recid:b.recid,column:b.column},{recid:c,column:e}],B=d.trigger($.extend(B,{originalRange:b.originalRange,newRange:b.newRange})),B.isCancelled===!0?(b.newRange=g,void(B.newRange=g)):(d.removeRange("grid-selection-expand"),void d.addRange({name:"grid-selection-expand",range:B.newRange,style:"background-color: rgba(100,100,100,0.1); border: 2px dotted rgba(100,100,100,0.5);"}))}}}function c(a){d.removeRange("grid-selection-expand"),delete d.last.move,$(document).off(".w2ui-"+d.name),d.trigger($.extend(B,{phase:"after"}))}if(0!==this.ranges.length){for(var d=this,e=(new Date).getTime(),f=$("#grid_"+this.name+"_frecords"),g=$("#grid_"+this.name+"_records"),h=0;hthis.last.colStart&&(l=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(j.recid)+' td[col="start"]')),j.columnthis.last.colEnd&&(p='"end"',m=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(k.recid)+' td[col="end"]'));var q=parseInt($("#grid_"+this.name+"_rec_top").next().attr("index")),r=parseInt($("#grid_"+this.name+"_rec_bottom").prev().attr("index")),s=parseInt($("#grid_"+this.name+"_frec_top").next().attr("index")),t=parseInt($("#grid_"+this.name+"_frec_bottom").prev().attr("index"));0===l.length&&j.indexq&&(l=$("#grid_"+this.name+"_rec_top").next().find("td[col="+j.column+"]")),0===m.length&&k.index>r&&j.indexs&&(n=$("#grid_"+this.name+"_frec_top").next().find("td[col="+j.column+"]")),0===o.length&&k.index>t&&j.index0||o.length>0)if(0===y.length?(f.append('
'+("selection"==i.name?'
':"")+"
"),y=$("#grid_"+this.name+"_f"+i.name)):(y.attr("style",i.style),y.find(".w2ui-selection-resizer").show()),0===o.length&&(o=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(k.recid)+" td:last-child"),0===o.length&&(o=$("#grid_"+this.name+"_frec_bottom td:first-child")),y.css("border-right","0px"),y.find(".w2ui-selection-resizer").hide()),null!=j.recid&&null!=k.recid&&n.length>0&&o.length>0){var z=n.position().left-1+f.scrollLeft(),A=n.position().top-1+f.scrollTop();y.show().css({left:(z>0?z:0)+"px",top:(A>0?A:0)+"px",width:o.position().left-n.position().left+o.width()+3+"px",height:o.position().top-n.position().top+o.height()+3+"px"})}else y.hide();else y.hide();var y=$("#grid_"+this.name+"_"+i.name);if(l.length>0||m.length>0)if(0===y.length?(g.append('
'+("selection"==i.name?'
':"")+"
"),y=$("#grid_"+this.name+"_"+i.name)):y.attr("style",i.style),0===l.length&&(l=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(j.recid)+" td:first-child"),0===l.length&&(l=$("#grid_"+this.name+"_rec_top td:first-child"))),0!==o.length&&y.css("border-left","0px"),null!=j.recid&&null!=k.recid&&l.length>0&&m.length>0){var z=l.position().left-1+g.scrollLeft(),A=l.position().top-1+g.scrollTop();y.show().css({left:(z>0?z:0)+"px",top:(A>0?A:0)+"px",width:m.position().left-l.position().left+m.width()+3+"px",height:m.position().top-l.position().top+m.height()+3+"px"})}else y.hide();else y.hide()}}$(this.box).find(".w2ui-selection-resizer").off("mousedown").on("mousedown",a).off("dblclick").on("dblclick",function(a){var b=d.trigger({phase:"before",type:"resizerDblClick",target:d.name,originalEvent:a});b.isCancelled!==!0&&d.trigger($.extend(b,{phase:"after"}))});var B={phase:"before",type:"selectionExtend",target:d.name,originalRange:null,newRange:null};return(new Date).getTime()-e}},select:function(){if(0===arguments.length)return 0;var a=((new Date).getTime(),0),b=this.last.selection;this.multiSelect||this.selectNone();var c={phase:"before",type:"select",target:this.name};1==arguments.length?(c.multiple=!1,$.isPlainObject(arguments[0])?(c.recid=arguments[0].recid,c.column=arguments[0].column):c.recid=arguments[0]):(c.multiple=!0,c.recids=Array.prototype.slice.call(arguments,0));var d=this.trigger(c);if(d.isCancelled===!0)return 0;if("row"==this.selectType)for(var e=0;e=this.last.range_start&&g+1<=this.last.range_end)&&(h=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(f)),i=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(f))),"row"==this.selectType){if(b.indexes.indexOf(g)!=-1)continue;b.indexes.push(g),h&&i&&(h.addClass("w2ui-selected").data("selected","yes").find(".w2ui-col-number").addClass("w2ui-row-selected"),i.addClass("w2ui-selected").data("selected","yes").find(".w2ui-col-number").addClass("w2ui-row-selected"),h.find(".w2ui-grid-select-check").prop("checked",!0)),a++}}}else{for(var j={},e=0;e=this.last.range_start&&g+1<=this.last.range_end&&(h=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(f)),i=$("#grid_"+this.name+"_frec_"+w2utils.escapeId(f)));var n=b.columns[g]||[];b.indexes.indexOf(g)==-1&&b.indexes.push(g);for(var o=0;o0&&b.indexes.length==this.records.length,s=b.indexes.length>0&&0!==this.searchData.length&&b.indexes.length==this.last.searchIds.length;return r||s?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.addRange("selection"),this.trigger($.extend(d,{phase:"after"})),a},unselect:function(){for(var a=0,b=this.last.selection,c=0;c td[col="+j+"]").removeClass("w2ui-selected w2ui-inactive"),$("#grid_"+this.name+"_frec_"+w2utils.escapeId(d)).find(" > td[col="+j+"]").removeClass("w2ui-selected w2ui-inactive");for(var n=!1,o=!1,p=this.getSelection(),l=0;l0&&b.indexes.length==this.records.length,r=b.indexes.length>0&&0!==this.searchData.length&&b.indexes.length==this.last.searchIds.length;return q||r?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.addRange("selection"),a},selectAll:function(){var a=(new Date).getTime();if(this.multiSelect!==!1){var b=this.trigger({phase:"before",type:"select",target:this.name,all:!0});if(b.isCancelled!==!0){for(var c="object"!=typeof this.url?this.url:this.url.get,d=this.last.selection,e=[],f=0;f=1?this.toolbar.enable("w2ui-delete"):this.toolbar.disable("w2ui-delete"),this.addRange("selection"),$("#grid_"+this.name+"_check_all").prop("checked",!0),this.status(),this.trigger($.extend(b,{phase:"after"})),(new Date).getTime()-a}}},selectNone:function(){var a=(new Date).getTime(),b=this.trigger({phase:"before",type:"unselect",target:this.name,all:!0});if(b.isCancelled!==!0){var c=this.last.selection;return"row"==this.selectType?($(this.box).find(".w2ui-grid-records tr.w2ui-selected").removeClass("w2ui-selected w2ui-inactive").removeData("selected").find(".w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-frecords tr.w2ui-selected").removeClass("w2ui-selected w2ui-inactive").removeData("selected").find(".w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find("input.w2ui-grid-select-check").prop("checked",!1)):($(this.box).find(".w2ui-grid-columns td .w2ui-col-header, .w2ui-grid-fcolumns td .w2ui-col-header").removeClass("w2ui-col-selected"),$(this.box).find(".w2ui-grid-records tr .w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-frecords tr .w2ui-col-number").removeClass("w2ui-row-selected"),$(this.box).find(".w2ui-grid-data.w2ui-selected").removeClass("w2ui-selected w2ui-inactive").removeData("selected"),$(this.box).find("input.w2ui-grid-select-check").prop("checked",!1)),c.indexes=[],c.columns={},this.toolbar.disable("w2ui-edit","w2ui-delete"),this.removeRange("selection"),$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status(),this.trigger($.extend(b,{phase:"after"})),(new Date).getTime()-a}},getSelection:function(a){var b=[],c=this.last.selection;if("row"==this.selectType){for(var d=0;d0)for(var j=0;j0){var v={field:k.field,type:k.type,operator:null!=k.operator?k.operator:"in",value:x};d.push(v)}}}else for(var j=0;j0&&e[0].focus(),b.checked||(b.checked=!0,$(c).addClass("checked")),a.trigger($.extend(d,{phase:"after"}))},onHide:function(){b.checked=!1,$(c).removeClass("checked")}})}},searchClose:function(){this.box&&0!==this.searches.length&&(this.toolbar&&this.toolbar.uncheck("w2ui-search-advanced"),$().w2overlay({name:this.name+"-searchOverlay"}))},searchReset:function(a){for(var b=[],c=!1,d=0;d0)if(this.multiSearch&&this.show.searchAll)this.last.field="all",this.last.label=w2utils.lang("All Fields");else{for(var f=0;f=this.searches.length?(this.last.field="",this.last.label=""):(this.last.field=this.searches[f].field,this.last.label=this.searches[f].label)}this.last.multi=!1,this.last.xhr_offset=0,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selection.indexes=[],this.last.selection.columns={},this.searchClose(),$("#grid_"+this.name+"_search_all").val("").removeData("selected"),a||this.reload(),this.trigger($.extend(e,{phase:"after"}))}},searchShowFields:function(){for(var a=this,b=$("#grid_"+this.name+"_search_all"),c='
',d=-1;d",e),e.label=e.caption),c+=""}c+="
'+e.label+"
",setTimeout(function(){$(b).w2overlay({html:c,name:a.name+"-searchFields",left:-10})},1)},initAllField:function(a,b){var c=$("#grid_"+this.name+"_search_all");if("all"==a){var d={field:"all",label:w2utils.lang("All Fields")};c.w2field("clear"),c.change()}else{var d=this.getSearch(a);if(null==d)return;var e=d.type;["enum","select"].indexOf(e)!=-1&&(e="list"),c.w2field(e,$.extend({},d.options,{suffix:"",autoFormat:!1,selected:b})),["list","enum","date","time","datetime"].indexOf(d.type)!=-1&&(this.last.search="",this.last.item="",c.val(""))}""!=this.last.search?(this.last.label=d.label,this.search(d.field,this.last.search)):(this.last.field=d.field,this.last.label=d.label),c.attr("placeholder",w2utils.lang(d.label||d.caption||d.field)),$().w2overlay({name:this.name+"-searchFields"})},clear:function(a){this.total=0,this.records=[],this.summary=[],this.last.xhr_offset=0,this.last.idCache={},this.reset(!0),a||this.refresh()},reset:function(a){this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selection={indexes:[],columns:{}},this.last.range_start=null,this.last.range_end=null,$("#grid_"+this.name+"_records").prop("scrollTop",0),a||this.refresh()},skip:function(a,b){var c="object"!=typeof this.url?this.url:this.url.get;c?(this.offset=parseInt(a),this.offset>this.total&&(this.offset=this.total-this.limit),(this.offset<0||!w2utils.isInt(this.offset))&&(this.offset=0),this.clear(!0),this.reload(b)):console.log("ERROR: grid.skip() can only be called when you have remote data source.")},load:function(a,b){return null==a?void console.log('ERROR: You need to provide url argument when calling .load() method of "'+this.name+'" object.'):(this.clear(!0),void this.request("get",{},a,b))},reload:function(a){var b=this,c="object"!=typeof this.url?this.url:this.url.get;b.selectionSave(),c?this.load(c,function(){b.selectionRestore(),"function"==typeof a&&a()}):(this.reset(!0),this.localSearch(),this.selectionRestore(),"function"==typeof a&&a({status:"success"}))},request:function(a,b,c,d){if(null==b&&(b={}),""!=c&&null!=c||(c=this.url),""!=c&&null!=c){w2utils.isInt(this.offset)||(this.offset=0),w2utils.isInt(this.last.xhr_offset)||(this.last.xhr_offset=0);var e={limit:this.limit,offset:parseInt(this.offset)+parseInt(this.last.xhr_offset),searchLogic:this.last.logic,search:this.searchData.map(function(a){var b=$.extend({},a);return this.searchMap&&this.searchMap[b.field]&&(b.field=this.searchMap[b.field]),b}.bind(this)),sort:this.sortData.map(function(a){var b=$.extend({},a);return this.sortMap&&this.sortMap[b.field]&&(b.field=this.sortMap[b.field]),b}.bind(this))};if(0===this.searchData.length&&(delete e.search,delete e.searchLogic),0===this.sortData.length&&delete e.sort,$.extend(e,this.postData),$.extend(e,b),"get"==a){var f=this.trigger({phase:"before",type:"request",target:this.name,url:c,postData:e,httpHeaders:this.httpHeaders});if(f.isCancelled===!0)return void("function"==typeof d&&d({status:"error",message:"Request aborted."}))}else var f={url:c,postData:e,httpHeaders:this.httpHeaders};var g=this;if(0===this.last.xhr_offset)g.lock(w2utils.lang(g.msgRefresh),!0);else{var h=$("#grid_"+this.name+"_rec_more, #grid_"+this.name+"_frec_more");this.autoLoad===!0?h.show().find("td").html('
'):h.find("td").html("
"+w2utils.lang("Load")+" "+g.limit+" "+w2utils.lang("More")+"...
")}if(this.last.xhr)try{this.last.xhr.abort()}catch(a){}if(c="object"!=typeof f.url?f.url:f.url.get,"save"==e.cmd&&"object"==typeof f.url&&(c=f.url.save),"delete"==e.cmd&&"object"==typeof f.url&&(c=f.url.remove),!$.isEmptyObject(g.routeData)){var i=w2utils.parseRoute(c);if(i.keys.length>0)for(var j=0;jc.width()&&c.width(e+20)}catch(a){}}var f=this;if(this.last.inEditMode!==!0){var g=f.get(a,!0),h=f.getCellEditable(g,b);if(h){var i=f.records[g],j=f.columns[b],k=j.frozen===!0?"_f":"_";if(["enum","file"].indexOf(h.type)!=-1)return void console.log('ERROR: input types "enum" and "file" are not supported in inline editing.');var l=f.trigger({phase:"before",type:"editField",target:f.name,recid:a,column:b,value:c,index:g,originalEvent:d});if(l.isCancelled!==!0&&(c=l.value,this.last.inEditMode=!0,this.last._edit={value:c,index:g,column:b,recid:a},this.selectNone(),this.select({recid:a,column:b}),["checkbox","check"].indexOf(h.type)==-1)){var m=$("#grid_"+f.name+k+"rec_"+w2utils.escapeId(a)),n=m.find("[col="+b+"] > div");$(this.box).find("div.w2ui-edit-box").remove(),"row"!=this.selectType&&($("#grid_"+this.name+k+"selection").attr("id","grid_"+this.name+"_editable").removeClass("w2ui-selection").addClass("w2ui-edit-box").prepend('
').find(".w2ui-selection-resizer").remove(),n=$("#grid_"+this.name+"_editable >div:first-child")),null==h.inTag&&(h.inTag=""),null==h.outTag&&(h.outTag=""),null==h.style&&(h.style=""),null==h.items&&(h.items=[]);var o=i.w2ui&&i.w2ui.changes&&null!=i.w2ui.changes[j.field]?w2utils.stripTags(i.w2ui.changes[j.field]):w2utils.stripTags(i[j.field]);null==o&&(o="");var p="object"!=typeof o?o:"";null!=l.old_value&&(p=l.old_value),null!=c&&(o=c);var q=null!=j.style?j.style+";":"";switch("string"==typeof j.render&&["number","int","float","money","percent","size"].indexOf(j.render.split(":")[0])!=-1&&(q+="text-align: right;"),h.items.length>0&&!$.isPlainObject(h.items[0])&&(h.items=w2obj.field.prototype.normMenu(h.items)),h.type){case"select":for(var r="",s=0;s"+h.items[s].text+"";n.addClass("w2ui-editable").html('"+h.outTag),setTimeout(function(){n.find("select").on("change",function(a){delete f.last.move}).on("blur",function(a){1!=$(this).data("keep-open")&&f.editChange.call(f,this,g,b,a)})},10);break;case"div":var t=m.find("[col="+b+"] > div"),u="font-family: "+t.css("font-family")+"; font-size: "+t.css("font-size")+";";n.addClass("w2ui-editable").html('
"+h.outTag),null==c&&n.find("div.w2ui-input").text("object"!=typeof o?o:"");var v=n.find("div.w2ui-input").get(0);setTimeout(function(){var a=v;$(a).on("blur",function(c){1!=$(this).data("keep-open")&&f.editChange.call(f,a,g,b,c)})},10),null!=c&&$(v).text("object"!=typeof o?o:"");break;default:var t=m.find("[col="+b+"] > div"),u="font-family: "+t.css("font-family")+"; font-size: "+t.css("font-size");n.addClass("w2ui-editable").html('"+h.outTag),"number"==h.type&&(o=w2utils.formatNumber(o)),"date"==h.type&&(o=w2utils.formatDate(w2utils.isDate(o,h.format,!0)||new Date,h.format)),null==c&&n.find("input").val("object"!=typeof o?o:"");var v=n.find("input").get(0);$(v).w2field(h.type,$.extend(h,{selected:o})),setTimeout(function(){var a=v;"list"==h.type&&(a=$($(v).data("w2field").helpers.focus).find("input"),"object"!=typeof o&&""!=o&&a.val(o).css({opacity:1}).prev().css({opacity:1}),n.find("input").on("change",function(a){f.editChange.call(f,v,g,b,a)})),$(a).on("blur",function(a){1!=$(this).data("keep-open")&&f.editChange.call(f,v,g,b,a)})},10),null!=c&&$(v).val("object"!=typeof o?o:"")}setTimeout(function(){f.last.inEditMode&&(n.find("input, select, div.w2ui-input").data("old_value",p).on("mousedown",function(a){a.stopPropagation()}).on("click",function(a){"div"==h.type?e.call(n.find("div.w2ui-input")[0],null):e.call(n.find("input, select")[0],null)}).on("paste",function(a){var b=a.originalEvent;a.preventDefault();var c=b.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,c)}).on("keydown",function(c){var d=this,k="DIV"==d.tagName.toUpperCase()?$(d).text():$(d).val();switch(c.keyCode){case 8:"list"!=h.type||$(v).data("w2field")||c.preventDefault();break;case 9:case 13:c.preventDefault();break;case 37:0===w2utils.getCursorPosition(d)&&c.preventDefault();break;case 39:w2utils.getCursorPosition(d)==k.length&&(w2utils.setCursorPosition(d,k.length),c.preventDefault())}setTimeout(function(){switch(c.keyCode){case 9:var h=a,k=c.shiftKey?f.prevCell(g,b,!0):f.nextCell(g,b,!0);if(null==k){var l=c.shiftKey?f.prevRow(g,b):f.nextRow(g,b);if(null!=l&&l!=g){h=f.records[l].recid;for(var m=0;m0&&(a.focus(),clearTimeout(f.last.kbd_timer),"SELECT"!=a[0].tagName.toUpperCase()&&w2utils.setCursorPosition(a[0],b),a[0].resize=e,e.call(a[0],null))}},50),f.trigger($.extend(l,{phase:"after",input:n.find("input, select, div.w2ui-input")})))},5)}}}else if(13==d.keyCode){var g=this.last._edit.index,b=this.last._edit.column,a=this.last._edit.recid;this.editChange({type:"custom",value:this.last._edit.value},this.get(a,!0),b,d);var w=d.shiftKey?this.prevRow(g,b):this.nextRow(g,b);null!=w&&w!=g&&setTimeout(function(){"row"!=f.selectType?(f.selectNone(),f.select({recid:f.records[w].recid,column:b})):f.editField(f.records[w].recid,b,null,d)},1),this.last.inEditMode=!1}else{var x=$(this.box).find("div.w2ui-edit-box .w2ui-input");x.length>0&&"DIV"==x[0].tagName&&(x.text(x.text()+c),w2utils.setCursorPosition(x[0],x.text().length))}},editChange:function(a,b,c,d){var e=this;setTimeout(function(){var a=$(e.box).find("#grid_"+e.name+"_focus"); +a.is(":focus")||a.focus()},10);var f=b<0;b=b<0?-b-1:b;var g=f?this.summary:this.records,h=g[b],i=this.columns[c],j=$("#grid_"+this.name+(i.frozen===!0?"_frec_":"_rec_")+w2utils.escapeId(h.recid)),k=a.tagName&&"DIV"==a.tagName.toUpperCase()?$(a).text():a.value,l=this.parseField(h,i.field),m=$(a).data("w2field");m&&("list"==m.type&&(k=$(a).data("selected")),($.isEmptyObject(k)||null==k)&&(k=""),$.isPlainObject(k)||(k=m.clean(k))),"checkbox"==a.type&&(h.w2ui&&h.w2ui.editable===!1&&(a.checked=!a.checked),k=a.checked);var n={phase:"before",type:"change",target:this.name,input_id:a.id,recid:h.recid,index:b,column:c,originalEvent:d.originalEvent?d.originalEvent:d,value_new:k,value_previous:h.w2ui&&h.w2ui.changes&&h.w2ui.changes.hasOwnProperty(i.field)?h.w2ui.changes[i.field]:l,value_original:l};for(null!=$(d.target).data("old_value")&&(n.value_previous=$(d.target).data("old_value"));;){if(k=n.value_new,"object"!=typeof k&&String(l)!=String(k)||"object"==typeof k&&k&&k.id!=l&&("object"!=typeof l||null==l||k.id!=l.id)){if(n=this.trigger($.extend(n,{type:"change",phase:"before"})),n.isCancelled!==!0){if(k!==n.value_new)continue;h.w2ui=h.w2ui||{},h.w2ui.changes=h.w2ui.changes||{},h.w2ui.changes[i.field]=n.value_new,this.trigger($.extend(n,{phase:"after"}))}}else if(n=this.trigger($.extend(n,{type:"restore",phase:"before"})),n.isCancelled!==!0){if(k!==n.value_new)continue;h.w2ui&&h.w2ui.changes&&delete h.w2ui.changes[i.field],h.w2ui&&$.isEmptyObject(h.w2ui.changes)&&delete h.w2ui.changes,this.trigger($.extend(n,{phase:"after"}))}break}var o=$(j).find("[col="+c+"]");f||(h.w2ui&&h.w2ui.changes&&null!=h.w2ui.changes[i.field]?o.addClass("w2ui-changed"):o.removeClass("w2ui-changed"),o.replaceWith(this.getCellHTML(b,c,f))),$(this.box).find("div.w2ui-edit-box").remove(),this.show.toolbarSave&&(this.getChanges().length>0?this.toolbar.enable("w2ui-save"):this.toolbar.disable("w2ui-save")),e.last.inEditMode=!1},delete:function(a){var b=((new Date).getTime(),this),c=this.trigger({phase:"before",target:this.name,type:"delete",force:a});if(a&&this.message(),c.isCancelled!==!0){a=c.force,setTimeout(function(){$().w2tag()},20);var d=this.getSelection();if(0!==d.length){if(""!=this.msgDelete&&!a)return void this.message({width:380,height:170,body:'
'+w2utils.lang(b.msgDelete).replace("NN",d.length).replace("records",1==d.length?"record":"records")+"
",buttons:w2utils.settings.macButtonOrder?'":'",onOpen:function(a){var c=$(this.box).find("input, textarea, select, button");c.off(".message").on("blur.message",function(a){c.index(a.target)+1===c.length&&(c.get(0).focus(),a.preventDefault())}).on("keydown.message",function(a){27==a.keyCode&&b.message()}),setTimeout(function(){$(this.box).find(".w2ui-btn.btn-default").focus(),clearTimeout(b.last.kbd_timer)}.bind(this),50)}});var e="object"!=typeof this.url?this.url:this.url.remove;if(e)this.request("delete");else if("object"!=typeof d[0])this.selectNone(),this.remove.apply(this,d);else{for(var f=0;f0&&e.multiSelect){if(i[0].recid){var l=this.get(i[0].recid,!0),m=this.get(a,!0);if(d>i[0].column)var n=i[0].column,o=d;else var n=d,o=i[0].column;for(var p=n;p<=o;p++)k.push(p)}else var l=this.get(f,!0),m=this.get(a,!0);var q=[];if(l>m){var g=l;l=m,m=g}for(var r="object"!=typeof this.url?this.url:this.url.get,s=l;s<=m;s++)if(!(this.searchData.length>0)||r||$.inArray(s,this.last.searchIds)!=-1)if("row"==this.selectType)q.push(this.records[s].recid);else for(var t=0;t300?this.selectNone():this.unselect.apply(this,i),v===!0&&1==i.length?this.unselect({recid:a,column:d}):this.select({recid:a,column:d})}this.status(),e.initResize(),this.trigger($.extend(h,{phase:"after"}))}}},columnClick:function(a,b){var c=this.trigger({phase:"before",type:"columnClick",target:this.name,field:a,originalEvent:b});if(c.isCancelled!==!0){if("row"==this.selectType){var d=this.getColumn(a);d&&d.sortable&&this.sort(a,null,!(!b||!b.ctrlKey&&!b.metaKey)),"line-number"==c.field&&(this.getSelection().length>=this.records.length?this.selectNone():this.selectAll())}else{if(b.altKey){var d=this.getColumn(a);d&&d.sortable&&this.sort(a,null,!(!b||!b.ctrlKey&&!b.metaKey))}if("line-number"==c.field)this.getSelection().length>=this.records.length?this.selectNone():this.selectAll();else{b.shiftKey||b.metaKey||b.ctrlKey||this.selectNone();var e=this.getSelection(),d=this.getColumn(c.field,!0),f=[],g=[];if(0!=e.length&&b.shiftKey){var h=d,i=e[0].column;h>i&&(h=e[0].column,i=d);for(var j=h;j<=i;j++)g.push(j)}else g.push(d);var c=this.trigger({phase:"before",type:"columnSelect",target:this.name,columns:g});if(c.isCancelled!==!0){for(var j=0;j1){for(var a=0;a1&&(i.splice(i.indexOf(d.records[d.last.sel_ind].recid),1),d.unselect.apply(d,i),!0)}var d=this,e="object"!=typeof this.url?this.url:this.url.get;if(d.keyboard===!0){var f=d.trigger({phase:"before",type:"keydown",target:d.name,originalEvent:a});if(f.isCancelled!==!0){if($(this.box).find(">.w2ui-message").length>0)return void(27==a.keyCode&&this.message());var g=!1,h=$("#grid_"+d.name+"_records"),i=d.getSelection();0===i.length&&(g=!0);var j=i[0]||null,k=[],l=i[i.length-1];if("object"==typeof j&&null!=j){j=i[0].recid,k=[];for(var m=0;;){if(!i[m]||i[m].recid!=j)break;k.push(i[m].column),m++}l=i[i.length-1].recid}var n=d.get(j,!0),o=d.get(l,!0),p=(d.get(j),$("#grid_"+d.name+"_rec_"+(null!=n?w2utils.escapeId(d.records[n].recid):"none"))),q=!1,r=a.keyCode,s=a.shiftKey;switch(r){case 8:case 46:var t=this.toolbar.get("w2ui-delete");t&&t.hidden!==!0&&d.delete(),q=!0,a.stopPropagation();break;case 27:d.selectNone(),q=!0;break;case 65:if(!a.metaKey&&!a.ctrlKey)break;d.selectAll(),q=!0;break;case 13:if("row"==this.selectType&&d.show.expandColumn===!0){if(p.length<=0)break;d.toggle(j,a),q=!0}else{for(var u=0;u0&&(d.editField(j,k[0],null,a),q=!0)}break;case 37:if(g){b();break}if("row"==this.selectType){if(p.length<=0)break;var w=this.records[n].w2ui||{};!w||null==w.parent_recid||Array.isArray(w.children)&&0!==w.children.length&&w.expanded?d.collapse(j,a):(d.unselect(j),d.collapse(w.parent_recid,a),d.select(w.parent_recid))}else{var x=d.prevCell(n,k[0]);if(s||null!=x||(this.selectNone(),x=0),null!=x)if(s&&d.multiSelect){if(c())return;var w=[],y=[],z=[];if(0===k.indexOf(this.last.sel_col)&&k.length>1){for(var A=0;A1)d.selectNone();else for(var B=1;B1){for(var A=0;A1)d.selectNone();else for(var B=0;Bx&&d.last.sel_ind!=o?d.unselect(d.records[o].recid):d.select(d.records[x].recid);else if(d.last.sel_ind>x&&d.last.sel_ind!=o){x=o;for(var w=[],u=0;u300?this.selectNone():this.unselect.apply(this,i),d.click({recid:d.records[x].recid,column:k[0]},a);d.scrollIntoView(x),a.preventDefault&&a.preventDefault()}else if(!s)if(i.length>1)d.selectNone();else for(var B=1;B300?this.selectNone():this.unselect.apply(this,i),d.click({recid:d.records[C].recid,column:k[0]},a);d.scrollIntoView(C),q=!0}else if(!s)if(i.length>1)d.selectNone();else for(var B=0;B0&&(a=this.last.searchIds.indexOf(a)),f.height()0?g:d)&&f.length>0){var h=Math.floor(f[0].scrollTop/this.recordHeight),i=h+Math.floor(f.height()/this.recordHeight);a==h&&(c===!0?f.prop({scrollTop:f.scrollTop()-f.height()/1.3}):(f.stop(),f.animate({scrollTop:f.scrollTop()-f.height()/1.3},250,"linear"))),a==i&&(c===!0?f.prop({scrollTop:f.scrollTop()+f.height()/1.3}):(f.stop(),f.animate({scrollTop:f.scrollTop()+f.height()/1.3},250,"linear"))),(ai)&&(c===!0?f.prop({scrollTop:(a-1)*this.recordHeight}):(f.stop(),f.animate({scrollTop:(a-1)*this.recordHeight},250,"linear")))}if(null!=b){for(var j=0,k=0,l=w2utils.scrollBarSize(),m=0;m<=b;m++){var n=this.columns[m];n.frozen||n.hidden||(j=k,k+=parseInt(n.sizeCalculated))}f.width()0&&$(d.box).find(c.target).w2menu(d.menu,{originalEvent:c,contextMenu:!0,onSelect:function(b){d.menuClick(a,parseInt(b.index),b.originalEvent)}}),c.preventDefault&&c.preventDefault(),d.trigger($.extend(i,{phase:"after"})))}},menuClick:function(a,b,c){var d=this,e=d.trigger({phase:"before",type:"menuClick",target:d.name,originalEvent:c,recid:a,menuIndex:b,menuItem:d.menu[b]});e.isCancelled!==!0&&d.trigger($.extend(e,{phase:"after"}))},toggle:function(a){var b=this.get(a);return b.w2ui=b.w2ui||{},b.w2ui.expanded===!0?this.collapse(a):this.expand(a)},expand:function(a){var b=this.get(a,!0),c=this.records[b];c.w2ui=c.w2ui||{};var d=w2utils.escapeId(a),e=c.w2ui.children;if(Array.isArray(e)){if(c.w2ui.expanded===!0||0===e.length)return!1;var f=this.trigger({phase:"before",type:"expand",target:this.name,recid:a});if(f.isCancelled===!0)return!1;c.w2ui.expanded=!0,e.forEach(function(a){a.w2ui=a.w2ui||{},a.w2ui.parent_recid=c.recid,null==a.w2ui.children&&(a.w2ui.children=[])}),this.records.splice.apply(this.records,[b+1,0].concat(e)),this.total+=e.length;var g="object"!=typeof this.url?this.url:this.url.get;g||(this.localSort(!0,!0),this.searchData.length>0&&this.localSearch(!0)),this.refresh(),this.trigger($.extend(f,{phase:"after"}))}else{if($("#grid_"+this.name+"_rec_"+d+"_expanded_row").length>0||this.show.expandColumn!==!0)return!1;if("none"==c.w2ui.expanded)return!1;$("#grid_"+this.name+"_rec_"+d).after('
'),$("#grid_"+this.name+"_frec_"+d).after(''+(this.show.lineNumbers?'':"")+'
');var f=this.trigger({phase:"before",type:"expand",target:this.name,recid:a,box_id:"grid_"+this.name+"_rec_"+a+"_expanded",fbox_id:"grid_"+this.name+"_frec_"+d+"_expanded"});if(f.isCancelled===!0)return $("#grid_"+this.name+"_rec_"+d+"_expanded_row").remove(),$("#grid_"+this.name+"_frec_"+d+"_expanded_row").remove(),!1;var h=$(this.box).find("#grid_"+this.name+"_rec_"+a+"_expanded"),i=$(this.box).find("#grid_"+this.name+"_frec_"+a+"_expanded"),j=h.find("> div:first-child").height();h.height()=0)break;l++}this.records.splice(k,l-k+1),this.total-=l-k+1;var m="object"!=typeof this.url?this.url:this.url.get;m||this.searchData.length>0&&this.localSearch(!0),this.refresh(),c.trigger($.extend(h,{phase:"after"}))}else{if(0===$("#grid_"+this.name+"_rec_"+f+"_expanded_row").length||this.show.expandColumn!==!0)return!1;var h=this.trigger({phase:"before",type:"collapse",target:this.name,recid:a,box_id:"grid_"+this.name+"_rec_"+f+"_expanded",fbox_id:"grid_"+this.name+"_frec_"+f+"_expanded"});if(h.isCancelled===!0)return!1;$("#grid_"+this.name+"_rec_"+f).removeAttr("expanded").removeClass("w2ui-expanded"),$("#grid_"+this.name+"_frec_"+f).removeAttr("expanded").removeClass("w2ui-expanded"),$("#grid_"+this.name+"_cell_"+this.get(a,!0)+"_expand div").html("+"),$("#grid_"+c.name+"_rec_"+f+"_expanded").css("height","0px"),$("#grid_"+c.name+"_frec_"+f+"_expanded").css("height","0px"),setTimeout(function(){$("#grid_"+c.name+"_rec_"+f+"_expanded_row").remove(),$("#grid_"+c.name+"_frec_"+f+"_expanded_row").remove(),e.w2ui.expanded=!1,c.trigger($.extend(h,{phase:"after"})),c.resizeRecords()},300)}return!0},sort:function(a,b,c){var d=this.trigger({phase:"before",type:"sort",target:this.name,field:a,direction:b,multiField:c});if(d.isCancelled!==!0){if(null!=a){for(var e=this.sortData.length,f=0;f0&&this.localSearch(!0),this.last.scrollTop=0,$("#grid_"+this.name+"_records").prop("scrollTop",0),this.trigger($.extend(d,{phase:"after",direction:b})),this.refresh())}},copy:function(a,b){if($.isPlainObject(a))return this.trigger($.extend(a,{phase:"after"})),a.text;var c=this.getSelection();if(0===c.length)return"";var d="";if("object"==typeof c[0]){for(var e=c[0].column,f=c[0].column,g=[],h=0;hf&&(f=c[h].column),g.indexOf(c[h].index)==-1&&g.push(c[h].index);g.sort(function(a,b){return a-b});for(var i=0;i div.w2ui-grid-box").css("width",$(this.box).width()).css("height",$(this.box).height());var c=this.trigger({phase:"before",type:"resize",target:this.name});if(c.isCancelled!==!0)return a.resizeBoxes(),a.resizeRecords(),a.toolbar&&a.toolbar.resize&&a.toolbar.resize(),this.trigger($.extend(c,{phase:"after"})),(new Date).getTime()-b}},update:function(a){var b=(new Date).getTime();if(null==this.box)return 0;if(null==a){for(var c=this.last.range_start-1;c<=this.last.range_end-1;c++)if(!(c<0)){var d=this.records[c]||{};d.w2ui||(d.w2ui={});for(var e=0;e0){null==b&&(b=this.get(a,!0));var e=c.attr("line"),f=!this.records[b]||this.records[b].recid!=a,g="object"!=typeof this.url?this.url:this.url.get;if(this.searchData.length>0&&!g)for(var h=0;h0&&(this.last.field=this.searches[0].field,this.last.label=this.searches[0].label);for(var h=0;h0&&k.indexes.length==this.records.length,m=k.indexes.length>0&&0!==this.searchData.length&&k.indexes.length==this.last.searchIds.length;l||m?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1),this.status();for(var n=a.find({"w2ui.expanded":!0},!0),o=0;o0&&b.forEach(function(b){$(a.box).find('td[col="'+b.col+'"]').not(".w2ui-head").w2marker(b.search)})},50),this.show.toolbarSave&&(this.getChanges().length>0?this.toolbar.enable("w2ui-save"):this.toolbar.disable("w2ui-save")),this.trigger($.extend(d,{phase:"after"})),a.resize(),a.addRange("selection"),setTimeout(function(){a.resize(),a.scroll()},1),a.reorderColumns&&!a.last.columnDrag?a.last.columnDrag=a.initColumnDrag():!a.reorderColumns&&a.last.columnDrag&&a.last.columnDrag.remove(), (new Date).getTime()-b}}},refreshBody:function(){var a=this,b=this.find({"w2ui.summary":!0},!0);if(b.length>0){for(var c=0;c=0;c--)this.records.splice(b[c],1)}this.scroll();var d=this.getRecordsHTML(),e=this.getColumnsHTML(),f='
'+d[0]+'
"+d[1]+'
'+e[0]+'
'+e[1]+"
",g=$("#grid_"+this.name+"_body",a.box).html(f),h=$("#grid_"+this.name+"_records",a.box);if(g.data("scrolldata",{lastTime:0,lastDelta:0,time:0}).find(".w2ui-grid-frecords").on("mousewheel DOMMouseScroll ",function(b){b.preventDefault();var c=b.originalEvent,d=g.data("scrolldata"),e=$(this).siblings(".w2ui-grid-records").addBack().filter(".w2ui-grid-records"),f=null!=typeof c.wheelDelta?c.wheelDelta*-1/120:(c.detail||c.deltaY)/3,i=e.scrollTop();d.time=+new Date,d.lastTime
'+this.msgEmpty+"
"):$("#grid_"+this.name+"_empty_msg").length>0&&$("#grid_"+this.name+"_empty_msg").remove(),this.summary.length>0){var i=this.getSummaryHTML();$("#grid_"+this.name+"_fsummary").html(i[0]).show(),$("#grid_"+this.name+"_summary").html(i[1]).show()}else $("#grid_"+this.name+"_fsummary").hide(),$("#grid_"+this.name+"_summary").hide()},render:function(a){function b(a){if(1==a.which&&("text"==e.last.userSelect&&(delete e.last.userSelect,$(e.box).find(".w2ui-grid-body").css(w2utils.cssPrefix("user-select","none"))),!("row"==e.selectType&&($(a.target).parents().hasClass("w2ui-head")||$(a.target).hasClass("w2ui-head"))||e.last.move&&"expand"==e.last.move.type))){if(a.altKey)$(e.box).find(".w2ui-grid-body").css(w2utils.cssPrefix("user-select","text")),e.selectNone(),e.last.move={type:"text-select"},e.last.userSelect="text";else{for(var b=a.target,f={x:a.offsetX-10,y:a.offsetY-10},g=!1;b&&(!b.classList||!b.classList.contains("w2ui-grid"));)b.tagName&&"TD"==b.tagName.toUpperCase()&&(g=!0),b.tagName&&"TR"!=b.tagName.toUpperCase()&&1==g&&(f.x+=b.offsetLeft,f.y+=b.offsetTop),b=b.parentNode;e.last.move={x:a.screenX,y:a.screenY,divX:0,divY:0,focusX:f.x,focusY:f.y,recid:$(a.target).parents("tr").attr("recid"),column:parseInt("TD"==a.target.tagName.toUpperCase()?$(a.target).attr("col"):$(a.target).parents("td").attr("col")),type:"select",ghost:!1,start:!0},null==e.last.move.recid&&(e.last.move.type="select-column");var h=a.target,i=$(e.box).find("#grid_"+e.name+"_focus");if(e.last.move){var j=e.last.move.focusX,k=e.last.move.focusY,l=$(h).parents("table").parent();(l.hasClass("w2ui-grid-records")||l.hasClass("w2ui-grid-frecords")||l.hasClass("w2ui-grid-columns")||l.hasClass("w2ui-grid-fcolumns")||l.hasClass("w2ui-grid-summary"))&&(j=e.last.move.focusX-$(e.box).find("#grid_"+e.name+"_records").scrollLeft(),k=e.last.move.focusY-$(e.box).find("#grid_"+e.name+"_records").scrollTop()),($(h).hasClass("w2ui-grid-footer")||$(h).parents("div.w2ui-grid-footer").length>0)&&(k=$(e.box).find("#grid_"+e.name+"_footer").position().top),l.hasClass("w2ui-scroll-wrapper")&&l.parent().hasClass("w2ui-toolbar")&&(j=e.last.move.focusX-l.scrollLeft()),i.css({left:j-10,top:k})}setTimeout(function(){["INPUT","TEXTAREA","SELECT"].indexOf(h.tagName.toUpperCase())!=-1?$(h).focus():i.is(":focus")||i.focus()},50),e.multiSelect||e.reorderRows||"drag"!=e.last.move.type||delete e.last.move}if(1==e.reorderRows){var m=a.target;if("TD"!=m.tagName.toUpperCase()&&(m=$(m).parents("td")[0]),$(m).hasClass("w2ui-col-number")){e.selectNone(),e.last.move.reorder=!0;var n=$(e.box).find(".w2ui-even.w2ui-empty-record").css("background-color"),o=$(e.box).find(".w2ui-odd.w2ui-empty-record").css("background-color");$(e.box).find(".w2ui-even td").not(".w2ui-col-number").css("background-color",n),$(e.box).find(".w2ui-odd td").not(".w2ui-col-number").css("background-color",o);var p=e.last.move;if(!p.ghost){var q=$("#grid_"+e.name+"_rec_"+p.recid),b=q.parents("table").find("tr:first-child").clone();p.offsetY=a.offsetY,p.from=p.recid,p.pos=q.position(),p.ghost=$(q).clone(!0),p.ghost.removeAttr("id"),q.find("td").remove(),q.append('');var r=$(e.box).find(".w2ui-grid-records");r.append('
'),$("#grid_"+e.name+"_ghost").append(b).append(p.ghost)}var s=$("#grid_"+e.name+"_ghost"),r=$(e.box).find(".w2ui-grid-records");s.css({top:p.pos.top+r.scrollTop(),left:p.pos.left,"border-top":"1px solid #aaa","border-bottom":"1px solid #aaa"})}else e.last.move.reorder=!1}$(document).on("mousemove.w2ui-"+e.name,c).on("mouseup.w2ui-"+e.name,d),a.stopPropagation()}}function c(a){var b=e.last.move;if(b&&["select","select-column"].indexOf(b.type)!=-1&&(b.divX=a.screenX-b.x,b.divY=a.screenY-b.y,!(Math.abs(b.divX)<=1&&Math.abs(b.divY)<=1))){if(e.last.cancelClick=!0,1==e.reorderRows&&e.last.move.reorder){var c=$(a.target).parents("tr"),d=c.attr("recid");if(d!=b.from){var f=($("#grid_"+e.name+"_rec_"+b.recid),$("#grid_"+e.name+"_rec_"+d));$(e.box).find(".tmp-ghost").css("border-top","0px"),f.addClass("tmp-ghost").css("border-top","2px solid #769EFC"),b.lastY=a.screenY,b.to=d}var g=$("#grid_"+e.name+"_ghost"),h=$(e.box).find(".w2ui-grid-records");return void g.css({top:b.pos.top+b.divY+h.scrollTop(),left:b.pos.left})}b.start&&b.recid&&(e.selectNone(),b.start=!1);var i=[],d="TR"==a.target.tagName.toUpperCase()?$(a.target).attr("recid"):$(a.target).parents("tr").attr("recid");if(null==d){if("row"==e.selectType)return;if(e.last.move&&"select"==e.last.move.type)return;var j=parseInt($(a.target).parents("td").attr("col"));if(isNaN(j))e.removeRange("column-selection"),$(e.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected"),$(e.box).find(".w2ui-col-number").removeClass("w2ui-row-selected"),delete b.colRange;else{var k=j+"-"+j;b.columnj&&(k=j+"-"+b.column);for(var l=[],c=k.split("-"),n=parseInt(c[0]);n<=parseInt(c[1]);n++)l.push(n);if(b.colRange!=k&&(m=e.trigger({phase:"before",type:"columnSelect",target:e.name,columns:l,isCancelled:!1}),m.isCancelled!==!0)){null==b.colRange&&e.selectNone();var c=k.split("-");$(e.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected");for(var o=parseInt(c[0]);o<=parseInt(c[1]);o++)$(e.box).find("#grid_"+e.name+"_column_"+o+" .w2ui-col-header").addClass("w2ui-col-selected");$(e.box).find(".w2ui-col-number").not(".w2ui-head").addClass("w2ui-row-selected"),b.colRange=k,e.removeRange("column-selection"),e.addRange({name:"column-selection",range:[{recid:e.records[0].recid,column:c[0]},{recid:e.records[e.records.length-1].recid,column:c[1]}],style:"background-color: rgba(90, 145, 234, 0.1)"})}}}else{var p=e.get(b.recid,!0);if(null==p||e.records[p]&&e.records[p].recid!=b.recid)return;var q=e.get(d,!0);if(null==q)return;var r=parseInt(b.column),s=parseInt("TD"==a.target.tagName.toUpperCase()?$(a.target).attr("col"):$(a.target).parents("td").attr("col"));if(isNaN(r)&&isNaN(s)&&(r=0,s=e.columns.length-1),p>q){var c=p;p=q,q=c}var c="ind1:"+p+",ind2;"+q+",col1:"+r+",col2:"+s;if(b.range==c)return;b.range=c;for(var t=p;t<=q;t++)if(!(e.last.searchIds.length>0&&e.last.searchIds.indexOf(t)==-1))if("row"!=e.selectType){if(r>s){var c=r;r=s,s=c}for(var c=[],u=r;u<=s;u++)e.columns[u].hidden||i.push({recid:e.records[t].recid,column:parseInt(u)})}else i.push(e.records[t].recid);if("row"!=e.selectType){for(var v=e.getSelection(),c=[],w=0;wk?e.records.splice(k,0,c):e.records.splice(k-1,0,c)),$("#grid_"+e.name+"_ghost").remove(),e.refresh(),e.trigger($.extend(i,{phase:"after"}))}}delete e.last.move,$(document).off(".w2ui-"+e.name)}}var e=this,f=(new Date).getTime();if(null!=a&&($(this.box).find("#grid_"+this.name+"_body").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-grid").html(""),this.box=a),this.box){var g="object"!=typeof this.url?this.url:this.url.get,h=this.trigger({phase:"before",target:this.name,type:"render",box:a});if(h.isCancelled!==!0){if(this.reset(!0),!this.last.field)if(this.multiSearch&&this.show.searchAll)this.last.field="all",this.last.label=w2utils.lang("All Fields");else{for(var i=0;i=this.searches.length?(this.last.field="",this.last.label=""):(this.last.field=this.searches[i].field,this.last.label=this.searches[i].label)}if($(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-grid").html('
'),"row"!=this.selectType&&$(this.box).addClass("w2ui-ss"),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.initToolbar(),null!=this.toolbar&&this.toolbar.render($("#grid_"+this.name+"_toolbar")[0]),this.last.field&&"all"!=this.last.field){var j=this.searchData;setTimeout(function(){e.initAllField(e.last.field,1==j.length?j[0].value:null)},1)}$("#grid_"+this.name+"_footer").html(this.getFooterHTML()),this.last.state||(this.last.state=this.stateSave(!0)),this.stateRestore(),g&&(this.clear(),this.refresh());for(var k=!1,l=0;l0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-grid").html(""),delete w2ui[this.name],this.trigger($.extend(a,{phase:"after"})))},initColumnOnOff:function(){if(this.show.toolbarColumns){for(var a=this,b='
",c=0;c ")}var f="object"!=typeof this.url?this.url:this.url.get;(f&&a.show.skipRecords||a.show.saveRestoreState)&&(b+=''),f&&a.show.skipRecords&&(b+='"),a.show.saveRestoreState&&(b+='"),b+="
'+w2utils.lang("Skip")+' "+w2utils.lang("Records")+"
"+w2utils.lang("Save Grid State")+'
"+w2utils.lang("Restore Default State")+"
",this.toolbar.get("w2ui-column-on-off").html=b}},initColumnDrag:function(a){function b(){j.pressed=!1,clearTimeout(j.timeout)}function c(a){j.timeout&&clearTimeout(j.timeout);var b=this;j.pressed=!0,j.timeout=setTimeout(function(){if(j.pressed&&0!==j.numberPreColumnsPresent){var c,f,g,h,k,l=["w2ui-col-number","w2ui-col-expand","w2ui-col-select"],m=["w2ui-head-last"],n=l.concat(m),o=".w2ui-col-number, .w2ui-col-expand, .w2ui-col-select",p=".w2ui-head.w2ui-col-number, .w2ui-head.w2ui-col-expand, .w2ui-head.w2ui-col-select";if($(a.originalEvent.target).parents().hasClass("w2ui-head")){for(var q=0,r=n.length;q
'),j.markerLeft=$('
')),j.lastInt&&j.lastInt===a||(j.lastInt=a,j.marker.remove(),j.markerLeft.remove(),$(".w2ui-head").removeClass("w2ui-col-intersection"),a>=j.columns.length?($(j.columns[j.columns.length-1]).children("div:last").append(j.marker.addClass("right").removeClass("left")),$(j.columns[j.columns.length-1]).addClass("w2ui-col-intersection")):a<=j.numberPreColumnsPresent?($(j.columns[j.numberPreColumnsPresent]).prepend(j.marker.addClass("left").removeClass("right")).css({position:"relative"}),$(j.columns[j.numberPreColumnsPresent]).prev().addClass("w2ui-col-intersection")):($(j.columns[a]).children("div:last").prepend(j.marker.addClass("left").removeClass("right")),$(j.columns[a]).prev().children("div:last").append(j.markerLeft.addClass("right").removeClass("left")).css({position:"relative"}),$(j.columns[a-1]).addClass("w2ui-col-intersection")))}function g(a,b,c){if(a<=b[0])return 0;if(a>=b[b.length-1]+c)return b.length;for(var d=0,e=b.length;df&&a<=h)return d;if(a>h&&a<=g)return d+1}return intersection}function h(a,b){$(j.ghost).css({left:a-10,top:b-10})}if(this.columnGroups&&this.columnGroups.length)throw"Draggable columns are not currently supported with column groups.";var i=this,j={};return j.lastInt=null,j.pressed=!1,j.timeout=null,j.columnHead=null,$(i.box).on("mousedown",c),$(i.box).on("mouseup",b),{remove:function(){$(i.box).off("mousedown",c),$(i.box).off("mouseup",b),$(i.box).find(".w2ui-head").removeAttr("draggable"),i.last.columnDrag=!1}}},columnOnOff:function(a,b){var c=$(a.target).parents("tr").find(".w2ui-column-check"),d=this.trigger({phase:"before",target:this.name,type:"columnOnOff",field:b,originalEvent:a});if(d.isCancelled!==!0){for(var e=this,f=!(a.shiftKey||a.metaKey||a.ctrlKey||$(a.target).hasClass("w2ui-column-check")),g=e.find({"w2ui.expanded":!0},!0),h=0;h ';this.toolbar.items.push({type:"html",id:"w2ui-search",html:c})}if(this.show.toolbarSearch&&this.multiSearch&&this.searches.length>0&&this.toolbar.items.push($.extend(!0,{},this.buttons["search-go"])),(this.show.toolbarSearch||this.show.toolbarInput)&&(this.show.toolbarAdd||this.show.toolbarEdit||this.show.toolbarDelete||this.show.toolbarSave)&&this.toolbar.items.push({type:"break",id:"w2ui-break1"}),this.show.toolbarAdd&&this.toolbar.items.push($.extend(!0,{},this.buttons.add)),this.show.toolbarEdit&&this.toolbar.items.push($.extend(!0,{},this.buttons.edit)),this.show.toolbarDelete&&this.toolbar.items.push($.extend(!0,{},this.buttons.delete)),this.show.toolbarSave&&((this.show.toolbarAdd||this.show.toolbarDelete||this.show.toolbarEdit)&&this.toolbar.items.push({type:"break",id:"w2ui-break2"}),this.toolbar.items.push($.extend(!0,{},this.buttons.save))),b)for(var d=0;d div',a.box).each(function(){var a=this.offsetWidth-this.scrollWidth;a0&&(c.css({bottom:0+(this.show.footer?w2utils.getSize(e,"height"):0)+"px"}),d.css({bottom:0+(this.show.footer?w2utils.getSize(e,"height"):0)+"px",right:"0px"})),this.show.footer&&e.css({bottom:"0px",left:"0px",right:"0px"}),f.css({top:0+(this.show.header?w2utils.getSize(a,"height"):0)+(this.show.toolbar?w2utils.getSize(b,"height"):0)+"px",bottom:0+(this.show.footer?w2utils.getSize(e,"height"):0)+(this.summary.length>0?w2utils.getSize(d,"height"):0)+"px",left:"0px",right:"0px"})},resizeRecords:function(){function a(a,b,c){var d="",e="",f="";d+='',e+='',c.show.lineNumbers&&(d+=''),c.show.selectColumn&&(d+=''),c.show.expandColumn&&(d+=''),e+='';for(var g=0;gc.last.colEnd)&&!h.frozen||(f='',h.frozen?d+=f:e+=f)}d+=' ',e+=' ',$("#grid_"+c.name+"_frecords > table").append(d),$("#grid_"+c.name+"_records > table").append(e)}var b=this;$(this.box).find(".w2ui-empty-record").remove();var c=$(this.box),d=$(this.box).find("> div.w2ui-grid-box"),e=$("#grid_"+this.name+"_header"),f=$("#grid_"+this.name+"_toolbar"),g=$("#grid_"+this.name+"_summary"),h=$("#grid_"+this.name+"_fsummary"),i=$("#grid_"+this.name+"_footer"),j=$("#grid_"+this.name+"_body"),k=$("#grid_"+this.name+"_columns"),l=$("#grid_"+this.name+"_fcolumns"),m=$("#grid_"+this.name+"_records"),n=$("#grid_"+this.name+"_frecords"),o=$("#grid_"+this.name+"_scroll1"),p=8*String(this.total).length+10;p<34&&(p=34),null!=this.lineNumberWidth&&(p=this.lineNumberWidth);for(var q=!1,r=!1,s=0,t=0;ttable").height()+(q?w2utils.scrollBarSize():0)&&(r=!0),this.fixedBody){var v=d.height()-(this.show.header?w2utils.getSize(e,"height"):0)-(this.show.toolbar?w2utils.getSize(f,"height"):0)-("none"!=g.css("display")?w2utils.getSize(g,"height"):0)-(this.show.footer?w2utils.getSize(i,"height"):0);j.css("height",v)}else{var v=w2utils.getSize(k,"height")+w2utils.getSize($("#grid_"+b.name+"_records table"),"height")+(q?w2utils.scrollBarSize():0);b.height=v+w2utils.getSize(d,"+height")+(b.show.header?w2utils.getSize(e,"height"):0)+(b.show.toolbar?w2utils.getSize(f,"height"):0)+("none"!=g.css("display")?w2utils.getSize(g,"height"):0)+(b.show.footer?w2utils.getSize(i,"height"):0),d.css("height",b.height),j.css("height",v),c.css("height",w2utils.getSize(d,"height")+w2utils.getSize(c,"+height"))}var w=this.records.length,x="object"!=typeof this.url?this.url:this.url.get;if(0==this.searchData.length||x||(w=this.last.searchIds.length),this.fixedBody||(r=!1),q||r?(k.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show(),m.css({top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(k,"height")+"px","-webkit-overflow-scrolling":"touch","overflow-x":q?"auto":"hidden","overflow-y":r?"auto":"hidden"})):(k.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").hide(),m.css({ top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(k,"height")+"px",overflow:"hidden"}),m.length>0&&(this.last.scrollTop=0,this.last.scrollLeft=0)),q?(n.css("margin-bottom",w2utils.scrollBarSize()),o.show()):(n.css("margin-bottom",0),o.hide()),n.css({overflow:"hidden",top:m.css("top")}),this.show.emptyRecords&&!r){var y=Math.floor(m.height()/this.recordHeight)-1,z=0;if(m[0]&&(z=m[0].scrollHeight-y*this.recordHeight),z>=this.recordHeight&&(z-=this.recordHeight,y++),this.fixedBody){for(var A=w;A0){for(var B=parseInt(j.width())-(r?w2utils.scrollBarSize():0)-(this.show.lineNumbers?p:0)-(this.show.selectColumn?26:0)-(this.show.expandColumn?26:0)-1,C=B,D=0,E=!1,t=0;t0&&(F.gridMinWidth>C&&F.hidden!==!0&&(F.hidden=!0,E=!0),F.gridMinWidth0)for(var t=0;tparseInt(F.max)&&(F.sizeCalculated=F.max+"px"),G+=parseInt(F.sizeCalculated))}var H=parseInt(C)-parseInt(G);if(H>0&&D>0)for(var t=0;;){var F=this.columns[t];if(null!=F)if(F.hidden||"px"==F.sizeType)t++;else{if(F.sizeCalculated=parseInt(F.sizeCalculated)+1+"px",H--,0===H)break;t++}else t=0}else H>0&&k.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show();var I=1;this.show.lineNumbers&&(I+=p),this.show.selectColumn&&(I+=26),this.show.expandColumn&&(I+=26);for(var t=0;t table > tbody > tr:nth-child(1) td").add(l.find("> table > tbody > tr:nth-child(1) td")).each(function(a,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",p);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0===D?H:0)+"px")}),3==k.find("> table > tbody > tr").length&&k.find("> table > tbody > tr:nth-child(1) td").add(l.find("> table > tbody > tr:nth-child(1) td")).html("").css({height:"0px",border:"0px",padding:"0px",margin:"0px"}),m.find("> table > tbody > tr:nth-child(1) td").add(n.find("> table > tbody > tr:nth-child(1) td")).each(function(a,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",p);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0===D?H:0)+"px")}),g.find("> table > tbody > tr:nth-child(1) td").add(h.find("> table > tbody > tr:nth-child(1) td")).each(function(a,c){$(c).hasClass("w2ui-col-number")&&$(c).css("width",p);var d=$(c).attr("col");if(null!=d){if("start"==d){for(var e=0,f=0;f0&&0===D?H:0)+"px")}),this.initResize(),this.refreshRanges(),(this.last.scrollTop||this.last.scrollLeft)&&m.length>0&&(k.prop("scrollLeft",this.last.scrollLeft),m.prop("scrollTop",this.last.scrollTop),m.prop("scrollLeft",this.last.scrollLeft))},getSearchesHTML:function(){function a(a,c){var d="",e=b.operators[b.operatorsMap[a]];null!=c&&(e=c);for(var f=0;f'+w2utils.lang(h)+"\n"}return d}for(var b=this,c='',d=!1,e=0;eX",d=!0),null==f.inTag&&(f.inTag=""),null==f.outTag&&(f.outTag=""),null==f.style&&(f.style=""),null==f.type&&(f.type="text"),null==f.label&&null!=f.caption&&(console.log("NOTICE: grid search.caption property is deprecated, please use search.label. Search ->",f),f.label=f.caption);var h='";switch(c+='"}}return c+='
'+g+' '+(f.label||"")+' '+h+' ',f.type){case"text":case"alphanumeric":case"hex":case"color":case"list":case"combo":case"enum":var i="width: 250px;";["hex","color"].indexOf(f.type)!=-1&&(i="width: 90px;"),c+='";break;case"int":case"float":case"money":case"currency":case"percent":case"date":case"time":case"datetime":var i="width: 90px";"datetime"==f.type&&(i="width: 140px;"),c+='";break;case"select":c+='"}c+=f.outTag+"
"},initOperator:function(a,b){var c=this,d=c.searches[b],e=$("#grid_"+c.name+"_range_"+b),f=$("#grid_"+c.name+"_field_"+b),g=f.parent().find("span input");switch(f.show(),e.hide(),$(a).val()){case"between":e.show(),g.w2field(d.type,d.options);break;case"not null":case"null":f.hide(),f.val("1"),f.change()}},initSearches:function(){for(var a=this,b=0;b'+l+""}else i+='"}$("#grid_"+this.name+"_field_"+b).html(i)}null!=d?("int"==d.type&&["in","not in"].indexOf(d.operator)!=-1&&$("#grid_"+this.name+"_field_"+b).w2field("clear").val(d.value),$("#grid_"+this.name+"_operator_"+b).val(d.operator).trigger("change"),$.isArray(d.value)?["in","not in"].indexOf(d.operator)!=-1?$("#grid_"+this.name+"_field_"+b).val(d.value).trigger("change"):($("#grid_"+this.name+"_field_"+b).val(d.value[0]).trigger("change"),$("#grid_"+this.name+"_field2_"+b).val(d.value[1]).trigger("change")):null!=d.value&&$("#grid_"+this.name+"_field_"+b).val(d.value).trigger("change")):$("#grid_"+this.name+"_operator_"+b).val(f).trigger("change")}$("#w2ui-overlay-"+this.name+"-searchOverlay .w2ui-grid-searches *[rel=search]").on("keypress",function(b){13==b.keyCode&&(a.search(),$().w2overlay({name:a.name+"-searchOverlay"}))})},getColumnsHTML:function(){function a(){var a="",b="",d="",e=c.columnGroups.length-1;null==c.columnGroups[e].text&&null!=c.columnGroups[e].caption&&(console.log("NOTICE: grid columnGroup.caption property is deprecated, please use columnGroup.text. Group -> ",c.columnGroups[e]),c.columnGroups[e].text=c.columnGroups[e].caption),""!=c.columnGroups[c.columnGroups.length-1].text&&c.columnGroups.push({text:""}),c.show.lineNumbers&&(a+='
 
'),c.show.selectColumn&&(a+='
 
'),c.show.expandColumn&&(a+='
 
');var f=0;b+='';for(var g=0;g",i),i.text=i.caption);for(var j=0,k=f;k'),d='"+n+'
'+(i.text?i.text:" ")+"
",i&&i.frozen?a+=d:b+=d}else d='
'+(h.text?h.text:" ")+"
",i&&i.frozen?a+=d:b+=d;f+=h.span}return a+="",b+='',[a,b]}function b(a){var b="",d="";c.show.lineNumbers&&(b+='
#
"),c.show.selectColumn&&(b+='
"),c.show.expandColumn&&(b+='
 
');var e,f=0,g=0;d+='';for(var h=0;h ",i),i.text=i.caption),null==i.size&&(i.size="100%"),h==g&&(e=c.columnGroups[f++]||{},g+=e.span),(!(hc.last.colEnd)||i.frozen)&&!i.hidden&&(e.master!==!0||a)){var j=c.getColumnCellHTML(h);i&&i.frozen?b+=j:d+=j}}return b+='
 
',d+='
 
',b+="",d+="",[b,d]}var c=this,d="",e="";if(this.show.columnHeaders)if(this.columnGroups.length>0){var f=b(!0),g=a(),h=b(!1);d=f[0]+g[0]+h[0],e=f[1]+g[1]+h[1]}else{var i=b(!0);d=i[0],e=i[1]}return[d,e]},getColumnCellHTML:function(a){var b=this.columns[a];if(null==b)return"";for(var c=!this.reorderColumns||this.columnGroups&&this.columnGroups.length?"":" w2ui-reorder-cols-head ",d="",e=0;e"+(b.resizable!==!1?'
':"")+'
'+(b.text?b.text:" ")+"
";return i},columnTooltipShow:function(a){if("normal"!=this.columnTooltip){var b=$(this.box).find("#grid_"+this.name+"_column_"+a),c=this.columns[a],d=this.columnTooltip;b.prop("_mouse_over",!0),setTimeout(function(){b.prop("_mouse_over")===!0&&b.prop("_mouse_tooltip")!==!0&&(b.prop("_mouse_tooltip",!0),b.w2tag(c.tooltip,{position:d}))},1)}},columnTooltipHide:function(a){if("normal"!=this.columnTooltip){var b=$(this.box).find("#grid_"+this.name+"_column_"+a);this.columns[a];b.removeProp("_mouse_over"),setTimeout(function(){b.prop("_mouse_over")!==!0&&b.prop("_mouse_tooltip")===!0&&(b.removeProp("_mouse_tooltip"),b.w2tag())},1)}},getRecordsHTML:function(){var a=this.records.length,b="object"!=typeof this.url?this.url:this.url.get;0==this.searchData.length||b||(a=this.last.searchIds.length),a>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start;var c=$("#grid_"+this.name+"_records"),d=Math.floor((c.height()||0)/this.recordHeight)+this.last.show_extra+1;(!this.fixedBody||d>a)&&(d=a);var e=this.getRecordHTML(-1,0),f=""+e[0],g="
"+e[1];f+='',g+='';for(var h=0;h
',g+=' ',this.last.range_start=0,this.last.range_end=d,[f,g]},getSummaryHTML:function(){if(0!==this.summary.length){for(var a=this.getRecordHTML(-1,0),b=""+a[0],c="
"+a[1],d=0;d0&&a.forEach(function(a){$(c.box).find('td[col="'+a.col+'"]').not(".w2ui-head").w2marker(a.search)})},50))}var c=((new Date).getTime(),this),d="object"!=typeof this.url?this.url:this.url.get,e=$("#grid_"+this.name+"_records"),f=$("#grid_"+this.name+"_frecords");if(a){var g=a.target.scrollTop,h=a.target.scrollLeft;c.last.scrollTop=g,c.last.scrollLeft=h,$("#grid_"+c.name+"_columns")[0].scrollLeft=h,$("#grid_"+c.name+"_summary")[0].scrollLeft=h,f[0].scrollTop=g}this.last.bubbleEl&&($(this.last.bubbleEl).w2tag(),this.last.bubbleEl=null);var i=null,j=null;if(c.disableCVS||c.columnGroups.length>0)i=0,j=c.columns.length-1;else{for(var k=e.width(),l=0,m=0;mc.last.scrollLeft&&null==i&&(i=m),l+n-30>c.last.scrollLeft+k&&null==j&&(j=m),l+=n}null==j&&(j=c.columns.length-1)}if(null!=i&&(i<0&&(i=0),j<0&&(j=0),i==j&&(i>0?i--:j++),i!=c.last.colStart||j!=c.last.colEnd)){var o=$(c.box),p=Math.abs(i-c.last.colStart),q=Math.abs(j-c.last.colEnd);if(p<5&&q<5){var r=o.find(".w2ui-grid-columns #grid_"+c.name+"_column_start"),s=o.find(".w2ui-grid-columns .w2ui-head-last"),t=o.find("#grid_"+c.name+"_records .w2ui-grid-data-spacer"),u=o.find("#grid_"+c.name+"_records .w2ui-grid-data-last"),v=o.find("#grid_"+c.name+"_summary .w2ui-grid-data-spacer"),w=o.find("#grid_"+c.name+"_summary .w2ui-grid-data-last");if(i>c.last.colStart)for(var m=c.last.colStart;mj;m--)o.find("#grid_"+c.name+"_columns #grid_"+c.name+"_column_"+m).remove(),o.find("#grid_"+c.name+'_records td[col="'+m+'"]').remove(),o.find("#grid_"+c.name+'_summary td[col="'+m+'"]').remove();if(i=i;m--)c.columns[m]&&(c.columns[m].frozen||c.columns[m].hidden)||(r.after(c.getColumnCellHTML(m)),t.each(function(a,b){var d=$(b).parent().attr("index"),e='';null!=d&&(e=c.getCellHTML(parseInt(d),m,!1)),$(b).after(e)}),v.each(function(a,b){var d=$(b).parent().attr("index"),e='';null!=d&&(e=c.getCellHTML(parseInt(d),m,!0)),$(b).after(e)}));if(j>c.last.colEnd)for(var m=c.last.colEnd+1;m<=j;m++)c.columns[m]&&(c.columns[m].frozen||c.columns[m].hidden)||(s.before(c.getColumnCellHTML(m)),u.each(function(a,b){var d=$(b).parent().attr("index"),e='';null!=d&&(e=c.getCellHTML(parseInt(d),m,!1)),$(b).before(e)}),w.each(function(a,b){var d=$(b).parent().attr("index")||-1,e=c.getCellHTML(parseInt(d),m,!0);$(b).before(e)}));c.last.colStart=i,c.last.colEnd=j,c.resizeRecords()}else{c.last.colStart=i,c.last.colEnd=j;var x=this.getColumnsHTML(),y=this.getRecordsHTML(),z=this.getSummaryHTML(),A=o.find("#grid_"+this.name+"_columns"),B=o.find("#grid_"+this.name+"_records"),C=o.find("#grid_"+this.name+"_frecords"),D=o.find("#grid_"+this.name+"_summary");A.find("tbody").html(x[1]),C.html(y[0]),B.prepend(y[1]),null!=z&&D.html(z[1]),setTimeout(function(){B.find("> table").not("table:first-child").remove(),D[0]&&(D[0].scrollLeft=c.last.scrollLeft)},1),c.resizeRecords()}}var E=this.records.length;if(0==this.searchData.length||d||(E=this.last.searchIds.length),0!==E&&0!==e.length&&0!==e.height()&&(E>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start,!(e.height()E&&(F=E),G>=E-1&&(G=E),$("#grid_"+this.name+"_footer .w2ui-footer-right").html((c.show.statusRange?w2utils.formatNumber(this.offset+F)+"-"+w2utils.formatNumber(this.offset+G)+(this.total!=-1?" "+w2utils.lang("of")+" "+w2utils.formatNumber(this.total):""):"")+(d&&c.show.statusBuffered?" ("+w2utils.lang("buffered")+" "+w2utils.formatNumber(E)+(this.offset>0?", skip "+w2utils.formatNumber(this.offset):"")+")":"")),d||this.fixedBody&&!(this.total!=-1&&this.total<=this.vs_start)){var H=Math.floor(e[0].scrollTop/this.recordHeight)-this.last.show_extra,I=H+Math.floor(e.height()/this.recordHeight)+2*this.last.show_extra+1;H<1&&(H=1),I>this.total&&this.total!=-1&&(I=this.total);var J=e.find("#grid_"+this.name+"_rec_top"),K=e.find("#grid_"+this.name+"_rec_bottom"),L=f.find("#grid_"+this.name+"_frec_top"),M=f.find("#grid_"+this.name+"_frec_bottom");String(J.next().prop("id")).indexOf("_expanded_row")!=-1&&(J.next().remove(),L.next().remove()),this.total>I&&String(K.prev().prop("id")).indexOf("_expanded_row")!=-1&&(K.prev().remove(),M.prev().remove());var N=parseInt(J.next().attr("line")),O=parseInt(K.prev().attr("line"));if(N=N-this.last.show_extra+2&&H>1)return;for(;;){var P=f.find("#grid_"+this.name+"_frec_bottom").prev(),Q=e.find("#grid_"+this.name+"_rec_bottom").prev();if("top"==Q.attr("line"))break;if(!(parseInt(Q.attr("line"))>I))break;P.remove(),Q.remove()}var R=e.find("#grid_"+this.name+"_rec_top").next(),S=R.attr("line");"bottom"==S&&(S=I);for(var m=parseInt(S)-1;m>=H;m--)if(this.records[m-1]){var Q=this.records[m-1].w2ui;Q&&!Array.isArray(Q.children)&&(Q.expanded=!1);var T=this.getRecordHTML(m-1,m);J.after(T[1]),L.after(T[0])}b(),setTimeout(function(){c.refreshRanges()},0)}var U=(H-1)*c.recordHeight,V=(E-I)*c.recordHeight;V<0&&(V=0),J.css("height",U+"px"),L.css("height",U+"px"),K.css("height",V+"px"),M.css("height",V+"px"),c.last.range_start=H,c.last.range_end=I;var W=Math.floor(e[0].scrollTop/this.recordHeight),X=W+Math.floor(e.height()/this.recordHeight);if(X+10>E&&this.last.pull_more!==!0&&(E
')}),(Y.find("td .w2ui-spinner").length>0||Y.find("td").text().indexOf("Load")==-1)&&Y.find("td").html("
"+w2utils.lang("Load")+" "+c.limit+" "+w2utils.lang("More")+"...
")}E>=this.total-this.offset&&this.total!=-1&&$("#grid_"+this.name+"_rec_more, #grid_"+this.name+"_frec_more").hide()}}},getRecordHTML:function(a,b,c){var d,e="",f="",g="",h=this.last.selection;if(a==-1){f+='
',g+='',this.show.lineNumbers&&(f+=''),this.show.selectColumn&&(f+=''),this.show.expandColumn&&(f+=''),g+='';for(var i=0;i',j.frozen&&!j.hidden)f+=e;else{if(j.hidden||ithis.last.colEnd)continue;g+=e}}return f+='',g+='',f+="",g+="",[f,g]}var k="object"!=typeof this.url?this.url:this.url.get;if(c!==!0)if(this.searchData.length>0&&!k){if(a>=this.last.searchIds.length)return"";a=this.last.searchIds[a],d=this.records[a]}else{if(a>=this.records.length)return"";d=this.records[a]}else{if(a>=this.summary.length)return"";d=this.summary[a]}if(!d)return"";null==d.recid&&null!=this.recid&&null!=d[this.recid]&&(d.recid=d[this.recid]);var l=(w2utils.escapeId(d.recid),!1);h.indexes.indexOf(a)!=-1&&(l=!0);var m=d.w2ui?d.w2ui.style:"";null!=m&&"string"==typeof m||(m="");var n=d.w2ui?d.w2ui.class:"";if(null!=n&&"string"==typeof n||(n=""),f+='",g+='",this.show.lineNumbers&&(f+='"),this.show.selectColumn){var o=!1;d&&d.w2ui&&d.w2ui.hideCheckBox===!0&&(o=!0),f+='"}if(this.show.expandColumn){var p="";p=d.w2ui&&d.w2ui.expanded===!0?"-":"+",d.w2ui&&"none"==d.w2ui.expanded&&(p=""),d.w2ui&&"spinner"==d.w2ui.expanded&&(p='
'),f+='"}g+='';for(var q=0,r=0;;){var s=1,j=this.columns[q];if(null==j)break;if(j.hidden)q++,r>0&&r--;else if(r>0){if(q++,null==this.columns[q])break;d.w2ui.colspan[this.columns[q-1].field]=0,r--}else{if(d.w2ui){var t=d.w2ui.colspan,u=this.columns[q].field;t&&0===t[u]&&delete t[u]}if(!(qthis.last.colEnd)||j.frozen){if(d.w2ui&&"object"==typeof d.w2ui.colspan){var v=parseInt(d.w2ui.colspan[j.field])||null;if(v>1){for(var w=0,i=q;i=this.columns.length);i++)this.columns[i].hidden&&w++;s=v-w,r=v-1}}var x=this.getCellHTML(a,q,c,s);j.frozen?f+=x:g+=x,q++}else q++}}return f+='',g+='', f+="",g+="",[f,g]},getLineHTML:function(a){return"
"+a+"
"},getCellHTML:function(a,b,c,d){var e=this.columns[b];if(null==e)return"";var f=c!==!0?this.records[a]:this.summary[a],g=a!==-1?this.getCellValue(a,b,c):"",h=a!==-1?this.getCellEditable(a,b):"",i="max-height: "+parseInt(this.recordHeight)+"px;",j=!c&&f&&f.w2ui&&f.w2ui.changes&&null!=f.w2ui.changes[e.field],k="",l="",m=this.last.selection,n=!1,o="";if(m.indexes.indexOf(a)!=-1&&(n=!0),null==d&&(d=f&&f.w2ui&&f.w2ui.colspan&&f.w2ui.colspan[e.field]?f.w2ui.colspan[e.field]:1),0===b&&f&&f.w2ui&&Array.isArray(f.w2ui.children)){for(var p=0,q=this.get(f.w2ui.parent_recid,!0);;){if(null==q)break;p++;var r=this.records[q].w2ui;if(null==r||null==r.parent_recid)break;q=this.get(r.parent_recid,!0)}if(f.w2ui.parent_recid)for(var s=0;s';o+='"}if(e.info===!0&&(e.info={}),null!=e.info){var t="w2ui-icon-info";"function"==typeof e.info.icon?t=e.info.icon(f):"object"==typeof e.info.icon?t=e.info.icon[this.parseField(f,e.field)]||"":"string"==typeof e.info.icon&&(t=e.info.icon);var u=e.info.style||"";"function"==typeof e.info.style?u=e.info.style(f):"object"==typeof e.info.style?u=e.info.style[this.parseField(f,e.field)]||"":"string"==typeof e.info.style&&(u=e.info.style),o+='"}if(null!=e.render&&a!==-1){if("function"==typeof e.render&&(g=$.trim(e.render.call(this,f,a,b,g)),(g.length<4||"'+o+String(g)+"")),"object"==typeof e.render){var v=e.render[g];null!=v&&""!==v||(v=g),g='
'+o+v+"
"}if("string"==typeof e.render){var w=e.render.toLowerCase().indexOf(":"),r=[];w==-1?(r[0]=e.render.toLowerCase(),r[1]=""):(r[0]=e.render.toLowerCase().substr(0,w),r[1]=e.render.toLowerCase().substr(w+1));var x=w2utils.formatters[r[0]];g='
'+o+("function"==typeof x?x(g,r[1]):"")+"
"}}else{if(h&&["checkbox","check"].indexOf(h.type)!=-1){var y=c?-(a+1):a;i+="text-align: center;",g='',o=""}if(this.show.recordTitles){var z=w2utils.stripTags(String(g).replace(/"/g,"''"));null!=e.title&&("function"==typeof e.title&&(z=e.title.call(this,f,a,b)),"string"==typeof e.title&&(z=e.title))}g='
'+o+String(g)+"
"}if(null==g&&(g=""),"string"==typeof e.render){var r=e.render.toLowerCase().split(":");["number","int","float","money","currency","percent","size"].indexOf(r[0])!=-1&&(k+="text-align: right;")}f&&f.w2ui&&("object"==typeof f.w2ui.style&&("string"==typeof f.w2ui.style[b]&&(k+=f.w2ui.style[b]+";"),"string"==typeof f.w2ui.style[e.field]&&(k+=f.w2ui.style[e.field]+";")),"object"==typeof f.w2ui.class&&("string"==typeof f.w2ui.class[b]&&(l+=f.w2ui.class[b]+" "),"string"==typeof f.w2ui.class[e.field]&&(l+=f.w2ui.class[e.field]+" ")));var A=!1;return n&&$.inArray(b,m.columns[a])!=-1&&(A=!0),g='
",a===-1&&c===!0&&(g='"),g},showBubble:function(a,b){var c="",d=this.columns[b].info,e=this.records[a],f=$(this.box).find("#grid_"+this.name+"_data_"+a+"_"+b+" .w2ui-info");if(this.last.bubbleEl&&$(this.last.bubbleEl).w2tag(),this.last.bubbleEl=f,null==d.fields){d.fields=[];for(var g=0;g1&&(w2utils.formatters[j[1]]?k=w2utils.formatters[j[1]](k,j[2]||null):console.log('ERROR: w2utils.formatters["'+j[1]+'"] does not exists.')),(d.showEmpty===!0||null!=k&&""!=k)&&(null!=d.maxLength&&"string"==typeof k&&k.length>d.maxLength&&(k=k.substr(0,d.maxLength)+"..."),c+="")}else c+=''}c+="
"+(c!==!0?this.getLineHTML(b,d):"")+"'+(c===!0||d.w2ui&&d.w2ui.hideCheckBox===!0?"":'
')+"
'+(c!==!0?'
"+p+"
":"")+"
1?'colspan="'+d+'"':"")+">"+g+"1?'colspan="'+d+'"':"")+">
"+h.text+""+((0===k?"0":k)||"")+"
"}else if($.isPlainObject(i)){c='';for(var l in i){var m=i[l];if(""!=m&&"-"!=m&&"--"!=m&&"---"!=m){var j=String(m).split(":"),h=this.getColumn(j[0]);null==h&&(h={field:j[0],caption:j[0]});var k=h?this.parseField(e,h.field):"";j.length>1&&(w2utils.formatters[j[1]]?k=w2utils.formatters[j[1]](k,j[2]||null):console.log('ERROR: w2utils.formatters["'+j[1]+'"] does not exists.')),"function"==typeof m&&(k=m(e,a,b)),(d.showEmpty===!0||null!=k&&""!=k)&&(null!=d.maxLength&&"string"==typeof k&&k.length>d.maxLength&&(k=k.substr(0,d.maxLength)+"..."),c+="")}else c+=''}c+="
"+l+""+(k||"")+"
"}$(f).w2tag($.extend({html:c,left:-4,position:"bottom|top",className:"w2ui-info-bubble",style:"",hideOnClick:!0},d.options||{}))},getCellEditable:function(a,b){var c=this.columns[b],d=this.records[a];if(!d||!c)return null;var e=d.w2ui?d.w2ui.editable:null;if(e===!1)return null;if((null==e||e===!0)&&(e=c?c.editable:null,"function"==typeof e)){var f=this.getCellValue(a,b,!1);e=e.call(this,d,a,b,f)}return e},getCellValue:function(a,b,c){var d=this.columns[b],e=c!==!0?this.records[a]:this.summary[a],f=this.parseField(e,d.field);return e&&e.w2ui&&e.w2ui.changes&&null!=e.w2ui.changes[d.field]&&(f=e.w2ui.changes[d.field]),$.isPlainObject(f)&&(d.options&&d.options.items?(val=d.options.items.find(function(a){return a.id==f.id}),f=val?val.text:f.id):(null!=f.text&&(f=f.text),null!=f.id&&(f=f.id))),null==f&&(f=""),f},getFooterHTML:function(){return'
'},status:function(a){if(null!=a)$("#grid_"+this.name+"_footer").find(".w2ui-footer-left").html(a);else{var b="",c=this.getSelection();if(c.length>0&&(this.show.statusSelection&&c.length>1&&(b=String(c.length).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")+" "+w2utils.lang("selected")),this.show.statusRecordID&&1==c.length)){var d=c[0];"object"==typeof d&&(d=d.recid+", "+w2utils.lang("Column")+": "+d.column),b=w2utils.lang("Record ID")+": "+d+" "}$("#grid_"+this.name+"_footer .w2ui-footer-left").html(b),1==c.length?this.toolbar.enable("w2ui-edit"):this.toolbar.disable("w2ui-edit"),c.length>=1?this.toolbar.enable("w2ui-delete"):this.toolbar.disable("w2ui-delete")}},lock:function(a,b){var c=this,d=Array.prototype.slice.call(arguments,0);d.unshift(this.box),setTimeout(function(){$(c.box).find("#grid_"+c.name+"_empty_msg").remove(),w2utils.lock.apply(window,d)},10)},unlock:function(a){var b=this.box;setTimeout(function(){$(b).find(".w2ui-message").not(".w2ui-closing").length>0||w2utils.unlock(b,a)},25)},stateSave:function(a){var b=this;if(!w2utils.hasLocalStorage)return null;for(var c,d={columns:[],show:$.extend({},this.show),last:{search:this.last.search,multi:this.last.multi,logic:this.last.logic,label:this.last.label,field:this.last.field,scrollTop:this.last.scrollTop,scrollLeft:this.last.scrollLeft},sortData:[],searchData:[]},e=0;e0&&b.localSort(),b.searchData.length>0&&b.localSearch()),b.last.scrollTop=f,b.last.scrollLeft=g,b.refresh()},1)}return this.trigger($.extend(e,{phase:"after"})),!0},stateReset:function(){if(this.stateRestore(this.last.state),w2utils.hasLocalStorage)try{var a=$.parseJSON(localStorage.w2ui||"{}");a.states&&a.states[this.stateId||this.name]&&delete a.states[this.stateId||this.name],localStorage.w2ui=JSON.stringify(a)}catch(a){return delete localStorage.w2ui,null}},parseField:function(a,b){if(this.nestedFields){var c="";try{c=a;for(var d=String(b).split("."),e=0;e=this.columns.length)return null;var e=this.records[a].w2ui,f=(this.columns[b],this.columns[d]),g=e&&e.colspan&&!isNaN(e.colspan[f.field])?parseInt(e.colspan[f.field]):1;if(null==f)return null;if(f&&f.hidden||0===g)return this.nextCell(a,d,c);if(c){var h=this.getCellEditable(a,b);if(null==h||["checkbox","check"].indexOf(h.type)!=-1)return this.nextCell(a,d,c)}return d},prevCell:function(a,b,c){var d=b-1;if(d<0)return null;var e=this.records[a].w2ui,f=this.columns[d],g=e&&e.colspan&&!isNaN(e.colspan[f.field])?parseInt(e.colspan[f.field]):1;if(null==f)return null;if(f&&f.hidden||0===g)return this.prevCell(a,d,c);if(c){var h=this.getCellEditable(a,b);if(null==h||["checkbox","check"].indexOf(h.type)!=-1)return this.prevCell(a,d,c)}return d},nextRow:function(a,b){var c=this.last.searchIds,d=null;if(a+10&&a0)for(;;){if($.inArray(a,c)!=-1||a>this.records.length)break;a++}var e=this.records[a].w2ui,f=this.columns[b],g=e&&e.colspan&&null!=f&&!isNaN(e.colspan[f.field])?parseInt(e.colspan[f.field]):1;d=0===g?this.nextRow(a,b):a}return d},prevRow:function(a,b){var c=this.last.searchIds,d=null;if(a>0&&0===c.length||c.length>0&&a>c[0]){if(a--,c.length>0)for(;;){if($.inArray(a,c)!=-1||a<0)break;a--}var e=this.records[a].w2ui,f=this.columns[b],g=e&&e.colspan&&null!=f&&!isNaN(e.colspan[f.field])?parseInt(e.colspan[f.field]):1;d=0===g?this.prevRow(a,b):a}return d},selectionSave:function(){return this.last._selection=this.getSelection(),this.last._selection},selectionRestore:function(a){var b=(new Date).getTime();this.last.selection={indexes:[],columns:{}};for(var c=this.last.selection,d=this.last._selection,e=0;e'+a+"",buttons:'",onOpen:function(a){setTimeout(function(){$(this.box).find(".w2ui-btn").focus()},25)},onClose:function(a){"function"==typeof b&&b()}}),w2utils.message.call(this,{box:this.box,path:"w2ui."+this.name,title:".w2ui-grid-header:visible",body:".w2ui-grid-box"},a)}},$.extend(w2grid.prototype,w2utils.event),w2obj.grid=w2grid}(jQuery),function(a){var b=function(b){this.box=null,this.name=null,this.panels=[],this.tmp={},this.padding=1,this.resizer=4,this.style="",a.extend(!0,this,w2obj.layout,b)},c=["top","left","main","preview","right","bottom"];a.fn.w2layout=function(d){function e(b,c,d){var e=b.get(c);return null!=e&&null==d&&(d=e.tabs),null!=e&&null!=d&&(a.isArray(d)&&(d={tabs:d}),a().w2destroy(b.name+"_"+c+"_tabs"),e.tabs=a().w2tabs(a.extend({},d,{owner:b,name:b.name+"_"+c+"_tabs"})),e.show.tabs=!0,!0)}function f(b,c,d){var e=b.get(c);return null!=e&&null==d&&(d=e.toolbar),null!=e&&null!=d&&(a.isArray(d)&&(d={items:d}),a().w2destroy(b.name+"_"+c+"_toolbar"),e.toolbar=a().w2toolbar(a.extend({},d,{owner:b,name:b.name+"_"+c+"_toolbar"})),e.show.toolbar=!0,!0)}if(a.isPlainObject(d)){if(!w2utils.checkName(d,"w2layout"))return;var g=d.panels||[],h=new b(d);a.extend(h,{handlers:[],panels:[]});for(var i=0,j=g.length;i0&&h.render(a(this)[0]),w2ui[h.name]=h,h}var l=w2ui[a(this).attr("name")];return l?arguments.length>0?(l[d]&&l[d].apply(l,Array.prototype.slice.call(arguments,1)),this):l:null},b.prototype={onShow:null,onHide:null,onResizing:null,onResizerClick:null,onRender:null,onRefresh:null,onContent:null,onResize:null,onDestroy:null,panel:{type:null,title:"",size:100,minSize:20,maxSize:!1,hidden:!1,resizable:!1,overflow:"auto",style:"",content:"",tabs:null,toolbar:null,width:null,height:null,show:{toolbar:!1,tabs:!1},callBack:null,onRefresh:null,onShow:null,onHide:null},content:function(a,b,c){return console.log("NOTICE: layout.content method is deprecated, please use layout.html() instead"),this.html(a,b,c)},html:function(b,c,d){var e=this,f=this.get(b),g={panel:b,html:f.content,error:!1,cancelled:!1,removed:function(a){"function"==typeof a&&(f.callBack=a)}};if("function"==typeof f.callBack&&(f.callBack({panel:b,content:f.content,new_content:c,transition:d||"none"}),f.callBack=null),"css"==b)return a("#layout_"+e.name+"_panel_css").html(""),g.status=!0,g;if(null==f)return console.log("ERROR: incorrect panel name. Panel name can be main, left, right, top, bottom, preview or css"),g.error=!0,g;if(null==c)return g;var h=this.trigger({phase:"before",type:"content",target:b,object:f,content:c,transition:d});if(h.isCancelled===!0)return g.cancelled=!0,g;if(c instanceof jQuery)return console.log("ERROR: You can not pass jQuery object to w2layout.content() method"),g;var i="#layout_"+this.name+"_panel_"+f.type,j=a(i+"> .w2ui-panel-content"),k=0;if(j.length>0&&(a(i).scrollTop(0),k=a(j).position().top),""===f.content)f.content=c,this.refresh(b);else{if(f.content=c,!f.hidden&&null!=d&&""!==d){var l=a(i+"> .w2ui-panel-content");l.after('
');var m=a(i+"> .w2ui-panel-content.new-panel");l.css("top",k),m.css("top",k),"object"==typeof c?(c.box=m[0],c.render()):m.html(c),w2utils.transition(l[0],m[0],d,function(){l.remove(),m.removeClass("new-panel"),m.css("overflow",f.overflow),e.resize(),window.navigator.userAgent.indexOf("MSIE")!=-1&&setTimeout(function(){e.resize()},100)})}this.refresh(b)}return e.trigger(a.extend(h,{phase:"after"})),e.resize(),window.navigator.userAgent.indexOf("MSIE")!=-1&&setTimeout(function(){e.resize()},100),g},message:function(b,c){var d=this;"string"==typeof c&&(c={width:c.length<300?350:550,height:c.length<300?170:250,body:'
'+c+"
",buttons:'",onOpen:function(b){setTimeout(function(){a(this.box).find(".w2ui-btn").focus()},25)}});var e,f=this.get(b),g=a("#layout_"+this.name+"_panel_"+f.type),h=g.css("overflow");c&&(c.onClose&&(e=c.onClose),c.onClose=function(b){"function"==typeof e&&e(b),b.done(function(){a("#layout_"+d.name+"_panel_"+f.type).css("overflow",h)})}),a("#layout_"+this.name+"_panel_"+f.type).css("overflow","hidden"),w2utils.message.call(this,{box:a("#layout_"+this.name+"_panel_"+f.type),param:b,path:"w2ui."+this.name,title:".w2ui-panel-title:visible",body:".w2ui-panel-content"},c)},load:function(b,c,d,e){var f=this;return"css"==b?(a.get(c,function(a,c,d){f.content(b,d.responseText),e&&e()}),!0):null!=this.get(b)&&(a.get(c,function(a,c,g){f.content(b,g.responseText,d),e&&e(),f.resize(),window.navigator.userAgent.indexOf("MSIE")!=-1&&setTimeout(function(){f.resize()},100)}),!0)},sizeTo:function(b,c,d){var e=this,f=e.get(b);return null!=f&&(a(e.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",d!==!0?".2s":"0s")),setTimeout(function(){e.set(b,{size:c})},1),setTimeout(function(){a(e.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),e.resize()},500),!0)},show:function(b,c){var d=this,e=this.trigger({phase:"before",type:"show",target:b,object:this.get(b),immediate:c});if(e.isCancelled!==!0){var f=d.get(b);return null!=f&&(f.hidden=!1,c===!0?(a("#layout_"+d.name+"_panel_"+b).css({opacity:"1"}),d.trigger(a.extend(e,{phase:"after"})),d.resize()):(a("#layout_"+d.name+"_panel_"+b).css({opacity:"0"}),a(d.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",".2s")),setTimeout(function(){d.resize()},1),setTimeout(function(){a("#layout_"+d.name+"_panel_"+b).css({opacity:"1"})},250),setTimeout(function(){a(d.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),d.trigger(a.extend(e,{phase:"after"})),d.resize()},500)),!0)}},hide:function(b,c){var d=this,e=this.trigger({phase:"before",type:"hide",target:b,object:this.get(b),immediate:c});if(e.isCancelled!==!0){var f=d.get(b);return null!=f&&(f.hidden=!0,c===!0?(a("#layout_"+d.name+"_panel_"+b).css({opacity:"0"}),d.trigger(a.extend(e,{phase:"after"})),d.resize()):(a(d.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",".2s")),a("#layout_"+d.name+"_panel_"+b).css({opacity:"0"}),setTimeout(function(){d.resize()},1),setTimeout(function(){a(d.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),d.trigger(a.extend(e,{phase:"after"})),d.resize()},500)),!0)}},toggle:function(a,b){var c=this.get(a);return null!=c&&(c.hidden?this.show(a,b):this.hide(a,b))},set:function(b,c){var d=this.get(b,!0);return null!=d&&(a.extend(this.panels[d],c),null==c.content&&null==c.resizable||this.refresh(b),this.resize(),!0)},get:function(a,b){for(var c=0;c .w2ui-panel-content");return 1!=c.length?null:c[0]},hideToolbar:function(b){var c=this.get(b);c&&(c.show.toolbar=!1,a("#layout_"+this.name+"_panel_"+b+"> .w2ui-panel-toolbar").hide(),this.resize())},showToolbar:function(b){var c=this.get(b);c&&(c.show.toolbar=!0,a("#layout_"+this.name+"_panel_"+b+"> .w2ui-panel-toolbar").show(),this.resize())},toggleToolbar:function(a){var b=this.get(a);b&&(b.show.toolbar?this.hideToolbar(a):this.showToolbar(a))},assignToolbar:function(b,c){"string"==typeof c&&null!=w2ui[c]&&(c=w2ui[c]);var d=this.get(b);d.toolbar=c;var e=a(this.box).find(b+"> .w2ui-panel-toolbar");null!=d.toolbar?(0===e.find("[name="+d.toolbar.name+"]").length?e.w2render(d.toolbar):null!=d.toolbar&&d.toolbar.refresh(),this.showToolbar(b),this.refresh(b)):(e.html(""),this.hideToolbar(b))},hideTabs:function(b){var c=this.get(b);c&&(c.show.tabs=!1,a("#layout_"+this.name+"_panel_"+b+"> .w2ui-panel-tabs").hide(),this.resize())},showTabs:function(b){var c=this.get(b);c&&(c.show.tabs=!0,a("#layout_"+this.name+"_panel_"+b+"> .w2ui-panel-tabs").show(),this.resize())},toggleTabs:function(a){var b=this.get(a);b&&(b.show.tabs?this.hideTabs(a):this.showTabs(a))},render:function(b){function d(){h.tmp.events={resize:function(a){w2ui[h.name].resize()},resizeStart:e,mouseMove:g,mouseUp:f},a(window).on("resize",h.tmp.events.resize)}function e(b,d){if(h.box){d||(d=window.event),a(document).off("mousemove",h.tmp.events.mouseMove).on("mousemove",h.tmp.events.mouseMove),a(document).off("mouseup",h.tmp.events.mouseUp).on("mouseup",h.tmp.events.mouseUp),h.tmp.resize={type:b,x:d.screenX,y:d.screenY,diff_x:0,diff_y:0,value:0};for(var e=0;e0?f.attr("locked","previous"):h.lock(c[e],{opacity:0})}"left"!=b&&"right"!=b||(h.tmp.resize.value=parseInt(a("#layout_"+h.name+"_resizer_"+b)[0].style.left)),"top"!=b&&"preview"!=b&&"bottom"!=b||(h.tmp.resize.value=parseInt(a("#layout_"+h.name+"_resizer_"+b)[0].style.top))}}function f(b){if(h.box&&(b||(b=window.event),a(document).off("mousemove",h.tmp.events.mouseMove),a(document).off("mouseup",h.tmp.events.mouseUp),null!=h.tmp.resize)){for(var d=0;dc.width&&(g=c.minSize-c.width),c.maxSize&&c.width+g>c.maxSize&&(g=c.maxSize-c.width),j.minSize+g>j.width&&(g=j.width-j.minSize);break;case"right":c.minSize+g>c.width&&(g=c.width-c.minSize),c.maxSize&&c.width-g>c.maxSize&&(g=c.width-c.maxSize),j.minSize-g>j.width&&(g=j.minSize-j.width);break;case"top":c.minSize-i>c.height&&(i=c.minSize-c.height),c.maxSize&&c.height+i>c.maxSize&&(i=c.maxSize-c.height),j.minSize+i>j.height&&(i=j.height-j.minSize);break;case"preview":case"bottom":c.minSize+i>c.height&&(i=c.height-c.minSize),c.maxSize&&c.height-i>c.maxSize&&(i=c.height-c.maxSize),j.minSize-i>j.height&&(i=j.minSize-j.height)}switch(d.diff_x=g,d.diff_y=i,d.type){case"top":case"preview":case"bottom":d.diff_x=0,f.length>0&&(f[0].style.top=d.value+d.diff_y+"px");break;case"left":case"right":d.diff_y=0,f.length>0&&(f[0].style.left=d.value+d.diff_x+"px")}h.trigger(a.extend(e,{phase:"after"}))}}}var h=this,i=(new Date).getTime(),j=h.trigger({phase:"before",type:"render",target:h.name,box:b});if(j.isCancelled!==!0){if(null!=b&&(a(h.box).find("#layout_"+h.name+"_panel_main").length>0&&a(h.box).removeAttr("name").removeClass("w2ui-layout").html(""),h.box=b),!h.box)return!1;a(h.box).attr("name",h.name).addClass("w2ui-layout").html("
"),a(h.box).length>0&&(a(h.box)[0].style.cssText+=h.style);for(var k=0;k
');a(h.box).find(" > div").append(l)}return a(h.box).find(" > div").append('
'),h.refresh(),h.trigger(a.extend(j,{phase:"after"})),setTimeout(function(){d(),h.resize()},0),(new Date).getTime()-i}},refresh:function(b){var c=this;null==b&&(b=null);var d=(new Date).getTime(),e=c.trigger({phase:"before",type:"refresh",target:null!=b?b:c.name,object:c.get(b)});if(e.isCancelled!==!0){if("string"==typeof b){var f=c.get(b);if(null==f)return;var g="#layout_"+c.name+"_panel_"+f.type,h="#layout_"+c.name+"_resizer_"+f.type;a(g).css({display:f.hidden?"none":"block"}),f.resizable?a(h).show():a(h).hide(),"object"==typeof f.content&&"function"==typeof f.content.render?(f.content.box=a(g+"> .w2ui-panel-content")[0],setTimeout(function(){a(g+"> .w2ui-panel-content").length>0&&(a(g+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").css("overflow",f.overflow)[0].style.cssText+=";"+f.style),f.content&&"function"==typeof f.content.render&&f.content.render()},1)):a(g+"> .w2ui-panel-content").length>0&&(a(g+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").html(f.content).css("overflow",f.overflow)[0].style.cssText+=";"+f.style);var i=a(c.box).find(g+"> .w2ui-panel-tabs");f.show.tabs?0===i.find("[name="+f.tabs.name+"]").length&&null!=f.tabs?i.w2render(f.tabs):f.tabs.refresh():i.html("").removeClass("w2ui-tabs").hide(),i=a(c.box).find(g+"> .w2ui-panel-toolbar"),f.show.toolbar?0===i.find("[name="+f.toolbar.name+"]").length&&null!=f.toolbar?i.w2render(f.toolbar):f.toolbar.refresh():i.html("").removeClass("w2ui-toolbar").hide(),i=a(c.box).find(g+"> .w2ui-panel-title"),f.title?i.html(f.title).show():i.html("").hide()}else{if(0===a("#layout_"+c.name+"_panel_main").length)return void c.render();c.resize();for(var j=0;j div").css({width:f+"px",height:g+"px"});for(var h,i,j,k,l,m=this,n=this.get("main"),o=this.get("preview"),p=this.get("left"),q=this.get("right"),r=this.get("top"),s=this.get("bottom"),t=null!=o&&o.hidden!==!0,u=null!=p&&p.hidden!==!0,v=null!=q&&q.hidden!==!0,w=null!=r&&r.hidden!==!0,x=null!=s&&s.hidden!==!0,y=0;ythis.padding?this.resizer:this.padding,a("#layout_"+this.name+"_resizer_top").show().css({display:"block",left:h+"px",top:i+"px",width:j+"px",height:k+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(b){var c=m.trigger({phase:"before",type:"resizerClick",target:"top",originalEvent:b});if(c.isCancelled!==!0)return w2ui[m.name].tmp.events.resizeStart("top",b),m.trigger(a.extend(c,{phase:"after"})),!1}))):(a("#layout_"+this.name+"_panel_top").hide(),a("#layout_"+this.name+"_resizer_top").hide()),null!=p&&p.hidden!==!0?(h=0,i=0+(w?r.sizeCalculated+this.padding:0),j=p.sizeCalculated,k=g-(w?r.sizeCalculated+this.padding:0)-(x?s.sizeCalculated+this.padding:0),l=a("#layout_"+this.name+"_panel_left"),window.navigator.userAgent.indexOf("MSIE")!=-1&&l.length>0&&l[0].clientHeightthis.padding?this.resizer:this.padding,a("#layout_"+this.name+"_resizer_left").show().css({display:"block",left:h+"px",top:i+"px",width:j+"px",height:k+"px",cursor:"ew-resize"}).off("mousedown").on("mousedown",function(b){var c=m.trigger({phase:"before",type:"resizerClick",target:"left",originalEvent:b});if(c.isCancelled!==!0)return w2ui[m.name].tmp.events.resizeStart("left",b),m.trigger(a.extend(c,{phase:"after"})),!1}))):(a("#layout_"+this.name+"_panel_left").hide(), @@ -11,5 +11,5 @@ a("#layout_"+this.name+"_resizer_left").hide()),null!=q&&q.hidden!==!0?(h=f-q.si },onKeydown:function(a){if(0===d("#w2ui-popup .w2ui-message").length)switch(a.originalEvent.keyCode){case 13:d("#w2ui-popup .w2ui-popup-btn#Ok").focus().addClass("clicked"),w2popup.close();break;case 27:w2popup.close()}}})),{change:function(a){return d("#w2prompt").on("keyup",a).keyup(),this},ok:function(a){return e.callBack=a,this}}};!function(a){var b=function(b){this.box=null,this.name=null,this.active=null,this.flow="down",this.tooltip="top|left",this.tabs=[],this.routeData={},this.right="",this.style="",a.extend(this,{handlers:[]}),a.extend(!0,this,w2obj.tabs,b)};a.fn.w2tabs=function(c){if(a.isPlainObject(c)){if(!w2utils.checkName(c,"w2tabs"))return;for(var d=c.tabs||[],e=new b(c),f=0;f0?(g[c]&&g[c].apply(g,Array.prototype.slice.call(arguments,1)),this):g:null},b.prototype={onClick:null,onClose:null,onRender:null,onRefresh:null,onResize:null,onDestroy:null,tab:{id:null,text:null,route:null,hidden:!1,disabled:!1,closable:!1,tooltip:null,style:"",onClick:null,onRefresh:null,onClose:null},add:function(a){return this.insert(null,a)},insert:function(c,d){a.isArray(d)||(d=[d]);for(var e=0;e ",f),null!=f.hint&&console.log("NOTICE: tabs tab.hint property is deprecated, please use tab.tooltip. Tab -> ",f);var g=f.text;"function"==typeof g&&(g=g.call(this,f)),null==g&&(g="");var h=a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(f.id)),i="";f.closable&&!f.disabled&&(i='
");var j=i+'
"+w2utils.lang(g)+"
";if(0===h.length){var k="";f.hidden&&(k+="display: none;"),f.disabled&&(k+="opacity: 0.2;");var l=''+j+"";this.get(b,!0)!==this.tabs.length-1&&a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(b,!0))+1].id)).length>0?a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(b,!0))+1].id)).before(l):a(this.box).find("#tabs_"+this.name+"_right").before(l)}else h.html(j),f.hidden?h.css("display","none"):h.css("display",""),f.disabled?h.css({opacity:"0.2"}):h.css({opacity:"1"})}return a("#tabs_"+this.name+"_right").html(this.right),this.trigger(a.extend(d,{phase:"after"})),(new Date).getTime()-c}},render:function(b){var c=(new Date).getTime(),d=this.trigger({phase:"before",type:"render",target:this.name,box:b});if(d.isCancelled!==!0){if(null!=b&&(a(this.box).find("> table #tabs_"+this.name+"_right").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-tabs").html(""),this.box=b),!this.box)return!1;var e='
'+this.right+'
";return a(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-tabs").html(e),a(this.box).length>0&&(a(this.box)[0].style.cssText+=this.style),this.trigger(a.extend(d,{phase:"after"})),this.refresh(),this.resize(),(new Date).getTime()-c}},scroll:function(b){var c,d,e,f=a(this.box),g=this,h=f.find(".w2ui-scroll-wrapper"),i=h.scrollLeft();switch(b){case"left":c=h.outerWidth(),d=h.find(":first").outerWidth(),e=i-c+50,e<=0&&(e=0),h.animate({scrollLeft:e},300);break;case"right":c=h.outerWidth(),d=h.find(":first").outerWidth(),e=i+c-50,e>=d-c&&(e=d-c),h.animate({scrollLeft:e},300)}setTimeout(function(){g.resize()},350)},resize:function(){var b=(new Date).getTime(),c=this.trigger({phase:"before",type:"resize",target:this.name});if(c.isCancelled!==!0){var d=a(this.box);d.find(".w2ui-scroll-left, .w2ui-scroll-right").hide();var e=d.find(".w2ui-scroll-wrapper");return e.find(":first").outerWidth()>e.outerWidth()&&(e.scrollLeft()>0&&d.find(".w2ui-scroll-left").show(),e.scrollLeft() table #tabs_"+this.name+"_right").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-tabs").html(""),delete w2ui[this.name],this.trigger(a.extend(b,{phase:"after"})))},click:function(b,c){var d=this.get(b);if(null==d||d.disabled)return!1;var e=this.trigger({phase:"before",type:"click",target:b,tab:d,object:d,originalEvent:c});if(e.isCancelled!==!0){if(a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.active)+" .w2ui-tab").removeClass("active"),this.active=d.id,"string"==typeof d.route){var f=""!==d.route?String("/"+d.route).replace(/\/{2,}/g,"/"):"",g=w2utils.parseRoute(f);if(g.keys.length>0)for(var h=0;h'),setTimeout(function(){a(f.box).find("#tabs_"+f.name+"_tab_"+w2utils.escapeId(d.id)).find(":first-child").css({width:"0px"})},50)},200),setTimeout(function(){f.remove(b)},450),this.trigger(a.extend(e,{phase:"after"})),this.refresh()}},animateInsert:function(b,c){if(null!=this.get(b)&&a.isPlainObject(c)&&w2utils.checkUniqueId(c.id,this.tabs,"tabs",this.name)){var d=a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(c.id));if(0===d.length){null==c.text&&null!=c.caption&&(c.text=c.caption);var e='
'+(c.closable?'
':"")+'
'+c.text+"
";a("body").append(e);var f='
 
',g="";c.hidden&&(g+="display: none;"),c.disabled&&(g+="opacity: 0.2;");var h=''+f+"";this.get(b,!0)!==this.tabs.length&&a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(b,!0))].id)).length>0?a(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(b,!0))].id)).before(h):a(this.box).find("#tabs_"+this.name+"_right").before(h);var i=this;setTimeout(function(){var b=a("#_tmp_simple_tab").width();a("#_tmp_tabs").remove(),a("#tabs_"+i.name+"_tab_"+w2utils.escapeId(c.id)+" > div").css("width",b+"px")},1),setTimeout(function(){i.insert(b,c)},200)}}}},a.extend(b.prototype,w2utils.event),w2obj.tabs=b}(jQuery),function(a){var b=function(b){this.box=null,this.name=null,this.routeData={},this.items=[],this.right="",this.tooltip="top|left",a.extend(!0,this,w2obj.toolbar,b)};a.fn.w2toolbar=function(c){if(a.isPlainObject(c)){if(!w2utils.checkName(c,"w2toolbar"))return;var d=c.items||[],e=new b(c);a.extend(e,{items:[],handlers:[]});for(var f=0;f0?(j[c]&&j[c].apply(j,Array.prototype.slice.call(arguments,1)),this):j:null},b.prototype={onClick:null,onRender:null,onRefresh:null,onResize:null,onDestroy:null,item:{id:null,type:"button",text:null,html:"",tooltip:null,count:null,hidden:!1,disabled:!1,checked:!1,img:null,icon:null,route:null,arrow:!0,style:null,group:null,items:null,selected:null,overlay:{},color:null,options:{advanced:!1,transparent:!0,html:""},onClick:null,onRefresh:null},add:function(a){this.insert(null,a)},insert:function(c,d){a.isArray(d)||(d=[d]);for(var e=0;e1){var g=this.get(b);return void(g&&!g.disabled&&d.menuClick({name:d.name,item:f,subItem:g,originalEvent:c}))}if(f&&!f.disabled){var h=this.trigger({phase:"before",type:"click",target:null!=b?b:this.name,item:f,object:f,originalEvent:c});if(h.isCancelled===!0)return;var i="#tb_"+this.name+"_item_"+w2utils.escapeId(f.id)+" table.w2ui-button";if(a(i).removeClass("down"),"radio"==f.type){for(var j=0;j19&&(e=19),"drop"==f.type&&c.w2overlay(f.html,a.extend({name:d.name,left:e,top:3},f.overlay,{onHide:function(a){b()}})),["menu","menu-radio","menu-check"].indexOf(f.type)!=-1){var g="normal";"menu-radio"==f.type&&(g="radio",f.items.forEach(function(a){f.selected==a.id?a.checked=!0:a.checked=!1})),"menu-check"==f.type&&(g="check",f.items.forEach(function(b){a.isArray(f.selected)&&f.selected.indexOf(b.id)!=-1?b.checked=!0:b.checked=!1})),c.w2menu(a.extend({name:d.name,items:f.items,left:e,top:3},f.overlay,{type:g,select:function(a){d.menuClick({name:d.name,item:f,subItem:a.item,originalEvent:a.originalEvent,keepOpen:a.keepOpen})},onHide:function(a){b()}}))}["color","text-color"].indexOf(f.type)!=-1&&a(c).w2color(a.extend({color:f.color,onHide:function(a){b(),d._tmpColor&&d.colorClick({name:d.name,item:f,color:d._tmpColor,final:!0}),delete d._tmpColor},onSelect:function(a){null!=a&&(d.colorClick({name:d.name,item:f,color:a}),d._tmpColor=a)}},f.options))},1)),["check","menu","menu-radio","menu-check","drop","color","text-color"].indexOf(f.type)!=-1&&(f.checked=!f.checked,f.checked?a(i).addClass("checked"):a(i).removeClass("checked")),f.route){var l=String("/"+f.route).replace(/\/{2,}/g,"/"),m=w2utils.parseRoute(l);if(m.keys.length>0)for(var n=0;n=d-c&&(e=d-c),h.animate({scrollLeft:e},300)}setTimeout(function(){g.resize()},350)},render:function(b){var c=(new Date).getTime(),d=this.trigger({phase:"before",type:"render",target:this.name,box:b});if(d.isCancelled!==!0&&(null!=b&&(a(this.box).find("> table #tb_"+this.name+"_right").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-toolbar").html(""),this.box=b),this.box)){for(var e='
',f=0;f ",g),null!=g.hint&&console.log("NOTICE: toolbar item.hint property is deprecated, please use item.tooltip. Item -> ",g),e+="spacer"==g.type?'':'')}return e+='",e+='
'+this.right+"
",a(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-toolbar").html(e),a(this.box).length>0&&(a(this.box)[0].style.cssText+=this.style),this.refresh(),this.resize(),this.trigger(a.extend(d,{phase:"after"})),(new Date).getTime()-c}},refresh:function(b){var c=(new Date).getTime(),d=this.trigger({phase:"before",type:"refresh",target:null!=b?b:this.name,item:this.get(b)});if(d.isCancelled!==!0){if(null!=b){var e=this.get(b);if(null==e)return!1;if("function"==typeof e.onRefresh){var f=this.trigger({phase:"before",type:"refresh",target:b,item:e,object:e});if(f.isCancelled===!0)return}var g=a(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(e.id)),h=this.getItemHTML(e);return this.tooltipHide(b,{}),0===g.length?(h="spacer"==e.type?'':''+h+"",this.get(b,!0)==this.items.length-1?a(this.box).find("#tb_"+this.name+"_right").before(h):a(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(this.items[parseInt(this.get(b,!0))+1].id)).before(h)):(["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(e.type)!=-1&&0==e.checked&&a("#w2ui-overlay-"+this.name).length>0&&a("#w2ui-overlay-"+this.name)[0].hide(),g.html(h),e.hidden?g.css("display","none"):g.css("display",""),e.disabled?g.addClass("disabled"):g.removeClass("disabled")),"function"==typeof e.onRefresh&&this.trigger(a.extend(f,{phase:"after"})),this.trigger(a.extend(d,{phase:"after"})),(new Date).getTime()-c}for(var i=0;ie.outerWidth()&&(e.scrollLeft()>0&&d.find(".w2ui-scroll-left").show(),e.scrollLeft() table #tb_"+this.name+"_right").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-toolbar").html(""),a(this.box).html(""),delete w2ui[this.name],this.trigger(a.extend(b,{phase:"after"})))},getItemHTML:function(a){var b="";null!=a.caption&&null==a.text&&(a.text=a.caption),null==a.text&&(a.text=""),null==a.tooltip&&null!=a.hint&&(a.tooltip=a.hint),null==a.tooltip&&(a.tooltip="");var c=" ",d="function"==typeof a.text?a.text.call(this,a):a.text;if(a.img&&(c='
'),a.icon&&(c='
'),""===b)switch(a.type){case"color":case"text-color":"string"==typeof a.color&&("#"==a.color.substr(0,1)&&(a.color=a.color.substr(1)),3!=a.color.length&&6!=a.color.length||(a.color="#"+a.color)),"color"==a.type&&(d='
'+(a.text?'
'+w2utils.lang(a.text)+"
":"")),"text-color"==a.type&&(d='
'+(a.text?w2utils.lang(a.text):"Aa")+"
");case"menu":case"menu-check":case"menu-radio":case"button":case"check":case"radio":case"drop":b+='
'+c+(""!==d?'":"")+(null!=a.count?'":"")+(["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(a.type)!=-1&&a.arrow!==!1?'':"")+"
'+w2utils.lang(d)+"'+a.count+"
";break;case"break":b+='
 
';break;case"html":b+='
'+("function"==typeof a.html?a.html.call(this,a):a.html)+"
"}return"
"+b+"
"},tooltipShow:function(b,c,d){if(null!=this.tooltip){var e=a(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(b)),f=this.get(b),g=this.tooltip,h=f.tooltip;"function"==typeof h&&(h=h.call(this,f)),clearTimeout(this._tooltipTimer),this._tooltipTimer=setTimeout(function(){if(e.prop("_mouse_tooltip")!==!0){if(e.prop("_mouse_tooltip",!0),["menu","menu-radio","menu-check","drop","color","text-color"].indexOf(f.type)!=-1&&1==f.checked)return;e.w2tag(w2utils.lang(h),{position:g})}},0),e.prop("_mouse_tooltip")&&1==d&&e.w2tag(w2utils.lang(h),{position:g})}},tooltipHide:function(b,c){if(null!=this.tooltip){var d=a(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(b));this.get(b);clearTimeout(this._tooltipTimer),setTimeout(function(){d.prop("_mouse_tooltip")===!0&&(d.removeProp("_mouse_tooltip"),d.w2tag())},1)}},menuClick:function(b){var c=this;if(b.item&&!b.item.disabled){var d=this.trigger({phase:"before",type:"click",target:b.item.id+":"+b.subItem.id,item:b.item,subItem:b.subItem,originalEvent:b.originalEvent});if(d.isCancelled===!0)return;var e=b.subItem,f=this.get(b.item.id);if("menu-radio"==f.type&&(f.selected=e.id,b.item.items.forEach(function(a){a.checked=!1}),e.checked=!0),"menu-check"==f.type)if(a.isArray(f.selected)||(f.selected=[]),null==e.group){var g=f.selected.indexOf(e.id);g==-1?(f.selected.push(e.id),e.checked=!0):(f.selected.splice(g,1),e.checked=!1)}else{var h=[];f.items.forEach(function(a){if(a.group===e.group){var b=f.selected.indexOf(a.id);b!=-1&&(a.id!=e.id&&h.push(a.id),f.selected.splice(b,1))}});var g=f.selected.indexOf(e.id);g==-1&&(f.selected.push(e.id),e.checked=!0)}if("string"==typeof e.route){var i=""!==e.route?String("/"+e.route).replace(/\/{2,}/g,"/"):"",j=w2utils.parseRoute(i);if(j.keys.length>0)for(var k=0;k0?(f[c]&&f[c].apply(f,Array.prototype.slice.call(arguments,1)),this):f:null},b.prototype={onClick:null,onDblClick:null,onContextMenu:null,onMenuClick:null,onExpand:null,onCollapse:null,onKeydown:null,onRender:null,onRefresh:null,onResize:null,onDestroy:null,onFocus:null,onBlur:null,onFlat:null,node:{id:null,text:"",count:null,img:null,icon:null,nodes:[],style:"",route:null,selected:!1,expanded:!1,hidden:!1,disabled:!1,group:!1,groupShowHide:!0,collapsible:!0,plus:!1,onClick:null,onDblClick:null,onContextMenu:null,onExpand:null,onCollapse:null,parent:null,sidebar:null},add:function(a,b){return 1==arguments.length&&(b=arguments[0],a=this),"string"==typeof a&&(a=this.get(a)),this.insert(a,null,b)},insert:function(c,d,e){var f,g,h,i,j;if(2==arguments.length)if(e=arguments[1],d=arguments[0],null!=d){if(g=this.get(d),null==g)return a.isArray(e)||(e=[e]),null!=e[0].caption&&null==e[0].text&&(console.log("NOTICE: sidebar node.caption property is deprecated, please use node.text. Node -> ",e[0]),e[0].text=e[0].caption),f=e[0].text,console.log('ERROR: Cannot insert node "'+f+'" because cannot find node "'+d+'" to insert before.'),null;c=this.get(d).parent}else c=this;"string"==typeof c&&(c=this.get(c)),a.isArray(e)||(e=[e]);for(var k=0;k0&&this.insert(h,null,j)}else console.log("ERROR: Cannot insert node with id="+i.id+" (text: "+i.text+") because another node with the same id already exists.");else null!=i.caption&&null==i.text&&(console.log("NOTICE: sidebar node.caption property is deprecated, please use node.text"),i.text=i.caption),f=i.text,console.log('ERROR: Cannot insert node "'+f+'" because it has no id.');return this.refresh(c.id),h},remove:function(){for(var a,b=0,c=0;c0&&1==arguments.length?this.refresh(a.parent.id):this.refresh(), b},set:function(b,c,d){if(2==arguments.length&&(d=c,c=b,b=this),"string"==typeof b&&(b=this.get(b)),null==b.nodes)return null;for(var e=0;e0&&(c=this.find(a.nodes[d],b,c))}return c},hide:function(){for(var a=0,b=0;b+'),d.expanded=!1,this.trigger(a.extend(e,{phase:"after"})),setTimeout(function(){c.refresh(b)},200),!0},collapseAll:function(a){if(null==a&&(a=this),"string"==typeof a&&(a=this.get(a)),null==a.nodes)return!1;for(var b=0;b0&&this.collapseAll(a.nodes[b]);return this.refresh(a.id),!0},expand:function(b){var c=this,d=this.get(b),e=this.trigger({phase:"before",type:"expand",target:b,object:d});if(e.isCancelled!==!0)return a(this.box).find("#node_"+w2utils.escapeId(b)+"_sub").slideDown(200),a(this.box).find("#node_"+w2utils.escapeId(b)+" .w2ui-node-dots:first-child").html('
-
'),d.expanded=!0,this.trigger(a.extend(e,{phase:"after"})),setTimeout(function(){c.refresh(b)},200),!0},expandAll:function(a){if(null==a&&(a=this),"string"==typeof a&&(a=this.get(a)),null==a.nodes)return!1;for(var b=0;b0&&this.expandAll(a.nodes[b]);this.refresh(a.id)},expandParents:function(a){var b=this.get(a);return null!=b&&(b.parent&&(b.parent.expanded||(b.parent.expanded=!0,this.refresh(b.parent.id)),this.expandParents(b.parent.id)),!0)},click:function(b,c){var d=this,e=this.get(b);if(null!=e&&!e.disabled&&!e.group){a(d.box).find(".w2ui-node.w2ui-selected").each(function(b,c){var e=a(c).attr("id").replace("node_",""),f=d.get(e);null!=f&&(f.selected=!1),a(c).removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected")});var f=a(d.box).find("#node_"+w2utils.escapeId(b)),g=a(d.box).find("#node_"+w2utils.escapeId(d.selected));f.addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected"),setTimeout(function(){var h=d.trigger({phase:"before",type:"click",target:b,originalEvent:c,node:e,object:e});if(h.isCancelled===!0)return f.removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected"),void g.addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected");if(null!=g&&(g.selected=!1),d.get(b).selected=!0,d.selected=b,"string"==typeof e.route){var i=""!==e.route?String("/"+e.route).replace(/\/{2,}/g,"/"):"",j=w2utils.parseRoute(i);if(j.keys.length>0)for(var k=0;k0&&b!==!0){var g=a.nodes[0];f=g.hidden||g.disabled||g.group?e(g):g}else f=c&&d+10?g(b.nodes[c-1]):b;return null!=d&&(d.hidden||d.disabled||d.group)&&(d=f(d)),d}function g(a){if(a.expanded&&a.nodes.length>0){var b=a.nodes[a.nodes.length-1];return b.hidden||b.disabled||b.group?f(b):g(b)}return a}var h=this,i=h.get(h.selected);if(h.keyboard===!0){i||(i=h.nodes[0]);var j=h.trigger({phase:"before",type:"keydown",target:h.name,originalEvent:b});j.isCancelled!==!0&&(13!=b.keyCode&&32!=b.keyCode||i.nodes.length>0&&h.toggle(h.selected),37==b.keyCode&&(i.nodes.length>0&&i.expanded?h.collapse(h.selected):(c(i.parent),i.parent.group||h.collapse(i.parent.id))),39==b.keyCode&&(i.nodes.length>0||i.plus)&&!i.expanded&&h.expand(h.selected),38==b.keyCode&&c(d(i,f)),40==b.keyCode&&c(d(i,e)),a.inArray(b.keyCode,[13,32,37,38,39,40])!=-1&&(b.preventDefault&&b.preventDefault(),b.stopPropagation&&b.stopPropagation()),h.trigger(a.extend(j,{phase:"after"})))}},scrollIntoView:function(b){null==b&&(b=this.selected);var c=this.get(b);if(null!=c){var d=a(this.box).find(".w2ui-sidebar-div"),e=a(this.box).find("#node_"+w2utils.escapeId(b)),f=e.offset().top-d.offset().top;(f+e.height()>d.height()||f<=0)&&d.animate({scrollTop:d.scrollTop()+f-d.height()/2+e.height()},250,"linear")}},dblClick:function(b,c){var d=this.get(b),e=this.trigger({phase:"before",type:"dblClick",target:b,originalEvent:c,object:d});e.isCancelled!==!0&&(this.toggle(b),this.trigger(a.extend(e,{phase:"after"})))},contextMenu:function(b,c){var d=this,e=d.get(b);b!=d.selected&&d.click(b);var f=d.trigger({phase:"before",type:"contextMenu",target:b,originalEvent:c,object:e,allowOnDisabled:!1});f.isCancelled!==!0&&(e.disabled&&!f.allowOnDisabled||(d.menu.length>0&&a(d.box).find("#node_"+w2utils.escapeId(b)).w2menu({items:d.menu,contextMenu:!0,originalEvent:c,onSelect:function(a){d.menuClick(b,parseInt(a.index),a.originalEvent)}}),c.preventDefault&&c.preventDefault(),d.trigger(a.extend(f,{phase:"after"}))))},menuClick:function(b,c,d){var e=this,f=e.trigger({phase:"before",type:"menuClick",target:b,originalEvent:d,menuIndex:c,menuItem:e.menu[c]});f.isCancelled!==!0&&e.trigger(a.extend(f,{phase:"after"}))},goFlat:function(){var b=this.trigger({phase:"before",type:"flat",goFlat:!this.flat});b.isCancelled!==!0&&(this.flat=!this.flat,this.refresh(),this.trigger(a.extend(b,{phase:"after"})))},render:function(b){var c=(new Date).getTime(),d=this,e=this.trigger({phase:"before",type:"render",target:this.name,box:b});if(e.isCancelled!==!0&&(null!=b&&(a(this.box).find("> div > div.w2ui-sidebar-div").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-sidebar").html(""),this.box=b),this.box)){a(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-sidebar").html('
'),a(this.box).find("> div").css({width:a(this.box).width()+"px",height:a(this.box).height()+"px"}),a(this.box).length>0&&(a(this.box)[0].style.cssText+=this.style);var f="";1==this.flatButton&&(f='
"),""===this.topHTML&&""===f||(a(this.box).find(".w2ui-sidebar-top").html(this.topHTML+f),a(this.box).find(".w2ui-sidebar-div").css("top",a(this.box).find(".w2ui-sidebar-top").height()+"px")),""!==this.bottomHTML&&(a(this.box).find(".w2ui-sidebar-bottom").html(this.bottomHTML),a(this.box).find(".w2ui-sidebar-div").css("bottom",a(this.box).find(".w2ui-sidebar-bottom").height()+"px"));var g;return a(this.box).find("#sidebar_"+this.name+"_focus").on("focus",function(a){clearTimeout(g),d.hasFocus||d.focus(a)}).on("blur",function(a){g=setTimeout(function(){d.hasFocus&&d.blur(a)},100)}).on("keydown",function(a){9!=a.keyCode&&w2ui[d.name].keydown.call(w2ui[d.name],a)}),a(this.box).off("mousedown").on("mousedown",function(b){setTimeout(function(){if(["INPUT","TEXTAREA","SELECT"].indexOf(b.target.tagName.toUpperCase())==-1){var c=a(d.box).find("#sidebar_"+d.name+"_focus");if(!c.is(":focus")){if(a(b.target).hasClass("w2ui-node")){var e=a(b.target).position().top+a(d.box).find(".w2ui-sidebar-top").height()+b.offsetY;c.css({top:e+"px",left:"0px"})}c.focus()}}},1)}),this.trigger(a.extend(e,{phase:"after"})),this.refresh(),(new Date).getTime()-c}},refresh:function(b){function c(a){var b="",c=a.img,d=a.icon;null==d&&null==c&&(null==d&&(d=k.icon),null==c&&(c=k.img));for(var e=a.parent,f=0;e&&null!=e.parent;)e.group&&f--,e=e.parent,f++;if(null!=a.caption&&null==a.text&&(a.text=a.caption),null!=a.caption&&(console.log("NOTICE: sidebar node.caption property is deprecated, please use node.text. Node -> ",a),a.text=a.caption),a.group)b='
"+(a.groupShowHide&&a.collapsible?""+(!a.hidden&&a.expanded?w2utils.lang("Hide"):w2utils.lang("Show"))+"":"")+("function"==typeof a.text?a.text.call(k,a):""+a.text+"")+'
',k.flat&&(b='
 
');else{a.selected&&!a.disabled&&(k.selected=a.id),e="",c&&(e='
'),d&&(e='
');var g=a.text;"function"==typeof a.text&&(g=a.text.call(k,a)),b='
'+(a.nodes.length>0?a.expanded?"-":"+":a.plus?"+":"")+'
'+e+(a.count||0===a.count?'
'+a.count+"
":"")+'
'+g+'
',k.flat&&(b='
'+a.count+"":""))+"'), { id: '"+a.id+"', left: -5 })\" onmouseout=\"jQuery(this).find('.w2ui-node-data').w2tag(null, { id: '"+a.id+"' })\" ondblclick=\"w2ui['"+k.name+"'].dblClick('"+a.id+"', event);\" oncontextmenu=\"w2ui['"+k.name+"'].contextMenu('"+a.id+"', event);\" onClick=\"w2ui['"+k.name+"'].click('"+a.id+'\', event); ">
'+e+'
')}return b}var d=(new Date).getTime(),e=this.trigger({phase:"before",type:"refresh",target:null!=b?b:this.name,fullRefresh:null==b});if(e.isCancelled!==!0){var f="";if(1==this.flatButton&&(f='
"),""===this.topHTML&&""===f||(a(this.box).find(".w2ui-sidebar-top").html(this.topHTML+f),a(this.box).find(".w2ui-sidebar-div").css("top",a(this.box).find(".w2ui-sidebar-top").height()+"px")),""!==this.bottomHTML&&(a(this.box).find(".w2ui-sidebar-bottom").html(this.bottomHTML),a(this.box).find(".w2ui-sidebar-div").css("bottom",a(this.box).find(".w2ui-sidebar-bottom").height()+"px")),a(this.box).find("> div").removeClass("w2ui-sidebar-flat").addClass(this.flat?"w2ui-sidebar-flat":"").css({width:a(this.box).width()+"px",height:a(this.box).height()+"px"}),this.nodes.length>0&&null==this.nodes[0].parent){var g=this.nodes;this.nodes=[],this.add(this,g)}var h,i,j,k=this;if(null==b)h=this,j=".w2ui-sidebar-div";else{if(h=this.get(b),null==h)return;j="#node_"+w2utils.escapeId(h.id)+"_sub"}var l;if(h!==this){var g="#node_"+w2utils.escapeId(h.id);l=c(h),a(this.box).find(g).before(''),a(this.box).find(g).remove(),a(this.box).find(j).remove(),a("#sidebar_"+this.name+"_tmp").before(l),a("#sidebar_"+this.name+"_tmp").remove()}a(this.box).find(j).html("");for(var m=0;m div").css({width:a(this.box).width()+"px",height:a(this.box).height()+"px"}),this.trigger(a.extend(c,{phase:"after"})),(new Date).getTime()-b},destroy:function(){var b=this.trigger({phase:"before",type:"destroy",target:this.name});b.isCancelled!==!0&&(a(this.box).find("> div > div.w2ui-sidebar-div").length>0&&a(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-sidebar").html(""),delete w2ui[this.name],this.trigger(a.extend(b,{phase:"after"})))},lock:function(a,b){var c=Array.prototype.slice.call(arguments,0);c.unshift(this.box),w2utils.lock.apply(window,c)},unlock:function(a){w2utils.unlock(this.box,a)}},a.extend(b.prototype,w2utils.event),w2obj.sidebar=b}(jQuery),function(a){var b=function(b){this.el=null,this.helpers={},this.type=b.type||"text",this.options=a.extend(!0,{},b),this.onSearch=b.onSearch||null,this.onRequest=b.onRequest||null,this.onLoad=b.onLoad||null,this.onError=b.onError||null,this.onClick=b.onClick||null,this.onAdd=b.onAdd||null,this.onNew=b.onNew||null,this.onRemove=b.onRemove||null,this.onMouseOver=b.onMouseOver||null,this.onMouseOut=b.onMouseOut||null,this.onIconClick=b.onIconClick||null,this.onScroll=b.onScroll||null,this.tmp={},delete this.options.type,delete this.options.onSearch,delete this.options.onRequest,delete this.options.onLoad,delete this.options.onError,delete this.options.onClick,delete this.options.onMouseOver,delete this.options.onMouseOut,delete this.options.onIconClick,delete this.options.onScroll,a.extend(!0,this,w2obj.field)};a.fn.w2field=function(c,d){if(0!==this.length){if(0===arguments.length){var e=a(this).data("w2field");return e}return"string"==typeof c&&"object"==typeof d&&(c=a.extend(!0,{},d,{type:c})),"string"==typeof c&&null==d&&(c={type:c}),c&&(c.type=String(c.type).toLowerCase()),this.each(function(d,e){var f=a(e).data("w2field");if(null==f)return f=new b(c),a.extend(f,{handlers:[]}),e&&(f.el=a(e)[0]),f.init(),a(e).data("w2field",f),f;if(f.clear(),"clear"!==c.type)return f=new b(c),a.extend(f,{handlers:[]}),e&&(f.el=a(e)[0]),f.init(),a(e).data("w2field",f),f})}var f=b.prototype;if(f[c])return f[c].apply(f,Array.prototype.slice.call(arguments,1))},b.prototype={custom:{},addType:function(a,b){return a=String(a).toLowerCase(),this.custom[a]=b,!0},removeType:function(a){return a=String(a).toLowerCase(),!!this.custom[a]&&(delete this.custom[a],!0)},init:function(){var b,c=this,d=this.options;if("function"==typeof this.custom[this.type])return void this.custom[this.type].call(this,d);if(["INPUT","TEXTAREA"].indexOf(this.el.tagName.toUpperCase())==-1)return void console.log("ERROR: w2field could only be applied to INPUT or TEXTAREA.",this.el);switch(this.type){case"text":case"int":case"float":case"money":case"currency":case"percent":case"alphanumeric":case"bin":case"hex":b={min:null,max:null,step:1,autoFormat:!0,currencyPrefix:w2utils.settings.currencyPrefix,currencySuffix:w2utils.settings.currencySuffix,currencyPrecision:w2utils.settings.currencyPrecision,decimalSymbol:w2utils.settings.decimalSymbol,groupSymbol:w2utils.settings.groupSymbol,arrows:!1,keyboard:!0,precision:null,silent:!0,prefix:"",suffix:""},this.options=a.extend(!0,{},b,d),d=this.options,d.numberRE=new RegExp("["+d.groupSymbol+"]","g"),d.moneyRE=new RegExp("["+d.currencyPrefix+d.currencySuffix+d.groupSymbol+"]","g"),d.percentRE=new RegExp("["+d.groupSymbol+"%]","g"),["text","alphanumeric","hex","bin"].indexOf(this.type)!==-1&&(d.arrows=!1,d.keyboard=!1),this.addPrefix(),this.addSuffix();break;case"color":b={prefix:"",suffix:'
 
',arrows:!1,keyboard:!1,advanced:null,transparent:!0},a.extend(d,b),this.addPrefix(),this.addSuffix(),""!==a(this.el).val()&&setTimeout(function(){c.change()},1);break;case"date":b={format:w2utils.settings.dateFormat,keyboard:!0,silent:!0,start:"",end:"",blocked:{},colored:{},blockWeekDays:null},this.options=a.extend(!0,{},b,d),d=this.options,null==a(this.el).attr("placeholder")&&a(this.el).attr("placeholder",d.format);break;case"time":b={format:w2utils.settings.timeFormat,keyboard:!0,silent:!0,start:"",end:"",noMinutes:!1},this.options=a.extend(!0,{},b,d),d=this.options,null==a(this.el).attr("placeholder")&&a(this.el).attr("placeholder",d.format);break;case"datetime":b={format:w2utils.settings.dateFormat+" | "+w2utils.settings.timeFormat,keyboard:!0,silent:!0,start:"",end:"",blocked:[],colored:{},placeholder:null,btn_now:!0,noMinutes:!1},this.options=a.extend(!0,{},b,d),d=this.options,null==a(this.el).attr("placeholder")&&a(this.el).attr("placeholder",d.placeholder||d.format);break;case"list":case"combo":if(b={items:[],selected:{},url:null,recId:null,recText:null,method:null,interval:350,postData:{},minLength:1,cacheMax:250,maxDropHeight:350,maxDropWidth:null,match:"begins",silent:!0,icon:null,iconStyle:"",align:"both",altRows:!0,onSearch:null,onRequest:null,onLoad:null,onError:null,onIconClick:null,renderDrop:null,compare:null,filter:!0,prefix:"",suffix:"",openOnFocus:!1,markSearch:!1},d.items=this.normMenu(d.items),"list"===this.type){if(b.openOnFocus=!0,a(this.el).addClass("w2ui-select"),!a.isPlainObject(d.selected)&&d.items)for(var e=0;e0?b.resize():clearInterval(c.sizeTimer)},200),a(b.el).data("tmp",c)},get:function(){var b;return b=["list","enum","file"].indexOf(this.type)!==-1?a(this.el).data("selected"):a(this.el).val()},set:function(b,c){if(["list","enum","file"].indexOf(this.type)!==-1){if("list"!==this.type&&c)null==a(this.el).data("selected")&&a(this.el).data("selected",[]),a(this.el).data("selected").push(b),a(this.el).change();else{var d="enum"===this.type?[b]:b;a(this.el).data("selected",d).change()}this.refresh()}else a(this.el).val(b)},setIndex:function(b,c){if(["list","enum"].indexOf(this.type)!==-1){var d=this.options.items;if(d&&d[b]){if("list"!==this.type&&c)null==a(this.el).data("selected")&&a(this.el).data("selected",[]),a(this.el).data("selected").push(d[b]),a(this.el).change();else{var e="enum"===this.type?[d[b]]:d[b];a(this.el).data("selected",e).change()}return this.refresh(),!0}}return!1},clear:function(){var b=this.options;["money","currency"].indexOf(this.type)!==-1&&a(this.el).val(a(this.el).val().replace(b.moneyRE,"")),"percent"===this.type&&a(this.el).val(a(this.el).val().replace(/%/g,"")),"list"===this.type&&a(this.el).removeClass("w2ui-select"),this.type="clear";var c=a(this.el).data("tmp");if(this.tmp){null!=c&&(a(this.el).height("auto"),c&&c["old-padding-left"]&&a(this.el).css("padding-left",c["old-padding-left"]),c&&c["old-padding-right"]&&a(this.el).css("padding-right",c["old-padding-right"]),c&&c["old-background-color"]&&a(this.el).css("background-color",c["old-background-color"]),c&&c["old-border-color"]&&a(this.el).css("border-color",c["old-border-color"]),clearInterval(c.sizeTimer)),a(this.el).val(this.clean(a(this.el).val())).removeClass("w2field").removeData().off(".w2field");for(var d in this.helpers)a(this.helpers[d]).remove();this.helpers={}}},refresh:function(){var b=this,c=this.options,d=a(this.el).data("selected"),e=(new Date).getTime();if(["list"].indexOf(this.type)!==-1&&(a(b.el).parent().css("white-space","nowrap"),b.helpers.prefix&&b.helpers.prefix.hide(),setTimeout(function(){if(b.helpers.focus){!a.isEmptyObject(d)&&c.icon?(c.prefix='',b.addPrefix()):(c.prefix="",b.addPrefix());var e=b.helpers.focus.find("input");""===a(e).val()?(a(e).css("text-indent","-9999em").prev().css("opacity",0),a(b.el).val(d&&null!=d.text?w2utils.lang(d.text):"")):(a(e).css("text-indent",0).prev().css("opacity",1),a(b.el).val(""),setTimeout(function(){b.helpers.prefix&&b.helpers.prefix.hide();var d="position: absolute; opacity: 0; margin: 4px 0px 0px 2px; background-position: left !important;";c.icon?(a(e).css("margin-left","17px"),a(b.helpers.focus).find(".icon-search").attr("style",d+"width: 11px !important; opacity: 1; display: block")):(a(e).css("margin-left","0px"),a(b.helpers.focus).find(".icon-search").attr("style",d+"width: 0px !important; opacity: 0; display: none"))},1)),a(b.el).prop("readonly")||a(b.el).prop("disabled")?setTimeout(function(){a(b.helpers.prefix).css("opacity","0.6"),a(b.helpers.suffix).css("opacity","0.6")},1):setTimeout(function(){a(b.helpers.prefix).css("opacity","1"),a(b.helpers.suffix).css("opacity","1")},1)}},1)),["enum","file"].indexOf(this.type)!==-1){var f="";if(d)for(var g=0;g  '):'
  
'+("enum"===b.type?h.text:h.name+' - '+w2utils.formatSize(h.size)+""),f+='
  • '+i+"
  • "}var j=b.helpers.multi,k=j.find("ul");if(j.attr("style",j.attr("style")+";"+c.style),a(b.el).css("z-index","-1"),a(b.el).prop("readonly")||a(b.el).prop("disabled")?setTimeout(function(){j[0].scrollTop=0,j.addClass("w2ui-readonly").find("li").css("opacity","0.9").parent().find("li.nomouse").hide().find("input").prop("readonly",!0).parents("ul").find(".w2ui-list-remove").hide()},1):setTimeout(function(){j.removeClass("w2ui-readonly").find("li").css("opacity","1").parent().find("li.nomouse").show().find("input").prop("readonly",!1).parents("ul").find(".w2ui-list-remove").show()},1),j.find(".w2ui-enum-placeholder").remove(),k.find("li").not("li.nomouse").remove(),""!==f)k.prepend(f);else if(null!=a(b.el).attr("placeholder")&&""===j.find("input").val()){var l="padding-top: "+a(this.el).css("padding-top")+";padding-left: "+a(this.el).css("padding-left")+"; box-sizing: "+a(this.el).css("box-sizing")+"; line-height: "+a(this.el).css("line-height")+"; font-size: "+a(this.el).css("font-size")+"; font-family: "+a(this.el).css("font-family")+"; ";j.prepend('
    '+a(b.el).attr("placeholder")+"
    ")}j.off("scroll.w2field").on("scroll.w2field",function(c){var d=b.trigger({phase:"before",type:"scroll",target:b.el,originalEvent:c});d.isCancelled!==!0&&b.trigger(a.extend(d,{phase:"after"}))}).find("li").data("mouse","out").on("click",function(c){var e="LI"===c.target.tagName.toUpperCase()?c.target:a(c.target).parents("LI"),f=d[a(e).attr("index")];if(!a(e).hasClass("nomouse"))if(c.stopPropagation(),a(c.target).hasClass("w2ui-list-remove")){if(a(b.el).prop("readonly")||a(b.el).prop("disabled"))return;var g=b.trigger({phase:"before",type:"remove",target:b.el,originalEvent:c.originalEvent,item:f});if(g.isCancelled===!0)return;a().w2overlay(),d.splice(a(c.target).attr("index"),1),a(b.el).trigger("input").trigger("change"),a(c.target).parent().fadeOut("fast"),setTimeout(function(){b.refresh(),b.trigger(a.extend(g,{phase:"after"}))},300)}else{var g=b.trigger({phase:"before",type:"click",target:b.el,originalEvent:c.originalEvent,item:f});if(g.isCancelled===!0)return;if("file"===b.type){var h="";/image/i.test(f.type)&&(h='
    ');var i='style="padding: 3px; text-align: right; color: #777;"',j='style="padding: 3px"';h+='
    "+w2utils.lang("Name")+":"+f.name+"
    "+w2utils.lang("Size")+":"+w2utils.formatSize(f.size)+"
    "+w2utils.lang("Type")+": '+f.type+"
    "+w2utils.lang("Modified")+":"+w2utils.date(f.modified)+"
    ",a("#w2ui-overlay").remove(),a(e).w2overlay(h)}b.trigger(a.extend(g,{phase:"after"}))}}).on("mouseover",function(c){var e="LI"===c.target.tagName.toUpperCase()?c.target:a(c.target).parents("LI");if(!a(e).hasClass("nomouse")){if("out"===a(e).data("mouse")){var f=d[a(c.target).attr("index")],g=b.trigger({phase:"before",type:"mouseOver",target:b.el,originalEvent:c.originalEvent,item:f});if(g.isCancelled===!0)return;b.trigger(a.extend(g,{phase:"after"}))}a(e).data("mouse","over")}}).on("mouseout",function(c){var e="LI"===c.target.tagName.toUpperCase()?c.target:a(c.target).parents("LI"); a(e).hasClass("nomouse")||(a(e).data("mouse","leaving"),setTimeout(function(){if("leaving"===a(e).data("mouse")){a(e).data("mouse","out");var f=d[a(c.target).attr("index")],g=b.trigger({phase:"before",type:"mouseOut",target:b.el,originalEvent:c.originalEvent,item:f});if(g.isCancelled===!0)return;b.trigger(a.extend(g,{phase:"after"}))}},0))}),a(this.el).height("auto");var m=a(j).find("> div.w2ui-multi-items").height()+2*w2utils.getSize(j,"+height");m<26&&(m=26),m>c.maxHeight&&(m=c.maxHeight),j.length>0&&(j[0].scrollTop=1e3);var n=w2utils.getSize(a(this.el),"height")-2;if(n>m&&(m=n),a(j).css({height:m+"px",overflow:m==c.maxHeight?"auto":"hidden"}),m0)){var e=this.helpers.focus,f=this.helpers.multi,g=this.helpers.suffix,h=this.helpers.prefix;if(e&&e.width(a(b.el).width()),f){var i=w2utils.getSize(b.el,"width")-parseInt(a(b.el).css("margin-left"),10)-parseInt(a(b.el).css("margin-right"),10);a(f).width(i)}g&&(b.options.suffix='
    ',b.addSuffix()),h&&b.addPrefix(),b.tmp.current_width=c}},clean:function(b){if("number"==typeof b)return b;var c=this.options;return b=String(b).trim(),["int","float","money","currency","percent"].indexOf(this.type)!==-1&&("string"==typeof b&&(c.autoFormat&&["money","currency"].indexOf(this.type)!==-1&&(b=String(b).replace(c.moneyRE,"")),c.autoFormat&&"percent"===this.type&&(b=String(b).replace(c.percentRE,"")),c.autoFormat&&["int","float"].indexOf(this.type)!==-1&&(b=String(b).replace(c.numberRE,"")),b=b.replace(/\s+/g,"").replace(w2utils.settings.groupSymbol,"").replace(w2utils.settings.decimalSymbol,".")),parseFloat(b)==b&&(null!=c.min&&bc.max&&(b=c.max,a(this.el).val(c.max))),b=""!==b&&w2utils.isFloat(b)?Number(b):""),b},format:function(a){var b=this.options;if(b.autoFormat&&""!==a)switch(this.type){case"money":case"currency":a=w2utils.formatNumber(a,b.currencyPrecision,b.groupSymbol),""!==a&&(a=b.currencyPrefix+a+b.currencySuffix);break;case"percent":a=w2utils.formatNumber(a,b.precision,b.groupSymbol),""!==a&&(a+="%");break;case"float":a=w2utils.formatNumber(a,b.precision,b.groupSymbol);break;case"int":a=w2utils.formatNumber(a,0,b.groupSymbol)}return a},change:function(b){var c=this,d=c.options;if(["int","float","money","currency","percent"].indexOf(this.type)!==-1){var e=a(this.el).val(),f=this.format(this.clean(a(this.el).val()));if(""!==e&&e!=f)return a(this.el).val(f).change(),b.stopPropagation(),b.preventDefault(),!1}if("color"===this.type){var g=a(this.el).val();"rgb"!==g.substr(0,3).toLowerCase()&&(g="#"+g,6!==a(this.el).val().length&&3!==a(this.el).val().length&&(g="")),a(this.el).next().find("div").css("background-color",g),a(this.el).is(":focus")&&a(this.el).data("skipInit")!==!0&&this.updateOverlay()}if(["list","enum","file"].indexOf(this.type)!==-1&&(c.refresh(),setTimeout(function(){c.refresh()},5)),["date","time","datetime"].indexOf(this.type)!==-1){var h=parseInt(c.el.value);w2utils.isInt(c.el.value)&&h>3e3&&("time"===this.type&&a(c.el).val(w2utils.formatTime(new Date(h),d.format)).change(),"date"===this.type&&a(c.el).val(w2utils.formatDate(new Date(h),d.format)).change(),"datetime"===this.type&&a(c.el).val(w2utils.formatDateTime(new Date(h),d.format)).change())}},click:function(b){b.stopPropagation(),["list","combo","enum"].indexOf(this.type)!==-1&&(a(this.el).is(":focus")||this.focus(b)),["date","time","color","datetime"].indexOf(this.type)!==-1&&this.updateOverlay()},focus:function(b){var c=this;if(["color","date","time","datetime"].indexOf(c.type)!==-1){if(a(c.el).prop("readonly")||a(c.el).prop("disabled"))return;a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),setTimeout(function(){c.updateOverlay()},150)}if(["list","combo","enum"].indexOf(c.type)!==-1){if(a(c.el).prop("readonly")||a(c.el).prop("disabled"))return;a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),c.resize(),setTimeout(function(){return"list"===c.type&&a(c.el).is(":focus")?void a(c.helpers.focus).find("input").focus():(c.search(),void setTimeout(function(){c.updateOverlay()},1))},1)}"file"===c.type&&a(c.helpers.multi).css({outline:"auto 5px #7DB4F3","outline-offset":"-2px"})},blur:function(b){var c=this,d=c.options,e=a(c.el).val().trim(),f=a("#w2ui-overlay");if(["color","date","time","list","combo","enum","datetime"].indexOf(c.type)!==-1){var g=window.setTimeout(function(){f.data("keepOpen")!==!0&&f.hide()},0);a(".menu",f).one("focus",function(){clearTimeout(g),a(this).one("focusout",function(a){f.hide()})})}["int","float","money","currency","percent"].indexOf(c.type)!==-1&&(""===e||c.checkType(e)||(a(c.el).val("").change(),d.silent===!1&&(a(c.el).w2tag("Not a valid number"),setTimeout(function(){a(c.el).w2tag("")},3e3)))),["date","time","datetime"].indexOf(c.type)!==-1&&(""===e||c.inRange(c.el.value)?"date"!==c.type||""===e||w2utils.isDate(c.el.value,d.format)?"time"!==c.type||""===e||w2utils.isTime(c.el.value)?"datetime"!==c.type||""===e||w2utils.isDateTime(c.el.value,d.format)||(a(c.el).val("").removeData("selected").change(),d.silent===!1&&(a(c.el).w2tag("Not a valid date"),setTimeout(function(){a(c.el).w2tag("")},3e3))):(a(c.el).val("").removeData("selected").change(),d.silent===!1&&(a(c.el).w2tag("Not a valid time"),setTimeout(function(){a(c.el).w2tag("")},3e3))):(a(c.el).val("").removeData("selected").change(),d.silent===!1&&(a(c.el).w2tag("Not a valid date"),setTimeout(function(){a(c.el).w2tag("")},3e3))):(a(c.el).val("").removeData("selected").change(),d.silent===!1&&(a(c.el).w2tag("Not in range"),setTimeout(function(){a(c.el).w2tag("")},3e3)))),"enum"===c.type&&a(c.helpers.multi).find("input").val("").width(20),"file"===c.type&&a(c.helpers.multi).css({outline:"none"})},keyPress:function(a){var b=this;b.options;if(["int","float","money","currency","percent","hex","bin","color","alphanumeric"].indexOf(b.type)!==-1){if(a.metaKey||a.ctrlKey||a.altKey||a.charCode!=a.keyCode&&a.keyCode>0)return;var c=String.fromCharCode(a.charCode);if(!b.checkType(c,!0)&&13!=a.keyCode)return a.preventDefault(),a.stopPropagation?a.stopPropagation():a.cancelBubble=!0,!1}["date","time","datetime"].indexOf(b.type)!==-1&&9!==a.keyCode&&setTimeout(function(){b.updateOverlay()},1)},keyDown:function(b,c){var d=this,e=d.options,f=b.keyCode||c&&c.keyCode,g=!1;if(["int","float","money","currency","percent"].indexOf(d.type)!==-1){if(!e.keyboard||a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;var h=parseFloat(a(d.el).val().replace(e.moneyRE,""))||0,i=e.step;switch((b.ctrlKey||b.metaKey)&&(i=10),f){case 38:if(b.shiftKey)break;a(d.el).val(h+i<=e.max||null==e.max?Number((h+i).toFixed(12)):e.max).change(),g=!0;break;case 40:if(b.shiftKey)break;a(d.el).val(h-i>=e.min||null==e.min?Number((h-i).toFixed(12)):e.min).change(),g=!0}g&&(b.preventDefault(),setTimeout(function(){d.el.setSelectionRange(d.el.value.length,d.el.value.length)},0))}if("date"===d.type){if(!e.keyboard||a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;var j=864e5,i=1;(b.ctrlKey||b.metaKey)&&(i=10);var k=w2utils.isDate(a(d.el).val(),e.format,!0);switch(k||(k=new Date,j=0),f){case 38:if(b.shiftKey)break;var l=w2utils.formatDate(k.getTime()+j,e.format);10==i&&(l=w2utils.formatDate(new Date(k.getFullYear(),k.getMonth()+1,k.getDate()),e.format)),a(d.el).val(l).trigger("input").change(),g=!0;break;case 40:if(b.shiftKey)break;var l=w2utils.formatDate(k.getTime()-j,e.format);10==i&&(l=w2utils.formatDate(new Date(k.getFullYear(),k.getMonth()-1,k.getDate()),e.format)),a(d.el).val(l).trigger("input").change(),g=!0}g&&(b.preventDefault(),setTimeout(function(){d.el.setSelectionRange(d.el.value.length,d.el.value.length),d.updateOverlay()},0))}if("time"===d.type){if(!e.keyboard||a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;var i=b.ctrlKey||b.metaKey?60:1,h=a(d.el).val(),m=d.toMin(h)||d.toMin((new Date).getHours()+":"+((new Date).getMinutes()-1));switch(f){case 38:if(b.shiftKey)break;m+=i,g=!0;break;case 40:if(b.shiftKey)break;m-=i,g=!0}g&&(a(d.el).val(d.fromMin(m)).trigger("input").change(),b.preventDefault(),setTimeout(function(){d.el.setSelectionRange(d.el.value.length,d.el.value.length)},0))}if("datetime"===d.type){if(!e.keyboard||a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;var j=864e5,i=1;(b.ctrlKey||b.metaKey)&&(i=10);var n=a(d.el).val(),k=w2utils.isDateTime(n,this.options.format,!0);switch(k||(k=new Date,j=0),f){case 38:if(b.shiftKey)break;var l=w2utils.formatDateTime(k.getTime()+j,e.format);10==i&&(l=w2utils.formatDateTime(new Date(k.getFullYear(),k.getMonth()+1,k.getDate()),e.format)),a(d.el).val(l).trigger("input").change(),g=!0;break;case 40:if(b.shiftKey)break;var l=w2utils.formatDateTime(k.getTime()-j,e.format);10==i&&(l=w2utils.formatDateTime(new Date(k.getFullYear(),k.getMonth()-1,k.getDate()),e.format)),a(d.el).val(l).trigger("input").change(),g=!0}g&&(b.preventDefault(),setTimeout(function(){d.el.setSelectionRange(d.el.value.length,d.el.value.length),d.updateOverlay()},0))}if("color"===d.type){if(a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;if((b.ctrlKey||b.metaKey)&&!b.shiftKey){var o=null,p=null;switch(f){case 38:o="up";break;case 40:o="down";break;case 39:o="right";break;case 37:o="left"}d.el.nav&&null!=o&&(p=d.el.nav(o),a(d.el).val(p).change(),b.preventDefault())}}if(["list","combo","enum"].indexOf(d.type)!==-1){if(a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;var q=a(d.el).data("selected"),r=a(d.el),s=!1;switch(["list","enum"].indexOf(d.type)!==-1&&("list"===d.type&&(r=a(d.helpers.focus).find("input")),"enum"===d.type&&(r=a(d.helpers.multi).find("input")),[37,38,39,40].indexOf(f)==-1&&setTimeout(function(){d.refresh()},1),86==b.keyCode&&(b.ctrlKey||b.metaKey)&&setTimeout(function(){d.refresh(),d.search(),d.request()},50)),f){case 27:"list"===d.type&&(""!==r.val()&&r.val(""),b.stopPropagation());break;case 37:case 39:break;case 13:if(0===a("#w2ui-overlay").length)break;var t=e.items[e.index];if("enum"===d.type)if(null!=t){var u=d.trigger({phase:"before",type:"add",target:d.el,originalEvent:b.originalEvent,item:t});if(u.isCancelled===!0)return;t=u.item,q.length>=e.max&&e.max>0&&q.pop(),delete t.hidden,delete d.tmp.force_open,q.push(t),a(d.el).change(),r.val("").width(20),d.refresh(),d.trigger(a.extend(u,{phase:"after"}))}else{t={id:r.val(),text:r.val()};var u=d.trigger({phase:"before",type:"new",target:d.el,originalEvent:b.originalEvent,item:t});if(u.isCancelled===!0)return;t=u.item,"function"==typeof d.onNew&&(q.length>=e.max&&e.max>0&&q.pop(),delete d.tmp.force_open,q.push(t),a(d.el).change(),r.val("").width(20),d.refresh()),d.trigger(a.extend(u,{phase:"after"}))}else t&&a(d.el).data("selected",t).val(t.text).change(),""===a(d.el).val()&&a(d.el).data("selected")&&a(d.el).removeData("selected").val("").change(),"list"===d.type&&(r.val(""),d.refresh()),d.tmp.force_hide=!0;break;case 8:case 46:if("enum"===d.type&&8===f&&""===r.val()&&q.length>0){var t=q[q.length-1],u=d.trigger({phase:"before",type:"remove",target:d.el,originalEvent:b.originalEvent,item:t});if(u.isCancelled===!0)return;q.pop(),a(d.el).trigger("input").trigger("change"),d.refresh(),d.trigger(a.extend(u,{phase:"after"}))}"list"===d.type&&""===r.val()&&(a(d.el).data("selected",{}).change(),d.refresh());break;case 38:for(e.index=w2utils.isInt(e.index)?parseInt(e.index):0,e.index--;e.index>0&&e.items[e.index].hidden;)e.index--;if(0===e.index&&e.items[e.index].hidden)for(;e.items[e.index]&&e.items[e.index].hidden;)e.index++;s=!0;break;case 40:for(e.index=w2utils.isInt(e.index)?parseInt(e.index):-1,e.index++;e.index=e.items.length&&(e.index=e.items.length-1),d.updateOverlay(s),b.preventDefault(),void setTimeout(function(){if("enum"===d.type){var a=r.get(0);a.setSelectionRange(a.value.length,a.value.length)}else if("list"===d.type){var a=r.get(0);a.setSelectionRange(a.value.length,a.value.length)}else d.el.setSelectionRange(d.el.value.length,d.el.value.length)},0);"enum"===d.type&&r.width(8*(r.val().length+2)+"px")}},keyUp:function(b){var c=this;if(["list","combo","enum"].indexOf(this.type)!==-1){if(a(c.el).prop("readonly")||a(c.el).prop("disabled"))return;if([16,17,18,20,37,39,91].indexOf(b.keyCode)==-1){var d=a(this.helpers.focus).find("input");0===d.length&&(d=a(this.el));var e=this.trigger({phase:"before",type:"search",originalEvent:b,target:d,search:d.val()});if(e.isCancelled===!0)return;this.tmp.force_hide||this.request(),1==d.val().length&&this.refresh(),0!==a("#w2ui-overlay").length&&[38,40].indexOf(b.keyCode)!=-1||this.search(),this.trigger(a.extend(e,{phase:"after"}))}}},clearCache:function(){var a=this.options;a.items=[],this.tmp.xhr_loading=!1,this.tmp.xhr_search="",this.tmp.xhr_total=-1},request:function(b){var c=this,d=this.options,e=a(c.el).val()||"";if(d.url){if("enum"===c.type){var f=a(c.helpers.multi).find("input");e=0===f.length?"":f.val()}if("list"===c.type){var f=a(c.helpers.focus).find("input");e=0===f.length?"":f.val()}if(0!==d.minLength&&e.lengthc.tmp.xhr_search.length||e.length>=c.tmp.xhr_search.length&&e.substr(0,c.tmp.xhr_search.length)!==c.tmp.xhr_search||e.lengthd.cacheMax&&b.records.splice(d.cacheMax,1e5),null==d.recId&&null!=d.recid&&(d.recId=d.recid),(d.recId||d.recText)&&b.records.forEach(function(a){"string"==typeof d.recId&&(a.id=a[d.recId]),"function"==typeof d.recId&&(a.id=d.recId(a)),"string"==typeof d.recText&&(a.text=a[d.recText]),"function"==typeof d.recText&&(a.text=d.recText(a))}),c.tmp.xhr_loading=!1,c.tmp.xhr_search=e,c.tmp.xhr_total=b.records.length,d.items=c.normMenu(b.records),""===e&&0===b.records.length?c.tmp.emptySet=!0:c.tmp.emptySet=!1;var j=a(c.el).data("find_selected");if(j){var k;Array.isArray(j)?(k=[],j.forEach(function(b){d.items.forEach(function(c){c.id==b&&k.push(a.extend(!0,{},c))})})):d.items.forEach(function(a){a.id==j&&(k=a)}),a(c.el).data("selected",k).removeData("find_selected").change()}c.search(),c.trigger(a.extend(i,{phase:"after"}))}}).fail(function(b,f,g){var h={status:f,error:g,rawResponseText:b.responseText},i=c.trigger({phase:"before",type:"error",target:c.el,search:e,error:h,xhr:b});if(i.isCancelled!==!0){if("abort"!==f){var j;try{j=a.parseJSON(b.responseText)}catch(a){}console.log("ERROR: Server communication failed.","\n EXPECTED:",{status:"success",records:[{id:1,text:"item"}]},"\n OR:",{status:"error",message:"error message"},"\n RECEIVED:","object"==typeof j?j:b.responseText)}c.tmp.xhr_loading=!1,c.tmp.xhr_search=e,c.tmp.xhr_total=0,d.items=[],c.clearCache(),c.search(),c.updateOverlay(!1,'
    '+(i.error||"Server communication failed")+"
    "),c.trigger(a.extend(i,{phase:"after"}))}}),c.trigger(a.extend(g,{phase:"after"}))}},b))}},search:function(){var b=this,c=this.options,d=a(b.el).val(),e=b.el,f=[],g=a(b.el).data("selected");if("enum"===b.type){e=a(b.helpers.multi).find("input"),d=e.val();for(var h in g)g[h]&&f.push(g[h].id)}else if("list"===b.type){e=a(b.helpers.focus).find("input"),d=e.val();for(var h in g)g[h]&&f.push(g[h].id)}if(b.tmp.xhr_loading!==!0){for(var i=0,j=0;j',{css:{"background-color":"#f5f5f5"},onShow:function(b){w2utils.isIE&&(console.log("IE"),a(".w2ui-calendar").on("mousedown",function(b){var c=a(b.target);1===c.length&&"w2ui-jump-year"===c[0].id&&a("#w2ui-overlay").data("keepOpen",!0)}))}});var f,g,h=w2utils.isDate(a(d.el).val(),d.options.format,!0);h&&(f=h.getMonth()+1,g=h.getFullYear()),function b(c,e){a("#w2ui-overlay > div > div").html(d.getMonthHTML(c,e,a(d.el).val())),a("#w2ui-overlay .w2ui-calendar-title").on("mousedown",function(){if(a(this).next().hasClass("w2ui-calendar-jump"))a(this).next().remove();else{var c,e;a(this).after('
    '),a(this).next().hide().html(d.getYearHTML()).fadeIn(200),setTimeout(function(){a("#w2ui-overlay .w2ui-calendar-jump").find(".w2ui-jump-month, .w2ui-jump-year").on("click",function(){a(this).hasClass("w2ui-jump-month")&&(a(this).parent().find(".w2ui-jump-month").removeClass("selected"),a(this).addClass("selected"),e=a(this).attr("name")),a(this).hasClass("w2ui-jump-year")&&(a(this).parent().find(".w2ui-jump-year").removeClass("selected"),a(this).addClass("selected"),c=a(this).attr("name")),null!=c&&null!=e&&(a("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout(function(){b(parseInt(e)+1,c)},100))}),a("#w2ui-overlay .w2ui-calendar-jump >:last-child").prop("scrollTop",2e3)},1)}}),a("#w2ui-overlay .w2ui-date").on("mousedown",function(){var b=a(this).attr("date");a(d.el).val(b).trigger("input").change(),a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"})}).on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)}),a("#w2ui-overlay .previous").on("mousedown",function(){var a=d.options.current.split("/");a[0]=parseInt(a[0])-1,b(a[0],a[1])}),a("#w2ui-overlay .next").on("mousedown",function(){var a=d.options.current.split("/");a[0]=parseInt(a[0])+1,b(a[0],a[1])})}(f,g)}if("time"===this.type){if(a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;0===a("#w2ui-overlay").length&&a(d.el).w2overlay('
    ',{css:{"background-color":"#fff"}});var i="h24"===this.options.format;a("#w2ui-overlay > div").html(d.getHourHTML()),a("#w2ui-overlay .w2ui-time").on("mousedown",function(b){a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"});var c=a(this).attr("hour");a(d.el).val((c>12&&!i?c-12:c)+":00"+(i?"":c<12?" am":" pm")).trigger("input").change()}),null==this.options.noMinutes||this.options.noMinutes===!1?a("#w2ui-overlay .w2ui-time").on("mouseup",function(){var b=a(this).attr("hour");a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),a(d.el).w2overlay('
    ',{css:{"background-color":"#fff"}}),a("#w2ui-overlay > div").html(d.getMinHTML(b)),a("#w2ui-overlay .w2ui-time").on("mousedown",function(){a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"});var c=a(this).attr("min");a(d.el).val((b>12&&!i?b-12:b)+":"+(c<10?0:"")+c+(i?"":b<12?" am":" pm")).trigger("input").change()}).on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}):a("#w2ui-overlay .w2ui-time").on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}if("datetime"===this.type){if(a(d.el).prop("readonly")||a(d.el).prop("disabled"))return;a("#w2ui-overlay .w2ui-time").length>0&&a("#w2ui-overlay")[0].hide(),0===a("#w2ui-overlay").length&&a(d.el).w2overlay('
    ',{css:{"background-color":"#f5f5f5"},onShow:function(b){w2utils.isIE&&(console.log("IE"),a(".w2ui-calendar").on("mousedown",function(b){var c=a(b.target);1===c.length&&"w2ui-jump-year"===c[0].id&&a("#w2ui-overlay").data("keepOpen",!0)}))}});var f,g,h=w2utils.isDateTime(a(d.el).val(),d.options.format,!0);h&&(f=h.getMonth()+1,g=h.getFullYear());var j=null;!function b(c,f){a("#w2ui-overlay > div > div").html(d.getMonthHTML(c,f,a(d.el).val())+(e.btn_now?'
    '+w2utils.lang("Current Date & Time")+"
    ":"")),a("#w2ui-overlay .w2ui-calendar-title").on("mousedown",function(){if(a(this).next().hasClass("w2ui-calendar-jump"))a(this).next().remove();else{var c,e;a(this).after('
    '),a(this).next().hide().html(d.getYearHTML()).fadeIn(200),setTimeout(function(){a("#w2ui-overlay .w2ui-calendar-jump").find(".w2ui-jump-month, .w2ui-jump-year").on("click",function(){a(this).hasClass("w2ui-jump-month")&&(a(this).parent().find(".w2ui-jump-month").removeClass("selected"),a(this).addClass("selected"),e=a(this).attr("name")),a(this).hasClass("w2ui-jump-year")&&(a(this).parent().find(".w2ui-jump-year").removeClass("selected"),a(this).addClass("selected"),c=a(this).attr("name")),null!=c&&null!=e&&(a("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout(function(){b(parseInt(e)+1,c)},100))}),a("#w2ui-overlay .w2ui-calendar-jump >:last-child").prop("scrollTop",2e3)},1)}}),a("#w2ui-overlay .w2ui-date").on("mousedown",function(){var b=a(this).attr("date");a(d.el).val(b).trigger("input").change(),a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),j=new Date(a(this).attr("data-date"))}).on("mouseup",function(){var b,c;a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),a(d.el).w2overlay('
    ',{css:{"background-color":"#fff"}});"h24"===d.options.format;a("#w2ui-overlay > div").html(d.getHourHTML()),a("#w2ui-overlay .w2ui-time").on("mousedown",function(c){a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),b=a(this).attr("hour"),j.setHours(b);var e=w2utils.formatDateTime(j,d.options.format);a(d.el).val(e).trigger("input").change()}),null==d.options.noMinutes||d.options.noMinutes===!1?a("#w2ui-overlay .w2ui-time").on("mouseup",function(){var e=a(this).attr("hour");a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),a(d.el).w2overlay('
    ',{css:{"background-color":"#fff"}}),a("#w2ui-overlay > div").html(d.getMinHTML(e)),a("#w2ui-overlay .w2ui-time").on("mousedown",function(){a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),c=a(this).attr("min"),j.setHours(b,c);var e=w2utils.formatDateTime(j,d.options.format);a(d.el).val(e).trigger("input").change()}).on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}):a("#w2ui-overlay .w2ui-time").on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}),a("#w2ui-overlay .previous").on("mousedown",function(){var a=d.options.current.split("/");a[0]=parseInt(a[0])-1,b(a[0],a[1])}),a("#w2ui-overlay .next").on("mousedown",function(){var a=d.options.current.split("/");a[0]=parseInt(a[0])+1,b(a[0],a[1])}),a("#w2ui-overlay .now").on("mousedown",function(){var b=w2utils.formatDateTime(new Date,d.options.format);return a(d.el).val(b).trigger("input").change(),!1}).on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}(f,g)}if(["list","combo","enum"].indexOf(this.type)!==-1){var k=this.el,l=this.el;if("enum"===this.type&&(k=a(this.helpers.multi),l=a(k).find("input")),"list"===this.type){var m=a(l).data("selected");a.isPlainObject(m)&&!a.isEmptyObject(m)&&e.index==-1&&e.items.forEach(function(a,b){a.id===m.id&&(e.index=b)}),l=a(this.helpers.focus).find("input")}if(a(l).is(":focus")){if(e.openOnFocus===!1&&""===a(l).val()&&d.tmp.force_open!==!0)return void a().w2overlay();if(d.tmp.force_hide)return a().w2overlay(),void setTimeout(function(){delete d.tmp.force_hide},1);""!==a(l).val()&&delete d.tmp.force_open;var n=w2utils.lang("No matches");null!=e.url&&a(l).val().length=e.max&&e.max>0&&c.pop(),delete b.item.hidden,c.push(b.item),a(d.el).data("selected",c).trigger("input").change(),a(d.helpers.multi).find("input").val("").width(20),d.refresh(),a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),d.trigger(a.extend(f,{phase:"after"}))}}else a(d.el).data("selected",b.item).val(b.item.text).trigger("input").change(),d.helpers.focus&&d.helpers.focus.find("input").val("")}}))}}},inRange:function(b,c){var d=!1;if("date"===this.type){var e=w2utils.isDate(b,this.options.format,!0);if(e){if(this.options.start||this.options.end){var f="string"==typeof this.options.start?this.options.start:a(this.options.start).val(),g="string"==typeof this.options.end?this.options.end:a(this.options.end).val(),h=w2utils.isDate(f,this.options.format,!0),i=w2utils.isDate(g,this.options.format,!0),j=new Date(e);h||(h=j),i||(i=j),j>=h&&j<=i&&(d=!0)}else d=!0;if(this.options.blocked&&a.inArray(b,this.options.blocked)!==-1&&(d=!1),null!==this.options.blockWeekDays&&void 0!==this.options.blockWeekDays&&void 0!=this.options.blockWeekDays.length)for(var k=this.options.blockWeekDays.length,l=0;l=n&&m<=o&&(d=!0)}else d=!0;else if("datetime"===this.type){var e=w2utils.isDateTime(b,this.options.format,!0);if(e){if(this.options.start||this.options.end){var h,i;if("object"==typeof this.options.start&&this.options.start instanceof Date)h=this.options.start;else{var f="string"==typeof this.options.start?this.options.start:a(this.options.start).val();h=""!==f.trim()?w2utils.isDateTime(f,this.options.format,!0):""}if("object"==typeof this.options.end&&this.options.end instanceof Date)i=this.options.end;else{var g="string"==typeof this.options.end?this.options.end:a(this.options.end).val();i=""!==g.trim()?w2utils.isDateTime(g,this.options.format,!0):""}var j=e;h||(h=j),i||(i=j),c&&h instanceof Date&&(h.setHours(0),h.setMinutes(0),h.setSeconds(0)),j>=h&&j<=i&&(d=!0)}else d=!0;if(d&&this.options.blocked)for(var l=0;l'+b.options.prefix+""),c=a(b.el).prev(),c.css({color:a(b.el).css("color"),"font-family":a(b.el).css("font-family"),"font-size":a(b.el).css("font-size"),"padding-top":a(b.el).css("padding-top"),"padding-bottom":a(b.el).css("padding-bottom"),"padding-left":a(b.el).css("padding-left"),"padding-right":0,"margin-top":parseInt(a(b.el).css("margin-top"),10)+2+"px","margin-bottom":parseInt(a(b.el).css("margin-bottom"),10)+1+"px","margin-left":a(b.el).css("margin-left"),"margin-right":0}).on("click",function(c){if(b.options.icon&&"function"==typeof b.onIconClick){var d=b.trigger({phase:"before",type:"iconClick",target:b.el,el:a(this).find("span.w2ui-icon")[0]});if(d.isCancelled===!0)return;b.trigger(a.extend(d,{phase:"after"}))}else"list"===b.type?a(b.helpers.focus).find("input").focus():a(b.el).focus()}),a(b.el).css("padding-left",c.width()+parseInt(a(b.el).css("padding-left"),10)+"px"),b.helpers.prefix=c)}},1)},addSuffix:function(){var b,c,d=this;setTimeout(function(){if("clear"!==d.type){var e=a(d.el).data("tmp")||{};e["old-padding-right"]&&a(d.el).css("padding-right",e["old-padding-right"]),e["old-padding-right"]=a(d.el).css("padding-right"),a(d.el).data("tmp",e),c=parseInt(a(d.el).css("padding-right"),10),d.options.arrows&&(d.helpers.arrows&&a(d.helpers.arrows).remove(),a(d.el).after('
     
    '), -b=a(d.el).next(),b.css({color:a(d.el).css("color"),"font-family":a(d.el).css("font-family"),"font-size":a(d.el).css("font-size"),height:a(d.el).height()+parseInt(a(d.el).css("padding-top"),10)+parseInt(a(d.el).css("padding-bottom"),10)+"px",padding:0,"margin-top":parseInt(a(d.el).css("margin-top"),10)+1+"px","margin-bottom":0,"border-left":"1px solid silver"}).css("margin-left","-"+(b.width()+parseInt(a(d.el).css("margin-right"),10)+12)+"px").on("mousedown",function(b){function c(){clearTimeout(f.data("_field_update_timer")),f.off("mouseup",c)}function e(c){a(d.el).focus(),d.keyDown(a.Event("keydown"),{keyCode:"up"===a(b.target).attr("type")?38:40}),c!==!1&&a("body").data("_field_update_timer",setTimeout(e,60))}var f=a("body");f.on("mouseup",c),f.data("_field_update_timer",setTimeout(e,700)),e(!1)}),c+=b.width()+12,a(d.el).css("padding-right",c+"px"),d.helpers.arrows=b),""!==d.options.suffix&&(d.helpers.suffix&&a(d.helpers.suffix).remove(),a(d.el).after('
    '+d.options.suffix+"
    "),b=a(d.el).next(),b.css({color:a(d.el).css("color"),"font-family":a(d.el).css("font-family"),"font-size":a(d.el).css("font-size"),"padding-top":a(d.el).css("padding-top"),"padding-bottom":a(d.el).css("padding-bottom"),"padding-left":"3px","padding-right":a(d.el).css("padding-right"),"margin-top":parseInt(a(d.el).css("margin-top"),10)+2+"px","margin-bottom":parseInt(a(d.el).css("margin-bottom"),10)+1+"px"}).on("click",function(b){"list"===d.type?a(d.helpers.focus).find("input").focus():a(d.el).focus()}),b.css("margin-left","-"+(w2utils.getSize(b,"width")+parseInt(a(d.el).css("margin-right"),10)+2)+"px"),c+=b.width()+3,a(d.el).css("padding-right",c+"px"),d.helpers.suffix=b)}},1)},addFocus:function(){var b,c=this,d=(this.options,0);a(c.helpers.focus).remove();var e=parseInt(a(c.el).attr("tabIndex"));isNaN(e)||e===-1||(c.el._tabIndex=e),c.el._tabIndex&&(e=c.el._tabIndex),null==e&&(e=-1);var f='
    ';a(c.el).attr("tabindex",-1).before(f);var g=a(c.el).prev();c.helpers.focus=g,g.css({width:a(c.el).width(),"margin-top":a(c.el).css("margin-top"),"margin-left":parseInt(a(c.el).css("margin-left"))+parseInt(a(c.el).css("padding-left"))+"px","margin-bottom":a(c.el).css("margin-bottom"),"margin-right":a(c.el).css("margin-right")}).find("input").css({cursor:"default",width:"100%",outline:"none",opacity:1,margin:0,border:"1px solid transparent",padding:a(c.el).css("padding-top"),"padding-left":0,"margin-left":d>0?d+6:0,"background-color":"transparent"}),g.find("input").on("click",function(b){0===a("#w2ui-overlay").length&&c.focus(b),b.stopPropagation()}).on("focus",function(d){b=a(c.el).attr("placeholder"),a(c.el).css({outline:"auto 5px #7DB4F3","outline-offset":"-2px"}),a(this).val(""),a(c.el).triggerHandler("focus"),d.stopPropagation?d.stopPropagation():d.cancelBubble=!0}).on("blur",function(d){a(c.el).css("outline","none"),a(this).val(""),c.refresh(),a(c.el).triggerHandler("blur"),d.stopPropagation?d.stopPropagation():d.cancelBubble=!0,null!=b&&a(c.el).attr("placeholder",b)}).on("keydown",function(d){var e=this;c.keyDown(d),setTimeout(function(){""===e.value?a(c.el).attr("placeholder",b):a(c.el).attr("placeholder","")},10)}).on("keyup",function(a){c.keyUp(a)}).on("keypress",function(a){c.keyPress(a)}),g.on("click",function(b){a(this).find("input").focus()}),c.refresh()},addMulti:function(){var b=this;this.options;a(b.helpers.multi).remove();var c="",d="margin-top : 0px; margin-bottom : 0px; margin-left : "+a(b.el).css("margin-left")+"; margin-right : "+a(b.el).css("margin-right")+"; width : "+(w2utils.getSize(b.el,"width")-parseInt(a(b.el).css("margin-left"),10)-parseInt(a(b.el).css("margin-right"),10))+"px;";if("enum"===b.type){var e=a(b.el).attr("tabIndex");e&&e!==-1&&(b.el._tabIndex=e),b.el._tabIndex&&(e=b.el._tabIndex),null==e&&(e=-1),c='
    '}"file"===b.type&&(c='
    ');var f=a(b.el).data("tmp")||{};f["old-background-color"]=a(b.el).css("background-color"),f["old-border-color"]=a(b.el).css("border-color"),a(b.el).data("tmp",f),a(b.el).before(c).css({"background-color":"transparent","border-color":"transparent"});var g=a(b.el).prev();b.helpers.multi=g,"enum"===b.type&&(a(b.el).attr("tabindex",-1),g.find("input").on("click",function(c){0===a("#w2ui-overlay").length&&b.focus(c),a(b.el).triggerHandler("click")}).on("focus",function(c){a(g).css({outline:"auto 5px #7DB4F3","outline-offset":"-2px"}),a(b.el).triggerHandler("focus"),c.stopPropagation?c.stopPropagation():c.cancelBubble=!0}).on("blur",function(c){a(g).css("outline","none"),a(b.el).triggerHandler("blur"),c.stopPropagation?c.stopPropagation():c.cancelBubble=!0}).on("keyup",function(a){b.keyUp(a)}).on("keydown",function(a){b.keyDown(a)}).on("keypress",function(a){b.keyPress(a)}),g.on("click",function(b){a(this).find("input").focus()})),"file"===b.type&&(a(b.el).css("outline","none"),g.on("click",function(c){a(b.el).focus(),a(b.el).prop("readonly")||a(b.el).prop("disabled")||(b.blur(c),b.resize(),setTimeout(function(){g.find("input").click()},10))}).on("dragenter",function(c){a(b.el).prop("readonly")||a(b.el).prop("disabled")||a(g).addClass("w2ui-file-dragover")}).on("dragleave",function(c){if(!a(b.el).prop("readonly")&&!a(b.el).prop("disabled")){var d=a(c.target).parents(".w2ui-field-helper");0===d.length&&a(g).removeClass("w2ui-file-dragover")}}).on("drop",function(c){if(!a(b.el).prop("readonly")&&!a(b.el).prop("disabled")){a(g).removeClass("w2ui-file-dragover");for(var d=c.originalEvent.dataTransfer.files,e=0,f=d.length;ee.maxFileSize)return c="Maximum file size is "+w2utils.formatSize(e.maxFileSize),e.silent===!1&&a(d.el).w2tag(c),void console.log("ERROR: "+c);if(0!==e.maxSize&&h+g.size>e.maxSize)return c=w2utils.lang("Maximum total size is")+" "+w2utils.formatSize(e.maxSize),void(e.silent===!1?a(d.el).w2tag(c):console.log("ERROR: "+c));if(0!==e.max&&i>=e.max)return c=w2utils.lang("Maximum number of files is")+" "+e.max,void(e.silent===!1?a(d.el).w2tag(c):console.log("ERROR: "+c));if(f.push(g),"undefined"!=typeof FileReader&&e.readContent===!0){var l=new FileReader;l.onload=function(){return function(b){var c=b.target.result,e=c.indexOf(",");g.content=c.substr(e+1),d.refresh(),a(d.el).trigger("input").trigger("change"),d.trigger(a.extend(k,{phase:"after"}))}}(),l.readAsDataURL(b)}else d.refresh(),a(d.el).trigger("input").trigger("change"),d.trigger(a.extend(k,{phase:"after"}))}},normMenu:function(b){if(a.isArray(b)){for(var c=0;c12&&(a-=12,b++),(a<1||0===a)&&(a+=12,b--),b/4==Math.floor(b/4)?f[1]="29":f[1]="28",j.current=a+"/"+b,d=new Date(b,a-1,1);for(var k=d.getDay(),l="",m=0;m'+i[m]+"";var n='
    '+e[a-1]+", "+b+'
    '+l+"",o=1;if("M"!==w2utils.settings.weekStarts&&k++,"datetime"===this.type){var p=w2utils.isDateTime(c,j.format,!0);c=w2utils.formatDate(p,w2utils.settings.dateFormat)}for(var q=1;q<43;q++){if(0===k&&1==q){for(var r=0;r<6;r++)n+='';q+=6}else if(qf[a-1]){n+='',q%7===0&&(n+="");continue}var s=b+"/"+a+"/"+o,t=new Date(s),u="";6===t.getDay()&&(u=" w2ui-saturday"),0===t.getDay()&&(u=" w2ui-sunday"),s==g&&(u+=" w2ui-today");var v,w,x=o,y="",z="";if("datetime"===this.type?(v=w2utils.formatDateTime(s,j.format),w=w2utils.formatDate(s,w2utils.settings.dateFormat)):(v=w2utils.formatDate(s,j.format),w=v),j.colored&&void 0!==j.colored[w]){var A=j.colored[w].split(":");z="background-color: "+A[0]+";",y="color: "+A[1]+";"}n+='",(q%7===0||0===k&&1==q)&&(n+=""),o++}return n+="
      
    '+x+"
    "},getYearHTML:function(){for(var a=w2utils.settings.shortmonths,b=w2utils.settings.dateStartYear,c=w2utils.settings.dateEndYear,d="",e="",f=0;f'+a[f]+"";for(var g=b;g<=c;g++)e+='
    '+g+"
    ";return'
    '+d+'
    '+e+"
    "},getHourHTML:function(){var a=[],b=this.options;null==b&&(b={format:w2utils.settings.timeFormat});for(var c=b.format.indexOf("h24")>-1,d=0;d<24;d++){var e=(d>=12&&!c?d-12:d)+":00"+(c?"":d<12?" am":" pm");12!=d||c||(e="12:00 pm"),a[Math.floor(d/8)]||(a[Math.floor(d/8)]="");var f=this.fromMin(this.toMin(e)),g=this.fromMin(this.toMin(e)+59);if("datetime"===this.type){var h=w2utils.isDateTime(this.el.value,b.format,!0),i=b.format.split("|")[0].trim();f=w2utils.formatDate(h,i)+" "+f,g=w2utils.formatDate(h,i)+" "+g}a[Math.floor(d/8)]+='
    '+e+"
    "}var j='
    '+w2utils.lang("Select Hour")+'
    '+a[0]+" "+a[1]+" "+a[2]+"
    ";return j},getMinHTML:function(a){null==a&&(a=0);var b=this.options;null==b&&(b={format:w2utils.settings.timeFormat});for(var c=b.format.indexOf("h24")>-1,d=[],e=0;e<60;e+=5){var f=(a>12&&!c?a-12:a)+":"+(e<10?0:"")+e+" "+(c?"":a<12?"am":"pm"),g=f,h=e<20?0:e<40?1:2;if(d[h]||(d[h]=""),"datetime"===this.type){var i=w2utils.isDateTime(this.el.value,b.format,!0),j=b.format.split("|")[0].trim();g=w2utils.formatDate(i,j)+" "+g}d[h]+='
    '+f+"
    "}var k='
    '+w2utils.lang("Select Minute")+'
    '+d[0]+" "+d[1]+" "+d[2]+"
    ";return k},toMin:function(a){if("string"!=typeof a)return null;var b=a.split(":");return 2!==b.length?null:(b[0]=parseInt(b[0]),b[1]=parseInt(b[1]),a.indexOf("pm")!==-1&&12!==b[0]&&(b[0]+=12),60*b[0]+b[1])},fromMin:function(a){var b="";a>=1440&&(a%=1440),a<0&&(a=1440+a);var c=Math.floor(a/60),d=(a%60<10?"0":"")+a%60,e=this.options;return null==e&&(e={format:w2utils.settings.timeFormat}),b=e.format.indexOf("h24")!==-1?c+":"+d:(c<=12?c:c-12)+":"+d+" "+(c>=12?"pm":"am")}},a.extend(b.prototype,w2utils.event),w2obj.field=b}(jQuery),function($){var w2form=function(a){this.name=null,this.header="",this.box=null,this.url="",this.routeData={},this.formURL="",this.formHTML="",this.page=0,this.recid=0,this.fields=[],this.actions={},this.record={},this.original=null,this.postData={},this.httpHeaders={},this.method=null,this.toolbar={},this.tabs={},this.style="",this.focus=0,this.autosize=!0,this.nestedFields=!0,this.multipart=!1,this.tabindexBase=0,this.isGenerated=!1,this.last={xhr:null},$.extend(!0,this,w2obj.form,a)};$.fn.w2form=function(a){if($.isPlainObject(a)){var b=this;if(!w2utils.checkName(a,"w2form"))return;var c=a.record,d=a.original,e=a.fields,f=a.toolbar,g=a.tabs,h=new w2form(a);if($.extend(h,{record:{},original:null,fields:[],tabs:{},toolbar:{},handlers:[]}),$.isArray(g)){$.extend(!0,h.tabs,{tabs:[]});for(var i=0;i",l),l.field=l.name),h.fields[k]=l}for(var k in c)$.isPlainObject(c[k])?h.record[k]=$.extend(!0,{},c[k]):h.record[k]=c[k];for(var k in d)$.isPlainObject(d[k])?h.original[k]=$.extend(!0,{},d[k]):h.original[k]=d[k];return b.length>0&&(h.box=b[0]),""!==h.formURL?$.get(h.formURL,function(a){h.formHTML=a,h.isGenerated=!0,0===$(h.box).length&&0===a.length||($(h.box).html(a),h.render(h.box))}):""!==h.formHTML||(0!==$(this).length&&""!==$.trim($(this).html())?h.formHTML=$(this).html():h.formHTML=h.generateHTML()),w2ui[h.name]=h,""===h.formURL&&(String(h.formHTML).indexOf("w2ui-page")===-1&&(h.formHTML='
    '+h.formHTML+"
    "),$(h.box).html(h.formHTML),h.isGenerated=!0,h.render(h.box)),h}var b=w2ui[$(this).attr("name")];return b?arguments.length>0?(b[a]&&b[a].apply(b,Array.prototype.slice.call(arguments,1)),this):b:null},w2form.prototype={onRequest:null,onLoad:null,onValidate:null,onSubmit:null,onProgress:null,onSave:null,onChange:null,onInput:null,onRender:null,onRefresh:null,onResize:null,onDestroy:null,onAction:null,onToolbar:null,onError:null,msgNotJSON:"Returned data is not in valid JSON format.",msgAJAXerror:"AJAX error. See console for more details.",msgRefresh:"Loading...",msgSaving:"Saving...",get:function(a,b){if(0===arguments.length){for(var c=[],d=0;d0&&this.refresh.apply(this,a),a.length},hide:function(){for(var a=[],b=0;b0&&this.refresh.apply(this,a),a.length},enable:function(){for(var a=[],b=0;b0&&this.refresh.apply(this,a),a.length},disable:function(){for(var a=[],b=0;b0&&this.refresh.apply(this,a),a.length},change:function(){Array.from(arguments).forEach(function(a){var b=this.get(a);b.$el&&b.$el.change()}.bind(this))},reload:function(a){var b="object"!=typeof this.url?this.url:this.url.get;b&&0!==this.recid&&null!=this.recid?this.request(a):"function"==typeof a&&a()},clear:function(){0!=arguments.length?Array.from(arguments).forEach(function(a){var b=this.record;String(a).split(".").map(function(a,c,d){d.length-1!==c?b=b[a]:delete b[a]}),this.refresh(a)}.bind(this)):(this.recid=0,this.record={},this.original=null,this.refresh()),$().w2tag()},error:function(a){var b=this,c=this.trigger({target:this.name,type:"error",message:a,xhr:this.last.xhr});return c.isCancelled===!0?void("function"==typeof callBack&&callBack()):(setTimeout(function(){b.message(a)},1),void this.trigger($.extend(c,{phase:"after"})))},message:function(a){"string"==typeof a&&(a={width:a.length<300?350:550,height:a.length<300?170:250,body:'
    '+a+"
    ",buttons:'",onOpen:function(a){setTimeout(function(){$(a.box).find(".w2ui-btn").focus()},25)}}),w2utils.message.call(this,{box:this.box,path:"w2ui."+this.name,title:".w2ui-form-header:visible",body:".w2ui-form-box"},a)},validate:function(a){null==a&&(a=!0),$().w2tag();for(var b=[],c=0;c0)for(var k=0;k'),setTimeout(function(){function apend(a,b,c,d){function e(b,c,d){if("object"==typeof b&&b instanceof File&&a.append(d,b),"object"==typeof b)if(b&&b.constructor===Array)for(var f=0;f0)for(var k=0;k",i),i.html.label=i.html.caption),i.html=$.extend(!0,{label:"",span:6,attr:"",text:"",style:"",page:0,column:0},i.html),null==a&&(a=i.html.page),null==b&&(b=i.html.column),""==i.html.label&&(i.html.label=i.field);var j='";switch(i.type){case"pass":case"password":j='";break;case"checkbox":j='";break;case"radio":j="";var k=i.options.items?i.options.items:i.html.items;$.isArray(k)||(k=[]),k.length>0&&(k=w2obj.field.prototype.normMenu(k));for(var l=0;l '+k[l].text+"
    ";break;case"select":j='"; -break;case"textarea":j='";break;case"toggle":j='
    ';break;case"map":i.html.key=i.html.key||{},i.html.value=i.html.value||{},j='
    '+i.html.text;break;case"html":case"custom":case"empty":j=i&&i.html&&i.html.html?i.html.html:""}""!==g&&(a!=i.html.page||b!=i.html.column||i.html.group&&g!=i.html.group)&&(f[a][b]+="\n ",g=""),i.html.group&&g!=i.html.group&&(c+='\n
    '+i.html.group+'
    \n
    ',g=i.html.group),null==i.html.anchor?c+='\n
    \n "+("empty"===i.type?"":"\n
    "+j+w2utils.lang(i.html.text)+"
    ")+"\n
    ":(f[i.html.page].anchors=f[i.html.page].anchors||{},f[i.html.page].anchors[i.html.anchor]='
    '+("empty"===i.type?"":"
    "+w2utils.lang(i.html.label)+j+w2utils.lang(i.html.text)+"
    ")+"
    "),null==f[i.html.page]&&(f[i.html.page]={}),null==f[i.html.page][i.html.column]&&(f[i.html.page][i.html.column]=""),f[i.html.page][i.html.column]+=c,a=i.html.page,b=i.html.column}if(""!==g&&(f[a][b]+="\n
    "),this.tabs.tabs)for(var l=0;l",o),o.text=o.caption),o.text&&(p.text=o.text),o.style&&(p.style=o.style),o.class&&(p.class=o.class)):(p.text=n,["save","update","create"].indexOf(n.toLowerCase())!==-1?p.class="w2ui-btn-blue":p.class=""),m+='\n ",d++}m+="\n"}c="";for(var q=0;q",f[q].before&&(c+=f[q].before),c+='
    ',Object.keys(f[q]).sort().forEach(function(a,b){a==parseInt(a)&&(c+='
    '+(f[q][a]||"")+"\n
    ")}),c+="\n
    ",f[q].after&&(c+=f[q].after),c+="\n",f[q].anchors&&Object.keys(f[q].anchors).forEach(function(a,b){c=c.replace(a,f[q].anchors[a])});return c+=m},action:function(a,b){var c=this.actions[a],d=c;$.isPlainObject(c)&&c.onClick&&(d=c.onClick);var e=this.trigger({phase:"before",target:a,type:"action",click:d,originalEvent:b});e.isCancelled!==!0&&("function"==typeof d&&d.call(this,b),this.trigger($.extend(e,{phase:"after"})))},resize:function(){function a(){d.width($(b.box).width()).height($(b.box).height()),f.css("top",""!==b.header?w2utils.getSize(e,"height"):0),g.css("top",(""!==b.header?w2utils.getSize(e,"height"):0)+("object"==typeof b.toolbar&&$.isArray(b.toolbar.items)&&b.toolbar.items.length>0?w2utils.getSize(f,"height"):0)),h.css("top",(""!==b.header?w2utils.getSize(e,"height"):0)+("object"==typeof b.toolbar&&$.isArray(b.toolbar.items)&&b.toolbar.items.length>0?w2utils.getSize(f,"height")+5:0)+("object"==typeof b.tabs&&$.isArray(b.tabs.tabs)&&b.tabs.tabs.length>0?w2utils.getSize(g,"height")+5:0)),h.css("bottom",k.length>0?w2utils.getSize(k,"height"):0)}var b=this,c=this.trigger({phase:"before",target:this.name,type:"resize"});if(c.isCancelled!==!0){var d=$(this.box).find("> div.w2ui-form-box"),e=$(this.box).find("> div .w2ui-form-header"),f=$(this.box).find("> div .w2ui-form-toolbar"),g=$(this.box).find("> div .w2ui-form-tabs"),h=$(this.box).find("> div .w2ui-page"),i=$(this.box).find("> div .w2ui-page.page-"+this.page),j=$(this.box).find("> div .w2ui-page.page-"+this.page+" > div"),k=$(this.box).find("> div .w2ui-buttons");a(),this.autosize&&(0!==parseInt($(this.box).height())&&$(this.box).data("auto-size")!==!0||($(this.box).height((e.length>0?w2utils.getSize(e,"height"):0)+("object"==typeof this.tabs&&$.isArray(this.tabs.tabs)&&this.tabs.tabs.length>0?w2utils.getSize(g,"height"):0)+("object"==typeof this.toolbar&&$.isArray(this.toolbar.items)&&this.toolbar.items.length>0?w2utils.getSize(f,"height"):0)+(h.length>0?w2utils.getSize(j,"height")+w2utils.getSize(i,"+height")+12:0)+(k.length>0?w2utils.getSize(k,"height"):0)),$(this.box).data("auto-size",!0)),a()),this.toolbar&&this.toolbar.resize&&this.toolbar.resize(),this.tabs&&this.tabs.resize&&this.tabs.resize(),b.trigger($.extend(c,{phase:"after"}))}},refresh:function(){var a=(new Date).getTime(),b=this;if(this.box&&this.isGenerated&&null!=$(this.box).html()){var c=this.trigger({phase:"before",target:this.name,type:"refresh",page:this.page,field:f,fields:arguments});if(c.isCancelled!==!0){var d=Array.from(this.fields.keys());arguments.length>0?d=Array.from(arguments).map(function(a,b){return"string"!=typeof a&&console.log("ERROR: Arguments in refresh functions should be field names"),this.get(a,!0)}.bind(this)).filter(function(a,b){return null!=a}):($(this.box).find("input, textarea, select").each(function(a,c){var d=null!=$(c).attr("name")?$(c).attr("name"):$(c).attr("id"),e=b.get(d);if(e){var f=$(c).closest(".w2ui-page");if(f.length>0)for(var g=0;g<100;g++)if(f.hasClass("page-"+g)){e.page=g;break}}}),$(this.box).find(".w2ui-page").hide(),$(this.box).find(".w2ui-page.page-"+this.page).show(),$(this.box).find(".w2ui-form-header").html(this.header),"object"==typeof this.tabs&&$.isArray(this.tabs.tabs)&&this.tabs.tabs.length>0?($("#form_"+this.name+"_tabs").show(),this.tabs.active=this.tabs.tabs[this.page].id,this.tabs.refresh()):$("#form_"+this.name+"_tabs").hide(),"object"==typeof this.toolbar&&$.isArray(this.toolbar.items)&&this.toolbar.items.length>0?($("#form_"+this.name+"_toolbar").show(),this.toolbar.refresh()):$("#form_"+this.name+"_toolbar").hide());for(var e=0;e0){var k=$(e.el).data("w2field").helpers.multi;$(k).removeClass("w2ui-error")}(""===j||null==j||$.isArray(j)&&0===j.length||$.isPlainObject(j)&&$.isEmptyObject(j))&&(j=null),b.setValue(this.name,j),b.trigger($.extend(i,{phase:"after"}))}}).on("input.w2form",function(a){var c=this.value;"checkbox"==a.target.type&&(c=a.target.checked),null==b.original&&($.isEmptyObject(b.record)?b.original={}:b.original=$.extend(!0,{},b.record));var d=b.trigger({phase:"before",target:this.name,type:"input",value_new:c,originalEvent:a});d.isCancelled!==!0&&b.trigger($.extend(d,{phase:"after"}))}),f.required?$(f.el).parent().parent().addClass("w2ui-required"):$(f.el).parent().parent().removeClass("w2ui-required"),null!=f.disabled){var h=$(f.el);f.disabled?(null==h.data("w2ui-tabIndex")&&h.data("w2ui-tabIndex",h.prop("tabIndex")),$(f.el).prop("readonly",!0).prop("tabindex",-1).closest(".w2ui-field").addClass("w2ui-disabled")):$(f.el).prop("readonly",!1).prop("tabIndex",h.data("w2ui-tabIndex")).closest(".w2ui-field").removeClass("w2ui-disabled")}var g=f.el;g||(g=$(this.box).find("#"+f.field)),f.hidden?$(g).closest(".w2ui-field").hide():$(g).closest(".w2ui-field").show()}$(this.box).find("button, input[type=button]").each(function(a,c){$(c).off("click").on("click",function(a){var c=this.value;this.id&&(c=this.id),this.name&&(c=this.name),b.action(c,a)})});for(var e=0;e0&&!$.isPlainObject(k[0])&&(f.options.items=w2obj.field.prototype.normMenu(k));for(var l=!1,m=0;m0){k=w2obj.field.prototype.normMenu(k),$(f.el).html("");for(var p=0;p'+k[p].text+"'+(a.html.key.text||"")+''+(a.html.value.text||"")+"";b.append(d)},a.el.mapRefresh=function(b,c){var d=1;Object.keys(b).forEach(function(e){var f=c.find("#"+a.name+"_key_"+d),g=c.find("#"+a.name+"_value_"+d);0!=f.length&&0!=g.length||(a.el.mapAdd(a,c,d),f=c.find("#"+a.name+"_key_"+d),g=c.find("#"+a.name+"_value_"+d)),f.val(e),g.val(b[e]),f.parent().attr("data-key",e),d++}),a.el.mapAdd(a,c,d),$(a.el).next().find("input.w2ui-map").off(".mapChange").on("input.mapChange",function(a){var c=$(a.target).parents(".w2ui-field"),d=(c.find("input"),$(a.target).parents(".w2ui-map-field").attr("data-key")),e=$(a.target).parents(".w2ui-map-field").find(".key").val(),f=$(a.target).parents(".w2ui-map-field").find(".value").val();delete b[d],b[e]=f,console.log("change",b)}).on("blur.mapChange",function(){console.log("blue"),a.el.mapRefresh(b,c)})},a.el.mapRefresh(i,$(a.el).parent().find(".w2ui-map-container"))}(f);break;case"radio":$(f.$el).prop("checked",!1).each(function(a,b){$(b).val()==i&&$(b).prop("checked",!0)});break;case"checkbox":$(f.el).prop("checked",!!i);break;case"html":case"custom":case"empty":break;default:$(f.el).val(i),$(f.el).w2field($.extend({},f.options,{type:f.type}))}}for(var g=$(this.box).find(".w2ui-page"),m=0;m *").length>1&&$(g[m]).wrapInner("
    ");return this.trigger($.extend(c,{phase:"after"})),this.resize(),(new Date).getTime()-a}}},render:function(a){var b=(new Date).getTime(),c=this;if("object"==typeof a&&($(this.box).find("#form_"+this.name+"_tabs").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),this.box=a),this.isGenerated&&this.box){var d=this.trigger({phase:"before",target:this.name,type:"render",box:null!=a?a:this.box});if(d.isCancelled!==!0){var e='
    '+(""!==this.header?'
    '+this.header+"
    ":"")+' '+this.formHTML+"
    ";$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-form").html(e),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),"function"!=typeof this.toolbar.render&&(this.toolbar=$().w2toolbar($.extend({},this.toolbar,{name:this.name+"_toolbar",owner:this})),this.toolbar.on("click",function(a){var b=c.trigger({phase:"before",type:"toolbar",target:a.target,originalEvent:a});b.isCancelled!==!0&&c.trigger($.extend(b,{phase:"after"}))})),"object"==typeof this.toolbar&&"function"==typeof this.toolbar.render&&this.toolbar.render($("#form_"+this.name+"_toolbar")[0]),"function"!=typeof this.tabs.render&&(this.tabs=$().w2tabs($.extend({},this.tabs,{name:this.name+"_tabs",owner:this,active:this.tabs.active})),this.tabs.on("click",function(a){c.goto(this.get(a.target,!0))})),"object"==typeof this.tabs&&"function"==typeof this.tabs.render&&(this.tabs.render($("#form_"+this.name+"_tabs")[0]),this.tabs.active&&this.tabs.click(this.tabs.active)),this.trigger($.extend(d,{phase:"after"})),this.resize();var f="object"!=typeof this.url?this.url:this.url.get;return f&&0!==this.recid&&null!=this.recid?this.request():this.refresh(),0===$(".w2ui-layout").length&&(this.tmp_resize=function(a){w2ui[c.name].resize()},$(window).off("resize","body").on("resize","body",this.tmp_resize)),this.focus!=-1&&setTimeout(function(){0===$(c.box).find("input, select, textarea").length?setTimeout(focusEl,500):c.applyFocus()},50),(new Date).getTime()-b}}},applyFocus:function(){for(var a=this.focus,b=$(this.box).find("div:not(.w2ui-field-helper) > input, select, textarea, div > label:nth-child(1) > :radio").not(".file-input");$(b[a]).is(":hidden")&&b.length>=a;)a++;b[a]&&b[a].focus()},destroy:function(){var a=this.trigger({phase:"before",target:this.name,type:"destroy"});a.isCancelled!==!0&&("object"==typeof this.toolbar&&this.toolbar.destroy&&this.toolbar.destroy(),"object"==typeof this.tabs&&this.tabs.destroy&&this.tabs.destroy(),$(this.box).find("#form_"+this.name+"_tabs").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),delete w2ui[this.name],this.trigger($.extend(a,{phase:"after"})),$(window).off("resize","body"))}},$.extend(w2form.prototype,w2utils.event),w2obj.form=w2form}(jQuery),function(a,b){if("function"==typeof define&&define.amd)return define(function(){return b});if("undefined"!=typeof exports){if("undefined"!=typeof module&&module.exports)return exports=module.exports=b;a=exports}for(var c in b)a[c]=b[c]}(this,{w2ui:w2ui,w2obj:w2obj,w2utils:w2utils,w2popup:w2popup,w2alert:w2alert,w2confirm:w2confirm,w2prompt:w2prompt}); \ No newline at end of file +b=a(d.el).next(),b.css({color:a(d.el).css("color"),"font-family":a(d.el).css("font-family"),"font-size":a(d.el).css("font-size"),height:a(d.el).height()+parseInt(a(d.el).css("padding-top"),10)+parseInt(a(d.el).css("padding-bottom"),10)+"px",padding:0,"margin-top":parseInt(a(d.el).css("margin-top"),10)+1+"px","margin-bottom":0,"border-left":"1px solid silver"}).css("margin-left","-"+(b.width()+parseInt(a(d.el).css("margin-right"),10)+12)+"px").on("mousedown",function(b){function c(){clearTimeout(f.data("_field_update_timer")),f.off("mouseup",c)}function e(c){a(d.el).focus(),d.keyDown(a.Event("keydown"),{keyCode:"up"===a(b.target).attr("type")?38:40}),c!==!1&&a("body").data("_field_update_timer",setTimeout(e,60))}var f=a("body");f.on("mouseup",c),f.data("_field_update_timer",setTimeout(e,700)),e(!1)}),c+=b.width()+12,a(d.el).css("padding-right",c+"px"),d.helpers.arrows=b),""!==d.options.suffix&&(d.helpers.suffix&&a(d.helpers.suffix).remove(),a(d.el).after('
    '+d.options.suffix+"
    "),b=a(d.el).next(),b.css({color:a(d.el).css("color"),"font-family":a(d.el).css("font-family"),"font-size":a(d.el).css("font-size"),"padding-top":a(d.el).css("padding-top"),"padding-bottom":a(d.el).css("padding-bottom"),"padding-left":"3px","padding-right":a(d.el).css("padding-right"),"margin-top":parseInt(a(d.el).css("margin-top"),10)+2+"px","margin-bottom":parseInt(a(d.el).css("margin-bottom"),10)+1+"px"}).on("click",function(b){"list"===d.type?a(d.helpers.focus).find("input").focus():a(d.el).focus()}),b.css("margin-left","-"+(w2utils.getSize(b,"width")+parseInt(a(d.el).css("margin-right"),10)+2)+"px"),c+=b.width()+3,a(d.el).css("padding-right",c+"px"),d.helpers.suffix=b)}},1)},addFocus:function(){var b,c=this,d=(this.options,0);a(c.helpers.focus).remove();var e=parseInt(a(c.el).attr("tabIndex"));isNaN(e)||e===-1||(c.el._tabIndex=e),c.el._tabIndex&&(e=c.el._tabIndex),null==e&&(e=-1);var f='
    ';a(c.el).attr("tabindex",-1).before(f);var g=a(c.el).prev();c.helpers.focus=g,g.css({width:a(c.el).width(),"margin-top":a(c.el).css("margin-top"),"margin-left":parseInt(a(c.el).css("margin-left"))+parseInt(a(c.el).css("padding-left"))+"px","margin-bottom":a(c.el).css("margin-bottom"),"margin-right":a(c.el).css("margin-right")}).find("input").css({cursor:"default",width:"100%",outline:"none",opacity:1,margin:0,border:"1px solid transparent",padding:a(c.el).css("padding-top"),"padding-left":0,"margin-left":d>0?d+6:0,"background-color":"transparent"}),g.find("input").on("click",function(b){0===a("#w2ui-overlay").length&&c.focus(b),b.stopPropagation()}).on("focus",function(d){b=a(c.el).attr("placeholder"),a(c.el).css({outline:"auto 5px #7DB4F3","outline-offset":"-2px"}),a(this).val(""),a(c.el).triggerHandler("focus"),d.stopPropagation?d.stopPropagation():d.cancelBubble=!0}).on("blur",function(d){a(c.el).css("outline","none"),a(this).val(""),c.refresh(),a(c.el).triggerHandler("blur"),d.stopPropagation?d.stopPropagation():d.cancelBubble=!0,null!=b&&a(c.el).attr("placeholder",b)}).on("keydown",function(d){var e=this;c.keyDown(d),setTimeout(function(){""===e.value?a(c.el).attr("placeholder",b):a(c.el).attr("placeholder","")},10)}).on("keyup",function(a){c.keyUp(a)}).on("keypress",function(a){c.keyPress(a)}),g.on("click",function(b){a(this).find("input").focus()}),c.refresh()},addMulti:function(){var b=this;this.options;a(b.helpers.multi).remove();var c="",d="margin-top : 0px; margin-bottom : 0px; margin-left : "+a(b.el).css("margin-left")+"; margin-right : "+a(b.el).css("margin-right")+"; width : "+(w2utils.getSize(b.el,"width")-parseInt(a(b.el).css("margin-left"),10)-parseInt(a(b.el).css("margin-right"),10))+"px;";if("enum"===b.type){var e=a(b.el).attr("tabIndex");e&&e!==-1&&(b.el._tabIndex=e),b.el._tabIndex&&(e=b.el._tabIndex),null==e&&(e=-1),c='
    '}"file"===b.type&&(c='
    ');var f=a(b.el).data("tmp")||{};f["old-background-color"]=a(b.el).css("background-color"),f["old-border-color"]=a(b.el).css("border-color"),a(b.el).data("tmp",f),a(b.el).before(c).css({"background-color":"transparent","border-color":"transparent"});var g=a(b.el).prev();b.helpers.multi=g,"enum"===b.type&&(a(b.el).attr("tabindex",-1),g.find("input").on("click",function(c){0===a("#w2ui-overlay").length&&b.focus(c),a(b.el).triggerHandler("click")}).on("focus",function(c){a(g).css({outline:"auto 5px #7DB4F3","outline-offset":"-2px"}),a(b.el).triggerHandler("focus"),c.stopPropagation?c.stopPropagation():c.cancelBubble=!0}).on("blur",function(c){a(g).css("outline","none"),a(b.el).triggerHandler("blur"),c.stopPropagation?c.stopPropagation():c.cancelBubble=!0}).on("keyup",function(a){b.keyUp(a)}).on("keydown",function(a){b.keyDown(a)}).on("keypress",function(a){b.keyPress(a)}),g.on("click",function(b){a(this).find("input").focus()})),"file"===b.type&&(a(b.el).css("outline","none"),g.on("click",function(c){a(b.el).focus(),a(b.el).prop("readonly")||a(b.el).prop("disabled")||(b.blur(c),b.resize(),setTimeout(function(){g.find("input").click()},10))}).on("dragenter",function(c){a(b.el).prop("readonly")||a(b.el).prop("disabled")||a(g).addClass("w2ui-file-dragover")}).on("dragleave",function(c){if(!a(b.el).prop("readonly")&&!a(b.el).prop("disabled")){var d=a(c.target).parents(".w2ui-field-helper");0===d.length&&a(g).removeClass("w2ui-file-dragover")}}).on("drop",function(c){if(!a(b.el).prop("readonly")&&!a(b.el).prop("disabled")){a(g).removeClass("w2ui-file-dragover");for(var d=c.originalEvent.dataTransfer.files,e=0,f=d.length;ee.maxFileSize)return c="Maximum file size is "+w2utils.formatSize(e.maxFileSize),e.silent===!1&&a(d.el).w2tag(c),void console.log("ERROR: "+c);if(0!==e.maxSize&&h+g.size>e.maxSize)return c=w2utils.lang("Maximum total size is")+" "+w2utils.formatSize(e.maxSize),void(e.silent===!1?a(d.el).w2tag(c):console.log("ERROR: "+c));if(0!==e.max&&i>=e.max)return c=w2utils.lang("Maximum number of files is")+" "+e.max,void(e.silent===!1?a(d.el).w2tag(c):console.log("ERROR: "+c));if(f.push(g),"undefined"!=typeof FileReader&&e.readContent===!0){var l=new FileReader;l.onload=function(){return function(b){var c=b.target.result,e=c.indexOf(",");g.content=c.substr(e+1),d.refresh(),a(d.el).trigger("input").trigger("change"),d.trigger(a.extend(k,{phase:"after"}))}}(),l.readAsDataURL(b)}else d.refresh(),a(d.el).trigger("input").trigger("change"),d.trigger(a.extend(k,{phase:"after"}))}},normMenu:function(b){if(a.isArray(b)){for(var c=0;c12&&(a-=12,b++),(a<1||0===a)&&(a+=12,b--),b/4==Math.floor(b/4)?f[1]="29":f[1]="28",j.current=a+"/"+b,d=new Date(b,a-1,1);for(var k=d.getDay(),l="",m=0;m'+i[m]+"";var n='
    '+e[a-1]+", "+b+'
    '+l+"",o=1;if("M"!==w2utils.settings.weekStarts&&k++,"datetime"===this.type){var p=w2utils.isDateTime(c,j.format,!0);c=w2utils.formatDate(p,w2utils.settings.dateFormat)}for(var q=1;q<43;q++){if(0===k&&1==q){for(var r=0;r<6;r++)n+='';q+=6}else if(qf[a-1]){n+='',q%7===0&&(n+="");continue}var s=b+"/"+a+"/"+o,t=new Date(s),u="";6===t.getDay()&&(u=" w2ui-saturday"),0===t.getDay()&&(u=" w2ui-sunday"),s==g&&(u+=" w2ui-today");var v,w,x=o,y="",z="";if("datetime"===this.type?(v=w2utils.formatDateTime(s,j.format),w=w2utils.formatDate(s,w2utils.settings.dateFormat)):(v=w2utils.formatDate(s,j.format),w=v),j.colored&&void 0!==j.colored[w]){var A=j.colored[w].split(":");z="background-color: "+A[0]+";",y="color: "+A[1]+";"}n+='",(q%7===0||0===k&&1==q)&&(n+=""),o++}return n+="
      
    '+x+"
    "},getYearHTML:function(){for(var a=w2utils.settings.shortmonths,b=w2utils.settings.dateStartYear,c=w2utils.settings.dateEndYear,d="",e="",f=0;f'+a[f]+"";for(var g=b;g<=c;g++)e+='
    '+g+"
    ";return'
    '+d+'
    '+e+"
    "},getHourHTML:function(){var a=[],b=this.options;null==b&&(b={format:w2utils.settings.timeFormat});for(var c=b.format.indexOf("h24")>-1,d=0;d<24;d++){var e=(d>=12&&!c?d-12:d)+":00"+(c?"":d<12?" am":" pm");12!=d||c||(e="12:00 pm"),a[Math.floor(d/8)]||(a[Math.floor(d/8)]="");var f=this.fromMin(this.toMin(e)),g=this.fromMin(this.toMin(e)+59);if("datetime"===this.type){var h=w2utils.isDateTime(this.el.value,b.format,!0),i=b.format.split("|")[0].trim();f=w2utils.formatDate(h,i)+" "+f,g=w2utils.formatDate(h,i)+" "+g}a[Math.floor(d/8)]+='
    '+e+"
    "}var j='
    '+w2utils.lang("Select Hour")+'
    '+a[0]+" "+a[1]+" "+a[2]+"
    ";return j},getMinHTML:function(a){null==a&&(a=0);var b=this.options;null==b&&(b={format:w2utils.settings.timeFormat});for(var c=b.format.indexOf("h24")>-1,d=[],e=0;e<60;e+=5){var f=(a>12&&!c?a-12:a)+":"+(e<10?0:"")+e+" "+(c?"":a<12?"am":"pm"),g=f,h=e<20?0:e<40?1:2;if(d[h]||(d[h]=""),"datetime"===this.type){var i=w2utils.isDateTime(this.el.value,b.format,!0),j=b.format.split("|")[0].trim();g=w2utils.formatDate(i,j)+" "+g}d[h]+='
    '+f+"
    "}var k='
    '+w2utils.lang("Select Minute")+'
    '+d[0]+" "+d[1]+" "+d[2]+"
    ";return k},toMin:function(a){if("string"!=typeof a)return null;var b=a.split(":");return 2!==b.length?null:(b[0]=parseInt(b[0]),b[1]=parseInt(b[1]),a.indexOf("pm")!==-1&&12!==b[0]&&(b[0]+=12),60*b[0]+b[1])},fromMin:function(a){var b="";a>=1440&&(a%=1440),a<0&&(a=1440+a);var c=Math.floor(a/60),d=(a%60<10?"0":"")+a%60,e=this.options;return null==e&&(e={format:w2utils.settings.timeFormat}),b=e.format.indexOf("h24")!==-1?c+":"+d:(c<=12?c:c-12)+":"+d+" "+(c>=12?"pm":"am")}},a.extend(b.prototype,w2utils.event),w2obj.field=b}(jQuery),function($){var w2form=function(a){this.name=null,this.header="",this.box=null,this.url="",this.routeData={},this.formURL="",this.formHTML="",this.page=0,this.recid=0,this.fields=[],this.actions={},this.record={},this.original=null,this.postData={},this.httpHeaders={},this.method=null,this.toolbar={},this.tabs={},this.style="",this.focus=0,this.autosize=!0,this.nestedFields=!0,this.multipart=!1,this.tabindexBase=0,this.isGenerated=!1,this.last={xhr:null},$.extend(!0,this,w2obj.form,a)};$.fn.w2form=function(a){if($.isPlainObject(a)){var b=this;if(!w2utils.checkName(a,"w2form"))return;var c=a.record,d=a.original,e=a.fields,f=a.toolbar,g=a.tabs,h=new w2form(a);if($.extend(h,{record:{},original:null,fields:[],tabs:{},toolbar:{},handlers:[]}),$.isArray(g)){$.extend(!0,h.tabs,{tabs:[]});for(var i=0;i",l),l.field=l.name),h.fields[k]=l}for(var k in c)$.isPlainObject(c[k])?h.record[k]=$.extend(!0,{},c[k]):h.record[k]=c[k];for(var k in d)$.isPlainObject(d[k])?h.original[k]=$.extend(!0,{},d[k]):h.original[k]=d[k];return b.length>0&&(h.box=b[0]),""!==h.formURL?$.get(h.formURL,function(a){h.formHTML=a,h.isGenerated=!0,0===$(h.box).length&&0===a.length||($(h.box).html(a),h.render(h.box))}):""!==h.formHTML||(0!==$(this).length&&""!==$.trim($(this).html())?h.formHTML=$(this).html():h.formHTML=h.generateHTML()),w2ui[h.name]=h,""===h.formURL&&(String(h.formHTML).indexOf("w2ui-page")===-1&&(h.formHTML='
    '+h.formHTML+"
    "),$(h.box).html(h.formHTML),h.isGenerated=!0,h.render(h.box)),h}var b=w2ui[$(this).attr("name")];return b?arguments.length>0?(b[a]&&b[a].apply(b,Array.prototype.slice.call(arguments,1)),this):b:null},w2form.prototype={onRequest:null,onLoad:null,onValidate:null,onSubmit:null,onProgress:null,onSave:null,onChange:null,onInput:null,onRender:null,onRefresh:null,onResize:null,onDestroy:null,onAction:null,onToolbar:null,onError:null,msgNotJSON:"Returned data is not in valid JSON format.",msgAJAXerror:"AJAX error. See console for more details.",msgRefresh:"Loading...",msgSaving:"Saving...",get:function(a,b){if(0===arguments.length){for(var c=[],d=0;d0&&this.refresh.apply(this,a),a.length},hide:function(){for(var a=[],b=0;b0&&this.refresh.apply(this,a),a.length},enable:function(){for(var a=[],b=0;b0&&this.refresh.apply(this,a),a.length},disable:function(){for(var a=[],b=0;b0&&this.refresh.apply(this,a),a.length},change:function(){Array.from(arguments).forEach(function(a){var b=this.get(a);b.$el&&b.$el.change()}.bind(this))},reload:function(a){var b="object"!=typeof this.url?this.url:this.url.get;b&&0!==this.recid&&null!=this.recid?this.request(a):"function"==typeof a&&a()},clear:function(){0!=arguments.length?Array.from(arguments).forEach(function(a){var b=this.record;String(a).split(".").map(function(a,c,d){d.length-1!==c?b=b[a]:delete b[a]}),this.refresh(a)}.bind(this)):(this.recid=0,this.record={},this.original=null,this.refresh()),$().w2tag()},error:function(a){var b=this,c=this.trigger({target:this.name,type:"error",message:a,xhr:this.last.xhr});return c.isCancelled===!0?void("function"==typeof callBack&&callBack()):(setTimeout(function(){b.message(a)},1),void this.trigger($.extend(c,{phase:"after"})))},message:function(a){"string"==typeof a&&(a={width:a.length<300?350:550,height:a.length<300?170:250,body:'
    '+a+"
    ",buttons:'",onOpen:function(a){setTimeout(function(){$(a.box).find(".w2ui-btn").focus()},25)}}),w2utils.message.call(this,{box:this.box,path:"w2ui."+this.name,title:".w2ui-form-header:visible",body:".w2ui-form-box"},a)},validate:function(a){null==a&&(a=!0),$().w2tag();for(var b=[],c=0;c0)for(var k=0;k'),setTimeout(function(){function apend(a,b,c,d){function e(b,c,d){if("object"==typeof b&&b instanceof File&&a.append(d,b),"object"==typeof b)if(b&&b.constructor===Array)for(var f=0;f0)for(var k=0;k",i),i.html.label=i.html.caption),i.html=$.extend(!0,{label:"",span:6,attr:"",text:"",style:"",page:0,column:0},i.html),null==a&&(a=i.html.page),null==b&&(b=i.html.column),""==i.html.label&&(i.html.label=i.field);var j='";switch(i.type){case"pass":case"password":j='";break;case"checkbox":j='";break;case"radio":j="";var k=i.options.items?i.options.items:i.html.items;$.isArray(k)||(k=[]),k.length>0&&(k=w2obj.field.prototype.normMenu(k));for(var l=0;l '+k[l].text+"
    ";break;case"select":j='";break;case"textarea":j='";break;case"toggle":j='
    ';break;case"map":case"array":i.html.key=i.html.key||{},i.html.value=i.html.value||{},j='
    '+i.html.text;break;case"html":case"custom":case"empty":j=i&&i.html&&i.html.html?i.html.html:""}""!==g&&(a!=i.html.page||b!=i.html.column||i.html.group&&g!=i.html.group)&&(f[a][b]+="\n ",g=""),i.html.group&&g!=i.html.group&&(c+='\n
    '+i.html.group+'
    \n
    ',g=i.html.group),null==i.html.anchor?c+='\n
    \n "+("empty"===i.type?"":"\n
    "+j+w2utils.lang(i.html.text)+"
    ")+"\n
    ":(f[i.html.page].anchors=f[i.html.page].anchors||{},f[i.html.page].anchors[i.html.anchor]='
    '+("empty"===i.type?"":"
    "+w2utils.lang(i.html.label)+j+w2utils.lang(i.html.text)+"
    ")+"
    "),null==f[i.html.page]&&(f[i.html.page]={}),null==f[i.html.page][i.html.column]&&(f[i.html.page][i.html.column]=""),f[i.html.page][i.html.column]+=c,a=i.html.page,b=i.html.column}if(""!==g&&(f[a][b]+="\n
    "),this.tabs.tabs)for(var l=0;l",o),o.text=o.caption),o.text&&(p.text=o.text),o.style&&(p.style=o.style),o.class&&(p.class=o.class)):(p.text=n,["save","update","create"].indexOf(n.toLowerCase())!==-1?p.class="w2ui-btn-blue":p.class=""),m+='\n ",d++}m+="\n"}c="";for(var q=0;q",f[q].before&&(c+=f[q].before),c+='
    ',Object.keys(f[q]).sort().forEach(function(a,b){a==parseInt(a)&&(c+='
    '+(f[q][a]||"")+"\n
    ")}),c+="\n
    ",f[q].after&&(c+=f[q].after),c+="\n",f[q].anchors&&Object.keys(f[q].anchors).forEach(function(a,b){c=c.replace(a,f[q].anchors[a])});return c+=m},action:function(a,b){var c=this.actions[a],d=c;$.isPlainObject(c)&&c.onClick&&(d=c.onClick);var e=this.trigger({phase:"before",target:a,type:"action",click:d,originalEvent:b});e.isCancelled!==!0&&("function"==typeof d&&d.call(this,b),this.trigger($.extend(e,{phase:"after"})))},resize:function(){function a(){d.width($(b.box).width()).height($(b.box).height()),f.css("top",""!==b.header?w2utils.getSize(e,"height"):0),g.css("top",(""!==b.header?w2utils.getSize(e,"height"):0)+("object"==typeof b.toolbar&&$.isArray(b.toolbar.items)&&b.toolbar.items.length>0?w2utils.getSize(f,"height"):0)),h.css("top",(""!==b.header?w2utils.getSize(e,"height"):0)+("object"==typeof b.toolbar&&$.isArray(b.toolbar.items)&&b.toolbar.items.length>0?w2utils.getSize(f,"height")+5:0)+("object"==typeof b.tabs&&$.isArray(b.tabs.tabs)&&b.tabs.tabs.length>0?w2utils.getSize(g,"height")+5:0)),h.css("bottom",k.length>0?w2utils.getSize(k,"height"):0)}var b=this,c=this.trigger({phase:"before",target:this.name,type:"resize"});if(c.isCancelled!==!0){var d=$(this.box).find("> div.w2ui-form-box"),e=$(this.box).find("> div .w2ui-form-header"),f=$(this.box).find("> div .w2ui-form-toolbar"),g=$(this.box).find("> div .w2ui-form-tabs"),h=$(this.box).find("> div .w2ui-page"),i=$(this.box).find("> div .w2ui-page.page-"+this.page),j=$(this.box).find("> div .w2ui-page.page-"+this.page+" > div"),k=$(this.box).find("> div .w2ui-buttons");a(),this.autosize&&(0!==parseInt($(this.box).height())&&$(this.box).data("auto-size")!==!0||($(this.box).height((e.length>0?w2utils.getSize(e,"height"):0)+("object"==typeof this.tabs&&$.isArray(this.tabs.tabs)&&this.tabs.tabs.length>0?w2utils.getSize(g,"height"):0)+("object"==typeof this.toolbar&&$.isArray(this.toolbar.items)&&this.toolbar.items.length>0?w2utils.getSize(f,"height"):0)+(h.length>0?w2utils.getSize(j,"height")+w2utils.getSize(i,"+height")+12:0)+(k.length>0?w2utils.getSize(k,"height"):0)),$(this.box).data("auto-size",!0)),a()),this.toolbar&&this.toolbar.resize&&this.toolbar.resize(),this.tabs&&this.tabs.resize&&this.tabs.resize(),b.trigger($.extend(c,{phase:"after"}))}},refresh:function(){var a=(new Date).getTime(),b=this;if(this.box&&this.isGenerated&&null!=$(this.box).html()){var c=this.trigger({phase:"before",target:this.name,type:"refresh",page:this.page,field:f,fields:arguments});if(c.isCancelled!==!0){var d=Array.from(this.fields.keys());arguments.length>0?d=Array.from(arguments).map(function(a,b){return"string"!=typeof a&&console.log("ERROR: Arguments in refresh functions should be field names"),this.get(a,!0)}.bind(this)).filter(function(a,b){return null!=a}):($(this.box).find("input, textarea, select").each(function(a,c){var d=null!=$(c).attr("name")?$(c).attr("name"):$(c).attr("id"),e=b.get(d);if(e){var f=$(c).closest(".w2ui-page");if(f.length>0)for(var g=0;g<100;g++)if(f.hasClass("page-"+g)){e.page=g;break}}}),$(this.box).find(".w2ui-page").hide(),$(this.box).find(".w2ui-page.page-"+this.page).show(),$(this.box).find(".w2ui-form-header").html(this.header),"object"==typeof this.tabs&&$.isArray(this.tabs.tabs)&&this.tabs.tabs.length>0?($("#form_"+this.name+"_tabs").show(),this.tabs.active=this.tabs.tabs[this.page].id,this.tabs.refresh()):$("#form_"+this.name+"_tabs").hide(),"object"==typeof this.toolbar&&$.isArray(this.toolbar.items)&&this.toolbar.items.length>0?($("#form_"+this.name+"_toolbar").show(),this.toolbar.refresh()):$("#form_"+this.name+"_toolbar").hide());for(var e=0;e0){var k=$(e.el).data("w2field").helpers.multi;$(k).removeClass("w2ui-error")}(""===j||null==j||$.isArray(j)&&0===j.length||$.isPlainObject(j)&&$.isEmptyObject(j))&&(j=null),b.setValue(this.name,j),b.trigger($.extend(i,{phase:"after"}))}}).on("input.w2form",function(a){var c=this.value;"checkbox"==a.target.type&&(c=a.target.checked),null==b.original&&($.isEmptyObject(b.record)?b.original={}:b.original=$.extend(!0,{},b.record));var d=b.trigger({phase:"before",target:this.name,type:"input",value_new:c,originalEvent:a});d.isCancelled!==!0&&b.trigger($.extend(d,{phase:"after"}))}),f.required?$(f.el).parent().parent().addClass("w2ui-required"):$(f.el).parent().parent().removeClass("w2ui-required"),null!=f.disabled){var h=$(f.el);f.disabled?(null==h.data("w2ui-tabIndex")&&h.data("w2ui-tabIndex",h.prop("tabIndex")),$(f.el).prop("readonly",!0).prop("tabindex",-1).closest(".w2ui-field").addClass("w2ui-disabled")):$(f.el).prop("readonly",!1).prop("tabIndex",h.data("w2ui-tabIndex")).closest(".w2ui-field").removeClass("w2ui-disabled")}var g=f.el;g||(g=$(this.box).find("#"+f.field)),f.hidden?$(g).closest(".w2ui-field").hide():$(g).closest(".w2ui-field").show()}$(this.box).find("button, input[type=button]").each(function(a,c){$(c).off("click").on("click",function(a){var c=this.value;this.id&&(c=this.id),this.name&&(c=this.name),b.action(c,a)})});for(var e=0;e0&&!$.isPlainObject(k[0])&&(f.options.items=w2obj.field.prototype.normMenu(k));for(var l=!1,m=0;m0){k=w2obj.field.prototype.normMenu(k),$(f.el).html("");for(var p=0;p'+k[p].text+"'+(a.html.key.text||"")+''+(a.html.value.text||"")+"";b.append(d)},b.el.mapRefresh=function(c,d){var e,f=1;"map"==b.type&&($.isPlainObject(c)||(c={}),null==c._order&&(c._order=Object.keys(c)),e=c._order),"array"==b.type&&(Array.isArray(c)||(c=[]),e=c.map(function(a){return a.key})),e.forEach(function(a){var e=d.find("#"+b.name+"_key_"+f),g=d.find("#"+b.name+"_value_"+f);0!=e.length&&0!=g.length||(b.el.mapAdd(b,d,f),e=d.find("#"+b.name+"_key_"+f),g=d.find("#"+b.name+"_value_"+f));var h=c[a];if("array"==b.type){var i=c.filter(function(b){return b.key==a});i.length>0&&(h=i[0].value)}e.val(a),g.val(h),e.parents(".w2ui-map-field").attr("data-key",a),f++});var g=d.find("#"+b.name+"_key_"+f).parent(),h=d.find("#"+b.name+"_key_"+(f+1)).parent();0==g.length&&b.el.mapAdd(b,d,f),1==g.length&&1==h.length&&(g.removeAttr("data-key"),g.find(".key").val(h.find(".key").val()),g.find(".value").val(h.find(".value").val()),h.remove()),$(b.el).next().find("input.w2ui-map").off(".mapChange").on("change.mapChange",function(){var e=$(event.target).parents(".w2ui-map-field"),f=e.attr("data-key"),g=e.find(".key").val(),h=e.find(".value").val(),i={},j={},k=null,l=null;i[g]=h,"array"==b.type&&(c.forEach(function(a,b){a.key==f&&(l=b)}),k=c[l]),null!=f&&"map"==b.type&&(j[f]=c[f]),null!=f&&"array"==b.type&&(j[f]=k.value);var m=a.trigger({phase:"before",target:b.field,type:"change",originalEvent:event,value_new:i,value_previous:j});if(m.isCancelled!==!0){if("map"==b.type){delete c[f];var n=c._order.indexOf(f);if(""!=g){if(null!=c[g]){var o,p=0;do p++,o=g+p;while(null!=c[o]);g=o,e.find(".key").val(o)}c[g]=h,e.attr("data-key",g),n!=-1?c._order[n]=g:c._order.push(g)}else c._order.splice(n,1),e.find(".value").val("")}else"array"==b.type&&(""!=g?null==k?c.push({key:g,value:h}):(k.key=g,k.value=h):c.splice(aInd,1));a.setValue(b.field,c),b.el.mapRefresh(c,d),a.trigger($.extend(m,{phase:"after"}))}})},b.el.mapRefresh(i,$(b.el).parent().find(".w2ui-map-container"))}(this,f);break;case"radio":$(f.$el).prop("checked",!1).each(function(a,b){$(b).val()==i&&$(b).prop("checked",!0)});break;case"checkbox":$(f.el).prop("checked",!!i);break;case"html":case"custom":case"empty":break;default:$(f.el).val(i),$(f.el).w2field($.extend({},f.options,{type:f.type}))}}for(var g=$(this.box).find(".w2ui-page"),m=0;m *").length>1&&$(g[m]).wrapInner("
    ");return this.trigger($.extend(c,{phase:"after"})),this.resize(),(new Date).getTime()-a}}},render:function(a){var b=(new Date).getTime(),c=this;if("object"==typeof a&&($(this.box).find("#form_"+this.name+"_tabs").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),this.box=a),this.isGenerated&&this.box){var d=this.trigger({phase:"before",target:this.name,type:"render",box:null!=a?a:this.box});if(d.isCancelled!==!0){var e='
    '+(""!==this.header?'
    '+this.header+"
    ":"")+' '+this.formHTML+"
    ";$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-form").html(e),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),"function"!=typeof this.toolbar.render&&(this.toolbar=$().w2toolbar($.extend({},this.toolbar,{name:this.name+"_toolbar",owner:this})),this.toolbar.on("click",function(a){var b=c.trigger({phase:"before",type:"toolbar",target:a.target,originalEvent:a});b.isCancelled!==!0&&c.trigger($.extend(b,{phase:"after"}))})),"object"==typeof this.toolbar&&"function"==typeof this.toolbar.render&&this.toolbar.render($("#form_"+this.name+"_toolbar")[0]),"function"!=typeof this.tabs.render&&(this.tabs=$().w2tabs($.extend({},this.tabs,{name:this.name+"_tabs",owner:this,active:this.tabs.active})),this.tabs.on("click",function(a){c.goto(this.get(a.target,!0))})),"object"==typeof this.tabs&&"function"==typeof this.tabs.render&&(this.tabs.render($("#form_"+this.name+"_tabs")[0]),this.tabs.active&&this.tabs.click(this.tabs.active)),this.trigger($.extend(d,{phase:"after"})),this.resize();var f="object"!=typeof this.url?this.url:this.url.get;return f&&0!==this.recid&&null!=this.recid?this.request():this.refresh(),0===$(".w2ui-layout").length&&(this.tmp_resize=function(a){w2ui[c.name].resize()},$(window).off("resize","body").on("resize","body",this.tmp_resize)),this.focus!=-1&&setTimeout(function(){0===$(c.box).find("input, select, textarea").length?setTimeout(focusEl,500):c.applyFocus()},50),(new Date).getTime()-b}}},applyFocus:function(){for(var a=this.focus,b=$(this.box).find("div:not(.w2ui-field-helper) > input, select, textarea, div > label:nth-child(1) > :radio").not(".file-input");$(b[a]).is(":hidden")&&b.length>=a;)a++;b[a]&&b[a].focus()},destroy:function(){var a=this.trigger({phase:"before",target:this.name,type:"destroy"});a.isCancelled!==!0&&("object"==typeof this.toolbar&&this.toolbar.destroy&&this.toolbar.destroy(),"object"==typeof this.tabs&&this.tabs.destroy&&this.tabs.destroy(),$(this.box).find("#form_"+this.name+"_tabs").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),delete w2ui[this.name],this.trigger($.extend(a,{phase:"after"})),$(window).off("resize","body"))}},$.extend(w2form.prototype,w2utils.event),w2obj.form=w2form}(jQuery),function(a,b){if("function"==typeof define&&define.amd)return define(function(){return b});if("undefined"!=typeof exports){if("undefined"!=typeof module&&module.exports)return exports=module.exports=b;a=exports}for(var c in b)a[c]=b[c]}(this,{w2ui:w2ui,w2obj:w2obj,w2utils:w2utils,w2popup:w2popup,w2alert:w2alert,w2confirm:w2confirm,w2prompt:w2prompt}); \ No newline at end of file diff --git a/src/w2form.js b/src/w2form.js index 013ece3a3..35ca7dc49 100644 --- a/src/w2form.js +++ b/src/w2form.js @@ -524,6 +524,11 @@ }) } } + if (fld.type == 'map') { + var tmp = { nestedFields: true, record: data }; + var val = this.getValue.call(tmp, fld.field); + if (val._order) delete val._order + } }.bind(this)) return data; }, @@ -993,6 +998,7 @@ input = '
    '; break; case 'map': + case 'array': field.html.key = field.html.key || {}; field.html.value = field.html.value || {}; input = ''+ @@ -1452,8 +1458,18 @@ $(field.el).val(value); break; case 'map': + case 'array': + // init map + if (field.type == 'map' && (value == null || !$.isPlainObject(value))) { + this.setValue(field.field, {}) + value = this.getValue(field.field) + } + if (field.type == 'array' && (value == null || !Array.isArray(value))) { + this.setValue(field.field, []) + value = this.getValue(field.field) + } // need closure - (function (field) { + (function (obj, field) { field.el.mapAdd = function (field, div, cnt) { var html = '
    '+ ''+ @@ -1466,7 +1482,17 @@ field.el.mapRefresh = function (map, div) { // generate options var cnt = 1; - Object.keys(map).forEach(function (item) { + var names; + if (field.type == 'map') { + if (!$.isPlainObject(map)) map = {} + if (map._order == null) map._order = Object.keys(map) + names = map._order + } + if (field.type == 'array') { + if (!Array.isArray(map)) map = [] + names = map.map(function (item) { return item.key }) + } + names.forEach(function (item) { var $k = div.find('#' + field.name + '_key_' + cnt) var $v = div.find('#' + field.name + '_value_' + cnt) if ($k.length == 0 || $v.length == 0) { @@ -1474,32 +1500,98 @@ $k = div.find('#' + field.name + '_key_' + cnt) $v = div.find('#' + field.name + '_value_' + cnt) } + var val = map[item]; + if (field.type == 'array') { + var tmp = map.filter(function(it) { return it.key == item ? true : false}) + if (tmp.length > 0) val = tmp[0].value + } $k.val(item) - $v.val(map[item]) - $k.parent().attr('data-key', item) + $v.val(val) + $k.parents('.w2ui-map-field').attr('data-key', item) cnt++ }) - field.el.mapAdd(field, div, cnt); + var curr = div.find('#' + field.name + '_key_' + cnt).parent() + var next = div.find('#' + field.name + '_key_' + (cnt + 1)).parent() + if (curr.length == 0) { + field.el.mapAdd(field, div, cnt); + } + if (curr.length == 1 && next.length == 1) { + curr.removeAttr('data-key') + curr.find('.key').val(next.find('.key').val()); + curr.find('.value').val(next.find('.value').val()); + next.remove() + } // attach events $(field.el).next().find('input.w2ui-map') .off('.mapChange') - .on('input.mapChange', function (event) { - var $cont = $(event.target).parents('.w2ui-field') - var $input = $cont.find('input') - var old_key = $(event.target).parents('.w2ui-map-field').attr('data-key') - var key = $(event.target).parents('.w2ui-map-field').find('.key').val() - var value = $(event.target).parents('.w2ui-map-field').find('.value').val() - delete map[old_key]; - map[key] = value; - console.log('change', map); - }) - .on('blur.mapChange', function () { - console.log('blue') + .on('change.mapChange', function () { + var $div = $(event.target).parents('.w2ui-map-field') + var old = $div.attr('data-key') + var key = $div.find('.key').val() + var value = $div.find('.value').val() + // event before + var value_new = {} + var value_previous = {} + var aMap = null + var aIndex = null + value_new[key] = value + if (field.type == 'array') { + map.forEach(function (it, ind) { + if (it.key == old) aIndex = ind + }) + aMap = map[aIndex] + } + if (old != null && field.type == 'map') { + value_previous[old] = map[old] + } + if (old != null && field.type == 'array') { + value_previous[old] = aMap.value + } + var edata = obj.trigger({ phase: 'before', target: field.field, type: 'change', originalEvent: event, value_new: value_new, value_previous: value_previous }) + if (edata.isCancelled === true) { + return; + } + if (field.type == 'map') { + delete map[old]; + var ind = map._order.indexOf(old) + if (key != '') { + if (map[key] != null) { + var newKey, more = 0 + do { more++; newKey = key + more } while (map[newKey] != null) + key = newKey + $div.find('.key').val(newKey) + } + map[key] = value; + $div.attr('data-key', key) + if (ind != -1) { + map._order[ind] = key + } else { + map._order.push(key) + } + } else { + map._order.splice(ind, 1) + $div.find('.value').val('') + } + } else if (field.type == 'array') { + if (key != '') { + if (aMap == null) { + map.push({ key: key, value: value }) + } else { + aMap.key = key + aMap.value = value + } + } else { + map.splice(aInd, 1) + } + } + obj.setValue(field.field, map) field.el.mapRefresh(map, div) + // event after + obj.trigger($.extend(edata, { phase: 'after' })); }) } field.el.mapRefresh(value, $(field.el).parent().find('.w2ui-map-container')) - })(field) + })(this, field) break; case 'radio': $(field.$el).prop('checked', false).each(function (index, el) { diff --git a/src/w2grid.js b/src/w2grid.js index 74931dd06..d70fe105f 100644 --- a/src/w2grid.js +++ b/src/w2grid.js @@ -398,7 +398,7 @@ info : null // info bubble, can be bool/object }, - msgDelete : 'Are you sure you want to delete selected records?', + msgDelete : 'Are you sure you want to delete NN records?', msgNotJSON : 'Returned data is not in valid JSON format.', msgAJAXerror : 'AJAX error. See console for more details.', msgRefresh : 'Refreshing...', @@ -2373,8 +2373,6 @@ if (!w2utils.isInt(this.last.xhr_offset)) this.last.xhr_offset = 0; // add list params var params = { - cmd : cmd, - selected : this.getSelection(), limit : this.limit, offset : parseInt(this.offset) + parseInt(this.last.xhr_offset), searchLogic : this.last.logic, @@ -3158,9 +3156,11 @@ if (recs.length === 0) return; if (this.msgDelete != '' && !force) { this.message({ - width : 350, + width : 380, height : 170, - body : '
    ' + w2utils.lang(obj.msgDelete) + '
    ', + body : '
    ' + + w2utils.lang(obj.msgDelete).replace('NN', recs.length).replace('records', (recs.length == 1 ? 'record' : 'records')) + + '
    ', buttons : (w2utils.settings.macButtonOrder ? '' + '' diff --git a/test/form2.html b/test/form2.html index 4216d2672..ac09ddb0b 100644 --- a/test/form2.html +++ b/test/form2.html @@ -18,12 +18,25 @@ header : 'Edit header', //formURL : 'form-template.html', //formHTML: 'some html', + onChange(event) { + console.log(event) + }, record: { "field_date": '3/15/2013', - "field_map": { - key1: 'some', - key2: '2' - } + "field_map1": { + key1: '1', + key2: '2', + key3: '3', + key4: '4', + key5: '5' + }, + "field_array": [ + { key: 'key1', value: '1' }, + { key: 'key2', value: '2' }, + { key: 'key3', value: '3' }, + { key: 'key4', value: '4' }, + { key: 'key5', value: '5' } + ] }, tabs: ['General', 'Aditional'], fields: [ @@ -34,6 +47,13 @@ value: { attr: 'placeholder="value"', text: ''} }, }, + { field: 'field_array', type: 'array', required: true, + html: { + label: 'Array', page: 0, text: '', + key: { attr: 'placeholder="key"', text: '='}, + value: { attr: 'placeholder="value"', text: ''} + }, + }, { field: 'field_text', type: 'text', required: true, html: { label: 'Text', page: 0 } }, @@ -83,6 +103,9 @@ //obj.clear(); }); } + }, + onChange: function (event) { + console.log('change', event) } }); });