');var r=this,i=$("#w2ui-overlay div");i.css(t.css).html(e),typeof t["class"]!="undefined"&&i.addClass(t["class"]),typeof t.top=="undefined"&&(t.top=0),typeof t.left=="undefined"&&(t.left=0),typeof t.width=="undefined"&&(t.width=100),typeof t.height=="undefined"&&(t.height=0);var s=i.css("background-color"),i=$("#w2ui-overlay");typeof s!="undefined"&&s!="rgba(0, 0, 0, 0)"&&s!="transparent"&&i.css("background-color",s),i.css({display:"none",left:$(r).offset().left+t.left+"px",top:$(r).offset().top+w2utils.getSize($(r),"height")+3+t.top+"px","min-width":t.width?t.width:"auto","min-height":t.height?t.height:"auto"}).fadeIn("fast").data("position",$(r).offset().left+"x"+($(r).offset().top+r.offsetHeight)).on("click",function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0});var o=function(){typeof t.onHide=="function"&&t.onHide(),$("#w2ui-overlay").remove(),$(document).off("click",o)};setTimeout(function(){$(document).on("click",o),typeof t.onShow=="function"&&t.onShow()},1)}}(),function(){var w2grid=function(e){this.name=null,this.box=null,this.header="",this.url="",this.columns=[],this.columnGroups=[],this.records=[],this.searches=[],this.searchData=[],this.sortData=[],this.postData={},this.toolbar={},this.show={header:!1,toolbar:!1,footer:!1,columnHeaders:!0,lineNumbers:!1,expandColumn:!1,selectColumn:!1,emptyRecords:!0,toolbarReload:!0,toolbarColumns:!0,toolbarSearch:!0,toolbarAdd:!1,toolbarDelete:!1,toolbarSave:!1},this.fixedBody=!0,this.fixedRecord=!0,this.multiSearch=!0,this.multiSelect=!0,this.multiSort=!0,this.keyboard=!0,this.total=0,this.page=0,this.recordsPerPage=50,this.style="",this.msgDelete=w2utils.lang("Are you sure you want to delete selected records?"),this.msgNotJSON=w2utils.lang("Returned data is not in valid JSON format."),this.msgRefresh=w2utils.lang("Refreshing..."),this.onRequest=null,this.onLoad=null,this.onAdd=null,this.onDelete=null,this.onSave=null,this.onSelect=null,this.onUnselect=null,this.onClick=null,this.onDblClick=null,this.onSort=null,this.onSearch=null,this.onChange=null,this.onExpand=null,this.onError=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,this.last={field:"all",caption:w2utils.lang("All Fields"),logic:"OR",search:"",multi:!1,scrollTop:0,scrollLeft:0,selected:[],sortData:null,sortCount:0,xhr:null},this.isIOS=navigator.userAgent.toLowerCase().indexOf("iphone")!=-1||navigator.userAgent.toLowerCase().indexOf("ipod")!=-1||navigator.userAgent.toLowerCase().indexOf("ipad")!=-1?!0:!1,$.extend(!0,this,e)};$.fn.w2grid=function(e){if(typeof e=="object"||!e){if(!e||typeof e.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2grid().');return}if(typeof w2ui[e.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+e.name+").");return}if(!w2utils.isAlphaNumeric(e.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var t=e.columns,n=e.columnGroups,r=e.records,i=e.searches,s=e.searchData,o=e.sortData,u=e.postData,a=e.toolbar,f=new w2grid(e);$.extend(f,{postData:{},records:[],columns:[],searches:[],toolbar:{},sortData:[],searchData:[],handlers:[]}),f.onExpand!=null&&(f.show.expandColumn=!0),$.extend(!0,f.toolbar,a);for(var l in t)f.columns[l]=$.extend({},t[l]);for(var l in n)f.columnGroups[l]=$.extend({},n[l]);for(var l in i)f.searches[l]=$.extend({},i[l]);for(var l in s)f.searchData[l]=$.extend({},s[l]);for(var l in o)f.sortData[l]=$.extend({},o[l]);for(var l in u)f.postData[l]=$.extend({},u[l]);for(var c in r){if(r[c].recid==null||typeof r[c].recid=="undefined"){console.log("ERROR: Cannot add records without recid. (obj: "+f.name+")");return}f.records[c]=$.extend({},r[c])}f.records.length>0&&(f.total=f.records.length);for(var h in f.columns){var p=f.columns[h];if(typeof p.searchable=="undefined"||f.getSearch(p.field)!=null)continue;var d=p.searchable,v="";p.searchable===!0&&(d="text",v='size="20"'),f.addSearch({field:p.field,caption:p.caption,type:d,attr:v})}return f.initToolbar(),$(this).length!=0&&f.render($(this)[0]),w2ui[f.name]=f,f}if(typeof $(this).data("w2name")!="undefined"){var m=w2ui[$(this).data("w2name")];return m[e].apply(m,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+e+" does not exist on jQuery.w2grid")},w2grid.prototype={add:function(e){$.isArray(e)||(e=[e]);var t=0;for(var n in e){if(e[n].recid==null||typeof e[n].recid=="undefined"){console.log("ERROR: Cannot add record without recid. (obj: "+this.name+")");continue}this.records.push(e[n]),t++}return this.total=this.records.length,this.url==""&&(this.localSearch(),this.localSort()),this.refresh(),t},find:function(e,t){if(typeof e=="undefined"||e==null)e={};var n=[];for(var r=0;r-1){var a=String(o.field).split(".");u=this.records[n][a[0]],typeof u=="object"&&u!=null&&(u=u[a[1]])}else u=this.records[n][o.field];typeof o.render!="undefined"&&(typeof o.render=="function"&&(u=o.render.call(this,this.records[n],n)),typeof o.render=="object"&&(u=o.render[this.records[n][o.field]]));if(u==null||typeof u=="undefined")u="";if(typeof o.render=="string")switch(o.render.toLowerCase()){case"url":var f=u.indexOf("/",8);u=''+u.substr(0,f)+"";break;case"repeat":n>0&&this.records[n][o.field]==this.records[n-1][o.field]&&this.records[n][o.field]!=""&&(u="-- // --")}$(r).find("#grid_"+this.name+"_cell_"+i+"_"+s+" > div").html(u),s++;if(typeof this.columns[s]=="undefined")break}}},get:function(e,t){for(var n=0;n=0;n--)this.records[n].recid==arguments[t]&&(this.records.splice(n,1),e++);return this.url==""&&(this.total=this.records.length,this.localSearch(),this.localSort()),this.refresh(),e},addColumn:function(e,t){arguments.length==1?(t=e,e=this.columns.length):(e=this.getColumn(e,!0),e===null&&(e=this.columns.length)),$.isArray(t)||(t=[t]);for(var n in t)this.columns.splice(e,0,t[n]),e++;this.initColumnOnOff(),this.refresh()},removeColumn:function(){var e=0;for(var t in arguments)for(var n=this.columns.length-1;n>=0;n--)this.columns[n].field==arguments[t]&&(this.columns.splice(n,1),e++);return this.initColumnOnOff(),this.refresh(),e},getColumn:function(e,t){for(var n=0;n=0;n--)this.columns[n].field==arguments[t]&&this.columns[n].hidden!==!1&&(this.columns[n].hidden=!1,e++);return this.resize(),e},hideColumn:function(){var e=0;for(var t in arguments)for(var n=this.columns.length-1;n>=0;n--)this.columns[n].field==arguments[t]&&this.columns[n].hidden!==!0&&(this.columns[n].hidden=!0,e++);return this.resize(),e},addSearch:function(e,t){arguments.length==1?(t=e,e=this.searches.length):(e=this.getSearch(e,!0),e===null&&(e=this.searches.length)),$.isArray(t)||(t=[t]);for(var n in t)this.searches.splice(e,0,t[n]),e++;this.searchClose()},removeSearch:function(){var e=0;for(var t in arguments)for(var n=this.searches.length-1;n>=0;n--)this.searches[n].field==arguments[t]&&(this.searches.splice(n,1),e++);return this.searchClose(),e},getSearch:function(e,t){for(var n=0;n=0;n--)this.searches[n].field==arguments[t]&&this.searches[n].hidden!==!1&&(this.searches[n].hidden=!1,e++);return this.searchClose(),e},hideSearch:function(){var e=0;for(var t in arguments)for(var n=this.searches.length-1;n>=0;n--)this.searches[n].field==arguments[t]&&this.searches[n].hidden!==!0&&(this.searches[n].hidden=!0,e++);return this.searchClose(),e},getSearchData:function(e){for(var t in this.searchData)if(this.searchData[t].field==e)return this.searchData[t];return null},clear:function(){this.records=[],this.total=0,this.refresh()},localSort:function(){var e=this;this.records.sort(function(t,n){if(t.summary&&n.summary){if(t.recid>n.recid)return 1;if(t.recid<=n.recid)return-1}var r=0;for(var i in e.sortData){var s=t[e.sortData[i].field],o=n[e.sortData[i].field];typeof s=="string"&&(s=$.trim(s.toLowerCase())),typeof o=="string"&&(o=$.trim(o.toLowerCase())),s>o&&(r=e.sortData[i].direction=="asc"?1:-1),s0){this.total=0;for(var r in this.records){var rec=this.records[r],fl=0;for(var s in this.searches){var search=this.searches[s],sdata=this.getSearchData(search.field);if(sdata==null)continue;var val1;try{val1=eval("rec."+search.field)}catch(e){}val1=String(val1).toLowerCase();if(typeof sdata.value!="undefined")if(!$.isArray(sdata.value))var val2=String(sdata.value).toLowerCase();else var val2=sdata.value[0],val3=sdata.value[1];switch(sdata.operator){case"is":rec[search.field]==sdata.value&&fl++,search.type=="text"&&val1==val2&&fl++;if(search.type=="date"){var da=new Date(val1),db=new Date(val2);d0=Date.UTC(da.getFullYear(),da.getMonth(),da.getDate()),d1=Date.UTC(db.getFullYear(),db.getMonth(),db.getDate()),d0==d1&&fl++}break;case"between":search.type=="int"&&parseInt(rec[search.field])>=parseInt(val2)&&parseInt(rec[search.field])<=parseInt(val3)&&fl++,search.type=="float"&&parseFloat(rec[search.field])>=parseFloat(val2)&&parseFloat(rec[search.field])<=parseFloat(val3)&&fl++;if(search.type=="date"){var da=new Date(val1),db=new Date(val2),dc=new Date(val3);d0=Date.UTC(da.getFullYear(),da.getMonth(),da.getDate()),d1=Date.UTC(db.getFullYear(),db.getMonth(),db.getDate()),d2=Date.UTC(dc.getFullYear(),dc.getMonth(),dc.getDate()),d0>=d1&&d0<=d2&&fl++}break;case"begins with":val1.indexOf(val2)==0&&fl++;break;case"contains":val1.indexOf(val2)>=0&&fl++;break;case"ends with":val1.indexOf(val2)==val1.length-val2.length&&fl++}}this.last.logic=="OR"&&(rec.hidden=fl==0?!0:!1),this.last.logic=="AND"&&(rec.hidden=fl!=this.searchData.length?!0:!1),rec.hidden!==!0&&rec.summary!==!0&&this.total++}}},select:function(e){var t=0;for(var n in arguments){var r=this.get(arguments[n]);if(r==null||r.selected===!0)continue;var i=this.trigger({phase:"before",type:"select",target:this.name,recid:r.recid});if(i.stop===!0)continue;var s=this.get(r.recid,!0);r.selected=!0,$("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid)).addClass("w2ui-selected").data("selected","yes"),$("#grid_"+this.name+"_cell_"+s+"_select_check").attr("checked",!0),t++,this.trigger($.extend(i,{phase:"after"}))}$("#grid_"+this.name+"_check_all").attr("checked",!0),$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length!=0&&$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length==$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]:checked").length?$("#grid_"+this.name+"_check_all").attr("checked",!0):$("#grid_"+this.name+"_check_all").removeAttr("checked");var o="";return this.getSelection().length>0&&(o=this.getSelection().length+" selected"),$("#"+this.name+"_grid_footer .w2ui-footer-left").html(o),t},unselect:function(e){var t=0;for(var n in arguments){var r=this.get(arguments[n]);if(r==null||r.selected!==!0)continue;var i=this.trigger({phase:"before",type:"unselect",target:this.name,recid:r.recid});if(i.stop===!0)continue;var s=this.get(r.recid,!0);r.selected=!1,$("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid)).removeClass("w2ui-selected").data("selected",""),$("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid)).length!=0&&($("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid))[0].style.cssText=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid)).attr("custom_style")),$("#grid_"+this.name+"_cell_"+s+"_select_check").removeAttr("checked"),t++,this.trigger($.extend(i,{phase:"after"}))}$("#grid_"+this.name+"_check_all").attr("checked",!0),$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length!=0&&$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length==$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]:checked").length?$("#grid_"+this.name+"_check_all").attr("checked",!0):$("#grid_"+this.name+"_check_all").removeAttr("checked");var o="";return this.getSelection().length>0&&(o=this.getSelection().length+" selected"),$("#"+this
.name+"_grid_footer .w2ui-footer-left").html(o),t},selectAll:function(){if(this.multiSelect===!1)return;for(var e=0;e0?this.toolbar.enable("delete-selected"):this.toolbar.disable("delete-selected")},selectPage:function(){if(this.multiSelect===!1)return;this.selectNone();var e=0;if(this.url==""){var t=this.page*this.recordsPerPage;for(var n=0;n0?this.toolbar.enable("delete-selected"):this.toolbar.disable("delete-selected")},selectNone:function(){this.unselect.apply(this,this.getSelection()),this.last.selected=[]},getSelection:function(){return this.find({selected:!0})},search:function(e,t){var n=this,r=[],i=this.last.multi,s=this.last.logic,o=this.last.field,u=this.last.search;if(arguments.length==0){for(var a in this.searches){var f=this.searches[a],l=$("#grid_"+this.name+"_operator_"+a).val(),c=$("#grid_"+this.name+"_field_"+a).val(),h=$("#grid_"+this.name+"_field2_"+a).val();if(c!=""&&c!=null||typeof h!="undefined"&&h!=""){var p={field:f.field,type:f.type,operator:l};l=="between"?$.extend(p,{value:[c,h]}):$.extend(p,{value:c}),r.push(p)}}r.length>0&&(i=!0,s="AND")}if($.isArray(e)){var d="AND";typeof t=="string"&&(d=t.toUpperCase(),d!="OR"&&d!="AND"&&(d="AND")),u="",i=!0,s=d;for(var v in e){var m=e[v],f=this.getSearch(m.field);if(f==null){console.log('ERROR: Cannot find field "'+m.field+'" when submitting a search.');continue}var p=$.extend({},m);typeof p.type=="undefined"&&(p.type=f.type),typeof p.operator=="undefined"&&(p.operator="is",p.type=="text"&&(p.operator="begins with")),r.push(p)}}if(typeof e=="string"&&typeof t=="string"){o=e,u=t,i=!1,s="OR";if(t!="")for(var a in this.searches){var f=this.searches[a];f.field==e&&(this.last.caption=f.caption);if(e!="all"&&f.field==e){var p={field:f.field,type:f.type,operator:f.type=="text"?"begins with":"is",value:t};r.push(p)}if(e=="all")if(f.type=="text"||f.type=="int"&&w2utils.isInt(t)||f.type=="float"&&w2utils.isFloat(t)||f.type=="money"&&w2utils.isMoney(t)||f.type=="hex"&&w2utils.isHex(t)||f.type=="date"&&w2utils.isDate(t)||f.type=="alphaNumeric"&&w2utils.isAlphaNumeric(t)){var p={field:f.field,type:f.type,operator:f.type=="text"?"begins with":"is",value:t};r.push(p)}}}var g=this.trigger({phase:"before",type:"search",target:this.name,searchData:r});if(g.stop===!0)return;this.searchData=g.searchData,this.last.field=o,this.last.search=u,this.last.multi=i,this.last.logic=s,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selected=[],this.searchClose(),this.url!=""?(this.page=0,this.reload()):(this.localSearch(),this.goto(0)),this.trigger($.extend(g,{phase:"after"}))},searchOpen:function(){if(!this.box)return;if(this.searches.length==0)return;var e=this;$("#tb_"+this.name+"_toolbar_item_search-advanced").w2overlay(this.getSearchesHTML(),{left:-10,"class":"w2ui-grid-searches",onShow:function(){e.last.logic=="OR"&&(e.searchData=[]),e.initSearches(),$("#w2ui-overlay .w2ui-grid-searches").data("grid-name",e.name);var t=$("#w2ui-overlay .w2ui-grid-searches *[rel=search]");t.length>0&&t[0].focus()}})},searchClose:function(){if(!this.box)return;if(this.searches.length==0)return;$().w2overlay()},searchShowFields:function(e){typeof e=="undefined"&&(e=$("#grid_"+this.name+"_search_all"));var t='
';for(var n=-1;n'+'
"+"
"+r.caption+"
"+""}t+="
",$(e).w2overlay(t,{left:-15,top:7})},searchReset:function(){var e=this.trigger({phase:"before",type:"search",target:this.name,searchData:[]});if(e.stop===!0)return;this.searchData=[],this.last.search="",this.last.logic="OR",this.last.multi&&(this.multiSearch?(this.last.field="all",this.last.caption=w2utils.lang("All Fields")):(this.last.field=this.searches[0].field,this.last.caption=this.searches[0].caption)),this.last.multi=!1,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selected=[],this.searchClose(),this.url!=""?(this.page=0,this.reload()):(this.localSearch(),this.goto(0)),this.trigger($.extend(e,{phase:"after"}))},"goto":function(e){var t=Math.floor(this.total/this.recordsPerPage);(this.total%this.recordsPerPage!=0||t==0)&&t++,t<1&&(t=1),e<0&&(e=0),e>=t&&(e=t-1),this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selected=[],this.page=e,this.reload()},load:function(e,t){if(typeof e=="undefined"){console.log('ERROR: You need to provide url argument when calling .load() method of "'+this.name+'" object.');return}this.request("get-records",{},e,t)},reload:function(e){this.url!=""?this.request("get-records",{},null,e):this.refresh()},reset:function(){this.page=0,this.searchData=[],this.last.search="",this.last.field="all",this.last.caption=w2utils.lang("All Fields"),this.last.logic="OR",this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selected=[],this.last.sortCount=0,this.last.sortData!=null&&(this.sortData=this.last.sortData);for(var e=0;e0?$().w2popup("message",{width:370,height:140,html:'
';for(var n in this.columns){var r=this.columns[n];t+='
'+"
"+"
"+' "+"
"+"
"}t+="
",this.toolbar.get("column-on-off").html=t},initToolbar:function(){if(typeof this.toolbar["render"]=="undefined"){var e=this.toolbar.items;this.toolbar.items=[],this.toolbar=$().w2toolbar($.extend(!0,{},this.toolbar,{name:this.name+"_toolbar",owner:this})),this.show.toolbarReload&&this.toolbar.items.push({type:"button",id:"refresh",img:"icon-reload",hint:w2utils.lang("Reload data in the list")}),this.show.toolbarColumns&&(this.toolbar.items.push({type:"drop",id:"column-on-off",img:"icon-columns",hint:w2utils.lang("Show/hide columns"),arrow:!1,html:""}),this.initColumnOnOff()),(this.show.toolbarReload||this.show.toolbarColumn)&&this.toolbar.items.push({type:"break",id:"break0"});if(this.show.toolbarSearch){var t='
"+"
"+"
"+' "+"
"+"
"+'
"+"
"+"
";this.toolbar.items.push({type:"html",id:"search",html:t}),this.multiSearch&&this.searches.length>0&&this.toolbar.items.push({type:"button",id:"search-advanced",caption:w2utils.lang("Search..."),hint:w2utils.lang("Open Search Fields")})}(this.show.toolbarAdd||this.show.toolbarDelete||this.show.toolbarSave)&&this.toolbar.items.push({type:"break",id:"break1"}),this.show.toolbarAdd&&this.toolbar.items.push({type:"button",id:"add",caption:w2utils.lang("Add New"),hint:w2utils.lang("Add new record"),img:"icon-add"}),this.show.toolbarDelete&&this.toolbar.items.push({type:"button",id:"delete-selected",caption:w2utils.lang("Delete"),hint:w2utils.lang("Delete selected records"),img:"icon-delete",disabled:!0}),this.show.toolbarSave&&((this.show.toolbarAdd||this.show.toolbarDelete)&&this.toolbar.items.push({type:"break",id:"break2"}),this.toolbar.items.push({type:"button",id:"save-changed",caption:w2utils.lang("Save"),hint:w2utils.lang("Save changed records"),img:"icon-save"}));for(var n in e)this.toolbar.items.push(e[n]);var r=this;this.toolbar.on("click",function(e,t){switch(e){case"refresh":r.reload();break;case"column-on-off":for(var n in r.columns)r.columns[n].hidden?$("#grid_"+r.name+"_column_"+n+"_check").removeAttr("checked"):$("#grid_"+r.name+"_column_"+n+"_check").attr("checked",!0);for(var n in r.columns)typeof r.columns[n].sizeOriginal!="undefined"&&(r.columns[n].size=r.columns[n].sizeOriginal);r.initResize(),r.resize();break;case"add":r.doAdd();break;case"search-advanced":r.searchOpen();break;case"add-new":r.doAdd();break;case"delete-selected":r.doDelete();break;case"save-changed":r.doSave();break;default:e.substr(0,7)=="choice-"&&typeof t!="object"&&(r.toolbar.set(e,{caption:r.toolbar.get(e).prepend+t}),typeof r.toolbar.get(e).param=="function"&&r.toolbar.get(e).param(e,t),typeof r.toolbar.get(e).onClick=="function"&&r.toolbar.get(e).onClick(e,t))}})}return},initSearches:function(){var e=this;for(var t in this.searches){var n=this.searches[t],r=this.getSearchData(n.field);switch(String(n.type).toLowerCase()){case"alphaNumeric":case"text":$("#grid_"+this.name+"_operator_"+t).val("begins with");break;case"int":case"float":case"hex":case"money":case"date":$("#grid_"+this.name+"_field_"+t).w2field(n.type),$("#grid_"+this.name+"_field2_"+t).w2field(n.type);break;case"list":var i='';for(var s in n.items)if($.isPlainObject(n.items[s])){var o=n.items[s].id,u=n.items[s].text;typeof o=="undefined"&&typeof n.items[s].value!="undefined"&&(o=n.items[s].value),typeof u=="undefined"&&typeof n.items[s].caption!="undefined"&&(u=n.items[s].caption),o==null&&(o=""),i+='"}else i+='";$("#grid_"+this.name+"_field_"+t).html(i)}r!=null&&($("#grid_"+this.name+"_operator_"+t).val(r.operator).trigger("change"),$.isArray(r.value)?($("#grid_"+this.name+"_field_"+t).val(r.value[0]).trigger("change"),$("#grid_"+this.name+"_field2_"+t).val(r.value[1]).trigger("change")):typeof r.value!="udefined"&&$("#grid_"+this.name+"_field_"+t).val(r.value).trigger("change"))}$("#w2ui-overlay .w2ui-grid-searches *[rel=search]").on("keypress",function(t){t.keyCode==13&&e.search()})},initResize:function(){var e=this;$(this.box).find(".w2ui-resizer").off("mousedown").off("click").each(function(e,t){var n=$(t).parent();$(t).css({height:n.height(),"margin-top":"-"+n.height()+"px","margin-left":n.width()-6+"px"})}).on("mousedown",function(t){t||(t=window.event),window.addEventListener||window.document.attachEvent("onselectstart",function(){return!1}),e.resizing=!0,e.tmp_x=t.screenX,e.tmp_y=t.screenY,e.tmp_col=$(this).attr("name"),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,t.preventDefault&&t.preventDefault();for(var n in e.columns)typeof e.columns[n].sizeOriginal=="undefined"&&(e.columns[n].sizeOriginal=e.columns[n].size),e.columns[n].size=e.columns[n].sizeCalculated;var r=function(t){if(e.resizing!=1)return;t||(t=window.event),e.tmp_div_x=t.screenX-e.tmp_x,e.tmp_div_y=t.screenY-e.tmp_y,e.columns[e.tmp_col].size=parseInt(e.columns[e.tmp_col].size)+e.tmp_div_x+"px",e.resizeRecords(),e.tmp_x=t.screenX,e.tmp_y=t.screenY},i=function(t){delete e.resizing,$(document).off("mousemove",r),$(document).off("mouseup",i),e.resizeRecords()};$(document).on("mousemove",r),$(document).on("mouseup",i)}).on("click",function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,e.preventDefault&&e.preventDefault()})},resizeBoxes:function(){var e=$(this.box).find("> div"),t=$("#grid_"+this.name+"_header"),n=$("#grid_"+this.name+"_toolbar"),r=$("#grid_"+this.name+"_summary"),i=$("#grid_"+this.name+"_footer"),s=$("#grid_"+this.name+"_body"),o=$("#grid_"+this.name+"_columns"),u=$("#grid_"+this.name+"_records");this.show.header&&t.css({top:"0px",left:"0px",right:"0px"}),this.show.toolbar&&n.css({top:0+(this.show.header?w2utils.getSize(t,"height"):0)+"px",left:"0px",right:"0px"}),this.show.footer&&i.css({bottom:"0px",left:"0px",right:"0px"}),this.summary!=""&&r.css({bottom:0+(this.show.footer?w2utils.getSize(i,"height"):0)+"px",left:"0px",right:"0px"}),s.css({top:0+(this.show.header?w2utils.getSize(t,"height"):0)+(this.show.toolbar?w2utils.getSize(n,"height"):0)+"px",bottom:0+(this.show.footer?w2utils.getSize(i,"height"):0)+(this.summary!=""?w2utils.getSize(r,"height"):0)+"px",left:"0px",right:"0px"})},resizeRecords:function(){var e=this;$(this.box).find(".w2ui-empty-record").remove();var t=$(this.box),n=$(this.box).find("> div"),r=$("#grid_"+this.name+"_header"),i=$("#grid_"+this.name+"_toolbar"),s=$("#grid_"+this.name+"_summary"),o=$("#grid_"+this.name+"_footer"),u=$("#grid_"+this.name+"_body"),a=$("#grid_"+this.name+"_columns"),f=$("#grid_"+this.name+"_records");if(!this.fixedBody)setTimeout(function(){var f=w2utils.getSize(a,"height")+w2utils.getSize($("#grid_"+e.name+"_records table"),"height");e.height=f+w2utils.getSize(n,"+height")+(e.show.header?w2utils.getSize(r,"height"):0)+(e.show.toolbar?w2utils.getSize(i,"height"):0)+(s.css("display")!="none"?w2utils.getSize(s,"height"):0)+(e.show.footer?w2utils.getSize(o,"height"):0),n.height(e.height),u.height(f),t.height(w2utils.getSize(n,"height")+w2utils.getSize(t,"+height"))},1);else{var l=n.height()-(this.show.header?w2utils.getSize(r,"height"):0)-(this.show.toolbar?w2utils.getSize(i,"height"):0)-(s.css("display")!="none"?w2utils.getSize(s,"height"):0)-(this.show.footer?w2utils.getSize(o,"height"):0);u.height(l)}if(u.height()-a.height()<$(f).find(":first-child").height())var c=!0;else c=!1;if(u.width()<$(f).find(":first-child").width())var h=!0;else h=!1;this.fixedBody||(c=!1,h=!1),h||c?(f.css({top:(this.columnGroups.length>0?1:0)+w2utils.getSize(a,"height")+"px","-webkit-overflow-scrolling":"touch","overflow-x":h?"auto":"hidden","overflow-y":c?"auto":"hidden"}),$("#grid_"+this.name+"_cell_header_last").show()):(f.css({top:(this.columnGroups.length>0?1:0)+w2utils.getSize(a,"height")+"px",overflow:"hidden"}),f.length>0&&(this.last.scrollTop=0,this.last.scrollLeft=0),$("#grid_"+this.name+"_cell_header_last").hide());if(this.show.emptyRecords&&!c){var p=0;if(this.url==""){var d=this.page*this.recordsPerPage;for(var v=0;v',this.show.lineNumbers&&(y+='
";if($.isPlainObject(col.editable)){var edit=col.editable;edit.type=="enum"&&console.log("ERROR: Grid's inline editing does not support enum field type."),(edit.type=="list"||edit.type=="select")&&console.log("ERROR: Grid's inline editing does not support list/select field type."),typeof edit.inTag=="undefined"&&(edit.inTag=""),typeof edit.outTag=="undefined"&&(edit.outTag=""),typeof edit.style=="undefined"&&(edit.style=""),typeof edit.items=="undefined"&&(edit.items=[]),(typeof record["editable"]=="undefined"||record.editable===!0)&&edit.type!="enum"&&edit.type!="list"&&edit.type!="select"&&(rec_field='
":this.summary="",html},getFooterHTML:function(){var e=this.page*this.recordsPerPage+this.recordsPerPage;e>this.total&&(e=this.total);var t=this.page*this.recordsPerPage+1+"-"+e+" of "+this.total;this.page==0&&this.total==0&&(t="0-0 of 0");var n=Math.floor(this.total/this.recordsPerPage);(this.total%this.recordsPerPage!=0||n==0)&&n++,n<1&&(n=1);var r='";return'
"+' "+"
"},lock:function(e){var t=this;typeof e=="undefined"||e==""?setTimeout(function(){$("#grid_"+t.name+"_lock").remove(),$("#grid_"+t.name+"_status").remove()},25):($("#grid_"+t.name+"_lock").remove(),$("#grid_"+t.name+"_status").remove(),$(this.box).find("> div :first-child").before(''+''),setTimeout(function(){var n=$("#grid_"+t.name+"_lock"),r=$("#grid_"+t.name+"_status");r.data("old_opacity",r.css("opacity")).css("opacity","0").show(),n.data("old_opacity",n.css("opacity")).css("opacity","0").show(),setTimeout(function(){var i=($(t.box).width()-w2utils.getSize(r,"width"))/2,s=($(t.box).height()*.9-w2utils.getSize(r,"height"))/2;n.css({opacity:n.data("old_opacity"),left:"0px",top:"0px",width:"100%",height:"100%"}),r.html(e).css({opacity:r.data("old_opacity"),left:i+"px",top:s+"px"})},10)},10))},unlock:function(){this.lock()}},$.extend(w2grid.prototype,$.w2event),w2obj.grid=w2grid}(),function(){var e=function(e){this.box=null,this.name=null,this.panels=[],this.padding=1,this.resizer=4,this.style="",this.css="",this.onShow=null,this.onHide=null,this.onResizing=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,$.extend(!0,this,e)};$.fn.w2layout=function(t){if(typeof t=="object"||!t){if(!t||typeof t.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2layout().');return}if(typeof w2ui[t.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+t.name+").");return}if(!w2utils.isAlphaNumeric(t.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=t.panels,r=new e(t);$.extend(r,{handlers:[],panels:[]});for(var i in n)r.panels[i]=$.extend(!0,{},e.prototype.panel,n[i]),($.isPlainObject(r.panels[i].tabs)||$.isArray(r.panels[i].tabs))&&r.initTabs(n[i].type),($.isPlainObject(r.panels[i].toolbar)||$.isArray(r.panels[i].toolbar))&&r.initToolbar(n[i].type);for(var i in{top:"",left:"",main:"",preview:"",right:"",bottom:""}){if(r.get(i)!=null)continue;r.panels[i]=$.extend(!0,{},e.prototype.panel,{type:i,hidden:!0,size:50})}return $(this).length>0&&($(this).data("w2name",r.name),r.render($(this)[0])),w2ui[r.name]=r,r}if(typeof $(this).data("w2name")!="undefined"){var s=w2ui[$(this).data("w2name")];return s[t].apply(s,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+t+" does not exist on jQuery.w2layout")},e.prototype={panel:{type:null,size:100,minSize:20,hidden:!1,resizable:!1,overflow:"auto",style:"",content:"",tabs:null,toolbar:null,width:null,height:null,onRefresh:null,onShow:null,onHide:null},content:function(e,t,n){var r=this,i=this.get(e);if(i==null)return!1;if($("#layout_"+this.name+"_panel2_"+i.type).length>0)return!1;$("#layout_"+this.name+"_panel_"+i.type).scrollTop(0);if(t==null||typeof t=="undefined")return i.content;if(i.content=="")i.content=t,i.hidden||this.refresh(e);else{i.content=t;if(!i.hidden)if(n!=null&&n!=""&&typeof n!="undefined"){var s="layout_"+this.name+"_panel_"+i.type,o=$("#"+s+" > .w2ui-panel-content");o.after('');var u=$("#"+s+" > .w2ui-panel-content.new-panel");typeof t=="object"?(t.box=u[0],t.render()):u.html(t),w2utils.transition(o[0],u[0],n,function(){o.remove(),u.removeClass("new-panel"),window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){r.resize()},100)})}else i.hidden||this.refresh(e)}return window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){r.resize()},100),!0},load:function(e,t,n,r){var i=this;return this.get(e)==null?!1:($.get(t,function(t,s,o){i.content(e,o.responseText,n),r&&r(),window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){i.resize()},100)}),!0)},show:function(e,t){var n=this,r=this.trigger({phase:"before",type:"show",target:e,panel:this.get(e),immediate:t});if(r.stop===!0)return!1;var i=n.get(e);return i==null?!1:(i.hidden=!1,t===!0?($("#layout_"+n.name+"_panel_"+e).css({opacity:"1"}),i.resizabled&&$("#layout_"+n.name+"_resizer_"+e).show(),n.trigger($.extend(r,{phase:"after"})),n.resize()):(i.resizabled&&$("#layout_"+n.name+"_resizer_"+e).show(),$("#layout_"+n.name+"_panel_"+e).css({opacity:"0"}),$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":".2s","-moz-transition":".2s","-ms-transition":".2s","-o-transition":".2s"}),setTimeout(function(){n.resize()},1),setTimeout(function(){$("#layout_"+n.name+"_panel_"+e).css({opacity:"1"})},250),setTimeout(function(){$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":"0s","-moz-transition":"0s","-ms-transition":"0s","-o-transition":"0s"}),n.trigger($.extend(r,{phase:"after"})),n.resize()},500)),!0)},hide:function(e,t){var n=this,r=this.trigger({phase:"before",type:"hide",target:e,panel:this.get(e),immediate:t});if(r.stop===!0)return!1;var i=n.get(e);return i==null?!1:(i.hidden=!0,t===!0?($("#layout_"+n.name+"_panel_"+e).css({opacity:"0"}),$("#layout_"+n.name+"_resizer_"+e).hide(),n.trigger($.extend(r,{phase:"after"})),n.resize()):($("#layout_"+n.name+"_resizer_"+e).hide(),$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":".2s","-moz-transition":".2s","-ms-transition":".2s","-o-transition":".2s"}),$("#layout_"+n.name+"_panel_"+e).css({opacity:"0"}),setTimeout(function(){n.resize()},1),setTimeout(function(){$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":"0s","-moz-transition":"0s","-ms-transition":"0s","-o-transition":"0s"}),n.trigger($.extend(r,{phase:"after"})),n.resize()},500)),!0)},toggle:function(e,t){var n=this.get(e);return n==null?!1:n.hidden?this.show(e,t):this.hide(e,t)},set:function(e,t){var n=this.get(e,!0);return n==null?!1:($.extend(this.panels[n],t),this.refresh(e),!0)},get:function(e,t){var n=null;for(var r in this.panels)if(this.panels[r].type==e)return t===!0?r:this.panels[r];return null},initToolbar:function(e,t){var n=this.get(e);return n!=null&&typeof t=="undefined"&&(t=n.toolbar),n==null||t==null?!1:($.isArray(t)&&(t={items:t}),$().w2destroy(this.name+"_"+e+"_toolbar"),n.toolbar=$().w2toolbar($.extend({},t,{owner:this,name:this.name+"_"+e+"_toolbar"})),!0)},initTabs:function(e,t){var n=this.get(e);return n!=null&&typeof t=="undefined"&&(t=n.tabs),n==null||t==null?!1:($.isArray(t)&&(t={tabs:t}),$().w2destroy(this.name+"_"+e+"_tabs"),n.tabs=$().w2tabs($.extend({},t,{owner:this,name:this.name+"_"+e+"_tabs"})),!0)},render:function(e){window.getSelection&&window.getSelection().removeAllRanges();var t=this.trigger({phase:"before",type:"render",target:this.name,box:e});if(t.stop===!0)return!1;typeof e!="undefined"&&e!=null&&($(this.box).find("#layout_"+this.name+"_panel_main").length>0&&$(this.box).removeData("w2name").removeClass("w2ui-layout").html(""),this.box=e);if(!this.box)return!1;$(this.box).data("w2name",this.name).addClass("w2ui-layout").html(""),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style);var n=["top","left","main","preview","right","bottom"];for(var r in n){var i=this.get(n[r]),s='
'+' '+' '+' '+"
"+'';$(this.box).find(" > div").append(s),i.tabs!=null&&$(this.box).find("#layout_"+this.name+"_panel_"+n[r]+" .w2ui-panel-tabs").w2render(i.tabs),i.toolbar!=null&&$(this.box).find("#layout_"+this.name+"_panel_"+n[r]+" .w2ui-panel-toolbar").w2render(i.toolbar)}return $(this.box).find(" > div").append('"),this.trigger($.extend(t,{phase:"after"})),this.refresh(),this.initEvents(),!0},refresh:function(e){window.getSelection&&window.getSelection().removeAllRanges(),typeof e=="undefined"&&(e=null);var t=this.trigger({phase:"before",type:"refresh",target:typeof e!="undefined"?e:this.name,panel:this.get(e)});if(t.stop===!0)return!1;if(e!=null&&typeof e!="undefined"){var n=this.get(e);if(n==null)return!1;var r=$("#layout_"+this.name+"_panel_"+e).css({display:n.hidden?"none":"block"});r=r.find(".w2ui-panel-content"),r.length>0&&(r.css("overflow",n.overflow)[0].style.cssText+=";"+n.style),typeof n.content=="object"&&n.content.render?n.content.render($("#layout_"+this.name+"_panel_"+n.type+" > .w2ui-panel-content")[0]):$("#layout_"+this.name+"_panel_"+n.type+" > .w2ui-panel-content").html(n.content),n.tabs!=null&&n.tabs.refresh(),n.toolbar!=null&&n.toolbar.refresh()}else{if($("#layout_"+this.name+"_panel_main").length<=0){this.render();return}this.resize();for(var n in this.panels)this.refresh(this.panels[n].type)}return this.trigger($.extend(t,{phase:"after"})),!0},resize:function(){window.getSelection&&window.getSelection().removeAllRanges();if(!this.box)return!1;var e=this.trigger({phase:"before",type:"resize",target:this.name,panel:this.tmp_resizing});if(e.stop===!0)return!1;var t=parseInt($(this.box).width()),n=parseInt($(this.box).height());$(this.box).find(" > div").css({width:t+"px",height:n+"px"});var r=this,i=this.get("main"),s=this.get("preview"),o=this.get("left"),u=this.get("right"),a=this.get("top"),f=this.get("bottom"),l=!0,c=s!=null&&s.hidden!=1?!0:!1,h=o!=null&&o.hidden!=1?!0:!1,p=u!=null&&u.hidden!=1?!0:!1,d=a!=null&&a.hidden!=1?!0:!1,v=f!=null&&f.hidden!=1?!0:!1;a&&String(a.size).substr(String(a.size).length-1)=="%"&&(a.size=n*parseInt(a.size)/100),o&&String(o.size).substr(String(o.size).length-1)=="%"&&(o.size=n*parseInt(o.size)/100),u&&String(u.size).substr(String(u.size).length-1)=="%"&&(u.size=n*parseInt(u.size)/100),f&&String(f.size).substr(String(f.size).length-1)=="%"&&(f.size=n*parseInt(f.size)/100),s&&String(s.size).substr(String(s.size).length-1)=="%"&&(s.size=(n-(a&&!a.hidden?a.size:0)-(f&&!f.hidden?f.size:0))*parseInt(s.size)/100),a&&(a.size=parseInt(a.size)),o&&(o.size=parseInt(o.size)),s&&(s.size=parseInt(s.size)),u&&(u.size=parseInt(u.size)),f&&(f.size=parseInt(f.size));if(a!=null&&a.hidden!=1){var m=0,g=0,y=t,b=a.size;$("#layout_"+this.name+"_panel_top").css({display:"block",left:m+"px",top:g+"px",width:y+"px",height:b+"px"}).show(),a.width=y,a.height=b,a.resizable&&(g=a.size,b=this.resizer,$("#layout_"+this.name+"_resizer_top").show().css({display:"block",left:m+"px",top:g+"px",width:y+"px",height:b+"px",cursor:"ns-resize"}).bind("mousedown",function(e){return w2ui[r.name].startResize("top",e),!1}))}else $("#layout_"+this.name+"_panel_top").hide();if(o!=null&&o.hidden!=1){var m=0,g=0+(d?a.size+(a.resizable?this.resizer:this.padding):0),y=o.size,b=n-(d?a.size+(a.resizable?this.resizer:this.padding):0)-(v?f.size+(f.resizable?this.resizer:this.padding):0),w=$("#layout_"+this.name+"_panel_left");window.navigator.userAgent.indexOf("MSIE")>0&&w.length>0&&w[0].clientHeight0&&w.length>0&&w[0].clientHeight0&&w.length>0&&w[0].clientHeight .w2ui-panel-",n=0;S.tabs!=null&&(w2ui[this.name+"_"+E+"_tabs"]&&w2ui[this.name+"_"+E+"_tabs"].resize(),n+=w2utils.getSize($(x+"tabs").css({display:"block"}),"height")),S.toolbar!=null&&(w2ui[this.name+"_"+E+"_toolbar"]&&w2ui[this.name+"_"+E+"_toolbar"].resize(),n+=w2utils.getSize($(x+"toolbar").css({top:n+"px",display:"block"}),"height")),$(x+"content").css({display:"block"}).css({top:n+"px"})}for(var T in this.panels){var E=this.panels[T];typeof E.content=="object"&&E.content.resize&&E.content.resize()}var r=this;return clearTimeout(this._resize_timer),this._resize_timer=setTimeout(function(){for(var e in w2ui)typeof w2ui[e].resize=="function"&&typeof w2ui[e].panels=="undefined"&&w2ui[e].resize()},200),this.trigger($.extend(e,{phase:"after"})),!0},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});return e.stop===!0?!1:typeof w2ui[this.name]=="undefined"?!1:($(this.box).find("#layout_"+this.name+"_panel_main").length>0&&$(this.box).removeData("w2name").removeClass("w2ui-layout").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"})),$(window).off("resize",this.events.resize),$(document).off("mousemove",this.events.mousemove),$(document).off("mouseup",this.events.mouseup),!0)},initEvents:function(){var e=this;this.events={resize:function(t){w2ui[e.name].resize()},mousemove:function(t){w2ui[e.name].doResize(t)},mouseup:function(t){w2ui[e.name].stopResize(t)}},$(window).on("resize",this.events.resize),$(document).on("mousemove",this.events.mousemove),$(document).on("mouseup",this.events.mouseup)},startResize:function(e,t){if(!this.box)return;t||(t=window.event),window.addEventListener||window.document.attachEvent("onselectstart",function(){return!1}),this.tmp_resizing=e,this.tmp_x=t.screenX,this.tmp_y=t.screenY,this.tmp_div_x=0,this.tmp_div_y=0;if(e=="left"||e=="right")this.tmp_value=parseInt($("#layout_"+this.name+"_resizer_"+e)[0].style.left);if(e=="top"||e=="preview"||e=="bottom")this.tmp_value=parseInt($("#layout_"+this.name+"_resizer_"+e)[0].style.top)},doResize:function(e){if(!this.box)return;e||(e=window.event);if(typeof this.tmp_resizing=="undefined")return;var t=this.get(this.tmp_resizing),n=this.trigger({phase:"before",type:"resizing",target:this.tmp_resizing,object:t,event:e});if(n.stop===!0)return!1;var r=$("#layout_"+this.name+"_resizer_"+this.tmp_resizing
);r.hasClass("active")||r.addClass("active"),this.tmp_div_x=e.screenX-this.tmp_x,this.tmp_div_y=e.screenY-this.tmp_y,this.tmp_resizing=="left"&&this.get("left").minSize-this.tmp_div_x>this.get("left").width&&(this.tmp_div_x=this.get("left").minSize-this.get("left").width),this.tmp_resizing=="left"&&this.get("main").minSize+this.tmp_div_x>this.get("main").width&&(this.tmp_div_x=this.get("main").width-this.get("main").minSize),this.tmp_resizing=="right"&&this.get("right").minSize+this.tmp_div_x>this.get("right").width&&(this.tmp_div_x=this.get("right").width-this.get("right").minSize),this.tmp_resizing=="right"&&this.get("main").minSize-this.tmp_div_x>this.get("main").width&&(this.tmp_div_x=this.get("main").minSize-this.get("main").width),this.tmp_resizing=="top"&&this.get("top").minSize-this.tmp_div_y>this.get("top").height&&(this.tmp_div_y=this.get("top").minSize-this.get("top").height),this.tmp_resizing=="top"&&this.get("main").minSize+this.tmp_div_y>this.get("main").height&&(this.tmp_div_y=this.get("main").height-this.get("main").minSize),this.tmp_resizing=="bottom"&&this.get("bottom").minSize+this.tmp_div_y>this.get("bottom").height&&(this.tmp_div_y=this.get("bottom").height-this.get("bottom").minSize),this.tmp_resizing=="bottom"&&this.get("main").minSize-this.tmp_div_y>this.get("main").height&&(this.tmp_div_y=this.get("main").minSize-this.get("main").height),this.tmp_resizing=="preview"&&this.get("preview").minSize+this.tmp_div_y>this.get("preview").height&&(this.tmp_div_y=this.get("preview").height-this.get("preview").minSize),this.tmp_resizing=="preview"&&this.get("main").minSize-this.tmp_div_y>this.get("main").height&&(this.tmp_div_y=this.get("main").minSize-this.get("main").height);switch(this.tmp_resizing){case"top":case"preview":case"bottom":this.tmp_div_x=0,r.length>0&&(r[0].style.top=this.tmp_value+this.tmp_div_y+"px");break;case"left":case"right":this.tmp_div_y=0,r.length>0&&(r[0].style.left=this.tmp_value+this.tmp_div_x+"px")}this.trigger($.extend(n,{phase:"after"}))},stopResize:function(e){if(!this.box)return;e||(e=window.event),window.addEventListener||window.document.attachEvent("onselectstart",function(){return!1});if(typeof this.tmp_resizing=="undefined")return;var t=this.get(this.tmp_resizing);switch(this.tmp_resizing){case"top":t.size=parseInt(t.size)+this.tmp_div_y;break;case"preview":case"bottom":t.size=parseInt(t.size)-this.tmp_div_y;break;case"left":t.size=parseInt(t.size)+this.tmp_div_x;break;case"right":t.size=parseInt(t.size)-this.tmp_div_x}this.resize(),$("#layout_"+this.name+"_resizer_"+this.tmp_resizing).removeClass("active"),delete this.tmp_resizing}},$.extend(e.prototype,$.w2event),w2obj.layout=e}(),function(){$.fn.w2popup=function(e,t){typeof e=="undefined"&&(t={},e="open"),$.isPlainObject(e)&&(t=e,e="open"),typeof t=="undefined"&&(t={});var n={};return $(this).length>0&&($(this).find("div[rel=title]").length>0&&(n.title=$(this).find("div[rel=title]").html()),$(this).find("div[rel=body]").length>0&&(n.body=$(this).find("div[rel=body]").html(),n.style=$(this).find("div[rel=body]")[0].style.cssText),$(this).find("div[rel=buttons]").length>0&&(n.buttons=$(this).find("div[rel=buttons]").html()),parseInt($(this).css("width"))!=0&&(n.width=parseInt($(this).css("width"))),parseInt($(this).css("height"))!=0&&(n.height=parseInt($(this).css("height")))),window.w2popup[e]($.extend({},n,t))},window.w2popup={defaults:{title:"",body:"",buttons:"",style:"",color:"#000",opacity:.4,speed:.3,modal:!1,maximized:!1,width:500,height:300,showClose:!0,showMax:!1,transition:null,onUnlock:null,onOpen:null,onChange:null,onBeforeClose:null,onClose:null,onMax:null,onMin:null},open:function(e){var t=$("#w2ui-popup").data("options"),e=$.extend({},this.defaults,{body:"",renderTime:0,onOpen:null,onChange:null,onBeforeClose:null,onClose:null},t,e);if(window.innerHeight==undefined){var n=document.documentElement.offsetWidth,r=document.documentElement.offsetHeight;w2utils.engine=="IE7"&&(n+=21,r+=4)}else var n=window.innerWidth,r=window.innerHeight;parseInt(n)-10';e.title!=""&&(o+='
",buttons:' '+''}),$("#w2ui-popup #buttonNo").on("click",function(){$().w2popup("close"),typeof n=="function"&&n("No")}),$("#w2ui-popup #buttonYes").on("click",function(){$().w2popup("close"),typeof n=="function"&&n("Yes")})}}(),function(){var e=function(e){this.box=null,this.name=null,this.active=null,this.tabs=[],this.right="",this.style="",this.onClick=null,this.onClose=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,$.extend(!0,this,e)};$.fn.w2tabs=function(t){if(typeof t=="object"||!t){if(!t||typeof t.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2tabs().');return}if(typeof w2ui[t.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+t.name+").");return}if(!w2utils.isAlphaNumeric(t.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=t.tabs,r=new e(t);$.extend(r,{tabs:[],handlers:[]});for(var i in n)r.tabs[i]=$.extend({},e.prototype.tab,n[i]);return $(this).length!=0&&(r.box=$(this)[0],$(this).data("w2name",r.name),r.render()),w2ui[r.name]=r,r}if(typeof $(this).data("w2name")!="undefined"){var s=w2ui[$(this).data("w2name")];return s[t].apply(s,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+t+" does not exist on jQuery.w2tabs")},e.prototype={tab:{id:null,text:"",hidden:!1,disabled:!1,closable:!1,hint:"",onClick:null,onRefresh:null,onClose:null},add:function(e){return this.insert(null,e)},insert:function(e,t){$.isArray(t)||(t=[t]);for(var n in t){if(String(t[n].id)=="undefined"){console.log('ERROR: The parameter "id" is required but not supplied. (obj: '+this.name+")");return}var r=!0;for(var i in this.tabs)if(this.tabs[i].id==t[n].id){r=!1;break}if(!r){console.log('ERROR: The parameter "id='+t[n].id+'" is not unique within the current tabs. (obj: '+this.name+")");return}if(!w2utils.isAlphaNumeric(t[n].id)){console.log('ERROR: The parameter "id='+t[n].id+'" must be alpha-numeric + "-_". (obj: '+this.name+")");return}var t=$.extend({},t,t[n]);if(e==null||typeof e=="undefined")this.tabs.push(t);else{var s=this.get(e,!0);this.tabs=this.tabs.slice(0,s).concat([t],this.tabs.slice(s))}this.refresh(t[n].id)}},remove:function(e){var t=0;for(var n in arguments){var r=this.get(arguments[n]);if(!r)return!1;t++,this.tabs.splice(this.get(r.id,!0),1),$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(r.id)).remove()}return t},select:function(e){return this.get(e)==null||this.active==e?!1:(this.active=e,this.refresh(),!0)},set:function(e,t){var n=this.get(e,!0);return n==null?!1:($.extend(this.tabs[n],t),this.refresh(e),!0)},get:function(e,t){for(var n in this.tabs)if(this.tabs[n].id==e)return t===!0?n:this.tabs[n];return null},show:function(){var e=0;for(var t in arguments){var n=this.get(arguments[t]);if(!n||n.hidden===!1)continue;n.hidden=!1,this.refresh(n.id),e++}return e},hide:function(){var e=0;for(var t in arguments){var n=this.get(arguments[t]);if(!n||n.hidden===!0)continue;n.hidden=!0,this.refresh(n.id),e++}return e},enable:function(e){var t=0;for(var n in arguments){var r=this.get(arguments[n]);if(!r||r.disabled===!1)continue;r.disabled=!1,this.refresh(r.id),t++}return t},disable:function(e){var t=0;for(var n in arguments){var r=this.get(arguments[n]);if(!r||r.disabled===!0)continue;r.disabled=!0,this.refresh(r.id),t++}return t},refresh:function(e){window.getSelection&&window.getSelection().removeAllRanges();if(String(e)=="undefined")for(var t in this.tabs)this.refresh(this.tabs[t].id);var n=this.trigger({phase:"before",type:"refresh",target:typeof e!="undefined"?e:this.name,tab:this.get(e)});if(n.stop===!0)return!1;var r=this.get(e);if(r==null)return;typeof r.caption!="undefined"&&(r.text=r.caption);var i=$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(r.id)),s=(r.closable?'":"")+'
";$(this.box).data("w2name",this.name).addClass("w2ui-reset w2ui-tabs").html(n),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.trigger($.extend(t,{phase:"after"})),this.refresh()},resize:function(){window.getSelection&&window.getSelection().removeAllRanges();var e=this.trigger({phase:"before",type:"resize",target:this.name});if(e.stop===!0)return!1;this.trigger($.extend(e,{phase:"after"}))},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});if(e.stop===!0)return!1;$(this.box).find("> table #tabs_"+this.name+"_right").length>0&&$(this.box).removeData("w2name").removeClass("w2ui-reset w2ui-tabs").html(""),delete w2ui[this.name],this.trigger($.extend({phase:"after"}))},doClick:function(e,t){var n=this.get(e);if(n==null||n.disabled)return!1;var r=this.trigger({phase:"before",type:"click",target:e,tab:this.get(e),event:t});if(r.stop===!0)return!1;$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.active)+" .w2ui-tab").removeClass("active"),this.active=n.id,this.trigger($.extend(r,{phase:"after"})),this.refresh(e)},doClose:function(e,t){var n=this.get(e);if(n==null||n.disabled)return!1;var r=this.trigger({phase:"before",type:"close",target:e,tab:this.get(e),event:t});if(r.stop===!0)return!1;var i=this;$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(n.id)).css({"-webkit-transition":".2s","-moz-transition":"2s","-ms-transition":".2s","-o-transition":".2s",opacity:"0"}),setTimeout(function(){var e=$(i.box).find("#tabs_"+i.name+"_tab_"+w2utils.escapeId(n.id)).width();$(i.box).find("#tabs_"+i.name+"_tab_"+w2utils.escapeId(n.id)).html(''),setTimeout(function(){$(i.box).find("#tabs_"+i.name+"_tab_"+w2utils.escapeId(n.id)).find(":first-child").css({width:"0px"})},50)},200),setTimeout(function(){i.remove(e)},450),this.trigger($.extend(r,{phase:"after"})),this.refresh()},doInsert:function(e,t){if(this.get(e)==null)return;if(!$.isPlainObject(t))return;var n=!0;for(var r in this.tabs)if(this.tabs[r].id==t.id){n=!1;break}if(!n){console.log('ERROR: The parameter "id='+t.id+'" is not unique within the current tabs. (obj: '+this.name+")");return}var i=$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(t.id));if(i.length!=0)return;typeof t.caption!="undefined"&&(t.text=t.caption);var s='
",this.get(e,true)!=this.tabs.length&&$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(e,!0))].id)).length>0?$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(e,!0))].id)).before(html):$(this.box).find("#tabs_"+this.name+"_right").before(html);var u=this;setTimeout(function(){var e=$("#_tmp_simple_tab").width();$("#_tmp_tabs").remove(),$("#tabs_"+u.name+"_tab_"+w2utils.escapeId(t.id)+" > div").css("width",e+"px")},1),setTimeout(function(){u.insert(e,t)},200)}},$.extend(e.prototype,$.w2event),w2obj.tabs=e}(),function(){var e=function(e){this.box=null,this.name=null,this.items=[],this.right="",this.onClick=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,$.extend(!0,this,e)};$.fn.w2toolbar=function(t){if(typeof t=="object"||!t){if(!t||typeof t.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2toolbar().');return}if(typeof w2ui[t.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+t.name+").");return}if(!w2utils.isAlphaNumeric(t.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=t.items,r=new e(t);$.extend(r,{items:[],handlers:[]});for(var i in n)r.items[i]=$.extend({},e.prototype.item,n[i]);return $(this).length!=0&&(r.box=$(this)[0],$(this).data("w2name",r.name),r.render()),w2ui[r.name]=r,r}if(typeof $(this).data("w2name")!="undefined"){var s=w2ui[$(this).data("w2name")];return s[t].apply(s,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+t+" does not exist on jQuery.w2toolbar")},e.prototype={item:{id:null,type:"button",text:"",html:"",img:null,icon:null,hidden:!1,disabled:!1,checked:!1,arrow:!0,hint:"",group:null,items:null,onClick:null},add:function(e){this.insert(null,e)},insert:function(t,n){$.isArray(n)||(n=[n]);for(var r in n){if(typeof n[r].type=="undefined"){console.log('ERROR: The parameter "type" is required but not supplied in w2toolbar.add() method.');return}if($.inArray(String(n[r].type),["button","check","radio","drop","menu","break","html","spacer"])==-1){console.log('ERROR: The parameter "type" should be one of the following [button, check, radio, drop, menu, break, html, spacer] in w2toolbar.add() method.');return}if(typeof n[r].id=="undefined"){console.log('ERROR: The parameter "id" is required but not supplied in w2toolbar.add() method.');return}var i=!0;for(var s=0;s table #tb_"+this.name+"_right").length>0&&$(this.box).removeData("w2name").removeClass("w2ui-reset w2ui-toolbar").html(""),this.box=e);if(!this.box)return;var n='
"+''}return t}window.getSelection&&window.getSelection().removeAllRanges();var t=this.trigger({phase:"before",type:"refresh",target:typeof e!="undefined"?e:this.name});if(t.stop===!0)return!1;this.topHTML!=""&&($(this.box).find(".w2ui-sidebar-top").html(this.topHTML),$(this.box).find(".w2ui-sidebar-div").css("top",$(this.box).find(".w2ui-sidebar-top").height()+"px")),this.bottomHTML!=""&&($(this.box).find(".w2ui-sidebar-bottom").html(this.bottomHTML),$(this.box).find(".w2ui-sidebar-div").css("bottom",$(this.box).find(".w2ui-sidebar-bottom").height()+"px")),$(this.box).find("> div").css({width:$(this.box).width()+"px",height:$(this.box).height()+"px"});var n=this;if(typeof e=="undefined")var r=this,i=".w2ui-sidebar-div";else{var r=this.get(e);if(r==null)return;var i="#node_"+w2utils.escapeId(r.id)+"_sub"}if(r!=this){var s="#node_"+w2utils.escapeId(r.id),o=a(r);$(this.box).find(s).before(''),$(this.box).find(s).remove(),$(this.box).find(i).remove(),$("#sidebar_"+this.name+"_tmp").before(o),$("#sidebar_"+this.name+"_tmp").remove()}$(this.box).find(i).html("");for(var u=0;u div").css({width:$(this.box).width()+"px",height:$(this.box).height()+"px"}),this.trigger($.extend(e,{phase:"after"}))},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});if(e.stop===!0)return!1;$(this.box).find("> div > div.w2ui-sidebar-div").length>0&&$(this.box).removeData("w2name").removeClass("w2ui-reset w2ui-sidebar").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"}))}},$.extend(e.prototype,$.w2event),w2obj.sidebar=e}(),function(e){var t=new function(){this.customTypes=[]};e.fn.w2field=function(e){if(t[e])return t[e].apply(this,Array.prototype.slice.call(arguments,1));if(typeof e=="object")return t.init.apply(this,arguments);if(typeof e=="string")return t.init.apply(this,[{type:e}]);console.log("ERROR: Method "+e+" does not exist on jQuery.w2field")},e.extend(t,{init:function(n){var r=t;return e(this).each(function(r,i){if(typeof t.customTypes[n.type.toLowerCase()]=="function"){t.customTypes[n.type.toLowerCase()].call(this,n);return}switch(n.type.toLowerCase()){case"clear":e(this).off("keypress").off("focus").off("blur"),e(this).removeData(),e(this).prev().hasClass("w2ui-list")&&(e(this).prev().remove(),e(this).removeAttr("tabindex").css("border-color","").show()),e(this).prev().hasClass("w2ui-upload")&&(e(this).prev().remove(),e(this).removeAttr("tabindex").css("border-color","").show());break;case"text":break;case"int":e(this).on("keypress",function(e){if(e.metaKey||e.ctrlKey||e.altKey||e.charCode!=e.keyCode&&e.keyCode>0)return;var t=String.fromCharCode(e.charCode);if(!w2utils.isInt(t)&&t!="-")return e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}),e(this).on("blur",function(t){this.value!=""&&!w2utils.isInt(this.value)&&e(this).w2tag(w2utils.lang("Not an integer"))});break;case"float":e(this).on("keypress",function(e){if(e.metaKey||e.ctrlKey||e.altKey||e.charCode!=e.keyCode&&e.keyCode>0)return;var t=String.fromCharCode(e.charCode);if(!w2utils.isInt(t)&&t!="."&&t!="-")return e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}),e(this).on("blur",function(t){this.value!=""&&!w2utils.isFloat(this.value)&&e(this).w2tag(w2utils.lang("Not a float"))});break;case"money":e(this).on("keypress",function(e){if(e.metaKey||e.ctrlKey||e.altKey||e.charCode!=e.keyCode&&e.keyCode>0)return;var t=String.fromCharCode(e.charCode);if(!w2utils.isInt(t)&&t!="."&&t!="-"&&t!="$"&&t!="€"&&t!="£"&&t!="¥")return e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}),e(this).on("blur",function(t){this.value!=""&&!w2utils.isMoney(this.value)&&e(this).w2tag(w2utils.lang("Not in money format"))});break;case"hex":e(this).on("keypress",function(e){if(e.metaKey||e.ctrlKey||e.altKey||e.charCode!=e.keyCode&&e.keyCode>0)return;var t=String.fromCharCode(e.charCode);if(!w2utils.isHex(t))return e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}),e(this).on("blur",function(t){this.value!=""&&!w2utils.isHex(this.value)&&e(this).w2tag(w2utils.lang("Not a hex number"))});break;case"alphanumeric":e(this).on("keypress",function(e){if(e.metaKey||e.ctrlKey||e.altKey||e.charCode!=e.keyCode&&e.keyCode>0)return;var t=String.fromCharCode(e.charCode);if(!w2utils.isAlphaNumeric(t))return e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}),e(this).on("blur",function(t){this.value!=""&&!w2utils.isAlphaNumeric(this.value)&&e(this).w2tag(w2utils.lang("Not alpha-numeric"))});break;case"date":var s=this,o={format:w2utils.settings.date_format,start:"",end:"",blocked:{},colored:{}};n=e.extend({},o,n),e(this).css({transition:"none","-webkit-transition":"none","-moz-transition":"none","-ms-transition":"none","-o-transition":"none"}).data("options",n).on("focus",function(){var t=parseFloat(e(s).offset().top)+parseFloat(s.offsetHeight),r=parseFloat(e(s).offset().left);clearInterval(e(s).data("mtimer")),e("#global_calendar_div").remove(),e("body").append('
'+"
"),e("#global_calendar_div").html(e().w2field("calendar_get",s.value,n)).css({left:r+"px",top:t+"px"}).data("el",s).show();var i=setInterval(function(){e("#global_calendar_div").data("position")!=e(s).offset().left+"x"+(e(s).offset().top+s.offsetHeight)&&e("#global_calendar_div").css({"-webkit-transition":".2s",left:e(s).offset().left+"px",top:e(s).offset().top+s.offsetHeight+"px"}).data("position",e(s).offset().left+"x"+(e(s).offset().top+s.offsetHeight));if(e(s).length==0||e(s).offset().left==0&&e(s).offset().top==0){clearInterval(i),e("#global_calendar_div").remove();return}},100);e(s).data("mtimer",i)}).on("blur",function(t){e(s).val(e.trim(e(s).val())),e.trim(e(s).val())!=""&&!w2utils.isDate(e(s).val(),n.format)&&e(this).w2tag(w2utils.lang("Not a valid date")+": "+n.format),clearInterval(e(s).data("mtimer")),e("#global_calendar_div").remove()}).on("keypress",function(t){var r=this;setTimeout(function(){e("#global_calendar_div").html(e().w2field("calendar_get",r.value,n))},10)});break;case"time":break;case"datetime":break;case"color":break;case"select":case"list":if(this.tagName!="SELECT"){console.log("ERROR: You can only apply $().w2field('list') to a SELECT element");return}var o={items:[],value:null,showNone:!0},u=e.extend({},o,n),a="",f=t.cleanItems(u.items);u.showNone&&(a='");for(var l in f)!u.showNone&&u.value==null&&(u.value=f[l].id),a+='";u.items=f,e(this).data("settings",u),e(this).html(a),e(this).val(u.value),e(this).val()!=u.value&&e(this).change();break;case"enum":if(this.tagName!="INPUT"){console.log("ERROR: You can only apply $().w2field('enum') to an INPUT element");return}var o={url:"",items:[],selected:[],max:0,maxHeight:72,showAll:!1,maxCache:500,onRender:null,onSelect:null},s=this,u=e.extend({},o,n);u.items=t.cleanItems(u.items),u.selected=t.cleanItems(u.selected),e(this).data("selected",u.selected),e(this).css({"border-color":"transparent"}),this.add=function(t){var n=e(this).data("selected");e.isArray(n)||(n=[]),u.max!=0&&u.max<=n.length&&n.splice(n.length-1,1),n.push(t),e(this).data("selected",n),e(this).data("last_del",null),e(this).trigger("change")},this.show=function(){if(e("#w2ui-global-items").length!=0)return;e("body").append('');var n=e("#w2ui-global-items");n.css({display:"block",left:e(s).offset().left+"px",top:e(s).offset().top+s.offsetHeight+"px"}).width(w2utils.getSize(s,"width")).data("position",e(s).offset().left+"x"+(e(s).offset().top+s.offsetHeight)),t.list_render.call(s);var r=function(){var n=e("#w2ui-global-items");if(e(s).length==0||e(s).offset().left==0&&e(s).offset().top==0){clearInterval(e(s).data("mtimer")),hide();return}n.data("position")!=e(s).offset().left+"x"+(e(s).offset().top+s.offsetHeight)&&(n.css({"-webkit-transition":".2s",left:e(s).offset().left+"px",top:e(s).offset().top+s.offsetHeight+"px"}).data("position",e(s).offset().left+"x"+(e(s).offset().top+s.offsetHeight)),setTimeout(function(){t.list_render.call(s,e(s).data("last_search"))},200)),n.length>0&&e(s).data("mtimer",setTimeout(r,100))};e(s).data("mtimer",setTimeout(r,100))},this.hide=function(){clearTimeout(e(s).data("mtimer")),e("#w2ui-global-items").remove()},this.refresh=function(){var n=this;e(e(this).data("div")).remove();var r="margin-top: "+e(this).css("margin-top")+"; "+"margin-bottom: "+e(this).css("margin-bottom")+"; "+"margin-left: "+e(this).css("margin-left")+"; "+"margin-right: "+e(this).css("margin-right")+"; "+"width: "+(w2utils.getSize(this,"width")-parseInt(e(this).css("margin-left"))-parseInt(e(this).css("margin-right")))+"px; ",i='
'+"
",s=e(this).data("selected");for(var o in s)i+='
'+'
'+s[o].text+"
";i+='',i+="
",e(this).before(i);var a=e(this).prev()[0];e(this).data("div",a);var f=w2utils.getSize(a,"height")-parseInt(e(a).css("margin-top"))-parseInt(e(a).css("margin-bottom"));f<23&&(f=23),f>u.maxHeight&&(f=u.maxHeight),e(a).height(f),a.length>0&&(a[0].scrollTop=1e3),e(this).height(f),e(a).on("click",function(r){var i=r.target;i.title==w2utils.lang("Remove")&&(e(n).data("selected").splice(e(i).attr("index"),1),e(i.parentNode).remove(),n.refresh(),t.list_render.call(n),e(n).trigger("change"),r.stopPropagation?r.stopPropagation():r.cancelBubble=!0),e(this).find("input").focus()}),e(a).find("input").on("focus",function(t){e(a).css({outline:"auto 5px -webkit-focus-ring-color","outline-offset":"-2px"}),n.show(),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0}).on("blur",function(t){e(a).css("outline","none"),n.hide(),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0})},e(this).data("settings",u).attr("tabindex",-1),this.refresh();break;case"upload":if(this.tagName!="INPUT"){console.log("ERROR: You can only apply $().w2field('upload') to an INPUT element");return}var o={url:"",base64:!0,hint:w2utils.lang("Attach files by dragging and dropping or Click to Select"),max:0,maxSize:0,maxFileSize:0,onAdd:null,onRemove:null,onItemClick:null,onItemDblClick:null,onItemOver:null,onItemOut:null,onProgress:null,onComplete:null},s=this,u=e.extend({},o,n);u.base64===!0&&(u.maxSize==0&&(u.maxSize=20971520),u.maxFileSize==0&&(u.maxFileSize=20971520));var c=u.selected;delete u.selected,e.isArray(c)||(c=[]),e(this).data("selected",c).data("settings",u).attr("tabindex",-1),t.upload_init.call(this),this.refresh=function(){var t=this,n=e(this).data("div"),r=e(this).data("settings"),i=e(this).data("selected");e(n).find("li").remove();for(var s in i){var o=i[s],u=e(n).find(".file-list li").length;e(n).find("> span:first-child").remove(),e(n).find(".file-list").append('
",d}}),w2obj.field=t}(jQuery),function(){var w2form=function(e){this.name=null,this.header="",this.box=null,this.url="",this.formURL="",this.formHTML="",this.page=0,this.recid=0,this.fields=[],this.actions={},this.record={},this.original={},this.postData={},this.tabs={},this.style="",this.focusFirst=!0,this.msgNotJSON=w2utils.lang("Return data is not in JSON format."),this.msgRefresh=w2utils.lang("Refreshing..."),this.msgSaving=w2utils.lang("Saving..."),this.onRequest=null,this.onLoad=null,this.onSubmit=null,this.onSave=null,this.onChange=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,this.onAction=null,this.onError=null,this.last={xhr:null},$.extend(!0,this,e)};$.fn.w2form=function(e){if(typeof e=="object"||!e){var t=this;if(!e||typeof e.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2form().');return}if(typeof w2ui[e.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+e.name+").");return}if(!w2utils.isAlphaNumeric(e.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=e.record,r=e.original,i=e.fields,s=e.tabs,o=new w2form(e);$.extend(o,{record:{},original:{},fields:[],tabs:{},handlers:[]}),$.isArray(s)?$.extend(!0,o.tabs,{tabs:s}):$.extend(!0,o.tabs,s);for(var u in i)o.fields[u]=$.extend(!0,{},i[u]);for(var u in n)$.isPlainObject(n[u])?o.record[u]=$.extend(!0,{},n[u]):o.record[u]=n[u];for(var u in r)$.isPlainObject(r[u])?o.original[u]=$.extend(!0,{},r[u]):o.original[u]=r[u];return o.initTabs(),$(this).length!=0&&!o.formURL?(o.formHTML||(o.formHTML=$(this).html()),o.init(this),o.render($(this)[0])):o.formURL&&$.get(o.formURL,function(e){o.formHTML=e;if($(t).length!=0||e.length!=0)$(t).html(o.formHTML),o.init(t),o.render($(t)[0])}),w2ui[o.name]=o,o}if(typeof $(this).data("w2name")!="undefined"){var t=w2ui[$(this).data("w2name")];return t[e].apply(t,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+e+" does not exist on jQuery.w2form")},w2form.prototype={init:function(e){var t=this;$(e).find("input, textarea, select").each(function(e,n){var r="text",i=typeof $(n).attr("name")!="undefined"?$(n).attr("name"):$(n).attr("id");n.type=="checkbox"&&(r="checkbox"),n.type=="radio"&&(r="radio"),n.type=="password"&&(r="password"),n.type=="button"&&(r="button"),n.tagName=="select"&&(r="list"),n.tagName=="textarea"&&(r="textarea");var s=r=="checkbox"||r=="radio"?$(n).attr("checked")?!0:!1:$(n).val(),o=t.get(i);if(o&&r!="button"){var u=$(n).parents(".w2ui-page");if(u.length>0)for(var a=0;a<100;a++)if(u.hasClass("page-"+a)){o.page=a;break}}else r!="button"&&console.log('WARNING: Field "'+i+'" is present in HTML, but not defined in w2form.')})},initTabs:function(){if(typeof this.tabs["render"]=="undefined"){var e=this;this.tabs=$().w2tabs($.extend({},this.tabs,{name:this.name+"_tabs",owner:this})),this.tabs.on("click",function(t,n){e.goto(this.get(t,!0))})}return},get:function(e,t){for(var n in this.fields)if(this.fields[n].name==e)return t===!0?n:this.fields[n];return null},set:function(e,t){for(var n in this.fields)if(this.fields[n].name==e)return $.extend(this.fields[n],t),this.refresh(),!0;return!1},reload:function(e){this.url!=""?this.request(e):(this.refresh(),typeof e=="function"&&e())},clear:function(){this.recid=0,this.record={};for(var e in this.fields){var t=this.fields[e];t.options&&t.options.selected&&delete t.options.selected}$().w2tag(),this.refresh()},error:function(e){var t=this,n=this.trigger({target:this.name,type:"error",message:e,xhr:this.last.xhr});if(n.stop===!0)return typeof callBack=="function"&&callBack(),!1;setTimeout(function(){$("#w2ui-popup").length>0?$().w2popup("message",{width:370,height:140,html:'
",buttons:''}),console.log("ERROR: "+e)},1),this.trigger($.extend(n,{phase:"after"}))},validate:function(e){typeof e=="undefined"&&(e=!0);var t=[];for(var n in this.fields){var r=this.fields[n];this.record[r.name]==null&&(this.record[r.name]="");switch(r.type){case"int":if(this.record[r.name]&&!w2utils.isInt(this.record[r.name])){var i={field:r,error:w2utils.lang("Not an integer")};t.push(i),e&&$(r.el).w2tag(i.error,{"class":"w2ui-error"})}break;case"float":if(this.record[r.name]&&!w2utils.isFloat(this.record[r.name])){var i={field:r,error:w2utils.lang("Not a float")};t.push(i),e&&$(r.el).w2tag(i.error,{"class":"w2ui-error"})}break;case"money":if(this.record[r.name]&&!w2utils.isMoney(this.record[r.name])){var i={field:r,error:w2utils.lang("Not in money format")};t.push(i),e&&$(r.el).w2tag(i.error,{"class":"w2ui-error"})}break;case"hex":if(this.record[r.name]&&!w2utils.isHex(this.record[r.name])){var i={field:r,error:w2utils.lang("Not a hex number")};t.push(i),e&&$(r.el).w2tag(i,{"class":"w2ui-error"})}break;case"email":if(this.record[r.name]&&!w2utils.isEmail(this.record[r.name])){var i={field:r,error:w2utils.lang("Not a valid email")};t.push(i),e&&$(r.el).w2tag(i.error,{"class":"w2ui-error"})}break;case"checkbox":this.record[r.name]==1?this.record[r.name]=1:this.record[r.name]=0;break;case"date":if(this.record[r.name]&&!w2utils.isDate(this.record[r.name],r.options.format)){var i={field:r,error:w2utils.lang("Not a valid date")+": "+r.options.format};t.push(i),e&&$(r.el).w2tag(i.error,{"class":"w2ui-error"})}break;case"select":case"list":break;case"enum":}var s=this.record[r.name];if(r.required&&(s===""||$.isArray(s)&&s.length==0)){var i={field:r,error:w2utils.lang("Required field")};t.push(i),e&&$(r.el).w2tag(i.error,{"class":"w2ui-error"})}}return t},request:function(postData,callBack){var obj=this;typeof postData=="function"&&(callBack=postData,postData=null),$.isPlainObject(postData)||(postData={});if(!this.url)return;if(this.recid==null||typeof this.recid=="undefined")this.recid=0;var params={};params.cmd="get-record",params.name=this.name,params.recid=this.recid,$.extend(params,this.postData),$.extend(params,postData);var eventData=this.trigger({phase:"before",type:"request",target:this.name,url:this.url,postData:params});if(eventData.stop===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Request aborted."}),!1;this.record={},this.original={},this.lock(this.msgRefresh);if(this.last.xhr)try{this.last.xhr.abort()}catch(e){}this.last.xhr=$.ajax({type:"GET",url:eventData.url,data:String($.param(eventData.postData,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]"),dataType:"text",complete:function(xhr,status){obj.unlock();var eventData=obj.trigger({phase:"before",target:obj.name,type:"load",xhr:xhr,status:status});if(eventData.stop===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Request aborted."}),!1;var responseText=obj.last.xhr.responseText;if(status!="error"){if(typeof responseText!="undefined"&&responseText!=""){var data;if(typeof responseText=="object")data=responseText;else try{eval("data = "+responseText)}catch(e){}typeof data=="undefined"&&(data={status:"error",message:obj.msgNotJSON,responseText:responseText}),data["status"]=="error"?obj.error(data.message):(obj.record=$.extend({},data.record),obj.original=$.extend({},data.record))}}else obj.error("AJAX Error "+xhr.status+": "+xhr.statusText);obj.trigger($.extend(eventData,{phase:"after"})),obj.refresh(),typeof callBack=="function"&&callBack(data)}}),this.trigger($.extend(eventData,{phase:"after"}))},save:function(postData,callBack){var obj=this;typeof postData=="function"&&(callBack=postData,postData=null);var errors=obj.validate(!0);if(errors.length!==0){obj.goto(errors[0].field.page);return}if(typeof postData=="undefined"||postData==null)postData={};if(!obj.url){console.log("ERROR: Form cannot be saved because no url is defined.");return}obj.lock(obj.msgSaving+' '),setTimeout(function(){var params={};params.cmd="save-record",params.name=obj.name,params.recid=obj.recid,$.extend(params,this.postData),$.extend(params,postData),params.record=$.extend(!0,{},obj.record);for(var f in obj.fields){var field=obj.fields[f];switch(String(field.type).toLowerCase()){case"date":var dt=params.record[field.name];if(field.options.format.toLowerCase()=="dd/mm/yyyy"||field.options.format.toLowerCase()=="dd-mm-yyyy"||field.options.format.toLowerCase()=="dd.mm.yyyy")var tmp=dt.replace(/-/g,"/").replace(/\./g,"/").split("/"),dt=new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]);params.record[field.name]=w2utils.formatDate(dt,"yyyy-mm-dd")}}var eventData=obj.trigger({phase:"before",type:"submit",target:obj.name,url:obj.url,postData:params});if(eventData.stop===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Saving aborted."}),!1;if(obj.last.xhr)try{obj.last.xhr.abort()}catch(e){}obj.last.xhr=$.ajax({type:w2utils.settings.RESTfull?obj.recid==0?"POST":"PUT":"POST",url:eventData.url,data:String($.param(eventData.postData,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]"),dataType:"text",xhr:function(){var e=new window.XMLHttpRequest;return e.upload.addEventListener("progress",function(e){if(e.lengthComputable){var t=Math.round(e.loaded/e.total*100);$("#"+obj.name+"_progress").text(""+t+"%")}},!1),e},complete:function(xhr,status){obj.unlock();var eventData=obj.trigger({phase:"before",target:obj.name,type:"save",xhr:xhr,status:status});if(eventData.stop===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Saving aborted."}),!1;var responseText=xhr.responseText;if(status!="error"){if(typeof responseText!="undefined"&&responseText!=""){var data;if(typeof responseText=="object")data=responseText;else try{eval("data = "+responseText)}catch(e){}typeof data=="undefined"&&(data={status:"error",message:obj.msgNotJSON,responseText:responseText}),data["status"]=="error"?obj.error(data.message):obj.original=$.extend({},obj.record)}}else obj.error("AJAX Error "+xhr.status+": "+xhr.statusText);obj.trigger($.extend(eventData,{phase:"after"})),obj.refresh(),typeof callBack=="function"&&callBack(data)}}),obj.trigger($.extend(eventData,{phase:"after"}))},50)},lock:function(e,t){var n=this;typeof e=="undefined"||e==""?setTimeout(function(){$("#form_"+n.name+"_lock").remove(),$("#form_"+n.name+"_status").remove()},25):($("#form_"+n.name+"_lock").remove(),$("#form_"+n.name+"_status").remove(),$(this.box).find("> div :first-child").before(''+''),setTimeout(function(){var t=$("#form_"+n.name+"_lock"),r=$("#form_"+n.name+"_status");r.data("old_opacity",r.css("opacity")).css("opacity","0").show(),t.data("old_opacity",t.css("opacity")).css("opacity","0").show(),setTimeout(function(){var i=($(n.box).width()-w2utils.getSize(r,"width"))/2,s=($(n.box).height()*.9-w2utils.getSize(r,"height"))/2;t.css({opacity:t.data("old_opacity"),width:$(n.box).width()+"px",height:$(n.box).height()+"px"}),r.html(e).css({opacity:r.data("old_opacity"),left:i+"px",top:s+"px"})},10)},10))},unlock:function(){this.lock()},"goto":function(e){typeof e!="undefined"&&(this.page=e),$(this.box).data("auto-size")===!0&&$(this.box).height(0),this.refresh()},generateHTML:function(e){var t="";typeof e.pages=="undefined"&&(e.pages=[e.fields],delete e.fields);var n=0;for(var r in e.pages){var i=e.pages[r];typeof i.tab!="undefined"&&this.tabs.add({id:"tab"+this.tabs.tabs.length,caption:i.tab}),t+='
';for(var s in i.fields){var o=i.fields[s],u='";o.type=="select"&&(u='"),o.type=="textarea"&&(u='"),t+='
'+o.caption+":
"+'
'+u+"
"}t+="
",n++}if(typeof e.buttons!="undefined"){t+='
';for(var s in e.buttons){var a=e.buttons[s];t+='"}t+="
"}return this.formHTML=t,this.render(),t},doAction:function(e,t){var n=this.trigger({phase:"before",target:e,type:"action",event:t});if(n.stop===!0)return!1;typeof this.actions[e]=="function"&&this.actions[e].call(this,t),this.trigger($.extend(n,{phase:"after"}))},resize:function(){function f(){n.width($(e.box).width()).height($(e.box).height()),i.css("top",e.header!=""?w2utils.getSize(r,"height"):0),s.css("top",(e.header!=""?w2utils.getSize(r,"height"):0)+(e.tabs.tabs.length>0?w2utils.getSize(i,"height")+5:0)),s.css("bottom",a.length>0?w2utils.getSize(a,"height"):0)}var e=this,t=this.trigger({phase:"before",target:this.name,type:"resize"});if(t.stop===!0)return!1;var n=$(this.box).find("> div"),r=$(this.box).find("> div .w2ui-form-header"),i=$(this.box).find("> div .w2ui-form-tabs"),s=$(this.box).find("> div .w2ui-page"),o=$(this.box).find("> div .w2ui-page.page-"+this.page),u=$(this.box).find("> div .w2ui-page.page-"+this.page+" > div"),a=$(this.box).find("> div .w2ui-buttons");f();if($(this.box).height()==0||$(this.box).data("auto-size")===!0)$(this.box).height((r.length>0?w2utils.getSize(r,"height"):0)+(this.tabs.tabs.length>0?w2utils.getSize(i,"height"):0)+(s.length>0?w2utils.getSize(u,"height")+w2utils.getSize(o,"+height")+12:0)+(a.length>0?w2utils.getSize(a,"height"):0)),$(this.box).data("auto-size",!0);f(),e.trigger($.extend(t,{phase:"after"}))},refresh:function(){var e=this,t=this.trigger({phase:"before",target:this.name,type:"refresh",page:this.page});if(t.stop===!0)return!1;$(this.box).find(".w2ui-page").hide(),$(this.box).find(".w2ui-page.page-"+this.page).show(),typeof this.tabs=="object"&&this.tabs.tabs.length>0?($("#form_"+this.name+"_tabs").show(),this.tabs.active=this.tabs.tabs[this.page].id,this.tabs.refresh()):$("#form_"+this.name+"_tabs").hide();for(var n in this.fields){var r=this.fields[n];r.el=$(this.box).find('[name="'+String(r.name).replace(/\\/g,"\\\\")+'"]')[0];if(typeof r.el=="undefined"){console.log('ERROR: Cannot associate field "'+r.name+'" with html control. Make sure html control exists with the same name.');return}r.el.id=r.name,$(r.el).off("change").on("change",function(){var t=this.value,n=e.record[this.name]?e.record[this.name]:"",r=e.get(this.name);if((r.type=="enum"||r.type=="upload")&&$(this).data("selected")){var i=$(this).data("selected"),s=e.get(this.name).selected,t=[],n=[];if($.isArray(i))for(var o in i)t[o]=$.extend(!0,{},i[o]);if($.isArray(s))for(var o in s)n[o]=$.extend(!0,{},s[o]);e.get(this.name).selected=t}var u=e.trigger({phase:"before",target:this.name,type:"change",value_new:t,value_previous:n});if(u.stop===!0)return $(this).val(e.record[this.name]),!1;var a=this.value;this.type=="checkbox"&&(a=this.checked?!0:!1),this.type=="radio"&&(a=this.checked?!0:!1),r.type=="enum"&&(a=t),r.type=="upload"&&(a=t),e.record[this.name]=a,e.trigger($.extend(u,{phase:"after"}))}),r.required?$(r.el).parent().addClass("w2ui-required"):$(r.el).parent().removeClass("w2ui-required")}$(this.box).find("button, input[type=button]").each(function(t,n){$(n).off("click").on("click",function(t){var n=this.value;this.name&&(n=this.name),this.id&&(n=this.id),e.doAction(n,t)})});for(var n in this.fields){var r=this.fields[n],i=typeof this.record[r.name]!="undefined"?this.record[r.name]:"";switch(String(r.type).toLowerCase()){case"email":case"text":r.el.value=i;break;case"date":r.options||(r.options={}),r.options.format||(r.options.format="mm/dd/yyyy");if(r.options.format.toLowerCase()=="dd/mm/yyyy"||r.options.format.toLowerCase()=="dd-mm-yyyy"||r.options.format.toLowerCase()=="dd.mm.yyyy"){var s=i.replace(/-/g,"/").replace(/\./g,"/").split("/");r.el.value=w2utils.formatDate(s[2]+"-"+s[1]+"-"+s[0],r.options.format)}else r.el.value=w2utils.formatDate(i,r.options.format);this.record[r.name]=r.el.value,$(r.el).w2field($.extend({},r.options,{type:"date"}));break;case"int":r.el.value=i,$(r.el).w2field("int");break;case"float":r.el.value=i,$(r.el).w2field("float");break;case"money":r.el.value=i,$(r.el).w2field("money");break;case"hex":r.el.value=i,$(r.el).w2field("hex");break;case"alphanumeric":r.el.value=i,$(r.el).w2field("alphaNumeric");break;case"checkbox":this.record[r.name]==1||this.record[r.name]==1||this.record[r.name]=="t"?$(r.el).attr("checked",!0):$(r.el).removeAttr("checked");break;case"password":r.el.value=i;break;case"select":case"list":$(r.el).w2field($.extend({},r.options,{type:"list",value:i}));break;case"enum":if(typeof r.options=="undefined"||typeof r.options.url=="undefined"&&typeof r.options.items=="undefined"){console.log("ERROR: (w2form."+e.name+") the field "+r.name+" defined as enum but not field.options.url or field.options.items provided.");break}var o=i;$(r.el).w2field($.extend({},r.options,{type:"enum",selected:i}));break;case"upload":$(r.el).w2field($.extend({},r.options,{type:"upload",selected:i}));break;default:console.log('ERROR: field type "'+r.type+'" is not recognized.')}}var s=$(this.box).find(".w2ui-page");for(var u=0;u *").length>1&&$(s[u]).wrapInner("");this.trigger($.extend(t,{phase:"after"})),this.resize()},render:function(e){function i(){var e=$(t.box).find("input, select");e.length>0&&e[0].focus()}var t=this,n=this.trigger({phase:"before",target:this.name,type:"render",box:typeof e!="undefined"?e:this.box});if(n.stop===!0)return!1;typeof e!="undefined"&&e!=null&&($(this.box).find("#form_"+this.name+"_tabs").length>0&&$(this.box).removeData("w2name").removeClass("w2ui-reset w2ui-form").html(""),this.box=e);var r="