/*!@license
 * Infragistics.Web.ClientUI Grid Sorting 14.1.20141.1020
 *
 * Copyright (c) 2011-2014 Infragistics Inc.
 *
 * http://www.infragistics.com/
 *
 * Depends on:
 * Depends on:
 *	jquery-1.4.4.js
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 *	infragistics.ui.grid.framework.js
 *	infragistics.ui.shared.js
 *	infragistics.dataSource.js
 *	infragistics.util.js
 */
if(typeof jQuery!=="function"){throw new Error("jQuery is undefined")}(function($){$.widget("ui.igGridSorting",{css:{sortableColumnHeader:"ui-iggrid-sortableheader ui-state-default",sortableColumnHeaderActive:"ui-iggrid-sortableheaderactive ui-state-active",sortableColumnHeaderHover:"ui-iggrid-sortableheaderhover ui-state-hover",sortableColumnHeaderFocus:"ui-iggrid-sortableheaderfocus ui-state-focus",ascendingColumnHeader:"ui-iggrid-colheaderasc",descendingColumnHeader:"ui-iggrid-colheaderdesc",ascendingColumn:"ui-iggrid-colasc ui-state-highlight",descendingColumn:"ui-iggrid-coldesc ui-state-highlight",sortIndicator:"ui-iggrid-colindicator",fcSortIndicatorAscending:"ui-iggrid-featurechooser-li-iconcontainer ui-icon ui-iggrid-icon-sort-a-z",fcSortIndicatorDescending:"ui-iggrid-featurechooser-li-iconcontainer ui-icon ui-iggrid-icon-sort-z-a",sortIndicatorAscending:"ui-iggrid-colindicator-asc ui-icon ui-icon-arrowthick-1-n",sortIndicatorDescending:"ui-iggrid-colindicator-desc ui-icon ui-icon-arrowthick-1-s",dialogSortedColumns:"ui-iggrid-sorting-dialog-sortedcolumns",dialogUnsortedColumns:"ui-iggrid-sorting-dialog-unsortedcolumns",dialogUnsortedColumnsSortByButton:"ui-iggrid-sorting-dialog-unsortedcolumns-sortbybutton",dialogAsdDescButton:"ui-iggrid-sorting-dialog-ascdescbutton",modalDialogSortByColumn:"ui-iggrid-sorting-dialog-sortbybutton",dialogSortedColumnsItem:"ui-widget-content",dialogUnsortedColumnsItem:"ui-widget-content",dialogButtonAsc:"ui-button ui-corner-all ui-button-icon-only ig-sorting-indicator",dialogButtonAscIcon:"ui-button-icon-primary ui-icon ui-icon-arrowthick-1-n",dialogButtonDesc:"ui-button ui-corner-all ui-button-icon-only ig-sorting-indicator",dialogButtonDescIcon:"ui-button-icon-primary ui-icon ui-icon-arrowthick-1-s",dialogButtonUnsort:"ui-iggrid-sorting-dialog-sortbybuttons ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-igbutton ui-widget-content ui-igbutton-remove",dialogButtonUnsortContainer:"ui-button-icon-primary ui-icon ui-icon-circle-close",dialogSortedColumnTextContainer:"ui-iggrid-dialog-text",dialogItemText:"ui-iggrid-dialog-text",dialogButtonsHover:"ui-state-hover",featureChooserModalDialogIcon:"ui-icon ui-iggrid-icon-multiple-sorting"},options:{type:null,caseSensitive:false,applySortedColumnCss:true,sortUrlKey:null,sortUrlKeyAscValue:null,sortUrlKeyDescValue:null,mode:"single",customSortFunction:null,firstSortDirection:"ascending",sortedColumnTooltip:$.ig.GridSorting.locale.sortedColumnTooltipFormat,modalDialogSortOnClick:false,modalDialogSortByButtonText:$.ig.GridSorting.locale.modalDialogSortByButtonText,modalDialogResetButtonLabel:$.ig.GridSorting.locale.modalDialogResetButton,modalDialogCaptionButtonDesc:$.ig.GridSorting.locale.modalDialogCaptionButtonDesc,modalDialogCaptionButtonAsc:$.ig.GridSorting.locale.modalDialogCaptionButtonAsc,modalDialogCaptionButtonUnsort:$.ig.GridSorting.locale.modalDialogCaptionButtonUnsort,modalDialogWidth:350,modalDialogHeight:"",modalDialogAnimationDuration:200,featureChooserText:$.ig.GridSorting.locale.featureChooserText,unsortedColumnTooltip:$.ig.GridSorting.locale.unsortedColumnTooltip,columnSettings:[{columnKey:null,columnIndex:null,firstSortDirection:null,currentSortDirection:null,allowSorting:true}],modalDialogCaptionText:$.ig.GridSorting.locale.modalDialogCaptionText,modalDialogButtonApplyText:$.ig.GridSorting.locale.modalDialogButtonApplyText,modalDialogButtonCancelText:$.ig.GridSorting.locale.modalDialogButtonCancelText,featureChooserSortAsc:$.ig.GridSorting.locale.featureChooserSortAsc,featureChooserSortDesc:$.ig.GridSorting.locale.featureChooserSortDesc,persist:true},renderInFeatureChooser:true,events:{columnSorting:"columnSorting",columnSorted:"columnSorted",modalDialogOpening:"modalDialogOpening",modalDialogOpened:"modalDialogOpened",modalDialogMoving:"modalDialogMoving",modalDialogClosing:"modalDialogClosing",modalDialogClosed:"modalDialogClosed",modalDialogContentsRendering:"modalDialogContentsRendering",modalDialogContentsRendered:"modalDialogContentsRendered",modalDialogSortingChanged:"modalDialogSortingChanged",modalDialogButtonUnsortClick:"modalDialogButtonUnsortClick",modalDialogSortClick:"modalDialogSortClick",modalDialogButtonApplyClick:"modalDialogButtonApplyClick",modalDialogButtonResetClick:"modalDialogButtonResetClick"},_createWidget:function(options,element){this.options.columnSettings=[];$.Widget.prototype._createWidget.apply(this,arguments)},_create:function(){var self=this;this._headers=[];this._clickHandler=function(event){var th,id;id=$(event.target).closest(".ui-iggrid").attr("id").replace("_container","");if(self.grid.element.attr("id")!==id){return}th=$(event.currentTarget).closest("th");if(th.attr("data-skip")!=="true"&&(self.grid._isMultiColumnGrid!==true||th.attr("data-isheadercell")==="true")){th.find("a").focus();self._handleSort(event);if($("#"+self.grid.id()+"_hscroller").scrollLeft()>0&&self.grid.options.fixedHeaders===true){self.grid.headersTable().parent().scrollLeft($("#"+self.grid.id()+"_hscroller").scrollLeft())}}};this._dragStartHandler=function(event){var id,noCancel=true;noCancel=self.grid._trigger("headercelldragcancel",event,{});if(noCancel){id=$(event.target).closest(".ui-iggrid").attr("id").replace("_container","");if(self.grid.element.attr("id")!==id){return}event.stopPropagation();event.preventDefault()}else{return true}return false};this._mouseOverHandler=function(event){var id,$target=$(event.currentTarget),cs;id=$(event.target).closest(".ui-iggrid").attr("id").replace("_container","");if(self.grid.element.attr("id")!==id){return}cs=self._getColSettingFromElement(event.currentTarget);if(cs&&cs.allowSorting!==false){$target.addClass(self.css.sortableColumnHeaderHover)}};this._mouseOutHandler=function(event){var id;id=$(event.target).closest(".ui-iggrid").attr("id").replace("_container","");if(self.grid.element.attr("id")!==id){return}$(event.currentTarget).removeClass(self.css.sortableColumnHeaderHover)};$("#"+this.element[0].id).delegate("thead th",{click:this._clickHandler,mouseover:this._mouseOverHandler,mouseout:this._mouseOutHandler});$("#"+this.element[0].id+" thead th").bind("dragstart",this._dragStartHandler);$("#"+this.element[0].id+"_headers thead th").bind("dragstart",this._dragStartHandler);$(document).delegate("#"+this.element[0].id+"_headers thead th",{click:this._clickHandler,mouseover:this._mouseOverHandler,mouseout:this._mouseOutHandler});this._keyDownHandler=function(event){self._handleSortKb(event)};this._focusHandler=function(event){self._handleFocusKb(event)};this._blurHandler=function(event){self._handleBlurKb(event)};$("#"+this.element[0].id).delegate("thead th a:not([th-remove-focus])",{keydown:this._keyDownHandler,focus:this._focusHandler,blur:this._blurHandler});$(document).delegate("#"+this.element[0].id+"_headers thead th a:not([th-remove-focus])",{keydown:this._keyDownHandler,focus:this._focusHandler,blur:this._blurHandler})},_setOption:function(key,value){var i,col,featureChooserInstance,modalDialog=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog");$.Widget.prototype._setOption.apply(this,arguments);switch(key){case"type":throw new Error($.ig.Grid.locale.optionChangeNotSupported+" "+key);case"caseSensitive":this.grid.dataSource.settings.sorting.caseSensitive=this.options.caseSensitive;break;case"modalDialogSortOnClick":modalDialog.remove();this._renderMultipleSortingDialog();break;case"modalDialogAnimationDuration":modalDialog.igGridModalDialog("option","animationDuration",value);break;case"modalDialogWidth":modalDialog.igGridModalDialog("option","modalDialogWidth",value);break;case"modalDialogHeight":modalDialog.igGridModalDialog("option","modalDialogHeight",value);break;case"modalDialogButtonApplyText":modalDialog.igGridModalDialog("option","buttonApplyText",value);break;case"modalDialogButtonCancelText":modalDialog.igGridModalDialog("option","buttonCancelText",value);break;case"modalDialogCaptionText":modalDialog.igGridModalDialog("option","modalDialogCaptionText",value);break;case"featureChooserText":featureChooserInstance=this.grid.element.data("igGridFeatureChooser");if(featureChooserInstance){for(i=0;i<this.grid.options.columns.length;i++){col=this.grid.options.columns[i].key;featureChooserInstance._setListItemText(col,"Sorting",value)}}break;default:break}},_getColSettingFromElement:function(e){var index,cs=this.options.columnSettings,$e=$(e);index=parseInt($e.data("columnIndex"),10);return cs[index]},_handleSortKb:function(event){var index=$(event.currentTarget).closest("th").data("columnIndex"),id;id=$(event.target).closest(".ui-iggrid").attr("id").replace("_container","");if(this.grid.element.attr("id")!==id){return}if(event.keyCode===$.ui.keyCode.ENTER||event.keyCode===$.ui.keyCode.SPACE){if(this._currentActiveHeader){this._currentActiveHeader.removeClass(this.css.sortableColumnHeaderActive)}$(event.currentTarget).closest("th").addClass(this.css.sortableColumnHeaderActive);this._currentActiveHeader=$(event.currentTarget).closest("th");if(event.shiftKey){this.unsortColumn(index,$(event.currentTarget).closest("th"))}else{this.sortColumn(index,null,$(event.currentTarget).closest("th"));if($.ig.util.isIE){$(event.currentTarget).focus()}}event.stopPropagation();event.preventDefault()}},_handleFocusKb:function(event){var $target=$(event.currentTarget),id=$(event.target).closest(".ui-iggrid").attr("id").replace("_container","");if(this.grid.element.attr("id")!==id||$target.attr("data-fixing-indicator")!==undefined){return}$target.closest("th").addClass(this.css.sortableColumnHeaderFocus)},_handleBlurKb:function(event){var id=$(event.target).closest(".ui-iggrid").attr("id").replace("_container","");if(this.grid.element.attr("id")!==id){return}$(event.currentTarget).closest("th").removeClass(this.css.sortableColumnHeaderFocus)},_handleSort:function(event){if(this._resizing&&this._resizing._resizing){this._resizing._resizing=false;return}var $th=$(event.currentTarget).closest("th"),index=$th.data("columnIndex"),isShiftClicked=false;if(this._currentActiveHeader){this._currentActiveHeader.removeClass(this.css.sortableColumnHeaderActive)}isShiftClicked=event.shiftKey;if(isShiftClicked){$th.removeClass(this.css.sortableColumnHeaderFocus).removeClass(this.css.sortableColumnHeaderActive);this._currentHeader=$th;this.unsortColumn(index,$th)}else{$(event.currentTarget).addClass(this.css.sortableColumnHeaderActive);this._currentActiveHeader=$th;this.sortColumn(index,null,$(event.currentTarget))}event.stopPropagation();event.preventDefault()},_initLoadingIndicator:function(){this._loadingIndicator=this.grid.container().length>0?this.grid.container().igLoading().data("igLoading").indicator():this.grid.element.igLoading().data("igLoading").indicator()},_getHeaderCellByIdentifier:function(identifier){var $headerCell,colKey;if($.type(identifier)==="number"){colKey=this.grid.options.columns[identifier].key}else{colKey=identifier}$headerCell=$("#"+this.grid.element[0].id+"_"+colKey);return $headerCell},sortColumn:function(index,direction,header){var colKey,expr,noCancel=true,s,i,visualIndex,groupby,reset=true,se,newSE=[],apiCall=header===null||header===undefined,addSE=false,isHidden=false;this._currentIdentifier=index;if($.type(index)==="number"){colKey=this.grid.options.columns[index].key;if(this.grid.options.columns[index].hidden){isHidden=true}}else{colKey=index;if(header===null||header===undefined){header=$("#"+this.grid.element[0].id+"_"+colKey)}index=header.data("columnIndex");if(index===undefined){isHidden=true}}expr=this.grid.dataSource.settings.sorting.expressions;s=this._findColumnSetting(colKey);if(this.grid.options.virtualizationMode==="fixed"&&(this.grid.options.virtualization===true||this.grid.options.columnVirtualization===true)){visualIndex=index-this.grid._startColIndex}else{visualIndex=index}if(apiCall&&this._currentActiveHeader){this._currentActiveHeader.removeClass(this.css.sortableColumnHeaderActive)}if(header===null||header===undefined){visualIndex+=this.grid.headersTable().children("thead").children("tr").children("th[data-skip=true]").length;if(colKey){header=$("#"+this.grid.element[0].id+"_"+colKey)}else{header=this.grid.headersTable().children("thead").children("tr").children("th:nth-child("+(visualIndex+1)+")")}apiCall=true}if(s&&s.allowSorting===false){return}if(direction!==null&&direction!==undefined){s.currentSortDirection=direction}else{if(s.currentSortDirection!==undefined&&s.currentSortDirection!==null&&!s.currentSortDirection.startsWith("asc")&&!s.currentSortDirection.startsWith("desc")||s.currentSortDirection===undefined||s.currentSortDirection===null){s.currentSortDirection=s.firstSortDirection===undefined?this.options.firstSortDirection:s.firstSortDirection}else{s.currentSortDirection=s.currentSortDirection!==undefined&&s.currentSortDirection!==null&&s.currentSortDirection.indexOf("asc")!==-1?"descending":"ascending"}}if(!apiCall){noCancel=this._trigger(this.events.columnSorting,null,{columnKey:colKey,direction:s.currentSortDirection,owner:this})}if(noCancel){this._loadingIndicator.show();header.attr("title",s.currentSortDirection.startsWith("asc")?this.options.sortedColumnTooltip.replace("${direction}",$.ig.GridSorting.locale.ascending):this.options.sortedColumnTooltip.replace("${direction}",$.ig.GridSorting.locale.descending));if(this.options.mode==="single"){if(isHidden){this._clearSortStates(header,-1);for(i=0;i<this.grid.options.columns.length;i++){if(this.options.columnSettings[i]&&this.options.columnSettings[i].allowSorting!==false&&this.options.columnSettings[i].columnKey!==colKey){this._clearSortState(header,this.options.columnSettings[i].columnIndex,this.options.columnSettings[i].columnKey)}}}else{if(colKey&&this.grid.hasFixedColumns()){this._clearSortStatesByKey(header,colKey)}else{this._clearSortStates(header,index)}}for(i=0;this.grid.options.features&&i<this.grid.options.features.length;i++){if(this.grid.options.features[i].name==="GroupBy"){groupby=this.grid.element.data("igGridGroupBy");if(groupby&&groupby.options.groupedColumns&&groupby.options.groupedColumns.length>0){reset=false}}}if(isHidden&&direction!==null&&direction!==undefined){s.currentSortDirection=direction}if(reset){this.grid.dataSource.settings.sorting.expressions=[{fieldName:colKey,dir:s.currentSortDirection.startsWith("asc")?"asc":"desc"}]}else{se=this.grid.dataSource.settings.sorting.expressions;addSE=true;for(i=0;i<se.length;i++){if(se[i].isGroupBy===true){if(se[i].fieldName===colKey){addSE=false}newSE.push(se[i])}}if(addSE){newSE.push({fieldName:colKey,dir:s.currentSortDirection.startsWith("asc")?"asc":"desc"})}this.grid.dataSource.settings.sorting.expressions=newSE}}else{for(i=0;i<expr.length;i++){if(expr[i].fieldName===colKey){expr.splice(i,1)}}this.grid.dataSource.settings.sorting.expressions=expr.concat([{fieldName:colKey,dir:s.currentSortDirection.startsWith("asc")?"asc":"desc"}])}noCancel=this.grid._trigger(this.grid.events.dataBinding,null,{owner:this.grid});if(this.grid._hasUnboundColumns&&this.options.type==="remote"){this.grid._rebindUnboundColumns=true}if(noCancel){this._saveSortingExpressions();this.grid.element.trigger("iggriduisoftdirty",{owner:this});this._currentHeader=header;this._currentIndex=index;if(this.options.type==="remote"){if(!apiCall){this._shouldFireColumnSorted=true}this.grid.dataSource.dataBind()}else{this.grid.dataSource.sort(this.grid.dataSource.settings.sorting.expressions,s.currentSortDirection);this.grid._renderData();if(!apiCall){this._trigger(this.events.columnSorted,null,{columnKey:colKey,direction:s.currentSortDirection,owner:this})}}this._curColKey=colKey;this._curSortDir=s.currentSortDirection}}},sortMultiple:function(){var self=this,noCancel,expr=this.grid.dataSource.settings.sorting.expressions,header;noCancel=this.grid._trigger(this.grid.events.dataBinding,null,{owner:this.grid});if(noCancel){$.each(this.grid.options.columns,function(index,column){var i,cs,colKey=column.key;header=$("#"+self.grid.element[0].id+"_"+colKey);for(i=0;i<expr.length;i++){if(expr[i].fieldName===colKey){break}}cs=self._findColumnSetting(colKey);if(cs){if(i===expr.length){cs.currentSortDirection=undefined}else{cs.currentSortDirection=expr[i].dir}}self._applySortStyles(header,index)});this.grid.element.trigger("iggriduisoftdirty",{owner:this});if(this._isResetClick===true){this._isResetClick=false}if(this.options.type==="remote"){this.grid.dataSource.dataBind()}else{this.grid.dataSource.sort(this.grid.dataSource.settings.sorting.expressions);this.grid._renderData()}this._saveSortingExpressions()}},unsortColumn:function(index,header){if(this.options.mode==="single"){return}var colKey,expr,noCancel=true,s,i,apiCall=false;if($.type(index)==="number"){colKey=this.grid.options.columns[index].key}else{colKey=index;for(i=0;i<this.grid.options.columns.length;i++){if(this.grid.options.columns[i].key===colKey){index=i;break}}}expr=this.grid.dataSource.settings.sorting.expressions;s=this._findColumnSetting(colKey);if(s===null||s===undefined){return}if(s&&s.allowSorting===false){return}s.currentSortDirection=undefined;for(i=0;i<expr.length;i++){if(expr[i].fieldName===colKey){expr.splice(i,1)}}this._currentIndex=null;this._currentHeader=null;this._applySortStyles($("#"+this.grid.element[0].id+"_"+colKey),index);noCancel=this.grid._trigger(this.grid.events.dataBinding,null,{owner:this.grid});if(noCancel){this.grid.element.trigger("iggriduisoftdirty",{owner:this});this._currentHeader=header;if(this.options.type==="remote"){if(!apiCall){this._shouldFireColumnSorted=true}this.grid.dataSource.dataBind()}else{this.grid.dataSource.sort(this.grid.dataSource.settings.sorting.expressions);this.grid._trigger(this.grid.events.dataBound,null,{owner:this.grid});this.grid._renderData();if(!apiCall){this._trigger(this.events.columnSorted,null,{columnKey:colKey,direction:s.currentSortDirection,owner:this})}}this._curColKey=colKey;this._curSortDir=s.currentSortDirection;this._saveSortingExpressions()}},_excludeExpr:function(key){if(this.options.persist&&!this._couldPreserveData()){return}var expr=this.grid.dataSource.settings.sorting.expressions,i;for(i=0;i<expr.length;i++){if(expr[i].fieldName===key){$.ig.removeFromArray(expr,i)}}},_applySortStyles:function(header,index,columnKey,ignoreActiveSelection){var oldHeight=null,span,col,indicatorContainer,visualIndex,indexResolved,i,tmpIndexResolved,currentColumnSetting,columnOption=this.grid.options.columns[index],dataSkipColumnCount=0,isFixed,toolTip=this.options.sortedColumnTooltip,hasFixedColumns=this.grid.hasFixedColumns(),sortAsc=toolTip.replace("${direction}",$.ig.GridSorting.locale.ascending),sortDesc=toolTip.replace("${direction}",$.ig.GridSorting.locale.descending);if(this.grid.options.virtualizationMode==="fixed"&&(this.grid.options.virtualization===true||this.grid.options.columnVirtualization===true)){visualIndex=index-this.grid._startColIndex}else{visualIndex=index}if(this.grid.options.fixedHeaders){oldHeight=this.grid.headersTable().outerHeight()}span=header.find(".ui-iggrid-colindicator");if(span.length===0){span=$("<span></span>").addClass(this.css.sortIndicator)}indicatorContainer=header.find(".ui-iggrid-indicatorcontainer");if(indicatorContainer.length===0){indicatorContainer=$("<div></div>").appendTo(header).addClass("ui-iggrid-indicatorcontainer")}indicatorContainer.append(span);dataSkipColumnCount=header.closest("thead").find(".ui-iggrid-header[data-skip=true]").length;indexResolved=visualIndex+dataSkipColumnCount+1;tmpIndexResolved=indexResolved;for(i=0;i<this.grid.options.columns.length;i++){if(i+dataSkipColumnCount<indexResolved&&this.grid.options.columns[i].hidden){tmpIndexResolved--}}indexResolved=tmpIndexResolved;if(columnKey!==null&&columnKey!==undefined){for(i=0;i<this.options.columnSettings.length;i++){if(this.options.columnSettings[i].columnKey===columnKey){currentColumnSetting=this.options.columnSettings[i];break}}}else{currentColumnSetting=this.options.columnSettings[index]}if(hasFixedColumns){if(columnOption){columnKey=columnOption.key;isFixed=columnOption.fixed===true}else if(currentColumnSetting){columnKey=currentColumnSetting.columnKey;isFixed=this.grid.columnByKey(columnKey).fixed===true}indexResolved=this._columnFixing._getVisibleIndex(columnKey,isFixed)+1}if(hasFixedColumns&&this.grid._isFixedElement(header)){col=$("#"+this.element[0].id+"_fixed tbody tr td:nth-child("+indexResolved+")")}else{if(hasFixedColumns&&!columnOption&&!currentColumnSetting){indexResolved-=this.grid._fixedColumns.length}if(this.grid.options.fixedHeaders!==true){col=header.closest("thead").parent().find("tbody tr td:nth-child("+indexResolved+")")}else if(this.options.applySortedColumnCss!==false){col=this.grid.element.find("tr td:nth-child("+indexResolved+")")}}if(currentColumnSetting!==undefined&&currentColumnSetting.currentSortDirection!==undefined&&(!columnOption||columnOption&&columnOption.hidden!==true)){if(currentColumnSetting.currentSortDirection.indexOf("asc")!==-1){span.removeClass(this.css.sortIndicatorDescending).addClass(this.css.sortIndicatorAscending);header.removeClass(this.css.descendingColumnHeader).addClass(this.css.ascendingColumnHeader);header.attr("title",sortAsc);if(this.options.applySortedColumnCss!==false&&ignoreActiveSelection!==true){col.removeClass(this.css.descendingColumn).addClass(this.css.ascendingColumn)}}else{span.removeClass(this.css.sortIndicatorAscending).addClass(this.css.sortIndicatorDescending);header.removeClass(this.css.ascendingColumnHeader).addClass(this.css.descendingColumnHeader);header.attr("title",sortDesc);if(this.options.applySortedColumnCss!==false&&ignoreActiveSelection!==true){col.removeClass(this.css.ascendingColumn).addClass(this.css.descendingColumn)}}}else{header.attr("title",this.options.unsortedColumnTooltip);if(this.grid._isMultiColumnGrid===true){span=header.find(".ui-iggrid-colindicator")}else{span=header.parent("tr").find("th:nth-child("+indexResolved+") .ui-iggrid-colindicator")}span.removeClass(this.css.sortIndicatorAscending).removeClass(this.css.descendingColumnHeader);header.removeClass(this.css.sortableColumnHeaderActive).removeClass(this.css.sortableColumnHeaderFocus).removeClass(this.css.ascendingColumnHeader).removeClass(this.css.descendingColumnHeader)}if(oldHeight!==null&&oldHeight!==this.grid.headersTable().outerHeight()){this.grid._initializeHeights()}},_clearSortStatesByKey:function(header,key){var i,cs=this.options.columnSettings,csLen=cs.length,clearHiddenCols=this.options.mode==="single"&&this.grid._detachedHeaderCells;for(i=0;i<csLen;i++){if(cs[i].allowSorting===false||cs[i].columnKey===key){continue}delete cs[i].currentSortDirection;this._clearSortState(header,cs[i].columnIndex,cs[i].columnKey);if(clearHiddenCols&&cs[i].columnKey&&this.grid._detachedHeaderCells[cs[i].columnKey]){this._clearHeaderCellSortState(this.grid._detachedHeaderCells[cs[i].columnKey][0])}}},_clearSortStates:function(header,index){var i,cs=this.options.columnSettings,realIndex=index,isSingleMode=this.options.mode==="single";for(i=0;i<this.grid.options.columns.length;i++){if(i<index&&this.grid.options.columns[i].hidden){realIndex--}}index=realIndex;for(i=0;i<this.options.columnSettings.length;i++){if(cs[i].allowSorting!==false){if(index!==undefined&&cs[i].columnIndex!==index){delete cs[i].currentSortDirection;this._clearSortState(header,cs[i].columnIndex,cs[i].columnKey)}if(this.grid._detachedHeaderCells&&isSingleMode&&cs[i].columnKey&&this.grid._detachedHeaderCells[cs[i].columnKey]){if(cs[i].currentSortDirection!==undefined&&cs[i].currentSortDirection!==null){delete cs[i].currentSortDirection}this._clearHeaderCellSortState(this.grid._detachedHeaderCells[cs[i].columnKey][0])}}}},_clearSortStateFixing:function(columnKey){var th,id=this.grid.element.attr("id")+"_"+columnKey,visibleIndex=this._columnFixing._getVisibleIndex(columnKey);th=$("#"+id);this._clearSortStateByVisibleIndex(visibleIndex,th)},_clearSortState:function(header,i,columnKey){if(this.grid.hasFixedColumns()&&columnKey!==undefined){this._clearSortStateFixing(columnKey);return}var th,ths,fixedColumnsLength;if(this.grid._isMultiColumnGrid===true){ths=this.grid._headerCells;th=ths[i];if(th===undefined){return}}else{if(this.grid.hasFixedColumns()){fixedColumnsLength=this.grid._fixedColumns.length;if(i<fixedColumnsLength){ths=this.grid.fixedHeadersTable().find("thead > tr").first().find("th").not("[data-skip=true]")}else{ths=this.grid.headersTable().find("thead > tr").first().find("th").not("[data-skip=true]");i-=fixedColumnsLength}th=ths.eq(i)}else{ths=this.grid.headersTable().find("thead > tr").first().find("th").not("[data-skip=true]");th=ths.eq(i)}}this._clearSortStateByVisibleIndex(i,th)},_clearSortStateByVisibleIndex:function(i,th){var spanHeader=th,col;this._clearHeaderCellSortState(spanHeader);if(this.options.columnSettings.length>i&&this.options.columnSettings[i].allowSorting){th.attr("title",this.options.unsortedColumnTooltip)}else{th.attr("title","")}if(this.options.applySortedColumnCss!==false){if(this.grid.options.fixedHeaders!==true){col=th.closest("thead").parent().find("tbody tr td:nth-child("+(i+1)+")")}else{col=this.grid.element.find("tr td:nth-child("+(i+1)+")")}col.removeClass(this.css.descendingColumn).removeClass(this.css.ascendingColumn)}},_clearHeaderCellSortState:function(spanHeader){var span=spanHeader.find(".ui-iggrid-colindicator");if(span.hasClass("ui-iggrid-colindicator-desc")||span.hasClass("ui-iggrid-colindicator-asc")){span.removeClass(this.css.sortIndicatorDescending).removeClass(this.css.sortIndicatorAscending);spanHeader.removeClass(this.css.ascendingColumnHeader).removeClass(this.css.descendingColumnHeader).removeClass(this.css.sortableColumnHeaderFocus)}},_initDefaultSettings:function(){var settings=[],key,cs=this.options.columnSettings,i,j,k,colIndex=0,defaultExpressions=[],defExpLength,isToSkipGroupBySortingExpr=false,allowSorting,isToCheckUnboundColumns=this.grid._hasUnboundColumns===true&&this.options.type==="remote";if(this.grid.dataSource.settings.sorting.expressions!==null&&this.grid.dataSource.settings.sorting.expressions!==undefined){defaultExpressions=this.grid.dataSource.settings.sorting.expressions}defExpLength=defaultExpressions.length;if(this.grid.options.columns&&this.grid.options.columns.length>0){for(i=0;i<this.grid.options.columns.length;i++){allowSorting=true;if(isToCheckUnboundColumns&&this.grid.getUnboundColumnByKey(this.grid.options.columns[i].key)!==null){allowSorting=false}settings[i]={columnIndex:colIndex,columnKey:this.grid.options.columns[i].key,allowSorting:allowSorting};if(this.grid.options.columns[i].hidden!==true){colIndex++}}}for(i=0;i<cs.length;i++){for(key in cs[i]){if(cs[i].hasOwnProperty(key)&&key!=="columnKey"&&key!=="columnIndex"){if(key==="userSet_currentSortDirection"){if(cs[i].userSet_currentSortDirection==="undefined"){delete cs[i].currentSortDirection}else{cs[i].currentSortDirection=cs[i].userSet_currentSortDirection}}else if(key==="userSet_allowSorting"){cs[i].allowSorting=cs[i][key];delete cs[i][key]}}}}for(i=0;i<cs.length;i++){for(j=0;j<settings.length;j++){if(settings[j].columnKey!==null&&settings[j].columnKey!==undefined&&cs[i].columnKey!==null&&cs[i].columnKey!==undefined){if(settings[j].columnKey===cs[i].columnKey){break}}else if(settings[j].columnIndex===cs[i].columnIndex){break}}if(j===settings.length){continue}for(key in cs[i]){if(cs[i].hasOwnProperty(key)&&key!=="columnKey"&&key!=="columnIndex"&&!key.startsWith("userSet")){settings[j][key]=cs[i][key];settings[j]["userSet_"+key]=cs[i][key];if(key==="currentSortDirection"&&cs[i][key]){if($.type(settings[j].columnKey)!=="number"){isToSkipGroupBySortingExpr=false;if(defExpLength>0){for(k=0;k<defExpLength;k++){if(defaultExpressions[k].fieldName===settings[j].columnKey){if(defaultExpressions[k].isGroupBy===true){isToSkipGroupBySortingExpr=true}else{defaultExpressions.splice(k,1)}break}}}if(isToSkipGroupBySortingExpr===true){continue}defaultExpressions.push({fieldName:settings[j].columnKey,dir:cs[i][key].startsWith("asc")?"asc":"desc"})}else{defaultExpressions.push({fieldIndex:settings[j].columnKey,dir:cs[i][key].startsWith("asc")?"asc":"desc"})}}}}}for(i=0;i<settings.length;i++){if(!settings[i].hasOwnProperty("currentSortDirection")){settings[i].userSet_currentSortDirection="undefined"}}this.options.columnSettings=settings;this.grid.dataSource.settings.sorting.expressions=defaultExpressions;this.grid.dataSource.settings.sorting.defaultFields=defaultExpressions},_headerCellRendered:function(event,ui){var cs=this._findColumnSetting(ui.columnKey),i,col,initialSorting,featureChooserInstance=this.grid.element.data("igGridFeatureChooser");if(event.target.id!==this.grid.element[0].id){return}if(ui.isMultiColumnHeader===true){return}if(ui.columnKey&&cs){this._headers.push({header:ui.th,index:cs.columnIndex});if(cs.allowSorting!==false){ui.th.addClass(this.css.sortableColumnHeader);if(cs.currentSortDirection===undefined||cs.currentSortDirection===null){ui.th.attr("title",this.options.unsortedColumnTooltip)}else{ui.th.attr("title",cs.currentSortDirection.startsWith("asc")?this.options.sortedColumnTooltip.replace("${direction}",$.ig.GridSorting.locale.ascending):this.options.sortedColumnTooltip.replace("${direction}",$.ig.GridSorting.locale.descending))}$("<span></span>").appendTo(ui.th).addClass(this.css.sortIndicator);$(ui.th).wrapInner('<a href="#"></a>');if(cs.currentSortDirection!==undefined){this._applySortStyles(ui.th,cs.columnIndex)}}else{$(ui.th).wrapInner('<a href="#"></a>')}}if(!this._featureChooserInitialized&&featureChooserInstance){this._featureChooserInitialized=true;this._featureChooserMenuTogglingHandler=$.proxy(this._featureChooserMenuToggling,this);this.grid.element.bind("iggridfeaturechoosermenutoggling",this._featureChooserMenuTogglingHandler);if(featureChooserInstance._isTouchDevice()){for(i=0;i<this.grid.options.columns.length;i++){col=this.grid.options.columns[i];cs=this._getColumnSettingsByIndex(i);if(cs.allowSorting){if(featureChooserInstance&&featureChooserInstance._shouldRenderInFeatureChooser(col.key)===true){initialSorting=cs.currentSortDirection;if(initialSorting===null){initialSorting=false}featureChooserInstance._renderInFeatureChooser(col.key,{name:"SortingAscending",text:this.options.featureChooserSortAsc,textHide:this.options.featureChooserSortAsc,iconClass:this.css.fcSortIndicatorAscending,iconClassOff:this.css.fcSortIndicatorAscending,isSelected:initialSorting&&typeof initialSorting==="string"?initialSorting.toLowerCase().indexOf("asc")>-1:false,method:$.proxy(this._sortAscFromFeatureChooser,this),updateOnClickAll:false,groupName:"toggle",groupOrder:1,order:0,type:"toggle"});featureChooserInstance._renderInFeatureChooser(col.key,{name:"SortingDescending",text:this.options.featureChooserSortDesc,textHide:this.options.featureChooserSortDesc,iconClass:this.css.fcSortIndicatorDescending,iconClassOff:this.css.fcSortIndicatorDescending,isSelected:initialSorting&&typeof initialSorting==="string"?initialSorting.toLowerCase().indexOf("desc")>-1:false,method:$.proxy(this._sortDescFromFeatureChooser,this),updateOnClickAll:false,groupName:"toggle",groupOrder:1,order:0,type:"toggle"})}}}}if(this.options.mode!=="single"){for(i=0;i<this.grid.options.columns.length;i++){col=this.grid.options.columns[i];if(this._getColumnSettingsByIndex(i).allowSorting){if(featureChooserInstance._shouldRenderInFeatureChooser(col.key)===true){featureChooserInstance._renderInFeatureChooser(col.key,{name:"MultipleSorting",text:this.options.featureChooserText,iconClass:this.css.featureChooserModalDialogIcon,method:$.proxy(this.openMultipleSortingDialog,this),groupName:"modaldialog",groupOrder:3,order:2})}}}}}},_featureChooserMenuToggling:function(event,args){var i,expr,isAsc,hasSorting=false,columnKey=args.columnKey,featureChooserInstance=this.grid.element.data("igGridFeatureChooser"),exprs=this.grid.dataSource.settings.sorting.expressions,exprsLength=exprs.length;if(!args.isVisible){for(i=0;i<exprsLength;i++){expr=exprs[i];if(expr.fieldName===columnKey){hasSorting=true;isAsc=false;if(expr.dir&&expr.dir.toLowerCase().indexOf("asc")>-1){isAsc=true
}featureChooserInstance._setSelectedState("SortingDescending",columnKey,!isAsc,false);featureChooserInstance._setSelectedState("SortingAscending",columnKey,isAsc,false)}}if(!hasSorting){featureChooserInstance._setSelectedState("SortingDescending",columnKey,false,false);featureChooserInstance._setSelectedState("SortingAscending",columnKey,false,false)}}},_sortAscFromFeatureChooser:function(event,columnKey,isSelected){var featureChooserInstance=this.grid.element.data("igGridFeatureChooser");if(!featureChooserInstance){return}featureChooserInstance._setSelectedState("SortingDescending",columnKey,false,false);if(isSelected){this.sortColumn(columnKey,"asc")}else{this.unsortColumn(columnKey)}},_sortDescFromFeatureChooser:function(event,columnKey,isSelected){var featureChooserInstance=this.grid.element.data("igGridFeatureChooser");featureChooserInstance._setSelectedState("SortingAscending",columnKey,false,false);if(!featureChooserInstance){return}if(isSelected){this.sortColumn(columnKey,"desc")}else{this.unsortColumn(columnKey)}},_columnFixed:function(args){var i,colInd=args.colInd,cs,fixedTable=this.grid.fixedHeadersTable(),isAttachedSortingHandlers=false,fixedColumnsLength=args.fixedColsCount;isAttachedSortingHandlers=fixedTable.data("attachedSortingHandlers");if(isAttachedSortingHandlers!==true){fixedTable.data("attachedSortingHandlers",true);fixedTable.delegate("thead th",{click:this._clickHandler,mouseover:this._mouseOverHandler,mouseout:this._mouseOutHandler})}cs=this.options.columnSettings[colInd];if(cs){this.options.columnSettings.splice(colInd,1);this.options.columnSettings.splice(fixedColumnsLength-1,0,cs)}for(i=0;i<this.options.columnSettings.length;i++){this.options.columnSettings[i].columnIndex=i}},_columnsRearranged:function(event,ui){this._initDefaultSettings()},_columnMap:function(){var self=this,isMultiple=self.options.mode!=="single";return $.map(this.grid.options.columns,function(col,index){var allowSorting=false;if(isMultiple&&self._getColumnSettingsByIndex(index).allowSorting){allowSorting=true}return{columnKey:col.key,enabled:allowSorting}})},_findColumnSetting:function(key){var i;for(i=0;i<this.options.columnSettings.length;i++){if(this.options.columnSettings[i].columnKey===key){return this.options.columnSettings[i]}}},_dataRendered:function(){var i,cs,expr,col,colKey,gridId=this.grid.element[0].id,ignoreActiveSelection;if(!this._loadingIndicator){this._initLoadingIndicator()}expr=this._sortingExpressions;if(this._shouldFireColumnSorted){this._trigger(this.events.columnSorted,null,{columnKey:this._curColKey,direction:this._curSortDir,owner:this});this._shouldFireColumnSorted=false}this._loadingIndicator.hide();if(this._currentIndex!==undefined&&this._currentIndex!==null&&this._currentHeader!==undefined&&this._currentHeader!==null){this._applySortStyles(this._currentHeader,this._currentIndex)}else if(this.options.persist&&this._restoreSorting&&expr&&expr.length>0){for(i=0;i<expr.length;i++){if(expr[i].isGroupBy){continue}colKey=expr[i].fieldName;cs=this._findColumnSetting(colKey);if(cs){cs.currentSortDirection=expr[i].dir}col=$("#"+gridId+"_"+colKey);col.addClass(this.css.sortableColumnHeaderActive);this._currentActiveHeader=col;ignoreActiveSelection=true;if(i+1===expr.length){ignoreActiveSelection=false}this._applySortStyles(col,col.data("columnIndex"),colKey,ignoreActiveSelection)}}if(this._hc===undefined){this._hc=this.grid.container().find(".ui-iggrid-expandheadercell").length>0}if(this.grid.options.rowVirtualization||this.grid.options.virtualization){$("#"+this.grid.element.attr("id")+"_scrollContainer").scrollTop(0)}},_onUIDirty:function(e,args){var i,j,exprs=this.grid.dataSource.settings.sorting.expressions,defaultExprs=this.grid.dataSource.settings.sorting.defaultFields,cs=this.options.columnSettings,skip=false;if(args.owner===this||args.owner.element[0].id!==this.element[0].id){return}this._currentIdentifier=null;this._currentIndex=null;this._currentHeader=null;this._clearUi(true);for(i=0;i<exprs.length;i++){skip=false;for(j=0;j<cs.length;j++){if(cs[j].columnKey===exprs[i].fieldName&&cs[j].userSet_currentSortDirection){skip=true;break}}if(!skip){if(exprs.length>i){$.ig.removeFromArray(exprs,i)}if(defaultExprs.length>i){$.ig.removeFromArray(defaultExprs,i)}}}},_clearUi:function(resetAll){var i,header,csd,isMCH=this.grid._isMultiColumnGrid,persist=this.options.persist;for(i=0;this._headers&&i<this._headers.length;i++){csd=this.options.columnSettings[i].userSet_currentSortDirection;if((isMCH||persist)&&this.options.columnSettings[i].columnKey){header=$("#"+this.grid.element[0].id+"_"+this.options.columnSettings[i].columnKey)}else{header=this._headers[i].header}if(csd===undefined||csd===null||csd==="undefined"){this._clearSortState(header,i,this.options.columnSettings[i].columnKey);if(this.options.mode!=="single"){delete this.options.columnSettings[i].currentSortDirection;this._excludeExpr(this.options.columnSettings[i].columnKey)}}else{this._applySortStyles(header,i)}header.removeClass(this.css.sortableColumnHeaderActive).removeClass(this.css.sortableColumnHeaderHover).removeClass(this.css.sortableColumnAscending).removeClass(this.css.sortableColumnDescending).addClass(this.grid.css.headerClass);if(!header.hasClass(this.grid.css.headerCellFeatureEnabledClass)){header.addClass(this.grid.css.headerCellFeatureEnabledClass)}if(this.options.columnSettings[i].allowSorting){header.addClass(this.css.sortableColumnHeader)}}},_virtualHorizontalScroll:function(event,args){var start=args.startColIndex,end=args.endColIndex,i,j,cs=this.options.columnSettings,header,ths=this.grid.headersTable().find("thead > tr").first().find("th").not("[data-skip=true]"),visibleColumns=this.grid._visibleColumns();for(i=0;i<ths.length;i++){header=ths.eq(i);this._clearSortState(header,i);header.removeClass(this.css.sortableColumnHeaderActive).removeClass(this.css.sortableColumnHeaderHover).removeClass(this.css.sortableColumnAscending).removeClass(this.css.sortableColumnDescending).addClass(this.grid.css.headerClass).addClass(this.css.sortableColumnHeader)}for(i=start;i<=end;i++){header=ths.eq(i-start);header.data("columnIndex",i);for(j=0;j<cs.length;j++){if(cs[j].currentSortDirection&&cs[j].columnKey===visibleColumns[i].key){this._applySortStyles(header,i)}}}},_columnsCollectionModified:function(event,args){if(args.owner.element.attr("id")!==this.grid.element.attr("id")){return}var i,j,found,colKey,cs,col,colApplySelection,indexApplySelection;for(i=0;i<this.options.columnSettings.length;i++){j=0;found=false;for(j=0;j<this.grid._visibleColumns().length;j++){if(this.grid._visibleColumns()[j].key===this.options.columnSettings[i].columnKey){found=true;colKey=this.grid._visibleColumns()[j].key;break}}if(found){this.options.columnSettings[i].columnIndex=j;cs=this._findColumnSetting(colKey);if(cs&&cs.currentSortDirection!==undefined&&this.options.applySortedColumnCss!==false){col=$("#"+this.grid.element[0].id+"_"+colKey);this._applySortStyles(col,col.data("columnIndex"),colKey,true)}}}if(this._currentIdentifier){if($.type(this._currentIdentifier)==="number"){if(this._currentIndex!==undefined&&this._currentIndex!==null&&this._currentHeader!==undefined&&this._currentHeader!==null){this._applySortStyles(this._currentHeader,this._currentIndex)}}else{colApplySelection=$("#"+this.grid.element[0].id+"_"+this._currentIdentifier);indexApplySelection=colApplySelection.data("columnIndex");if($.type(indexApplySelection)==="number"){this._applySortStyles(colApplySelection,indexApplySelection,this._currentIdentifier)}}}$("#"+this.element[0].id+" thead th").removeClass(this.css.sortableColumnHeaderHover)},destroy:function(){var i,a,header,span,text,modalDialog=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog");if(!this.grid){return}$("#"+this.element[0].id).undelegate("thead th","dragstart",this._dragStartHandler);$("#"+this.element[0].id).undelegate("thead th","mouseover",this._mouseOverHandler);$("#"+this.element[0].id).undelegate("thead th","mouseout",this._mouseOutHandler);$("#"+this.element[0].id).undelegate("thead th","click",this._clickHandler);$(document).undelegate("#"+this.element[0].id+"_headers thead th","dragstart",this._dragStartHandler);$(document).undelegate("#"+this.element[0].id+"_headers thead th","mouseover",this._mouseOverHandler);$(document).undelegate("#"+this.element[0].id+"_headers thead th","mouseout",this._mouseOutHandler);$(document).undelegate("#"+this.element[0].id+"_headers thead th","click",this._clickHandler);$("#"+this.element[0].id).undelegate("thead th a","keydown",this._keyDownHandler);$("#"+this.element[0].id).undelegate("thead th a","focus",this._focusHandler);$("#"+this.element[0].id).undelegate("thead th a","blur",this._blurHandler);$(document).undelegate("#"+this.element[0].id+"_headers thead th a","keydown",this._keyDownHandler);$(document).undelegate("#"+this.element[0].id+"_headers thead th a","focus",this._focusHandler);$(document).undelegate("#"+this.element[0].id+"_headers thead th a","blur",this._blurHandler);$("#"+this.element[0].id).undelegate("thead th a:not([th-remove-focus])",{keydown:this._keyDownHandler,focus:this._focusHandler,blur:this._blurHandler});$(document).undelegate("#"+this.element[0].id+"_headers thead th a:not([th-remove-focus])",{keydown:this._keyDownHandler,focus:this._focusHandler,blur:this._blurHandler});this.grid.element.unbind("iggridheadercellrendered",this._headerCellRenderedHandler);this.grid.element.unbind("iggridvirtualhorizontalscroll",this._virtualHorizontalScrollHandler);this.grid.element.unbind("iggriduidirty",this._uiDirtyHandler);this.grid.element.unbind("iggridheaderrendered",this._headerRenderedHandler);this.grid.element.unbind("iggridcolumnscollectionmodified",this._columnsCollectionModifiedHandler);this.grid.element.unbind("iggridcolumnmovingcolumnmoved",this._columnsRearangedHandler);if(this._featureChooserMenuTogglingHandler){this.grid.element.unbind("iggridfeaturechoosermenutoggling",this._featureChooserMenuTogglingHandler)}delete this._blurHandler;delete this._clickHandler;delete this._headerCellRenderedHandler;delete this._focusHandler;delete this._keyDownHandler;delete this._mouseOutHandler;delete this._mouseOverHandler;delete this._dragStartHandler;delete this._uiDirtyHandler;delete this._virtualHorizontalScrollHandler;delete this._headerRenderedHandler;delete this._columnsRearangedHandler;this.grid.element.find(".ui-iggrid-colasc").removeClass("ui-iggrid-colasc ui-state-highlight");this.grid.element.find(".ui-iggrid-coldesc").removeClass("ui-iggrid-coldesc ui-state-highlight");this._clearUi(true);for(i=0;this._headers&&i<this._headers.length;i++){header=this._headers[i].header;header.removeClass("ui-iggrid-sortableheader ui-state-default ui-state-active ui-state-hover ui-state-focus");header.attr("title","");span=header.find("a span");text=span.text();a=header.find("a");$("<span>"+text+"</span>").appendTo(header).addClass("ui-iggrid-headertext");a.remove()}this._headers=null;if(this._loadingIndicator){delete this._loadingIndicator}modalDialog.igGridModalDialog("getCaptionButtonContainer");modalDialog.remove();$.Widget.prototype.destroy.apply(this,arguments);return this},_renderMultipleSortingDialog:function(){var $buttonOK,self=this,o=this.options,modalDialogId=this.grid.element[0].id+"_multiplesorting_modalDialog",$captionButtonContainer,modalDialog;$("#"+modalDialogId).remove();modalDialog=$("<div></div>").appendTo(this.grid._rootContainer()).attr("id",modalDialogId);modalDialog.igGridModalDialog({buttonApplyText:o.modalDialogButtonApplyText,buttonCancelText:o.modalDialogButtonCancelText,renderFooterButtons:!o.modalDialogSortOnClick,modalDialogCaptionText:o.modalDialogCaptionText,modalDialogWidth:o.modalDialogWidth,modalDialogHeight:o.modalDialogHeight,animationDuration:o.modalDialogAnimationDuration,gridContainer:this.grid.container(),modalDialogOpening:function(event,args){var noCancel=self._trigger(self.events.modalDialogOpening,null,{modalDialogElement:modalDialog,owner:self});if(noCancel){self._multiplesortingDialogOpening(event,args);self._trigger(self.events.modalDialogOpened,null,{modalDialogElement:modalDialog,owner:self})}return noCancel},modalDialogMoving:function(e,ui){self._trigger(self.events.modalDialogMoving,null,{modalDialogElement:e.target,owner:self,originalPosition:ui.originalPosition,position:ui.position})},modalDialogClosing:function(event,args){return self._trigger(self.events.modalDialogClosing,null,{modalDialogElement:modalDialog,owner:self})},modalDialogClosed:function(event,args){self._trigger(self.events.modalDialogClosed,null,{modalDialogElement:modalDialog,owner:self})}});if(o.modalDialogSortOnClick){$captionButtonContainer=modalDialog.igGridModalDialog("getCaptionButtonContainer");$("<span></span>").bind("click.hiding",function(event){modalDialog.igGridModalDialog("closeModalDialog",true);event.preventDefault();event.stopPropagation();return false}).addClass("ui-icon ui-icon-closethick").appendTo($("<a></a>").appendTo($captionButtonContainer).attr("title",$.ig.GridHiding.locale.columnChooserCloseButtonTooltip).attr("href","#").attr("role","button").addClass("ui-dialog-titlebar-close ui-corner-all"))}else{$captionButtonContainer=modalDialog.igGridModalDialog("getCaptionButtonContainer");$buttonOK=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog_footer_buttonok");$buttonOK.bind("igbuttonclick",function(e){self._multiplesortingDialogButtonOKClick(e)})}},openMultipleSortingDialog:function(){var modalDialog=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog");modalDialog.igGridModalDialog("openModalDialog")},closeMultipleSortingDialog:function(){var modalDialog=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog");modalDialog.igGridModalDialog("closeModalDialog")},_multiplesortingDialogOpening:function(){this._tempExpr=this.grid.dataSource.settings.sorting.expressions.slice(0);this.renderMultipleSortingDialogContent(true)},renderMultipleSortingDialogContent:function(isToCallEvents){var $content,$sortedColumns,$unsortedColumns,i,j,noCancel=true,self=this,columns=this.grid.options.columns,css=this.css,se=this.grid.dataSource.settings.sorting.expressions,seLength=se.length,sortedColumns=[],modalDialog=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog");if(isToCallEvents){noCancel=this._trigger(this.events.modalDialogContentsRendering,null,{modalDialogElement:modalDialog,owner:this})}if(noCancel){this.removeDialogClearButton();$content=modalDialog.igGridModalDialog("getContent");$content.empty();$sortedColumns=$("<div></div>").attr("id",this.grid.element[0].id+"_multiplesorting_modalDialog_sortedcolumns").addClass(css.dialogSortedColumns).appendTo($content);$unsortedColumns=$("<div></div>").attr("id",this.grid.element[0].id+"_multiplesorting_modalDialog_unsortedcolumns").addClass(css.dialogUnsortedColumns).appendTo($content);$("<ul></ul>").addClass(css.dialogSortedColumnsList).appendTo($sortedColumns);$("<ul></ul>").addClass(css.dialogUnsortedColumnsList).appendTo($unsortedColumns);$.each(columns,function(columnIndex,column){var cs,columnIdentifier,direction;cs=self._getColumnSettingsByIndex(columnIndex);if(cs===null||cs===undefined||cs.allowSorting===false){return true}columnIdentifier=cs.columnKey||cs.columnIndex||column.key;for(i=0;i<self._tempExpr.length;i++){if(self._tempExpr[i].fieldName===columnIdentifier){break}}if(i!==self._tempExpr.length){sortedColumns.push({column:column,columnIndex:cs.columnIndex,dir:self._tempExpr[i].dir,columnIdentifier:columnIdentifier})}else{direction=cs.currentSortDirection||self.options.firstSortDirection;self._renderDialogUnsortedColumn(column,cs.columnIndex,direction,columnIdentifier)}});for(i=0;i<seLength;i++){for(j=0;j<sortedColumns.length;j++){if(se[i].fieldName===sortedColumns[j].columnIdentifier){self._renderDialogSortedColumn(sortedColumns[j].column,sortedColumns[j].columnIndex,sortedColumns[j].dir,sortedColumns[j].columnIdentifier);break}}}if(isToCallEvents){this._trigger(this.events.modalDialogContentsRendered,null,{modalDialogElement:modalDialog,owner:this})}if(this._checkRenderButtonReset()){this._renderDialogButtonClearAll()}}},_addSlideButtonSortingColumns:function(){var css=this.css,o=this.options,$sortedColumns=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog_sortedcolumns"),buttonId=this.grid.element[0].id+"_multiplesorting_modalDialog_slidebutton",$button,innerHTML;innerHTML='<div class="'+css.dialogSlideArea+'">'+'	<div class="'+css.dialogSlideAreaContainer+'">'+'		<button id="'+buttonId+'" class="'+css.dialogButtonSlide+'" role="button" aria-disabled="false" title="'+o.dialogButtonSlideCaption+'">'+'			<span class="'+css.dialogButtonSlideContainer+'"></span>'+'			<span class="ui-button-text">'+o.dialogButtonSlideCaption+"</span>"+"		</button>"+"	</div>"+"</div>";$(innerHTML).insertAfter($sortedColumns);$button=$("#"+buttonId);$button.bind({click:function(e,args){$sortedColumns.slideToggle("slow");$(this).find("span:eq(0)").toggleClass(css.dialogButtonSlideUp);return false}})},_renderDialogSortedColumn:function(column,columnIndex,direction,columnIdentifier){var self=this,$li,css=this.css,$buttonUnsort,liHTML,o=this.options,buttonAscDescId=this.grid.element[0].id+"_"+columnIdentifier+"_multiplesorting_modalDialog_sortedcolumns_buttonascdesc",buttonUnsortId=this.grid.element[0].id+"_"+columnIdentifier+"_multiplesorting_modalDialog_sortedcolumns_buttonunsort",$ul=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog_sortedcolumns ul");$ul.css("width");$li=$("<li></li>").attr("id",self.grid.element[0].id+"_"+columnIdentifier+"_multiplesorting_sorted_li").addClass(css.dialogSortedColumnsItem);$li.appendTo($ul);if(columnIndex!==null&&columnIndex!==undefined){$li.attr("li-order",columnIndex)}liHTML='<span id="'+buttonAscDescId+'" class="'+css.dialogButtonAsc+'" role="button" title="'+o.modalDialogCaptionButtonDesc+'" >'+'	<span class="'+css.dialogButtonAscIcon+'"></span>'+"</span>"+'<span class="'+css.dialogSortedColumnTextContainer+'">'+column.headerText+"</span>"+'<button id="'+buttonUnsortId+'" class="'+css.dialogButtonUnsort+'" role="button" title="'+o.modalDialogCaptionButtonUnsort+'" >'+'	<span class="'+css.dialogButtonUnsortContainer+'"></span>'+'	<span class="ui-button-text">'+o.modalDialogCaptionButtonUnsort+"</span>"+"</button>";$li.bind({click:function(e,args){self._currentIdentifier=columnIdentifier;self._dialogButtonAscDescClick(columnIdentifier);if(self._checkRenderButtonReset()){self._renderDialogButtonClearAll()}else{self.removeDialogClearButton()}e.preventDefault();e.stopPropagation()}});$li.html(liHTML);$buttonUnsort=$("#"+buttonUnsortId);if(direction!==undefined){if(direction.indexOf("asc")!==-1){self._setDialogButtonAscDesc(true,columnIdentifier);self._setTempExpr(columnIdentifier,"asc")}else{self._setDialogButtonAscDesc(false,columnIdentifier);self._setTempExpr(columnIdentifier,"desc")}}else{self._setDialogButtonAscDesc(true,columnIdentifier);self._setTempExpr(columnIdentifier,"asc")}$buttonUnsort.bind({click:function(e,args){var noCancel,modalDialog=$("#"+self.grid.element[0].id+"_multiplesorting_modalDialog");noCancel=self._trigger(self.events.modalDialogButtonUnsortClick,e,{modalDialogElement:modalDialog,owner:self,columnKey:columnIdentifier});if(noCancel){$li.remove();if(o.modalDialogSortOnClick===true){self.unsortColumn(columnIdentifier)}else{self._setTempExpr(columnIdentifier)}self._renderDialogUnsortedColumn(column,columnIndex,direction,columnIdentifier);if(self._checkRenderButtonReset()){self._renderDialogButtonClearAll()}else{self.removeDialogClearButton()}}e.preventDefault();e.stopPropagation()},mouseover:function(e,args){if(!$(this).hasClass(css.dialogButtonsHover)){$(this).addClass(css.dialogButtonsHover)}},mouseout:function(e,args){if($(this).hasClass(css.dialogButtonsHover)){$(this).removeClass(css.dialogButtonsHover)}}})},_dialogButtonAscDescClick:function(columnIdentifier){var o=this.options,noCancel,modalDialog=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog"),$buttonAscDesc=$("#"+this.grid.element[0].id+"_"+columnIdentifier+"_multiplesorting_modalDialog_sortedcolumns_buttonascdesc"),isAsc=$buttonAscDesc.data("isAsc");noCancel=this._trigger(this.events.modalDialogSortingChanged,null,{modalDialogElement:modalDialog,owner:this,columnKey:columnIdentifier,isAsc:!isAsc});if(noCancel){if(isAsc===true){if(o.modalDialogSortOnClick===true){this.sortColumn(columnIdentifier,"descending",this._getHeaderCellByIdentifier(columnIdentifier))}else{this._setTempExpr(columnIdentifier,"desc")}this._setDialogButtonAscDesc(false,columnIdentifier)}else{if(o.modalDialogSortOnClick===true){this.sortColumn(columnIdentifier,"ascending",this._getHeaderCellByIdentifier(columnIdentifier))}else{this._setTempExpr(columnIdentifier,"asc")}this._setDialogButtonAscDesc(true,columnIdentifier)}}},_setDialogButtonAscDesc:function(isAsc,columnIdentifier){var css=this.css,buttonAscDescId=this.grid.element[0].id+"_"+columnIdentifier+"_multiplesorting_modalDialog_sortedcolumns_buttonascdesc",$buttonAscDesc=$("#"+buttonAscDescId),$spanIcon=$buttonAscDesc.find("span:eq(0)");$buttonAscDesc.data("isAsc",isAsc);if(isAsc===true){$buttonAscDesc.attr("title",this.options.modalDialogCaptionButtonDesc).removeClass(css.dialogButtonDesc).addClass(css.dialogButtonAsc);$spanIcon.removeClass(css.dialogButtonDescIcon).addClass(css.dialogButtonAscIcon);this._setTempExpr(columnIdentifier,"asc")}else{$buttonAscDesc.attr("title",this.options.modalDialogCaptionButtonAsc).removeClass(css.dialogButtonAsc).addClass(css.dialogButtonDesc);$spanIcon.removeClass(css.dialogButtonAscIcon).addClass(css.dialogButtonDescIcon);this._setTempExpr(columnIdentifier,"desc")}},_setTempExpr:function(colKey,dir){var i,expr=this._tempExpr;for(i=0;i<expr.length;i++){if(expr[i].fieldName===colKey){expr.splice(i,1);if(dir===null||dir===undefined){this._tempExpr=expr;return}}}this._tempExpr=expr.concat([{fieldName:colKey,dir:dir}])},_renderDialogUnsortedColumn:function(column,columnIndex,direction,columnIdentifier){var self=this,$li,$a,o=this.options,css=this.css,$ul=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog_unsortedcolumns ul");$ul.css("width");$li=$("<li></li>").attr("id",self.grid.element[0].id+"_"+columnIdentifier+"_multiplesorting_unsorted_li").addClass(css.dialogUnsortedColumnsItem).append('<span class="'+css.dialogUnsortedColumnsSortByButton+'"><a href="#"></a></span> <span class="'+css.dialogItemText+'">'+column.headerText+"</span>");this._insertColumnModalDialog($ul,$li,columnIndex);if(columnIndex!==null&&columnIndex!==undefined){$li.attr("li-order",columnIndex)}$a=$li.find("a:first");$a.addClass(css.modalDialogSortByColumn);$a.html(o.modalDialogSortByButtonText);$li.bind({click:function(e,args){var noCancel,modalDialog=$("#"+self.grid.element[0].id+"_multiplesorting_modalDialog");noCancel=self._trigger(self.events.modalDialogSortClick,e,{modalDialogElement:modalDialog,owner:self,columnKey:columnIdentifier});if(noCancel){$li.remove();self._renderDialogSortedColumn(column,columnIndex,direction,columnIdentifier);if(o.modalDialogSortOnClick){self.sortColumn(columnIdentifier,null,self._getHeaderCellByIdentifier(columnIdentifier))}else{if(self._checkRenderButtonReset()){self._renderDialogButtonClearAll()}else{self.removeDialogClearButton()}}}e.preventDefault();e.stopPropagation()}})},_checkRenderButtonReset:function(){var i,j,cs,columnKey,expr=this._tempExpr;this._isResetClick=false;for(i=0;i<this.options.columnSettings.length;i++){cs=this.options.columnSettings[i];if(cs.allowSorting===false){continue}columnKey=cs.columnKey;for(j=0;j<expr.length;j++){if(expr[j].fieldName===columnKey){if(cs.userSet_currentSortDirection!==expr[j].dir){return true}break}}if(j===expr.length&&cs.userSet_currentSortDirection!=="undefined"){return true}}this._isResetClick=true;return false},removeDialogClearButton:function(){$("#"+this.grid.element[0].id+"_sorting_modalDialog_reset_button").remove()},_renderDialogButtonClearAll:function(){if(this.options.modalDialogSortOnClick===true){return}var self=this,o=this.options,resetButtonId=self.grid.element[0].id+"_sorting_modalDialog_reset_button",modalDialog=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog"),$captionButtonContainer,$resetButton;if($("#"+resetButtonId).length===0){$captionButtonContainer=modalDialog.igGridModalDialog("getCaptionButtonContainer");$resetButton=$("<button></button>").attr("id",resetButtonId).appendTo($captionButtonContainer);$resetButton.igButton({labelText:o.modalDialogResetButtonLabel,click:function(e){var noCancel,i,cs=self.options.columnSettings;noCancel=self._trigger(self.events.modalDialogButtonResetClick,e,{modalDialogElement:modalDialog,owner:self});if(noCancel){self._tempExpr=[];for(i=0;i<cs.length;i++){if(cs[i].allowSorting!==false&&cs[i].userSet_currentSortDirection!=="undefined"){self._tempExpr.push({fieldName:cs[i].columnKey,dir:cs[i].userSet_currentSortDirection})}}self.renderMultipleSortingDialogContent(false);self.removeDialogClearButton();self._isResetClick=true}}})}},_multiplesortingDialogButtonOKClick:function(e,args){var noCancel,modalDialog=$("#"+this.grid.element[0].id+"_multiplesorting_modalDialog");noCancel=this._trigger(this.events.modalDialogButtonApplyClick,null,{modalDialogElement:modalDialog,owner:this,columnsToSort:this._tempExpr});if(noCancel){this.grid.dataSource.settings.sorting.expressions=this._tempExpr;this.sortMultiple();modalDialog.igGridModalDialog("closeModalDialog")}},_insertColumnModalDialog:function($ul,$li,pos){var i,$currLi,currPos,listItems=$ul.find("li"),listItemsLength=listItems.length;if(listItemsLength===0||pos===null||pos===undefined){$li.appendTo($ul);return}for(i=0;i<listItemsLength;i++){$currLi=$(listItems[i]);currPos=$currLi.attr("li-order");if(currPos>=pos){$li.insertBefore($currLi);break}}if(i===listItemsLength){$li.appendTo($ul)}},_getColumnSettings:function(index,key){var i,foundByIndex=null;for(i=0;i<this.options.columnSettings.length;i++){if(this.options.columnSettings[i].columnKey===key){foundByIndex=this.options.columnSettings[i];break}if(this.options.columnSettings[i].columnIndex===index){foundByIndex=this.options.columnSettings[i];break}}return foundByIndex},_getColumnSettingsByIndex:function(index){var key=this.grid.options.columns[index].key;return this._getColumnSettings(index,key)},_headerRendered:function(event,ui){if(ui.owner.element.attr("id")!==this.grid.element.attr("id")){return}if(this.grid.element.data("igGridResizing")){this._resizing=this.grid.element.data("igGridResizing")}if(!this._columnFixing&&this.grid.element.data("igGridColumnFixing")){this._columnFixing=this.grid.element.data("igGridColumnFixing")}if(this.options.mode!=="single"){this._renderMultipleSortingDialog()}},_getDataColumnSortingExpressions:function(se){if(!this.grid._hasUnboundColumns){return se}var grid=this.grid,newSE;newSE=$.grep(se,function(s){var col=grid.columnByKey(s.fieldName);return!col||col.unbound!==true});return newSE},_saveSortingExpressions:function(){if(this.options.persist){var se;if(this._restoreSorting===undefined||this._restoreSorting){$.each(this.options.columnSettings,function(i,setting){delete setting.userSet_currentSortDirection})}se=this._getDataColumnSortingExpressions(this.grid.dataSource.settings.sorting.expressions);this.grid._savePersistenceData(se,"sorting",this.grid.element[0].id);this._sortingExpressions=se;this._restoreSorting=false}},_preserveSorting:function(){var se=this.grid._getPersistenceData("sorting",this.grid.element[0].id);if(se){this._restoreSorting=true;if(se!==this._sortingExpressions){this._sortingExpressions=se}this.grid.dataSource.settings.sorting.expressions=se;this.grid.dataSource.settings.sorting.defaultFields=se}},_couldPreserveData:function(){return!this.options.persist||this.grid.dataSource.settings.sorting.expressions!==this.grid._getPersistenceData("sorting",this.grid.element[0].id)},_injectGrid:function(gridInstance,isRebind){this.grid=gridInstance;var restoreSortingExpr;if(this.options.type===null){this.options.type=this.grid._inferOpType()}if(this.options.type){this.grid.dataSource.settings.sorting.type=this.options.type}else{this.grid.dataSource.settings.sorting.type="remote"}this.grid.dataSource.settings.sorting.caseSensitive=this.options.caseSensitive;this.grid.dataSource.settings.sorting.defaultFields=this.grid.dataSource.settings.sorting.expressions;this.grid.dataSource.settings.sorting.enabled=true;this.grid.dataSource.settings.sorting.sortUrlKey=this.options.sortUrlKey;this.grid.dataSource.settings.sorting.sortUrlAscValueKey=this.options.sortUrlKeyAscValue;this.grid.dataSource.settings.sorting.sortUrlDescValueKey=this.options.sortUrlKeyDescValue;if($.type(this.options.customSortFunction)==="function"){this.grid.dataSource.settings.sorting.customFunc=this.options.customSortFunction}else if(typeof this.options.customSortFunction==="string"){if(window[this.options.customSortFunction]&&typeof window[this.options.customSortFunction]==="function"){this.grid.dataSource.settings.sorting.customFunc=window[this.options.customSortFunction]}}if(this._headerCellRenderedHandler!==null&&this._headerCellRenderedHandler!==undefined){this.grid.element.unbind("iggridheadercellrendered",this._headerCellRenderedHandler)}if(this._uiDirtyHandler){this.grid.element.unbind("iggriduidirty",this._uiDirtyHandler)}if(this._headerRenderedHandler!==null&&this._headerRenderedHandler!==undefined){this.grid.element.unbind("iggridheaderrendered",this._headerRenderedHandler)}this._headerCellRenderedHandler=$.proxy(this._headerCellRendered,this);this._columnsCollectionModifiedHandler=$.proxy(this._columnsCollectionModified,this);this._uiDirtyHandler=$.proxy(this._onUIDirty,this);this._headerRenderedHandler=$.proxy(this._headerRendered,this);this._columnsRearangedHandler=$.proxy(this._columnsRearranged,this);this.grid.element.bind("iggridheadercellrendered",this._headerCellRenderedHandler);this._virtualHorizontalScrollHandler=$.proxy(this._virtualHorizontalScroll,this);this.grid.element.bind("iggridvirtualhorizontalscroll",this._virtualHorizontalScrollHandler);this.grid.element.bind("iggriduidirty",this._uiDirtyHandler);this.grid.element.bind("iggridcolumnscollectionmodified",this._columnsCollectionModifiedHandler);this.grid.element.bind("iggridheaderrendered",this._headerRenderedHandler);this.grid.element.bind("iggridcolumnmovingcolumnmoved",this._columnsRearangedHandler);if(this.options.persist&&this.grid._hasUnboundColumns){cs=this.options.columnSettings;for(i=0;i<cs.length;i++){if(cs[i].columnKey&&cs[i].currentSortDirection){col=this.grid.columnByKey(cs[i].columnKey);if(col&&col.unbound===true){delete cs[i].currentSortDirection}}}}this._initDefaultSettings();restoreSortingExpr=null;if(this.options.persist&&this.grid.element.data("igGridGroupBy")&&this.options.mode!=="single"){if(this.grid.element.data("igGridGroupBy")._getSortingExpressions()===this.grid.dataSource.settings.sorting.expressions){restoreSortingExpr=this.grid.dataSource.settings.sorting.expressions.slice(0)}}this._clearUi();if(restoreSortingExpr){this.grid.dataSource.settings.sorting.expressions=restoreSortingExpr;this._saveSortingExpressions()}this._currentActiveHeader=null;this._currentHeader=null;this._currentIndex=null;this._currentIdentifier=null;if(this.options.persist){this._preserveSorting()}}});$.extend($.ui.igGridSorting,{version:"14.1.20141.1020"})})(jQuery);(function($){$(document).ready(function(){var wm=$("#__ig_wm__").length>0?$("#__ig_wm__"):$('<div id="__ig_wm__"></div>').appendTo(document.body);wm.css({position:"fixed",bottom:0,right:0,zIndex:1e3}).addClass("ui-igtrialwatermark")})})(jQuery);