/*!@license
 * Infragistics.Web.ClientUI Grid Selection (and Keyboard navigation) 21.2.12
 *
 * Copyright (c) 2011-2022 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().length<col||col<0){return}cellId={id:this._pkProp?row[this._pkProp]:row,columnKey:this.grid._visibleColumns()[col].key};cellElement=$()}else{row-=this.grid._startRowIndex||0;col-=this.grid._startColIndex||0;rowElement=this._getRowByIndex(row,isFixed);cellId=this._identifierForCell(this._getCellByIndex(col,rowElement));cellElement=this._getCellByIdentifier(cellId)}if(this._selection.settings.owner!==this.grid){this._selection.changeOwner(this.grid)}if(this.options.activation){if($.ig.util.isTouchDevice()){this.grid._setIgScrollPositionTop(0)}this._selection.activate(cellId,cellElement)}if(!this._selection.isSelected(cellId,this.grid)){this._selection.select(cellId,true,{element:cellElement},true)}},selectCellById:function(id,colKey){var identifier={id:id,columnKey:colKey};if(this.options.mode==="row"){return}if(!this._selection.isSelected(identifier,this.grid)){if(this._selection.settings.owner!==this.grid){this._selection.changeOwner(this.grid)}this._selection.select(identifier,true,{element:this._getCellByIdentifier(identifier)},true)}},deselectCell:function(row,col,isFixed){var rowElement,cellId,cellElement;row-=this.grid._startRowIndex||0;col-=this.grid._startColIndex||0;rowElement=this._getRowByIndex(row,isFixed);cellId=this._identifierForCell(this._getCellByIndex(col,rowElement));cellElement=this._getCellByIdentifier(cellId);if(this.options.mode==="row"){return}if(this._selection.isSelected(cellId,this.grid)){this._selection.deselect(cellId,{element:cellElement},true)}},deselectCellById:function(id,colKey){var identifier={id:id,columnKey:colKey};if(this.options.mode==="row"){return}if(this._selection.isSelected(identifier,this.grid)){this._selection.deselect(identifier,{element:this._getCellByIdentifier(identifier)},true)}},selectRow:function(index){var row,rowId;if(this.options.mode==="cell"){return}if(this._isOutOfView(index)){row=this.grid._getDataView()[index];if(!row){return}rowId=this._pkProp?row[this._pkProp]:index;row=$()}else{index-=this.grid._startRowIndex||0;row=this._getRowByIndex(index,false).add(this._getRowByIndex(index,true));rowId=this._identifierForRow(row.eq(0))}if(this._selection.settings.owner!==this.grid){this._selection.changeOwner(this.grid)}if(this.options.activation){if($.ig.util.isTouchDevice()){this.grid._setIgScrollPositionTop(0)}this._selection.activate(rowId,row)}if(!this._selection.isSelected(rowId,this.grid)){this._selection.select(rowId,true,{element:row},true)}},selectRowById:function(id){if(this.options.mode==="cell"){return}if(!this._selection.isSelected(id,this.grid)){if(this._selection.settings.owner!==this.grid){this._selection.changeOwner(this.grid)}this._selection.select(id,true,{element:this._getRowsByIdentifier(id)},true)}},deselectRow:function(index){var row,rowId;index-=this.grid._startRowIndex||0;row=this._getRowByIndex(index,false).add(this._getRowByIndex(index,true));rowId=this._identifierForRow(row.eq(0));if(this.options.mode==="cell"){return}if(this._selection.isSelected(rowId,this.grid)){this._selection.deselect(rowId,{element:row},true)}},deselectRowById:function(id){if(this.options.mode==="cell"){return}if(this._selection.isSelected(id,this.grid)){this._selection.deselect(id,{element:this._getRowsByIdentifier(id)},true)}},selectedCells:function(){if(this._selection.settings.owner!==this.grid){return[]}return this.options.multipleSelection?this._selection.selectedCells():null},selectedRows:function(){if(this._selection.settings.owner!==this.grid){return[]}return this.options.multipleSelection?this._selection.selectedRows():null},selectedCell:function(){var selectedCells;if(this._selection.settings.owner!==this.grid){return null}selectedCells=this._selection.selectedCells();return this.options.multipleSelection?null:selectedCells.length===1?selectedCells[0]:null},selectedRow:function(){var selectedRows;if(this._selection.settings.owner!==this.grid){return null}selectedRows=this._selection.selectedRows();return this.options.multipleSelection?null:selectedRows.length===1?selectedRows[0]:null},activeCell:function(){if(this.options.mode==="row"){return null}if(this._selection.settings.owner!==this.grid){return null}return this._selection.activeCell()},activeRow:function(){if(this.options.mode==="cell"){return null}if(this._selection.settings.owner!==this.grid){return null}return this._selection.activeRow()},_singleSelectChange:function(target,ctrlKey){var tId,tIdx,oldT=target;if(this.options.mode==="row"){target=target.closest("tr");target.addClass("initially-focused");if(this.grid.hasFixedColumns()){tIdx=target.index();target=target.add(this._getRowByIndex(tIdx,!this.grid._isFixedElement(target)))}}else{target=target.closest("td")}if(this._selection.settings.owner!==this.grid){this._selection.changeOwner(this.grid)}tId=this._identifierForTarget(target);if(this.options.activation&&(oldT.is("tr")||oldT.is("td"))){this._selection.activate(tId,target)}if(this._canBeSelected(tId,target)){this._selection.select(tId,ctrlKey,{element:target})}},_shiftSelectChange:function(target){var tId,rangeStats,keep=this.options.mode==="cell"&&this.options.allowMultipleRangeSelection,v=this.grid.options.virtualization||this.grid.options.rowVirtualization||this.grid.options.columnVirtualization;target=this.options.mode==="row"?target.closest("tr"):target.closest("td");if(this._selection.settings.owner!==this.grid){this._selection.changeOwner(this.grid)}tId=this._identifierForTarget(target);if(!this._canBeSelected(tId,target)){return}if(this._selection.rangeSelectStart===null||this._selection.rangeSelectStart===undefined){this._selection.rangeSelectStart=tId;this._selection.rangeSelectEnd=null}else if(this._selection.rangeSelectEnd===tId||this._selection.rangeSelectStart===this._selection.rangeSelectEnd&&this._selection.rangeSelectStart===tId){return}else{this._selection.rangeSelectEnd=tId}if(v){rangeStats=this._getRecordRange(this._selection.rangeSelectStart,tId)}else{rangeStats=this._getElementRange(this._selection.rangeSelectStart,tId)}if(!rangeStats.range||!rangeStats.range.length){return}if(keep){this._selection.rangeSelect(rangeStats.range,false,this._previousRangeCache,rangeStats,false);this._previousRangeCache=rangeStats.range}else{this._selection.rangeSelect(rangeStats.range,false,null,rangeStats,false)}},_navigate:function(code,ctrlKey,shiftKey,prevElementOverride){var prevActiveElement=prevElementOverride||this._selection.activeElement,nextActiveElementParent,childSelection,nextActiveElement=this._getNextActiveElement(code,!shiftKey&&this.options.wrapAround,prevActiveElement);if(!nextActiveElement||nextActiveElement.length===0){return}nextActiveElementParent=nextActiveElement.closest(".ui-iggrid-table");if(nextActiveElementParent.attr("id")!==this.grid.id()&&nextActiveElement.closest(".ui-iggrid").attr("id")!==this.grid.container().attr("id")){childSelection=nextActiveElementParent.data("igGridSelection");this._selection.changeOwner(childSelection.grid);nextActiveElementParent.closest(".ui-iggrid").focus();childSelection._storedActiveIndex=null;childSelection._navigateOwn(nextActiveElement,prevActiveElement,code,ctrlKey,shiftKey)}else{this._navigateOwn(nextActiveElement,prevActiveElement,code,ctrlKey,shiftKey)}},_navigateOwn:function(nextActiveElement,prevActiveElement,code,ctrlKey,shiftKey){var nextId=this._identifierForTarget(nextActiveElement),prevElement=this._selection.elementFromIdentifier(prevActiveElement),prevRowIndex=prevElement.is("tr")?this.grid.getElementInfo(prevElement).rowIndex:0,nextRowIndex=nextActiveElement.is("tr")?this.grid.getElementInfo(nextActiveElement).rowIndex:0,deselectRowOnShift=false;if(nextActiveElement.is("tr")&&this.grid.hasFixedColumns()){nextActiveElement.addClass("initially-focused");nextActiveElement=nextActiveElement.add(this._getRowByIndex(nextActiveElement.index(),!this.grid._isFixedElement(nextActiveElement)))}if(!nextActiveElement.is("tr")&&nextId.columnKey.startsWith("##")&&shiftKey){this._navigate(code,ctrlKey,shiftKey,nextId);return}this._selection.activate(nextId,nextActiveElement);if(ctrlKey){this._setScroll(code,nextActiveElement);return}if(shiftKey){if(this.options.mode==="row"||!this.options.multipleSelection){if(!this._rangeSelectionStartIndex){this._rangeSelectionStartIndex=prevRowIndex}if(nextRowIndex-prevRowIndex<0&&prevRowIndex>this._rangeSelectionStartIndex||nextRowIndex-prevRowIndex>0&&prevRowIndex<this._rangeSelectionStartIndex){deselectRowOnShift=true}if(deselectRowOnShift&&this._canBeSelected(prevActiveElement,prevElement)&&(this._selection.isSelected(this._selection.activeElement,this.grid)||!this._canBeSelected(nextId,nextActiveElement))){this._selection.deselect(prevActiveElement)}else if(!deselectRowOnShift&&this._canBeSelected(nextId,nextActiveElement)){this._selection.toggle(nextActiveElement)}}else{this._shiftSelectChange(nextActiveElement,false)}}else{if(nextId.columnKey&&nextId.columnKey.startsWith("##")||!this._canBeSelected(nextId,nextActiveElement)){if(this._selection.isSelected(prevActiveElement)){this._selection.clearSelection()}}else{this._rangeSelectionStartIndex=null;this._selection.select(nextId,false,{element:nextActiveElement})}}this._setScroll(code,nextActiveElement)},_handleToggle:function(ctrlKey){var element=this._selection.elementFromIdentifier(this._selection.activeElement),row,cell;if(element.is("th")){row=this._getRowsByIdentifier(this._selection.activeElement.id);if(this.grid.hasFixedColumns()&&this.grid._isFixedElement(element)){cell=this._firstDataCellForRow(row.first())}else{cell=this._firstDataCellForRow(row.last())}this._singleSelectChange(cell,ctrlKey)}else if(element.attr("data-parent")){element.closest(".ui-iggrid-root").igHierarchicalGrid("toggle",element.closest("tr"))}else if(element.hasClass("ui-igtreegrid-expansion-indicator-cell")&&element.attr("data-expand-cell")){element.closest(".ui-iggrid-table").igTreeGrid("toggleRow",element.closest("tr"))}},_getNextActiveElement:function(code,wrapAround,override){var currentActiveElement=override instanceof $?override:this._selection.elementFromIdentifier(override||this._selection.activeElement),currentRow=currentActiveElement.closest("tr"),currentCellIndex=currentActiveElement.index(),hasFixedCols=this.grid.hasFixedColumns(),isFixedElement=hasFixedCols?this.grid._isFixedElement(currentActiveElement):false,fixingDir=this.grid.fixingDirection(),nextElement,nextElementIndex,nextRow,wrapped,go=this.grid.options,vVirt=go.virtualization||go.rowVirtualization,cellRowSpan=currentActiveElement.attr("rowspan")!==undefined,cellColSpan=currentActiveElement.attr("colspan")!==undefined,cellColSpanVal=parseInt(currentActiveElement.attr("colspan")),hierRowSkip=this.options.skipChildren?"[data-container=true]":"",lastSmallSelection;if(!this._rowMergeOffset){this._rowMergeOffset=0}if(this._selectionHistory&&this._selectionHistory.length===1){this._rowMergeOffset=0}if(code===$.ui.keyCode.UP){nextRow=this._getPrevRow(currentRow,wrapAround,isFixedElement,false,vVirt);currentRow=nextRow;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)}}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._selectionHistory.length;i++){nextCell=this._selectionHistory[i-1];curCell=this._selectionHistory[i];if(nextCell.keyCode===$.ui.keyCode.UP||nextCell.keyCode===$.ui.keyCode.DOWN){break}if(curCell.elem===null||!curCell.elem.attr("rowspan")){return curCell}else if(parseInt(curCell.elem.attr("rowspan"))<curRowspan){targetCell=curCell;curRowspan=parseInt(targetCell.elem.attr("rowspan"))}}return targetCell},_cleanHistorySaveNextRow:function(keyCode,wrapAround,isFixedElement,hasFixedCols,vVirt){var smallestCell=this._findLastSmallestCellGroupSelected(),cellRow=smallestCell.rowOfElem,nextRow=this._getNextRow(cellRow,wrapAround,isFixedElement,hasFixedCols,vVirt);this._selectionHistory=[{elem:null,elemIndex:smallestCell.elemIndex,rowOfElem:nextRow?nextRow:cellRow,keyCode:keyCode}]},_cleanHistorySavePrevRow:function(keyCode,wrapAround,isFixedElement,hasFixedCols,vVirt){var smallestCell=this._findLastSmallestCellGroupSelected(),cellRow=smallestCell.rowOfElem,prevRow=this._getPrevRow(cellRow,wrapAround,isFixedElement,hasFixedCols,vVirt);this._selectionHistory=[{elem:null,elemIndex:smallestCell.elemIndex,rowOfElem:prevRow?prevRow:cellRow,keyCode:keyCode}]},_getNextRowByEndMergedCell:function(code,wrapAround,isFixedElement,fixingDir){var nextRow,hasFixedCols=this.grid.hasFixedColumns(),vVirt=this.grid.options.virtualization||this.grid.options.rowVirtualization,lastSmallSelection=this._findLastSmallestCellGroupSelected(),smallRowSelected=lastSmallSelection.rowOfElem,prevRowSelected=this._selectionHistory[1].rowOfElem;if(code===$.ui.keyCode.RIGHT){if(this._selectionHistory[0].keyCode===$.ui.keyCode.UP){nextRow=this._getRowByIndex(prevRowSelected.index(),hasFixedCols?!isFixedElement:false)}else if(isFixedElement&&fixingDir==="left"||!isFixedElement&&fixingDir==="right"){nextRow=this._getRowByIndex(smallRowSelected.index(),!isFixedElement)}else{nextRow=this._getNextRow(smallRowSelected,wrapAround,isFixedElement,hasFixedCols,vVirt)}}else if(code===$.ui.keyCode.LEFT){if(this._selectionHistory[0].keyCode===$.ui.keyCode.UP){nextRow=this._getPrevRow(prevRowSelected,wrapAround,isFixedElement,hasFixedCols,vVirt);nextRow=this._getPrevRow(nextRow,wrapAround,isFixedElement,hasFixedCols,vVirt);this._selectionHistory.shift();this._cleanHistorySavePrevRow(code,wrapAround,false,hasFixedCols,vVirt)}else if(!isFixedElement&&fixingDir==="left"||isFixedElement&&fixingDir==="right"){nextRow=this._getRowByIndex(smallRowSelected.index(),!isFixedElement)}else{nextRow=this._getPrevRow(smallRowSelected,wrapAround,isFixedElement,hasFixedCols,vVirt)}}return nextRow},_getNextRow:function(currentRow,wrapAround,isFixed,swap,virt){var hierRowSkip=this.options.skipChildren?"[data-container=true]":"",nextRow,cIdx;if(virt){cIdx=currentRow.index();if(cIdx>=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;i<ds.length;i++){if(!ds[i].ig_pk){ds[i].ig_pk=$.ig.util.getCheckSumForObject(ds[i])}}},_initSelectionCollection:function(){var rootGrid,opts;rootGrid=this.grid.element.closest(".ui-iggrid-root");if(rootGrid.length>0){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<parentOffset.left){parent[0].scrollLeft=parent[0].scrollLeft-child.outerWidth();this.grid._synchronizeHScroll()}}},_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},_getRecordRange:function(start,end,data){var startRecord,endRecord,startRecordIndex,endRecordIndex,startPropIndex,endPropIndex,range=[],recordRange,propRange,i,j,dv=data?data:this.grid._getDataView(),srId,erId,vcols=this.grid._visibleColumns();if(this.options.mode==="row"){srId=start;erId=end}else{srId=start.id;erId=end.id}if(this._pkProp){for(i=0;i<dv.length;i++){if(dv[i][this._pkProp]===srId){startRecord=dv[i];startRecordIndex=i}if(dv[i][this._pkProp]===erId){endRecord=dv[i];endRecordIndex=i}if(startRecord&&endRecord){break}}}else{startRecord=srId>=0&&srId<dv.length?dv[srId]:null;startRecordIndex=srId;endRecord=erId>=0&&erId<dv.length?dv[erId]:null;endRecordIndex=erId}if(!startRecord||!endRecord){return}if(startRecordIndex>endRecordIndex){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;i<recordRange.length;i++){range.push({id:i+startRecordIndex})}}else{for(i=0;i<recordRange.length;i++){if(!recordRange[i].__gbRecord){range.push({id:recordRange[i][this._pkProp]})}}}return{startIndex:startRecordIndex,endIndex:endRecordIndex,active:end,element:this._getRowsByIdentifier(end),range:range}}for(i=0;i<vcols.length;i++){if(vcols[i].key===start.columnKey){startPropIndex=i}if(vcols[i].key===end.columnKey){endPropIndex=i}if(startPropIndex!==undefined&&endPropIndex!==undefined){break}}if(startPropIndex===undefined||endPropIndex===undefined){return}if(startPropIndex>endPropIndex){propRange=vcols.slice(endPropIndex,startPropIndex+1)}else{propRange=vcols.slice(startPropIndex,endPropIndex+1)}if(!this._pkProp){for(i=0;i<recordRange.length;i++){for(j=0;j<propRange.length;j++){range.push({id:{id:i+startRecordIndex,columnKey:propRange[j].key}})}}}else{for(i=0;i<recordRange.length;i++){for(j=0;j<propRange.length;j++){range.push({id:{id:recordRange[i][this._pkProp],columnKey:propRange[j].key}})}}}return{firstRowIndex:startRecordIndex,lastRowIndex:endRecordIndex,firstColumnIndex:startPropIndex,lastColumnIndex:endPropIndex,active:end,element:this._getCellByIdentifier(end),range:range}},_getElementRange:function(start,end){var startElement,endElement,startRowIndex,endRowIndex,range=[],i,reverse,rowRange,fixedRowRange,cellRange,rowIndex,isStartFixed,isEndFixed,rowIdentifier,rowElement;startElement=this._selection.elementFromIdentifier(start);endElement=this._selection.elementFromIdentifier(end);startRowIndex=this._getIndexForRow(startElement.closest("tr"));endRowIndex=this._getIndexForRow(endElement.closest("tr"));reverse=startRowIndex>endRowIndex;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;i<rowRange.length;i++){rowIndex=i+startRowIndex;rowIdentifier=this._identifierForRow(rowRange.eq(i));rowElement=rowRange.eq(i);if(this._canBeSelected(rowIdentifier,rowElement)){range.push({id:this._pkProp?this._identifierForRow(rowElement):rowIndex,index:rowIndex,element:rowElement.add(fixedRowRange?fixedRowRange.eq(i):null)})}}return{startIndex:startRowIndex,endIndex:endRowIndex,active:end,element:endElement,range:range}}if(this.grid.hasFixedColumns()){isStartFixed=this.grid._isFixedElement(startElement);isEndFixed=this.grid._isFixedElement(endElement);if(isStartFixed&&isEndFixed){cellRange=this._getCellRangeFor(fixedRowRange,startElement,endElement,startRowIndex)}else if(isStartFixed!==isEndFixed){cellRange=this._getCrossCellRange(rowRange,fixedRowRange,startElement,endElement,startRowIndex)}else{cellRange=this._getCellRangeFor(rowRange,startElement,endElement,startRowIndex)}}else{cellRange=this._getCellRangeFor(rowRange,startElement,endElement,startRowIndex)}return $.extend(cellRange,{firstRowIndex:startRowIndex,lastRowIndex:endRowIndex,active:end,element:endElement})},_getCrossCellRange:function(rowRange,fixedRowRange,startElement,endElement,startRowIndex){var fixingDir=this.grid.fixedBodyContainer().attr("data-fixing-direction"),startFixedElement,endFixedElement,startUnfixedElement,endUnfixedElement,startFixedRow,endFixedRow,startUnfixedRow,endUnfixedRow,unfixedRange,fixedRange;if(this.grid._isFixedElement(startElement)){startFixedRow=startElement.parent();startFixedElement=startElement;endUnfixedRow=endElement.parent();endUnfixedElement=endElement;endFixedRow=this._getRowByIndex(endUnfixedRow.index(),true);startUnfixedRow=this._getRowByIndex(startFixedRow.index(),false);if(fixingDir==="left"){endFixedElement=endFixedRow.children("td:not([data-skip=true])").last();startUnfixedElement=startUnfixedRow.children("td:not([data-skip=true])").first()}else{endFixedElement=endFixedRow.children("td:not([data-skip=true])").first();startUnfixedElement=startUnfixedRow.children("td:not([data-skip=true])").last()}}else{startUnfixedRow=startElement.parent();startUnfixedElement=startElement;endFixedRow=endElement.parent();endFixedElement=endElement;endUnfixedRow=this._getRowByIndex(endFixedRow.index(),false);startFixedRow=this._getRowByIndex(startUnfixedRow.index(),true);if(fixingDir==="left"){endUnfixedElement=endUnfixedRow.children("td:not([data-skip=true])").first();startFixedElement=startFixedRow.children("td:not([data-skip=true])").last()}else{endUnfixedElement=endUnfixedRow.children("td:not([data-skip=true])").last();startFixedElement=startFixedRow.children("td:not([data-skip=true])").first()}}fixedRange=this._getCellRangeFor(fixedRowRange,startFixedElement,endFixedElement,startRowIndex);unfixedRange=this._getCellRangeFor(rowRange,startUnfixedElement,endUnfixedElement,startRowIndex);return{range:fixedRange.range.concat(unfixedRange.range),firstColumnIndex:fixedRange.startCellIndex,lastColumnIndex:fixedRange.endCellIndex}},_getCellRangeFor:function(rowRange,startElement,endElement,startRowIndex){var startCellIndex,endCellIndex,reverse,crLength,cellRange,range=[],row,rowIndex,cell,cellIndex,cellId,i,startElementIndex;startCellIndex=startElement.parent().children("td").index(startElement);endCellIndex=endElement.parent().children("td").index(endElement);reverse=startCellIndex>endCellIndex;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<cellRange.length;i++){cell=cellRange.eq(i);if(cell.parent()[0]!==row[0]){row=cell.parent();rowIndex=startRowIndex+Math.floor(i/crLength)}cellIndex=i%crLength+startElementIndex;cellId=this._identifierForTarget(cell);if(this._canBeSelected(cellId)){range.push({id:cellId,element:cell,rowIndex:rowIndex,index:cellIndex})}}return{firstColumnIndex:startCellIndex,lastColumnIndex:endCellIndex,range:range}},_isOutOfView:function(rowIdx,colIdx){var rv=this.grid.options.rowVirtualization||this.grid.options.virtualization,cv=this.grid.options.columnVirtualization||this.grid.options.virtualization,sri=this.grid._startRowIndex||0,sci=this.grid._startColIndex||0,vrc=this.grid._virtualRowCount,vcc=this.grid._virtualColumnCount;if(colIdx===null||colIdx===undefined){return rv?rowIdx<sri||rowIdx>=sri+vrc:false}return rv||cv?rowIdx<sri||rowIdx>=sri+vrc||(colIdx<sci||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<cols.length;i++){if(cols[i].key===identifier.columnKey){colIndex=i;break}}return cellRow.children("td:nth-child("+(colIndex+1+skippedCells-sci)+")")}return this.grid.cellById(identifier.id,identifier.columnKey)||$()},_getNonDataCellPerColumnByIdentifier:function(cellRow,identifier){var colKey=identifier.columnKey.replace(/#/g,"").split("_")[1];return cellRow.children("td[aria-describedby='"+this.grid.id()+"_"+colKey+"']")},_getNonDataCellByIdentifier:function(identifier){var cellRow;if(!this._pkProp){cellRow=this._getRowByIndex(identifier.id,this.grid.hasFixedColumns())}else{cellRow=this._getRowsByIdentifier(identifier.id)}if(/##GBGSCEL_([^\s]+)##/.test(identifier.columnKey)){return this._getNonDataCellPerColumnByIdentifier(cellRow,identifier)}switch(identifier.columnKey){case this._rsCellKey:return cellRow.children("th:first");case this._gbEmptyCellKey:return cellRow.children(".ui-iggrid-nongrouprowemptycell:first");case this._gbExpandCellKey:return cellRow.children().first();case this._gbSummaryCellKey:return cellRow.children().last();case this._gbGroupSummaryIconCellKey:return cellRow.children().first();case this._gbGroupSummaryEmptyCellKey:return cellRow.children(".ui-iggrid-summaryemptycellcolumn:first");case this._hgCellKey:return cellRow.children("td[data-parent='true']");case this._tgExpandKey:return cellRow.children(".ui-igtreegrid-non-data-column:first");default:return $()}},_getRecordByIdentifier:function(identifier){var dv=this.grid._getDataView(),i,record=null,index=-1;if(this._pkProp){for(i=0;i<dv.length;i++){if(dv[i][this._pkProp]===identifier){record=dv[i];index=i;break}}}else{if(identifier>=0&&identifier<dv.length){record=dv[identifier];index=identifier}}return{record:record,index:index}},_getRowByIndex:function(index,fixed){var tbody=fixed?this.grid.fixedBodyContainer().find("tbody"):this.grid.element.find("tbody");return tbody.children("tr:not([data-container])").eq(index)},_getCellByIndex:function(index,row){return row.children("td").eq(index)},_getIndexForRow:function(row){return row.closest("tbody").children("tr:not([data-container])").index(row)+(this.grid._startRowIndex||0)},_getColKeyForCell:function(cell){var col=this.grid.getColumnByTD(cell);return col?col.column.key:null},_getColIndexByKey:function(key){var i,columns=this.grid._visibleColumns();for(i=0;i<columns.length;i++){if(columns[i].key===key){return i}}return-1},_onRowSelectionChanging: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&&a.range&&a.range.length>0){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;i<this.grid.options.features.length;i++){if(this.grid.options.features[i].name==="Selection"){this.grid.options.features[i].inherit=true}if(this.grid.options.features[i].name==="RowSelectors"){if(this.grid.options.features[i].enableCheckBoxes===true&&this.grid.options.features[i].checkBoxMode!=="triState"){this.options.mode="row"}}}this._initSelectionCollection(isRebind);if(!isRebind){this._createHandlers()}this.grid.element.unbind("iggriddatarendering",this._dataRenderingHandler).bind("iggriddatarendering",this._dataRenderingHandler);this.grid.element.unbind("iggridvirtualrendering",this._virtualRecordsRenderingHandler).bind("iggridvirtualrendering",this._virtualRecordsRenderingHandler);this.grid.element.unbind("igtreegridvirtualrendering",this._virtualRecordsRenderingHandler).bind("igtreegridvirtualrendering",this._virtualRecordsRenderingHandler);this.grid.element.unbind("iggridvirtualrecordsrender",this._virtualRecordsRendererHandler).bind("iggridvirtualrecordsrender",this._virtualRecordsRendererHandler);this.grid.element.unbind("igtreegridvirtualrecordsrender",this._virtualRecordsRendererHandler).bind("igtreegridvirtualrecordsrender",this._virtualRecordsRendererHandler);this.grid.element.unbind("iggridcolumnscollectionmodified",this._columnsCollectionModifiedHandler).bind("iggridcolumnscollectionmodified",this._columnsCollectionModifiedHandler);if(!isRebind){this.grid._cellStyleSubscribers.push(this.options.mode==="row"?$.proxy(this._applyRowStyle,this):$.proxy(this._applyCellStyle,this))}}});$.extend($.ui.igGridSelection,{version:"21.2.12"});$.ig.SelectionCollection=$.ig.SelectionCollection||Class.extend({settings:{multipleSelection:false,subscribers:{},owner:null},init:function(options){if(options){this.settings=$.extend(true,{},$.ig.SelectionCollection.prototype.settings,options)}this.selection={};return this},addSubscriber:function(subscriber,owner){var suid=$.ig.uid();if(!this.settings.subscribers[owner]){this.settings.subscribers[owner]={}}this.settings.subscribers[owner][suid]=subscriber;return suid},removeSubscriber:function(subscriberId,owner){delete this.settings.subscribers[owner][subscriberId]},changeOwner:function(newOwner){this.cleanAll();this.settings.owner=newOwner},isSelected:function(identifier,forOwner){return false},isActive:function(identifier,forOwner){return false},elementFromIdentifier:function(identifier){return $()},toggle:function(element){if(this.activeElement===null){return}this.select(this.activeElement,true,{element:element||this.elementFromIdentifier(this.activeElement)})},activate:function(identifier,element,suppress){var info={element:element,id:identifier};if(!this.isActive(identifier)){if(this._requestTrigger("ActivationChanging",suppress,info)){this._notify("deactivate");this.activeElement=identifier;this._notify("activate",element);this._requestTrigger("ActivationChanged",suppress,info)}}},deactivate:function(suppress){if(this._requestTrigger("ActivationChanging",suppress,null)){this._notify("deactivate");this.activeElement=null;this._requestTrigger("ActivationChanged",suppress,null)}},select:function(identifier,add,info,suppress){info=info||{};info.element=info.element||this.elementFromIdentifier(identifier);info.id=identifier;if(this.isSelected(identifier)){if(add){if(this._requestTrigger("SelectionChanging",suppress,info)){this._markUnselected(identifier);this._notify("deselect",info);this._requestTrigger("SelectionChanged",suppress,info)}}else{if(this.onlyOneSelected()){return}if(this._requestTrigger("SelectionChanging",suppress,info)){this.clearSelection();this._markSelected(identifier,info);this._notify("select",info);this._requestTrigger("SelectionChanged",suppress,info)}}}else{if(this._requestTrigger("SelectionChanging",suppress,info)){if(!add||!this.settings.multipleSelection){this.clearSelection()}this._markSelected(identifier,info);this._notify("select",info);this._requestTrigger("SelectionChanged",suppress,info)}}this.rangeSelectStart=identifier;this.rangeSelectEnd=identifier},rangeSelect:function(range,add,prevRange,info,suppress){var i;if(!this._requestTrigger("SelectionChanging",suppress,info)){return}if(!prevRange||!this._rangeUnlock){if(!add){this.clearSelection()}}else{this._rangeUnlock(prevRange)}for(i=0;i<range.length;i++){if(!this.isSelected(range[i].id)){this._markSelected(range[i].id,range[i]);this._notify("select",range[i])}}this.activate(info.active,info.element||this.elementFromIdentifier(info.active));this._requestTrigger("SelectionChanged",suppress,info)},rangeDeselect:function(range,info,suppress){var i;if(!this._requestTrigger("SelectionChanging",suppress,info)){return}for(i=0;i<range.length;i++){this._markUnselected(range[i].id);this._notify("deselect",range[i])}this._requestTrigger("SelectionChanged",suppress,info)},deselect:function(identifier,info,suppress){info=info||{};info.element=info.element||this.elementFromIdentifier(identifier);info.id=identifier;this.select(identifier,true,info,suppress)},deselectAll:function(suppress){if(!this._requestTrigger("SelectionChanging",suppress,{})){return}this.clearSelection();this._requestTrigger("SelectionChanged",suppress,{})},clearSelection:function(forOwner){if(!forOwner||forOwner===this.settings.owner){this.selection={};this._notify("clearSelection")}},cleanAll:function(forOwner){if(!forOwner||forOwner===this.settings.owner){this.deactivate(true);this.clearSelection()}},onlyOneSelected:function(){return false},selectedCells:function(){return[]},selectedRows:function(){return[]},selectionLength:function(){return Object.keys(this.selection).length},_requestTrigger:function(type,suppress,args){var subs=this.settings.subscribers[this.settings.owner.id()],func="_on"+this._selectionMode()+type,key,result=true;if(suppress){return true}for(key in subs){if(subs.hasOwnProperty(key)&&typeof subs[key][func]==="function"){result=result&&subs[key][func](args)}}return result},_notify:function(message,info){var subs=this.settings.subscribers[this.settings.owner.id()],func="_"+message,key;for(key in subs){if(subs.hasOwnProperty(key)&&typeof subs[key][func]==="function"){subs[key][func](info)}}}});$.ig.SelectedRowsCollection=$.ig.SelectedRowsCollection||$.ig.SelectionCollection.extend({isSelected:function(identifier,forOwner){if(forOwner&&this.settings.owner!==forOwner){return false}return this.selection[identifier]!==undefined},isActive:function(identifier,forOwner){if(forOwner&&this.settings.owner!==forOwner){return false}return this.activeElement===identifier},selectedDataRows:function(){var s=this.selection,key,dataRows=[];for(key in s){if(s.hasOwnProperty(key)&&key.indexOf(":")===-1&&s[key].element&&!s[key].element.attr("data-grouprow")&&!s[key].element.attr("data-summaryrow")){dataRows.push(s[key])}}return dataRows},selectedRows:function(){var rows=this._rowscache||[],rowKey,id;for(rowKey in this.selection){if(this.selection.hasOwnProperty(rowKey)){id=this.settings.owner._fixPKValue(rowKey);id=isNaN(id)?rowKey:id;rows.push(this._selectedRowObject(id))}}this.invalid=false;return rows},activeRow:function(){var row;if(this.activeElement!==null&&this.activeElement!==undefined){row=this.elementFromIdentifier(this.activeElement);return{id:this.activeElement,index:this.elementPosition(this.activeElement,row),element:row}}return null},elementFromIdentifier:function(identifier){return this.settings.owner.element.data("igGridSelection")._getRowsByIdentifier(identifier)},elementPosition:function(identifier,element){var ownSelection=this.settings.owner.element.data("igGridSelection");if(element&&element.length>0){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<range.length;i++){if(this._unlockSelected(range[i].id)){this._notify("deselect",range[i])}}},_selectedCellObject:function(identifier){var cellInfo=this.selection[identifier.id][identifier.columnKey],pos;if($.type(cellInfo)!=="object"){cellInfo={};this.selection[identifier.id][identifier.columnKey]=cellInfo}if(this.invalid){cellInfo.element=this.elementFromIdentifier(identifier);cellInfo.row=cellInfo.element.parent();pos=this.elementPosition(identifier,cellInfo.element);cellInfo.rowIndex=pos.x;cellInfo.index=pos.y}else{cellInfo.element=cellInfo.element||this.elementFromIdentifier(identifier);cellInfo.row=cellInfo.row||cellInfo.element.parent();if(!(cellInfo.rowIndex!==undefined&&cellInfo.rowIndex!==null&&cellInfo.index!==undefined&&cellInfo.index!==null)){pos=this.elementPosition(identifier,cellInfo.element);cellInfo.rowIndex=pos.x;cellInfo.index=pos.y}}return $.extend(true,{},cellInfo,{id:identifier.id,columnKey:identifier.columnKey})},_selectionMode:function(){return"Cell"}});return $});