/*!@license * Infragistics.Web.ClientUI Grid Selection (and Keyboard navigation) 19.1.20 * * Copyright (c) 2011-2019 Infragistics Inc. * * http://www.infragistics.com/ * * Depends on: * jquery-1.9.1.js * jquery.ui.core.js * jquery.ui.widget.js * infragistics.ui.grid.framework.js * infragistics.ui.shared.js * infragistics.dataSource.js * infragistics.util.js */ (function(factory){if(typeof define==="function"&&define.amd){define(["./infragistics.ui.grid.framework"],factory)}else{return factory(jQuery)}})(function($){"use strict";$.widget("ui.igGridSelection",$.ui.igWidget,{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,persist:true,allowMultipleRangeSelection:true},events:{rowSelectionChanging:"rowSelectionChanging",rowSelectionChanged:"rowSelectionChanged",cellSelectionChanging:"cellSelectionChanging",cellSelectionChanged:"cellSelectionChanged",activeCellChanging:"activeCellChanging",activeCellChanged:"activeCellChanged",activeRowChanging:"activeRowChanging",activeRowChanged:"activeRowChanged"},_create:function(){this._isMouseDown=false;this._pkProp=null;this._rsCellKey="##ROWSEL##";this._gbExpandCellKey="##GBXCEL##";this._gbSummaryCellKey="##GBSCEL##";this._gbEmptyCellKey="##GBECEL##";this._gbGroupSummaryIconCellKey="##GBGSICEL##";this._gbGroupSummaryEmptyCellKey="##GBGSECEL##";this._gbGroupSummaryCellKey="##GBGSCEL_{col}##";this._hgCellKey="##HIEGRD##";this._tgExpandKey="##TGXCEL##";this.element.attr("aria-multiselectable",this.options.multipleSelection)},destroy:function(){this.grid.element.unbind({iggriddatarendering:this._dataRenderingHandler,iggridvirtualrendering:this._virtualRecordsRenderingHandler,igtreegridvirtualrendering:this._virtualRecordsRenderingHandler,iggridvirtualrecordsrender:this._virtualRecordsRendererHandler,igtreegridvirtualrecordsrender:this._virtualRecordsRendererHandler,iggridcolumnscollectionmodified:this._columnsCollectionModifiedHandler});this.clearSelection();this._unregisterEvents();this._selection.removeSubscriber(this._subId,this.grid.id());this._superApply(arguments);return this},_registerWidget:$.noop,_unregisterWidget:$.noop,_setOption:function(key,value){var rs;$.Widget.prototype._setOption.apply(this,arguments);if(key==="mode"){throw new Error(this._getLocaleValue("optionChangeNotSupported").replace("{optionName}",key))}if(key==="multipleSelection"){this._selection.settings.multipleSelection=value;rs=this.grid.element.data("igGridRowSelectors");if(rs){if(value){rs._renderHeaderRowSelectors(this.grid)}else{rs._headerCheckbox().remove()}}}},_dataRendering:function(event,ui){var tbody;if(ui.owner.id()!==this.grid.id()){return}tbody=this.grid.element.find("tbody").add(this.grid.fixedBodyContainer().find("tbody"));if(this._tbodyBinding){tbody.unbind(this._tbodyBinding)}this._pkProp=this.grid.options.primaryKey;if(this.options.persist&&!this.grid.options.primaryKey){this._createUidForData();this._pkProp="ig_pk"}},_dataRendered:function(){this._unregisterEvents();this._registerEvents();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")}}this.grid._startRowIndex=this.grid._startRowIndex||0;this._defaultAttributes();if(this.options.persist){this._paintActive();this._renderAttributes();this._selection.invalid=true}else{this.clearSelection()}},_fixedColumnsChanged:function(args){if(args.isToFix&&args.isInit){this._unregisterEvents();this._registerEvents();this._selection.invalid=true}},_virtualRecordsRendering:function(){this._storedActiveElement=this.activeCell()||this.activeRow();if(this._storedActiveElement){this._storedActiveElement.element.blur()}},_virtualRecordsRender:function(evt,ui){var ae;if(ui.owner.id()!==this.grid.id()){return}this._selection.invalid=true;$(document).unbind("keydown."+this.grid.id());if(this.grid.options.virtualization===true&&this.grid.options.virtualizationMode==="continuous"){this._unregisterEvents();this._registerEvents()}this._paintActive();this._renderAttributes();if(this.options.mode==="cell"){ae=this.activeCell()}else{ae=this.activeRow()}if(ae&&ae.element instanceof $){ae.element.focus()}else if(this._storedActiveElement){if(this.options.mode==="cell"){this._getCellByIdentifier(this._storedActiveElement).focus()}else{this._getRowsByIdentifier(this._storedActiveElement.id).focus()}}},_columnsCollectionModified:function(evt,ui){if(ui.owner.id()===this.grid.id()){this._unregisterEvents();this._registerEvents();this._selection.invalid=true;this._paintActive()}},_hidingFinished:function(){if(this.options.persist){this._paintActive();this._selection.invalid=true}},_rowDeleted:function(rowId){var cellsForRow,colKey,cellId;this._selection.invalid=true;if(this.options.mode==="cell"){if(this._selection.settings.owner===this.grid){if(this._selection.activeElement&&this._selection.activeElement.id===rowId){this._selection.deactivate()}cellsForRow=this._selection.selection[rowId];for(colKey in cellsForRow){if(cellsForRow.hasOwnProperty(colKey)){cellId={id:rowId,columnKey:colKey};this._selection.deselect(cellId,null,false)}}}}else{if(this._selection.isActive(rowId,this.grid)){this._selection.deactivate()}if(this._selection.isSelected(rowId,this.grid)){this._selection.deselect(rowId,null,false)}}},_mouseDown:function(event){var target,targetGrid,gOpts=this.grid.options,re=new RegExp("^"+this.grid.id()+"(_fixed)?$"),hasVirtualization=gOpts.virtualization||gOpts.rowVirtualization||gOpts.columnVirtualization,scrollCont=hasVirtualization?this.grid._vdisplaycontainer():this.grid.scrollContainer();if(event&&event.which!==1){return}target=event&&event.target?$(event.target):null;this._mouseDownTarget=target;this._mouseDownScroll=scrollCont.length?scrollCont.scrollTop():0;this._prevDragTar=target[0];this._previousRangeCache=event.ctrlKey||event.metaKey?[]:null;if(this.options.allowMultipleRangeSelection&&this.options.mode==="cell"){this._selection._lockSelection()}targetGrid=target?target.closest(".ui-iggrid-table"):null;if(target&&target.hasClass("ui-iggrid-scrolldiv")){return}if(targetGrid&&targetGrid.length>0&&!targetGrid.attr("id").match(re)){return}this._isMouseDown=true;if(this.options.mouseDragSelect===false||this.options.multipleSelection===false||this.options.mode==="row"){return}this._firstDragCell=target},_mouseMove:function(event){var target=event&&event.target?$(event.target):null,fdc=this._firstDragCell,re,$tbl;if(event&&this._suspend){return}if(this.options.mode!=="cell"||!this.options.mouseDragSelect||!this._isMouseDown){return}target=target.closest("td,th");if(fdc&&fdc.length>0){$tbl=fdc.closest(".ui-iggrid-table");re=new RegExp("^"+this.grid.id()+"(_fixed)?$");if(target[0]!==this._prevDragTar&&target.closest(".ui-iggrid-table").attr("id").match(re)&&$tbl.length&&$tbl.attr("id").match(re)&&!(target.is("th")||target.attr("data-skip"))){this._selection.rangeSelectStart=this._identifierForTarget(fdc);this._dragSelect=true;this._prevDragTar=target[0];this._shiftSelectChange(target,false);this._storedActiveIndex=target.closest("td").index()}}},_mouseUp:function(event){var gOpts=this.grid.options,hasVirtualization=gOpts.virtualization||gOpts.rowVirtualization||gOpts.columnVirtualization,scrollCont=hasVirtualization?this.grid._vdisplaycontainer():this.grid.scrollContainer(),target=event&&event.target?$(event.target):null,targetGrid=target?target.closest(".ui-iggrid-table"):null,re=new RegExp("^"+this.grid.id()+"(_fixed)?$"),shouldCancel,self=this,ctrl;if(targetGrid&&targetGrid.length>0&&!targetGrid.attr("id").match(re)){return}this._isMouseDown=false;if(!target||this._dragSelect||this._suspend||!this._mouseDownTarget||this._mouseDownTarget[0]!==target[0]||event.which>1||$.ig.util.isTouch&&(scrollCont.length?scrollCont.scrollTop():0)!==this._mouseDownScroll){this._dragSelect=false;this._prevDragTar=null;this._firstDragCell=null;this._mouseDownTarget=null;return}if(target.closest(".ui-iggrid-rowselector-class").length===1||target.hasClass("ui-iggrid-childarea")||target.parent().hasClass("ui-iggrid-childarea")||target.hasClass("ui-widget-header")){return}if(this._hc){target.parents("tr[data-container]").each(function(){if($(this).closest(".ui-iggrid-table").attr("id")===self.grid.element.attr("id")){shouldCancel=true;return false}});if(shouldCancel){return}}if(event.shiftKey&&this.options.multipleSelection){this._shiftSelectChange(target,true)}else{ctrl=event.ctrlKey||event.metaKey||this.options.mode==="cell"&&this.options.multipleCellSelectOnClick;this._singleSelectChange(target,ctrl)}this._maxHistoryLength=this.grid.options.columns.length;this._selectionHistory=[{elem:target,elemIndex:target.index(),rowOfElem:target.closest("tr"),prevSelected:null,keyCode:null}]},_touchStart:function(event){event.target=$(document.elementFromPoint(event.originalEvent.touches[0].clientX,event.originalEvent.touches[0].clientY));event.which=1;if(event.target.hasClass("ui-iggrid-selectedcell")&&event.target.hasClass("ui-state-focus")){this._canDrag=true}else{this._canDrag=false}this._mouseDown(event)},_touchEnd:function(event){event.target=$(document.elementFromPoint(event.originalEvent.changedTouches[0].clientX,event.originalEvent.changedTouches[0].clientY));this._canDrag=false;this._mouseUp(event)},_touchMove:function(event){if(!this._isMouseDown||!this._canDrag){return true}event.preventDefault();event.target=$(document.elementFromPoint(event.originalEvent.touches[0].clientX,event.originalEvent.touches[0].clientY));this._mouseMove(event)},_pointerDown:function(event){this.grid.element.css("-ms-touch-action","none");this._mouseDown(event)},_pointerMove:function(event){this._mouseMove(event)},_pointerUp:function(event){this.grid.element.css("-ms-touch-action","auto");this._mouseUp(event)},_keyDown:function(event){var target,tId,targetGrid,re=new RegExp("^"+this.grid.id()+"(_fixed)?$"),el;if(event&&this._suspend){return}if(this.grid!==this._selection.settings.owner){return}if(this._isMouseDown===true){return}if(this.options.activation!==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}target=event&&event.target?$(event.target):null;tId=target?this._identifierForTarget(target):null;targetGrid=target?target.closest(".ui-iggrid-table"):null;if(targetGrid&&targetGrid.length>0&&!targetGrid.attr("id").match(re)){return}if(this._selection.activeElement===null||this._selection.activeElement===undefined){if(this.options.mode==="cell"){el=target.children("td:not([data-skip='true']):first");if(!el.length){return}this._singleSelectChange(el,false,false);if(event.keyCode===$.ui.keyCode.SPACE){event.preventDefault()}return}el=target.closest("tr");if(!el.length){return}this._selection.activate(this._identifierForRow(el),el)}event.preventDefault();if(event.keyCode===$.ui.keyCode.ENTER||event.keyCode===$.ui.keyCode.SPACE){if(this._suppressKey(event.keyCode)){return}if(!this._isDataElement(this._selection.activeElement)||!this._canBeSelected(tId,target)){this._handleToggle(event.ctrlKey||event.metaKey)}else{this._selection.toggle()}return}this._navigate(event.keyCode,event.ctrlKey||event.metaKey,event.shiftKey)},_selectStart:function(event){var re=new RegExp("^"+this.grid.id()+"(_fixed)?$"),target=event.target?$(event.target):null,targetGrid=target?target.closest(".ui-iggrid-table"):$();if(targetGrid.length>0&&!targetGrid.attr("id").match(re)){return}if(event&&this._suspend){return}if(this.options.mouseDragSelect===false||this.options.multipleSelection===false){return false}event.preventDefault()},_selectStartContainer:function(event){if(event.target&&$(event.target).hasClass("ui-iggrid-fixedcontainer")){event.preventDefault()}},_tbodyFocusIn:function(event){var target=event&&event.target?$(event.target):null,targetGrid=target?target.closest(".ui-iggrid-table"):null,re=new RegExp("^"+this.grid.id()+"(_fixed)?$"),reo;if(target.is("[data-rs-select-all]")||target.is("[data-rs-deselect-all]")){targetGrid=target?target.closest(".ui-iggrid").find(".ui-iggrid-table"):null}if(this._selection.settings.owner){reo=new RegExp("^"+this._selection.settings.owner.id()+"(_fixed)?$")}if(targetGrid&&targetGrid.length>0){if(!targetGrid.attr("id").match(re)){return}if(reo&&!targetGrid.attr("id").match(reo)){this._selection.changeOwner(this.grid)}}if(this.options.mode==="row"){if(target.is("tr")){this._selection.activate(this._identifierForRow(target),target)}}else{if(target.is("td")){this._selection.activate(this._identifierForTarget(target),target);if(!target.attr("data-gbsummary")){this._storedActiveIndex=target.index()}}}},_tbodyFocusOut:function(event){var target=event&&event.target?$(event.target):null,targetGrid=target?target.closest(".ui-iggrid-table"):null,re=new RegExp("^"+this.grid.id()+"(_fixed)?$"),id;if(targetGrid&&targetGrid.length>0&&!targetGrid.attr("id").match(re)){return}if(this.options.mode==="row"){if(target.is("tr")){id=this._identifierForRow(target);if(this._selection.isActive(id)){this._selection.deactivate()}}}else{if(target.is("td")){id=this._identifierForTarget(target);if(this._selection.isActive(id)){this._selection.deactivate()}}}},_preventDefault:function(event){if($(event.target).is("td")){event.preventDefault()}},_releaseMouse:function(){this._dragSelect=false;this._firstDragCell=null;this._isMouseDown=false;this._mouseDownTarget=null},_applyCellStyle:function(data,col){var identifier={id:data[this._pkProp],columnKey:col};return this._selection.isSelected(identifier,this.grid)?this.css.selectedCell:""},_applyRowStyle:function(data){var id=data.__gbRecord?data.id:data[this._pkProp];return this._selection.isSelected(id,this.grid)?this.css.selectedCell:""},_paintActive:function(){if(this._selection.activeElement&&this._selection.settings.owner===this.grid){if(this.options.mode==="row"){this._getRowsByIdentifier(this._selection.activeElement).addClass(this.css.activeRow)}else{this._getCellByIdentifier(this._selection.activeElement).addClass(this.css.activeCell)}}},_renderAttributes:function(){if(this._selection.selectionLength()){if(this.options.mode==="row"){this.grid.element.children("tbody").find("td.ui-iggrid-selectedcell").closest("tr").attr("aria-selected",true);this.grid.fixedBodyContainer().find("tbody").find("td.ui-iggrid-selectedcell").closest("tr").attr("aria-selected",true)}else{this.grid.element.children("tbody").find("td.ui-iggrid-selectedcell").attr("aria-selected",true);this.grid.fixedBodyContainer().find("tbody").find("td.ui-iggrid-selectedcell").attr("aria-selected",true)}}else{if(this.options.mode==="row"){this.grid.element.children("tbody").find("td:not('.ui-iggrid-selectedcell')").closest("tr").attr("aria-selected",false);this.grid.fixedBodyContainer().find("tbody").find("td:not('.ui-iggrid-selectedcell')").closest("tr").attr("aria-selected",false)}else{this.grid.element.children("tbody").find("td:not('.ui-iggrid-selectedcell')").attr("aria-selected",false);this.grid.fixedBodyContainer().find("tbody").find("td:not('.ui-iggrid-selectedcell')").attr("aria-selected",false)}}},_defaultAttributes:function(){if(this.options.mode==="row"){this.grid.element.children("tbody").children("tr").attr("aria-selected",false);this.grid.fixedBodyContainer().find("tbody").children("tr").attr("aria-selected",false)}else{this.grid.element.children("tbody").find("td").attr("aria-selected",false);this.grid.fixedBodyContainer().find("tbody").find("td").attr("aria-selected",false)}},clearSelection:function(){this._selection.cleanAll(this.grid)},selectCell:function(row,col,isFixed){var rowElement,cellId,cellElement,record;if(this.options.mode==="row"){return}if(this._isOutOfView(row,col)){record=this.grid._getDataView()[row];if(!record){return}if(this.grid._visibleColumns().lengththis._rangeSelectionStartIndex||nextRowIndex-prevRowIndex>0&&prevRowIndex=nextRow.children().length?nextRow.children().length-1:this._storedActiveIndex||currentCellIndex;nextElement=nextRow.children().eq(nextElementIndex);if(this._rowMergeOffset!==0){nextElementIndex+=this._rowMergeOffset;nextElement=nextRow.children().eq(nextElementIndex);this._rowMergeOffset=0}if(nextElement.attr("aria-rowmerged")!==undefined){while(nextElement.attr("aria-rowmerged")!==undefined){this._rowMergeOffset++;nextElementIndex--;nextElement=nextRow.children().eq(nextElementIndex)}}while(!nextElement.is(":visible")&&nextElement.attr("aria-rowmerged")===undefined){nextRow=this._getPrevRow(currentRow,wrapAround,isFixedElement,false,vVirt);currentRow=nextRow;if(this.options.mode==="row"||!nextRow){return nextRow}nextElement=nextRow.children().eq(nextElementIndex)}}else if(code===$.ui.keyCode.DOWN){nextRow=this._getNextRow(currentRow,wrapAround,isFixedElement,false,vVirt);if(cellRowSpan){var rowspan=parseInt(currentActiveElement.attr("rowspan"));nextRow=this._getRowByIndex(currentRow.index()+rowspan,isFixedElement);if(!nextRow.length){nextRow=this._firstRow(null,isFixedElement,hierRowSkip)}else if(nextRow.attr("data-container")){nextRow=this._firstRow(nextRow,isFixedElement,hierRowSkip)}}if(this.options.mode==="row"||!nextRow){return nextRow}nextElementIndex=currentCellIndex>=nextRow.children().length?nextRow.children().length-1:this._storedActiveIndex||currentCellIndex;nextElement=nextRow.children().eq(nextElementIndex);if(this._rowMergeOffset!==0){nextElementIndex+=this._rowMergeOffset;nextElement=nextRow.children().eq(nextElementIndex);this._rowMergeOffset=0}if(nextElement.attr("aria-rowmerged")!==undefined){while(nextElement.attr("aria-rowmerged")!==undefined){this._rowMergeOffset++;nextElementIndex--;nextElement=nextRow.children().eq(nextElementIndex)}}}else if(code===$.ui.keyCode.LEFT&&this.options.mode==="cell"){if(currentActiveElement.is(":first-child")){if(hasFixedCols&&!isFixedElement&&fixingDir==="left"){if(cellRowSpan&&this._selectionHistory.length>1){nextRow=this._getNextRowByEndMergedCell(code,wrapAround,isFixedElement,fixingDir)}else if(cellColSpan){currentCellIndex-=cellColSpanVal-1;nextRow=this._getRowByIndex(currentRow.index(),true)}else{nextRow=this._getRowByIndex(currentRow.index(),true)}}else if(hasFixedCols&&isFixedElement&&fixingDir==="right"){if(cellRowSpan&&this._selectionHistory.length>1){nextRow=this._getNextRowByEndMergedCell(code,wrapAround,isFixedElement,fixingDir)}else if(cellColSpan){currentCellIndex-=cellColSpanVal-1;nextRow=this._getRowByIndex(currentRow.index(),false)}else{nextRow=this._getRowByIndex(currentRow.index(),false)}}else{if(cellRowSpan&&this._selectionHistory.length>1){nextRow=this._getNextRowByEndMergedCell(code,wrapAround,isFixedElement,fixingDir)}else if(cellColSpan){currentCellIndex-=cellColSpanVal-1;nextRow=this._getPrevRow(currentRow,wrapAround,isFixedElement,hasFixedCols,vVirt)}else{nextRow=this._getPrevRow(currentRow,wrapAround,isFixedElement,hasFixedCols,vVirt)}this._cleanHistorySavePrevRow(code,wrapAround,isFixedElement,hasFixedCols,vVirt)}wrapped=true}else{if(cellRowSpan&&this._selectionHistory.length>1){if(this._selectionHistory[0].keyCode===$.ui.keyCode.UP){currentRow=this._selectionHistory[1].rowOfElem;nextRow=this._getPrevRow(currentRow,wrapAround,isFixedElement,false,vVirt)}else if(this._selectionHistory[0].keyCode===$.ui.keyCode.DOWN){nextRow=this._selectionHistory[0].rowOfElem}else if(this._selectionHistory[0].keyCode===$.ui.keyCode.RIGHT){nextRow=this._selectionHistory[1].rowOfElem}else if(this._selectionHistory[0].keyCode===$.ui.keyCode.LEFT&&isFixedElement){lastSmallSelection=this._findLastSmallestCellGroupSelected();nextRow=this._getRowByIndex(lastSmallSelection.rowOfElem.index(),true)}else if(this._selectionHistory[0].keyCode===$.ui.keyCode.LEFT){lastSmallSelection=this._findLastSmallestCellGroupSelected();nextRow=this._getRowByIndex(lastSmallSelection.rowOfElem.index(),false)}else{nextRow=currentRow}}else{nextRow=currentRow}}if(!nextRow||nextRow.length===0){return null}nextElementIndex=wrapped?nextRow.children().length-1:currentCellIndex-1;nextElement=nextRow.children().eq(nextElementIndex);if(nextElement.attr("colspan")===undefined){this._rowMergeOffset=0}while(!nextElement.is(":visible")){if(nextElement.attr("aria-rowmerged")!==undefined){while(nextElement.attr("aria-rowmerged")!==undefined){this._rowMergeOffset++;nextElementIndex--;nextElement=nextRow.children().eq(nextElementIndex)}}else{nextRow=this._getPrevRow(nextRow,wrapAround,isFixedElement,false,vVirt);nextElementIndex=wrapped?nextRow.children().length-1:currentCellIndex-1;nextElement=nextRow.children().eq(nextElementIndex)}}this._revertH=wrapped}else if(code===$.ui.keyCode.RIGHT&&this.options.mode==="cell"){if(currentActiveElement.is(":last-child")){if(hasFixedCols&&isFixedElement&&fixingDir==="left"){if(cellRowSpan&&this._selectionHistory.length>1){nextRow=this._getNextRowByEndMergedCell(code,wrapAround,isFixedElement,fixingDir)}else if(cellColSpan){currentCellIndex+=cellColSpanVal-1;nextRow=this._getRowByIndex(currentRow.index(),false)}else{nextRow=this._getRowByIndex(currentRow.index(),false)}}else if(hasFixedCols&&!isFixedElement&&fixingDir==="right"){if(cellRowSpan&&this._selectionHistory.length>1){ nextRow=this._getNextRowByEndMergedCell(code,wrapAround,isFixedElement,fixingDir)}else if(cellColSpan){currentCellIndex+=cellColSpanVal-1;nextRow=this._getRowByIndex(currentRow.index(),true)}else{nextRow=this._getRowByIndex(currentRow.index(),true)}}else{if(cellRowSpan&&this._selectionHistory.length>1){nextRow=this._getNextRowByEndMergedCell(code,wrapAround,isFixedElement,fixingDir)}else if(cellColSpan){currentCellIndex+=cellColSpanVal-1;nextRow=this._getNextRow(currentRow,wrapAround,isFixedElement,hasFixedCols,vVirt)}else{nextRow=this._getNextRow(currentRow,wrapAround,isFixedElement,hasFixedCols,vVirt)}this._cleanHistorySaveNextRow(code,wrapAround,isFixedElement,hasFixedCols,vVirt)}wrapped=true}else{if(cellRowSpan&&this._selectionHistory.length>1){if(this._selectionHistory[0].keyCode===$.ui.keyCode.UP){currentRow=this._selectionHistory[1].rowOfElem;nextRow=this._getPrevRow(currentRow,wrapAround,isFixedElement,false,vVirt)}else if(this._selectionHistory[0].keyCode===$.ui.keyCode.DOWN){nextRow=this._selectionHistory[0].rowOfElem}else if(this._selectionHistory[0].keyCode===$.ui.keyCode.LEFT){nextRow=this._selectionHistory[1].rowOfElem}else if(this._selectionHistory[0].keyCode===$.ui.keyCode.RIGHT&&isFixedElement){lastSmallSelection=this._findLastSmallestCellGroupSelected();nextRow=this._getRowByIndex(lastSmallSelection.rowOfElem.index(),true)}else if(this._selectionHistory[0].keyCode===$.ui.keyCode.RIGHT){lastSmallSelection=this._findLastSmallestCellGroupSelected();nextRow=this._getRowByIndex(lastSmallSelection.rowOfElem.index(),false)}else{nextRow=currentRow}}else if(cellColSpan){if(this.grid.options.columns.length<=currentCellIndex+parseInt(cellColSpanVal)){currentCellIndex=-1;nextRow=this._getNextRow(currentRow,wrapAround,!isFixedElement,hasFixedCols,vVirt)}else{currentCellIndex+=parseInt(cellColSpanVal)-1;nextRow=currentRow}}else{nextRow=currentRow}}if(!nextRow){return null}nextElementIndex=wrapped?0:currentCellIndex+1;nextElement=nextRow.children().eq(nextElementIndex);if(nextElement.attr("colspan")===undefined){this._rowMergeOffset=0}while(!nextElement.is(":visible")){if(nextElement.attr("aria-rowmerged")!==undefined){while(nextElement.attr("aria-rowmerged")!==undefined){this._rowMergeOffset++;nextRow=this._getPrevRow(nextRow,wrapAround,isFixedElement,false,vVirt);nextElementIndex=wrapped?0:currentCellIndex+1;nextElement=nextRow.children().eq(nextElementIndex)}}else{nextRow=this._getPrevRow(nextRow,wrapAround,isFixedElement,false,vVirt);nextElementIndex=wrapped?0:currentCellIndex+1;nextElement=nextRow.children().eq(nextElementIndex)}}this._revertH=wrapped}if(nextElement&&!nextElement.attr("data-gbsummary")){this._storedActiveIndex=nextElementIndex}if(!this._selectionHistory){this._maxHistoryLength=this.grid.options.columns.length;this._selectionHistory=[{elem:nextElement,elemIndex:nextElementIndex,rowOfElem:nextRow,keyCode:null}]}else{this._selectionHistory.unshift({elem:nextElement,elemIndex:nextElementIndex,rowOfElem:nextRow,keyCode:code});if(this._selectionHistory.length>this._maxHistoryLength){this._selectionHistory.splice(this._maxHistoryLength)}}return nextElement},_findLastSmallestCellGroupSelected:function(){var i,nextCell,curCell,targetCell=this._selectionHistory[0],curRowspan=targetCell.elem&&targetCell.elem.attr("rowspan")?parseInt(targetCell.elem.attr("rowspan")):0;for(i=1;i=this.grid._virtualRowCount-1){this._scrollVmanual(true);return null}}if(currentRow.first().parent().children((hierRowSkip.length>0?":not("+hierRowSkip+")":"")+":visible:last")[0]===currentRow[0]){if(wrapAround){nextRow=this._firstRow(null,swap?!isFixed:isFixed,hierRowSkip)}else{return}this._revertV=true}else{if(isFixed&&$.ig.util.isIE){currentRow.width()}if(swap){nextRow=this._getRowByIndex(currentRow.index()+1,!isFixed)}else{nextRow=currentRow.nextAll("tr"+(hierRowSkip.length>0?":not("+hierRowSkip+")":"")+":visible").first()}this._revertV=false}if(nextRow.attr("data-container")){nextRow=this._firstRow(nextRow,swap?!isFixed:isFixed,hierRowSkip)}return nextRow},_getPrevRow:function(currentRow,wrapAround,isFixed,swap,virt){var hierRowSkip=this.options.skipChildren?"[data-container=true]":"",nextRow,cIdx;if(virt){cIdx=currentRow.index();if(cIdx<=0){this._scrollVmanual(false);return null}}if(currentRow.is(":first-child")){if(wrapAround){nextRow=this._lastRow(null,swap?!isFixed:isFixed,hierRowSkip)}else{return}this._revertV=true}else{if(isFixed&&$.ig.util.isIE){currentRow.width()}if(swap){nextRow=this._getRowByIndex(currentRow.index()-1,!isFixed)}else{nextRow=currentRow.prevAll("tr"+(hierRowSkip.length>0?":not("+hierRowSkip+")":"")+":visible").first()}this._revertV=false}if(nextRow.attr("data-container")){nextRow=this._lastRow(nextRow,swap?!isFixed:isFixed,hierRowSkip)}return nextRow},_lastRow:function(container,fixed,rowSkip){var body;if(container){body=container.find("tbody")}else if(fixed){body=this.grid.fixedBodyContainer().find("tbody")}else{body=this.grid.element.children("tbody")}return body.children("tr"+(rowSkip.length>0?":not("+rowSkip+")":"")+":visible").last()},_firstRow:function(container,fixed,rowSkip){var body;if(container){body=container.find("tbody")}else if(fixed){body=this.grid.fixedBodyContainer().find("tbody")}else{body=this.grid.element.children("tbody")}return body.children("tr"+(rowSkip.length>0?":not("+rowSkip+")":"")).first()},_createUidForData:function(){var i=0,ds=this.grid.dataSource?this.grid.dataSource._data:[];for(i=0;i0){rootGrid=rootGrid.data("igGrid")}else{rootGrid=this.grid}opts={multipleSelection:this.options.multipleSelection,byIndex:this._pkProp===null,owner:this.grid};if(this.options.mode==="row"){rootGrid._selectionCollection=rootGrid._selectionCollection||new $.ig.SelectedRowsCollection(opts)}else{rootGrid._selectionCollection=rootGrid._selectionCollection||new $.ig.SelectedCellsCollection(opts)}this._selection=rootGrid._selectionCollection;this.grid._selection=this._selection;if(!this._subId){this._subId=this._selection.addSubscriber(this,this.grid.id())}},_setScroll:function(code,nextActiveElement){var scrollHDir;var scrollVDir=this._revertV?code===$.ui.keyCode.DOWN||code===$.ui.keyCode.RIGHT?"up":"down":code===$.ui.keyCode.DOWN||code===$.ui.keyCode.RIGHT?"down":"up";this._setScrollTop(nextActiveElement,this.grid.element.parent(),nextActiveElement.closest("tr"),scrollVDir,nextActiveElement.closest("tr").index());if(this.options.mode==="cell"&&(code===$.ui.keyCode.LEFT||code===$.ui.keyCode.RIGHT)&&!this.grid._isFixedElement(nextActiveElement)){scrollHDir=this._revertH?code===$.ui.keyCode.LEFT?"right":"left":code===$.ui.keyCode.LEFT?"left":"right";this._setScrollLeft(this.grid._hscrollbarcontent(),nextActiveElement,scrollHDir,nextActiveElement.index())}},_setScrollTop:function(nextActiveElement,parent,child,direction,index){var childh,isDown,isUp,v,c,parentOffset=parent.igOffset(),childOffset=child.igOffset();if(!child||child.length===0){return}v=this.grid.options.virtualization||this.grid.options.rowVirtualization;c=v&&this.grid.options.virtualizationMode==="continuous";if(nextActiveElement.attr("rowspan")!==undefined){if(direction==="down"){childh=nextActiveElement.outerHeight()+child.outerHeight()-($(parent).outerHeight()-(childOffset.top-parentOffset.top))}else{childh=child.outerHeight()-(childOffset.top-parentOffset.top)}}else{childh=v&&!c?parseInt(this.grid.options.avgRowHeight,10):child.outerHeight()}if(!v||c){if(nextActiveElement.attr("rowspan")!==undefined){isDown=childOffset.top+nextActiveElement.outerHeight()+this.grid._scrollbarWidth()>parentOffset.top+$(parent).outerHeight()}else{isDown=childOffset.top+childh+this.grid._scrollbarWidth()>parentOffset.top+$(parent).outerHeight()}isUp=childOffset.top-childh/2<=parentOffset.top||c&&index<0}if(index===0&&(!v||c)){parent[0].scrollTop=0}else if(direction==="down"){if(isDown){if(c){this.grid._onVirtualVerticalScroll({},childh,direction)}}}else{if(isUp){if(c){this.grid._onVirtualVerticalScroll({},childh,direction)}}}},_setScrollLeft:function(parent,child,direction,index){var parentOffset=parent.igOffset(),sc,childOffset=child.igOffset(),fullLeft;if(!child||!child.length||!parent.length){return}sc=this.grid.scrollContainer();fullLeft=childOffset.left+(sc.length>0?sc.scrollLeft():0);if(index===0){parent[0].scrollLeft=0;this.grid._synchronizeHScroll()}else if(direction==="right"){if(fullLeft+child.outerWidth()>parentOffset.left+parent.outerWidth()){parent[0].scrollLeft=fullLeft-(parentOffset.left+parent.outerWidth())+child.outerWidth();this.grid._synchronizeHScroll()}}else{if(childOffset.left=0&&srId=0&&erIdendRecordIndex){recordRange=dv.slice(endRecordIndex,startRecordIndex+1)}else{recordRange=dv.slice(startRecordIndex,endRecordIndex+1)}startRecordIndex=Math.min(startRecordIndex,endRecordIndex);if(this.options.mode==="row"){if(!this._pkProp){for(i=0;iendPropIndex){propRange=vcols.slice(endPropIndex,startPropIndex+1)}else{propRange=vcols.slice(startPropIndex,endPropIndex+1)}if(!this._pkProp){for(i=0;iendRowIndex;if(reverse){startRowIndex=startRowIndex+endRowIndex;endRowIndex=startRowIndex-endRowIndex;startRowIndex=startRowIndex-endRowIndex}rowRange=this.grid.element.find("tbody").children("tr:not([data-container]):visible").slice(startRowIndex,endRowIndex+1);if(this.grid.hasFixedColumns()){fixedRowRange=this.grid.fixedBodyContainer().find("tbody").children("tr:not([data-container]):visible").slice(startRowIndex,endRowIndex+1)}if(this.options.mode==="row"){for(i=0;iendCellIndex;if(reverse){startCellIndex=startCellIndex+endCellIndex;endCellIndex=startCellIndex-endCellIndex;startCellIndex=startCellIndex-endCellIndex}crLength=endCellIndex-startCellIndex+1;cellRange=rowRange.find("td:nth-of-type(n+"+(startCellIndex+1)+"):nth-of-type(-n+"+(endCellIndex+1)+")");if(!cellRange.length){return{range:range}}row=cellRange.eq(0).parent();rowIndex=startRowIndex;startElementIndex=startElement.index();for(i=0;i=sri+vrc:false}return rv||cv?rowIdx=sri+vrc||(colIdx=sci+vcc):false},_isDataElement:function(identifier){var type=$.type(identifier);return type==="number"||type==="string"||!identifier.columnKey.startsWith("##")},_suppressKey:function(keyCode){var updating=this.grid.element.data("igGridUpdating"),key;switch(keyCode){case $.ui.keyCode.ENTER:key="enter";break;case $.ui.keyCode.SPACE:key="space";break}if(updating){return updating.options.startEditTriggers.indexOf(key)>=0}return false},_firstDataCellForRow:function(row){return row.children("td:not([data-skip='true'],td[data-parent]):first")},_canBeSelected:function(identifier,target){return!identifier.columnKey&&target&&target.is("tr")&&!target.attr("data-grouprow")&&!target.attr("data-summaryrow")||identifier.columnKey&&!identifier.columnKey.startsWith("##")},_identifierForTarget:function(target){if(target.is("tr")){return this._identifierForRow(target)}if(target.hasClass("ui-iggrid-nongrouprowemptycell")){return this._identifierForDataSkipCell(target,this._gbEmptyCellKey)}if(target.hasClass("ui-iggrid-expandcolumn")){if(target.attr("data-parent")){return this._identifierForDataSkipCell(target,this._hgCellKey)}return this._identifierForDataSkipCell(target,this._gbExpandCellKey)}if(target.attr("data-gbsummary")){return this._identifierForDataSkipCell(target,this._gbSummaryCellKey)}if(target.attr("gbsummaryiconcell")){return this._identifierForDataSkipCell(target,this._gbGroupSummaryIconCellKey)}if(target.attr("gbsummaryemptycell")){return this._identifierForDataSkipCell(target,this._gbGroupSummaryEmptyCellKey)}if(target.attr("gbsummarycell")){return this._identifierForDataSkipCellPerColumn(target,this._gbGroupSummaryCellKey,"{col}")}if(target.hasClass("ui-igtreegrid-non-data-column")&&target.attr("data-skip")){return this._identifierForDataSkipCell(target,this._tgExpandKey)}if(target.is("td")){return this._identifierForCell(target)}if(target.is("th")){return this._identifierForDataSkipCell(target,this._rsCellKey)}return null},_getRowId:function(row){var attrId=row.attr("data-id");if(row.attr("data-grouprow")||row.attr("data-summaryrow")){if(!this._pkProp){return null}return attrId}return this.grid._fixPKValue(attrId)},_identifierForCell:function(cell){var row=cell.parent(),id=this._getRowId(row);if(id===null||id===undefined){id=this._getIndexForRow(row)}return{id:id,columnKey:this._getColKeyForCell(cell)}},_identifierForRow:function(row){var id=this._getRowId(row);if(id!==null&&id!==undefined){return id}return this._getIndexForRow(row)},_identifierForDataSkipCell:function(cell,key){var row=cell.parent(),id=this._getRowId(row);if(id===null||id===undefined){id=this._getIndexForRow(row)}return{id:id,columnKey:key}},_identifierForDataSkipCellPerColumn:function(cell,key,replaceValue){var row=cell.parent(),id=this._getRowId(row),col=this.grid.getColumnByTD(cell);if(id===null||id===undefined){id=this._getIndexForRow(row)}key=key.replace(replaceValue,col.column.key);return{id:id,columnKey:key}},_getRowsByIdentifier:function(identifier){var urow,frow=$();if(!this._pkProp){if(this.grid.hasFixedColumns()){frow=this._getRowByIndex(identifier,true)}urow=this._getRowByIndex(identifier,false)}else{if(this.grid.hasFixedColumns()){frow=this.grid.rowById(identifier,true)}urow=this.grid.rowById(identifier,false)}return urow instanceof $?urow.add(frow):$()},_getCellByIdentifier:function(identifier){var cellRow,isFixed,skippedCells,colIndex,i,cols,sci=this.grid._startColIndex||0;if(identifier.columnKey&&identifier.columnKey.startsWith("##")){return this._getNonDataCellByIdentifier(identifier)}if(!this._pkProp){isFixed=this.grid.isFixedColumn(identifier.columnKey);cellRow=this._getRowByIndex(identifier.id,isFixed);cols=this.grid._visibleColumns(isFixed);skippedCells=cellRow.children("th,[data-skip=true],[data-parent]").length;for(i=0;i=0&&identifier0){args.row.id=a.range[a.range.length-1].id}else if(this._pkProp){args.row.id=a.id}}if(a.startIndex!==undefined){args.startIndex=a.startIndex;args.endIndex=a.endIndex}return this._trigger(this.events.rowSelectionChanging,null,args)},_onRowSelectionChanged:function(a){var args={owner:this,selectedRows:this._selection.selectedRows()};if(a.element&&a.element.length){args.row={element:a.element,index:a.index!==undefined?a.index:this._getIndexForRow(a.element)};if(this._pkProp){args.row.id=a.id||this._identifierForRow(a.element)}}else{args.row={element:$(),index:-1};if(this._pkProp){args.row.id=a.id}}return this._trigger(this.events.rowSelectionChanged,null,args)},_onCellSelectionChanging:function(a){var args={owner:this,selectedCells:this._selection.selectedCells()};if(a.element&&a.element.length){args.cell={element:a.element,row:a.row||a.element.closest("tr"),columnKey:a.id?a.id.columnKey:this._getColKeyForCell(a.element)};args.cell.index=a.index!==undefined?a.index:this._getColIndexByKey(args.cell.columnKey);args.cell.rowIndex=a.rowIndex!==undefined?a.rowIndex:this._getIndexForRow(args.cell.row);if(this._pkProp){args.cell.rowId=a.id?a.id.id:this._identifierForRow(args.cell.row)}}else{args.cell={element:$(),row:$(),columnKey:a.id.columnKey};args.cell.index=-1;args.cell.rowIndex=-1;if(this._pkProp){args.cell.rowId=a.id?a.id.id:null}}if(a.firstColumnIndex!==undefined){args.firstColumnIndex=a.firstColumnIndex;args.firstRowIndex=a.firstRowIndex;args.lastColumnIndex=a.lastColumnIndex;args.lastRowIndex=a.lastRowIndex}return this._trigger(this.events.cellSelectionChanging,null,args)},_onCellSelectionChanged:function(a){var args={owner:this,selectedCells:this._selection.selectedCells()};if(a.element&&a.element.length){args.cell={element:a.element,row:a.row||a.element.closest("tr"),columnKey:a.id?a.id.columnKey:this._getColKeyForCell(a.element)};args.cell.index=a.index!==undefined?a.index:this._getColIndexByKey(args.cell.columnKey);args.cell.rowIndex=a.rowIndex!==undefined?a.rowIndex:this._getIndexForRow(args.cell.row);if(this._pkProp){args.cell.rowId=a.rowId||this._identifierForRow(args.cell.row)}}else{args.cell={element:$(),row:$(),columnKey:a.id.columnKey};args.cell.index=-1;args.cell.rowIndex=-1;if(this._pkProp){args.cell.rowId=a.id?a.id.id:null}}return this._trigger(this.events.cellSelectionChanged,null,args)},_onRowActivationChanging:function(a){var args={owner:this,row:a?{element:a.element,index:this._getIndexForRow(a.element)}:null};if(this._pkProp&&a){args.row.id=a.id}return this._trigger(this.events.activeRowChanging,null,args)},_onRowActivationChanged:function(a){var args={owner:this,row:a?{element:a.element,index:this._getIndexForRow(a.element)}:null};if(this._pkProp&&a){args.row.id=a.id}return this._trigger(this.events.activeRowChanged,null,args)},_onCellActivationChanging:function(a){var args={owner:this,cell:a?{element:a.element,row:a.element.closest("tr")}:null},noCancel=true;if(a){args.cell.index=this._getColIndexByKey(a.id.columnKey);args.cell.rowIndex=this._getIndexForRow(args.cell.row);args.cell.columnKey=a.id.columnKey;if(this._pkProp){args.cell.rowId=a.id.id}}noCancel=this._trigger(this.events.activeCellChanging,null,args);if(!noCancel){this._storedActiveIndex=this._getCellByIdentifier(this._selection.activeElement).index()}return noCancel},_onCellActivationChanged:function(a){var args={owner:this,cell:a?{element:a.element,row:a.element.closest("tr")}:null};if(a){args.cell.index=this._getColIndexByKey(a.id.columnKey);args.cell.rowIndex=this._getIndexForRow(args.cell.row);args.cell.columnKey=a.id.columnKey;if(this._pkProp){args.cell.rowId=a.id.id}}return this._trigger(this.events.activeCellChanged,null,args)},_select:function(info){var element=info.element||this._selection.elementFromIdentifier(info.id);if(element.is("tr")){element.children("td").not("[data-skip=true]").addClass(this.css.selectedCell)}else{element.addClass(this.css.selectedCell)}element.attr("aria-selected",true)},_deselect:function(info){var element=info.element||this._selection.elementFromIdentifier(info.id);if(element.is("tr")){element.children("td").removeClass(this.css.selectedCell)}else{element.removeClass(this.css.selectedCell)}element.attr("aria-selected",false)},_resizeGridWidth:function(decrease){if(decrease&&this._gridWidthDecreased||!decrease&&!this._gridWidthDecreased){return}var grid=this.grid,diff,padding=parseInt(grid.element.find("tbody tr td:last-child").css(grid._padding),10),$col=grid.element.find("colgroup:first>col:last");this._scrollbarWidth=this._scrollbarWidth||grid._scrollbarWidth();diff=this._scrollbarWidth;this._gridWidthDecreased=false;if(decrease){diff=-diff;this._gridWidthDecreased=true}grid.element.find("tbody tr td:last-child").css({"padding-right":padding+diff,"border-right":diff>0?"1px":"0px"});grid.element.css("width",grid.element.width()+diff);$col.width($col.width()+diff)},_isScrollbarOverLastCells:function(){if(this._isScrollbarOverLastCellsCache===undefined||this._isScrollbarOverLastCellsCache===null){var opts=this.grid.options,hasFixedHeaders=opts.showHeader&&opts.fixedHeaders===true&&opts.height!==null,hasVirtualization=opts.virtualization===true||opts.columnVirtualization===true||opts.rowVirtualization===true,lastColInPixels=this.grid._lastColPixelWidth!==undefined&&this.grid._lastColPixelWidth!==null,hasHorizontalScrollbar=this.grid._hscrollbar().length>0;this._isScrollbarOverLastCellsCache=this.grid._hasVerticalScrollbar&&hasFixedHeaders&&!hasVirtualization&&hasHorizontalScrollbar&&lastColInPixels}return this._isScrollbarOverLastCellsCache},_activate:function(element){var initiallyFocused,me=this;if(element.is("tr")){element.addClass(this.css.activeRow);initiallyFocused=element.filter(".initially-focused");if(initiallyFocused.length){initiallyFocused.focus();initiallyFocused.removeClass("initially-focused"); return}}else{element.addClass(this.css.activeCell)}if(this.options.mode==="cell"&&$.ig.util.isIE&&element.is(":last-child")&&this._isScrollbarOverLastCells()){this._resizeGridWidth(true);element.focus();if(this._timeoutResizeGrid){clearTimeout(this._timeoutResizeGrid);this._timeoutResizeGrid=null}this._timeoutResizeGrid=setTimeout(function(){me._resizeGridWidth(false)},100)}else{element.focus()}},_deactivate:function(){if(this.grid.hasFixedColumns()){if(this.options.mode==="row"){this.grid.fixedBodyContainer().find("tbody").find("tr.ui-iggrid-activerow").removeClass(this.css.activeRow)}else{this.grid.fixedBodyContainer().find("tbody").find("td.ui-iggrid-activecell").removeClass(this.css.activeCell)}}if(this.options.mode==="row"){this.grid.element.find("tbody").find("tr.ui-iggrid-activerow").removeClass(this.css.activeRow)}else{this.grid.element.find("tbody").find("td.ui-iggrid-activecell").removeClass(this.css.activeCell)}},_clearSelection:function(){this.grid.fixedBodyContainer().find("tbody").find("td.ui-iggrid-selectedcell").removeClass(this.css.selectedCell).attr("aria-selected",false);this.grid.fixedBodyContainer().find("tbody").find("tr[aria-selected]").attr("aria-selected",false);this.grid.element.children("tbody").find("td.ui-iggrid-selectedcell").removeClass(this.css.selectedCell).attr("aria-selected",false);this.grid.element.children("tbody").find("tr[aria-selected]").attr("aria-selected",false)},_createHandlers:function(){this._dataRenderingHandler=$.proxy(this._dataRendering,this);this._virtualRecordsRenderingHandler=$.proxy(this._virtualRecordsRendering,this);this._virtualRecordsRendererHandler=$.proxy(this._virtualRecordsRender,this);this._columnsCollectionModifiedHandler=$.proxy(this._columnsCollectionModified,this);this._mouseDownHandler=$.proxy(this._mouseDown,this);this._mouseMoveHandler=$.proxy(this._mouseMove,this);this._mouseUpHandler=$.proxy(this._mouseUp,this);this._pointerDownHandler=$.proxy(this._pointerDown,this);this._pointerMoveHandler=$.proxy(this._pointerMove,this);this._pointerUpHandler=$.proxy(this._pointerUp,this);this._selectStartHandler=$.proxy(this._selectStart,this);this._selectStartContainerHandler=$.proxy(this._selectStartContainer,this);this._releaseMouseHandler=$.proxy(this._releaseMouse,this);this._touchStartHandler=$.proxy(this._touchStart,this);this._touchEndHandler=$.proxy(this._touchEnd,this);this._touchMoveHandler=$.proxy(this._touchMove,this);this._keyDownHandler=$.proxy(this._keyDown,this);this._containerFocusHandler=$.proxy(this._containerFocus,this);this._focusInHandler=$.proxy(this._tbodyFocusIn,this);this._focusOutHandler=$.proxy(this._tbodyFocusOut,this);this._preventDefaultHandler=$.proxy(this._preventDefault,this)},_unregisterEvents:function(){var gOpts=this.grid.options,tbody=this.grid.element.find("tbody").add(this.grid.fixedBodyContainer().find("tbody")),hasVirtualization=gOpts.virtualization||gOpts.rowVirtualization||gOpts.columnVirtualization,scrollCont=hasVirtualization?this.grid._vdisplaycontainer():this.grid.scrollContainer();if(this._tbodyBinding){tbody.unbind(this._tbodyBinding)}$(document).unbind("mouseup."+this.grid.id()+"_selection");scrollCont.unbind("scroll",this._releaseMouseHandler);this.grid.container().unbind("selectstart",this._selectStartContainerHandler);this.grid.element.removeClass("ui-iggrid-canceltextselection");if(this.options.mode==="row"){this.grid.element.find("tbody td").unbind("mousedown",this._preventDefaultHandler)}},_registerEvents:function(){var gOpts=this.grid.options,tbody=this.grid.element.find("tbody").add(this.grid.fixedBodyContainer().find("tbody")),hasVirtualization=gOpts.virtualization||gOpts.rowVirtualization||gOpts.columnVirtualization,scrollCont=hasVirtualization?this.grid._vdisplaycontainer():this.grid.scrollContainer();this._tbodyBinding=this._tbodyBinding||this._generateTbodyBinding();tbody.unbind(this._tbodyBinding).bind(this._tbodyBinding);$(document).bind("mouseup."+this.grid.id()+"_selection",this._releaseMouseHandler);scrollCont.bind("scroll",this._releaseMouseHandler);scrollCont.bind("igscrollscrolling",this._releaseMouseHandler);this.grid.container().bind("selectstart",this._selectStartContainerHandler);if(this.options.multipleSelection===true){this.grid.element.addClass("ui-iggrid-canceltextselection")}if(this.options.mode==="row"){this.grid.element.find("tbody td").bind("mousedown",this._preventDefaultHandler)}},_generateTbodyBinding:function(){var binding={};binding.selectstart=this._selectStartHandler;binding.focusin=this._focusInHandler;binding.focusout=this._focusOutHandler;binding.keydown=this._keyDownHandler;if($.ig.util.isTouch){binding.touchstart=this._touchStartHandler;binding.touchend=this._touchEndHandler;binding.touchmove=this._touchMoveHandler}if(window.navigator.msPointerEnabled||window.navigator.pointerEnabled){binding.MSPointerDown=this._pointerDownHandler;binding.MSPointerMove=this._pointerMoveHandler;binding.MSPointerUp=this._pointerUpHandler;binding.pointerdown=this._pointerDownHandler;binding.pointermove=this._pointerMoveHandler;binding.pointerup=this._pointerUpHandler}else{binding.mousedown=this._mouseDownHandler;binding.mousemove=this._mouseMoveHandler;binding.mouseup=this._mouseUpHandler}return binding},_injectGrid:function(gridInstance,isRebind){var i;this.grid=gridInstance;for(i=0;i0){return ownSelection._getIndexForRow(element)}return ownSelection._getRecordByIdentifier(identifier).index},onlyOneSelected:function(){return Object.keys(this.selection).length===1},_markSelected:function(identifier,info){this.selection[identifier]=info||true},_markUnselected:function(identifier){delete this.selection[identifier]},_selectedRowObject:function(identifier){var rowInfo=this.selection[identifier];if($.type(rowInfo)!=="object"){rowInfo={};this.selection[identifier]=rowInfo}if(this.invalid){rowInfo.element=this.elementFromIdentifier(identifier);rowInfo.index=this.elementPosition(identifier,rowInfo.element)}else{rowInfo.element=rowInfo.element||this.elementFromIdentifier(identifier);rowInfo.index=rowInfo.index!==undefined&&rowInfo.index!==null?rowInfo.index:this.elementPosition(identifier,rowInfo.element)}return $.extend(true,{},rowInfo,{id:identifier})},_selectionMode:function(){return"Row"}});$.ig.SelectedCellsCollection=$.ig.SelectedCellsCollection||$.ig.SelectionCollection.extend({isSelected:function(identifier,forOwner){if(forOwner&&this.settings.owner!==forOwner){return false}return this.selection[identifier.id]!==undefined&&this.selection[identifier.id][identifier.columnKey]!==undefined},atLeastOneSelected:function(rowId,forOwner){if(forOwner&&this.settings.owner!==forOwner){return false}return Object.keys(this.selection[rowId]).length>0},isActive:function(identifier,forOwner){if(forOwner&&this.settings.owner!==forOwner){return false}return this.activeElement&&this.activeElement.id===identifier.id&&this.activeElement.columnKey===identifier.columnKey},selectedCells:function(){var cells=[],sid,rowKey,columnKey,id;for(rowKey in this.selection){if(this.selection.hasOwnProperty(rowKey)){for(columnKey in this.selection[rowKey]){if(this.selection[rowKey].hasOwnProperty(columnKey)){id=this.settings.owner._fixPKValue(rowKey);id=isNaN(id)?rowKey:id;sid={id:id,columnKey:columnKey};cells.push(this._selectedCellObject(sid))}}}}this.invalid=false;return cells},activeCell:function(){var cell,pos;if(this.activeElement){cell=this.elementFromIdentifier(this.activeElement);pos=this.elementPosition(this.activeElement,cell);return{row:cell.parent(),id:this.activeElement.id,columnKey:this.activeElement.columnKey,rowIndex:pos.x,index:pos.y,element:cell}}return null},elementFromIdentifier:function(identifier){return this.settings.owner.element.data("igGridSelection")._getCellByIdentifier(identifier)},elementPosition:function(identifier,element){var ownSelection=this.settings.owner.element.data("igGridSelection");if(element&&element.length>0){return{x:ownSelection._getIndexForRow(element.parent()),y:element.index()}}return{x:ownSelection._getRecordByIdentifier(identifier.id).index,y:ownSelection._getColIndexByKey(identifier.columnKey)}},onlyOneSelected:function(){var rKeys=Object.keys(this.selection);if(rKeys.length===1){return Object.keys(this.selection[rKeys[0]]).length===1}return false},_lockSelection:function(){var rowId,cellId;for(rowId in this.selection){if(this.selection.hasOwnProperty(rowId)){for(cellId in this.selection[rowId]){if(this.selection[rowId].hasOwnProperty(cellId)){if($.type(this.selection[rowId][cellId]==="object")){this.selection[rowId][cellId].locked=true}else{this.selection[rowId][cellId]={locked:true}}}}}}},_markSelected:function(identifier,info){this.selection[identifier.id]=this.selection[identifier.id]||{};this.selection[identifier.id][identifier.columnKey]=info||true},_markUnselected:function(identifier){if(!this.selection[identifier.id]){return}delete this.selection[identifier.id][identifier.columnKey]},_unlockSelected:function(identifier){var c;if(!this.selection[identifier.id]){return false}c=this.selection[identifier.id][identifier.columnKey];if($.type(c)==="object"){if(!c.locked){delete this.selection[identifier.id][identifier.columnKey];return true}return false}delete this.selection[identifier.id][identifier.columnKey];return true},_rangeUnlock:function(range){var i;for(i=0;i