text: var VW={Grid:{}};
  (function(m){VW.Grid.ColumnBehaviour={Default:1,NoHorizontalScrollBar:2};m.CellInfo=function(g,f,d,k){this.cell=g;this.ColumnInfo=f;this.boundData=d;this.row=k};var s={"==":"eq",equals:"eq",isequalto:"eq",equalto:"eq",equal:"eq","!=":"neq",ne:"neq",notequals:"neq",isnotequalto:"neq",notequalto:"neq",notequal:"neq","<":"lt",islessthan:"lt",lessthan:"lt",less:"lt","<=":"lte",le:"lte",islessthanorequalto:"lte",lessthanequal:"lte",">":"gt",isgreaterthan:"gt",greaterthan:"gt",greater:"gt",">=":"gte",isgreaterthanorequalto:"gte",
  greaterthanequal:"gte",ge:"gte",notsubstringof:"doesnotcontain",startsWith:"startswith",endsWith:"endswith",substringof:"contains"},v=function(){function g(b){return b.replace(a,"\\").replace(k,"")}function f(a,c,e,h){var p;null!=e&&("string"===typeof e&&(e=g(e),(p=d.exec(e))?e=new Date(+p[1]):h?(e="'"+e.toLowerCase()+"'",c="("+c+" || '').toLowerCase()"):e="'"+e+"'"),e.getTime&&(c="("+c+"?"+c+".getTime():"+c+")",e=e.getTime()));return c+" "+a+" "+e}var d=/^\/Date\((.*?)\)\/$/,k=/(\r+|\n+)/g,a=/(?=['\\])/g;
  return{eq:function(a,c,e){return f("==",a,c,e)},neq:function(a,c,e){return f("!=",a,c,e)},gt:function(a,c,e){return f(">",a,c,e)},gte:function(a,c,e){return f(">=",a,c,e)},lt:function(a,c,e){return f("<",a,c,e)},lte:function(a,c,e){return f("<=",a,c,e)},startswith:function(a,c,e){e&&(a="("+a+" || '').toLowerCase()",c&&(c=c.toLowerCase()));c&&(c=g(c));return a+".lastIndexOf('"+c+"', 0) == 0"},endswith:function(a,c,e){e&&(a="("+a+" || '').toLowerCase()",c&&(c=c.toLowerCase()));c&&(c=g(c));return a+
  ".indexOf('"+c+"', "+a+".length - "+(c||"").length+") >= 0"},contains:function(a,c,e){e&&(a="("+a+" || '').toLowerCase()",c&&(c=c.toLowerCase()));c&&(c=g(c));return a+".indexOf('"+c+"') >= 0"},doesnotcontain:function(a,c,e){e&&(a="("+a+" || '').toLowerCase()",c&&(c=c.toLowerCase()));c&&(c=g(c));return a+".indexOf('"+c+"') == -1"}}}();m.GridModel=function(g){function f(d){var a,b,c,e=d.filters;if(e)for(d=0,a=e.length;d<a;d++)b=e[d],(c=b.operator)&&"string"===typeof c&&(b.operator=s[c.toLowerCase()]||
  c),f(b)}this.cacheData=this.data=g instanceof RadiantQ.RQ_CollectionChangeNotifier?g:new RadiantQ.RQ_CollectionChangeNotifier(g);this.sortedList=[];this.Change=new ObjectEvent;this.getComparer=function(){for(var d=[],a=0;a<this.sortedList.length;a++){var b=this.sortedList[a],c=null,e=this.createComparer(b),c=e;"desc"==b.dir&&(c=function(a,b){return e(b,a,!0)});d.push(c)}return d};this.createComparer=function(d){var a=new Function("view","return view."+d.field);return function(b,c){b=a(b);c=a(c);return null==
  b&&null==c?0:null==b?-1:null==c?1:b.Compare?b.Compare(c):b>c?1:b<c?-1:0}};this.AddItemsToSortList=function(d){this.removetItemFormSortedList(d);this.sortedList.push(d)};this.removetItemFormSortedList=function(d){this.sortedList=$.grep(this.sortedList,function(a){return a.field!=d.field})};this.combine=function(d){return function(a,b){var c=d[0](a,b),e,h;e=1;for(h=d.length;e<h;e++)c=c||d[e](a,b);return c}};this.sort=function(d){if(null==d.dir){this.removetItemFormSortedList(d);var a=this.getComparer();
  0!=a.length?(a=this.combine(a),this.data=this.data.slice(0).sort(a)):this.data=this.cacheData.slice(0)}else d.comparer=a,"multiple"!=d.mode?(this.sortedList=[],this.AddItemsToSortList(d),a=this.getComparer()[0]):(this.AddItemsToSortList(d),a=this.combine(this.getComparer())),this.data=this.data.slice(0).sort(a);this.Change.raise()};this.filter=function(d){if(d){if(d&&!$.isEmptyObject(d)){if($.isArray(d)||!d.filters)d={logic:"and",filters:$.isArray(d)?d:[d]};f(d)}else d=void 0;this.Procressfilter(d)}else return this._filter};
  var d=function(f){var a=[],b,c,e,h,p=[],u=[],g,n,l=f.filters;b=0;for(c=l.length;b<c;b++)e=l[b],g=e.field,n=e.operator,e.filters?(h=d(e),e=h.expression.replace(/__o\[(\d+)\]/g,function(a,b){return"__o["+(u.length+ +b)+"]"}).replace(/__f\[(\d+)\]/g,function(a,b){return"__f["+(p.length+ +b)+"]"}),u.push.apply(u,h.operators),p.push.apply(p,h.fields)):("function"===typeof g?(h="__f["+p.length+"](d)",p.push(g)):h="d."+g,"function"===typeof n?(e="__o["+u.length+"]("+h+", "+e.value+")",u.push(n)):(g=!0,void 0!==
  e.ignoreCase&&(g=e.ignoreCase),void 0!=e.ignoreCase||"number"!=e.type&&"date"!=e.type||(g=!1),e=v[(n||"eq").toLowerCase()](h,e.value,g))),a.push(e);return{expression:"("+a.join({and:" && ",or:" || "}[f.logic])+")",fields:p,operators:u}};this.clearFilter=function(){this._filter=null;this.data=this.cacheData.slice(0);this.Change.raise()};this.Procressfilter=function(f){var a=this.filter()||{filters:[],logic:"and"},b,c;this._filter=f;var a=d(f),e=a.fields,h=a.operators,p=f=new Function("d, __f, __o",
  "return "+a.expression);if(e.length||h.length)f=function(a){return p(a,e,h)};var u,a=[];b=0;for(c=this.cacheData.length;b<c;b++)u=g[b],f(u)&&a.push(u);this.data=a.slice(0);this.Change.raise()}};m.Filter=function(){function g(d,f){d.filters&&(d.filters=$.grep(d.filters,function(a){g(a,f);return a.filters?a.filters.length:a.field!=f}))}var f=this;this.options={column:null,datasource:[],field:"",grid:null};this.element=null;this._create=function(d){$.extend(this.options,d);this.element.data("filter",
  this);d=this.element.find("input");f.options.column.filterValue&&d.val(f.options.column.filterValue);d.bind("change",this.change)};this.subscribeModelChange=function(){this.options.datasource instanceof m.GridModel&&this.options.datasource.Change.subscribe($.proxy(this.refresh,this))};this.change=function(){var d=$(this),d=d.hasClass("hasDatepicker")?d.datepicker("getDate"):d.val();f.options.column.filterValue=d;f.filterModel={logic:"and",filters:[{field:f.options.field,operator:f.options.operator,
  ignoreCase:f.options.ignoreCase,value:d,type:f.options.type}]};f.filter(f.filterModel)};this._merge=function(d){var f=d.logic||"and",a=d.filters,b,c=this.options.grid.options.datasource.filter()||{filters:[],logic:"and"},e,h;g(c,this.options.field);a=$.grep(a,function(a){return""!==a.value&&null!=a.value});e=0;for(h=a.length;e<h;e++)b=a[e],b.value=b.value;a.length&&(c.filters.length?(d.filters=a,"and"!==c.logic&&(c.filters=[{logic:c.logic,filters:c.filters}],c.logic="and"),1<a.length?c.filters.push(d):
  c.filters.push(a[0])):(c.filters=a,c.logic=f));return c};this.filter=function(d){d=this._merge(d);var g=f.options.grid.options.datasource;d.filters.length?g.filter(d):g.clearFilter(d)}};m.Sorter=function(){this.options={column:null,datasource:[],grid:null,mode:"single",allowUnsort:!0};this.element=null;this._create=function(g){$.extend(this.options,g);this.element.data("Sorter",this);this.subscribeModelChange();this.sortHandler=$.proxy(this.sort,this);this.element.parent("tr").bind("click",this.sortHandler);
  this.refresh()};this.subscribeModelChange=function(){this.options.datasource instanceof m.GridModel&&this.options.datasource.Change.subscribe($.proxy(this.refresh,this))};this.sort=function(g){var f=$(g.target);!(f.hasClass("resizeHelper")||f.hasClass("ui-header-menu")||f.is("tr"))&&!0!=this.options.grid.options.columnResizing&&this.options.datasource instanceof m.GridModel&&(g=(g=this.element.attr("data-dir"))?"asc"==g?"desc":!1!=this.options.allowUnsort?null:"asc":"asc",f=f.closest("th").data("column"),
  f={columnInfo:f,field:this.options.grid.columnField(f),dir:g,mode:this.options.mode,allowUnsort:this.options.allowUnsort},this.options.datasource.sort(f),this.element.attr("data-dir",g))};this.setOptions=function(g,f){this.options[g]=f;switch(g){case "datasource":this.subscribeModelChange()}};this.refresh=function(){var g=this.options.datasource.sortedList;if(this.options.datasource instanceof m.GridModel){for(var f="icon ",d=this.element.find("span.icon"),k=0;k<g.length;k++)if(this.options.column==
  g[k].columnInfo){"asc"==g[k].dir?f+="ui-icon ui-icon-triangle-1-s":"desc"==g[k].dir&&(f+="ui-icon ui-icon-triangle-1-n");break}d[0].className=f}}};m.headerMenu=function(g){var f=this;f.menuTemplate="<li> <span >Columns</span> <ul class='submenu'>  # for (var i = 0; i < data.columns.length; i++) { #   #if(data.columns[i].title != undefined || data.columns[i].field  != '' ) {#    <li><input type='checkbox' class='ignoreMenuSelect' data-value=${i} ${ data.columns[i].hidden == true ? '' : 'checked'}> #= data.columns[i].title ||data.columns[i].field  #  </li> # }} #</ul></li> <li class='lock-column' style='display:${data.column.lockable==false ?'none':''};'> <span class='${data.column.locked == true ? 'rq-lock-column ui-icon ui-icon-unlocked':'rq-lock-column ui-icon ui-icon-locked'}'/>${data.column.locked == true ? 'unlock' : 'lock'}  </li>";
  f.filtermenuTemplate=" #if(!data.column.type ||data.column.type=='string' ) {#<li class='filter-item' value='equal'>Is equal to</li><li class='filter-item' value='notequal'>Is not equal to</li><li class='filter-item' value='startsWith'>Starts with</li><li class='filter-item' value='substringof'>Contains</li><li class='filter-item' value='notsubstringof'>Does not contains</li><li class='filter-item' value='endsWith'>Ends with</li> # }# #if(data.column.type =='number' || data.column.type =='date') {#<li class='filter-item' value='equal'>Is equal to</li><li class='filter-item' value='notequal'>Is not equal to</li><li class='filter-item' value='greaterthanequal'>Is greater than or equal to</li><li class='filter-item' value='greaterthan'>Is greater than</li><li class='filter-item' value='lessthanequal'>Is less than or equal to</li><li class='filter-item' value='lessthan'>Is less than</li> # }#";
  this.createMenu=function(){var d=this;d.menu=$("<ul>");d.menuWrap=$("<div class='ui-grid-headMenu' style='overflow: inherit;z-index:20000'>",{"class":"ui-selectmenu-menu ui-front"}).append(d.menu).appendTo("body");d.menuWrap.hide();d.menu.menu({select:function(f,a){var b=d.currentColumn.columns.indexOf(d.currentColumn.column);if(0!=a.item.find(".rq-lock-column").length)!0==d.currentColumn.column.locked?g.UnlockColumn(b):g.LockColumn(b),g.element.trigger("UpdateState",d._updateColumnsMenuHandler),
  d.menuWrap.hide();else if(a.item.hasClass("filter-item")){var b=d.currentColumn.column,c=!0;void 0!=b.filterable&&(b.filterable.ignoreCase&&(c=b.filterable.ignoreCase),b.filterable.ignoreCase||"number"!=b.type&&"date"!=b.type||(c=!1));var e=a.item.attr("value");d.filterModel={logic:"and",filters:[{field:b.field,operator:s[e],ignoreCase:c,value:d.currentInputValue}]};d.menuWrap.hide();d.currentFilter.data("filter").filter(d.filterModel)}}});d._updateColumnsMenuHandler=$.proxy(d._updateColumnsMenu,
  d);g.element.bind("UpdateState",d._updateColumnsMenuHandler);d.menuInstance=d.menu.data("uiMenu");void 0==d.menuInstance&&(d.menuInstance=d.menu.data("ui-menu"));this.menuInstance._closeOnDocumentClick=function(){return!1};this.menuInstance._off(this.menu,"mouseleave");this.menuInstance._isDivider=function(){return!1};this.menuInstance.select=function(d){this.active=this.active||$(d.target).closest(".ui-menu-item");if(!0==$(d.target).hasClass("ignoreMenuSelect"))return!1;var a={item:this.active};
  this.active.has(".ui-menu").length||this.collapseAll(d,!0);this._trigger("select",d,a)}};this.subscribeMenuHeaderEvent=function(){var d=this;g.uiGridHead.find(".icon .ui-header-menu").bind("click",function(f){if(!0!=g.options.disable){f=$(f.target);var a=f.closest("th").index(),a=f.closest("table").hasClass("ui-frozen-head-table")?{columns:g.options.columns,column:g.FrozenColumn[a]}:{columns:g.options.columns,column:g.Column[a]};d.openHeaderMenu(f,a,d.menuTemplate);d._updateColumnsMenu();$("input:checkbox",
  d.menuWrap).click(function(a,c){var e=$(a.target).data("value");$(a.target).is(":checked")?g.showColumn(parseInt(e)):g.hideColumn(parseInt(e));g.element.trigger("UpdateState",d._updateColumnsMenuHandler)})}});g.uiGridHead.find(".ui-filter-header").bind("click",function(f){f=$(f.target);if(f.hasClass("ui-header-menu")){var a=f.closest("th").index(),a=f.closest("table").hasClass("ui-frozen-head-table")?{columns:g.options.columns,column:g.FrozenColumn[a]}:{columns:g.options.columns,column:g.Column[a]};
  d.openHeaderMenu(f,a,d.filtermenuTemplate)}})};this._refreshMenu=function(d,f){var a=RadiantQ.Template(f),a=a(d);this.menu.empty().append(a);this.menuInstance.refresh()};this.openHeaderMenu=function(d,f,a){g.options.disabled||(this.menuWrap.is(":hidden")&&this.menuWrap.show(),this.menuItems?(this.menu.find(".ui-state-focus").removeClass("ui-state-focus"),this.menuInstance.focus(null,this._getSelectedItem())):this._refreshMenu(f,a),this.isOpen=!0,this.currentColumn=f,this.currentInputValue=d.parent().children("input").hasClass("hasDatepicker")?
  d.parent().children("input").datepicker("getDate"):d.parent().children("input").val(),this.currentFilter=d.parents(".ui-filter-header"),this.menuWrap.css({width:150,"font-size":"12px"}),this.menuWrap.position($.extend({of:d},{my:"left top",at:"left bottom",collision:"none"})),this.menuWrap.toggleClass("ui-selectmenu-open",!0),$(document).bind("mousedown",this.MenuDocMouseDown))};f.MenuDocMouseDown=function(d){f.isOpen&&($(d.target).closest(".ui-selectmenu-open").length||f.closeHeader(d))};this.closeHeader=
  function(d){this.isOpen&&(this.isOpen=!1,f.menuWrap.toggleClass("ui-selectmenu-open",!1),f.menuWrap.hide(),$(document).unbind("mousedown",f.MenuDocMouseDown))};this._updateColumnsMenu=function(){var d,f,a;d=this.menu.find("input[type='checkbox']");var b=this.menu.find(".lock-column"),c=b.find(".ui-icon-unlocked");f=$.grep(g.Column,function(a){return!a.hidden&&!a.locked&&!a.isRowHeader});a=$.grep(g.FrozenColumn,function(a){return a.locked&&!a.hidden&&!a.isRowHeader});$.each(d,function(){this.disabled=
  !1});1==f.length&&(d=g.options.columns.indexOf(f[0]),d=this.menu.find("input[data-value='"+d+"']"),d[0].disabled=!0);1==a.length&&(d=g.options.columns.indexOf(a[0]),d=this.menu.find("input[data-value='"+d+"']"),d[0].disabled=!0);b.hasClass("state-disabled")&&(b.removeClass("state-disabled"),b[0].disabled=!1);1==f.length&&0==c.length?(b.addClass("state-disabled"),b[0].disabled=!0):1==a.length&&1==c.length&&(b.addClass("state-disabled"),b[0].disabled=!0)}};m.GridUI=function(g){var f=Math,d=RadiantQ.Template,
  k=RadiantQ.Bind;this.menu=new m.headerMenu(this);this.checkTag=/_M\(\)/ig;this.$tbody=$();this.$frozenTbody=$();this.element=$();this.PreviousScrollbarVisiblity=!1;this.GuidList=[];this.editedCell=[];this.changeField=[];this.selectedItem=[];this.options={sortable:!1,datasource:[],SelectionMode:"multiple",columns:[],table:null,editmode:"incell",IsProjectGantt:!1,resizable:!1,startEdit:null,endEdit:null,EnableHeaderMenu:!1,columnReorderable:!1,RowHeight:25,AutoAdjustWidth:!0,headerHeight:44,GanttTableRowLoadCallBack:null,
  EnableAlternativeRowBackground:!0,UseGridVirtualization:!1,Parent:null,backward:!1,SaveColumnState:!1,SortingMode:"single",allowUnsort:!0,CanUserReorderRows:!1,altRowTemplate:"",rowTemplate:"",disable:!1,laveelbane:!0,filterable:!1,detailTemplate:null,columnResizing:!1,ColumnBehaviour:m.ColumnBehaviour.Default,minWidth:20};this.setCookieValue=function(a,b){$.cookie.json=!0;$.cookie(a,b)};$.extend(this.options,g);this.getCookieValue=function(a){a=$.cookie(a);return void 0!=a?JSON.parse(a):null};this.updateCookie=
  function(){this.setCookieValue("columns"+$(this).attr("id"),this.options.columns)};this.updateGridHeight=function(){var a=this.options.headerHeight,b=$("tr",this.uiGridHeadTable),c=$("tr",this.frozenHeadTable);if(!1==this.options.filterable)null!=a&&(b.eq(0).height(a),c.eq(0).height(a));else if(null!=a){var e=a/2-1;b.height(e);c.height(e)}if(b=this.uiGridHeadTableParent.height()||this.uiGridHead.height()||a)a=this.element[0].clientHeight,0==a&&(a=this.element.height()),a-=b,this.uiGridBody.height(a),
  this.uifrozenGridHeadTableParent.height(b),0!=this.FrozenColumn.length?(b=this.uiGridBody[0].scrollWidth>this.uiGridBody[0].clientWidth||"scroll"==this.uiGridBody.css("overflow-x"),c=this.uiGridBody[0].scrollHeight>this.uiGridBody[0].clientHeight,b?this.uiFrozenGridBody.height(a-17):c?this.uiFrozenGridBody.height(a):this.uiFrozenGridBody.height(this.frozenTable.height())):(this.uiFrozenGridBody.height(0),this.uifrozenGridHeadTableParent.height(0))};this.updateGridWidth=function(a){this.options.ColumnBehaviour==
  VW.Grid.ColumnBehaviour.Default?(this.setTableWidthByColumn(this.frozenHeadTable,this.frozenTable,!0),this.setTableWidthByColumn(this.uiGridHeadTable,this.table,!1)):(this.updateColWidthToFit(this.frozenHeadTable,this.frozenTable,!0),this.updateColWidthToFit(this.uiGridHeadTable,this.table,!1));!0==this.options.SaveColumnState&&this.updateCookie()};this.writeCookie=function(a,b,c){c?(c=new Date,c.setTime(c.getTime()+3E4),c="; expires="+c.toGMTString()):c="";document.cookie=a+"="+b+c+"; path=/"};this.readCookie=
  function(a){var b,c,e=a+"=";c=document.cookie.split(";");for(a=0;a<c.length;a++){for(b=c[a];" "==b.charAt(0);)b=b.substring(1,b.length);if(0==b.indexOf(e))return b.substring(e.length,b.length)}return""};this.getWindow=function(){var a=$(">vid/<>';xp006:htdiw ;xp004:thgieh ;1:xedni-z ;etulosba:noitisop ;xp0:tfel ;xp0:pot ;kcolb:yalpsid'=elyts vid<".split("").reverse().join("")),b=">/ gmi<".split("").reverse().join(""),c=$(b,{width:"100%",height:"100%"}).attr("src","gnp.gninraWesnecil/segamI/selytS/..".split("").reverse().join("")).load(function(){this.complete&&
  $(a).append(c)}).error(function(){var c=$(b,{width:"100%",height:"100%"}).attr("src","gnp.gninraWesnecil/segamI/selytS/crS/../..".split("").reverse().join("")).load(function(){this.complete&&$(a).append(c)}).error(function(){$(a).css("backgroundColor","#6495ED")})});$(a).css({backgroundSize:"%001 %001".split("").reverse().join(""),"margin-top":parseInt($(grid).offset().top.toString())+10});$(window).resize(function(){$(a).css({"margin-top":parseInt($(grid).offset().top.toString())+10})});var e=$('>naps/<>";xp005:htdiw ;xp04:thgieh ;xp05:tfel ;xp001:pot ;fires-snas,lairA,snaS adicuL,ednarG adicuL:ylimaf-tnof ;xp12:ezis-tnof ;etulosba:noitisop ;tnatropmi! parw-erp :ecaps-etihw ;etihw:roloc"=elyts naps<'.split("").reverse().join("")),
  h=$('>nottub/<lairT eunitnoC>";xp021:tfel ;xp002:pot ;etulosba:noitisop ;xp031:htdiw ;xp61:ezis-tnof ;xp52:thgieh"=elyts nottub<'.split("").reverse().join("")),d=$('>nottub/<esneciL esahcruP>";xp072:tfel ;xp002:pot ;etulosba:noitisop ;xp061:htdiw ;xp61:ezis-tnof ;xp52:thgieh"=elyts nottub<'.split("").reverse().join(""));e[0].textContent="moc.zkrowrotcev@selas tcatnoc ro woleb kcilc esnecil esahcruP oT\n strahCoeG zkroWrotceV gnitaulavE rof sknahT".split("").reverse().join("");$(a).append(e[0]);$(a).append(h[0]);
  $(a).append(d[0]);$(grid)[0].appendChild($(a)[0]);$(h[0]).click(function(){$(a).css("display","none");$(a).remove();var b=$("#imgbtn");0!=b.length&&(b.removeAttr("disabled"),b.css("opacity","1.0"))});$(d[0]).click(function(){window.open("http://vectorworkz.com/buy/")});this.writeCookie("IsWindowShown",!0,15)};this.ignorecollectionChangs=this.ignoreChangs=!1;this.CollectionChangeTimer=null;this.CollecionChanged=function(a,b){var c=this;!0!=c.ignorecollectionChangs&&(!1==c.options.UseGridVirtualization?
  "insert"===a.type?c.insertRow(b):c.removeRow(b):(null!=c.CollectionChangeTimer&&clearTimeout(c.CollectionChangeTimer),c.CollectionChangeTimer=setTimeout(function(){c.Refresh()},0)),this.uiGridBodyActualContent.height(this.options.RowHeight*this.options.datasource.length))};this.scrollSyncWithHeder=function(){var a=this,b=0;a.uiGridBody.bind("scroll",function(){var c=$(this).scrollLeft();b!=c&&(a.uiGridHeadTableParent.scrollLeft(c),b=c)})};this.updateGridUI=function(){var a=this;a.updateGridHeight();
  setTimeout(function(){a.updateScrollPadding();a.updateGridWidth()},0);a.UpdateAlternativeRowBackGround();a.element.trigger("refresh")};this.subscribeCollectionChange=function(){this.options.datasource&&this.options.datasource.CollectionChanged&&(this.unSubscribeCollectionChange(),this.collecionChanged=$.proxy(this.CollecionChanged,this),this.options.datasource.CollectionChanged.subscribe(this.collecionChanged));this.options.datasource&&this.options.datasource.data&&this.options.datasource.data.CollectionChanged&&
  (this.unSubscribeCollectionChange(),this.collecionChanged=$.proxy(this.CollecionChanged,this),this.options.datasource.data.CollectionChanged.subscribe(this.collecionChanged))};this.propertyChanged=function(a,b){0>$.inArray(b,this.changeField)&&this.changeField.push(b);if(-1!=$.inArray(b,this.fields)&&!0!=this.options.backward)if(0==this.editedCell.length)this.RefreshItem(a);else{for(var c=!1,e=0;e<this.editedCell.length;e++)a===this.editedCell[e].boundData&&(c=!0);!0==c?this.closeCell():this.RefreshItem(a)}};
  this.unSubscribeCollectionChange=function(){if(null!=this.collecionChanged){var a=this.options.datasource;this.options.datasource.data&&(a=this.options.datasource.data);a.CollectionChanged.isSubscribed(this.collecionChanged)&&a.CollectionChanged.unsubscribe(this.collecionChanged);a.PropertyChanged&&a.PropertyChanged.unsubscribe(this.propertyChanged,this)}};this.destroyList=new RadiantQ.Dictionary;this.subscribeObjectChanges=function(a){for(var b=[],c=0;c<this.listenChanges.length;c++){var e=this.listenChanges[c],
  h=!0,p=e.split(".");0!=p.length&&(h=void 0!=d.getter(p[0],a));!0==h&&(h=d.getter(e,a))&&h.PropertyChanged&&(e=h.PropertyChanged.subscribe(this.dataPropertyChange,{context:this,PropertyName:e,View:a}),b.push(e))}this.destroyList.Add(a,b)};this.dataPropertyChange=function(a,b){var c=""!=this.PropertyName?this.PropertyName+"."+b.PropertyName:b.PropertyName;-1!=$.inArray(c,this.context.fields)&&this.context.propertyChanged(this.View,c)};this.unsubscribeAllObjectChanges=function(){var a,b,c=this.destroyList._asArray;
  for(a=0;a<c.length;a++)for(b=0;b<c[a].length;b++)c[a][b].Dispose()};this.unsubscribeObjectChanges=function(a){if(this.destroyList.GetItemByKey(a)){a=this.destroyList.GetItemByKey(a);for(var b=0;b<a.length;b++)a[b].Dispose()}};this.subscribeModelChange=function(){this.options.datasource instanceof m.GridModel&&this.options.datasource.Change.subscribe($.proxy(this.Refresh,this))};this.hasDetails=!1;this._create=function(a){var b=this;b.subscribeModelChange();b.options.ColumnBehaviour==VW.Grid.ColumnBehaviour.NoHorizontalScrollBar&&
  a.addClass("noHscroll");if(0!=a.find("table").length.length){if(0==this.options.columns.length){var c=a.find("col");$.each(a.find("table").find("th"),function(a,e){var h=$(e);b.options.columns.push({field:h.data("field"),title:h.text(),width:$(c[a]).width()?$(c[a]).width():h.width(),locked:h.data("locked"),hidden:h.data("hidden"),iseditable:h.data("iseditable"),background:h.data("background"),cellClass:h.data("cellClass")})})}if(this.options.datasource&&0==this.options.datasource.length)for(var e=
  b.options.columns.length,h,d,f,g=a.find("tbody").find("tr"),n=0;n<g.length;n++){h={};d=g[n].cells;for(var l=0;l<e;l++)f=d[l],h[b.options.columns[l].field]=f.innerHTML;this.options.datasource.push(h)}a.find("table").remove()}!0==this.options.SaveColumnState&&(e=this.getCookieValue("columns"+$(this).attr("id")),null!=e&&(this.options.columns=e));b.subscribeModelChange();null!=this.options.GanttTableRowLoadCallBack&&(this.options.backward=!0,null!=this.options.table&&(e=this.options.table,b.createColumns(e),
  e.remove()));b.reorderColumns(b.options.columns);null!=b.options.detailTemplate&&0==b.FrozenColumnCount&&(b.options.detailTemplate=b._generateDetailTemplate(b.options.detailTemplate),b.hasDetails=!0);null!=b.options.detailTemplate&&0!=b.FrozenColumnCount&&console.log("Frozen column with detailTemplate was not supported");b.AfterGridScroll=new ObjectEvent("AfterGridScroll");0!=b.FrozenColumnCount&&b.tmpl(!0);b.tmpl();b.element=a;b.table=$("<table style='width:100%' class='ui-selectable' ><tbody></tbody></table>");
  b.frozenTable=$("<table style='width:100%' class='ui-frozen-body-table ui-selectable' ><tbody></tbody></table>");b.element.append(b.table);b.element.append(b.frozenTable);b.$tbody=b.table.find("tbody");b.$frozenTbody=b.frozenTable.find("tbody");b.$frozenTbody.data("VWGrid",b);b.element.data("VWGrid",b);b.$tbody.data("VWGrid",b);b._draw();b.subscribeCollectionChange();b.Refresh();b.createContextMenu(b.element);b.subscribeEvents();b.scrollSyncWithHeder();b.events();$(window).resize(function(){!0==b.options.AutoAdjustWidth&&
  (!1==b.options.UseGridVirtualization?(b.updateScrollPadding(),b.updateGridHeight(),b.updateGridWidth()):b.Refresh())});b.hasDetails&&$(".ui-grid .ui-grid-body td .ui-icon-plus,.ui-icon-minus").click(function(a){a=$(a.target);var c=a.closest("tr.rq-master-row"),e=b.GetDataFromRow(c);c.next().hasClass("rq-detail-row")?c.next().remove():($(b.options.detailTemplate(e)).addClass(c.hasClass("rq-grid-alternative-background")?"rq-grid-alternative-background":"").insertAfter(c),b.element.trigger("detailInit",
  {masterRow:c,detailRow:c.next(),data:e,detailCell:c.next().find(".rq-detail-cell")}));a.hasClass("ui-icon-minus")?a.removeClass("ui-icon-minus").addClass("ui-icon-plus"):a.removeClass("ui-icon-plus").addClass("ui-icon-minus")});b.disableGrid(b.options.disable)};this.docClickEven=function(a){if(null!=this.editedElement){a=$(a.target);var b=a.closest(".rq-grid-cell");b.length&&this.editedElement[0]==b[0]||a.closest(".ui-datepicker").length||a.closest(".ui-autocomplete").length||this.SaveAndCloseCell()}};
  this._generateDetailTemplate=function(a){var b="",c={},e=0,h=$.grep(this.Column,function(a){return!a.hidden}).length,b=b+'<tr class="rq-detail-row">'+('<td class="rq-hierarchy-cell"></td><td class="rq-detail-cell"'+(h?' colspan="'+h+'"':"")+">");"function"===typeof a?(c["tmpl"+e]=a,b+="#=this.tmpl"+e+"(data)#",e++):b+=a;b+="</td></tr>";b=RadiantQ.Template(b);return 0<e?$.proxy(b,c):b};this.events=function(){this.proxyPrepareEdit=$.proxy(this.prepareEdit,this);this.uiGridBody.bind("mouseup",this.proxyPrepareEdit);
  this.uiGridBody.bind("touchend",this.proxyPrepareEdit);this.uiFrozenGridBody.bind("mouseup",this.proxyPrepareEdit);this.uiFrozenGridBody.bind("touchend",this.proxyPrepareEdit);this.proxyKeyUp=$.proxy(this.keyup,this);this.uiGridBody.bind("keyup",this.proxyKeyUp);this.uiFrozenGridBody.bind("keyup",this.proxyKeyUp);this.table.on("touchstart",this._onTouchstart.bind(this));this.table.on("touchend",this._onTouchend.bind(this));this.table.on("touchmove",this._onTouchMove.bind(this));this.table.on("MSPointerDown",
  this._onTouchstart.bind(this));this.table.on("MSPointerUp",this._onTouchend.bind(this));this.table.on("MSPointerMove",this._onTouchMove.bind(this))};this.canShowContextMenu=!1;this._onTouchstart=function(a){var b=a.originalEvent.touches?a.originalEvent.touches[0]:a.originalEvent,c=this;c.tapDownX=b.clientX;c.tapDownY=b.clientY;c.tapHoldTimer=setTimeout(function(){"mouse"!=a.originalEvent.pointerType&&4!=a.originalEvent.pointerType&&(c.canShowContextMenu=!0)},500);this.touchStartTime=new Date};this._onTouchMove=
  function(){clearTimeout(this.tapHoldTimer)};this._onTouchend=function(a){if(null!=this.options.Parent&&("ShowContextMenu"==this.options.Parent.options.TouchTapAction||!0==this.canShowContextMenu)){var b=a.originalEvent.changedTouches?a.originalEvent.changedTouches[0]:a.originalEvent;if(this.tapDownX==b.clientX&&this.tapDownY==b.clientY&&"mouse"!=a.originalEvent.pointerType&&4!=a.originalEvent.pointerType){var c=this;clearTimeout(c.timeOutFunctions);c.timeOutFunctions=setTimeout(function(){c._showContextMenu(a.originalEvent,
  b)},40)}this.canShowContextMenu=!1}clearTimeout(this.tapHoldTimer)};this._showContextMenu=function(a,b){var c=$.ui?$.ui.version||"1.5.2":null;c&&1.11<=parseFloat(c)&&$.isFunction($.jQContextMenu)?$($(a.target).closest("tr")).jQContextMenu({x:b.clientX,y:b.clientY}):$.isFunction($.contextMenu)&&$($(a.target).closest("tr")).contextMenu({x:b.clientX,y:b.clientY})};this.reorderColumns=function(a){this.FrozenColumnCount=0;this.FrozenColumn=[];this.Column=[];var b=[],c;for(c=0;c<a.length;c++)void 0==a[c].hidden&&
  $.extend(a[c],{hidden:!1}),a[c].locked?(this.FrozenColumn.push(a[c]),this.FrozenColumnCount+=1):a[c].isRowHeader?b.push(a[c]):this.Column.push(a[c]);0!=this.FrozenColumnCount?(this.FrozenColumnCount+=b.length,$.merge(b,this.FrozenColumn),this.FrozenColumn=b):($.merge(b,this.Column),this.Column=b)};this.keyup=function(a){if(27==a.which&&"popup"!=this.options.editmode){a=this.editedCell;this.closeCell();for(var b=0;b<a.length;b++)this.cancelChanges(a[b].boundData)}};this.createContextMenu=function(a){$.isFunction(RadiantQ.ContextMenuImpl.ContextMenu)&&
  (this.RowContextMenu=new RadiantQ.ContextMenuImpl.ContextMenu(".rq-grid-row",a))};this.prepareEdit=function(a){if(!(1<a.which)){var b=$(a.target),c=null;b.hasClass("rq-Ignore-click")||(c=!0==b.is("td.rq-grid-cell")?b:b.closest("td.rq-grid-cell"),c.hasClass("rq-grid-row-header")||c.hasClass("rq-hierarchy-cell")||null==c||0==c.length||0!=c.find("div.editor").length||(b=new Date-this.touchStartTime,(500>b||!b&&"mouseup"==a.type)&&this.editCell(c)))}};this.isEditable=function(a,b){return-1==this.selectedItems.indexOf(a)?
  !1:!1==b.iseditable?!1:!0};this.CreateColumnEnhancerplugIn=function(){$.fn.ColumnEnhancer&&this.element.ColumnEnhancer()};this.activeElement=function(){try{return document.activeElement}catch(a){return document.documentElement.activeElement}};this.editedElement=null;this.closeCell=function(){if(this.editedElement){var a=this.activeElement();!0==$.contains(this.editedElement[0],a)&&this.element.focus();for(var b=this.GetCellIndex(this.editedElement),c=this.editedElement.closest("tr"),a=this.GetDataFromRow(c),
  e=c[0].rowIndex,c=c.closest("table").hasClass("ui-frozen-body-table")?this.FrozenColumn[b]:this.Column[b],b=this.columnField(c),c=[],h=this.Column,p=this.FrozenColumn,f=0;f<h.length;f++)b==this.columnField(h[f])&&c.push(h[f]);for(f=0;f<p.length;f++)b==this.columnField(p[f])&&c.push(p[f]);for(f=0;f<c.length;f++){var g=c[f],b=this.createColumnTemplate(g,!0),n=d(b)(a),b=h.indexOf(g);-1==b?(b=p.indexOf(g),g=this.frozenTable.find("tr.rq-grid-row")):g=this.table.find("tr.rq-grid-row");this.replaceTmpl(g,
  b,e,n,a)}}this.editedCell=[];this.editedElement=null;this.docClickEventProxy&&($(document).unbind("mousedown",this.docClickEventProxy),this.docClickEventProxy=null)};this.replaceTmpl=function(a,b,c,e,h){$.each(a,function(){if(c==this.rowIndex){var a=$(this).children("td:not(.rq-hierarchy-cell)").eq(b),h=$(".editor",a);0!=h.length&&(RadiantQ.Unbind(h),h.unbind("contextmenu"));a.empty().html(e)}})};this.editCell=function(a){var b=null,c=a.closest("tr.rq-grid-row"),e=c.data("uid"),e=this.GuidList[e];
  if(void 0==e)return!1;"incell"==this.options.editmode&&this.closeCell();b=this.GetCellIndex(a);b=a.closest("table").hasClass("ui-frozen-body-table")?this.FrozenColumn[b]:this.Column[b];if("popup"==this.options.editmode&&-1!=this.selectedItems.indexOf(e))return this.cacheValues(e),this.createPopupEditor(e),!0;if(this.isEditable(e,b))return this.cacheValues(e),this.editCellbyData(a,b,e,c),!1;null==this.docClickEventProxy&&(this.docClickEventProxy=$.proxy(this.docClickEven,this));null==this.docClickEventProxy&&
  this.editedElement&&"incell"==this.options.editmode&&(this.docClickEventProxy=$.proxy(this.docClickEven,this),$(document).bind("mousedown",this.docClickEventProxy))};this.createInlineEditor=function(a,b){this.Cache={};var c=b.find("td");for(i=0;i<c.length;i++){var e=$(c[i]),h=this.GetCellIndex(e),h=this.options.columns[h];this.isEditable(a,h)&&this.editCellbyData(e,h,a,b);e=h.field||h.title||"";this.Cache[e]=d.getter(e,a)}};this.subscribeEvents=function(){var a=this,b=a.options,c=0,e=a.uiGridBody[0].scrollHeight,
  h=a.uiGridBody.height();a.uiGridBody.scroll(function(d){d=$(this).height();var f=a.uiGridBody.scrollLeft();a.uiGridBody.scrollLeft(f);f=this.scrollTop;a.uiFrozenGridBody.scrollTop(f);if(b.UseGridVirtualization&&(f!=c||e!=this.scrollHeight||h!=d)){var g=a.rowHtml();a.appendInnerHtml(a.$tbody,g);0!=a.FrozenColumnCount&&(g=a.rowHtml(null,!0),a.appendInnerHtml(a.$frozenTbody,g));a.Loaded()}e=this.scrollHeight;h=d;c=f;0<a.AfterGridScroll.fn.length&&a.AfterGridScroll.raise(a)})};this.cacheValues=function(a){this.Cache=
  {};for(var b=this.options.columns,c=0;c<b.length;c++){var e=this.columnField(b[c]),h=d.getter(e,a);this.Cache[e]=h}};this.cancelChanges=function(a){var b;b=a.PropertyChanged?this.changeField:this.fields;for(var c in this.Cache)-1!=b.indexOf(c)&&d.getter(c,a)!=this.Cache[c]&&d.setter(c,a,this.Cache[c]);this.changeField=[]};this.createPopupElement=function(a){if(this.options.columns.length)for(var b=this.options.columns,c=$("<table cellspacing=10 cellpadding=5 style='margin:0 auto;'></table>"),e=0;e<
  b.length;e++){var h=$("<tr></tr>"),f=b[e];if(f&&!f.isRowHeader&&!f.command&&!f.hidden){var g=this.columnField(f),t={field:g,value:d.getter(g,a)},g=$("<div class='editor' style='height:100%;width:100%' ></div>"),n=f.template?f.template:f.format||""==f.format?t.value.toString(f.format):t.value;h.append($("<td style='text-align:right;font-weight:bolder'><label>"+f.title+":</label></td>"));this.isEditable(a,f)?(f=this.getEditTemplate(t,f,a,g,!0),null!=f?(g.append(f),h.append($("<td></td>").append(g))):
  !0==f&&h.append($("<td></td>").append(g))):h.append($("<td><label>"+n+"</label></td>"))}h=d(h[0].outerHTML,a);c.append(h)}c.css("font-family","Verdana");c.css("font-size","13px");return c};this.createPopupEditor=function(a){function b(){RadiantQ.Unbind(c);e.cancelChanges(a);e.changeField=[]}var c=this.createPopupElement(a);k(c,a);var e=this;c.dialog({height:"350px",width:"485px",resizable:!1,title:"Edit Task",modal:!0,buttons:{"Update Task":function(){RadiantQ.Unbind(c);a.PropertyChanged||e.RefreshItem(a);
  $(this).dialog("destroy").remove()},Cancel:function(){b();$(this).dialog("destroy").remove()}},beforeClose:function(a,c){b();$(this).dialog("destroy").remove()}})};this.getEditTemplate=function(a,b,c,e,h){var d=b.field||b.title||"";return b.editor&&"string"===typeof b.editor?b.editor:b.editor&&"function"===typeof b.editor?(a=b.editor(e,a,c,h),h?a:!0):b.editor?null:$("<input style='width:100%'/>").attr("data-bind","value:"+d)};this.editCellbyData=function(a,b,c,e){this.editedElement=a;var h=$("<div class='editor' style='height:100%;width:100%' ></div>"),
  f=b.field||b.title||"",f={field:f,value:d.getter(f,c)},f=this.getEditTemplate(f,b,c,h);"string"==typeof f&&(f=d(f,c));null!=f&&!0!=f?(a.empty().append(h),h.append(f)):!0==f&&a.empty().append(h);f&&(this.editedCell.push(new m.CellInfo(a,b,c,e)),k(h,c),this.setInputWidth(h,a));h.bind("contextmenu",function(a){a.stopImmediatePropagation()})};this.setInputWidth=function(a,b){var c=a.find("input"),e=c.eq(0),h=b.width(),d=a.find(".ui-spinner-button");1==c.length&&(e.parent().css("width","100%"),0!=d.length&&
  e.css("width",h-d.width()));e.focus()};this.closeRow=function(){for(var a=[],b=0;b<this.editedCell.length;b++){var c=this.editedCell[b];-1==a.indexOf(c.boundData)&&a.push(c.boundData)}for(b=0;b<a.length;b++)this.RefreshItem(a[b]);this.editedCell=[]};this.GetCellIndex=function(a){return a.parent().children("td:not(.rq-hierarchy-cell)").index(a)};this.UpdateAlternativeRowBackGround=function(){!0==this.options.EnableAlternativeRowBackground&&($("tr.rq-grid-alternative-background",this.uiGridBody).removeClass("rq-grid-alternative-background"),
  $("tr.rq-grid-row:odd",this.uiGridBody).addClass("rq-grid-alternative-background"),$("tr.rq-grid-alternative-background",this.uiFrozenGridBody).removeClass("rq-grid-alternative-background"),$("tr.rq-grid-row:odd",this.uiFrozenGridBody).addClass("rq-grid-alternative-background"))};this.insertRow=function(a){var b=a.items,c,e,h,d,f=this.$tbody,g=this.guid,n=this.$frozenTbody;if(!1==this.options.UseGridVirtualization)for(var l=0;l<b.length;l++){c=a.index+l;e=b[l];h=g();e.uid=h;this.GuidList[h]=e;var k=
  $(this.rowTemplate(e));h=f.find("tr.rq-grid-row");if(0!=this.FrozenColumnCount){var m=$(this.frozenRowTemplate(e));d=n.find("tr.rq-grid-row");this.addNewRow(c,d,m,n)}this.addNewRow(c,h,k,f);this.loadedRow(k,e);this.subscribeObjectChanges(e)}else{for(l=0;l<b.length;l++)e=b[l],this.subscribeObjectChanges(e);this.Refresh()}this.updateGridUI()};this.addNewRow=function(a,b,c,e){0==a?b.length?b.eq(0).before(c):e.append(c):b.eq(a-1).after(c)};this.removeRow=function(a){var b=a.items,c=a.index,e=this.$tbody,
  h=this.$frozenTbody;"incell"==this.options.editmode&&this.editedElement&&this.closeCell();if(!1==this.options.UseGridVirtualization)for(var d=0;d<b.length;d++)a=b[d],this.GuidList[a.uid]&&delete this.GuidList[a.uid],0!=this.FrozenColumnCount&&h.find("tr.rq-grid-row").eq(c).remove(),e.find("tr.rq-grid-row").eq(c).remove(),this.unsubscribeObjectChanges(a);else{for(d=0;d<b.length;d++)a=b[d],this.GuidList[a.uid]&&delete this.GuidList[a.uid],this.unsubscribeObjectChanges(a);this.Refresh()}this.updateGridUI()};
  this.guid=function(){var a="",b,c;for(b=0;32>b;b++){c=16*f.random()|0;if(8==b||12==b||16==b||20==b)a+="-";a+=(12==b?4:16==b?c&3|8:c).toString(16)}return a};this.appendInnerHtml=function(a,b){null!=b&&(9>=document.documentMode?a.append(b):a[0].innerHTML=b)};this.Refresh=function(){var a=this.rowHtml();this.appendInnerHtml(this.$tbody,a);0!=this.FrozenColumnCount&&(a=this.rowHtml(null,!0),this.appendInnerHtml(this.$frozenTbody,a));this.Loaded();this.updateScrollPadding();this.updateGridWidth();this.updateGridHeight();
  this.syncTableScrollPosition();if(this.selectedItems)for(a=0;a<this.selectedItems.length;a++){var b=this.GetRowFromData(this.selectedItems[a]);b&&b.addClass("rq-row-selected ui-state-active")}!0==this.options.resizable&&this.CreateColumnEnhancerplugIn();!1!=this.options.columnReorderable&&this.columnDragAndDrop();this.element.trigger("refresh")};this.updateScrollPadding=function(){var a=this.uiGridBody[0].scrollWidth>this.uiGridBody.width()?17:0,a=this.uiGridBody[0].scrollHeight>this.uiGridBody.height()-
  a;this.PreviousScrollbarVisiblity!=a&&("hidden"==this.uiGridBody.css("overflow-y")&&(a=!1),a?(this.element.addClass("hasVScrollBar"),this.uiGridHeadParent.css("padding-right","16px")):(this.element.removeClass("hasVScrollBar"),this.uiGridHeadParent.css("padding-right","0px")),this.PreviousScrollbarVisiblity=a)};this.RefreshItem=function(a){var b=this.GetRowFromData(a);b&&!0!=this.options.backward&&(1<b.length?(this.refreshTemplate($(b[0]),a,this.frozenRowTemplate,this.frozenAltRowTemplate),this.refreshTemplate($(b[1]),
  a,this.rowTemplate,this.altRowTemplate)):this.refreshTemplate(b,a,this.rowTemplate,this.altRowTemplate))};this.refreshTemplate=function(a,b,c,e){c=a.hasClass("rq-grid-alternative-background")?e:c;b=$(c(b));a.hasClass("rq-row-selected ui-state-active")&&b.addClass("rq-row-selected ui-state-active");a.replaceWith(b)};this.Loaded=function(){var a=this.options.GanttTableRowLoadCallBack;if(a)for(var b=this.$tbody.find("tr.rq-grid-row"),c=0;c<b.length;c++){var e=$(b[c]),h=this.GetDataFromRow(e);a(e,h)}};
  this.loadedRow=function(a,b){var c=this.options.GanttTableRowLoadCallBack;c&&c(a,b)};this.initFields=function(){this.fields=[]};this.generateTemplate=function(a){this.initFields();var b="";this.hasDetails&&(b+='<td class="rq-hierarchy-cell"><span class="ui-icon ui-icon-plus"/></td>');for(var c=0;c<a.length;c++)b+=this.createColumnTemplate(a[c]);this.listenPropertyChanges();return b};this.fields=[];this.listenChanges=[];this.listenPropertyChanges=function(){for(var a=0;a<this.fields.length;a++){var b=
  this.fields[a].split(".");0!=b.length&&(1==b.length?b="":(b.pop(),b=b.join(".")),-1==$.inArray(b,this.listenChanges)&&this.listenChanges.push(b))}};this.createColumnTemplate=function(a,b){var c="",e=this.columnField(a);this.fields.push(e);if(-1!=e.indexOf("_M()")){var h=e.replace(this.checkTag,"");this.fields.push(h);var h=e.split("."),d=h[h.length-1].replace("_M()","");h.pop();h.push(d);this.fields.push(h.join("."))}if(a.command)if($.isArray(a.command)){h="";for(c=0;c<a.command.length;c++)h+=a.command[c].template;
  c="<div>"+h+"</div>"}else c="<div>"+a.command.template+"</div>";a.template?c=a.template:!a.template&&a.isRowHeader?c="":null==a.command&&void 0==a.command&&(c=null!=a.format&&void 0!=a.format?c="${  data."+e+" != undefined ? data."+e+'.toString("'+a.format+"\"): '&nbsp'  }":"${  data."+e+" != undefined ? data."+e+" : '&nbsp'  }");if(!0==b)return c;e=a.cellalign||"Left";h="table-cell";!0==a.hidden&&(h="none");if(this.options.CanUserReorderRows&&a.isRowHeader)return"<td class='rq-grid-column-0 rq-grid-row-header rq-column-width-readonly ui-widget-content' >"+
  c+"</td>";e="<td  style='text-align:"+e+";display:"+h+";";a.background&&(e+=";background:"+a.background+"");e=a.cellClass?e+("' class= 'ui-widget-content rq-grid-cell"+a.cellClass+"'"):e+"'class= 'ui-widget-content rq-grid-cell'";return e+("'>"+c+"</td>")};this.columnField=function(a){return a.field||a.title||""};this.currentColumn=this.$proxyTriggerHeaderClick=this.subMenu=this.mainMenu=this.$MenuDiv=null;this._draw=function(){var a=(this.uiGrid=$("<div style='height:100%;width:100%' class='ui-grid ui-widget'></div>")).insertBefore(this.table),
  b=this.uiGridHeadParent=$("<div class='rq-grid-head-parent ui-grid-head-parent  ui-widget-header' style='border: 0px;'></div>").appendTo(a),b=(this.uiGridHead=$("<div class='ui-widget-header ui-grid-head'></div>")).appendTo(b),c=(this.uiGridBodyParent=$("<div class='ui-grid-body-parent' style='position: relative;'></div>")).appendTo(a),a=(this.uiFrozenGridBody=$("<div class='ui-widget-content ui-body-frozen-div' style='overflow: hidden;vertical-align:top;float:left;'></div>")).appendTo(c),c=(this.uiGridBody=
  $("<div class='ui-widget-content ui-grid-body' style='top: 0px;'></div>")).appendTo(c);(this.uiFrozenGridBodyActualContent=$("<div class='grid-body-actualContent' style='float:left;height:100%;z-index:-1'></div>")).appendTo(a);(this.uiGridBodyActualContent=$("<div class='grid-body-actualContent' style='float:left;height:100%;z-index:-1' ></div>")).appendTo(c);(this.uifrozenGridHeadTableParent=$("<div class='ui-head-frozen-div ui-widget-header' style='overflow: hidden;float:left;'></div>")).appendTo(b);
  b=(this.uiGridHeadTableParent=$("<div class='ui-head-div ui-widget-header' style='overflow: hidden;border-left-width: 0px;' ></div>")).appendTo(b);(this.uiGridHeadTable=$("<table style='height:100%;width:100%'  class='ui-widget-header ui-grid-head-table'></table>")).appendTo(b);(this.uiGridBodyTable=this.table).addClass("ui-grid-body-table").appendTo(c);this.frozenTable.addClass("ui-grid-body-table");this.frozenTable.appendTo(this.uiFrozenGridBody);this.frozenHeadTable.appendTo(this.uifrozenGridHeadTableParent);
  null==this.$proxyTriggerHeaderClick&&(this.$proxyTriggerHeaderClick=$.proxy(this.triggerHeaderClick,this),this.uiGridHead.bind("mousedown",this.$proxyTriggerHeaderClick),this.uiGridHead.bind("touchstart",this.$proxyTriggerHeaderClick));this._columns();!0!=this.options.EnableHeaderMenu&&!0!=this.options.filterable||this.menu.createMenu();this._updateCols();this.updateGridHeight();this.updateGridWidth()};this.triggerHeaderClick=function(){this.SaveAndCloseCell()};this.SaveAndCloseCell=function(a){var b=
  this;if(null!=b.editedElement){var c=b.activeElement();!0==$.contains(b.editedElement[0],c)?(setTimeout(function(){var a=$(c);!0==a.is("input")&&a.blur()},0),setTimeout(function(){b.closeCell();a&&a()},10)):(b.closeCell(),a&&a())}};this.createFilterHeaderCell=function(a,b){var c=b.filterable?$("<th class='ui-filter-header  ui-widget-header'> <span class='ui-filter-span'> <input class='ui-filter-input' ></input> <span class='ui-header-menu menu-icon'></span></span> </th>").appendTo(a):$("<th class='ui-filter-header  ui-widget-header'></th>").appendTo(a);
  b.filterable&&"date"==b.type&&c.find(".ui-filter-input").datepicker({});var e="eq",h=!0;if(b.filterable){var d=b.filterable;d&&(e=d.operator);void 0!=d.ignoreCase&&(h=d.ignoreCase);void 0!=d.ignoreCase||"number"!=b.type&&"date"!=b.type||(h=!1);d=new m.Filter;d.element=c;d._create({column:b,datasource:this.options.datasource,grid:this,operator:e,ignoreCase:h,field:b.field,type:b.type?b.type:"string"})}};this.frozenHeadTable=$("<table class='ui-widget-header ui-frozen-head-table'><thead><tr></tr></thead></table>");
  this._columns=function(){var a=this;if(a.Column){var b=null,c=null,e=null,h,d,c=$("<thead></thead>");a.uiGridHeadTable.append(c);b=$("<tr></tr>").appendTo(c);this.hasDetails&&b.append("<th class='ui-widget-header rq-hierarchy-header'/>");a.options.filterable&&(e=$("<tr class='ui-filter-row' ></tr>").appendTo(c));$.each(a.Column,function(c,d){var h=$(a.createHeaderColumn(d));b.append(h);if(!0==a.options.sortable){var f=new m.Sorter;f.element=h;h.data("column",d);f._create({column:d,datasource:a.options.datasource,
  grid:a,mode:a.options.SortingMode,allowUnsort:a.options.allowUnsort})}e&&a.createFilterHeaderCell(e,d)})}0!=a.FrozenColumnCount&&(c=a.frozenHeadTable.find("thead"),h=a.frozenHeadTable.find("tr"),a.options.filterable&&(d=$("<tr class='ui-filter-row' ></tr>").appendTo(c)),$.each(a.FrozenColumn,function(b,c){var e=$(a.createHeaderColumn(c));h.append(e);if(!0==a.options.sortable){var f=new m.Sorter;f.element=e;e.data("column",c);f._create({column:c,datasource:a.options.datasource,grid:a,mode:a.options.mode,
  allowUnsort:a.options.allowUnsort})}d&&a.createFilterHeaderCell(d,c)}));this.menu.subscribeMenuHeaderEvent()};this.updateSorterSource=function(){var a=this;$.each(this.uiGrid.find("th.ui-widget-header"),function(){var b=$(this).data("Sorter");null!=b&&b.setOptions("datasource",a.options.datasource)})};this.setOptions=function(a,b){this.options[a]=b;switch(a){case "datasource":if(void 0!=b&&null!=b&&this.options.filterable){this.uiGrid.find(".ui-filter-input").val("");for(var c=0;c<this.options.columns.length;c++)this.options.columns[c].filterValue=
  null}this.Refresh();this.subscribeCollectionChange();this.subscribeModelChange();this.updateSorterSource();break;case "disable":this.disableGrid(b);case "headerHeight":this.updateGridHeight(),this.updateGridWidth(),this.updateScrollPadding()}};this.columnDragAndDrop=function(){var a=this,b=a.uiGridHeadTable.find("thead tr:eq(0) th"),c=a.frozenHeadTable.find("thead tr:eq(0) th"),e=b.add(c),d=a.uiGridBody.offset().left,f=d+a.uiGridBody.width();a.uiGridHeadTable.offset();a.uiGridHeadTable.height();var g=
  null,k=null,m=function(b){return!1!==a.columns[b].lockable},l=function(a,b){return $(a).parent()[0]===$(b).parent()[0]},r=function(a){var b=k;if(b===a[0])return!1;if(!l||!m||l(b,a))return!0};e.draggable({scroll:!0,helper:"clone",stack:"th",revert:"invalid",cursorAt:{bottom:25,left:50},drag:function(b,c){k=this;var e=c.helper;$(e).css({width:$(this).width(),height:$(this).closest("table").find("tr").height(),"line-height":"50px"});!0==a.options.EnableHeaderMenu&&$(e).find("div.ui-header-menu").removeClass("menu-icon");
  b.pageX>=f-70?(a.uiGridBody.scrollLeft(a.uiGridBody.scrollLeft()+10),a.uiGridHeadTableParent.scrollLeft(a.uiGridBody.scrollLeft())):70>=b.pageX-d&&(a.uiGridBody.scrollLeft(a.uiGridBody.scrollLeft()-10),a.uiGridHeadTableParent.scrollLeft(a.uiGridBody.scrollLeft()))}});e.droppable({tolerance:"touch",drop:function(b,c){var e=$(this);if(r(e)){var d=$(c.draggable).closest("table"),h=e.closest("table"),f=c.draggable.index(),e=e.index();a.processColumnReorder(d,h,f,e);g&&g.remove()}},deactivate:function(a,
  b){g&&g.remove()},over:function(b,c){g&&g.remove();var d=$(this);if(r(d)){var h=a.getOffset(d),f=h.left;l(d,k)?e.index(d)>e.index(k)&&(f+=d.outerWidth()):a._dropTarget=dropTarget;$(c.helper).find("div.nodropper").remove();$("<div class='grabber'></div>").insertBefore($(c.helper).find("div:eq(0)"));d=d.outerHeight();g=$('<div class="rq-reorder-cue"><div class="ui-icon ui-icon-triangle-1-s top-icon"></div><div class="ui-icon ui-icon-triangle-1-n bottom-icon"></div></div>');g.appendTo(document.body);
  g.find(".top-icon").css("margin-top","-12px");g.find(".bottom-icon").css("margin-top",d-12+"px");g.css({height:d,top:h.top,left:f})}else $(c.helper).find("div.grabber").remove(),$("<div class='nodropper'></div>").insertBefore($(c.helper).find("div:eq(0)"))}})};this.getOffset=function(a){a=a.offset();a.top-=window.pageYOffset-document.documentElement.scrollTop;a.left-=window.pageXOffset-document.documentElement.scrollLeft;return a};this.processColumnReorder=function(a,b,c,e){var d=$(this),f={};f.rows=
  d.closest("thead").find("tr");f.cellIndex=f.rows.find("th").length-1;f.dragIndex=c;f.dropIndex=e;this.columnReorderer(f,a,b,this.Column,this.FrozenColumn);this._updateCols();this.tmpl(!0);this.tmpl();this.Refresh()};this.columnReorderer=function(a,b,c,e,d){b.hasClass("ui-grid-head-table")&&c.hasClass("ui-grid-head-table")?(b=e.splice(a.dragIndex,1),e.splice(a.dropIndex,0,b[0]),c.find("tr").empty(),this.createtableHeader(this.Column,c)):b.hasClass("ui-frozen-head-table")&&c.hasClass("ui-frozen-head-table")&&
  (b=d.splice(a.dragIndex,1),d.splice(a.dropIndex,0,b[0]),c.find("tr").empty(),this.createtableHeader(this.FrozenColumn,c));this.menu.subscribeMenuHeaderEvent()};this.createtableHeader=function(a,b){var c=this,e=null;c.options.filterable&&(e=b.find(".ui-filter-row"));$.each(a,function(a,d){var f=$(c.createHeaderColumn(d));b.find("tr:eq(0)").append(f);if(!0==c.options.sortable){var g=new m.Sorter;g.element=f;f.data("column",d);g._create({column:d,datasource:c.options.datasource,grid:c,mode:c.options.SortingMode,
  allowUnsort:c.options.allowUnsort})}e&&c.createFilterHeaderCell(e,d)})};this.disableGrid=function(a){a?(this.element.prop("disabled",!0),this.selectedItems.clear(),this.element.css("opacity",0.5)):(this.element.prop("disabled",!1),this.element.css("opacity",1))};this.createHeaderColumn=function(a){if(a){var b=a.title||a.field||"",c="";!0==a.isRowHeader&&(c+=" rq-column-width-readonly");var e="<th ";a.id&&(e+='id = "'+a.id+'"');!0==a.hidden&&(e+="style='display:none'");e=e+("class='"+c+" ui-widget-header'><div style='position: relative;'> ")+
  b;e+="<span style='display: inline-block;' class='icon'></span> ";!0==this.options.EnableHeaderMenu&&!0!=a.isRowHeader&&(e+="<div  class='icon' style='width:16px;position: relative'><div class='ui-header-menu menu-icon'/></div>");return e+="<div class='resizeHelper ui-resizable-handle ui-resizable-e' style='top:-15.5px;height:45px;display:"+(!0==this.options.resizable?"block":"none")+"'></div></div></th>"}};this._updateCols=function(){this.appendCols(this.frozenHeadTable,this.frozenTable,this.FrozenColumn);
  this.appendCols(this.uiGridHeadTable,this.table,this.Column)};this.updateColWidthToFit=function(a,b,c){var e=!1==c?this.Column:this.FrozenColumn,d=this.element.width(),f=this.uiGridBody[0].scrollHeight>this.uiGridBody.height()?17:0,d=d-f;if(0!=e.length){var f=this.options.columns.slice(0),f=f.sort(function(a,b){return void 0==a.locked||void 0==b.locked?0:a.locked===b.locked?0:a.locked?-1:1}),g=function(a){for(var b=0,c=0;c<a.length;c++)a[c].width&&(b+=a[c].width);return b}(f),k=this.options.minWidth,
  m=function(a,b){for(var c=a.length-1;0<=c;c--)if(a[c].width>k)return a[c]};if(g>d)for(d=g-d;0<d;){g=m(f,d);if(null==g)break;d-=g.width-k;g.width=0<d?k:-d+k}else f[f.length-1].width+=d-g;f=a.find("col");$.each(f,function(a){$(this).width(e[a].width)});f=b.find("col");$.each(f,function(a){$(this).width(e[a].width)});this.setTableWidthByColumn(a,b,c)}};this.appendCols=function(a,b,c){var e;a.find("colgroup").remove();b.find("colgroup").remove();if(!a.find("colgroup").length){e=$("<colgroup></colgroup>").insertBefore(a.find("thead"));
  var d=null;c=$.map(c,function(a){if((d=a.width)&&0!==parseInt(d,10)&&!0!=a.hidden)return'<col style="width:'+("string"===typeof d?d:d+"px")+'"/>';if(!0!=a.hidden)return'<col style="width:100%"/>'});this.hasDetails&&e.append('<col style="width:27px"/>');e.append(c);e=a.find("colgroup").clone();e.insertBefore(b.children("tbody"));this.setTableWidthByColumn(a,b)}};this.tmpl=function(a){var b="",c=!0==a?this.generateTemplate(this.FrozenColumn):this.generateTemplate(this.Column),b=this.hasDetails?"<tr class='rq-grid-row rq-master-row ":
  "<tr class='rq-grid-row ";if(""==this.options.rowTemplate)var e=b+"' data-uid='${data.uid}' style='height:"+this.options.RowHeight+"px;'>",e=e+c+"</tr>";else e=this.options.rowTemplate;""==this.options.altRowTemplate?(b=b+"rq-grid-alternative-background' data-uid='${data.uid}' style='height:"+this.options.RowHeight+"px'>",b=b+c+"</tr>"):b=this.options.altRowTemplate;this.renderTemplate(e,b,a)};this.renderTemplate=function(a,b,c){c?(this.frozenRowTemplate=d(a),this.frozenAltRowTemplate=d(b)):(this.rowTemplate=
  d(a),this.altRowTemplate=d(b))};this.rowHtml=function(a,b){var c=this.uiGridBody.height();0>=c&&(c=this.uiGrid.height());return!0==b?this.renderRowHtml(a,this.frozenRowTemplate,this.frozenAltRowTemplate,this.$frozenTbody,this.frozenTable,this.uiFrozenGridBodyActualContent,c):this.renderRowHtml(a,this.rowTemplate,this.altRowTemplate,this.$tbody,this.table,this.uiGridBodyActualContent,c)};this.frozenAltRowTemplate=this.frozenRowTemplate="";this.renderRowHtml=function(a,b,c,e,d,f,g){var k=this.options.RowHeight,
  n=-k,l=this.options.datasource,r=this.uiGridBody,s=this.options.UseGridVirtualization,q=0;if(!l)return"";l instanceof m.GridModel&&(l=l.data);a||e.empty();s&&!a&&(e=r.scrollTop(),q=Math.floor(e/k),r=e%k,d[0].style.setProperty?d[0].style.setProperty("margin-top",e-r+"px","important"):d[0].style.setAttribute("margin-top",e-r+"px","important"));this.renderHeight=g;d=this.guid;e=this.GuidList;r="";null!=f&&f.height(k*l.length);this.unsubscribeAllObjectChanges();for(f=q;f<l.length&&!(s&&!a&&n>=g);f++){q=
  l[f];this.subscribeObjectChanges(q);if(void 0==q.uid){var v=d();q.uid=v;e[v]=q}else e[q.uid]=q;r=this.options.EnableAlternativeRowBackground?0==f%2?r+b(q):r+c(q):r+b(q);n+=q.RowHeight?q.RowHeight:k}return r};this.InsertColumn=function(a,b){this.fields=[];!0==b.locked?(0==a&&0==this.FrozenColumnCount&&(this.FrozenColumnCount+=1),this.insertTableColumn(a,b,this.frozenHeadTable,this.frozenTable,this.FrozenColumn,this.$frozenTbody),this.tmpl(!0)):(this.insertTableColumn(a,b,this.uiGridHeadTable,this.table,
  this.Column,this.$tbody),this.tmpl());this.updateGridHeight();this.updateGridWidth()};this.insertTableColumn=function(a,b,c,e,f,g){var k=this,t=d(k.createColumnTemplate(b,!1));if(!(a>f.length)){this.options.columns.splice(a,0,b);f.splice(a,0,b);k.appendCols(c,e,f);f=c.find("tr");var n=$(k.createHeaderColumn(b));if(!0==k.options.sortable){var l=new m.Sorter;n.data("column",b);l.element=n;l._create({column:b,datasource:k.options.datasource,grid:k,mode:k.options.SortingMode,allowUnsort:k.options.allowUnsort})}k.options.filterable&&
  (c=c.find("tr").hasClass("ui-filter-row")?c.find("tr:eq(1)"):$("<tr class='ui-filter-row' ></tr>").appendTo(c.find("thead")),k.createFilterHeaderCell(c,b));k.InsertElement(f,f.find("th"),n,a);k.InsertElement(e.find("colgroup"),e.find("col"),void 0,a);g.find("tr").each(function(){var b=$(this);k.InsertElement(b,b.find("td"),t(k.GetDataFromRow(b)),a)})}};this.RemoveColumn=function(a){this.fields=[];"number"!==typeof a&&(a=this.options.columns.indexOf(a));void 0!=this.options.columns[a]&&(!0==this.options.columns[a].locked?
  (this.removeTableColumn(a,this.frozenTable,this.frozenHeadTable,this.FrozenColumn),this.tmpl(!0)):(this.removeTableColumn(a,this.table,this.uiGridHeadTable,this.Column),this.tmpl()),this.updateGridHeight(),this.updateGridWidth())};this.removeTableColumn=function(a,b,c,e){a=this.options.columns.splice(a,1);var d=e.indexOf(a[0]);a=$("th:eq("+d+")",c);d=this.GetIndexByTableHead(a);$.each(b.find("tr"),function(){$(this).find("td").eq(d).remove()});a.remove();e.splice(d,1);this.appendCols(c,b,e)};this.GetIndexByTableHead=
  function(a){return $.inArray(a[0],a.parent().children())};this.InsertElement=function(a,b,c,e){b.length?0==e?b.eq(0).before(c):b.eq(e-1).after(c):a.append(c)};this.GetRowFromData=function(a){var b=a.uid;a=this.$tbody.find('tr[data-uid="'+b+'"]');0!=this.FrozenColumnCount&&(b=this.$frozenTbody.find('tr[data-uid="'+b+'"]'),a=b.add(a));return a.length?a:null};this.hideList=[];this.Cols=new RadiantQ.Dictionary;this.FrozenCols=new RadiantQ.Dictionary;this.GetColumnbyIndex=function(a){var b,c,e;!0==this.options.columns[a].locked?
  (a=this.FrozenColumn.indexOf(this.options.columns[a]),b=this.frozenTable,e=!0,c=this.frozenHeadTable):(a=this.Column.indexOf(this.options.columns[a]),b=this.table,e=!1,c=this.uiGridHeadTable);var d=0;if("string"===typeof a){var f=$("th#"+a,c);if(0==f.length)return null;a=f.index()}else f=$("th:eq("+a+")",c);d=this.GetIndexByTableHead(f);b=b.find("tr").find(" td:eq("+a+")");f=c.find("th:eq("+a+")");return{Header:f,Cells:b,Index:a,colIndex:d,Locked:e}};this.showColumn=function(a){a=this.GetColumnbyIndex(a);
  null!=a&&(!0==a.Locked?this.showtableColumn(a,this.frozenHeadTable,this.frozenTable,this.FrozenColumn,!0):this.showtableColumn(a,this.uiGridHeadTable,this.table,this.Column,!1),this._updateCols(),this.updateGridHeight(),this.updateGridWidth())};this.GridWidth=0;this.setTableWidthByColumn=function(a,b,c){var e=0,e=a.find("col");1!=this.Column.length||0!=this.Column[0].width&&void 0!=this.Column[0].width||c?(e=this.columnsWidth(e),a.width(e),b.width(e),this.GridWidth=e):(a.css("width","100%"),b.css("width",
  "100%"))};this.columnsWidth=function(a){for(var b,c=0,e=0,d=a.length;e<d;e++)(b=a[e].style.width)&&-1==b.indexOf("%")&&(c+=parseFloat(b,10));return c};this.showtableColumn=function(a,b,c,e,d){a.Header.show();this.setTableWidthByColumn(b,c);e[a.Index].hidden=!1;this.appendCols(b,c,e);this.hideList.splice(this.hideList.indexOf(a.Index),1);this.element.trigger("ColumnShow",{column:e[a.Index],index:a.colIndex});this.tmpl();d&&this.tmpl(!0);this.Refresh()};this.hideColumn=function(a){a=this.GetColumnbyIndex(a);
  null!=a&&(!0==a.Locked?this.hideTableColumn(a,this.frozenHeadTable,this.frozenTable,this.FrozenColumn,!0):this.hideTableColumn(a,this.uiGridHeadTable,this.table,this.Column,!1),this.updateGridHeight(),this.updateGridWidth(),this._updateCols())};this.hideTableColumn=function(a,b,c,e,d){a.Header.hide();e[a.Index].hidden=!0;this.appendCols(b,c,e);this.element.trigger("ColumnHide",{column:e[a.Index],index:a.colIndex});this.hideList.push(a.Index);d&&this.tmpl(!0);this.tmpl();this.Refresh()};this.LockColumn=
  function(a){if(-1!=this.options.columns[a]&&(!1==this.options.columns[a].locked||void 0==this.options.columns[a].locked)){var b=this.GetColumnbyIndex(a);b.Header.remove();this.Column.splice($.inArray(this.Column[b.colIndex],this.Column),1);var c=this.options.columns[a];$.extend(c,{locked:!0});this.FrozenColumn.push(c);this.createHeaderColumn(c);this.frozenHeadTable.find("tr:eq(0)").append(b.Header);this.options.filterable&&(b=this.frozenHeadTable.find("tr.ui-filter-row"),0==b.length&&(b=$("<tr class='ui-filter-row' ></tr>"),
  this.frozenHeadTable.find("thead").append(b)),this.createFilterHeaderCell(b,c));this._updateCols();this.element.trigger("ColumnLocked",{column:c,index:a});this.FrozenColumnCount+=1;this.tmpl();this.tmpl(!0);this.Refresh();this.menu.subscribeMenuHeaderEvent();this.updateGridHeight()}};this.UnlockColumn=function(a){if(-1!=this.options.columns[a]&&!0==this.options.columns[a].locked){var b=this.GetColumnbyIndex(a);b.Header.remove();var c=this.options.columns[a];this.FrozenColumn.splice($.inArray(this.FrozenColumn[b.colIndex],
  this.FrozenColumn),1);$.extend(c,{locked:!1});this.Column.splice(0,0,c);b=this.createHeaderColumn(c);this.uiGridHeadTable.find("tr:eq(0)").prepend(b);this.options.filterable&&(b=this.uiGridHeadTable.find("tr.ui-filter-row"),0==b.length&&(b=$("<tr class='ui-filter-row' ></tr>"),this.uiGridHeadTable.find("thead").append(b)),this.createFilterHeaderCell(b,c));this._updateCols();this.FrozenColumnCount-=1;this.element.trigger("ColumnUnlocked",{column:c,index:a});this.tmpl();this.tmpl(!0);this.Refresh();
  this.menu.subscribeMenuHeaderEvent();this.updateGridHeight()}};this.syncTableScrollPosition=function(){var a=this.uiGridBody.scrollTop();this.uiFrozenGridBody.scrollTop(a)};this.GetDataFromRow=function(a){a=$(a).data("uid");return this.GuidList[a]?this.GuidList[a]:null};return this};$.fn.VWGrid=function(g){g=new m.GridUI(g);g._create(this);new m.Selection(g);new m.Hoverable(g)};m.Selection=function(g){this.Grid=g;this.$GridTables=null;this.create=function(){var f=this;this.$GridTables=this.Grid.table.add(this.Grid.frozenTable);
  this.Grid.uiGridBodyParent.bind("mouseup",function(d){setTimeout(function(){f.mouseDown(d)},0)});var d=$.proxy(f.UpdateSelection,f);this.Grid.selectedItems.CollectionChanged.subscribe(d);this.UpdateSource()};this.Grid.selectedItems=new RadiantQ.RQ_CollectionChangeNotifier;this.UpdateSource=function(){var f=this,d=f.Grid.options.datasource;d&&d.CollectionChanged&&d.CollectionChanged.subscribe(function(d,a){"remove"===d.type&&f.Grid.selectedItems[0]==a.items[0]&&f.Grid.selectedItems.remove(a.items[0])})};
  this.mouseDown=function(f){var d=$(f.target).closest("tr"),g=d.parents("table"),a=this.Grid;if(!0!=a.options.disable){if(!g)return!1;if(g.hasClass("ui-selectable")){g=a.GetDataFromRow(d);if(!f.ctrlKey&&0!=d.length||"single"==a.options.SelectionMode){if(1==a.selectedItems.length&&a.selectedItems[0]==g)return;a.ClearSelection()}else if(0!=d.length&&(d.hasClass("rq-row-selected")||d.find("td").hasClass("rq-row-selected"))&&3!==f.which)return a.selectedItems.remove(g),!1;a.SelectRow(g)}return!1}};this.UpdateSelection=
  function(f,d){var g=d.items[0];"insert"===f.type?(g=this.$GridTables.find('tr[data-uid="'+g.uid+'"]'),g.addClass("rq-row-selected ui-state-active")):"remove"===f.type&&(g=this.$GridTables.find('tr[data-uid="'+g.uid+'"]'),g.removeClass("rq-row-selected ui-state-active"))};g.SelectRow=function(f){null!=f&&(1==g.selectedItems.length&&"single"==this.options.SelectionMode?(g.selectedItems.clear(),g.selectedItems.add(f)):g.selectedItems.contains(f)||g.selectedItems.add(f))};this.hightlighRowByData=function(f){null!=
  f&&g.selectedItems.add(f)};g.ClearSelection=function(){for(var f=g.selectedItems.length,d=0;d<f;d++)g.selectedItems.remove(g.selectedItems[0])};this.create();return this};m.Hoverable=function(g){this.Grid=g;this.prevChartRow=this.prevTableRow=this.prevFrozenRow=this.currentTr=this.currentData=null;this._create=function(){var f=this,d=this.Grid;this.$GridTables=d.table.add(d.frozenTable);d.uiGridBodyParent.bind("mouseover",function(d){f._mousehover(d)});d.uiGridBodyParent.bind("mouseleave",function(d){f.IsMouseIn()})};
  this._mousehover=function(f){if(!0!=g.options.disable)return this.currentTr=$(f.target).closest("tr"),0!=this.currentTr.length?this.IsMouseIn(this.currentTr.data("uid")):this.prevTableRow&&this.IsMouseIn(),!1};this.IsMouseIn=function(f){this.prevTableRow&&(this.prevTableRow.removeClass("rq-row-hover ui-state-hover"),this.prevTableRow=null);f&&(this.prevTableRow=this.$GridTables.find('tr[data-uid="'+f+'"]').addClass("rq-row-hover ui-state-hover"))};this._create();return this}})(VW.Grid);
  (function(m){var s=m(document),v=function(b,c){var e=m.extend({minWidth:20,GetGridInstance:function(){return b.data("VWGrid")}},c);e.publicProps={colWidth:null,startX:null,gridBody:null,gridHeadTable:null,$colElementHeader:null,$colElementBody:null,gridHeadth:null,lastColumnHeader:null,lastColumnBody:null,resizeStart:null,frozenGridHeadth:null,frozenGridHeadTable:null,gridInstance:e.GetGridInstance.call(this),gridTable:null,frozenGridTable:null,frozenGridBody:null,col:null,th:null,$grid:null,gridWidth:null,
  columnWidth:null,resizedcolumn:null,NewColWidth:null,tapDownX:null,tapDownY:null,touchStartTime:null,fitToGrid:!1};var d=e.publicProps;d.fitToGrid=d.gridInstance.options.ColumnBehaviour==VW.Grid.ColumnBehaviour.NoHorizontalScrollBar;1<d.gridInstance.uiGridHead.find("table").length?(d.gridHeadTable=m(d.gridInstance.uiGridHead.find("table")[1]),d.frozenGridHeadTable=m(d.gridInstance.uiGridHead.find("table")[0])):d.gridHeadTable=d.gridInstance.uiGridHead.find("table");d.gridHeadth=d.gridHeadTable.find("th");
  void 0!=d.frozenGridHeadTable&&(d.frozenGridHeadth=d.frozenGridHeadTable.find("th"));d.gridTable=d.gridInstance.table;d.gridBody=d.gridInstance.uiGridBody;d.frozenGridTable=d.gridInstance.frozenTable;d.frozenGridBody=d.gridInstance.uiFrozenGridBody;if(void 0!=d.frozenGridHeadTable){var f=d.frozenGridHeadth.not(".rq-column-width-readonly").find("div.resizeHelper");f.off("mousedown.columnResizer");f.off("mouseup.columnResizer");f.on("mousedown.columnResizer",{options:e,element:b},g);f.on("mouseup.columnResizer",
  {options:e,element:b},a)}d=d.gridHeadth.not(".rq-column-width-readonly").find("div.resizeHelper");d.off("mousedown.columnResizer");d.off("mouseup.columnResizer");d.on("mousedown.columnResizer",{options:e,element:b},g);d.on("mouseup.columnResizer",{options:e,element:b},a);return this};m.fn.ColumnEnhancer=function(a){a=new v(this,a);this.data("ColumnEnhancer",a)};var g=function(b){var c=b.data.options.publicProps,d=b.data.element,g=b.originalEvent;s.on("mousemove.columnResizer",{options:b.data.options,
  element:d},k);s.on("touchmove.columnResizer",{options:b.data.options,element:d},k);s.on("mouseup.columnResizer",{options:b.data.options,element:d},a);b=g.touches?g.touches[0]:b;m(b.target).closest("table").hasClass("ui-frozen-head-table")?f(d,c,b,c.frozenGridHeadth,c.frozenGridHeadTable,c.frozenGridBody,c.frozenGridTable):f(d,c,b,c.gridHeadth,c.gridHeadTable,c.gridBody,c.gridTable)},f=function(a,c,e,f,g,k,t){var n=m(e.target);d=c.startX=e.clientX;c.th=n.closest("th");c.th.parent().css("cursor","e-resize");
  var l=c.th.index();m(f[l]).hasClass("rq-column-width-readonly")?e.preventDefault():(c.$colElementHeader=g.find("colgroup:first > col:nth-child("+(l+1)+")"),c.$colElementBody=k.find("colgroup:first > col:nth-child("+(l+1)+")"),c.CurrentHeadTable=g,c.CurrentBodyTable=k,c.col=c.$colElementHeader.add(c.$colElementBody),c.$grid=g.add(t),c.gridWidth=t.find("tbody").outerWidth(),c.columnWidth=c.th.outerWidth(),c.Columns=[],n.closest("table").hasClass("ui-frozen-head-table")?c.Columns=c.gridInstance.FrozenColumn:
  c.Columns=c.gridInstance.Column,c.resizedcolumn=c.Columns[l],c.resizeStart=!0,a.trigger("ColumnResizeStart",{tableHeadCol:c.$colElementHeader,tableBodyCol:c.$colElementBody,col:c.col}))},d=0,k=function(a){var c=a.data.options.publicProps,e=a.originalEvent;if(c.resizeStart)if(c.gridInstance.options.columnResizing=!0,a.preventDefault(),a=e.touches?e.touches[0]:a,e=a.clientX-c.startX,!1==c.fitToGrid){if(!1==c.columnWidth-a.data.options.minWidth<=-e){var f=c.columnWidth+e;a=c.gridWidth+e;c.gridInstance.element.width()-
  55<a&&!0==c.resizedcolumn.locked||(c.col.width(f),c.NewColWidth=f,c.$grid.width(a).width(),c.resizedcolumn.width=c.NewColWidth,c.gridInstance.updateGridUI(),c.col.css("height","auto"))}}else{var e=a.clientX-d,g=0,k;var t=a.data.options,g=e;k=c.CurrentHeadTable.find("th:not(.ui-filter-header):visible");for(var t=t.minWidth,n=null,l=k.length-1,r=0,s=!1;0<=l;l--){var n=m(k[l]),f=c.Columns[l],q=t<=f.width;1<=g&&(q=0<f.width-t);if(q&&c.th[0]!=n[0]){s=!0;r=f.width;break}}k=!0==s?{Cols:c.CurrentHeadTable.add(c.CurrentBodyTable).find("colgroup:first > col:nth-child("+
  (l+1)+")"),width:r,column:f}:null;k&&(g=k.column.width-e,f=c.resizedcolumn.width+e,e=g>=a.data.options.minWidth,f>a.data.options.minWidth&&e&&(k.Cols.width(g),c.col.width(f),k.column.width=g,c.resizedcolumn.width=f));d=a.clientX}},a=function(a){var c=a.data.options.publicProps;a=a.data.element;c.resizeStart&&(c.th.parent().css("cursor","pointer"),c.gridInstance.options.columnResizing=!1,a.trigger("ColumnResizeEnd",{tableHeadCol:c.$colElementHeader,tableBodyCol:c.$colElementBody,col:c.col,tableHead:c.th,
  newColWidth:c.NewColWidth,gridWidth:c.gridWidth}),s.off("mousemove.columnResizer"),s.off("keyup.columnResize"),s.off("mouseup.columnResizer"),c.resizeStart=!1)}})(jQuery);
  