!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("$")):"function"==typeof define&&define.amd?define(["$"],t):"object"==typeof exports?exports["g5-gridview"]=t(require("$")):e["g5-gridview"]=t(e.$)}(this,function(e){return function(e){function t(r){if(i[r])return i[r].exports;var n=i[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var i={};return t.m=e,t.c=i,t.i=function(e){return e},t.d=function(e,i,r){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/dist/",t(t.s=24)}({11:function(e,t){e.exports={userAgent:navigator.userAgent.toLowerCase(),isMobile:function(){return/mobile/.test(this.userAgent)},isChrome:function(){return/chrom(e|ium)/.test(this.userAgent)}}},2:function(e,t){e.exports={math:{trunc:function(e){return(e>0?Math.floor:Math.ceil)(e)}},ui:{getClientX:function(e){if(null==e)return null;null!=e.originalEvent&&(e=e.originalEvent);var t=e.touches&&e.touches[0]&&e.touches[0].clientX;return void 0===t?e.clientX:t},getOffsetLeft:function(e){for(var t=0;e;)t+=e.offsetLeft,e=e.offsetParent;return t}},func:{debounce:function(e){for(var t=arguments.length,i=Array(t>3?t-3:0),r=3;r1&&void 0!==arguments[1]?arguments[1]:100,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window;clearTimeout(e.tiid),e.tiid=setTimeout(function(){return e.apply(s,i)},n)},throttle:function(e){for(var t=arguments.length,i=Array(t>3?t-3:0),r=3;r1&&void 0!==arguments[1]?arguments[1]:100,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window;clearTimeout(e.tiid);var l=new Date;void 0===e.tdate||l-e.tdate>n?(e.apply(s,i),e.tdate=l):e.tiid=setTimeout(function(){return e.apply(s,i)},n)}}}},24:function(e,t,i){function r(e){this.columns=[],this._source=[],this.source=this._source,this.lang={all:"( All )",ok:"OK",reset:"Reset",sort:"Sort",addLevel:"Add Level",deleteLevel:"Delete Level",copyLevel:"Copy Level",column:"Column",order:"Order",asc:"Asc",desc:"Desc",cancel:"Cancel",duplicatePrompt:"{column} is being sorted more than once. Delete the duplicate sort criteria and try again.",requirePrompt:"All sort criteria must have a column specified. Check the selected sort criteria and try again."},this.virtualCount=Y,this.rowHeight=27,this.filterRowHeight=26,this.total=null,this.height=null,this.virtual=!1,this.startIndex=0,this.sortIndex=-1,this.sortDirection=1,this.sortArray=null,this.selectedColumnIndex=-1,this.selectedIndexes=[],this.canMultiSelect=!1,this.allowHtml=!1,this.oddStyle=!1,this.$parent=e,this.$el=null,this.$refs={},this.$elems={},this.$window=window,this.willselect=null,this.selectedrowchanged=null,this.celldblclick=null,this.cellclick=null,this.rowdblclick=null,this.columnchanged=null}function n(e){return Array.prototype.slice.call(e.parentNode.children).indexOf(e)}function s(e,t){(t||!this._innerwidth&&!this._isdragging&&this._istouchdown)&&(delete this._istouchdown,this.sortable&&"INPUT"!==e.target.tagName&&"data-column-header-filter"!==e.target.className&&!e.target.classList.contains("arrow")&&"use"!==e.target.tagName.toLowerCase()&&$.call(e.data,this))}function l(e,t){if(null==e)return"";var i=e[t];return void 0===i&&(i=e),i}function o(e,t){var i=l(e,t);return Array.isArray(i)?i.join(","):i}function a(e,t){for(var i={},r=0;r'),a=j(""),d=j('').data("item",s),c=void 0;if(this.filterCustom||"function"!=typeof this.filter)c=l(s,"DisplayValue");else{var u={};u[this.key]=s,c=this.filter(u)}d.data("text",c).prop("checked",s.__checked).on("change",r),a.append(d),a.append(j(''));var f=j("").text(c);a.append(f),o.append(a),e.append(o)}}function u(e,t,i,r){t.children(".data-filter-items-sizeholder").remove(),t.children(".data-filter-items-contentholder").remove();var n=e.filterRowHeight,s=i.length*n;this.__filterHeight=s;var l=j('
').css("height",s);t.append(l);var a=j('
').css("top",n);t.data("items",i);for(var d=0;d=0}var u=void 0;u=i.length>12?i.slice(0,12):i,c.call(this,a,u,r),t.append(a)}function f(e,t){var i=e.filterRowHeight;if((t-=t%(2*i)+i)<0)t=0;else{var r=this.__filterHeight-12*i;r<0&&(r=0),t>r&&(t=r)}if(this.__filterTop!==t){this.__filterTop=t;var n=t/i;this.__filterStartIndex=n;var s=this.__itemHolder.data("items");s=n+12').on("mousedown",function(e){return e.stopPropagation()}).on("touchstart",function(e){return e.stopPropagation()}),c=j(e.currentTarget).parent(),p=c.offset(),g=c.width();s.css({top:p.top+c.height(),left:p.left+(g>200?g-200:0)});var v=j('
');if(this.__itemHolder=v,"function"==typeof this.onFillItems){v.css("overflow-y","hidden");var y=!1;if("function"==typeof this.onFillSearch){var m=this.onFillSearch();if(null!=m){var b=j('
');b.append(m),s.append(b),y=!0}}y?v.css("height",250):v.css("height",280),s.append(v),this.onFillItems(v,s)}else{var w=null;if(!1!==this.allowSearch){var x=j('
');w=j('');var _=function(e){return e.data.focus()},$=j('').on("mouseup",w,_).on("touchend",w,_);x.append(w,$),s.append(x)}v[0].addEventListener("scroll",function(e){M.throttle(f,X,t,i,e.target.scrollTop)},{passive:!0});var C=j('
'),k=j(""),I=j('');this.__checkboxAll=I,k.append(I),k.append(j('')),k.append(j("").text(i.lang.all)),C.append(k),v.append(C);var T=void 0;T=null!=this.filterSource?"function"==typeof this.filterSource?this.filterSource.call(i,this):this.filterSource:a.call(i.innerSource,this.key,"Value").sort(function(e,t){return e=o(e,"Value"),t=o(t,"Value"),e>t?1:e0&&T[0]!==Object(T[0])){H=[];for(var O=0;O=0});u.call(e.data.column,e.data.grid,v,i,I)}):v.css("height",255),I.on("change",function(e){var t=v.children(".data-filter-items-contentholder").find(".data-filter-items-item input"),i=j(e.target).prop("checked"),r=void 0;for(r=0;r'),V=j('').val(i.lang.reset).on("click",function(){delete t.filterValues,"function"==typeof t.onFilterReset?t.onFilterReset(e):(i.refreshGrid(),"function"==typeof t.afterFilter&&t.afterFilter(i)),n(),j(e.currentTarget).removeClass("filtered").addClass("no-filter")});N.append(V);var A=j('').val(i.lang.ok).on("click",function(){var r=v.data("items").filter(function(e){return!1!==e.__checked});if("function"==typeof t.onFilterOK)t.onFilterOK(r,e);else{var s=r.map(function(e){var t=l(e,"Value");return Array.isArray(t)?t.join(","):t});t.filterValues=s,i.refreshGrid(),"function"==typeof t.afterFilter&&t.afterFilter(i)}j(e.currentTarget).removeClass("no-filter").addClass("filtered"),n()});N.append(A),s.append(N)}r.append(s),setTimeout(function(){return s.addClass("active")},1)}function g(e){var t=this;if(this._istouchdown=!0,!1!==this.orderable&&!this.isfixed&&"INPUT"!==e.target.tagName&&"data-column-header-filter"!==e.target.className&&!e.target.classList.contains("arrow")&&"use"!==e.target.tagName.toLowerCase()){var i=P.getClientX(e),r=n(e.currentTarget),l=function(n){var s=P.getClientX(n),l=s-i,o=t._isdragging;!o&&(l>Q||l<-Q)&&(o=!0,t._isdragging=!0),o&&l!==t._offset&&(b.call(e.data,r,l,s),t._offset=l)},o=function(i){j(e.data.$window||window).off(".dragging"),t._isdragging?(delete t._isdragging,delete t._offset,w.call(e.data,r)):i.originalEvent&&i.originalEvent.touches&&s.call(t,i)},a=M.throttle.bind(this,l,X,null);j(e.data.$window||window).on("mousemove.dragging",a).on("mouseup.dragging",o).on("touchmove.dragging",a).on("touchend.dragging",o)}}function v(e){var t=this;e.stopPropagation(),e.preventDefault();var i=P.getClientX(e),r=this.width,s=n(e.currentTarget.parentNode);if(this.isfixed){for(var l=0,o=0;o=0&&(this.$el_fixed[0].style.width=this._baseWidth+t+1+"px"));var l=this.$elems.gridbodyContent.children;if(l.length>0)for(var o=0;o0)for(var a=0;a=0&&t>=0&&((n=r[l])&&!((" "+n.className+" ").indexOf(" data-column-header ")<0));l-=1){if(tn.offsetWidth/2?l:l+1;break}t-=n.offsetWidth}null==s&&(s=0),null!=this.fixedColumns&&s=0;a+=1){if(!(n=r[a])||(" "+n.className+" ").indexOf(" data-column-header ")<0){s=a;break}if(tn.offsetWidth/2?a+1:a;break}t-=n.offsetWidth}null==s&&(s=o-1)}if(s!==this._orderIndex){if(this._orderIndex=s,!(n=r[s]))return;this.$refs.draggerCursor.css("left",n.offsetLeft)}}function w(e){if(this.$refs.dragger.hide(),this.$refs.draggerCursor.hide(),this._orderIndex>=0&&this._orderIndex!==e){var t=this._orderIndex-e;if(t>=0&&t<=1)return;var i=this.$refs.header[0].children,r=this.$elems.gridbodyContent.children,n=this.$refs.total&&this.$refs.gridtotalbody[0].children;if(t>1){t=this._orderIndex-1;for(var s=e;st;a-=1){var d=this.columns[a];this.columns[a]=this.columns[a-1],this.columns[a-1]=d}j(i[e]).insertBefore(i[t]);for(var h=0;hr?1:-1)*t}:function(i,r){return e.sortFilter(i,r)*t}}function $(e,t,i){var r=this.columns.indexOf(e);if(!i){this.sortIndex=r,this.sortArray=null;for(var n=this.$refs.header[0].children,s=this.$refs.header_fixed&&this.$refs.header_fixed[0].children,l=0;l0?"asc":"desc"),a&&(a.className="arrow "+(this.sortDirection>0?"asc":"desc"))):"arrow"!==o.className&&(o.className="arrow",a&&(a.className="arrow"))}}this.source.sort(_(e,this.sortDirection)),this.refresh(),i||t||"function"!=typeof this.columnchanged||this.columnchanged(G.SORT,r,this.sortDirection)}function C(e,t){if(null!=this.source){var i=e.key,r="string"==typeof e.enabled,n=e.onchanged;if(null!=e.checkall)e.checkall.call(this,e,t);else for(var s=0;sr&&(e=r)}return this._scrollTop!==e?(this._scrollTop=e,this.virtual&&(this.startIndex=e/i),this.refresh(),this.virtual&&(this.$refs.gridbodyContent[0].style.top=e+"px",null!=this.$refs.gridbodyContent_fixed&&(this.$refs.gridbodyContent_fixed[0].style.top=e+"px"))):t&&this.refresh(),e}function T(e){if(typeof this.scrolling==="function"&&this.scrolling(e),this.resetScroll(e.target),this.virtual){var t=e.target.scrollTop;I.call(this,t)}}function H(e,t){if(null==e)return-1;for(var i=void 0;null!=(i=e.parentNode)&&(" "+i.className+" ").indexOf(" data-grid-row ")<0&&(" "+i.className+" ").indexOf(" data-grid-total-body ")<0;)e=i;if(null==i)return-1;for(var r=i.children.length-(t?0:1),n=0;n0){if(l.length>1||l[0]!==n){var a=l[l.length-1],d=void 0;a>n?(d=a,a=n):d=n,l.splice(0);for(var h=a;h<=d;h+=1)l.push(h);s=!0}}else 1===l.length&&l[0]===n||(l.splice(0,l.length,n),s=!0);else 1===l.length&&l[0]===n||(l.splice(0,l.length,n),s=!0);if(s){if(this.isEditable){for(var c=this.$elems.gridbodyContent.children.length,u=0;u=0?f.__selected=!0:delete f.__selected;var p=f.Values.__changed;if(null!=p)for(var g=0;g=0?(y[b].className="data-grid-row data-grid-row-selected",null!=m&&(m[b].className="data-grid-row data-grid-row-selected")):"data-grid-row"!==y[b].className&&(y[b].className="data-grid-row",null!=m&&(m[b].className="data-grid-row"));"function"==typeof this.selectedrowchanged&&this.selectedrowchanged(n)}var w=null!=i?i:H(e.target);this.selectedColumnIndex=w,(this.allowFullrowClick||w>=0)&&(1===e.buttons||e.originalEvent instanceof TouchEvent)&&"function"==typeof this.cellclick&&this.cellclick(n,w)&&(e.stopPropagation(),e.preventDefault())}}function S(e,t){if("INPUT"!==e.target.tagName){var i=t?-1:this.selectedIndex;if("function"==typeof this.rowdblclick&&this.rowdblclick(i),"function"==typeof this.celldblclick){var r=t?H(j(e.target).parents(".data-grid-total-row")[0],t):this.selectedColumnIndex;this.celldblclick(i,r)}}}function N(e,t){var i=this;if(null!=this._bodyRowCount){t=t||this.columns;var r=this._bodyRowCount;(!this.virtual||this.source.length0){for(var o=[],a=function(e){return S.call(i,e,!1)},d=0;d').on("mousedown",r).on("touchstart",r).on("dblclick",a),l=0;l");if(!1===l.visible)o.hide();else if(o[0].keyid=s+e<');else if(l.type===q.checkbox){var a=function(t){return k.call(i,t,s+e,l)},d=j(""),h=j('').on("change",a),c=j('');d.append(h,c),o.append(d)}else o.append("");n.append(o)}(l);n.append(""),o.push(n)}(d);var h=n.find("tr").last();h.hasClass("data-grid-row-total-holder")&&h.remove(),n.append(o),null!=this.total&&n.append('')}else if(l<0){l=-l;for(var d=1;d<=l;d+=1)j(e.children[s-d]).remove()}}}function V(e){var t=e.target;if("data-grid-hover-holder"!==t.className){for(var i=void 0;null!=(i=t.parentNode)&&(" "+i.className+" ").indexOf(" data-grid-row ")<0;)t=i;var r=t.keyid,n=e.data;if(null==i||null==r)return n.nowKeyid=null,void("none"!==n.style.display&&(n.style.display="none"));var s=n.nowKeyid;if((r+=this.startIndex<0&&(o=t.children[0]),null==l&&(l=o.scrollWidth>o.offsetWidth,this._overflows[r]=l),l){if(""!==n.style.display&&(n.style.display=""),s!==r){n.nowKeyid=r,n.innerText=o.innerText;var a=this.$refs.gridbodyContent[0].offsetTop+t.offsetTop,d=t.offsetLeft,h=n.offsetWidth;h>this._bodyClientWidth&&(h=this._bodyClientWidth);var c=this._bodyClientWidth+this._scrollLeft-h;d>c&&(d=c);var u=o.offsetHeight;n.style.cssText="top: "+a+"px; left: "+d+"px; max-width: "+this._bodyClientWidth+"px; height: "+(u-2)+"px"}}else null!=s&&(n.nowKeyid=null),"none"!==n.style.display&&(n.style.display="none")}}}function A(){var e=this.$refs.gridbody.find(".data-grid-hover-holder")[0];null!=e&&(null!=e.nowKeyid&&(e.nowKeyid=null),"none"!==e.style.display&&(e.style.display="none")),null!=this.$refs.gridbody_fixed&&null!=(e=this.$refs.gridbody_fixed.find(".data-grid-hover-holder")[0])&&(null!=e.nowKeyid&&(e.nowKeyid=null),"none"!==e.style.display&&(e.style.display="none"))}function z(e){var t=this,i=null==e?"":"_fixed";e=e||this.columns;var r=j('
'),n=j('');r.on("mouseenter",function(){return A.call(t)}),r.append(n);for(var l=this.$elems.sizeHolder,o=0;o
').hide().attr("data-key",r.key).on("mouseup",t,o))}else n.append(j('
').hide());return"continue"}if(r.width>0||r.isShrink)r.autoResize=!1;else{r.autoResize=!0,t._needAutoResize=!0,l.text(r.caption);var a=l.width()+20;a0&&(r.sortable=!0),r.isShrink?r.style={"text-align":r.align}:r.style={width:r.width,"max-width":r.width,"min-width":r.width,"text-align":r.align};var d=function(e){return s.call(r,e)},h=function(e){return g.call(r,e)},c=function(e){return v.call(r,e)},u=function(e){return C.call(t,r,j(e.target).prop("checked"))},f=j('').attr("data-key",r.key).css(r.style).css("cursor",r.sortable?"pointer":"auto").on("mouseup",t,d).on("touchend",t,d).on("mousedown",t,h).on("touchstart",t,h);if(r.istotal&&f.addClass("data-grid-column-header-total"),!1!==r.enabled&&r.allcheck&&r.type===q.checkbox){var y=j(""),m=j('').on("change",u),b=j('');y.append(m,b),null!=r.caption&&0!==r.caption.length||(r.sortable=!1),f.append(j('
').css(r.textStyle||{}).append(j("").append(y,j("").text(r.caption).attr("title",!1!==t.headerTitle?r.caption:""))))}else"function"==typeof r.caption?f.append(j('
').css(r.textStyle||{}).append(r.caption())):f.append(j('
').css(r.textStyle||{}).append(j("").text(r.caption).attr("title",!1!==t.headerTitle?r.caption:"")));if(f.append(j('')),r.allowFilter){var w=function(e){return p.call(r,e)},x=j('
').on("mousedown",t,w).on("touchstart",t,w);r.isFiltered&&x.removeClass("no-filter").addClass("filtered"),f.addClass("data-column-header-has-filter").append(x)}var _=j('
').on("mousedown",t,c).on("touchstart",t,c);if(!1===r.resizable&&_.css("display","none"),null!=r.tooltip){var $=r.tooltip;"function"==typeof $&&($=$(r)),f.attr("title",$)}f.append(_),n.append(f)})(o)}n.append(' ');var a=j('
').hide(),d=j('
').hide();return n.append(j("").append(a,d)),l.empty(),this.$refs["headerTable"+i]=r,this.$refs["header"+i]=n,this.$refs["dragger"+i]=a,this.$refs["draggerCursor"+i]=d,r}function R(e,t){var i=this,r=null==t?"":"_fixed",n=j('
');this.oddStyle?n.addClass("data-grid-odd-style"):n.addClass("data-grid-even-style"),null==t?n[0].addEventListener("scroll",function(e){null!=i.$refs.gridbody_fixed&&(i.$refs.gridbody_fixed[0].scrollTop=e.target.scrollTop),M.throttle(T,X,i,e)},{passive:!0}):n.on("mousewheel DOMMouseScroll",function(e){var t=-e.originalEvent.wheelDelta||40*e.originalEvent.detail,r={target:i.$refs.gridbody[0]};r.target.scrollTop+=t,T.call(i,r)}),t=t||this.columns,this._containerHeight=this.source.length*this.rowHeight;var s=void 0;if(0===this._containerHeight){this._containerHeight=1,s=0;for(var l=0;l").css({position:"relative","min-width":"100%","min-height":1,height:this._containerHeight,width:s});n.append(o);var a=j('
'),d=a.children("tbody")[0];o.append(a),N.call(this,d,t);var h=function(e){var t=e.currentTarget.nowKeyid;if(null!=t)return O.call(i,e,(t>>>U)-i.startIndex,t&Z)},c=function(e){return S.call(i,e,!1)};if(!this.noHoverHolder){var u=j('
').hide().on("mousedown",h).on("touchstart",h).on("dblclick",c);o.append(u),n.on("mousemove",u[0],function(e){return M.throttle(V,X,i,e)})}return this.$refs["gridbody"+r]=n,this.$refs["gridbodyContainer"+r]=o,this.$refs["gridbodyContent"+r]=a,this.$elems["gridbodyContent"+r]=d,e&&this.refresh(),n}function W(e){var t=this;if(null==this.total)return null;var i=null==e?"":"_fixed",r=j('
'),n=j('
');r.append(n);var s=function(e){return S.call(t,e,!0)},l=j('').on("dblclick",s);n.append(l);var o=this.$elems.sizeHolder;e=e||this.columns;for(var a=0;a');if(!1===d.visible)h.hide();else{var c=void 0;if(d.istotal?c=null:null!=(c=this.total[d.key])&&null!=c.DisplayValue&&(c=c.DisplayValue),null==c&&(c=""),d.autoResize){o.html(c);var u=o.width()+10;if(u>d.width){var f=u+"px";this.$refs.header[0].children[a].style.width=f,this.$refs.header[0].children[a].style.minWidth=f,this.$refs.header[0].children[a].style.maxWidth=f,d.width=u,d.style.width=u,d.style["max-width"]=u,d.style["min-width"]=u}}h.append(j("
").css(d.style).html(c))}l.append(h)}return o.empty(),this.$refs["gridtotal"+i]=n,this.$refs["gridtotalbody"+i]=l,this.$refs["total"+i]=r,r}function L(e,t,i,r,n){for(var s=this.startIndex,l=this.selectedIndexes,o=0;o=0?"data-grid-row data-grid-row-selected"!==u&&(d.className="data-grid-row data-grid-row-selected"):"data-grid-row"!==u&&(d.className="data-grid-row");for(var f=0;f0&&null!=i&&(null==i[f]||i[f]0&&(y.style.cssText="");for(var C in $)Object.prototype.hasOwnProperty.call($,C)&&(y.style[C]=$[C])}if(null!=p.bgFilter){var k=p.bgFilter(c);v.style.backgroundColor=k||""}if(null!=p.events)for(var I in p.events)Object.prototype.hasOwnProperty.call(p.events,I)&&(y[I]=p.events[I].bind(c));if(null!=p.attrs){var T=p.attrs;"function"==typeof T&&(T=T(c));for(var H in T)Object.prototype.hasOwnProperty.call(T,H)&&y.setAttribute(H,T[H])}}}}}}}var F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},j=i(4),D=i(2),E=D.math,P=D.ui,M=D.func,K=i(11);i(5);var B=window._network,G={REORDER:"reorder",RESIZE:"resize",SORT:"sort"},q={common:0,input:1,dropdown:2,checkbox:3},X=!K.isMobile()&&K.isChrome()?0:32,U=10,Z=1023,Y=100,J=4,Q=4,ee=50;r.prototype={get sortKey(){var e=this.columns&&this.columns[this.sortIndex];return e&&e.key},get selectedIndex(){return null!=this.selectedIndexes&&this.selectedIndexes.length>0?this.selectedIndexes[0]:-1},get innerSource(){return this._source},set innerSource(e){this._source=e,this.source=e}},r.COLUMN_TYPE=q,r.prototype.init=function(e){var t=this;if(delete this.$elems.sizeHolder,delete this.$el,this.$refs={},this.$elems={},this._rendering=!0,this._overflows={},this._scrollLeft=0,this.innerSource=this.source,this.virtual=this.source&&this.source.length>this.virtualCount,e=e||this.$parent,"string"==typeof e&&(e=j(e)),null==e)throw new Error("no specified parent.");this.$parent=e;var i=j('
');i.append('');var r=j('');i.on("keydown",function(e){var i=t.selectedIndex,r=!1;if("ArrowUp"===e.key)r=!0,i>1?(delete t.source[i].__selected,i-=1):i=0;else if("ArrowDown"===e.key){r=!0;var n=t.source&&t.source.length||0;i0){var a=this.columns.slice(0,l);this.fixedColumns=a;var d=j('
');e.append(d);var h=z.call(this,!1),c=W.call(this,!1),u=0;a.forEach(function(e){return u+=!1===e.visible?0:e.width+1}),d.css("width",u),d.append(h),null!=c&&d.append(c),R.call(this,!0,!1).insertAfter(h),this.$el_fixed=d}r.remove();var f=j('
');this.$elems.loading=f,i.append(f),this.$el=i,delete this._rendering,this.sortIndex>=0?$.call(this,this.columns[this.sortIndex],!0):null!=this.sortArray&&this.sortArray.length>0?this.sort():this.resize()},r.prototype.sort=function(){var e=this;if(null!=this.sortArray&&0!==this.sortArray.length){this.source.sort(function(t,i){for(var r=0;r0&&y.call(this,i,r)}}},r.prototype.refreshGrid=function(){var e=this;this.$refs.header.find(".data-column-header-filter").removeClass("filtered").addClass("no-filter");var t=null!=this.$refs.header_fixed;t&&this.$refs.header_fixed.find(".data-column-header-filter").removeClass("filtered").addClass("no-filter");for(var i=0;i0){var n=this.$refs.header.children().eq(i);n.find(".data-column-header-filter").removeClass("no-filter").addClass("filtered"),t&&(n=this.$refs.header_fixed.children().eq(i),n.length>0&&n.find(".data-column-header-filter").removeClass("no-filter").addClass("filtered"))}}this.source=this.innerSource.filter(function(t){for(var i=0;i=0?$.call(this,this.columns[this.sortIndex],null,!0):null!=this.sortArray&&this.sortArray.length>0&&this.sort(),this.reset()},r.prototype.resetScroll=function(e){if(null==this.$el)throw new Error("grid view has not been initialized.");null==e&&(e=this.$refs.gridbody[0]);var t=e.scrollLeft;if(this._scrollLeft!==t){this._scrollLeft=t;var i=-t+"px";this.$refs.headerTable[0].style.marginLeft=i,null!=this.$refs.gridtotal&&(this.$refs.gridtotal[0].style.marginLeft=i),"function"==typeof this.hscrolling&&this.hscrolling(-t)}},r.prototype.resize=function(e){if(!this._rendering&&null!=this.$el){var t=this.$refs.gridbody,i=this.$refs.gridbody_fixed,r=this.$refs.headerTable_fixed,n=this.$refs.header.height()+2,s=t[0].offsetTop;s!==n&&(t.css("top",n),null!=i&&i.css("top",n),null!=r&&r.css("height",n),s=n),n=this.height,null==n?n=this.$el.height()-s:0===n&&(n=this.$refs.gridbodyContent.height(),this.$el.css("height",s+n)),t.css("height",n);var l=n;if(null!=i){l-=t[0].offsetHeight-t[0].clientHeight,i.css("height",l),null!=this.$el_fixed&&this.$el_fixed.css("height",s+l)}var o=E.trunc((n-1)/this.rowHeight)+2*J+1;(e||o!==this._bodyRowCount)&&(this._bodyRowCount=o,this.reload());var a=this.$refs.gridbodyContent.width(),d=t[0].clientWidth;this._bodyClientWidth=d;var h=this.$refs.total;if(null==h)return void(this.$refs.gridbodyContainer.height()!==this._containerHeight&&(this.$refs.gridbodyContainer.css("height",this._containerHeight),null!=this.$refs.gridbodyContainer_fixed&&this.$refs.gridbodyContainer_fixed.css("height",this._containerHeight)));var c=this.$refs.gridtotal;c.width()!==a&&c.css("width",a);var u=this.$refs.gridtotalbody.height();if(u>0&&c.height()!==u&&(c.css("height",u),null!=this.$refs.gridtotal_fixed&&this.$refs.gridtotal_fixed.css("height",u),null!=this.$refs.gridtotalbody_fixed&&(this.$refs.gridtotalbody_fixed.css("height",u),this.$refs.gridtotalbody_fixed.children("th:first-child").css("height",u))),this.$refs.gridbodyContent.find("tr.data-grid-row-total-holder").css("height",u),u+=this._containerHeight,this.$refs.gridbodyContainer.height()!==u&&(this.$refs.gridbodyContainer.css("height",u),null!=this.$refs.gridbodyContainer_fixed&&this.$refs.gridbodyContainer_fixed.css("height",u)),0!==d){var f=t[0].offsetWidth-d,p=h[0].style.right;f>0&&""===p?h[0].style.right=f+"px":0===f&&""!==p&&(h[0].style.right="");var g=t[0].offsetHeight-t[0].clientHeight;p=h[0].style.bottom,g>0&&""===p?h[0].style.bottom=g+"px":0===g&&""!==p&&(h[0].style.bottom="")}}},r.prototype.setData=function(e){var t=this;if(null==this.$el)throw new Error("grid view has not been initialized.");this._containerHeight=e.length*this.rowHeight,this._overflows={},this.selectedColumnIndex=-1,this.selectedIndexes=[],this.startIndex=0,this._scrollTop=0,this.$refs.gridbody[0].scrollTop=0,null!=this.$refs.gridbody_fixed&&(this.$refs.gridbody_fixed[0].scrollTop=0),this.$refs.gridbodyContent.css("top",0),null!=this.$refs.gridbodyContent_fixed&&this.$refs.gridbodyContent_fixed.css("top",0),this.$refs.gridbodyContainer.css("height",this._containerHeight),null!=this.$refs.gridbodyContainer_fixed&&this.$refs.gridbodyContainer_fixed.css("height",this._containerHeight),this.virtual=e.length>this.virtualCount,this.innerSource=e,delete this._bodyRowCount;for(var i=this.$refs.header.children(".data-column-header"),r=0;r0?this.refreshGrid():(this.resize(),this.sortIndex>=0?$.call(this,this.columns[this.sortIndex],!0):null!=this.sortArray&&this.sortArray.length>0&&this.sort())},r.prototype.clearHeaderCheckbox=function(){this.$refs.header.find('label>input[type="checkbox"]').each(function(e,t){t.checked=!1})},r.prototype.resetFilter=function(){this.source=this.innerSource;for(var e=0;ei&&(t=i)}this._scrollTop=t;var r=t+"px";this.$refs.gridbodyContent[0].style.top=r,null!=this.$refs.gridbodyContent_fixed&&(this.$refs.gridbodyContent_fixed[0].style.top=r)}this.$refs.gridbody.prop("scrollTop",e),null!=this.$refs.gridbody_fixed&&this.$refs.gridbody_fixed.prop("scrollTop",e)},r.prototype.deleteRow=function(e){if(null==this.$el)throw new Error("grid view has not been initialized.");this.innerSource.splice(e,1),this.reload()},r.prototype.moveRow=function(e,t){var i=this.innerSource[e];if(null!=i&&0!==t){var r=e+t;t>0?r>=this.innerSource.length&&(r=this.innerSource.length-1):r<0&&(r=0),this.innerSource.splice(e,1),this.innerSource.splice(r,0,i),this.refresh()}},r.prototype.closeFilterPanel=function(){j((this.$window||window).document.body).children(".data-column-header-filter-panel").remove()},r.prototype.loading=function(e){!1===e?this.$elems.loading.css({visibility:"hidden",opacity:0}):this.$elems.loading.css({visibility:"visible",opacity:1})},r.prototype.showSortPanel=function(){var e=this,t=window["lib-ui"].createIcon,i=j('
'),n=j('
'),s=new r;s.rowHeight=33,s.lang=this.lang;var l=function(e){n.children(".button-delete").prop("disabled",e<0),n.children(".button-copy").prop("disabled",e<0),n.children(".button-move-up").prop("disabled",e<1),n.children(".button-move-down").prop("disabled",e>=s.source.length-1)};s.selectedrowchanged=l;var o=function(e){s.selectedIndexes=[e],s._containerHeight=s.source.length*s.rowHeight,N.call(s,s.$elems.gridbodyContent),s.refresh(),s.$refs.gridbody.prop("scrollTop",e*s.rowHeight),l(e)};n.append(j("").append(t("fa-light","plus"),j("").text(this.lang.addLevel)).on("click",function(){var e=s.selectedIndex,t={Values:{column:"",order:"asc"}};e>=0?(e+=1,s.source.splice(e,0,t)):(s.source.push(t),e=s.source.length-1),o(e)}),j('').append(t("fa-light","times"),j("").text(this.lang.deleteLevel)).on("click",function(){var e=s.selectedIndex;e<0||(s.source.splice(e,1),e>=s.source.length&&(e=s.source.length-1),o(e))}),j('').append(t("fa-light","copy"),j("").text(this.lang.copyLevel)).on("click",function(){var e=s.selectedIndex;if(!(e<0)){var t=s.source[e];null!=t&&(s.source.splice(e+1,0,{Values:Object.assign({},t.Values)}),o(e+1))}}),j('').append(t("fa-light","chevron-up")).on("click",function(){var e=s.selectedIndex;if(!(e<1)){if(null!=s.source[e]){var t=s.source.splice(e,1)[0];s.source.splice(e-1,0,t),o(e-1)}}}),j('').append(t("fa-light","chevron-down")).on("click",function(){var e=s.selectedIndex;if(!(e>=s.source.length-1)){if(null!=s.source[e]){var t=s.source.splice(e,1)[0];s.source.splice(e+1,0,t),o(e+1)}}}));var a=j('
');i.append(n,a);var d=[{key:"asc",text:this.lang.asc},{key:"desc",text:this.lang.desc}],h=this.columns.filter(function(e){return!1!==e.sortable&&!1!==e.visible}).map(function(e){return{key:e.key,caption:"function"==typeof e.caption?e.caption():e.caption}});s.columns=[{key:"column",caption:this.lang.column,width:270,allowHtml:!0,filter:function(e){var t=j('');return t.dropdown(h,{search:!1,textKey:"caption",valueKey:"key",selected:e.column}).on("select",function(t,i){null!=i&&i.key!==e.column&&(e.column=i.key)}),t},sortable:!1,orderable:!1},{key:"order",caption:this.lang.order,width:150,allowHtml:!0,filter:function(e){var t=j('');return t.dropdown(d,{search:!1,textKey:"text",valueKey:"key",selected:e.order}).on("select",function(t,i){null!=i&&i.key!==e.order&&(e.order=i.key)}),t},sortable:!1,orderable:!1}];var c=new window["lib-ui"].Popup({title:this.lang.sort,content:i[0],resizable:!0,buttons:[{text:this.lang.ok,trigger:function(){var t=s.source;if(null==t||0===t.length)e.sortArray=null;else{for(var i=window["lib-ui"].showAlert,r={},n=0;n0}).map(function(e){return{Values:e}})),s.selectedIndexes=[0],s.refresh(),l(0)})},r.clearGridWidth=function(e,t){B.query("DeleteManagementGridWidth",[e],t,function(){})},r.applyGridWidth=function(e,t,i,r,n){B.management("GetManagementChartGridLayout",[e],function(e){var s=t;if(e.Result&&e.Result.length>0){"function"==typeof n&&n(e.Result),s=[];for(var l=0;l0&&(i.sortIndex=s.length,i.sortDirection=2===h?-1:1),a=t[d];break}null!=a&&s.push(a)}}i.columns=s,i.init(),r&&r()},function(){i.columns=t,i.init(),r&&r()})},r.saveColumnInfo=function(e){return function(){for(var t=[],i=0;i