1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-25 03:34:05 +00:00
8bitworkshop/lib/w2ui-1.5.rc1.min.js

14 lines
396 KiB
JavaScript
Raw Normal View History

/* w2ui 1.5.rc1 (nightly) (c) http://w2ui.com, vitmalina@gmail.com */
var w2ui=w2ui||{},w2obj=w2obj||{},w2utils=function(a){function b(a){var b=/^[0-1]+$/;return b.test(a)}function c(a){var b=/^[-+]?[0-9]+$/;return b.test(a)}function d(a){return"string"==typeof a&&(a=a.replace(/\s+/g,"").replace(w2utils.settings.groupSymbol,"").replace(w2utils.settings.decimalSymbol,".")),("number"==typeof a||"string"==typeof a&&""!==a)&&!isNaN(Number(a))}function e(a){var b=w2utils.settings,c=new RegExp("^"+(b.currencyPrefix?"\\"+b.currencyPrefix+"?":"")+"[-+]?"+(b.currencyPrefix?"\\"+b.currencyPrefix+"?":"")+"[0-9]*[\\"+b.decimalSymbol+"]?[0-9]+"+(b.currencySuffix?"\\"+b.currencySuffix+"?":"")+"$","i");return"string"==typeof a&&(a=a.replace(new RegExp(b.groupSymbol,"g"),"")),"object"!=typeof a&&""!==a&&c.test(a)}function f(a){var b=/^[a-fA-F0-9]+$/;return b.test(a)}function g(a){var b=/^[a-zA-Z0-9_-]+$/;return b.test(a)}function h(a){var b=/^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;return b.test(a)}function i(a,b,d){if(!a)return!1;var e,f,g,h="Invalid Date";if(null==b&&(b=w2utils.settings.dateFormat),"function"==typeof a.getUTCFullYear)g=a.getUTCFullYear(),e=a.getUTCMonth()+1,f=a.getUTCDate();else if(parseInt(a)==a&&parseInt(a)>0)a=new Date(parseInt(a)),g=a.getUTCFullYear(),e=a.getUTCMonth()+1,f=a.getUTCDate();else{if(a=String(a),new RegExp("mon","ig").test(b)){b=b.replace(/month/gi,"m").replace(/mon/gi,"m").replace(/dd/gi,"d").replace(/[, ]/gi,"/").replace(/\/\//g,"/").toLowerCase(),a=a.replace(/[, ]/gi,"/").replace(/\/\//g,"/").toLowerCase();for(var i=0,j=w2utils.settings.fullmonths.length;i<j;i++){var k=w2utils.settings.fullmonths[i];a=a.replace(new RegExp(k,"ig"),parseInt(i)+1).replace(new RegExp(k.substr(0,3),"ig"),parseInt(i)+1)}}var l=a.replace(/-/g,"/").replace(/\./g,"/").toLowerCase().split("/"),m=b.replace(/-/g,"/").replace(/\./g,"/").toLowerCase();"mm/dd/yyyy"===m&&(e=l[0],f=l[1],g=l[2]),"m/d/yyyy"===m&&(e=l[0],f=l[1],g=l[2]),"dd/mm/yyyy"===m&&(e=l[1],f=l[0],g=l[2]),"d/m/yyyy"===m&&(e=l[1],f=l[0],g=l[2]),"yyyy/dd/mm"===m&&(e=l[2],f=l[1],g=l[0]),"yyyy/d/m"===m&&(e=l[2],f=l[1],g=l[0]),"yyyy/mm/dd"===m&&(e=l[1],f=l[2],g=l[0]),"yyyy/m/d"===m&&(e=l[1],f=l[2],g=l[0]),"mm/dd/yy"===m&&(e=l[0],f=l[1],g=l[2]),"m/d/yy"===m&&(e=l[0],f=l[1],g=parseInt(l[2])+1900),"dd/mm/yy"===m&&(e=l[1],f=l[0],g=parseInt(l[2])+1900),"d/m/yy"===m&&(e=l[1],f=l[0],g=parseInt(l[2])+1900),"yy/dd/mm"===m&&(e=l[2],f=l[1],g=parseInt(l[0])+1900),"yy/d/m"===m&&(e=l[2],f=l[1],g=parseInt(l[0])+1900),"yy/mm/dd"===m&&(e=l[1],f=l[2],g=parseInt(l[0])+1900),"yy/m/d"===m&&(e=l[1],f=l[2],g=parseInt(l[0])+1900)}return!!c(g)&&(!!c(e)&&(!!c(f)&&(g=+g,e=+e,f=+f,h=new Date(g,e-1,f),null!=e&&("Invalid Date"!=String(h)&&(h.getMonth()+1===e&&h.getDate()===f&&h.getFullYear()===g&&(d!==!0||h))))))}function j(b,c){if(null==b)return!1;var d,e,f;b=String(b),b=b.toUpperCase(),e=b.indexOf("AM")>=0,f=b.indexOf("PM")>=0;var g=f||e;d=g?12:24,b=b.replace("AM","").replace("PM",""),b=a.trim(b);var h=b.split(":"),i=parseInt(h[0]||0),j=parseInt(h[1]||0),k=parseInt(h[2]||0);return!!(g&&1===h.length||2===h.length||3===h.length)&&(!(""===h[0]||i<0||i>d||!this.isInt(h[0])||h[0].length>2)&&(!(h.length>1&&(""===h[1]||j<0||j>59||!this.isInt(h[1])||2!==h[1].length))&&(!(h.length>2&&(""===h[2]||k<0||k>59||!this.isInt(h[2])||2!==h[2].length))&&(!!(g||d!==i||0===j&&0===k)&&((!g||1!==h.length||0!==i)&&(c!==!0||(f&&12!==i&&(i+=12),e&&12===i&&(i+=12),{hours:i,minutes:j,seconds:k})))))))}function k(a,b,c){null==b&&(b=w2utils.settings.datetimeFormat);var d=b.split("|");if("function"==typeof a.getUTCFullYear)return c!==!0||a;if(parseInt(a)==a&&parseInt(a)>0)return a=new Date(parseInt(a)),c!==!0||a;var e=String(a).indexOf(" "),f=[a.substr(0,e),a.substr(e).trim()];d[0]=d[0].trim(),d[1]&&(d[1]=d[1].trim());var g=w2utils.isDate(f[0],d[0],!0),h=w2utils.isTime(f[1],!0);return g!==!1&&h!==!1&&(c!==!0||(g.setHours(h.hours),g.setMinutes(h.minutes),g.setSeconds(h.seconds),g))}function l(a){var b;if(""===a||null==a)return"";if(b="function"==typeof a.getUTCFullYear?a:parseInt(a)==a&&parseInt(a)>0?new Date(parseInt(a)):new Date(a),"Invalid Date"==String(b))return"";var c=new Date,d=(
}}return d.isPlainObject(a)||(a={type:a,scope:c}),a=d.extend({type:null,execute:"before",target:null,onComplete:null},a),a.type?b?(d.isArray(this.handlers)||(this.handlers=[]),console.log("add",a),void this.handlers.push({edata:a,handler:b})):void console.log("ERROR: You must specify event handler function when calling .on() method of "+this.name):void console.log("ERROR: You must specify event type when calling .on() method of "+this.name)},off:function(a,b){var c,d=jQuery;if("string"==typeof a&&a.indexOf(".")!=-1){var e=a.split(".");a=e[0],c=e[1]}if("string"==typeof a&&a.indexOf(":")!=-1){var e=a.split(":");["complete","done"].indexOf(a[1])!=-1&&(a[1]="after"),a={type:e[0],execute:e[1]}}if(d.isPlainObject(a)||(a={type:a}),a=d.extend({},{type:null,execute:"before",target:null,onComplete:null},a),!a.type&&!c)return void console.log("ERROR: You must specify event type when calling .off() method of "+this.name);b||(b=null);for(var f=[],g=0,h=this.handlers.length;g<h;g++){var i=this.handlers[g];(i.edata.type!==a.type&&"*"!==a.type&&(null==i.edata.scope||""!=a.type)||i.edata.target!==a.target&&null!=a.target||i.edata.execute!==a.execute&&null!=a.execute||i.handler!==b&&null!=b&&(null==c||i.edata.scope!=c))&&f.push(i)}this.handlers=f},trigger:function(a){var b=jQuery,a=b.extend({type:null,phase:"before",target:null,doneHandlers:[]},a,{isStopped:!1,isCancelled:!1,done:function(a){this.doneHandlers.push(a)},preventDefault:function(){this.isCancelled=!0},stopPropagation:function(){this.isStopped=!0}});"before"===a.phase&&(a.onComplete=null);var c,d,e;null==a.target&&(a.target=null),b.isArray(this.handlers)||(this.handlers=[]);for(var f=this.handlers.length-1;f>=0;f--){var g=this.handlers[f];if(!(g.edata.type!==a.type&&"*"!==g.edata.type||g.edata.target!==a.target&&null!=g.edata.target||g.edata.execute!==a.phase&&"*"!==g.edata.execute&&"*"!==g.edata.phase)&&(a=b.extend({},g.edata,a),c=[],e=new RegExp(/\((.*?)\)/).exec(g.handler),e&&(c=e[1].split(/\s*,\s*/)),2===c.length?g.handler.call(this,a.target,a):g.handler.call(this,a),a.isStopped===!0||a.stop===!0))return a}var h="on"+a.type.substr(0,1).toUpperCase()+a.type.substr(1);if("before"===a.phase&&"function"==typeof this[h]&&(d=this[h],c=[],e=new RegExp(/\((.*?)\)/).exec(d),e&&(c=e[1].split(/\s*,\s*/)),2===c.length?d.call(this,a.target,a):d.call(this,a),a.isStopped===!0||a.stop===!0))return a;if(null!=a.object&&"before"===a.phase&&"function"==typeof a.object[h]&&(d=a.object[h],c=[],e=new RegExp(/\((.*?)\)/).exec(d),e&&(c=e[1].split(/\s*,\s*/)),2===c.length?d.call(this,a.target,a):d.call(this,a),a.isStopped===!0||a.stop===!0))return a;if("after"===a.phase){"function"==typeof a.onComplete&&a.onComplete.call(this,a);for(var i=0;i<a.doneHandlers.length;i++)"function"==typeof a.doneHandlers[i]&&a.doneHandlers[i].call(this,a)}return a}},function(a){a.fn.w2render=function(b){a(this).length>0&&("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('<span class="w2ui-marker">')!=-1;)b.innerHTML=b.innerHTML.replace(/\<span class=\"w2ui\-marker\"\>((.|\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'<span class="w2ui-marker">'+a+"</span>"}b(a,d);for(var f=0;f<c.length;f++){var g=c[f];"string"!=typeof g&&(g=String(g)),g=g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&").replace(/&/g,"&amp;").replace(/</g,"&gt;").replace(/>/g,"&lt;");var h=new RegExp(g+"(?!([^<]+)?>)","gi");d.innerHTML=d.innerHTML.replace(h,e)}}):a(this).each(b)},a.fn.w2tag=function(b,c){return 1==arguments.length&&"object"==typeof b&&(c=b,null!=c.html&&(b=c.html)),c=a.extend({id:null,html:b,position:"right|top",align:"none",left:0,top:0,style:"",css:{},className:"",inputClass:"",onShow:null,onHide:null,hideOnKeyPress:!0,hideOnBlur:!1,hideOnClick:!1},c
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<b.length;d++){if(this.columns.splice(a,0,b[d]),b[d].searchable){var e=b[d].searchable,f="";b[d].searchable===!0&&(e="text",f='size="20"'),this.addSearch({field:b[d].field,caption:b[d].caption,type:e,attr:f})}a++,c++}return this.refresh(),c},removeColumn:function(){for(var a=0,b=0;b<arguments.length;b++)for(var c=this.columns.length-1;c>=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<this.columns.length;d++)c.push(this.columns[d].field);return c}for(var d=0;d<this.columns.length;d++)if(this.columns[d].field==a)return b===!0?d:this.columns[d];return null},toggleColumn:function(){for(var a=0,b=0;b<arguments.length;b++)for(var c=this.columns.length-1;c>=0;c--){var d=this.columns[c];d.field==arguments[b]&&(d.hidden=!d.hidden,a++)}return this.refreshBody(),this.resizeRecords(),a},showColumn:function(){for(var a=0,b=0;b<arguments.length;b++)for(var c=this.columns.length-1;c>=0;c--){var d=this.columns[c];d.gridMinWidth&&delete d.gridMinWidth,d.field==arguments[b]&&d.hidden!==!1&&(d.hidden=!1,a++)}return this.refreshBody(),this.resizeRecords(),a},hideColumn:function(){for(var a=0,b=0;b<arguments.length;b++)for(var c=this.columns.length-1;c>=0;c--){var d=this.columns[c];d.field==arguments[b]&&d.hidden!==!0&&(d.hidden=!0,a++)}return this.refreshBody(),this.resizeRecords(),a},addSearch:function(a,b){var c=0;1==arguments.length?(b=a,a=this.searches.length):("string"==typeof a&&(a=this.getSearch(a,!0)),null==a&&(a=this.searches.length)),$.isArray(b)||(b=[b]);for(var d=0;d<b.length;d++)this.searches.splice(a,0,b[d]),a++,c++;return this.searchClose(),c},removeSearch:function(){for(var a=0,b=0;b<arguments.length;b++)for(var c=this.searches.length-1;c>=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<this.searches.length;d++)c.push(this.searches[d].field);return c}for(var d=0;d<this.searches.length;d++)if(this.searches[d].field==a)return b===!0?d:this.searches[d];return null},toggleSearch:function(){for(var a=0,b=0;b<arguments.length;b++)for(var c=this.searches.length-1;c>=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<arguments.length;b++)for(var c=this.searches.length-1;c>=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<arguments.length;b++)for(var c=this.searches.length-1;c>=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;b<this.searchData.length;b++)if(this.searchData[b].field==a)return this.searchData[b];return null},localSort:function(a,b){function c(){for(var a=0;a<k.records.length;a++){var b=k.records[a];b.w2ui&&null!=b.w2ui.parent_recid&&(b.w2ui._path=f(b))}}function d(){for(var a=0;a<k.records.length;a++){var b=k.records[a];b.w2ui&&null!=b.w2ui.parent_recid&&(b.w2ui._path=null)}}function e(a,b){if(!(a.w2ui&&null!=a.w2ui.parent_recid||b.w2ui&&null!=b.w2ui.parent_recid))return g(a,b);for(var c=f(a),d=f(b),e=0;e<Math.min(c.length,d.length);e++){var h=g(c[e],d[e]);if(0!==h)return h}return c.length>d.length?1:c.length<d.length?-1:(console.log("ERROR: two paths should not be equal."),0)}function f(a){if(!a.w2ui||null==a.w2ui.parent_recid)ret
}if("int"==k.type&&""!==b){if(A="is",String(b).indexOf("-")!=-1){var v=b.split("-");2==v.length&&(A="between",B=[parseInt(v[0]),parseInt(v[1])])}if(String(b).indexOf(",")!=-1){var v=b.split(",");A="in",B=[];for(var j=0;j<v.length;j++)B.push(v[j])}}null!=k.operator&&(A=k.operator);var v={field:k.field,type:k.type,operator:A,value:B};d.push(v)}}if($.isArray(a)){var C="AND";"string"==typeof b&&(C=b.toUpperCase(),"OR"!=C&&"AND"!=C&&(C="AND")),h="",e=!0,f=C;for(var j=0;j<a.length;j++){var D=a[j],k=this.getSearch(D.field);if(null==k&&(k={type:"text",operator:"begins"}),$.isArray(D.value))for(var u=0;u<D.value.length;u++)"string"==typeof D.value[u]&&(D.value[u]=D.value[u].toLowerCase());d.push($.extend(!0,{},k,D))}}var E=this.trigger({phase:"before",type:"search",multi:0===arguments.length,target:this.name,searchData:d,searchField:a?a:"multi",searchValue:a?b:"multi"});E.isCancelled!==!0&&(this.searchData=E.searchData,this.last.field=g,this.last.search=h,this.last.multi=e,this.last.logic=f,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selection.indexes=[],this.last.selection.columns={},this.searchClose(),c?(this.last.xhr_offset=0,this.reload()):(this.localSearch(),this.refresh()),this.trigger($.extend(E,{phase:"after"})))},searchOpen:function(){if(this.box&&0!==this.searches.length){var a=this,b=this.trigger({phase:"before",type:"searchOpen",target:this.name});return b.isCancelled===!0?void setTimeout(function(){a.toolbar.uncheck("w2ui-search-advanced")},1):void $("#tb_"+this.name+"_toolbar_item_w2ui-search-advanced").w2overlay({html:this.getSearchesHTML(),name:this.name+"-searchOverlay",left:-10,class:"w2ui-grid-searches",onShow:function(){a.initSearches(),$("#w2ui-overlay-"+a.name+"-searchOverlay .w2ui-grid-searches").data("grid-name",a.name);var c=$("#w2ui-overlay-"+this.name+"-searchOverlay .w2ui-grid-searches *[rel=search]");c.length>0&&c[0].focus(),a.trigger($.extend(b,{phase:"after"}))}})}},searchClose:function(){this.box&&0!==this.searches.length&&(this.toolbar&&this.toolbar.uncheck("w2ui-search-advanced"),$().w2overlay({name:this.name+"-searchOverlay"}),$().w2overlay({name:this.name+"-searchOverlay"}))},searchReset:function(a){for(var b=[],c=!1,d=0;d<this.searches.length;d++)this.searches[d].hidden&&(b.push({field:this.searches[d].field,operator:this.searches[d].operator||"is",type:this.searches[d].type,value:this.searches[d].value||""}),c=!0);var e=this.trigger({phase:"before",type:"search",reset:!0,target:this.name,searchData:b});if(e.isCancelled!==!0){if(this.searchData=e.searchData,this.last.search="",this.last.logic=c?"AND":"OR",this.searches.length>0)if(this.multiSearch&&this.show.searchAll)this.last.field="all",this.last.caption=w2utils.lang("All Fields");else{for(var f=0;f<this.searches.length&&(this.searches[f].hidden||this.searches[f].simple===!1);)f++;f>=this.searches.length?(this.last.field="",this.last.caption=""):(this.last.field=this.searches[f].field,this.last.caption=this.searches[f].caption)}this.last.multi=!1,this.last.xhr_offset=0,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selection.indexes=[],this.last.selection.columns={},this.searchClose(),$("#grid_"+this.name+"_search_all").val("").removeData("selected"),a||this.reload(),this.trigger($.extend(e,{phase:"after"}))}},searchShowFields:function(){for(var a=this,b=$("#grid_"+this.name+"_search_all"),c='<div class="w2ui-select-field"><table><tbody>',d=-1;d<this.searches.length;d++){var e=this.searches[d];if(d==-1){if(!this.multiSearch||!this.show.searchAll)continue;e={field:"all",caption:w2utils.lang("All Fields")}}else if(this.searches[d].hidden===!0||this.searches[d].simple===!1)continue;c+="<tr "+(w2utils.isIOS?"onTouchStart":"onClick")+"=\"w2ui['"+this.name+"'].initAllField('"+e.field+"'); event.stopPropagation(); jQuery('#grid_"+this.name+"_search_all').w2overlay({ name: '"+this.name+'-searchFields\' });"> <td> <span class="w2ui-column-check w2ui-icon-'+(e.field==this.last.field?"check":"empty")+'"></span> </td> <td>'+e.caption+"</td></tr>"}c+="</tbody></table></div>",setTimeout(function(){$(b).w2overlay({html
B=n;for(var v=[],t=0;t<k.length;t++)v.push({recid:d.records[B].recid,column:k[t]});d.unselect.apply(d,v)}else{for(var v=[],t=0;t<k.length;t++)v.push({recid:d.records[B].recid,column:k[t]});d.select.apply(d,v)}}else i.length>300?this.selectNone():this.unselect.apply(this,i),d.click({recid:d.records[B].recid,column:k[0]},a);d.scrollIntoView(B),q=!0}else if(!s)if(i.length>1)d.selectNone();else for(var A=0;A<i.length-1;A++)d.unselect(i[A]);break;case 17:case 91:if(g)break;d.last.isSafari&&(d.last.copy_event=d.copy(!1,a),$("#grid_"+d.name+"_focus").val(d.last.copy_event.text).select());break;case 67:(a.metaKey||a.ctrlKey)&&(d.last.isSafari?d.copy(d.last.copy_event,a):(d.last.copy_event=d.copy(!1,a),$("#grid_"+d.name+"_focus").val(d.last.copy_event.text).select(),d.copy(d.last.copy_event,a)));break;case 88:if(g)break;(a.ctrlKey||a.metaKey)&&(d.last.isSafari?d.copy(d.last.copy_event,a):(d.last.copy_event=d.copy(!1,a),$("#grid_"+d.name+"_focus").val(d.last.copy_event.text).select(),d.copy(d.last.copy_event,a)),setTimeout(function(){d.delete(!0)},100))}for(var v=[32,187,189,192,219,220,221,186,222,188,190,191],z=48;z<=111;z++)v.push(z);v.indexOf(r)==-1||a.ctrlKey||a.metaKey||q||(0===k.length&&k.push(0),q=!1,setTimeout(function(){var b=$("#grid_"+d.name+"_focus"),c=b.val();b.val(""),d.editField(j,k[0],c,a)},1)),q&&a.preventDefault&&a.preventDefault(),d.trigger($.extend(f,{phase:"after"}))}}},scrollIntoView:function(a,b,c){var d=this.records.length;if(0==this.searchData.length||this.url||(d=this.last.searchIds.length),0!==d){if(null==a){var e=this.getSelection();if(0===e.length)return;$.isPlainObject(e[0])?(a=e[0].index,b=e[0].column):a=this.get(e[0],!0)}var f=$("#grid_"+this.name+"_records"),g=this.last.searchIds.length;if(g>0&&(a=this.last.searchIds.indexOf(a)),f.height()<this.recordHeight*(g>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"))),(a<h||a>i)&&(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()<k-f.scrollLeft()?c===!0?f.prop({scrollLeft:j-l}):f.animate({scrollLeft:j-l},250,"linear"):j<f.scrollLeft()&&(c===!0?f.prop({scrollLeft:k-f.width()+2*l}):f.animate({scrollLeft:k-f.width()+2*l},250,"linear"))}}},dblClick:function(a,b){var c=null;if("object"==typeof a&&(c=a.column,a=a.recid),null==b&&(b={}),null==c&&b.target){var d=b.target;"TD"!=d.tagName.toUpperCase()&&(d=$(d).parents("td")[0]),c=parseInt($(d).attr("col"))}var e=this.get(a,!0),f=this.records[e],g=this.trigger({phase:"before",target:this.name,type:"dblClick",recid:a,column:c,originalEvent:b});if(g.isCancelled!==!0){this.selectNone();var h=this.getCellEditable(e,c);h?this.editField(a,c,null,b):(this.select({recid:a,column:c}),(this.show.expandColumn||f.w2ui&&Array.isArray(f.w2ui.children))&&this.toggle(a)),this.trigger($.extend(g,{phase:"after"}))}},contextMenu:function(a,b,c){var d=this;if("text"!=d.last.userSelect){null==c&&(c={offsetX:0,offsetY:0,target:$("#grid_"+d.name+"_rec_"+a)[0]}),null==c.offsetX&&(c.offsetX=c.layerX-c.target.offsetLeft,c.offsetY=c.layerY-c.target.offsetTop),w2utils.isFloat(a)&&(a=parseFloat(a));var e=this.getSelection();if("row"==this.selectType)e.indexOf(a)==-1&&d.click(a);else{var f=$(c.target);"TD"!=f[0].tagName.toUpperCase()&&(f=$(c.target).parents("td"));var g=!1;b=f.attr("col");for(var h=0;h<e.length;h++)e[h].recid!=a&&e[h].column!=b||(g=!0);g||null==a||d.click({recid:a,column:b}),g||null==b||d.columnClick(this.columns[b].field,c)}var i=d.trigger({phase:"before",type:"contextMenu",target:d.name,originalEvent:c,recid:a,column:b});i.isCancelled!==!0&&(d.menu.length>0&&$(d
var d=this.columns[c],e=this.columns[c].caption;d.hideable!==!1&&(!e&&this.columns[c].tooltip&&(e=this.columns[c].tooltip),e||(e="- column "+(parseInt(c)+1)+" -"),b+='<tr id="grid_'+this.name+"_column_"+c+'_check" onclick="w2ui[\''+a.name+"'].columnOnOff(event, '"+d.field+'\'); event.stopPropagation();"> <td style="width: 30px; text-align: center; padding-right: 3px; color: #888;"> <span class="w2ui-column-check w2ui-icon-'+(d.hidden?"empty":"check")+'"></span> </td> <td onclick="jQuery(\'.w2ui-overlay\')[0].hide();"> <label>'+w2utils.stripTags(e)+"</label> </td></tr>")}var f="object"!=typeof this.url?this.url:this.url.get;(f&&a.show.skipRecords||a.show.saveRestoreState)&&(b+='<tr style="pointer-events: none"><td colspan="2"><div style="border-top: 1px solid #ddd;"></div></td></tr>'),f&&a.show.skipRecords&&(b+='<tr><td colspan="2" style="padding: 0px"> <div style="cursor: pointer; padding: 2px 8px; cursor: default">'+w2utils.lang("Skip")+' <input type="text" style="width: 60px" value="'+this.offset+'" onkeydown="if ([48,49,50,51,52,53,54,55,56,57,58,13,8,46,37,39].indexOf(event.keyCode) == -1) { event.preventDefault() }" onkeypress="if (event.keyCode == 13) { w2ui[\''+a.name+"'].skip(this.value); jQuery('.w2ui-overlay')[0].hide(); }\"/> "+w2utils.lang("Records")+" </div></td></tr>"),a.show.saveRestoreState&&(b+='<tr><td colspan="2" onclick="var obj = w2ui[\''+a.name+"']; obj.toolbar.uncheck('w2ui-column-on-off'); obj.stateSave();\"> <div style=\"cursor: pointer; padding: 4px 8px; cursor: default\">"+w2utils.lang("Save Grid State")+'</div></td></tr><tr><td colspan="2" onclick="var obj = w2ui[\''+a.name+"']; obj.toolbar.uncheck('w2ui-column-on-off'); obj.stateReset();\"> <div style=\"cursor: pointer; padding: 4px 8px; cursor: default\">"+w2utils.lang("Restore Default State")+"</div></td></tr>"),b+="</tbody></table></div>",this.toolbar.get("w2ui-column-on-off").html=b}},initColumnDrag:function(a){function b(){j.pressed=!1,clearTimeout(j.timeout)}function c(a){j.timeout&&clearTimeout(j.timeout);var b=this;j.pressed=!0,j.timeout=setTimeout(function(){if(j.pressed){var c,f,g,h,k,l=["w2ui-col-number","w2ui-col-expand","w2ui-col-select"],m=["w2ui-head-last"],n=l.concat(m),o=".w2ui-col-number, .w2ui-col-expand, .w2ui-col-select",p=".w2ui-head.w2ui-col-number, .w2ui-head.w2ui-col-expand, .w2ui-head.w2ui-col-select";if($(a.originalEvent.target).parents().hasClass("w2ui-head")){for(var q=0,r=n.length;q<r;q++)if($(a.originalEvent.target).parents().hasClass(n[q]))return;if(j.numberPreColumnsPresent=$(i.box).find(p).length,j.columnHead=h=$(a.originalEvent.target).parents(".w2ui-head"),k=parseInt(h.attr("col"),10),c=i.trigger({type:"columnDragStart",phase:"before",originalEvent:a,origColumnNumber:k,target:h[0]}),c.isCancelled===!0)return!1;f=j.columns=$(i.box).find(".w2ui-head:not(.w2ui-head-last)"),$(document).on("mouseup",e),$(document).on("mousemove",d),j.originalPos=parseInt($(a.originalEvent.target).parent(".w2ui-head").attr("col"),10),j.ghost=$(b).clone(!0),$(j.ghost).find('[col]:not([col="'+j.originalPos+'"]), .w2ui-toolbar, .w2ui-grid-header').remove(),$(j.ghost).find(o).remove(),$(j.ghost).find(".w2ui-grid-body").css({top:0}),g=$(j.ghost).find('[col="'+j.originalPos+'"]'),$(document.body).append(j.ghost),$(j.ghost).css({width:0,height:0,margin:0,position:"fixed",zIndex:999999,opacity:0}).addClass(".w2ui-grid-ghost").animate({width:g.width(),height:$(i.box).find(".w2ui-grid-body:first").height(),left:a.pageX,top:a.pageY,opacity:.8},0),j.offsets=[];for(var q=0,r=f.length;q<r;q++)j.offsets.push($(f[q]).offset().left);i.trigger($.extend(c,{phase:"after"}))}}},150)}function d(a){if(j.pressed){var b=a.originalEvent.pageX,c=a.originalEvent.pageY,d=j.offsets,e=$(".w2ui-head:not(.w2ui-head-last)").width();j.targetInt=Math.max(j.numberPreColumnsPresent,g(b,d,e)),f(j.targetInt),h(b,c)}}function e(a){j.pressed=!1;var b,c,f,g,h,k=$(".w2ui-grid-ghost");return b=i.trigger({type:"columnDragEnd",phase:"before",originalEvent:a,target:j.
for(var c=!this.reorderColumns||this.columnGroups&&this.columnGroups.length?"":" w2ui-reorder-cols-head ",d="",e=0;e<this.sortData.length;e++)this.sortData[e].field==b.field&&(new RegExp("asc","i").test(this.sortData[e].direction)&&(d="w2ui-sort-up"),new RegExp("desc","i").test(this.sortData[e].direction)&&(d="w2ui-sort-down"));var f=this.last.selection.columns,g=!1;for(var h in f)for(var e=0;e<f[h].length;e++)f[h][e]==a&&(g=!0);var i='<td id="grid_'+this.name+"_column_"+a+'" col="'+a+'" class="w2ui-head '+d+c+'" '+("normal"==this.columnTooltip&&b.tooltip?'title="'+b.tooltip+'" ':"")+" onmouseover = \"w2ui['"+this.name+"'].columnTooltipShow('"+a+"', event);\" onmouseout = \"w2ui['"+this.name+"'].columnTooltipHide('"+a+"', event);\" oncontextmenu = \"w2ui['"+this.name+"'].contextMenu(null, "+a+', event);" onclick="w2ui[\''+this.name+"'].columnClick('"+b.field+"', event);\" ondblclick=\"w2ui['"+this.name+"'].columnDblClick('"+b.field+"', event);\">"+(b.resizable!==!1?'<div class="w2ui-resizer" name="'+a+'"></div>':"")+' <div class="w2ui-col-header '+(d?"w2ui-col-sorted":"")+" "+(g?"w2ui-col-selected":"")+'"> <div class="'+d+'"></div>'+(b.caption?b.caption:"&#160;")+" </div></td>";return i},columnTooltipShow:function(a){if("normal"!=this.columnTooltip){var b=$(this.box).find("#grid_"+this.name+"_column_"+a),c=this.columns[a],d=this.columnTooltip;b.prop("_mouse_over",!0),setTimeout(function(){b.prop("_mouse_over")===!0&&b.prop("_mouse_tooltip")!==!0&&(b.prop("_mouse_tooltip",!0),b.w2tag(c.tooltip,{position:d}))},1)}},columnTooltipHide:function(a){if("normal"!=this.columnTooltip){var b=$(this.box).find("#grid_"+this.name+"_column_"+a);this.columns[a];b.removeProp("_mouse_over"),setTimeout(function(){b.prop("_mouse_over")!==!0&&b.prop("_mouse_tooltip")===!0&&(b.removeProp("_mouse_tooltip"),b.w2tag())},1)}},getRecordsHTML:function(){var a=this.records.length,b="object"!=typeof this.url?this.url:this.url.get;0==this.searchData.length||b||(a=this.last.searchIds.length),a>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start;var c=$("#grid_"+this.name+"_records"),d=Math.floor(c.height()/this.recordHeight)+this.last.show_extra+1;(!this.fixedBody||d>a)&&(d=a);var e=this.getRecordHTML(-1,0),f="<table><tbody>"+e[0],g="<table><tbody>"+e[1];f+='<tr id="grid_'+this.name+'_frec_top" line="top" style="height: 0px"> <td colspan="2000"></td></tr>',g+='<tr id="grid_'+this.name+'_rec_top" line="top" style="height: 0px"> <td colspan="2000"></td></tr>';for(var h=0;h<d;h++)e=this.getRecordHTML(h,h+1),f+=e[0],g+=e[1];return f+='<tr id="grid_'+this.name+'_frec_bottom" line="bottom" style="height: '+(a-d)*this.recordHeight+'px"> <td colspan="2000" style="border: 0"></td></tr><tr id="grid_'+this.name+'_frec_more" style="display: none; visibility: hidden"> <td colspan="2000" class="w2ui-load-more"></td></tr></tbody></table>',g+='<tr id="grid_'+this.name+'_rec_bottom" line="bottom" style="height: '+(a-d)*this.recordHeight+'px"> <td colspan="2000" style="border: 0"></td></tr><tr id="grid_'+this.name+'_rec_more" style="display: none"> <td colspan="2000" class="w2ui-load-more"></td></tr></tbody></table>',this.last.range_start=0,this.last.range_end=d,[f,g]},getSummaryHTML:function(){if(0!==this.summary.length){for(var a=this.getRecordHTML(-1,0),b="<table><tbody>"+a[0],c="<table><tbody>"+a[1],d=0;d<this.summary.length;d++)a=this.getRecordHTML(d,d+1,!0),b+=a[0],c+=a[1];return b+="</tbody></table>",c+="</tbody></table>",[b,c]}},scroll:function(a){function b(){c.markSearch&&(clearTimeout(c.last.marker_timer),c.last.marker_timer=setTimeout(function(){for(var a=[],b=0;b<c.searchData.length;b++){var d=c.searchData[b],e=c.getSearch(d.field);e&&!e.hidden&&a.indexOf(d.value)==-1&&a.push(d.value)}a.length>0&&$(c.box).find(".w2ui-grid-data > div").w2marker(a)},50))}var c=((new Date).getTime(),this),d="object"!=typeof this.url?this.url:this.url.get,e=$("#grid_"+this.name+"_records"),f=$("#grid_"+this.name+"_frecords");if(a){var g=a.target.scrollTop,h=a.target.scrollLeft;c.last.scrollTop=g,c.l
onResize:null,onDestroy:null,panel:{type:null,title:"",size:100,minSize:20,maxSize:!1,hidden:!1,resizable:!1,overflow:"auto",style:"",content:"",tabs:null,toolbar:null,width:null,height:null,show:{toolbar:!1,tabs:!1},onRefresh:null,onShow:null,onHide:null},html:function(a,b,c){return this.content(a,b,c)},content:function(b,c,d){var e=this,f=this.get(b);if("css"==b)return a("#layout_"+e.name+"_panel_css").html("<style>"+c+"</style>"),!0;if(null==f)return!1;if(null==c)return f.content;var g=this.trigger({phase:"before",type:"content",target:b,object:f,content:c,transition:d});if(g.isCancelled!==!0){if(c instanceof jQuery)return console.log("ERROR: You can not pass jQuery object to w2layout.content() method"),!1;var h="#layout_"+this.name+"_panel_"+f.type,i=a(h+"> .w2ui-panel-content"),j=0;if(i.length>0&&(a(h).scrollTop(0),j=a(i).position().top),""===f.content)f.content=c,this.refresh(b);else{if(f.content=c,!f.hidden&&null!=d&&""!==d){var k=a(h+"> .w2ui-panel-content");k.after('<div class="w2ui-panel-content new-panel" style="'+k[0].style.cssText+'"></div>');var l=a(h+"> .w2ui-panel-content.new-panel");k.css("top",j),l.css("top",j),"object"==typeof c?(c.box=l[0],c.render()):l.html(c),w2utils.transition(k[0],l[0],d,function(){k.remove(),l.removeClass("new-panel"),l.css("overflow",f.overflow),e.resize(),window.navigator.userAgent.indexOf("MSIE")!=-1&&setTimeout(function(){e.resize()},100)})}this.refresh(b)}return e.trigger(a.extend(g,{phase:"after"})),e.resize(),window.navigator.userAgent.indexOf("MSIE")!=-1&&setTimeout(function(){e.resize()},100),!0}},message:function(b,c){var d=this;"string"==typeof c&&(c={width:c.length<300?350:550,height:c.length<300?170:250,body:'<div class="w2ui-centered">'+c+"</div>",buttons:'<button class="w2ui-btn" onclick="w2ui[\''+this.name+"'].message('"+b+"')\">Ok</button>",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("#w2ui-popup #div-style").html(e)}a("#w2ui-tmp").remove()}if(w2popup.status="loading",null==b.url)return void console.log("ERROR: The url parameter is empty.");var d=String(b.url).split("#"),e=d[0],f=d[1];null==b&&(b={});var g=a("#w2ui-popup").data(e);null!=g?c(g,f):a.get(e,function(b,d,g){c(g.responseText,f),a("#w2ui-popup").data(e,g.responseText)})},message:function(b){var c=this;a().w2tag(),b||(b={width:200,height:100});var d=parseInt(a("#w2ui-popup").width()),e=parseInt(a("#w2ui-popup").height());b.originalWidth=b.width,b.originalHeight=b.height,parseInt(b.width)<10&&(b.width=10),parseInt(b.height)<10&&(b.height=10),null==b.hideOnClick&&(b.hideOnClick=!1);var f=a("#w2ui-popup").data("options")||{},g=parseInt(a("#w2ui-popup > .w2ui-popup-title").css("height"));(null==b.width||b.width>f.width-10)&&(b.width=f.width-10),(null==b.height||b.height>f.height-g-5)&&(b.height=f.height-g-5),b.originalHeight<0&&(b.height=e+b.originalHeight-g),b.originalWidth<0&&(b.width=d+2*b.originalWidth);var h=a("#w2ui-popup .w2ui-popup-title"),i=a("#w2ui-popup .w2ui-message").length;if(""===a.trim(b.html)&&""===a.trim(b.body)&&""===a.trim(b.buttons)){var j=a("#w2ui-popup #w2ui-message"+(i-1)),b=j.data("options")||{};j.css(w2utils.cssPrefix({transition:"0.15s",transform:"translateY(-"+b.height+"px)"})),1==i?w2popup.unlock(150):a("#w2ui-popup #w2ui-message"+(i-2)).css("z-index",1500),setTimeout(function(){var a=j.data("prev_focus");j.remove(),a&&a.length>0?a.focus():c.focus(),"function"==typeof b.onClose&&b.onClose()},150)}else{""===a.trim(b.body)&&""===a.trim(b.buttons)||(b.html='<div class="w2ui-message-body">'+b.body+'</div><div class="w2ui-message-buttons">'+b.buttons+"</div>"),a("#w2ui-popup .w2ui-message").css("z-index",1390),h.css("z-index",1501),a("#w2ui-popup .w2ui-box").before('<div id="w2ui-message'+i+'" class="w2ui-message" style="display: none; z-index: 1500; '+(0===h.length?"top: 0px;":"top: "+w2utils.getSize(h,"height")+"px;")+(null!=b.width?"width: "+b.width+"px; left: "+(d-b.width)/2+"px;":"left: 10px; right: 10px;")+(null!=b.height?"height: "+b.height+"px;":"bottom: 6px;")+w2utils.cssPrefix("transition",".3s",!0)+'"'+(b.hideOnClick===!0?'onclick="w2popup.message();"':"")+"></div>"),a("#w2ui-popup #w2ui-message"+i).data("options",b).data("prev_focus",a(":focus"));var k=a("#w2ui-popup #w2ui-message"+i).css("display");a("#w2ui-popup #w2ui-message"+i).css(w2utils.cssPrefix({transform:"none"==k?"translateY(-"+b.height+"px)":"translateY(0px)"})),"none"==k&&(a("#w2ui-popup #w2ui-message"+i).show().html(b.html),setTimeout(function(){a("#w2ui-popup #w2ui-message"+i).css(w2utils.cssPrefix({transform:"none"==k?"translateY(0px)":"translateY(-"+b.height+"px)"}))},1),0===i&&w2popup.lock(),setTimeout(function(){c.focus(),a("#w2ui-popup #w2ui-message"+i).css(w2utils.cssPrefix({transition:"0s"})),"function"==typeof b.onOpen&&b.onOpen()},350))}},focus:function(){var b=null,c=a("#w2ui-popup"),d="input:visible, button:visible, select:visible, textarea:visible";a(c).find(d).off(".keep-focus");var e=a("#w2ui-popup .w2ui-message").length-1,f=a("#w2ui-popup #w2ui-message"+e);if(f.length>0){var g=a(f[f.length-1]).find("button");g.length>0&&g[0].focus(),b=f}else if(c.length>0){var g=c.find(".w2ui-popup-buttons button");g.length>0&&g[0].focus(),b=c}a(b).find(d).on("blur.keep-focus",function(c){setTimeout(function(){var c=a(":focus");if(c.length>0&&!a(b).find(d).is(c)||c.hasClass("w2ui-popup-hidden")){var e=a(b).find(d);e.length>0&&e[0].focus()}},1)})},lock:function(b,c){var d=Array.prototype.slice.call(arguments,0);d.unshift(a("#w2ui-popup")),w2utils.lock.apply(window,d)},unlock:function(b){w2utils.unlock(a("#w2ui-popup"),b)},lockScreen:function(b){return!(a("#w2ui-lock").length>0)&&(null==b&&(b=a("#w2ui-popup").data("options")),null==b&&(b={}),b=a.extend({},w2popup.defaults,b),a("body").append('<div id="w2ui-lock" onmousewheel="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; if (event.preventDefault) event.preventDefault(); else return false;" style="position: '+("IE5"==w2utils.engine?"absolute":"fixed")+"
a(e).w2color({color:f.color,transparent:f.transparent},function(a,e){null!=a&&d.colorClick({name:d.name,item:f,color:a,originalEvent:c.originalEvent}),b()}))},1)),["check","menu","menu-radio","menu-check","drop","color","text-color"].indexOf(f.type)!=-1&&(f.checked=!f.checked,f.checked?a(i).addClass("checked"):a(i).removeClass("checked")),f.route){var l=String("/"+f.route).replace(/\/{2,}/g,"/"),m=w2utils.parseRoute(l);if(m.keys.length>0)for(var n=0;n<m.keys.length;n++)l=l.replace(new RegExp(":"+m.keys[n].name,"g"),this.routeData[m.keys[n].name]);setTimeout(function(){window.location.hash=l},1)}c&&["button","check","radio"].indexOf(f.type)!=-1&&this.tooltipShow(b,c,!0),this.trigger(a.extend(h,{phase:"after"}))}},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)},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='<div class="w2ui-scroll-wrapper" onmousedown="var el=w2ui[\''+this.name+'\']; if (el) el.resize();"><table cellspacing="0" cellpadding="0" width="100%"><tbody><tr>',f=0;f<this.items.length;f++){var g=this.items[f];null!=g&&(null==g.id&&(g.id="item_"+f),e+="spacer"==g.type?'<td width="100%" id="tb_'+this.name+"_item_"+g.id+'" align="right"></td>':'<td id="tb_'+this.name+"_item_"+g.id+'" style="'+(g.hidden?"display: none":"")+'" class="'+(g.disabled?"disabled":"")+'" valign="middle"></td>')}return e+='<td width="100%" id="tb_'+this.name+'_right" align="right">'+this.right+"</td>",e+='</tr></tbody></table></div><div class="w2ui-scroll-left" onclick="var el=w2ui[\''+this.name+"']; if (el) el.scroll('left');\"></div><div class=\"w2ui-scroll-right\" onclick=\"var el=w2ui['"+this.name+"']; if (el) el.scroll('right');\"></div>",a(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-toolbar").html(e),a(this.box).length>0&&(a(this.box)[0].style.cssText+=this.style),this.refresh(),this.resize(),this.trigger(a.extend(d,{phase:"after"})),(new Date).getTime()-c}},refresh:function(b){var c=(new Date).getTime(),d=this.trigger({phase:"before",type:"refresh",target:null!=b?b:this.name,item:this.get(b)});if(d.isCancelled!==!0){if(null!=b){var e=this.get(b);if(null==e)return!1;if("function"==typeof e.onRefresh){var f=this.trigger({phase:"before",type:"refresh",target:b,item:e,object:e});if(f.isCancelled===!0)return}var g=a(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(e.id)),h=this.getItemHTML(e);return 0===g.length?(h="spacer"==e.type?'<td width="100%" id="tb_'+this.name+"_item_"+e.id+'" align="right"></td>':'<td id="tb_'+this.name+"_item_"+e.id+'" style="'+(e.hidden?"display: none":"")+'" class="'+(e.disabled?"disabled":"")+'" valign="middle">'+h+"</td>",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;i<this.items.length;i++){var j=this.items[i];null==j.id&&(j.id="item_"+i),this.refresh(j.id)}}},resize:function(){var b=(new Date).getTime(),c=this.trigger({phase:"before",type:"resize",target:this.name});if(c.isC
d.keyboard=!1),this.addPrefix(),this.addSuffix();break;case"color":b={prefix:"#",suffix:'<div style="width: '+(parseInt(a(this.el).css("font-size"))||12)+'px">&#160;</div>',arrows:!1,keyboard:!1,transparent:!0},a.extend(d,b),this.addPrefix(),this.addSuffix(),a(this.el).attr("maxlength",6),""!==a(this.el).val()&&setTimeout(function(){c.change()},1);break;case"date":b={format:w2utils.settings.dateFormat,keyboard:!0,silent:!0,start:"",end:"",blocked:{},colored:{},blockWeekDays:null},this.options=a.extend(!0,{},b,d),d=this.options,null==a(this.el).attr("placeholder")&&a(this.el).attr("placeholder",d.format);break;case"time":b={format:w2utils.settings.timeFormat,keyboard:!0,silent:!0,start:"",end:"",noMinutes:!1},this.options=a.extend(!0,{},b,d),d=this.options,null==a(this.el).attr("placeholder")&&a(this.el).attr("placeholder",d.format);break;case"datetime":b={format:w2utils.settings.dateFormat+" | "+w2utils.settings.timeFormat,keyboard:!0,silent:!0,start:"",end:"",blocked:[],colored:{},placeholder:null,btn_now:!0,noMinutes:!1},this.options=a.extend(!0,{},b,d),d=this.options,null==a(this.el).attr("placeholder")&&a(this.el).attr("placeholder",d.placeholder||d.format);break;case"list":case"combo":if(b={items:[],selected:{},url:null,recId:null,recText:null,method:null,interval:350,postData:{},minLength:1,cacheMax:250,maxDropHeight:350,maxDropWidth:null,match:"begins",silent:!0,icon:null,iconStyle:"",onSearch:null,onRequest:null,onLoad:null,onError:null,onIconClick:null,renderDrop:null,compare:null,filter:!0,prefix:"",suffix:"",openOnFocus:!1,markSearch:!1},d.items=this.normMenu(d.items),"list"==this.type){if(b.openOnFocus=!0,a(this.el).addClass("w2ui-select"),!a.isPlainObject(d.selected)&&d.items)for(var e=0;e<d.items.length;e++){var f=d.items[e];if(f&&f.id==d.selected){d.selected=a.extend(!0,{},f);break}}this.watchSize()}d=a.extend({},b,d,{align:"both",altRows:!0}),this.options=d,a.isPlainObject(d.selected)||(d.selected={}),a(this.el).data("selected",d.selected),d.url&&(d.items=[],this.request(0)),"list"==this.type&&this.addFocus(),this.addPrefix(),this.addSuffix(),setTimeout(function(){c.refresh()},10),a(this.el).attr("autocomplete","off"),null!=d.selected.text&&a(this.el).val(d.selected.text);break;case"enum":b={items:[],selected:[],max:0,url:null,recId:null,recText:null,interval:350,method:null,postData:{},minLength:1,cacheMax:250,maxWidth:250,maxHeight:350,maxDropHeight:350,maxDropWidth:null,match:"contains",silent:!0,openOnFocus:!1,markSearch:!0,renderDrop:null,renderItem:null,compare:null,filter:!0,style:"",onSearch:null,onRequest:null,onLoad:null,onError:null,onClick:null,onAdd:null,onNew:null,onRemove:null,onMouseOver:null,onMouseOut:null,onScroll:null},d=a.extend({},b,d,{align:"both",suffix:"",altRows:!0}),d.items=this.normMenu(d.items),d.selected=this.normMenu(d.selected),this.options=d,a.isArray(d.selected)||(d.selected=[]),a(this.el).data("selected",d.selected),d.url&&(d.items=[],this.request(0)),this.addSuffix(),this.addMulti(),this.watchSize();break;case"file":b={selected:[],max:0,maxSize:0,maxFileSize:0,maxWidth:250,maxHeight:350,maxDropHeight:350,maxDropWidth:null,readContent:!0,silent:!0,renderItem:null,style:"",onClick:null,onAdd:null,onRemove:null,onMouseOver:null,onMouseOut:null},d=a.extend({},b,d,{align:"both",altRows:!0}),this.options=d,a.isArray(d.selected)||(d.selected=[]),a(this.el).data("selected",d.selected),null==a(this.el).attr("placeholder")&&a(this.el).attr("placeholder",w2utils.lang("Attach files by dragging and dropping or Click to Select")),this.addMulti(),this.watchSize()}this.tmp={onChange:function(a){c.change.call(c,a)},onClick:function(a){c.click.call(c,a)},onFocus:function(a){c.focus.call(c,a)},onBlur:function(a){c.blur.call(c,a)},onKeydown:function(a){c.keyDown.call(c,a)},onKeyup:function(a){c.keyUp.call(c,a)},onKeypress:function(a){c.keyPress.call(c,a)}},a(this.el).addClass("w2field w2ui-input").data("w2field",this).on("change.w2field",this.tmp.onChange).on("click.w2field",this.tmp.onClick).on("focus.w2field",this.tmp.onFocus).on("blur.w2field",this.tmp.onBlur).on("keydown.w2field",this
a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"});var d=a(this).attr("hour");a(c.el).val((d>12&&!h?d-12:d)+":00"+(h?"":d<12?" am":" pm")).change()}),null==this.options.noMinutes||this.options.noMinutes===!1?a("#w2ui-overlay .w2ui-time").on("mouseup",function(){var b=a(this).attr("hour");a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),a(c.el).w2overlay('<div class="w2ui-reset w2ui-calendar-time"></div>',{css:{"background-color":"#fff"}}),a("#w2ui-overlay > div").html(c.getMinHTML(b)),a("#w2ui-overlay .w2ui-time").on("mousedown",function(){a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"});var d=a(this).attr("min");a(c.el).val((b>12&&!h?b-12:b)+":"+(d<10?0:"")+d+(h?"":b<12?" am":" pm")).change()}).on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}):a("#w2ui-overlay .w2ui-time").on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}if("datetime"==this.type){if(a(c.el).prop("readonly")||a(c.el).prop("disabled"))return;a("#w2ui-overlay .w2ui-time").length>0&&a("#w2ui-overlay")[0].hide(),0===a("#w2ui-overlay").length&&a(c.el).w2overlay('<div class="w2ui-reset w2ui-calendar" onclick="event.stopPropagation();"></div>',{css:{"background-color":"#f5f5f5"}});var e,f,g=w2utils.isDateTime(a(c.el).val(),c.options.format,!0);g&&(e=g.getMonth()+1,f=g.getFullYear());var i=null;!function b(e,f){a("#w2ui-overlay > div > div").html(c.getMonthHTML(e,f,a(c.el).val())+(d.btn_now?'<div class="w2ui-calendar-now now">'+w2utils.lang("Current Date & Time")+"</div>":"")),a("#w2ui-overlay .w2ui-calendar-title").on("mousedown",function(){if(a(this).next().hasClass("w2ui-calendar-jump"))a(this).next().remove();else{var d,e;a(this).after('<div class="w2ui-calendar-jump" style=""></div>'),a(this).next().hide().html(c.getYearHTML()).fadeIn(200),setTimeout(function(){a("#w2ui-overlay .w2ui-calendar-jump").find(".w2ui-jump-month, .w2ui-jump-year").on("click",function(){a(this).hasClass("w2ui-jump-month")&&(a(this).parent().find(".w2ui-jump-month").removeClass("selected"),a(this).addClass("selected"),e=a(this).attr("name")),a(this).hasClass("w2ui-jump-year")&&(a(this).parent().find(".w2ui-jump-year").removeClass("selected"),a(this).addClass("selected"),d=a(this).attr("name")),null!=d&&null!=e&&(a("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout(function(){b(parseInt(e)+1,d)},100))}),a("#w2ui-overlay .w2ui-calendar-jump >:last-child").prop("scrollTop",2e3)},1)}}),a("#w2ui-overlay .w2ui-date").on("mousedown",function(){var b=a(this).attr("date");a(c.el).val(b).change(),a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),i=new Date(a(this).attr("data-date"))}).on("mouseup",function(){var b,d;a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),a(c.el).w2overlay('<div class="w2ui-reset w2ui-calendar-time"></div>',{css:{"background-color":"#fff"}});"h24"==c.options.format;a("#w2ui-overlay > div").html(c.getHourHTML()),a("#w2ui-overlay .w2ui-time").on("mousedown",function(d){a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),b=a(this).attr("hour"),i.setHours(b);var e=w2utils.formatDateTime(i,c.options.format);a(c.el).val(e).change()}),null==c.options.noMinutes||c.options.noMinutes===!1?a("#w2ui-overlay .w2ui-time").on("mouseup",function(){var e=a(this).attr("hour");a("#w2ui-overlay").length>0&&a("#w2ui-overlay")[0].hide(),a(c.el).w2overlay('<div class="w2ui-reset w2ui-calendar-time"></div>',{css:{"background-color":"#fff"}}),a("#w2ui-overlay > div").html(c.getMinHTML(e)),a("#w2ui-overlay .w2ui-time").on("mousedown",function(){a(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),d=a(this).attr("min"),i.setHours(b,d);var e=w2utils.formatDateTime(i,c.options.format);a(c.el).val(e).change()}).on("mouseup",function(){setTimeout(function(){a("#w2ui-overlay").length>0&&a("#w2ui-overlay").removeData("keepOpen")[0].hide()},10)})}):a("#w2ui-overlay .w2ui-time").on("mouseup",function(){setTimeout(function(){a("#w2u
}var ajaxOptions={type:"POST",url:url,data:edata.postData,headers:edata.httpHeaders,dataType:"text"};switch(w2utils.settings.dataType){case"HTTP":ajaxOptions.data=String($.param(ajaxOptions.data,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]");break;case"HTTPJSON":ajaxOptions.data={request:JSON.stringify(ajaxOptions.data)};break;case"RESTFULL":ajaxOptions.type="GET",ajaxOptions.data=String($.param(ajaxOptions.data,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]");break;case"RESTFULLJSON":ajaxOptions.type="GET",ajaxOptions.data=JSON.stringify(ajaxOptions.data),ajaxOptions.contentType="application/json";break;case"JSON":ajaxOptions.type="POST",ajaxOptions.data=JSON.stringify(ajaxOptions.data),ajaxOptions.contentType="application/json"}this.method&&(ajaxOptions.type=this.method),this.last.xhr=$.ajax(ajaxOptions).done(function(data,status,xhr){obj.unlock();var edata=obj.trigger({phase:"before",target:obj.name,type:"load",xhr:xhr});if(edata.isCancelled===!0)return void("function"==typeof callBack&&callBack({status:"error",message:"Request aborted."}));var data,responseText=obj.last.xhr.responseText;if("error"!=status){if(null!=responseText&&""!==responseText){if("object"==typeof responseText)data=responseText;else try{eval("data = "+responseText)}catch(a){}null==data&&(data={status:"error",message:w2utils.lang(obj.msgNotJSON),responseText:responseText}),"error"==data.status?obj.error(w2utils.lang(data.message)):(obj.record=$.extend({},data.record),obj.original=$.extend({},data.record))}}else obj.error("AJAX Error "+xhr.status+": "+xhr.statusText),data={status:"error",message:w2utils.lang(obj.msgAJAXerror),responseText:responseText};obj.trigger($.extend(edata,{phase:"after"})),obj.refresh(),"function"==typeof callBack&&callBack(data)}).fail(function(a,b,c){var d={status:b,error:c,rawResponseText:a.responseText},e=obj.trigger({phase:"before",type:"error",error:d,xhr:a});if(e.isCancelled!==!0){if("abort"!=b){var f;try{f=$.parseJSON(a.responseText)}catch(a){}console.log("ERROR: Server communication failed.","\n EXPECTED:",{status:"success",items:[{id:1,text:"item"}]},"\n OR:",{status:"error",message:"error message"},"\n RECEIVED:","object"==typeof f?f:a.responseText)}obj.trigger($.extend(e,{phase:"after"}))}}),this.trigger($.extend(edata,{phase:"after"}))}},submit:function(a,b){return this.save(a,b)},save:function(postData,callBack){var obj=this;$(this.box).find(":focus").change(),"function"==typeof postData&&(callBack=postData,postData=null);var errors=obj.validate(!0);if(0===errors.length){if(null==postData&&(postData={}),!obj.url||"object"==typeof obj.url&&!obj.url.save)return void console.log("ERROR: Form cannot be saved because no url is defined.");obj.lock(w2utils.lang(obj.msgSaving)+' <span id="'+obj.name+'_progress"></span>'),setTimeout(function(){var params={};params.cmd="save",params.recid=obj.recid,params.name=obj.name,$.extend(params,obj.postData),$.extend(params,postData),obj.fields.forEach(function(a){"file"==a.type&&Array.isArray(obj.record[a.field])&&obj.record[a.field].forEach(function(a){delete a.file})}),params.record=$.extend(!0,{},obj.record);var edata=obj.trigger({phase:"before",type:"submit",target:obj.name,url:obj.url,postData:params,httpHeaders:obj.httpHeaders});if(edata.isCancelled!==!0){var url=edata.url;if("object"==typeof edata.url&&edata.url.save&&(url=edata.url.save),obj.last.xhr)try{obj.last.xhr.abort()}catch(a){}if(!$.isEmptyObject(obj.routeData)){var info=w2utils.parseRoute(url);if(info.keys.length>0)for(var k=0;k<info.keys.length;k++)null!=obj.routeData[info.keys[k].name]&&(url=url.replace(new RegExp(":"+info.keys[k].name,"g"),obj.routeData[info.keys[k].name]))}var ajaxOptions={type:"POST",url:url,data:edata.postData,headers:edata.httpHeaders,dataType:"text",xhr:function(){var a=new window.XMLHttpRequest;return a.upload.addEventListener("progress",function(a){if(a.lengthComputable){var b=obj.trigger({phase:"before",type:"progress",total:a.total,loaded:a.loaded,originalEvent:a});if(b.isCancelled===!0)return;var c=Math.round(a.loaded/a.total*100);$("#"+obj.name+"_progress").text(""+c+"%"),obj.