/*!@license
 * Infragistics.Web.ClientUI Grid Selection (and Keyboard navigation) 13.1.20131.2523
 *
 * Copyright (c) 2011-2014 Infragistics Inc.
 *
 * http://www.infragistics.com/
 *
 * Depends on:
 *	jquery-1.4.4.js
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 *	infragistics.ui.grid.framework.js
 *	infragistics.ui.shared.js
 *	infragistics.dataSource.js
 *	infragistics.util.js
 *	modernizr.js
 */
if(typeof jQuery!=="function"){throw new Error("jQuery is undefined")}(function($){$.widget("ui.igGridSelection",{css:{selectedCell:"ui-iggrid-selectedcell ui-state-active",selectedRow:"ui-iggrid-selectedrow ui-state-active",activeCell:"ui-iggrid-activecell ui-state-focus",activeRow:"ui-iggrid-activerow ui-state-focus"},options:{multipleSelection:false,mouseDragSelect:true,mode:"row",activation:true,wrapAround:true,skipChildren:true,multipleCellSelectOnClick:false,touchDragSelect:true},events:{rowSelectionChanging:"rowSelectionChanging",rowSelectionChanged:"rowSelectionChanged",cellSelectionChanging:"cellSelectionChanging",cellSelectionChanged:"cellSelectionChanged",activeCellChanging:"activeCellChanging",activeCellChanged:"activeCellChanged",activeRowChanging:"activeRowChanging",activeRowChanged:"activeRowChanged"},_create:function(){this._isMouseDown=false;this._isDrag=false;this._registeredEvents=false;this.y_exclude_current=0;this.x_exclude_current=0},_setOption:function(key,value){$.Widget.prototype._setOption.apply(this,arguments);if(key==="mode"){throw new Error($.ig.Grid.locale.optionChangeNotSupported+" "+key)}},_dataRendering:function(e,args){var tbody;if(args.owner.id()!==this.grid.id()){return}tbody=this.grid.element.find("tbody");if(this._mouseDownHandler){tbody.unbind({mousedown:this._mouseDownHandler,mousemove:this._mouseMoveHandler,mouseup:this._mouseUpHandler,selectstart:this._selectStartHandler});if(this._touchEvents){tbody.unbind({touchstart:this._touchStartHandler,touchend:this._touchEndHandler,MSPointerDown:this._touchStartHandler,MSPointerMove:this._touchMoveHandler,MSPointerUp:this._touchEndHandler,pointerdown:this._touchStartHandler,pointermove:this._touchMoveHandler,pointerup:this._touchEndHandler});tbody[0].removeEventListener("touchmove",this._touchMoveHandler)}}},_dataRendered:function(){if(!this._registeredEvents){this._registerEvents();this._registeredEvents=true}else{this._registerTbodyEvents()}if(this._hc===undefined){this._hc=this.grid.container().closest(".ui-iggrid-root").length>0;if(this._hc===false){this._hc=this.grid.element.hasClass("ui-iggrid-root")}}if(this._hc){this._hgrid=this.grid.element.closest(".ui-iggrid-root")}if(this._groupBy===undefined){this._groupBy=this.grid.container().find(".ui-iggrid-groupbyarea").length>0}this._refresh(true);if(!this._initialSelectionInitialized){if(this.options.selectedRowIndex!==undefined&&this.options.selectedRowIndex!==null&&this.options.selectedRowIndex>=0){if(this.options.selectedCellIndex===undefined){this.selectRow(this.options.selectedRowIndex)}else if(this.options.selectedCellIndex!==undefined&&this.options.selectedRowIndex!==null&&this.options.selectedCellIndex>=0){this.selectCell(this.options.selectedRowIndex,this.options.selectedCellIndex)}}this._initialSelectionInitialized=true}this.grid._startRowIndex=this.grid._startRowIndex||0},_refresh:function(init){if(!init||!(this._firstCell&&this._firstCell.length!==0)){this._firstCell=this.grid.element.children("tbody").children("tr:visible:nth-child(1) td:nth-child(1)");if(!this._firstCell){this._firstRow=this.grid.element.children("tbody").children("tr:visible:nth-child(1)")}}if(!init||!(this._firstRow&&this._firstRow.length!==0)||!this._rowCount){this._firstRow=this.grid.element.children("tbody").children("tr:visible:nth-child(1)");if(this.grid.options.virtualization||this.grid.options.rowVirtualization){this._rowCount=this.grid.dataSource.dataView().length}else{this._rowCount=this.grid.element.find("tbody tr").length}this._length=this._firstRow?this._firstRow.children().length:0}this.x_exclude_current=this._calcExtraCells()},_registerTbodyEvents:function(){var tbody=this.grid.element.find("tbody"),opts=this.options;if(!this._mouseDownHandler){this._mouseDownHandler=$.proxy(this._mouseDown,this);this._selectStartHandler=$.proxy(this._selectStart,this);this._mouseMoveHandler=$.proxy(this._dragSelectChange,this);this._mouseUpHandler=$.proxy(this._selectInternal,this);if((typeof Modernizr==="object"&&Modernizr.touch===true||window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&opts.multipleSelection===true&&opts.mode==="cell"&&opts.touchDragSelect===true){this._touchStartHandler=$.proxy(this._touchStart,this);this._touchEndHandler=$.proxy(this._touchEnd,this);this._touchMoveHandler=$.proxy(this._touchMove,this);this._touchEvents=true}}else{tbody.unbind({mousedown:this._mouseDownHandler,mousemove:this._mouseMoveHandler,mouseup:this._mouseUpHandler,selectstart:this._selectStartHandler});if(this._touchEvents){tbody.unbind({touchstart:this._touchStartHandler,touchend:this._touchEndHandler,MSPointerDown:this._touchStartHandler,MSPointerMove:this._touchMoveHandler,MSPointerUp:this._touchEndHandler,pointerdown:this._touchStartHandler,pointermove:this._touchMoveHandler,pointerup:this._touchEndHandler});tbody[0].removeEventListener("touchmove",this._touchMoveHandler)}}tbody.bind({mousedown:this._mouseDownHandler,mousemove:this._mouseMoveHandler,mouseup:this._mouseUpHandler,selectstart:this._selectStartHandler});if(this._touchEvents){tbody.bind({touchstart:this._touchStartHandler,touchend:this._touchEndHandler,MSPointerDown:this._touchStartHandler,MSPointerMove:this._touchMoveHandler,MSPointerUp:this._touchEndHandler,pointerdown:this._touchStartHandler,pointermove:this._touchMoveHandler,pointerup:this._touchEndHandler});tbody[0].addEventListener("touchmove",this._touchMoveHandler)}},_registerFixedTbodyEvents:function(){var tbody=this.grid.fixedContainer().find("tbody"),opts=this.options;if(!this._mouseDownFixedHandler){this._mouseDownFixedHandler=$.proxy(this._mouseDown,this);this._selectStartFixedHandler=$.proxy(this._selectStart,this);this._mouseMoveFixedHandler=$.proxy(this._dragSelectChange,this);this._mouseUpFixedHandler=$.proxy(this._selectInternal,this);if((typeof Modernizr==="object"&&Modernizr.touch===true||window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&opts.multipleSelection===true&&opts.mode==="cell"&&opts.touchDragSelect===true){this._touchStartFixedHandler=$.proxy(this._touchStart,this);this._touchEndFixedHandler=$.proxy(this._touchEnd,this);this._touchMoveFixedHandler=$.proxy(this._touchMove,this);this._touchEvents=true}}else{tbody.unbind({mousedown:this._mouseDownFixedHandler,mousemove:this._mouseMoveFixedHandler,mouseup:this._mouseUpFixedHandler,selectstart:this._selectStartFixedHandler});if(this._touchEvents){tbody.unbind({touchstart:this._touchStartFixedHandler,touchend:this._touchEndFixedHandler,MSPointerDown:this._touchStartFixedHandler,MSPointerMove:this._touchMoveFixedHandler,MSPointerUp:this._touchEndFixedHandler,pointerdown:this._touchStartHandler,pointermove:this._touchMoveHandler,pointerup:this._touchEndHandler});tbody[0].removeEventListener("touchmove",this._touchMoveFixedHandler)}}tbody.bind({mousedown:this._mouseDownFixedHandler,mousemove:this._mouseMoveFixedHandler,mouseup:this._mouseUpFixedHandler,selectstart:this._selectStartFixedHandler});if(this._touchEvents){tbody.bind({touchstart:this._touchStartFixedHandler,touchend:this._touchEndFixedHandler,MSPointerDown:this._touchStartFixedHandler,MSPointerMove:this._touchMoveFixedHandler,MSPointerUp:this._touchEndFixedHandler,pointerdown:this._touchStartHandler,pointermove:this._touchMoveHandler,pointerup:this._touchEndHandler});tbody[0].addEventListener("touchmove",this._touchMoveFixedHandler)}},_registerEvents:function(){this._registerTbodyEvents();if(this._releaseMouseHandler===null||this._releaseMouseHandler===undefined){this._releaseMouseHandler=$.proxy(this._releaseMouse,this)}$(document).bind({mouseup:this._releaseMouseHandler});if(this.grid.options.virtualization){$("#"+this.grid.element[0].id+"_scrollContainer").bind({scroll:$.proxy(this._releaseMouse,this)})}else{$("#"+this.grid.element[0].id+"_scroll").bind({scroll:$.proxy(this._releaseMouse,this)})}this._keyDownHandler=$.proxy(this._navigate,this);this._focusHandler=$.proxy(this._navigateFocus,this);this._markMouseDownHandler=$.proxy(this._markMouseDown,this);if(this.grid.options.virtualization||this.grid.options.rowVirtualization){$("#"+this.grid.element[0].id+"_displayContainer_a").bind({keydown:this._keyDownHandler,focus:this._focusHandler})}else{this.grid.container().bind({keydown:this._keyDownHandler,focus:this._focusHandler})}if(this.options.multipleSelection===true){this.grid.element.addClass("ui-iggrid-canceltextselection")}},_unregisterEvents:function(){var tbody=this.grid.element.find("tbody");this.grid.element.unbind("mousedown",this._mouseDownHandler);this.grid.element.unbind("selectstart",this._selectStartHandler);this.grid.element.unbind("mousemove",this._mouseMoveHandler);this.grid.element.unbind("mouseup",this._mouseUpHandler);this.grid.container().unbind("keydown",this._keyDownHandler);this.grid.container().unbind("focus",this._focusHandler);this.grid.container().unbind("mousedown",this._markMouseDownHandler);this.grid.element.unbind("iggriduisoftdirty",this._uiDirtyHandler);this.grid.element.unbind("ighierarchicalgridrowexpanded",this._rowExpandedHandler);this.grid.element.unbind("iggridcolumnscollectionmodified",this._columnsCollectionModifiedHandler);this.grid.element.unbind("iggridvirtualrecordsrender",this._virtualRecordsRendererHandler);tbody.unbind({mousedown:this._mouseDownHandler,mousemove:this._mouseMoveHandler,mouseup:this._mouseUpHandler,selectstart:this._selectStartHandler});if(this._touchEvents){tbody.unbind({touchstart:this._touchStartHandler,touchend:this._touchEndHandler,MSPointerDown:this._touchStartHandler,MSPointerMove:this._touchMoveHandler,MSPointerUp:this._touchEndHandler,pointerdown:this._touchStartHandler,pointermove:this._touchMoveHandler,pointerup:this._touchEndHandler});tbody[0].removeEventListener("touchmove",this._touchMoveHandler)}if(this._releaseMouseHandler){$(document).unbind({mouseup:this._releaseMouseHandler});delete this._releaseMouseHandler}delete this._mouseDownHandler;delete this._selectStartHandler;delete this._mouseMoveHandler;delete this._mouseUpHandler;delete this._keyDownHandler;delete this._focusHandler;delete this._markMouseDownHandler;delete this._uiDirtyHandler;delete this._rowExpandedHandler;delete this._columnsCollectionModifiedHandler;delete this._virtualRecordsRendererHandler;delete this._touchEvents;this.grid.element.removeClass("ui-iggrid-canceltextselection")},_dragSelectChange:function(event){var selectedCells=[],startRowIndex,startColIndex,endRowIndex,endColIndex,outgrid,currentCell,tmp,noCancel=true,v=this.grid.options.virtualization||this.grid.options.rowVirtualization;if(event&&this._suspend){return}if(!this._prevX&&!this._prevY){this._prevX=event.clientX;this._prevY=event.clientY}if(Math.abs(this._prevX-event.clientX)<5&&Math.abs(this._prevY-event.clientY)<5){return}this._prevX=event.clientX;this._prevY=event.clientY;if(this.options.mouseDragSelect===false||this.options.multipleSelection===false||this.options.mode==="row"){return}if(this._isMouseDown===true){this._isDrag=true}else{return}if(this._isMouseDown!==true||this.options.mode!=="cell"){return}if(this._hc&&event&&event.target){outgrid=$(event.target).closest(".ui-iggrid-table");if(outgrid.length>0&&outgrid.attr("id")!==this.grid.element.attr("id")){event.stopPropagation();event.preventDefault();return}}currentCell=this._cellFromEvent(event);if(!currentCell){return}if(currentCell&&this.activeCell()&&currentCell.index===this.activeCell().index&&currentCell.rowIndex===this.activeCell().rowIndex){return}if(this._touchEvents&&!(window.navigator.msPointerEnabled||window.navigator.pointerEnabled)){event={originalEvent:event}}noCancel=this._trigger(this.events.cellSelectionChanging,event,{cell:currentCell,selectedCells:this.grid._selectedCells,owner:this,manual:false});if(noCancel){if(this.options.activation===true){this._activateCell(currentCell,event)}startRowIndex=this._firstDragCell.rowIndex;startColIndex=this._firstDragCell.index+this._firstDragCell.element.parent().children("[data-skip=true]").length;endRowIndex=currentCell.rowIndex;endColIndex=currentCell.index+this._firstDragCell.element.parent().children("[data-skip=true]").length;if(endRowIndex<startRowIndex){tmp=startRowIndex;startRowIndex=endRowIndex;endRowIndex=tmp}if(currentCell.isFixed===this._firstDragCell.isFixed&&endColIndex<startColIndex){tmp=startColIndex;startColIndex=endColIndex;endColIndex=tmp}if(currentCell.isFixed!==this._firstDragCell.isFixed&&(this._lastSelectedIndex===undefined||this._lastSelectedIndex===null)){if(currentCell.isFixed===true){this._lastSelectedIndex=this.grid._selectedCells[this.grid._selectedCells.length-1].index}else{this._lastSelectedIndex=endColIndex}}this.clearSelection(true);if(v){startRowIndex-=this.grid._startRowIndex;endRowIndex-=this.grid._startRowIndex}this._selectCell(startRowIndex,endRowIndex,startColIndex,endColIndex,currentCell.isFixed);this._currentCells=selectedCells;this._trigger(this.events.cellSelectionChanged,event,{cell:currentCell,selectedCells:this.grid._selectedCells,owner:this,manual:false})}},_touchStart:function(event){event.clientX=event.originalEvent.touches?event.originalEvent.touches[0].pageX:event.originalEvent.clientX;event.clientY=event.originalEvent.touches?event.originalEvent.touches[0].pageY:event.originalEvent.clientY;if(this._cellFromEvent(event).element.hasClass(this.css.selectedCell)){this.grid.element.css("-ms-touch-action","none");this._touchDragStart=true}},_touchEnd:function(event){if(this._touchDragStart){this._isMouseDown=false}this._touchDragStart=false;this._isDrag=false;this.grid.element.find("tbody").css("-ms-touch-action","auto")},_touchMove:function(event){if(!this._touchDragStart){return true}event.preventDefault();event.clientX=event.touches?event.touches[0].pageX:event.originalEvent.clientX;event.clientY=event.touches?event.touches[0].pageY:event.originalEvent.clientY;this._touchDragStart=true;this._isMouseDown=true;this._dragSelectChange(event)},_selectCell:function(startRowIndex,endRowIndex,startColIndex,endColIndex,isFixed){var i,j,cell;for(i=startRowIndex;i<=endRowIndex;i++){for(j=startColIndex;j<=endColIndex;j++){cell=$(this.grid.cellAt(j,i,isFixed)).addClass(this.css.selectedCell);this.grid._selectedCells.push(this._cellFromElement(cell,i+this.grid._startRowIndex,j,isFixed))}}},_cellFromEvent:function(event){var target,$target,isFixed=false;if(this._touchEvents===true){$target=$(document.elementFromPoint(event.clientX,event.clientY))}else{$target=$(event.originalEvent.originalTarget||event.originalEvent.srcElement)}target=$target.is("td,th")?$target[0]:$target.closest("td,th")[0];if(this.grid.hasFixedColumns()){isFixed=$target.closest("div").attr("data-fixed-container")!==undefined}return this._cellFromElement(target,undefined,undefined,isFixed)},_cellFromElement:function(e,row,col,isFixed){var $target,parent,parentIndex,cellIndex,key=null,tmpIndex;if(isFixed===null||isFixed===undefined){isFixed=false}$target=$(e);parent=$target.parent();if(row===undefined||col===undefined){cellIndex=$target.index();parentIndex=parent.index();if(this.grid.options.virtualization||this.grid.options.rowVirtualization||this.grid.options.columnVirtualization){if(this.grid._startRowIndex>0){parentIndex+=this.grid._startRowIndex}if(this.grid._startColIndex>0){cellIndex+=this.grid._startColIndex}}}else{cellIndex=col;parentIndex=row}if(cellIndex===-1){return}if(cellIndex-this.x_exclude_current<0){tmpIndex=0}else if(cellIndex-this.x_exclude_current>=this.grid._visibleColumns().length){tmpIndex=this.grid._visibleColumns().length-1}else{tmpIndex=cellIndex-this.x_exclude_current}if(this._hc===true&&cellIndex-this.x_exclude_current<this.grid._visibleColumns().length||$target.siblings("th").length>0){tmpIndex--}if(tmpIndex>=0&&this.grid._visibleColumns().length>tmpIndex){key=this.grid._visibleColumns()[tmpIndex].key}if(this.y_exclude_current!==undefined){parentIndex-=this.y_exclude_current}if(this.x_exclude_current!==undefined){cellIndex-=this.x_exclude_current}return{element:$target,row:parent,index:cellIndex,rowIndex:parentIndex,columnKey:key,isFixed:isFixed}},_mouseDown:function(event){var v=this.grid.options.virtualization||this.grid.options.rowVirtualization||this.grid.options.columnVirtualization,outgrid,ncv=this.grid.options.virtualizationMode!=="continuous";if(event&&this._suspend){return}if(event.target&&$(event.target).hasClass("ui-iggrid-scrolldiv")){return}if(event&&event.which===0){event.which=1}if(event&&event.which!==1){return}if(this._hc&&event&&event.target){outgrid=$(event.target).closest(".ui-iggrid-table");if(outgrid.length>0&&outgrid.attr("id")!==this.grid.element.attr("id")){return}}if(event.target&&$(event.target).closest("td").attr("data-skip")==="true"){event.stopPropagation();event.preventDefault();$(event.target).trigger("iggridselectionmousedown");return}if(event.which===2){return}this._isMouseDown=true;if(this.options.multipleSelection===false&&v&&ncv){$("#"+this.grid.element[0].id+"_displayContainer_a").focus();if((this.grid.options.virtualization||this.grid.options.rowVirtualization)&&this.grid.options.virtualizationMode==="continuous"){event.preventDefault()}}if(this.options.mouseDragSelect===false||this.options.multipleSelection===false){return}this._mouseLocation={clientX:event.clientX,clientY:event.clientY};this._firstDragCell=this._cellFromEvent(event);this._lastSelectedIndex=null;if(!event.ctrlKey&&!event.shiftKey&&this.options.multipleSelection!==true){this.clearSelection(true)}this._isInternalFocus=true;if(this.options.multipleSelection===true&&v&&ncv){$("#"+this.grid.element[0].id+"_displayContainer_a").focus()}if(!$(event.target).hasClass("ui-iggrid-expandbutton")&&!$(event.target).hasClass("ui-iggrid-expandcolumn")&&!$(event.target).hasClass("ui-iggrid-expandbuttongb")){if(v){event.stopPropagation();event.preventDefault()}$(event.target).trigger("iggridselectionmousedown")}},_markMouseDown:function(event){this._isMouseDown=true},_selectStart:function(event){if(event.target&&$(event.target).closest(".ui-iggrid-table").attr("id")!==this.grid.id()){return}if(event&&this._suspend){return}if(this.options.mouseDragSelect===false||this.options.multipleSelection===false){return false}event.stopPropagation();event.preventDefault()},_releaseMouse:function(){this._isMouseDown=false;this._isDrag=false},_selectInternal:function(event,row,col,isFixed){var target,parent,$target,gridCell,gridRow,i,noCancel=true,isInternal=false,vindex,isRs,outgrid,contSelection,fixedGridRow,cs,self=this,isRowSelection=false,parentIndex,v,excludeTmp,hasFixedColumns=this.grid.hasFixedColumns(),clickedOnFixedContainer=false,selectedRowIndex,sri;sri=this.grid._startRowIndex||0;v=this.grid.options.virtualization||this.grid.options.columnVirtualization||this.grid.options.rowVirtualization;if(!this._isMouseDown&&event){return}if(event&&event.which===0){event.which=1}if(event&&event.which!==1){return}if(event!==null&&event.target&&($(event.target).hasClass("ui-iggrid-childarea")||$(event.target).parent().hasClass("ui-iggrid-childarea")||$(event.target).hasClass("ui-widget-header"))){return}if(event===null){isInternal=true;excludeTmp=this.y_exclude_current;if(this._isContinuous||isInternal){excludeTmp=0}vindex=row-sri<0?0:row-sri+excludeTmp;event={originalEvent:{}};if(col===null||col===undefined){isRowSelection=true;if(v){event.originalEvent.originalTarget=this.grid.rowAt(vindex)}else{event.originalEvent.originalTarget=this.grid.rowAt(row-excludeTmp)}}else{if(v){event.originalEvent.originalTarget=this.grid.cellAt(col,vindex,isFixed)}else{event.originalEvent.originalTarget=this.grid.cellAt(col+this.x_exclude_current,row-excludeTmp,isFixed)}}event.originalEvent.srcElement=event.originalEvent.originalTarget}target=event.originalEvent.originalTarget||event.originalEvent.srcElement;$target=$(target);if(hasFixedColumns){clickedOnFixedContainer=$target.closest("div").attr("data-fixed-container")!==undefined}isRs=$target.closest("th.ui-iggrid-rowselector-class").length===1;if(event&&$target.is("span")&&($target.attr("data-chk")!==undefined||$target.parent().attr("data-chk")!==undefined)){this._mouseCtrlSelect=true;return}if(this._hc){outgrid=$target.closest(".ui-iggrid-table");if(outgrid.length>0&&outgrid.attr("id")!==this.grid.element.attr("id")){if(event&&!isInternal){event.preventDefault();this._isMouseDown=false;this._isDrag=false}return}$target.parents("tr[data-container]").each(function(){if($(this).closest(".ui-iggrid-table").attr("id")===self.grid.element.attr("id")){cs=true;return false}});if(cs){return}if(this._hgrid&&this._hgrid.data("data-selectgrid")!==this.grid.element.attr("id")){this.clearSelectionAllOthers(false,true);this._hgrid.data("data-selectgrid",this.grid.element.attr("id"))}}if(this._hc&&this._hdirty){this.y_exclude_current=this._excludeRowsLt($target.closest("tr"))}else if(!this._hc){this.y_exclude_current=0}if(this.x_exclude_current===undefined){this.x_exclude_current=this._calcExtraCells()}if(event&&this._suspend){return}if(event&&event.which===2){return}if(this._isDrag===true&&event!==null){this._isDrag=false;return}parent=$target.closest("tr");if($target.closest("th").length>0&&isRs===false){return}if($target.closest("td").attr("data-skip")==="true"){return}if(event.ctrlKey){this._isContinuous=false;this._mouseCtrlSelect=true}if(this.options.multipleCellSelectOnClick===true&&this.options.mode==="cell"&&this.activeCell()){this._isContinuous=false;this._mouseCtrlSelect=true;contSelection=true}if(this.options.mode==="cell"&&isRowSelection===false){if(isRs===true){if(isInternal===true){target=$target.is("th")?$target[0]:$target.closest("th")[0]}else{target=$target.is("th")?$target.next()[0]:$target.closest("th").next()[0]}}else{target=$target.is("td")?$target[0]:$target.closest("td")[0]}gridCell=this._cellFromElement(target,undefined,undefined,clickedOnFixedContainer,isFixed);if(this.options.activation===true&&this._rangeSelect!==true&&this._singleShiftSelect!==true&&this._ctrlSelect!==true){if(this.activeCell()&&gridCell&&this._mouseCtrlSelect!==true&&gridCell.isFixed===this.activeCell().isFixed&&gridCell.index===this.activeCell().index&&gridCell.rowIndex===this.activeCell().rowIndex){return}if(this._mouseCtrlSelect!==true){this._activateCell(gridCell,event)}else if(this.activeCell()&&(gridCell.index!==this.activeCell().index||gridCell.rowIndex!==this.activeCell().rowIndex)){this._activateCell(gridCell,event)}}}else{if(isInternal){parent=$(target)}parentIndex=parent.index();selectedRowIndex=parentIndex+sri-this.y_exclude_current;if(clickedOnFixedContainer){parent=this.grid.scrollContainer().find("tr:nth-child("+(selectedRowIndex+1)+")")}gridRow={element:parent,index:selectedRowIndex,id:parent.data()?parent.data().id:null};if(hasFixedColumns){fixedGridRow={element:this.grid.fixedContainer().find("tr:nth-child("+(selectedRowIndex+1)+")"),index:selectedRowIndex,id:parent.data()?parent.data().id:null}}if(gridRow.element.attr("data-container")){return}if(this.options.activation===true&&this._rangeSelect!==true&&this._singleShiftSelect!==true&&this._ctrlSelect!==true){if(!(this.activeRow()&&gridRow&&this._mouseCtrlSelect!==true&&gridRow.index===this.activeRow().index)){if(this._mouseCtrlSelect!==true){this._activateRow(gridRow,event,fixedGridRow)}else if(this.activeRow()&&gridRow.index!==this.activeRow().index){this._activateRow(gridRow,event,fixedGridRow)}}}}if(this.options.mode==="row"&&this.grid._selectedRow&&this._singleShiftSelect!==true&&this._ctrlSelect!==true&&this._mouseCtrlSelect!==true&&this.options.multipleSelection!==true&&gridRow&&gridRow.index===this.grid._selectedRow.index){return}if(this.options.mode==="cell"&&this.grid._selectedCell&&gridCell&&this._singleShiftSelect!==true&&this._ctrlSelect!==true&&this._mouseCtrlSelect!==true&&gridCell.isFixed===this.grid._selectedCell.isFixed&&gridCell.index===this.grid._selectedCell.index&&gridCell.rowIndex===this.grid._selectedCell.rowIndex){return}if(isInternal===false&&this.options.mode==="cell"||isInternal===true&&isRowSelection===false){if(isInternal===false&&!event.shiftKey||this._ctrlSelect===true){noCancel=this._trigger(this.events.cellSelectionChanging,event,{cell:gridCell,selectedCells:this.grid._selectedCells,owner:this,manual:isInternal})}if(noCancel&&gridCell&&gridCell.element&&!gridCell.element.hasClass("ui-iggrid-expandcolumn")&&!gridCell.element.hasClass("ui-iggrid-rowselector-class")){if(this.options.multipleSelection!==true){if(this.grid._selectedCell!==null){if(v){$(this.grid.cellAt(this.grid._selectedCell.index,this.grid._selectedCell.rowIndex-sri,isFixed)).removeClass(this.css.selectedCell)}else{this.grid._selectedCell.element.removeClass(this.css.selectedCell)}}if(this.grid._selectedRow!==null&&this.grid._selectedRow!==undefined){if(v){this.grid.rowAt(this.grid._selectedRow.index-sri).children().removeClass(this.css.selectedCell)}else{this.grid._selectedRow.element.children().removeClass(this.css.selectedCell)}}if(this.grid._selectedFixedRow!==null&&this.grid._selectedFixedRow!==undefined){this.grid._selectedFixedRow.element.children().removeClass(this.css.selectedCell)}}else{if(event.ctrlKey||this._ctrlSelect===true||contSelection===true){if(gridCell.element.hasClass(this.css.selectedCell)){for(i=0;i<this.grid._selectedCells.length;i++){if(this.grid._selectedCells[i].element&&this.grid._selectedCells[i].element.length>0){if(this.grid._selectedCells[i].element.index()===gridCell.rowIndex&&this.grid._selectedCells[i].index===gridCell.index){$.ig.removeFromArray(this.grid._selectedCells,i)}}else{if(this.grid._selectedCells[i].rowIndex===gridCell.rowIndex&&this.grid._selectedCells[i].index===gridCell.index){$.ig.removeFromArray(this.grid._selectedCells,i)}}}}else{this.grid._selectedCells.push(gridCell)}}else if(!event.shiftKey){if(!isInternal){this.clearSelection(true)}if(!this._isCellSelected(gridCell.rowIndex,gridCell.index)){this.grid._selectedCells.push(gridCell)}if(!isInternal){this._realActiveCell=gridCell}}else{this._shiftCellSelection(gridCell);return}}if((event.ctrlKey||this._ctrlSelect===true||contSelection===true)&&gridCell.element.hasClass(this.css.selectedCell)){gridCell.element.removeClass(this.css.selectedCell)}else{gridCell.element.addClass(this.css.selectedCell);this.grid._selectedCell=gridCell}if(isInternal===false||this._ctrlSelect===true){this._trigger(this.events.cellSelectionChanged,event,{cell:gridCell,selectedCells:this.grid._selectedCells,owner:this,manual:isInternal})}}}else if(isInternal===false&&this.options.mode==="row"||isInternal===true&&isRowSelection===true){if(isInternal===false&&!event.shiftKey||this._ctrlSelect===true){noCancel=this._trigger(this.events.rowSelectionChanging,event,{row:gridRow,selectedRows:this.grid._selectedRows,owner:this,manual:isInternal})}if(noCancel){if(this.options.multipleSelection!==true){if(this.grid._selectedRow!==null){if(v){$(this.grid.rowAt(this.grid._selectedRow.index-sri)).children().removeClass(this.css.selectedCell)}else{$(this.grid._selectedRow.element).children().removeClass(this.css.selectedCell)}}if(this.grid._selectedFixedRow!==null&&this.grid._selectedFixedRow!==undefined){$(this.grid._selectedFixedRow.element).children().removeClass(this.css.selectedCell)}if(this.grid._selectedCell!==null&&this.grid._selectedCell!==undefined){if(v){$(this.grid.cellAt(this.grid._selectedCell.index,this.grid._selectedCell.rowIndex-sri,isFixed)).removeClass(this.css.selectedCell)}else{this.grid._selectedCell.element.removeClass(this.css.selectedCell)}}if(this.grid._selectedFixedCell!==null&&this.grid._selectedFixedCell!==undefined){this.grid._selectedFixedCell.element.removeClass(this.css.selectedFixedCell)}}else{if(event.ctrlKey||this._ctrlSelect===true){if(gridRow.element.children().hasClass(this.css.selectedCell)){for(i=0;i<this.grid._selectedRows.length;i++){if(this.grid._selectedRows[i].element&&this.grid._selectedRows[i].element.length>0){if(this.grid._selectedRows[i].element.index()===gridRow.index){$.ig.removeFromArray(this.grid._selectedRows,i)}}else{if(this.grid._selectedRows[i].index===gridRow.index){$.ig.removeFromArray(this.grid._selectedRows,i)}}}if(hasFixedColumns){for(i=0;i<this.grid._selectedFixedRows.length;i++){if(this.grid._selectedFixedRows[i].element&&this.grid._selectedFixedRows[i].element.length>0){if(this.grid._selectedFixedRows[i].element.index()===gridRow.index){$.ig.removeFromArray(this.grid._selectedFixedRows,i)}}else{if(this.grid._selectedFixedRows[i].index===gridRow.index){$.ig.removeFromArray(this.grid._selectedFixedRows,i)}}}}}else{this.grid._selectedRows.push(gridRow);if(hasFixedColumns){this.grid._selectedFixedRows.push(fixedGridRow)}}}else if(!event.shiftKey){if(!isInternal){this.clearSelection(true)}if(!this._isRowSelected(gridRow.index)){this.grid._selectedRows.push(gridRow);if(hasFixedColumns){this.grid._selectedFixedRows.push(fixedGridRow)}}if(!isInternal){this._realActiveRow=gridRow}}else{this._shiftRowSelection(gridRow);return}}if((event.ctrlKey||this._ctrlSelect===true)&&gridRow.element.children().hasClass(this.css.selectedCell)){gridRow.element.removeClass(this.css.selectedRow);gridRow.element.children().removeClass(this.css.selectedCell);if(hasFixedColumns&&fixedGridRow){fixedGridRow.element.removeClass(this.css.selectedRow);fixedGridRow.element.children().removeClass(this.css.selectedCell)}}else if(parent.is("tr")){parent.children(":not(.ui-iggrid-nongrouprowemptycell)").addClass(this.css.selectedCell);if(hasFixedColumns){fixedGridRow.element.children(":not(.ui-iggrid-nongrouprowemptycell)").addClass(this.css.selectedCell)}}this.grid._selectedRow=gridRow;if(hasFixedColumns){this.grid._selectedFixedRow=fixedGridRow}if(isInternal===false||this._ctrlSelect===true){this._trigger(this.events.rowSelectionChanged,event,{row:gridRow,selectedRows:this.grid._selectedRows,owner:this,manual:isInternal})}else if(isInternal===true&&!this._rangeSelect){this._trigger("internalrowselectionchanged",event,{row:gridRow,selectedRows:this.grid._selectedRows,owner:this})}}}this._mouseCtrlSelect=false},_shiftRowSelection:function(row,noClear,singleRowNavigate,currentRow,event){var i,startIndex,endIndex,noCancel=true;this._isContinuous=true;if(this.grid._selectedRows.length===0){this._singleShiftSelect=true;noCancel=this._trigger(this.events.rowSelectionChanging,null,{row:row,startIndex:row.index,endIndex:row.index,selectedRows:this.grid._selectedRows,owner:this,manual:false});if(noCancel){this.selectRow(row.index);this._trigger(this.events.rowSelectionChanged,null,{row:row,selectedRows:this.grid._selectedRows,owner:this,manual:false})}this._singleShiftSelect=false;return}endIndex=row.index;startIndex=this.grid._selectedRows[0].index;noCancel=this._trigger(this.events.rowSelectionChanging,null,{row:row,startIndex:startIndex,endIndex:endIndex,selectedRows:this.grid._selectedRows,owner:this,manual:false});if(noCancel){this._rangeSelect=true;if(!singleRowNavigate){if(this.grid._selectedRows.length>0&&this.grid._selectedRows[0].index<row.index){if(noClear!==false){this.clearSelection(true)}for(i=startIndex;i<=endIndex;i++){this.selectRow(i)}}if(this.grid._selectedRows.length>0&&this.grid._selectedRows[0].index>row.index){if(noClear!==false){this.clearSelection(true)}for(i=startIndex;i>=endIndex;i--){this.selectRow(i)}}}else{if(event){this._activateRow(row,event)}if(this._isRowSelected(this.activeRow().index)){this.deselectRow(currentRow.index)}else{this.selectRow(this.activeRow().index)}this._singleShiftSelect=false}this._rangeSelect=false;this._trigger(this.events.rowSelectionChanged,null,{row:row,selectedRows:this.grid._selectedRows,owner:this,manual:false})}},_shiftCellSelection:function(cell,noClear,singleCellNavigate,currentCell,event){var firstCell,firstRowIndex,lastRowIndex,firstCellIndex,lastCellIndex,i,j,noCancel=true,lastSelRow=0,firstSelRow=Number.MAX_VALUE,lastSelCol=0,firstSelCol=Number.MAX_VALUE;this._isContinuous=true;if(this.grid._selectedCells.length===0){this._singleShiftSelect=true;noCancel=this._trigger(this.events.cellSelectionChanging,null,{cell:cell,firstRowIndex:cell.rowIndex,lastRowIndex:cell.rowIndex,firstColumnIndex:cell.index,lastColumnIndex:cell.index,selectedCells:this.grid._selectedCells,owner:this,manual:false});
if(noCancel){this.selectCell(cell.rowIndex,cell.index);this._trigger(this.events.cellSelectionChanged,null,{cell:cell,selectedCells:this.grid._selectedCells,owner:this,manual:false})}this._singleShiftSelect=false;return}firstCell=this.grid._selectedCells[0];firstRowIndex=firstCell.rowIndex;lastRowIndex=cell.rowIndex;firstCellIndex=firstCell.index;lastCellIndex=cell.index;noCancel=this._trigger(this.events.cellSelectionChanging,null,{cell:cell,firstRowIndex:firstRowIndex,lastRowIndex:lastRowIndex,firstColumnIndex:firstCellIndex,lastColumnIndex:lastCellIndex,selectedCells:this.grid._selectedCells,owner:this,manual:false});if(noCancel){if(noClear!==false){this.clearSelection(true)}this._rangeSelect=true;if(!singleCellNavigate){if(firstCell.isFixed===cell.isFixed){if(firstRowIndex<=lastRowIndex){for(i=firstRowIndex;i<=lastRowIndex;i++){if(firstCellIndex<=lastCellIndex){for(j=firstCellIndex;j<=lastCellIndex;j++){this.selectCell(i,j,cell.isFixed)}}else{for(j=firstCellIndex;j>=lastCellIndex;j--){this.selectCell(i,j,cell.isFixed)}}}}else{for(i=firstRowIndex;i>=lastRowIndex;i--){if(firstCellIndex<=lastCellIndex){for(j=firstCellIndex;j<=lastCellIndex;j++){this.selectCell(i,j,cell.isFixed)}}else{for(j=firstCellIndex;j>=lastCellIndex;j--){this.selectCell(i,j,cell.isFixed)}}}}}}else{this._singleShiftSelect=true;if(event){this._activateCell(cell,event)}if(this._isCellSelected(this.activeCell().rowIndex,this.activeCell().index)){this.deselectCell(currentCell.rowIndex,currentCell.index);for(i=0;i<this.grid._selectedCells.length;i++){if(this.grid._selectedCells[i].rowIndex>lastSelRow){lastSelRow=this.grid._selectedCells[i].rowIndex}if(this.grid._selectedCells[i].rowIndex<firstSelRow){firstSelRow=this.grid._selectedCells[i].rowIndex}if(this.grid._selectedCells[i].index>lastSelCol){lastSelCol=this.grid._selectedCells[i].index}if(this.grid._selectedCells[i].index<firstSelCol){firstSelCol=this.grid._selectedCells[i].index}}if(Math.abs(firstSelRow-lastSelRow)>0&&Math.abs(this.activeCell().index-currentCell.index)>0){if(firstSelRow<=lastSelRow){for(i=firstSelRow;i<=lastSelRow;i++){this.deselectCell(i,currentCell.index)}}else{for(i=firstSelRow;i>=lastSelRow;i--){this.deselectCell(i,currentCell.index)}}}else if(Math.abs(firstSelCol-lastSelCol)>0&&Math.abs(this.activeCell().rowIndex-currentCell.rowIndex)>0){if(firstSelCol<=lastSelCol){for(i=firstSelCol;i<=lastSelCol;i++){this.deselectCell(currentCell.rowIndex,i)}}else{for(i=firstSelCol;i>=lastSelCol;i--){this.deselectCell(currentCell.rowIndex,i)}}}}else{this.selectCell(this.activeCell().rowIndex,this.activeCell().index);for(i=0;i<this.grid._selectedCells.length;i++){if(this.grid._selectedCells[i].rowIndex>lastSelRow){lastSelRow=this.grid._selectedCells[i].rowIndex}if(this.grid._selectedCells[i].rowIndex<firstSelRow){firstSelRow=this.grid._selectedCells[i].rowIndex}if(this.grid._selectedCells[i].index>lastSelCol){lastSelCol=this.grid._selectedCells[i].index}if(this.grid._selectedCells[i].index<firstSelCol){firstSelCol=this.grid._selectedCells[i].index}}if(Math.abs(firstSelRow-lastSelRow)>0&&Math.abs(this.activeCell().index-currentCell.index)>0){if(firstSelRow<=lastSelRow){for(i=firstSelRow;i<=lastSelRow;i++){this.selectCell(i,this.activeCell().index)}}else{for(i=firstSelRow;i>=lastSelRow;i--){this.selectCell(i,this.activeCell().index)}}}else if(Math.abs(firstSelCol-lastSelCol)>0&&Math.abs(this.activeCell().rowIndex-currentCell.rowIndex)>0){if(firstSelCol<=lastSelCol){for(i=firstSelCol;i<=lastSelCol;i++){this.selectCell(this.activeCell().rowIndex,i)}}else{for(i=firstSelCol;i>=lastSelCol;i--){this.selectCell(this.activeCell().rowIndex,i)}}}}this._singleShiftSelect=false}this._rangeSelect=false;this._trigger(this.events.cellSelectionChanged,null,{cell:cell,selectedCells:this.grid._selectedCells,owner:this,manual:false})}},_rowExpanded:function(event,args){this._hdirty=true},_navigate:function(event){var vcontainer=$("#"+this.grid.element[0].id+"_displayContainer_a"),active,shouldNavigate=false;if(event&&this._suspend){return}if(this._isMouseDown===true){return}if(event.keyCode!==$.ui.keyCode.ENTER&&event.keyCode!==$.ui.keyCode.SPACE&&event.keyCode!==$.ui.keyCode.UP&&event.keyCode!==$.ui.keyCode.DOWN&&event.keyCode!==$.ui.keyCode.LEFT&&event.keyCode!==$.ui.keyCode.RIGHT){return}if(this._hc){active=this.options.mode==="row"?this.activeRow():this.activeCell();if(active!==undefined&&active!==null){active=this.options.mode==="row"?active.element:active.element.closest("tr");this.y_exclude_current=this._excludeRowsLt(active)}}else{this.y_exclude_current=0}if(this.x_exclude_current===undefined){this.x_exclude_current=this._calcExtraCells()}if(this.grid.options.virtualization){if($.ig.util.isIE&&document.activeElement&&document.activeElement.id!==this.grid.id()&&document.activeElement.id!==this.grid.container().attr("id")&&!$(document.activeElement).is("td")&&$(document.activeElement).closest("table")[0].id!==this.grid.id()){return}if(!$.ig.util.isIE&&event.target.id!==vcontainer.attr("id")){return}}else{if($.ig.util.isIE&&document.activeElement&&document.activeElement.id!==this.grid.id()&&document.activeElement.id!==this.grid.container().attr("id")&&!$(document.activeElement).is("td")&&$(document.activeElement).closest("table")[0].id!==this.grid.id()){return}if(!$.ig.util.isIE&&event.target.id!==this.grid.container().attr("id")){return}}if(this.options.activation===true){if(this.options.mode==="cell"){if(this.options.multipleSelection===true){if(this.activeCell()===null||this.activeCell()===undefined){this.selectCell(0,0)}else{if(this.options.skipChildren===false&&this._hc&&this._isMovingUpDown(event)){shouldNavigate=this._activateNextGrid(event);if(!shouldNavigate){this._navigateCell(event,false)}}else{this._navigateCell(event,false)}}}else{if(this.activeCell()===null&&this.grid._selectedCell===null||this.activeCell()===undefined&&this.grid._selectedCell===undefined){this.selectCell(0,0)}else{if(this.options.skipChildren===false&&this._hc&&this._isMovingUpDown(event)){shouldNavigate=this._activateNextGrid(event);if(!shouldNavigate){this._navigateCell(event,true)}}else{this._navigateCell(event,true)}}}}else{if(this.options.multipleSelection===true){if(this.activeRow()===null||this.activeRow()===undefined){this.selectRow(0)}else{if(this.options.skipChildren===false&&this._hc&&this._isMovingUpDown(event)){shouldNavigate=this._activateNextGrid(event);if(!shouldNavigate){this._navigateRow(event,false)}}else{this._navigateRow(event,false)}}}else{if(this.activeRow()===null&&this.grid._selectedRow===null||this.activeRow()===undefined&&this.grid._selectedRow===undefined){this.selectRow(0)}else{if(this.options.skipChildren===false&&this._hc&&this._isMovingUpDown(event)){shouldNavigate=this._activateNextGrid(event);if(!shouldNavigate){this._navigateRow(event,true)}}else{this._navigateRow(event,true)}}}}}},_isMovingUpDown:function(event){if(event.keyCode===$.ui.keyCode.UP||event.keyCode===$.ui.keyCode.DOWN){return true}return false},_navigateFocus:function(event){if($.ig.util.isFF&&event.originalEvent&&$(event.originalEvent.explicitOriginalTarget).is("th")){return}if(event.which!==1){$("#"+this.grid.element[0].id+"_displayContainer_a").unbind("focus",this._focusHandler);$("#"+this.grid.element[0].id+"_displayContainer_a").focus();$("#"+this.grid.element[0].id+"_displayContainer_a").bind({focus:this._focusHandler});event.stopPropagation();return}this._navigate(event)},_navigateCell:function(event,select){var nextX,nextY,x,y,currentCell=this.activeCell(),rowCount,newCell,length,newCellObject,noCancel=true,fixingDirection,sri=this.grid._startRowIndex,sci=this.grid._startColIndex,$newCell,hgrid,ptr,indexTmp=0,cKey,parent,cb,isFixedCell=false,v=this.grid.options.virtualization||this.grid.options.rowVirtualization,c,ret=false,rs,hasFixedColumns=this.grid.hasFixedColumns();c=v&&this.grid.options.virtualizationMode==="continuous";if(currentCell===null){return}if(hasFixedColumns){if(currentCell.element.closest("div").attr("data-fixed-container")!==undefined){isFixedCell=true;fixingDirection=currentCell.element.closest("div[data-fixing-direction]").attr("data-fixing-direction")}else{fixingDirection=this.grid.container().find("div[data-fixing-direction]").eq(0).attr("data-fixing-direction")}}if(sri===undefined||sri===null){sri=0}if(sci===undefined||sri===null){sci=0}if(v){x=currentCell.index-sci;y=currentCell.rowIndex-sri}else{x=currentCell.index;y=currentCell.rowIndex}y+=this.y_exclude_current;x+=this.x_exclude_current;if(!this._rowCount||!this._length){this._refresh()}rowCount=this._rowCount;length=this._length;if(hasFixedColumns){length-=this.grid._fixedColumns.length}if(this.x_exclude_current>0){length+=this.x_exclude_current}if(event.keyCode===$.ui.keyCode.ENTER||event.keyCode===$.ui.keyCode.SPACE){nextX=x;nextY=y;if(event.ctrlKey&&this._isCellSelected(y+sri-this.y_exclude_current,x+sci-this.x_exclude_current)){noCancel=this._trigger(this.events.cellSelectionChanging,event,{cell:currentCell,selectedCells:this.grid._selectedCells,owner:this,manual:false});if(noCancel){this.deselectCell(y+sri-this.y_exclude_current,x+sci-this.x_exclude_current);this._trigger(this.events.cellSelectionChanged,event,{cell:currentCell,selectedCells:this.grid._selectedCells,owner:this,manual:false})}}else if(event.ctrlKey||!this._isCellSelected(y-this.y_exclude_current,x)){this._ctrlSelect=true;this._selectInternal(null,y-this.y_exclude_current,x-this.x_exclude_current);this._ctrlSelect=false}}else if(event.keyCode===$.ui.keyCode.DOWN){nextX=x;nextY=y+1;if(this._realActiveCell!==null&&this._realActiveCell!==undefined&&this._isContinuous&&this.options.multipleSelection===true&&this.grid._selectedCells.length>1&&!event.shiftKey&&!event.ctrlKey){nextX=this._realActiveCell.index-sci+this.x_exclude_current;nextY=this._realActiveCell.rowIndex+1-sri+this.y_exclude_current}if(nextY-this.y_exclude_current>rowCount-1-sri&&this.options.wrapAround===true&&!v){nextY=this.y_exclude_current}else if(nextY-this.y_exclude_current>rowCount-1-sri&&this.options.wrapAround===false){if(this._hc&&!this.options.skipChildren){this._activateNextGrid(null,true)}return}}else if(event.keyCode===$.ui.keyCode.UP){nextX=x;nextY=y-1;if(this._realActiveCell!==null&&this._realActiveCell!==undefined&&this._isContinuous&&this.options.multipleSelection===true&&this.grid._selectedCells.length>1&&!event.shiftKey&&!event.ctrlKey){nextX=this._realActiveCell.index-sci+this.x_exclude_current;nextY=this._realActiveCell.rowIndex-1-sri+this.y_exclude_current}if(!v){if(nextY-this.y_exclude_current<0&&this.options.wrapAround===true){nextY=rowCount-1}else if(nextY-this.y_exclude_current<0&&this.options.wrapAround===false){if(this._hc&&!this.options.skipChildren){this._activateNextGrid(null,false)}return}}}else if(event.keyCode===$.ui.keyCode.LEFT){nextX=x-1;nextY=y;if(hasFixedColumns){if(isFixedCell){if(nextX<0){isFixedCell=false;if(fixingDirection==="left"){nextX=length-1;nextY-=1}else{nextX=length-1}}}else{if(nextX<0){isFixedCell=true;nextX=this.grid._fixedColumns.length-1;if(fixingDirection==="right"){nextY-=1;if(nextY<0){nextY=rowCount-1}}}}}if(nextX-this.x_exclude_current<0){if(this._hc&&!this.options.skipChildren){ret=this._activateNextGrid(null,false,true)}if(ret){return}nextX=length-1;nextY=y-1}if(this._realActiveCell!==null&&this._realActiveCell!==undefined&&this.options.multipleSelection===true&&this.grid._selectedCells.length>1&&!event.shiftKey&&!event.ctrlKey){nextX=this._realActiveCell.index-1-sci+this.x_exclude_current;nextY=this._realActiveCell.rowIndex-sri+this.y_exclude_current}if(!v){if(nextY<0&&this.options.wrapAround===true){nextX=length-1;nextY=rowCount-1}else if(nextY<0&&this.options.wrapAround===false){if(this._hc&&!this.options.skipChildren){this._activateNextGrid(null,false)}return}}}else if(event.keyCode===$.ui.keyCode.RIGHT){nextX=x+1;nextY=y;if(hasFixedColumns){if(isFixedCell){if(nextX>=this.grid._fixedColumns.length){isFixedCell=false;if(fixingDirection==="right"){nextY+=1}nextX=0}}else{if(nextX>=length){if(fixingDirection==="left"){nextY+=1}isFixedCell=true;nextX=0}}}if(nextX>=length){if(this._hc&&!this.options.skipChildren){ret=this._activateNextGrid(null,true,true)}if(ret){return}nextX=0;nextY=y+1}if(this._realActiveCell!==null&&this._realActiveCell!==undefined&&this.options.multipleSelection===true&&this.grid._selectedCells.length>1&&!event.shiftKey&&!event.ctrlKey){nextX=this._realActiveCell.index+1-sci+this.x_exclude_current;nextY=this._realActiveCell.rowIndex-sri+this.y_exclude_current}if(!v){if(nextY>=rowCount+this.y_exclude_current&&this.options.wrapAround===true){nextX=0;nextY=0}else if(nextY>=rowCount+this.y_exclude_current&&this.options.wrapAround===false){if(this._hc&&!this.options.skipChildren){this._activateNextGrid(null,true)}return}}}else{return}if(v&&!c&&nextY>=this.grid._virtualRowCount){this._setScrollTop(this.grid.element.parent(),newCell,nextY>y?"down":"up",nextY-this.y_exclude_current);nextY=this.grid._virtualRowCount-1}else if(v&&!c&&nextY<0&&sri>0){this._setScrollTop(this.grid.element.parent(),newCell,"up",nextY-this.y_exclude_current);nextY=0}else if(v&&!c&&nextY<0){return}if(this.x_exclude_current>0&&this.grid.rowAt(nextY).cells.length<length){nextX=this.grid.rowAt(nextY).cells.length-1}newCell=this.grid.cellAt(nextX===0?this.x_exclude_current:nextX,nextY-this.y_exclude_current,isFixedCell);if(newCell===undefined&&(event.keyCode===$.ui.keyCode.DOWN||event.keyCode===$.ui.keyCode.UP)){if(event.keyCode===$.ui.keyCode.DOWN){nextY++}else if(event.keyCode===$.ui.keyCode.UP){nextY--}newCell=this.grid.cellAt(nextX,nextY,isFixedCell)}if(!v||c){this._setScrollTop(this.grid.element.parent(),newCell,nextY>=y?"down":"up",nextY-this.y_exclude_current);if(c){if(sri!==this.grid._startRowIndex){nextY=nextY+(nextY>=y?-1:1)*Math.abs(this.grid._startRowIndex-sri);sri=this.grid._startRowIndex}newCell=this.grid.cellAt(nextX,nextY,isFixedCell)}if(this.grid.options.width!==null&&this.grid.options.height!==null){parent=$("#"+this.grid.element[0].id+"_hscroller")}else if(this.grid.scrollContainer().length>0){parent=this.grid.scrollContainer()}else{parent=this.grid.element.parent()}this._setScrollLeft(parent,newCell,nextX>=x?"right":"left",nextX-this.x_exclude_current)}if(newCell===undefined||newCell.length>1){return}$newCell=$(newCell);if(this._hc&&($newCell.hasClass("ui-iggrid-expandbutton")||$newCell.hasClass("ui-iggrid-expandcolumn"))){if(event.keyCode===$.ui.keyCode.ENTER){ptr=$newCell.closest("tr");hgrid=$newCell.closest(".ui-iggrid-root").data("igHierarchicalGrid");hgrid.toggle(ptr)}}if($newCell.hasClass("ui-iggrid-rowselector-class")&&(event.keyCode===$.ui.keyCode.ENTER||event.keyCode===$.ui.keyCode.SPACE)){rs=this.grid.element.data("igGridRowSelectors");cb=$newCell.find("span[data-role='checkbox']");if(rs&&cb.length>0){rs._handleCheck(cb)}}indexTmp=nextX-this.x_exclude_current;if(event.keyCode!==$.ui.keyCode.ENTER&&event.keyCode!==$.ui.keyCode.SPACE){$(currentCell.element).removeClass(this.css.activeCell);if(nextX===0){indexTmp=this.x_exclude_current}if(nextX>=this.grid.options.columns.length){cKey=this.grid.options.columns[this.grid.options.columns.length-1].key}else{cKey=this.grid.options.columns[nextX===0?0:indexTmp-(this._hc===true?1:0)].key}if(nextX<=0&&this._hc){cKey=null}if(v){newCellObject={element:$(newCell),index:nextX===0?sci:indexTmp+sci,rowIndex:nextY+sri-this.y_exclude_current,row:$(this.grid.rowAt(nextY)),columnKey:cKey}}else{newCellObject={element:$(newCell),index:nextX===0?0:indexTmp,rowIndex:nextY-this.y_exclude_current,row:$(this.grid.rowAt(nextY)),columnKey:cKey}}if(event.ctrlKey&&this.activeCell()&&(this.activeCell().index!==newCellObject.index||this.activeCell().rowIndex!==newCellObject.rowIndex)){this._activateCell(newCellObject,event)}if(!event.ctrlKey&&event.shiftKey&&this.options.multipleSelection===true){this._shiftCellSelection(newCellObject,false,true,currentCell,event)}else if(!event.ctrlKey){noCancel=this._trigger(this.events.cellSelectionChanging,event,{cell:newCellObject,selectedCells:this.grid._selectedCells,owner:this,manual:false});if(noCancel){this.clearSelection(true);this._selectInternal(null,nextY-this.y_exclude_current,nextX===0?0:indexTmp,isFixedCell);this._trigger(this.events.cellSelectionChanged,event,{cell:newCellObject,selectedCells:this.grid._selectedCells,owner:this,manual:false})}}}event.preventDefault();event.stopPropagation()},_navigateRow:function(event,select){var nextY,y,currentRow=this.activeRow(),rowCount,newRowObject,newRow,noCancel=true,v,c,sri=this.grid._startRowIndex;v=this.grid.options.virtualization||this.grid.options.rowVirtualization;c=v&&this.grid.options.virtualizationMode==="continuous";if(!currentRow){return}if(v){y=currentRow.index-sri}else{y=currentRow.index}y+=this.y_exclude_current;rowCount=this._rowCount;if(event.keyCode===$.ui.keyCode.ENTER||event.keyCode===$.ui.keyCode.SPACE){nextY=y;if(event.ctrlKey&&this._isRowSelected(y-this.y_exclude_current)){noCancel=this._trigger(this.events.rowSelectionChanging,event,{row:currentRow,selectedRows:this.grid._selectedRows,owner:this,manual:false});if(noCancel){this.deselectRow(y-this.y_exclude_current);this._trigger(this.events.rowSelectionChanged,event,{row:currentRow,selectedRows:this.grid._selectedRows,owner:this,manual:false})}noCancel=true}else{this._ctrlSelect=true;this._selectInternal(null,y-this.y_exclude_current);this._ctrlSelect=false}}else if(event.keyCode===$.ui.keyCode.DOWN){nextY=y+1;if(this._realActiveRow!==null&&this._realActiveRow!==undefined&&this.options.multipleSelection===true&&this.grid._selectedRows.length>1&&!event.shiftKey&&!event.ctrlKey&&this._isContinuous){nextY=this._realActiveRow.index+1+this.y_exclude_current}if(!v){if(nextY-this.y_exclude_current>rowCount-1&&this.options.wrapAround===true){nextY=this.y_exclude_current}else if(nextY-this.y_exclude_current>rowCount-1&&this.options.wrapAround===false){if(this._hc&&!this.options.skipChildren){this._activateNextGrid(null,true)}return}}}else if(event.keyCode===$.ui.keyCode.UP){nextY=y-1;if(this._realActiveRow!==null&&this._realActiveRow!==undefined&&this.options.multipleSelection===true&&this.grid._selectedRows.length>1&&!event.shiftKey&&!event.ctrlKey&&this._isContinuous){nextY=this._realActiveRow.index-1+this.y_exclude_current}if(!v){if(nextY-this.y_exclude_current<0&&this.options.wrapAround===true){nextY=rowCount-1}else if(nextY-this.y_exclude_current<0&&this.options.wrapAround===false){if(this._hc&&!this.options.skipChildren){this._activateNextGrid(null,false)}return}}}else{return}event.preventDefault();event.stopPropagation();if(v&&!c&&nextY>=this.grid._virtualRowCount){nextY=this.grid._virtualRowCount-1;newRow=this.grid.rowAt(nextY-this.y_exclude_current);this._setScrollTop(this.grid.element.parent(),newRow,nextY>=y?"down":"up",nextY-this.y_exclude_current)}else if(v&&!c&&nextY<0&&sri>0){nextY=-1;newRow=this.grid.rowAt(nextY);this._setScrollTop(this.grid.element.parent(),newRow,"up",nextY-this.y_exclude_current)}else if(!(v&&!c&&nextY<0)){newRow=this.grid.rowAt(nextY)}else{return}if(newRow===undefined||newRow.length>1){return}while(newRow&&!$(newRow).is(":visible")&&nextY>0&&nextY<rowCount-1){newRow=this.grid.rowAt(event.keyCode===$.ui.keyCode.UP?--nextY:++nextY)}if(!v||c){this._setScrollTop(this.grid.element.parent(),newRow,nextY>=y?"down":"up",nextY-this.y_exclude_current);if(c){if(sri!==this.grid._startRowIndex){nextY=nextY+(nextY>=y?-1:1)*Math.abs(this.grid._startRowIndex-sri);sri=this.grid._startRowIndex}newRow=this.grid.rowAt(nextY)}}if(event.keyCode!==$.ui.keyCode.ENTER&&event.keyCode!==$.ui.keyCode.SPACE){$(currentRow.element).removeClass(this.css.activeRow);if(v){newRowObject={element:$(newRow),index:nextY+sri-this.y_exclude_current}}else{newRowObject={element:$(newRow),index:nextY-this.y_exclude_current}}if(event.ctrlKey&&this.activeRow()&&this.activeRow().index!==newRowObject.index){this._activateRow(newRowObject,event)}if(!event.ctrlKey&&event.shiftKey&&this.options.multipleSelection===true){this._shiftRowSelection(newRowObject,false,true,currentRow,event)}else if(!event.ctrlKey){noCancel=this._trigger(this.events.rowSelectionChanging,event,{row:newRowObject,selectedRows:this.grid._selectedRows,owner:this,manual:false});if(noCancel){this.clearSelection(true);this._selectInternal(null,nextY-this.y_exclude_current);this._trigger(this.events.rowSelectionChanged,event,{row:newRowObject,selectedRows:this.grid._selectedRows,owner:this,manual:false})}}}},_activateNextGrid:function(event,goingDown,levelDown){var target,nextTarget,currentGrid=this.grid.container(),reset=true;if(this.options.mode==="row"){target=this.activeRow().element}else{target=$(this.activeCell().element).closest("tr")}if(event!==null||levelDown===true){if(!event){event={keyCode:goingDown?$.ui.keyCode.DOWN:$.ui.keyCode.UP}}if(event.keyCode===$.ui.keyCode.UP){nextTarget=target.prev();if(nextTarget.attr("data-container")&&nextTarget.is(":visible")){nextTarget=nextTarget.find(".ui-iggrid-table").last()}else{return false}}else{nextTarget=target.next();if(nextTarget.attr("data-container")&&nextTarget.is(":visible")){nextTarget=nextTarget.find(".ui-iggrid-table").first()}else{return false}}}else{if(goingDown){if(currentGrid.next().length>0){nextTarget=currentGrid.nextAll(".ui-iggrid").first().children(".ui-iggrid-table")}else{nextTarget=currentGrid.closest("tr:[data-container=true]").next();reset=false}}else{if(currentGrid.prev().length>0){nextTarget=currentGrid.prevAll(".ui-iggrid").first().children(".ui-iggrid-table")}else{nextTarget=currentGrid.closest("tr:[data-container=true]").prev();reset=false}}}this.clearSelection(false,true);if(reset){if(this.options.mode==="row"){if(goingDown!==undefined&&!goingDown){nextTarget.igGridSelection("selectRow",nextTarget.find(".ui-iggrid-tablebody > tr").last().index())}else{nextTarget.igGridSelection("selectRow",0)}}else{if(goingDown!==undefined&&!goingDown){nextTarget.igGridSelection("selectCell",nextTarget.find(".ui-iggrid-tablebody > tr").last().index(),0)}else{nextTarget.igGridSelection("selectCell",0,0)}}}else if(nextTarget&&nextTarget.length>0){if(this.options.mode==="row"){nextTarget.closest(".ui-iggrid-table").igGridSelection("selectRow",nextTarget.index())}else{nextTarget.closest(".ui-iggrid-table").igGridSelection("selectCell",nextTarget.index(),0)}}nextTarget.closest(".ui-iggrid").focus();return true},_setScrollTop:function(parent,child,direction,index){var parentOffset=parent.offset(),childOffset=$(child).offset(),childh,isDown,isUp,v,c,st;if(!child){return}v=this.grid.options.virtualization||this.grid.options.rowVirtualization;c=v&&this.grid.options.virtualizationMode==="continuous";childh=v&&!c?parseInt(this.grid.options.avgRowHeight,10):$(child).outerHeight();if(!v||c){isDown=childOffset.top+childh+this.grid._scrollbarWidth()>parentOffset.top+$(parent).outerHeight();isUp=childOffset.top<parentOffset.top||c&&index<0}else{isDown=childh*(index+1)>=parseInt(this.grid.options.height,10);isUp=index<0}if(index===0){parent[0].scrollTop=0}else if(direction==="down"){if(isDown){if(c||!v){st=parent[0].scrollTop+childOffset.top+this.grid._scrollbarWidth()-(parentOffset.top+parent.outerHeight())+$(child).outerHeight();if(c){this.grid._onVirtualVerticalScroll({},childh,direction)}else{parent[0].scrollTop=st}}else{this._scrollVmanual(true)}}}else{if(isUp){if(c||!v){st=parent[0].scrollTop-$(child).outerHeight();if(c){this.grid._onVirtualVerticalScroll({},childh,direction)}else{parent[0].scrollTop=st}}else{this._scrollVmanual(false)}}}},_scrollVmanual:function(down){var sc=$("#"+this.grid.element[0].id+"_scrollContainer"),h=parseInt(this.grid.options.avgRowHeight,10);this.grid._ignoreScroll=true;if(down){sc.scrollTop(sc.scrollTop()+h)}else{sc.scrollTop(sc.scrollTop()-h)}this.grid._onVirtualVerticalScroll();this.grid._ignoreScroll=false},_setScrollLeft:function(parent,child,direction,index){var parentOffset=parent.offset(),childOffset=$(child).offset();if(!child){return}if(index===0){parent[0].scrollLeft=0}else if(direction==="right"){if(childOffset.left+$(child).outerWidth()>parentOffset.left+$(parent).outerWidth()){parent[0].scrollLeft=parent[0].scrollLeft+childOffset.left-(parentOffset.left+parent.outerWidth())+$(child).outerWidth()}}else{if(childOffset.left<parentOffset.left){parent[0].scrollLeft=parent[0].scrollLeft-$(child).outerWidth()}}},_isRowSelected:function(y){var i;for(i=0;i<this.grid._selectedRows.length;i++){if(this.grid._selectedRows[i].index===y){return true}}return false},_isCellSelected:function(y,x){var i;for(i=0;i<this.grid._selectedCells.length;i++){if(this.grid._selectedCells[i].index===x&&this.grid._selectedCells[i].rowIndex===y){return true}}return false},_rs:function(e,args){var dom=args.dom,i=0,j=0,ac=this.activeCell(),ar=this.activeRow(),rows=this.grid.rows(),sri=this.grid._startRowIndex||0,sci=this.grid._startColIndex,dataSkip=this._firstRow?this._firstRow.find("th,[data-skip='true']").length:0;if(this.grid.id()!==args.owner.id()){return}if(this.grid.options.virtualization===true&&this.grid.options.virtualizationMode==="continuous"){this._registerTbodyEvents()}if(this.grid._selectedCell){this.grid._selectedCell.element=rows.eq(this.grid._selectedCell.rowIndex-sri).children("td").eq(this.grid._selectedCell.index-dataSkip);this.grid._selectedCell.row=this.grid._selectedCell.element.parent("tr")}if(this.grid._selectedRow){this.grid._selectedRow.element=rows.eq(this.grid._selectedRow.index-sri)}if(this.grid._activeRow){this.grid._activeRow.element=rows.eq(this.grid._activeRow.index-sri)}if(this.grid._activeCell){this.grid._activeCell.element=rows.eq(this.grid._activeCell.rowIndex-sri).children("td").eq(this.grid._activeCell.index);this.grid._activeCell.row=this.grid._activeCell.element.parent("tr")}if(this.grid._selectedRows&&this.grid._selectedRows.length>0){for(i=0;i<this.grid._selectedRows.length;i++){this.grid._selectedRows[i].element=rows.eq(this.grid._selectedRows[i].index-sri)}}if(this.grid._selectedCells&&this.grid._selectedCells.length>0){for(i=0;i<this.grid._selectedCells.length;i++){this.grid._selectedCells[i].element=rows.eq(this.grid._selectedCells[i].rowIndex-sri).children("td").eq(this.grid._selectedCells[i].index-dataSkip);this.grid._selectedCells[i].row=this.grid._selectedCells[i].element.parent("tr")}}ac=this.activeCell();ar=this.activeRow();for(i=0;i<dom.length;i++){for(j=0;j<dom[i].length;j++){if(this.options.mode==="cell"){if(this.options.multipleSelection){if(this._isCellSelected(i+sri,j+sci+dataSkip)){$(dom[i][j]).addClass(this.css.selectedCell)}}else if(this.grid._selectedCell){if(i+sri===this.grid._selectedCell.rowIndex&&j+sci+dataSkip===this.grid._selectedCell.index){$(dom[i][j]).addClass(this.css.selectedCell)}}}else{if(this.options.multipleSelection){if(this._isRowSelected(i+sri)){$(dom[i][j]).addClass(this.css.selectedRow)}}else if(this.grid._selectedRow){if(i+sri===this.grid._selectedRow.index){$(dom[i][j]).addClass(this.css.selectedRow)}}}}}if(ac){if(ac.rowIndex-sri>=0&&ac.rowIndex-sri<dom.length&&ac.index-sci-dataSkip>0&&ac.index-sci-dataSkip<dom[ac.rowIndex-sri].length){$(dom[ac.rowIndex-sri][ac.index-sci-dataSkip]).addClass(this.css.activeCell)}}if(ar){if(ar.index-sri>=0&&ar.index-sri<dom.length){$(dom[ar.index-sri]).first().closest("tr").addClass(this.css.activeRow)}}},selectCell:function(row,col,isFixed){var rv=this.grid.options.virtualization||this.grid.options.rowVirtualization,cv=this.grid.options.virtualization||this.grid.options.columnVirtualization,sri=this.grid._startRowIndex||0,sci=this.grid._startColIndex||0;if(rv&&(row>=sri+this.grid._virtualRowCount||row<sri)||cv&&(col>=sci+this.grid._virtualColumnCount||col<sci)){if(this.options.multipleSelection===true){this.grid._selectedCells.push({index:col,rowIndex:row});this.grid._selectedCell=null}else{this.clearSelection();this._activateCell({index:col,rowIndex:row},null,false)}this.grid._activeCell={index:col,rowIndex:row}}else{this._selectInternal(null,row,col,isFixed)}},deselectCell:function(row,col){var i;if(this.options.multipleSelection===true){for(i=0;i<this.selectedCells().length;i++){if(this.selectedCells()[i].index===col&&this.selectedCells()[i].rowIndex===row){this._deselectCell(this.selectedCells()[i]);$.ig.removeFromArray(this.selectedCells(),i);this.grid._selectedCell=null;break}}}else{if(this.selectedCell()!==null&&this.selectedCell()!==undefined){this._deselectCell(this.selectedCell());this.grid._selectedCell=null}}this._trigger("internalcellselectionchanged",null,{cell:null,selectedCells:this.grid._selectedCells,owner:this})},selectRow:function(index){var v=this.grid.options.virtualization||this.grid.options.rowVirtualization,sri=this.grid._startRowIndex||0;if(v&&(index>=sri+this.grid._virtualRowCount||index<sri)){if(this.options.multipleSelection===true){this.grid._selectedRows.push({index:index});this.grid._selectedRow=null}else{this.clearSelection();this.grid._selectedRow={index:index}}this._activateRow({index:index},null,false)}else{this._selectInternal(null,index)}},deselectRow:function(index){var i;if(this.options.multipleSelection===true){for(i=0;i<this.selectedRows().length;i++){if(this.selectedRows()[i].index===index||this.selectedRows()[i].element&&this.selectedRows()[i].element.index()===index){this._deselectRow(this.selectedRows()[i]);$.ig.removeFromArray(this.selectedRows(),i);this.grid._selectedRow=null;break}}}else{if(this.selectedRow()!==null&&this.selectedRow()!==undefined){this._deselectRow(this.selectedRow());this.grid._selectedRow=null}}this._trigger("internalrowselectionchanged",null,{row:null,selectedRows:this.grid._selectedRows,owner:this})},_deselectRow:function(row){var el;if(row.element&&row.element instanceof jQuery){el=row.element}else{el=$(this.grid._virtualDom[row.index])}el.removeClass(this.css.selectedRow);el.children().removeClass(this.css.selectedCell)},_deselectCell:function(cell){var el;if(cell.element&&cell.element instanceof jQuery){el=cell.element}else{el=$(this.grid._virtualDom[cell.rowIndex][cell.index])}el.removeClass(this.css.selectedCell)},_activateCell:function(cell,event,isFixed){var noCancel=true,v=this.grid.options.virtualization||this.grid.options.rowVirtualization,sri=this.grid._startRowIndex||0;noCancel=this._trigger(this.events.activeCellChanging,event,{cell:cell,owner:this});if(noCancel){if(this.activeCell()){if(v){$(this.grid.cellAt(this.grid._activeCell.index,this.grid._activeCell.rowIndex-sri)).removeClass(this.css.activeCell)}else{$(this.activeCell().element).removeClass(this.css.activeCell)}}if(this.activeRow()){if(v){$(this.grid.rowAt(this.grid._activeRow.index-sri)).removeClass(this.css.activeRow)}else{$(this.activeRow().element).removeClass(this.css.activeRow)}this.activeRow(null)}this.activeCell(cell);$(this.activeCell().element).addClass(this.css.activeCell);this._trigger(this.events.activeCellChanged,event,{cell:cell,owner:this})}},_activateRow:function(row,event,fixedRow){var noCancel=true,v=this.grid.options.virtualization||this.grid.options.rowVirtualization,sri=this.grid._startRowIndex||0;noCancel=this._trigger(this.events.activeRowChanging,event,{row:row,owner:this});if(noCancel){if(this.activeRow()){if(v){$(this.grid.rowAt(this.grid._activeRow.index-sri)).removeClass(this.css.activeRow)}else{$(this.activeRow().element).removeClass(this.css.activeRow)}}if(this.activeFixedRow()){$(this.activeFixedRow().element).removeClass(this.css.activeRow)}if(this.activeCell()){if(v){$(this.grid.cellAt(this.grid._activeCell.index,this.grid._activeCell.rowIndex-sri)).removeClass(this.css.activeCell)}else{$(this.activeCell().element).removeClass(this.css.activeCell)}this.activeCell(null)}this.activeRow(row);if(fixedRow){$(fixedRow.element).addClass(this.css.activeRow);this.activeFixedRow(fixedRow)}$(this.activeRow().element).addClass(this.css.activeRow);this._trigger(this.events.activeRowChanged,event,{row:row,owner:this})}},selectedCells:function(){return this.grid._selectedCells},selectedRows:function(){return this.grid._selectedRows},selectedCell:function(){return this.grid._selectedCell},selectedRow:function(){return this.grid._selectedRow
},activeCell:function(cell){if(cell!==undefined){this.grid._activeCell=cell}else{return this.grid._activeCell}},activeRow:function(row){if(row!==undefined){this.grid._activeRow=row}else{return this.grid._activeRow}},activeFixedRow:function(row){if(row!==undefined){this.grid._activeFixedRow=row}else{return this.grid._activeFixedRow}},clearSelection:function(internal,uiDirty){var i,v=this.grid.options.virtualization||this.grid.options.rowVirtualization,hasFixedColumns=this.grid.hasFixedColumns();for(i=0;i<this.grid._selectedCells.length;i++){if(!v){this.grid._selectedCells[i].element.removeClass(this.css.selectedCell)}else if(v&&this.grid._selectedCells[i].rowIndex-this.grid._startRowIndex>=0){$(this.grid.cellAt(this.grid._selectedCells[i].index,this.grid._selectedCells[i].rowIndex-this.grid._startRowIndex)).removeClass(this.css.selectedCell)}}if(hasFixedColumns){for(i=0;i<this.grid._selectedFixedCells.length;i++){if(!v||v&&this.grid._selectedFixedCells[i].rowIndex-this.grid._startRowIndex>=0){this.grid._selectedFixedCells[i].element.removeClass(this.css.selectedCell)}}this.grid._selectedFixedCells=[];for(i=0;i<this.grid._selectedFixedRows.length;i++){if(!v||v&&this.grid._selectedFixedRows[i].index-this.grid._startRowIndex>=0){$(this.grid._selectedFixedRows[i].element.children()).removeClass(this.css.selectedCell)}}this.grid._selectedFixedRows=[];if(this.grid._selectedFixedRow!==null&&this.grid._selectedFixedRow!==undefined){if(v&&this.grid._selectedFixedRow.index-this.grid._startRowIndex>=0){$(this.grid.rowAt(this.grid._selectedFixedRow.index-this.grid._startRowIndex)).children().removeClass(this.css.selectedCell)}else{$(this.grid._selectedFixedRow.element.children()).removeClass(this.css.selectedCell)}this.grid._selectedFixedRow=null}if(this.grid._selectedFixedCell!==null&&this.grid._selectedFixedCell!==undefined){if(v&&this.grid._selectedFixedCell.rowIndex-this.grid._startRowIndex>=0){$(this.grid.cellAt(this.grid._selectedFixedCell.index,this.grid._selectedCell.rowIndex-this.grid._startRowIndex)).removeClass(this.css.selectedCell)}else{this.grid._selectedFixedCell.element.removeClass(this.css.selectedCell)}this.grid._selectedFixedCell=null}}this.grid._selectedCells=[];for(i=0;i<this.grid._selectedRows.length;i++){if(!v){$(this.grid._selectedRows[i].element.children()).removeClass(this.css.selectedCell)}else if(v&&this.grid._selectedRows[i].index-this.grid._startRowIndex>=0){$(this.grid.rowAt(this.grid._selectedRows[i].index-this.grid._startRowIndex)).children().removeClass(this.css.selectedCell)}}this.grid._selectedRows=[];if(this.grid._selectedRow!==null&&this.grid._selectedRow!==undefined){if(v&&this.grid._selectedRow.index-this.grid._startRowIndex>=0){$(this.grid.rowAt(this.grid._selectedRow.index-this.grid._startRowIndex)).children().removeClass(this.css.selectedCell)}else{$(this.grid._selectedRow.element.children()).removeClass(this.css.selectedCell)}this.grid._selectedRow=null}if(this.grid._selectedCell!==null&&this.grid._selectedCell!==undefined){if(v&&this.grid._selectedCell.rowIndex-this.grid._startRowIndex>=0){$(this.grid.cellAt(this.grid._selectedCell.index,this.grid._selectedCell.rowIndex-this.grid._startRowIndex)).removeClass(this.css.selectedCell)}else{this.grid._selectedCell.element.removeClass(this.css.selectedCell)}this.grid._selectedCell=null}if(!internal){if(this.activeCell()){if(v){$(this.grid.cellAt(this.grid._activeCell.index,this.grid._activeCell.rowIndex-this.grid._startRowIndex)).removeClass(this.css.activeCell)}else{this.activeCell().element.removeClass(this.css.activeCell)}this.activeCell(null)}if(this._realActiveCell){this._realActiveCell.element.removeClass(this.css.activeCell);this._realActiveCell=null}if(this._realActiveRow){this._realActiveRow.element.removeClass(this.css.activeRow);this._realActiveRow=null}if(this.activeRow()){if(v){$(this.grid.rowAt(this.grid._activeRow.index-this.grid._startRowIndex)).removeClass(this.css.activeRow)}else{this.activeRow().element.removeClass(this.css.activeRow)}this.activeRow(null)}}if(uiDirty){this.activeCell(null);this.activeRow(null)}this._trigger("selectioncleared",this,{owner:this.grid,uiDirty:uiDirty})},clearSelectionAllChildren:function(internal,uiDirty){var children=this.grid.children(),i,sel;for(i=0;i<children.length;i++){sel=$(children[i]).data("igGridSelection");if(sel){sel.clearSelection(internal,uiDirty)}}},clearSelectionAll:function(internal,uiDirty){this.clearSelection(internal,uiDirty);this.clearSelectionAllOthers(internal,uiDirty)},clearSelectionAllOthers:function(internal,uiDirty){var hgrid,children,i,sel,rootSel;if(!this._hgrid){if(this.grid.element.hasClass("ui-iggrid-root")){hgrid=this.grid.element.data("igHierarchicalGrid")}else{hgrid=this.grid.element.closest(".ui-iggrid-root").data("igHierarchicalGrid")}}else{hgrid=this._hgrid.data("igHierarchicalGrid")}if(hgrid){children=hgrid.allChildren();for(i=0;i<children.length;i++){sel=$(children[i]).data("igGridSelection");if(sel&&$(children[i]).attr("id")!==this.grid.element.attr("id")){sel.clearSelection(internal,uiDirty)}}}if(hgrid.element.attr("id")!==this.grid.element.attr("id")&&hgrid.element.is("table")||hgrid.element.is("div")&&$("#"+hgrid.element.attr("id")+"_table").attr("id")!==this.grid.element.attr("id")){if(!hgrid.element.is("table")){rootSel=$("#"+hgrid.element.attr("id")+"_table").data("igGridSelection")}else{rootSel=hgrid.element.data("igGridSelection")}if(rootSel){rootSel.clearSelection(internal,uiDirty)}}},_excludeRows:function(element){return this.grid.element.children("tbody").children("tr:[data-container=true]").length},_excludeRowsLt:function(element){var index=element.index();return this.grid.element.children("tbody").children("tr:lt("+index+")").filter("[data-container=true]").length},_calcExtraCells:function(){return this.grid.element.find("tbody > tr > td[data-skip=true]").first().parent().find("[data-skip=true]").length},_columnsCollectionModified:function(evt,ui){if(ui.owner.id()===this.grid.id()){this._registerTbodyEvents()}},_columnFixed:function(args){var i,rows=[],cells=[];if(args.isFixed){if(this.grid._fixedColumns.length===1){this._registerFixedTbodyEvents();if(this.options.mode==="row"){if(this.grid.selectedRows().length>0){rows=this.grid.selectedRows().clone()}else if(this.grid.selectedRow()!==null){rows=[this.grid.selectedRow()]}if(rows.length>0){this.clearSelection(false);for(i=0;i<rows.length;i++){this.selectRow(rows[i].index)}}}}}if(this.grid.selectedCells().length>0){cells=this.grid.selectedCells()}else if(this.grid.selectedCell()!==null){cells=[this.grid.selectedCell()]}for(i=0;i<cells.length;i++){if(this.grid.columnByKey(cells[i].columnKey).fixed!==cells[i].isFixed){cells[i].isFixed=!cells[i].isFixed}}},destroy:function(){this.clearSelection();this._unregisterEvents();$.Widget.prototype.destroy.call(this);return this},_onUIDirty:function(e,args){if(args.owner===this||args.owner.element[0].id!==this.element[0].id){return}if(!this.grid.options.virtualization&&!this.grid.options.rowVirtualization){this._rowCount=this.grid.dataSource.dataView().length}if(this._groupBy){this._rowCount+=this.grid.element.children("tbody").children("tr[data-grouprow=true]").length}this.clearSelection(true,true)},_injectGrid:function(gridInstance){var i;this.grid=gridInstance;this.activeCell(null);this.grid._selectedCell=null;this.grid._selectedRow=null;this.activeRow(null);this.grid._selectedCells=[];this.grid._selectedRows=[];this.grid._selectedFixedCells=[];this.grid._selectedFixedRows=[];for(i=0;i<this.grid.options.features.length;i++){if(this.grid.options.features[i].name==="Selection"){this.grid.options.features[i].inherit=true}}if(this._virtualRecordsRendererHandler!==null&&this._virtualRecordsRendererHandler!==undefined){this.grid.element.unbind("iggridvirtualrecordsrender",this._virtualRecordsRendererHandler)}this._virtualRecordsRendererHandler=$.proxy(this._rs,this);this.grid.element.bind("iggridvirtualrecordsrender",this._virtualRecordsRendererHandler);if(this._uiDirtyHandler!==null&&this._uiDirtyHandler!==undefined){this.grid.element.unbind("iggriduisoftdirty",this._uiDirtyHandler)}this._uiDirtyHandler=$.proxy(this._onUIDirty,this);this.grid.element.bind("iggriduisoftdirty",this._uiDirtyHandler);if(this._dataRenderingHandler!==null&&this._dataRenderingHandler!==undefined){this.grid.element.unbind("iggriddatarendering",this._dataRenderingHandler)}this._dataRenderingHandler=$.proxy(this._dataRendering,this);this.grid.element.bind("iggriddatarendering",this._dataRenderingHandler);if(this._rowExpandedHandler!==null&&this._rowExpandedHandler!==undefined){this.grid.element.unbind("ighierarchicalgridrowexpanded",this._rowExpandedHandler)}this._rowExpandedHandler=$.proxy(this._rowExpanded,this);this.grid.element.bind("ighierarchicalgridrowexpanded",this._rowExpandedHandler);if(this._columnsCollectionModifiedHandler!==null&&this._columnsCollectionModifiedHandler!==undefined){this.grid.element.unbind("iggridcolumnscollectionmodified",this._columnsCollectionModifiedHandler)}this._columnsCollectionModifiedHandler=$.proxy(this._columnsCollectionModified,this);this.grid.element.bind("iggridcolumnscollectionmodified",this._columnsCollectionModifiedHandler);this._hdirty=true}});$.extend($.ui.igGridSelection,{version:"13.1.20131.2523"})})(jQuery);