text: !function(){var a=Fancy,b=a.get(document),c=a.HIDDEN_CLS,d=a.GRID_HEADER_CELL_CLS,e=a.GRID_HEADER_CELL_TEXT_CLS,f=a.GRID_HEADER_CELL_TRIGGER_CLS,g=a.GRID_HEADER_CELL_TRIGGER_IMAGE_CLS,h=a.GRID_HEADER_CELL_GROUP_LEVEL_1_CLS,i=a.GRID_HEADER_CELL_GROUP_LEVEL_2_CLS,j=a.GRID_STATE_DRAG_COLUMN_CLS;a.define("Fancy.grid.plugin.ColumnDrag",{extend:a.Plugin,ptype:"grid.columndrag",inWidgetName:"columndrag",activeSide:void 0,activeCell:void 0,activeIndex:void 0,activeColumn:void 0,inCell:void 0,inIndex:void 0,inSide:void 0,ok:!1,status:"none",constructor:function(a){this.Super("const",arguments)},init:function(){var a=this,b=a.widget;a.Super("init",arguments),b.on("render",function(){a.ons(),a.initHint()})},ons:function(){var a=this;a.widget.el.on("mousedown",a.onMouseDownCell,a,"div."+d)},onMouseDownCell:function(c){var e=this,j=e.widget,k=Fancy.get(c.currentTarget),l=Number(k.attr("index")),m=e.getSideByCell(k),n=j.getColumns(m),o=n[l],p=a.get(c.target);p.hasCls(f)||p.hasCls(g)||(k.hasCls(i)&&(e.activeCellTopGroup=e.getGroupStartEnd(k,m),e.activeCellTopGroup.cell=k),j.startResizing||(e.activeCellTopGroup||!1!==o.draggable)&&(k.hasCls(h)&&(e.activeUnderGroup=!0),e.activeSide=m,e.inSide=m,e.activeCell=k,e.inCell=k,e.activeIndex=Number(k.attr("index")),e.inIndex=e.activeIndex,e.activeColumn=n[e.activeIndex],e.mouseDownX=c.pageX,e.mouseDownY=c.pageY,b.once("mouseup",e.onMouseUp,e),b.on("mousemove",e.onMouseMove,e),j.el.on("mouseleave",e.onMouseLeave,e),j.el.on("mouseenter",e.onMouseEnterCell,e,"div."+d),j.el.on("mousemove",e.onMouseMoveCell,e,"div."+d)))},onMouseLeave:function(){this.hideHint()},onMouseUp:function(){var c=this,e=c.widget,f=!1;if(b.un("mousemove",c.onMouseMove,c),e.el.un("mouseleave",c.onMouseLeave,c),e.el.un("mouseenter",c.onMouseEnterCell,c,"div."+d),e.el.un("mousemove",c.onMouseMoveCell,c,"div."+d),c.ok){if(c.inSide===c.activeSide)c.dragColumn(c.inSide);else if("center"===c.activeSide){var g=c.inIndex;"right"===c.okPosition&&g++,e.moveColumn(c.activeSide,c.inSide,c.activeIndex,g,c.activeCellTopGroup)}else{var g=c.inIndex;"right"===c.okPosition&&g++,e.moveColumn(c.activeSide,c.inSide,c.activeIndex,g,c.activeCellTopGroup)}f=!0}delete c.inUpGroupCell,delete c.inUnderGroup,delete c.activeCellTopGroup,delete c.activeUnderGroup,delete c.activeSide,delete c.activeCell,delete c.activeIndex,delete c.activeIndex,delete c.activeColumn,delete c.mouseDownX,delete c.mouseDownY,c.ok=!1,delete c.okPosition,a.tip.hide(),setTimeout(function(){c.status="none"},1),c.removeDragState(),"dragging"===c.status&&setTimeout(function(){c.status="none",f&&(e.fire("columndrag"),e.scroller.update())},10),c.hideHint()},onMouseMove:function(b){var c=this,d=c.widget,h=d.header,i=d.leftHeader,j=d.rightHeader,k=b.pageX,l=b.pageY,m=d.getColumns(c.activeSide),n=a.get(b.target);if(!n.hasCls(f)&&!n.hasCls(g)&&(Math.abs(k-c.mouseDownX)>10||Math.abs(l-c.mouseDownY))){if(c.activeCellTopGroup?(a.tip.update(c.activeCellTopGroup.cell.select("."+e).item(0).dom.innerHTML||"&nbsp;"),c.status="dragging",c.addDragState()):(a.tip.update(c.activeColumn.title||"&nbsp;"),c.status="dragging",c.addDragState()),1===m.length&&"center"===c.activeSide)return a.tip.hide(),setTimeout(function(){c.status="none"},1),void c.removeDragState();a.tip.show(b.pageX+15,b.pageY+15),h.hideMenu&&(h.hideMenu(),d.leftColumns&&i.hideMenu()&&i.hideMenu(),d.rightColumns&&j.hideMenu()&&j.hideMenu())}},addDragState:function(){this.widget.el.addClass(j)},removeDragState:function(){this.widget.el.removeClass(j)},onMouseEnterCell:function(a){var b=this,c=Fancy.get(a.currentTarget),d=b.getSideByCell(c);b.hideHint(),c.hasCls(h)?b.inUnderGroup=!0:delete b.inUnderGroup,c.hasCls(i)?b.inUpGroupCell=c:delete b.inUpGroupCell,b.inSide=d,b.inCell=c,b.inIndex=Number(c.attr("index"))},onMouseMoveCell:function(a){var b=this,c=b.widget,d=b.inCell,e=parseInt(d.css("width")),g=d.select("."+f),h=Fancy.get(a.target),i=g.within(h)||h.hasClass(f),j=b.activeUnderGroup!==b.inUnderGroup&&!0===b.inUnderGroup,k=b.activeUnderGroup!==b.inUnderGroup&&!0===b.activeUnderGroup;if(1===c.getColumns(b.activeSide).length&&"center"===b.activeSide)return b.ok=!1,void b.hideHint();if(b.activeCellTopGroup)if(b.inUpGroupCell);else{var l=b.activeCellTopGroup.start,m=b.activeCellTopGroup.end;b.activeSide!==b.inSide?(b.ok=!0,a.offsetX>e/2||i?b.showHint("right"):b.showHint("left")):isNaN(b.inIndex)?b.hideHint():b.inIndex<l?a.offsetX>e/2?b.inIndex+1===l?b.hideHint():(b.ok=!0,b.showHint("right")):(b.ok=!0,b.showHint("left")):b.inIndex>m?a.offsetX<e/2?b.inIndex===m+1?b.hideHint():(b.ok=!0,b.showHint("left")):(b.ok=!0,b.showHint("right")):b.hideHint()}else if(b.inUpGroupCell){var n=b.getGroupStartEnd(),l=n.start,m=n.end;b.activeSide!==b.inSide?(b.ok=!0,a.offsetX>e/2||i?b.showHint("right"):b.showHint("left")):a.offsetX>e/2?b.activeIndex>m&&b.activeIndex-1===m?b.hideHint():(b.ok=!0,b.showHint("right")):b.activeIndex<l&&b.activeIndex+1===l?b.hideHint():(b.ok=!0,b.showHint("left"))}else b.activeSide!==b.inSide?(b.ok=!0,a.offsetX>e/2||i?b.showHint("right"):b.showHint("left")):b.activeIndex===b.inIndex?b.ok=!1:b.activeIndex<b.inIndex?a.offsetX>e/2||i?(b.ok=!0,b.showHint("right")):a.offsetX<e/2&&b.activeIndex+1!==b.inIndex?(b.ok=!0,b.showHint("left")):b.activeIndex+1===b.inIndex&&(j||k)?(b.ok=!0,b.showHint("left")):(b.ok=!1,b.hideHint()):b.activeIndex>b.inIndex&&(a.offsetX<e/2?i?j||k?(b.ok=!0,b.showHint("right")):b.activeIndex-1===b.inIndex||b.inUpGroupCell?(b.ok=!1,b.hideHint()):(b.ok=!0,b.showHint("right")):(b.ok=!0,b.showHint("left")):a.offsetX>e/2?b.activeIndex-1===b.inIndex&&(j||k)?(b.ok=!0,b.showHint("right")):b.activeIndex-1!==b.inIndex||b.activeUnderGroup?(b.ok=!0,b.showHint("right")):(b.ok=!1,b.hideHint()):(b.ok=!1,b.hideHint()))},showHint:function(a){var b=this,d=b.widget,e=d.cellHeaderHeight,f=b.inCell,g=b.topEl,h=b.bottomEl,i=f.offset(),j=parseInt(f.css("width")),k=parseInt(f.css("height"));b.okPosition=a,g.removeCls(c),h.removeCls(c);var l=0;"right"===a&&(l+=j),g.css({left:i.left+l-Math.ceil(parseInt(g.css("width"))/2),top:i.top-parseInt(g.css("height"))});var m=i.top+k;if(b.inUpGroupCell){var n=d.header.calcRows();m=i.top+n*e}h.css({left:i.left+l-Math.ceil(parseInt(h.css("width"))/2),top:m})},hideHint:function(){var a=this;a.topEl.addCls(c),a.bottomEl.addCls(c)},initHint:function(){var b=this,d=b.widget,e="fancy-theme-"+d.theme,f=a.get(document.body).dom,g=a.get(document.createElement("div")),h=a.get(document.createElement("div"));g.addCls("fancy-drag-hint-top",c,e),h.addCls("fancy-drag-hint-bottom",c,e),b.topEl=a.get(f.appendChild(g.dom)),b.bottomEl=a.get(f.appendChild(h.dom))},dragColumn:function(a){var b=this,c=b.widget,d=c.getHeader(a),e=c.getBody(a),f=b.activeIndex,g=b.inIndex,h=b.okPosition,i=c.getColumns(a),j=i[f],k=d.calcRows();if(b.activeCellTopGroup){var l=b.activeCellTopGroup.start,m=b.activeCellTopGroup.end,n=i.splice(l,m-l+1),g=b.inIndex;"right"===h&&g++,i=b.inIndex<l?Fancy.Array.insert(i,g,n):Fancy.Array.insert(i,g-n.length,n),c.setColumns(i,a)}else if(b.inUpGroupCell){var o=b.getGroupStartEnd();g=o.start,"right"===h&&(g=o.end+1)}else if("right"===h)if(b.inUnderGroup){var p=i[g].grouping,q=i[g+1];q&&q.grouping===p&&g++}else g++;if(c.groupheader&&!b.activeCellTopGroup){var r=i[g];r&&r.grouping&&b.inUnderGroup?(j.grouping=r.grouping,j.filter&&j.filter.header&&k<3&&delete j.filter):delete j.grouping}b.activeCellTopGroup||(i.splice(f,1),f<g&&g--,i.splice(g,0,j)),e.clearColumnsStyles(),d.updateTitles(),d.updateCellsSizes(),c.groupheader&&(c.header.fixGroupHeaderSizing(),c.leftColumns&&c.leftHeader.fixGroupHeaderSizing(),c.rightColumns&&c.rightHeader.fixGroupHeaderSizing(),d.reSetGroupIndexes()),d.reSetColumnsAlign(),d.reSetColumnsCls(),e.reSetColumnsAlign(),e.reSetColumnsCls(),e.updateColumnsSizes(),c.update()},getSideByCell:function(a){var b,c=this,d=c.widget;return d.centerEl.within(a)?b="center":d.leftEl.within(a)?b="left":d.rightEl.within(a)&&(b="right"),b},getGroupStartEnd:function(b,c){var d=this,e=d.widget,f=e.getHeader(c||d.inSide),g=(b||d.inUpGroupCell).attr("index"),h=f.el.select('[group-index="'+g+'"]'),i=[];return h.each(function(a){i.push(Number(a.attr("index")))}),{start:a.Array.min(i),end:a.Array.max(i)}}})}(),function(){var a=Fancy,b=a.get(document),c=a.HIDDEN_CLS,d=a.GRID_HEADER_CELL_CLS,e=a.GRID_HEADER_CELL_TEXT_CLS,f=a.GRID_HEADER_CELL_TRIGGER_CLS,g=a.GRID_HEADER_CELL_TRIGGER_IMAGE_CLS,h=a.GRID_HEADER_CELL_GROUP_LEVEL_1_CLS,i=a.GRID_HEADER_CELL_GROUP_LEVEL_2_CLS,j=a.GRID_STATE_DRAG_COLUMN_CLS;a.define("Fancy.grid.plugin.ColumnDrag",{extend:a.Plugin,ptype:"grid.columndrag",inWidgetName:"columndrag",activeSide:void 0,activeCell:void 0,activeIndex:void 0,activeColumn:void 0,inCell:void 0,inIndex:void 0,inSide:void 0,ok:!1,status:"none",constructor:function(a){this.Super("const",arguments)},init:function(){var a=this,b=a.widget;a.Super("init",arguments),b.on("render",function(){a.ons(),a.initHint()})},ons:function(){var a=this;a.widget.el.on("mousedown",a.onMouseDownCell,a,"div."+d)},onMouseDownCell:function(c){var e=this,j=e.widget,k=Fancy.get(c.currentTarget),l=Number(k.attr("index")),m=e.getSideByCell(k),n=j.getColumns(m),o=n[l],p=a.get(c.target);p.hasCls(f)||p.hasCls(g)||(k.hasCls(i)&&(e.activeCellTopGroup=e.getGroupStartEnd(k,m),e.activeCellTopGroup.cell=k),j.startResizing||(e.activeCellTopGroup||!1!==o.draggable)&&(k.hasCls(h)&&(e.activeUnderGroup=!0),e.activeSide=m,e.inSide=m,e.activeCell=k,e.inCell=k,e.activeIndex=Number(k.attr("index")),e.inIndex=e.activeIndex,e.activeColumn=n[e.activeIndex],e.mouseDownX=c.pageX,e.mouseDownY=c.pageY,b.once("mouseup",e.onMouseUp,e),b.on("mousemove",e.onMouseMove,e),j.el.on("mouseleave",e.onMouseLeave,e),j.el.on("mouseenter",e.onMouseEnterCell,e,"div."+d),j.el.on("mousemove",e.onMouseMoveCell,e,"div."+d)))},onMouseLeave:function(){this.hideHint()},onMouseUp:function(){var c=this,e=c.widget,f=!1;if(b.un("mousemove",c.onMouseMove,c),e.el.un("mouseleave",c.onMouseLeave,c),e.el.un("mouseenter",c.onMouseEnterCell,c,"div."+d),e.el.un("mousemove",c.onMouseMoveCell,c,"div."+d),c.ok){if(c.inSide===c.activeSide)c.dragColumn(c.inSide);else if("center"===c.activeSide){var g=c.inIndex;"right"===c.okPosition&&g++,e.moveColumn(c.activeSide,c.inSide,c.activeIndex,g,c.activeCellTopGroup)}else{var g=c.inIndex;"right"===c.okPosition&&g++,e.moveColumn(c.activeSide,c.inSide,c.activeIndex,g,c.activeCellTopGroup)}f=!0}delete c.inUpGroupCell,delete c.inUnderGroup,delete c.activeCellTopGroup,delete c.activeUnderGroup,delete c.activeSide,delete c.activeCell,delete c.activeIndex,delete c.activeIndex,delete c.activeColumn,delete c.mouseDownX,delete c.mouseDownY,c.ok=!1,delete c.okPosition,a.tip.hide(),setTimeout(function(){c.status="none"},1),c.removeDragState(),"dragging"===c.status&&setTimeout(function(){c.status="none",f&&(e.fire("columndrag"),e.scroller.update())},10),c.hideHint()},onMouseMove:function(b){var c=this,d=c.widget,h=d.header,i=d.leftHeader,j=d.rightHeader,k=b.pageX,l=b.pageY,m=d.getColumns(c.activeSide),n=a.get(b.target);if(!n.hasCls(f)&&!n.hasCls(g)&&(Math.abs(k-c.mouseDownX)>10||Math.abs(l-c.mouseDownY))){if(c.activeCellTopGroup?(a.tip.update(c.activeCellTopGroup.cell.select("."+e).item(0).dom.innerHTML||"&nbsp;"),c.status="dragging",c.addDragState()):(a.tip.update(c.activeColumn.title||"&nbsp;"),c.status="dragging",c.addDragState()),1===m.length&&"center"===c.activeSide)return a.tip.hide(),setTimeout(function(){c.status="none"},1),void c.removeDragState();a.tip.show(b.pageX+15,b.pageY+15),h.hideMenu&&(h.hideMenu(),d.leftColumns&&i.hideMenu()&&i.hideMenu(),d.rightColumns&&j.hideMenu()&&j.hideMenu())}},addDragState:function(){this.widget.el.addClass(j)},removeDragState:function(){this.widget.el.removeClass(j)},onMouseEnterCell:function(a){var b=this,c=Fancy.get(a.currentTarget),d=b.getSideByCell(c);b.hideHint(),c.hasCls(h)?b.inUnderGroup=!0:delete b.inUnderGroup,c.hasCls(i)?b.inUpGroupCell=c:delete b.inUpGroupCell,b.inSide=d,b.inCell=c,b.inIndex=Number(c.attr("index"))},onMouseMoveCell:function(a){var b=this,c=b.widget,d=b.inCell,e=parseInt(d.css("width")),g=d.select("."+f),h=Fancy.get(a.target),i=g.within(h)||h.hasClass(f),j=b.activeUnderGroup!==b.inUnderGroup&&!0===b.inUnderGroup,k=b.activeUnderGroup!==b.inUnderGroup&&!0===b.activeUnderGroup;if(1===c.getColumns(b.activeSide).length&&"center"===b.activeSide)return b.ok=!1,void b.hideHint();if(b.activeCellTopGroup)if(b.inUpGroupCell);else{var l=b.activeCellTopGroup.start,m=b.activeCellTopGroup.end;b.activeSide!==b.inSide?(b.ok=!0,a.offsetX>e/2||i?b.showHint("right"):b.showHint("left")):isNaN(b.inIndex)?b.hideHint():b.inIndex<l?a.offsetX>e/2?b.inIndex+1===l?b.hideHint():(b.ok=!0,b.showHint("right")):(b.ok=!0,b.showHint("left")):b.inIndex>m?a.offsetX<e/2?b.inIndex===m+1?b.hideHint():(b.ok=!0,b.showHint("left")):(b.ok=!0,b.showHint("right")):b.hideHint()}else if(b.inUpGroupCell){var n=b.getGroupStartEnd(),l=n.start,m=n.end;b.activeSide!==b.inSide?(b.ok=!0,a.offsetX>e/2||i?b.showHint("right"):b.showHint("left")):a.offsetX>e/2?b.activeIndex>m&&b.activeIndex-1===m?b.hideHint():(b.ok=!0,b.showHint("right")):b.activeIndex<l&&b.activeIndex+1===l?b.hideHint():(b.ok=!0,b.showHint("left"))}else b.activeSide!==b.inSide?(b.ok=!0,a.offsetX>e/2||i?b.showHint("right"):b.showHint("left")):b.activeIndex===b.inIndex?b.ok=!1:b.activeIndex<b.inIndex?a.offsetX>e/2||i?(b.ok=!0,b.showHint("right")):a.offsetX<e/2&&b.activeIndex+1!==b.inIndex?(b.ok=!0,b.showHint("left")):b.activeIndex+1===b.inIndex&&(j||k)?(b.ok=!0,b.showHint("left")):(b.ok=!1,b.hideHint()):b.activeIndex>b.inIndex&&(a.offsetX<e/2?i?j||k?(b.ok=!0,b.showHint("right")):b.activeIndex-1===b.inIndex||b.inUpGroupCell?(b.ok=!1,b.hideHint()):(b.ok=!0,b.showHint("right")):(b.ok=!0,b.showHint("left")):a.offsetX>e/2?b.activeIndex-1===b.inIndex&&(j||k)?(b.ok=!0,b.showHint("right")):b.activeIndex-1!==b.inIndex||b.activeUnderGroup?(b.ok=!0,b.showHint("right")):(b.ok=!1,b.hideHint()):(b.ok=!1,b.hideHint()))},showHint:function(a){var b=this,d=b.widget,e=d.cellHeaderHeight,f=b.inCell,g=b.topEl,h=b.bottomEl,i=f.offset(),j=parseInt(f.css("width")),k=parseInt(f.css("height"));b.okPosition=a,g.removeCls(c),h.removeCls(c);var l=0;"right"===a&&(l+=j),g.css({left:i.left+l-Math.ceil(parseInt(g.css("width"))/2),top:i.top-parseInt(g.css("height"))});var m=i.top+k;if(b.inUpGroupCell){var n=d.header.calcRows();m=i.top+n*e}h.css({left:i.left+l-Math.ceil(parseInt(h.css("width"))/2),top:m})},hideHint:function(){var a=this;a.topEl.addCls(c),a.bottomEl.addCls(c)},initHint:function(){var b=this,d=b.widget,e="fancy-theme-"+d.theme,f=a.get(document.body).dom,g=a.get(document.createElement("div")),h=a.get(document.createElement("div"));g.addCls("fancy-drag-hint-top",c,e),h.addCls("fancy-drag-hint-bottom",c,e),b.topEl=a.get(f.appendChild(g.dom)),b.bottomEl=a.get(f.appendChild(h.dom))},dragColumn:function(a){var b=this,c=b.widget,d=c.getHeader(a),e=c.getBody(a),f=b.activeIndex,g=b.inIndex,h=b.okPosition,i=c.getColumns(a),j=i[f],k=d.calcRows();if(b.activeCellTopGroup){var l=b.activeCellTopGroup.start,m=b.activeCellTopGroup.end,n=i.splice(l,m-l+1),g=b.inIndex;"right"===h&&g++,i=b.inIndex<l?Fancy.Array.insert(i,g,n):Fancy.Array.insert(i,g-n.length,n),c.setColumns(i,a)}else if(b.inUpGroupCell){var o=b.getGroupStartEnd();g=o.start,"right"===h&&(g=o.end+1)}else if("right"===h)if(b.inUnderGroup){var p=i[g].grouping,q=i[g+1];q&&q.grouping===p&&g++}else g++;if(c.groupheader&&!b.activeCellTopGroup){var r=i[g];r&&r.grouping&&b.inUnderGroup?(j.grouping=r.grouping,j.filter&&j.filter.header&&k<3&&delete j.filter):delete j.grouping}b.activeCellTopGroup||(i.splice(f,1),f<g&&g--,i.splice(g,0,j)),e.clearColumnsStyles(),d.updateTitles(),d.updateCellsSizes(),c.groupheader&&(c.header.fixGroupHeaderSizing(),c.leftColumns&&c.leftHeader.fixGroupHeaderSizing(),c.rightColumns&&c.rightHeader.fixGroupHeaderSizing(),d.reSetGroupIndexes()),d.reSetColumnsAlign(),d.reSetColumnsCls(),e.reSetColumnsAlign(),e.reSetColumnsCls(),e.updateColumnsSizes(),c.update()},getSideByCell:function(a){var b,c=this,d=c.widget;return d.centerEl.within(a)?b="center":d.leftEl.within(a)?b="left":d.rightEl.within(a)&&(b="right"),b},getGroupStartEnd:function(b,c){var d=this,e=d.widget,f=e.getHeader(c||d.inSide),g=(b||d.inUpGroupCell).attr("index"),h=f.el.select('[group-index="'+g+'"]'),i=[];return h.each(function(a){i.push(Number(a.attr("index")))}),{start:a.Array.min(i),end:a.Array.max(i)}}})}();