/*!@license
* Infragistics.Web.ClientUI Grid Editing 14.1.20141.1020
*
* Copyright (c) 2011-2014 Infragistics Inc.
*
* http://www.infragistics.com/
*
* Depends on:
* jquery-1.4.4.js
* jquery.ui.core.js
* jquery.ui.widget.js
* infragistics.ui.grid.framework.js
* infragistics.ui.editors.js
* infragistics.ui.validator.js
* infragistics.ui.combo.js
* infragistics.ui.rating.js
* infragistics.ui.shared.js
* infragistics.dataSource.js
* infragistics.util.js
*/
(function($){var _aNull=function(v,nan){return v===null||v===undefined||v==="undefined"||nan&&isNaN(v)},_int=function(e,val){val=e?e.css(val):0;try{val=parseInt(val,10)}catch(ignore){}return val&&!isNaN(val)?val:0},_filter=function(elem,name,p1,p2){elem=elem.data("igEditorFilter");return elem?elem.options.provider[name](p1,p2):null},_now=function(){return(new Date).getTime()},_throw=function(def){var str=$.ig.GridUpdating&&$.ig.GridUpdating.locale?$.ig.GridUpdating.locale[def]:def;throw new Error(str||def)},_stop=function(e){if(e&&e!==1){try{e.preventDefault();e.stopPropagation()}catch(ignore){}}};$.widget("ui.igGridUpdating",{grid:null,options:{columnSettings:[{columnKey:null,editorType:null,editorProvider:null,editorOptions:null,required:null,readOnly:null,validation:null,defaultValue:null}],editMode:"row",showReadonlyEditors:true,enableDeleteRow:true,enableAddRow:true,validation:false,doneLabel:null,doneTooltip:null,cancelLabel:null,cancelTooltip:null,addRowLabel:null,addRowTooltip:null,deleteRowLabel:null,deleteRowTooltip:null,rowEditDialogCaptionLabel:null,showDoneCancelButtons:true,enableDataDirtyException:true,rowEditDialogContentHeight:150,rowEditDialogFieldWidth:140,rowEditDialogWidth:370,rowEditDialogHeight:"350",startEditTriggers:"click,F2,enter",rowEditDialogContainment:"owner",rowEditDialogOkCancelButtonWidth:120,rowEditDialogRowTemplate:null,rowEditDialogRowTemplateID:null,horizontalMoveOnEnter:false,excelNavigationMode:false,saveChangesSuccessHandler:null,saveChangesErrorHandler:null,swipeDistance:"100px"},events:{editRowStarting:null,editRowStarted:null,editRowEnding:null,editRowEnded:null,editCellStarting:null,editCellStarted:null,editCellEnding:null,editCellEnded:null,rowAdding:null,rowAdded:null,rowDeleting:null,rowDeleted:null,dataDirty:null,generatePrimaryKeyValue:null,rowEditDialogOpening:null,rowEditDialogOpened:null,rowEditDialogContentsRendering:null,rowEditDialogContentsRendered:null,rowEditDialogClosing:null,rowEditDialogClosed:null},css:{buttonContainer:"ui-iggrid-buttoncontainer ui-widget-content ui-corner-all",button:"ui-iggrid-button ui-state-default ui-corner-all",doneButton:"ui-iggrid-donebutton ui-priority-primary ui-corner-all",cancelButton:"ui-iggrid-cancelbutton ui-corner-all",deleteButton:"ui-iggrid-deletebutton ui-state-default ui-corner-all",buttonHover:"ui-iggrid-buttonhover ui-state-hover",buttonDisabled:"ui-iggrid-buttondisabled ui-state-disabled",buttonActive:"ui-iggrid-buttonactive ui-state-active",doneIcon:"ui-iggrid-doneicon ui-icon ui-icon-check",cancelIcon:"ui-iggrid-cancelicon ui-icon ui-icon-cancel",buttonIconOnly:"ui-iggrid-button-icon-only",editingCell:"ui-iggrid-editingcell",addRow:"ui-iggrid-addrow ui-widget-header",addRowHover:"ui-iggrid-addrowhover ui-state-hover",addRowActive:"ui-iggrid-addrowactive ui-state-active",addRowIcon:"ui-iggrid-addrowicon ui-icon ui-icon-circle-plus",deleteIcon:"ui-iggrid-deleteicon ui-icon ui-icon-circle-close",editor:"ui-iggrid-editor",rowEditDialogHeaderCaption:"ui-dialog-titlebar ui-iggrid-filterdialogcaption ui-widget-header ui-corner-all ui-helper-reset ui-helper-clearfix",rowEditDialogHeaderCaptionTitle:"ui-dialog-title",rowEditDialog:"ui-dialog ui-draggable ui-resizable ui-iggrid-dialog ui-widget ui-widget-content ui-corner-all",blockArea:"ui-widget-overlay ui-iggrid-blockarea",rowEditDialogOkCancelButton:"ui-dialog-buttonpane ui-widget-content ui-helper-clearfix ui-iggrid-filterdialogokcancelbuttoncontainer",rowEditDialogTable:"ui-iggrid-filtertable ui-helper-reset"},setCellValue:function(rowId,colKey,value,tr){var $tr,$td,tdi;if(!_aNull(rowId)&&typeof colKey==="string"){$tr=tr?$(tr):this.grid.element.children("tbody").children('tr[data-id="'+rowId+'"]');if($tr.length!==1){$tr=1;$td=$()}else{tdi=this.grid._getCellIndexByColumnKey(colKey);$td=tdi>=0?$tr.children().eq(tdi):$();$tr=$tr[0]}if(this.isEditing()&&this._tds[colKey]&&$td.find(".ui-igedit,.ui-igcombo").length>0&&this.editorForKey(colKey)instanceof jQuery){if(this.editorForKey(colKey).data().hasOwnProperty("igCombo")){this.editorForKey(colKey).igCombo("value",value)}else{this.editorForKey(colKey).igEditor("value",value)}this._notifyChanged()}else{this._update(rowId,$tr,value,colKey,$td)}}},updateRow:function(rowId,values,tr){var key;if(!_aNull(rowId)&&values){tr=tr||this.grid.element.children("tbody").children('tr[data-id="'+rowId+'"]')[0]||1;if(this.isEditing()&&$(tr).find(".ui-igedit,.ui-igcombo").length>0){for(key in values){if(values.hasOwnProperty(key)&&this.editorForKey(key)instanceof jQuery){if(this.editorForKey(key).data().hasOwnProperty("igCombo")){this.editorForKey(key).igCombo("value",values[key])}else{this.editorForKey(key).igEditor("value",values[key])}}}this._notifyChanged()}else{this._update(rowId,tr,values)}}},addRow:function(values){values=values||{};var cols=this.options.columnSettings,i=cols?cols.length:0,key,val;while(i-->0){key=cols[i].columnKey;val=cols[i].defaultValue;if(!_aNull(val)&&!_aNull(key)){if(_aNull(values[key])){values[key]=val}}}this._update(values)},deleteRow:function(rowId,tr){if(!_aNull(rowId)){tr=tr||this.grid.element.children("tbody").children('tr[data-id="'+rowId+'"]')[0]||1;if(this.isEditing()&&$(tr).find(".ui-igedit,.ui-igcombo").length>0){this.endEdit(false)}this._update(rowId,tr)}},startEdit:function(row,col,e){var td=this.grid.cellAt(col,row),tr;if(this.options.editMode==="rowedittemplate"){tr=this.grid.rowAt(row);return this._startEditRowTemplate(e,$(tr))}if(td){td=this._startEdit($(td),e||1,1)===1}return!!td},startAddRowEdit:function(e){var tr=this._newTR,h,hasFixedColumns=this.grid.hasFixedColumns();if(this.options.editMode==="rowedittemplate"){return this._startEditRowTemplate(e,null,null,true)}if(tr){if(e&&e.target&&hasFixedColumns){if(this.grid._isFixedElement($(e.target))){tr=$(e.target).closest("thead").find("tr[data-new-row]")}}tr=this._startEdit($(tr.children()[0]),e||1,1,1,this._addTR.children()[0].offsetHeight)===1;if(this._newTR&&hasFixedColumns){if($.ig.util.isIE){h=this._addTR.outerHeight()}else{h=this._addTR.height()}this.grid.fixedContainer().find("thead tr[data-new-row]").height(h);this.grid.container().find("thead tr[data-new-row]").height(h);$(tr).height(h)}}return!!tr},endEdit:function(update,e){if(this.options.editMode==="rowedittemplate"){return update?this._rowEditDialogDoUpdate(e):this._closeRowEditDialog(e)}return!this._endEdit(e||1,update)},findInvalid:function(){var key,all=this._editors;for(key in all){if(all.hasOwnProperty(key)&&all[key]&&!_filter(all[key],"isValid")){return key}}return null},isEditing:function(){return!!this._tds},editorForKey:function(key){var e=this._editors;return e?e[key]:null},editorForCell:function(td,add){var e,key=this._key(td),edits=this._editors;if(!edits){edits=this._editors={}}e=edits[key];if(!e&&add){e=edits[key]=this._createEditor(td,key)}return e},findHiddenComboEditor:function(editor){var combos=this._hCombos,combo=combos&&editor?editor.data("igCombo"):null,hComboID=combo?combo.options._hComboID:null,obj=hComboID?combos[hComboID]:null;combo=obj?obj.combo.data("igCombo"):null;if(combo){combo._colKey=obj.key}return combo},_setOption:function(key,value){var o=this.options;if(o[key]===value){return this}this._endEdit();this._doButtons(2);o[key]=value;if(key.indexOf("ddRow")>0){this._headerRendered();this.grid._initializeHeights();if(this.grid.options.virtualization===true||this.grid.options.rowVirtualization===true){this.grid._onVirtualVerticalScroll()}}else if(key==="saveChangesSuccessHandler"){this._addDSSuccessHandler()}else if(key==="saveChangesErrorHandler"){this._addDSErrorHandler()}return this},_fire:function(name,e,a){if(a&&e&&e!==1){a.owner=this;return this._trigger(name,e,a)}return 1},_loc:function(prop,title){prop+=title?"Tooltip":"Label";title=this.options[prop];if(_aNull(title)){title=$.ig.GridUpdating&&$.ig.GridUpdating.locale?$.ig.GridUpdating.locale[prop]:null}return title||""},_div:function(){return this.grid.container()},_hscroll:function(scroller){if(!this._hscr1){var grid=this.grid.element;this._hscr1=$("#"+grid[0].id+"_hscroller");this._hscr2=this._hscr1.length?this._hscr1:grid.parent()}return scroller?this._hscr1:this._hscr2},_groupedColumnsChanged:function(args){this._groupCols=args.groupedColumns.length;this._hidingFinishing();this._headerRendered()},_headerRendered:function(i){var th,txt,title,me=this,grid=me.grid,hasFixedCols=grid.hasFixedColumns(),tr=me._addTR,o=me.options,cols=grid.options.columns,len=cols.length,fCols,ufCols;if(!o.enableAddRow||i===1){if(tr){tr.remove();me._newTR.remove();me._hierTD=me._newTR=me._addTR=null;if(this.grid.hasFixedColumns()){this.grid.fixedHeadersTable().find("thead tr[data-add-row]").remove();this.grid.fixedHeadersTable().find("thead tr[data-new-row]").remove();this.grid.element.data("igGridColumnFixing")._syncContainerHeights()}}return}txt=me._loc("addRow")||"&nbsp;";title=me._loc("addRow",1);if(tr){tr.find(".anr_t").html(txt);tr.find(".ui-iggrid-addrow").attr("title",title);tr.find(".anr_i").css("display","inline-block")}th=me._div().find("thead");if(!th||tr){return}if(hasFixedCols){fCols=[];ufCols=[];for(i=0;i<len;i++){if(cols[i].fixed===true){fCols.push(cols[i])}else{ufCols.push(cols[i])}}th=me._div().find("div[data-fixed-container]").find("thead");cols=ufCols;this._headerRenderedHelper(fCols,th,txt,title);th=me._div().find("div:not([data-fixed-container])").find("thead")}this._headerRenderedHelper(cols,th,txt,title)},_headerRenderedHelper:function(cols,th,txt,title){var i,plus,td,col,colSet,me=this,css=me.css,shift=me._addTrShift,colSpan=0,tr=me._addTR,o=me.options,grid=me.grid,len=cols.length,hiddenColumns=grid._initialHiddenColumns||[],hiddenKeys=[];plus=o.showPlusIcon;tr=me._addTR=$("<tr />").addClass(css.addRow).attr("data-skip","true").attr("data-add-row","true").appendTo(th);if(shift){for(i=0;i<shift.length;i++){$(shift[i]).appendTo(tr)}}else{me._hierOn=_now();grid._headerInit(tr);me._hierTD=tr.children().length}for(i=0;i<len;i++){if(!cols[i].hidden){colSpan++}else{hiddenKeys.push(cols[i].key)}}for(i=0;i<hiddenColumns.length;i++){if($.ig.indexInArray(hiddenKeys,hiddenColumns[i].key)===-1){hiddenKeys.push(hiddenColumns[i].key);colSpan--}}if(me._groupCols){me._groupTD1=$("<td />").addClass("ui-iggrid-rowselector-header").attr("data-skip","true").appendTo(tr)}td=$('<td colspan="'+colSpan+'"></td>').attr("title",title).addClass(css.addRow).appendTo(tr);me._addLeft=_int(td,"paddingLeft");$("<span />").css("display","inline-block").addClass(css.addRowIcon).addClass("anr_i").appendTo(td);$("<span>"+txt+"</span>").addClass("anr_t").css("outline",0).attr("tabIndex",me._ti+1).focus(function(e){me._onEvt(e,5)}).blur(function(e){me._onEvt(e,6)}).appendTo(td);tr=me._newTR=$("<tr />").attr("data-skip","true").attr("data-new-row","true").appendTo(th).hide();shift=this._newTrShift;if(shift){for(i=0;i<shift.length;i++){$(shift[i]).appendTo(tr)}}else{grid._headerInit(tr)}if(me._groupCols){me._groupTD2=$("<td />").addClass("ui-iggrid-rowselector-header").attr("data-skip","true").appendTo(tr)}for(i=0;i<len;i++){col=cols[i];if(!col.hidden&&$.ig.indexInArray(hiddenKeys,col.key)===-1){colSet=me._colSet(0,col?col.key:null);plus=colSet&&colSet.readOnly;txt=plus?colSet.defaultValue:null;txt=_aNull(txt)?"&nbsp;":grid._renderCell(txt,col);td=$("<td>"+txt+"</td>").addClass(css.editingCell).appendTo(tr);if(plus&&col&&col.key===grid.options.primaryKey){me._tdAddPrime=td}}}},_hierGridInDiv:function(){var css,kids,len,elem,extra=0,i=-1,tr=this._newTR,trA=this._addTR;kids=tr.parent().children();while(++i<kids.length){if(kids[i]!==trA[0]&&kids[i]!==tr[0]){break}}if(i>kids.length){return}kids=kids[i].childNodes;len=kids.length;for(i=0;i<len;i++){elem=kids[i];css=elem.getAttribute("data-skip")?elem.className:null;if(css&&(css.indexOf("-expand")>=0||css.indexOf("-rowselector")>=0)){extra++}else{break}}kids=tr.children();len=kids.length;for(i=0;i<len;i++){elem=kids[i];if(elem.getAttribute("data-skip")){extra--}else{break}}while(extra-->0){this.grid._headerInit(tr,null,true);this.grid._headerInit(trA,null,true)}},_hierHeaderInit:function(){var i,me=this,on=me._hierOn,tr=me._addTR;if(!tr||!on||_now()-on>200){return}if(me._hierTD){setTimeout(function(){me._hierGridInDiv()},0);setTimeout(function(){me._hierGridInDiv()},200);return}i=tr.children().length;me.grid._headerInit(tr,null,true);me.grid._headerInit(me._newTR,null,true);me._hierTD=tr.children().length-i},_dataRendered:function(){if(this._wasInit){return}this._scrollDiv();if(this._renderTouchUI&&this.options.editMode!=="row"){this._div().bind(this._tEvts);delete this._evts.mousemove;delete this._evts.mouseleave}this._div().bind(this._evts);this._wasInit=true},_findCell:function(e){var i=0,td=$(e),grid=this.grid.element[0];if(this.grid.hasFixedColumns()&&td.closest("div").attr("data-fixed-container")!==undefined){grid=$("#"+this.grid.id()+"_fixed")[0]}if(!td.is("td")){td=td.closest("td")}e=td;while(e&&i++<5){e=e.parent();if(e&&e[0]===grid){break}}return i===3&&this._col(td)>=0&&this._row(td)>=0?td:null},_td:function(from){var i,tds=this._tds;if(tds){for(i in tds){if(tds.hasOwnProperty(i)&&tds[i]&&(from?i===from:true)){return tds[i]}}}},_row:function(td){return td?td.parent().index():-1},_idForCol:function(id,shift){var last=-1,map=this._col(1),i=map?map.length:0;while(--i>=0){if(map[i]<0){continue}if(shift===-2){return i}if(map[i]===id){if(shift===1){return last}if(shift===-1){shift=-2}else{break}}last=i}return i},_keyForEditor:function(editor){var ckey;editor=editor instanceof jQuery?editor[0]:editor;for(ckey in this._editors){if(this._editors.hasOwnProperty(ckey)&&this._editors[ckey]&&this._editors[ckey][0]===editor){return ckey}}},_isAdd:function(td){return td===1?this._adding:this._isSrc(this._addTR,td)||this._isSrc(this._newTR,td)},_col:function(td){var col,shift,len,cols,id,i,add=this._isAdd(td),colInd=-1,hasFixedCols=this.grid.hasFixedColumns(),map=add?this._mapAdd:this._map;if(hasFixedCols&&td!==1){col=this.grid._getColumnByTD($(td));if(col!==null){colInd=col.index}}if(!map){shift=this._colShift(td);map=[];id=i=-1;while(shift-->0){map[++i]=-1}cols=this.grid.options.columns;len=cols.length;while(++id<len){if(cols[id]&&!cols[id].hidden){map[++i]=id}}if(add){this._mapAdd=map}else{this._map=map}}if(td===1){return map}if(hasFixedCols&&colInd!==-1){return colInd}id=td.index()+(this.grid._startColIndex||0);return td&&id<map.length?map[id]:-1},_colSet:function(td,key){var i,cols=this.options.columnSettings;if(!key){key=this._key(td)}i=cols&&key?cols.length:0;while(i-->0){if(cols[i].columnKey===key){return cols[i]}}},_isSame:function(td1,td2){return this._row(td1)===this._row(td2)&&this._col(td1)===this._col(td2)},_gridCol:function(key,id){var i=-1,cols=this.grid.options.columns;while(++i<cols.length){if(cols[i].key===key){return id?i:cols[i]}}},_prime:function(td){var key=td.parent().attr("data-id");return _aNull(key)?this._row(td):this._fixPrime(key)},_defVal:function(key,fire){var col;if(key){col=this._colSet(null,key);col=col?col.defaultValue:null;if(fire&&key===this.grid.options.primaryKey){col=this._defValue;if(!col){col={value:col||this._addRowNum};this._fire("generatePrimaryKeyValue",this._evt||{},col);this._defValue=col=col.value}}}return col},_addReadOnly:function(add){var v,key,prime,cols=this.options.columnSettings,vals={};for(key in cols){if(cols.hasOwnProperty(key)){v=cols[key];key=v.columnKey;if(v.readOnly){if(!add){vals[key]=this._getVal(this._row_,key)}else{v=this._defVal(key,1);if(!_aNull(v)){prime=key;vals[prime]=v}}}}}if(!prime&&add){this._fixPrime(vals,this.grid.dataSource)}return vals},_key:function(td){var cols,col;if(this.grid.hasFixedColumns()){col=this.grid._getColumnByTD(td);if(col!==null){return col.column.key}}cols=this.grid.options.columns;col=this._col(td);col=cols&&col>=0?cols[col]:null;return col?col.key:null},_equals:function(v1,v2){return v1===v2||v1&&v2&&v1.getTime&&v2.getTime&&v1.getTime()===v2.getTime()},_val:function(td,arg,vals){var val,add=this._adding,row=this._row_,key=this._key(td);if(add){val=this._defVal(key,vals&&_aNull(vals[key]))}else{val=this._getVal(row,key)}if(arg){if(add||!this._equals(val,arg.value)){if(vals){return arg.value}this._update(row,td.parent()[0],arg.value,key,td)}return undefined}return val},_colShift:function(td,tr){var i,add,shift=this._cShift,shiftAdd=this._cShiftAdd;if(!tr&&td){tr=td.parent()[0]}if(!tr){return shift<0?0:shift}add=this._isAdd(tr);if(add){if(shiftAdd>=0){return shiftAdd}}else if(shift>=0){return shift}tr=tr?tr.childNodes:null;if(!tr){return 0}shift=0;for(i=0;i<tr.length-1;i++){td=tr[i].className;if(td&&(td.indexOf("-expandcolumn")>=0||td.indexOf("-rowselector")>=0)||tr[i].getAttribute("data-skip")){shift++}else{break}}if(add){this._cShiftAdd=shift}else{this._cShift=shift}return shift},_cur:function(td,i){return{tbl:td.parent().parent().parent(),row:i?this._rowIndex:this._row(td),col:this._col(td)}},_nextTDFixing:function(cur,shift,row){var td=null,$fixedContainer,isLeft,tds;if(this.grid._isFixedElement(cur.td)){isLeft=cur.td.closest("div[data-fixing-direction]").attr("data-fixing-direction")==="left";if(isLeft){if(shift===1){tds=this.grid.element.find("tbody tr:nth-child("+(row+1)+")").children();if(tds.length>0){td=tds[0]}}else if(shift===-1&&row>=1){tds=this.grid.element.find("tbody tr:nth-child("+row+")").children();if(tds.length>0){td=tds[tds.length-1]}}}else{if(shift===1){tds=this.grid.element.find("tbody tr:nth-child("+(row+2)+")").children();if(tds.length>0){td=tds[0]}}else if(shift===-1){tds=this.grid.element.find("tbody tr:nth-child("+(row+1)+")").children();if(tds.length>0){td=tds[tds.length-1]}}}}else{$fixedContainer=this.grid.container().find("div[data-fixing-direction]");isLeft=$fixedContainer.attr("data-fixing-direction")==="left";if(isLeft){if(shift===1){tds=$fixedContainer.find("tbody tr:nth-child("+(row+2)+")").children();if(tds.length>0){td=tds[0]}}else if(shift===-1){tds=$fixedContainer.find("tbody tr:nth-child("+(row+1)+")").children();if(tds.length>0){td=tds[tds.length-1]}}}else{if(shift===1){tds=$fixedContainer.find("tbody tr:nth-child("+(row+1)+")").children();if(tds.length>0){td=tds[0]}}else if(shift===-1&&row>=1){tds=$fixedContainer.find("tbody tr:nth-child("+row+")").children();if(tds.length>0){td=tds[tds.length-1]}}}}return td},_nextTD:function(cur,shift,edit){var i,tds,tr,td,map,hasFixedCols=this.grid.hasFixedColumns(),tbody=cur.tbl.children("tbody")[0],rows=tbody?tbody.childNodes:0,rowsLen=rows?rows.length:0,row=cur.row;if(rowsLen<1||row<0||row>=rowsLen){return}tr=rows[row];if(!tr){return}tds=tr.childNodes;map=this._col(1);if(shift==="-tr1"||shift===-1&&cur.col===0&&cur.row===0){tr=row-1<0?rowsLen-1:row-1}else{tr=row+(shift||1);tr=tr>=rowsLen?0:tr}if(hasFixedCols&&cur.col>=0){i=cur.col;if(shift===1){i+=1}else if(shift===-1){i-=1}if(!tds[i]){i=-1}}else{i=this._idForCol(cur.col,shift)}if(shift&&shift!=="-tr1"){if(i>=0){cur.col=map[i];td=tds[i]}if(!td&&edit){if(hasFixedCols){td=this._nextTDFixing(cur,shift,row)}else if(tr>=0&&tr<rowsLen){if(shift>0){i=map[0]>=0?0:1}else{i=map.length;while(--i>=0){if(map[i]>=0){break}}}if(i>=0){cur.col=map[i];cur.row=tr;td=rows[cur.row].childNodes[i]}}}}else{if(tr<rowsLen){cur.row=tr;td=rows[cur.row].childNodes[i]}else{td=null}}cur.td=td?$(td):null;return td?cur:null},_nextEditor:function(key,shift){var e,col,ok=null,edits=this._editors,i,editors,cols,colsLength;if(this.grid.hasFixedColumns()){editors={};cols=this.grid.options.columns;colsLength=cols.length;for(i=0;i<colsLength;i++){col=cols[i].key;if(edits.hasOwnProperty(col)){editors[col]=edits[col]}}edits=this._editors=editors}for(col in edits){if(edits.hasOwnProperty(col)){if(shift&&key===col){return ok}if(col){e=edits[col];if(e&&e[0]&&e[0].offsetWidth>0){if(key===null){return e}ok=e}}if(key===col){key=null}}}},_nextEdit:function(e,shift,from){var cur,td=this._td(from);if(!td){return}cur=this._cur(td,true);cur.td=td;while(this._nextTD(cur,shift,1)){if(_aNull(this.editorForCell(cur.td))&&this.options.editMode!=="cell"){continue}if(this._startEdit(cur.td,e,this.options.editMode==="cell"?1:false)){return}}this._endEdit(e,1)},_createEditor:function(td,key,element){var v,oValid,elem,oEdit={},me=this,gridCol=me._gridCol(key)||{},format=gridCol.format,css=me.css.editor,xy=me._xy,col=me._colSet(td,key),provider=col?col.editorProvider:null,topBorder=me._tdBdrTop,retDone=$("#"+this.grid.container().attr("id")+"_igButton");if(col&&col.readOnly&&!element){return null}if(!xy&&!element){topBorder=me._tdBdrTop=_int(td,"borderTopWidth");v=$("<span />").addClass(css).prependTo(td);me._xy=xy={x:_int(v,"marginLeft"),y:_int(v,"marginTop")};xy.dx=xy.x+_int(v,"marginRight");xy.dy=xy.y+_int(v,"marginBottom");v.remove()}v=null;if(col){oEdit=col.editorOptions||oEdit;oValid=oEdit.validatorOptions;v=col.required;if(!oValid&&(col.validation||v)){oValid={}}if(v){oValid.required=oEdit.required=true}}if(me.options.validation&&!oValid){oValid={}}if(oValid){if(!me.grid.element.igValidator){_throw("igValidatorException")}if(col){col.editorOptions=oEdit}oEdit.validatorOptions=oValid;oValid.bodyAsParent=false;oValid.keepFocus=2;oValid.errorHidden=function(){me._error=null;if(me._butDone){me._butDone.removeClass(me.css.buttonDisabled)}if(retDone.length>0){retDone.igButton("option","disabled",false)}};oValid.errorShowing=function(){if(!_aNull(me._error)&&me._error!==key){return false}};oValid.errorShown=function(evt,ui){me._error=key;if(me._butDone){me._butDone.addClass(me.css.buttonDisabled)}ui=ui.owner._lbl;if(ui){ui.css("zIndex",99999)}me._scrollTo(key)}}if(!provider){if(gridCol.dataType==="bool"&&(format==="checkbox"||!format&&me.grid.options.renderCheckboxes)&&!element){provider=new $.ig.EditorProviderCheckbox}else if(col&&col.editorType==="combo"){provider=new $.ig.EditorProviderCombo}else if(col&&col.editorType==="rating"){provider=new $.ig.EditorProviderRating}else{provider=new $.ig.EditorProviderDefault}}me._hComboInit(oEdit);elem=provider.createEditor(me,key,col,me._ti,format,gridCol.dataType,me._val(td),element);if(!element){elem.addClass(css).css({marginLeft:xy.x-_int(td,"paddingLeft")+"px",marginTop:xy.y-topBorder-_int(td,"paddingTop")+"px"})}v=elem.igEditorFilter({provider:provider});return v},_notifyChanged:function(){var e=this._butDone;if(e){if(this.findInvalid()){e.addClass(this.css.buttonDisabled)}else{e.removeClass(this.css.buttonDisabled)}}e=$("#"+this.grid.container().attr("id")+"_igButton");if(e.length>0){if(this.findInvalid()){e.igButton("option","disabled",true)}else{e.igButton("option","disabled",false)}}this._modified=1},_notifyEditorKey:function(e,colKey){var but,old,val,next,cur,tar,key=e.keyCode||e.which||0,esc=key===27,o=this.options,shift;if(key!==9&&key!==13&&!esc){return}cur=this._editors[colKey];if(!cur||key===13&&(e.shiftKey||e.ctrlKey||this._13)){return}if(esc){old=cur._oldCellVal;val=_filter(cur,"getValue");if(!this._equals(old,val)){_filter(cur,"setValue",old);if(!this._equals(_filter(cur,"getValue"),val)){_filter(cur,"validate");_stop(e);return}}return this._endEdit(e,null,200)}if(key===13||!this._adding&&o.editMode==="cell"){tar=$(e.target);if(tar.length>0){tar.find("input").first().trigger("blur")}if(this.options.horizontalMoveOnEnter){shift=1}else{shift=key===9?e.shiftKey?-1:1:0}return this._nextEdit(e,shift)}next=this._nextEditor(colKey,e.shiftKey);if(!_filter(cur,"validate")){_stop(e);return}if((key===13||key===9)&&!next&&!this._adding){tar=$(e.target);if(tar.length>0){tar.find("input").first().trigger("blur")}}_stop(e);try{if(next&&this._adding&&!_aNull(this.grid._startColIndex)&&this.grid.table&&this.grid.table.rows[0]&&!this.grid.cellAt(this._col(next.parent()),0)){next=null}}catch(ex){next=null}if(next){this._scrollTo(next.parent(),next);return}but=this._butDone;if(!but||but[0].offsetWidth===0){return this._nextEdit(e,e.shiftKey?-1:0)}if(but.hasClass(this.css.buttonDisabled)){but=this._butCancel}but[0].focus();this._prevEdit=cur},_evtArg:function(td,editor,val){var arg={rowAdding:!!this._adding,columnIndex:this._col(td),rowID:this._row_,columnKey:this._key(td),editor:editor};arg.value=_aNull(val)?null:val;return arg},_checkHidden:function(vals){var col,key,colG,cols=this.grid.options.columns,i=cols.length;while(i-->0){colG=cols[i];if(colG&&colG.hidden){key=colG.key;col=this._colSet(null,key);col=col&&_aNull(vals[key])?col.defaultValue:null;if(col!==null){vals[key]=col}}}},_isToggle:function(e){e=e&&e.type&&e.type.indexOf("click")>=0?e.target:null;return e&&e.className&&e.className.indexOf("ui-icon-check")>=0},_lastTDWidth:function(td,width){var pad=_int(td,"paddingRight")>12,div=pad||!td.next()[0]?td.closest("div")[0]:null,v=div&&td[0].offsetLeft+td[0].offsetWidth>div.clientWidth+5?div.offsetWidth-div.clientWidth:0;if(v>10){div=pad?null:this._hscroll(1)[0];if(!div||div.offsetWidth<div.clientWidth+3){width-=Math.min(18,v)}}return width},_hComboInit:function(oEdit){var i,gCol,col,key,cols,combo,cell=this.options.editMode==="cell",hComboID=oEdit.parentCombo,combos=this._hCombos;if(!hComboID){return}cols=this.options.columnSettings;i=cols.length;combo=combos?combos[hComboID]:null;if(combo){oEdit._hComboID=hComboID;oEdit.parentCombo=combo.combo;i=0}while(i-->0){col=cols[i];key=col.columnKey;gCol=this._gridCol(key);combo=col.editorType==="combo"&&(cell||gCol&&gCol.hidden)?col.editorOptions:null;if(combo&&combo.id===hComboID){this._hCombos=combos=combos||{};oEdit._hComboID=hComboID;oEdit.parentCombo=combo=$('<span id="'+hComboID+'"></span>').igCombo(combo);combos[hComboID]={key:key,combo:combo};return}}},_hComboEdit:function(editor){var val,o,combo=this.findHiddenComboEditor(editor);if(!combo){return}o=combo.options;if(o.filteringType){combo.selectedIndex(-1);combo.activeIndex(-1);combo.dataBind()}val=this.grid.getCellValue(this._row_,combo._colKey);if(o.allowCustomValue){combo.text(val===null?o.nullText||"":val)}else{combo.value(val)}},_hComboRemove:function(destroy){var i,o,combo,combos=this._hCombos;if(!combos){return}for(i in combos){if(combos.hasOwnProperty(i)){combo=combos[i].combo;if(combo){combo.igCombo("destroy")}}}delete this._hCombos;combos=this.options.columnSettings;i=destroy?0:combos.length;while(i-->0){o=combos[i].editorOptions;combo=o?o._hComboID:null;if(combo){o.parentCombo=combo}}},_startEdit:function(td,e,foc,add,height,toggle){var i,tds,width,arg,editor,val,hasFixedCols=this.grid.hasFixedColumns(),funcIterator,grid=this.grid,prime=grid.options.primaryKey,me=this,fixedTDs=[],unfixedTDs=[],td0=td?td[0]:null,but=null,v=false,o=this.options;if(!td0){return}if(e){delete this._defValue;this._delHover();this._cShift=this._cShiftAdd=-1;this._map=undefined;if(this._tds){if(!add){if(hasFixedCols){i=td.index()}td=this._cur(td)}if(this._endEdit(e,1)){return 1}if(!add){if(i===undefined||!hasFixedCols){i=this._idForCol(td.col)}tds=td.row<0||td.col<0||i<0?null:td.tbl.children("tbody")[0];td=tds?tds.childNodes[td.row]:null;if(td){td=td.childNodes[i]}if(!td){return}td=$(td)}}if(!add&&!this._checkRow(td.parent())){return}this._row_=add?-1:this._prime(td);this._rowIndex=add?-1:this._row(td);if(!height){height=td[0].offsetHeight}if(add||o.editMode==="row"){arg={rowAdding:!!add,rowID:this._row_};if(!this._fire("editRowStarting",e,arg)){this._row_=null;this._rowIndex=-3;return}if(add){this._adding=add;if(this._tdAddPrime){i=this._gridCol(prime);val=this._defVal(prime,1);this._tdAddPrime.html(i?grid._renderCell(val,i):val)}this._addTR.hide();this._newTR.show();if(hasFixedCols){this.grid.fixedHeadersTable().find("thead tr[data-add-row]").hide();this.grid.fixedHeadersTable().find("thead tr[data-new-row]").show()}if(!this._addFixScroll){this._addFixScroll={scroll:function(){var cont=grid.scrollContainer()[0],left1=cont?cont.scrollLeft:-1,left2=this.scrollLeft;if(!_aNull(left2)&&left1>=0&&left1!==left2){cont.scrollLeft=left2}}}}this._addTR.closest("div").bind(this._addFixScroll)}tds=td.parent().children();this._evt=e;if(hasFixedCols){funcIterator=function(TDs){for(i=0;i<TDs.length;i++){td=$(TDs[i]);if(me._col(td)<0||TDs[i].offsetWidth<3||td.attr("data-skip")||td.is("th")){continue}td.addClass(me.css.editingCell);but=but||td;if(me._startEdit(td,null,e&&td[0]===td0,add,height,me._isToggle(e)&&td[0]===td0)){v=1;foc=null}}};if(this.grid._isFixedElement(td)){fixedTDs=tds;if(add){unfixedTDs=this.grid.headersTable().find("thead tr:nth-child("+(td.parent("tr").index()+1)+")").children()}else{unfixedTDs=this.grid.element.find("tbody tr:nth-child("+(td.parent("tr").index()+1)+")").children()}}else{unfixedTDs=tds;if(add){fixedTDs=this.grid.fixedHeadersTable().find("thead tr:nth-child("+(td.parent().index()+1)+")").children()}else{fixedTDs=$("#"+this.grid.id()+"_fixed").find("tbody tr:nth-child("+(td.parent().index()+1)+")").children()}}funcIterator(unfixedTDs);funcIterator(fixedTDs)}else{for(i=0;i<tds.length;i++){td=$(tds[i]);if(this._col(td)<0||tds[i].offsetWidth<3){continue}td.addClass(this.css.editingCell);but=but||td;if(this._startEdit(td,null,foc===1||e&&td[0]===td0,add,height,this._isToggle(e)&&td[0]===td0)){v=1;foc=null}}}delete this._evt;if(v&&but&&o.showDoneCancelButtons){this._doButtons(but)}if(this._butDelete){if(add){this._butDelete.addClass(this.css.buttonDisabled)}else{this._butDelete.removeClass(this.css.buttonDisabled)}}if(v){_stop(e);this._fire("editRowStarted",e,arg)}else{tds.removeClass(this.css.editingCell)}this._sel("act",but);if(add&&v){if(!this.grid._isFixedElement(td)){while(height-this._newTR[0].offsetHeight>0){if(v){v=null;td=$(tds[0]);add=_int(td,"paddingTop")+_int(td,"paddingBottom")+_int(td,"borderTopWidth")+_int(td,"borderBottomWidth")+1}if(--add<0){break}td.css("height",height-add)}}v=1}return v}toggle=toggle||this._isToggle(e)}editor=this.editorForCell(td,1);if(_aNull(this._row_)||!editor){return}width=td.outerWidth();if(!height){height=td[0].offsetHeight}arg=this._evtArg(td,editor,this._val(td,null,1));if(!width||!height){return}if(!this._fire("editCellStarting",e||this._evt,arg)){return"canceled"}this._hComboEdit(editor);width=this._lastTDWidth(td,width);width-=this._xy.dx+2;height-=this._xy.dy;if(e){_stop(e);td.addClass(this.css.editingCell)}editor.prependTo(td);_filter(editor,"setSize",Math.max(8,width),Math.max(10,height));if(!this._tds){this._tds={}}this._tds[this._key(td)]=td;v=_filter(editor,"validator");if(v&&v._setOption){v._setOption("bodyAsParent",grid.options.fixedHeaders!==false||!grid.options.height)}_filter(editor,"setValue",arg.value);editor._oldCellVal=_filter(editor,"getValue");this._fire("editCellStarted",e||this._evt,arg);if(foc){this._scrollTo(td,editor,false,300,toggle)}if(e){this._sel("act",td)}return 1},_endEdit:function(e,update,foc){var i,editor,val,key,td,arg,oldVals,stop,oldUpdate=update,eArg=e||"undefined",add=this._adding,tr=null,argR=null,vals=null,tds=this._tds,hasFixedCols=this.grid.hasFixedColumns(),o=this.options;if(!tds||this._skip){return}if(e&&e.type!=="mousedown"){stop=e;_stop(stop)}i=add||o.editMode==="row";if(!this._modified&&!add){update=false}if(i){for(key in tds){if(tds.hasOwnProperty(key)){td=tds[key];if(e&&!_aNull(td)){editor=this.editorForCell(td);if(oldUpdate&&!_aNull(editor)&&editor[0]&&editor[0].offsetWidth&&editor.igEditorFilter("hasInvalidMessage")){if(!stop){stop=e;_stop(stop)}this._scrollTo(td,editor,1);return 1}}}}vals=this._addReadOnly(add);oldVals={};for(key in tds){if(tds.hasOwnProperty(key)){td=tds[key];if(oldUpdate&&!_aNull(td)&&!_aNull(this.editorForCell(td))){editor=this.editorForCell(td);vals[key]=_filter(editor,"getValue");oldVals[key]=editor._oldCellVal;if(e&&editor[0]&&editor[0].offsetWidth&&!_filter(editor,"validate",!o)){if(!stop){stop=e;_stop(stop)}if(o){this._scrollTo(td,editor,1)}o=null}}}}if(e&&!o){return 1}if(add){this._checkHidden(vals)}this._skip=1;argR={oldValues:oldVals,values:vals,rowID:this._row_,keepEditing:false,update:!!update,rowAdding:!!add};if(!this._fire("editRowEnding",eArg,argR)){argR.update=update=oldUpdate=false}delete this._skip;if(e&&argR.keepEditing){return 1}}if(i){this._td().parent().children().removeClass(this.css.editingCell);if(hasFixedCols){$("#"+this.grid.id()+"_fixed").find("tbody tr:nth-child("+(this._td().parent().index()+1)+")").children().removeClass(this.css.editingCell)
}}tr=null;for(key in tds){if(tds.hasOwnProperty(key)){td=tds[key];if(!_aNull(td)&&!_aNull(this.editorForCell(td))){editor=this.editorForCell(td);if(!vals){if(e&&oldUpdate&&!_filter(editor,"validate")){if(!stop){stop=e;_stop(stop)}this._scrollTo(td,editor,1);return 1}td.removeClass(this.css.editingCell)}this._skip=1;this._doButtons(1);val=_filter(editor,"getValue");arg=this._evtArg(td,editor,val);arg.update=!!update;if(!this._adding){arg.update=arg.update&&!this._equals(this._getVal(this._row_,this._key(td)),val)}arg.oldValue=editor._oldCellVal;if(!vals){arg.keepEditing=false}if(!this._fire("editCellEnding",eArg,arg)){arg.value=editor._oldCellVal}if(oldUpdate&&!vals&&e&&arg.keepEditing){_stop(e);this._scrollTo(td,editor,1);delete this._skip;return 1}val=foc?editor.data("igEditor")||editor.data("igCombo")||editor.data("igRating"):null;if(val&&typeof val.hasFocus==="function"&&val.hasFocus()){try{editor.parent()[0].focus()}catch(ignore){}foc=null}editor.igEditorFilter("remove");val=arg.value;if(update&&vals){vals[key]=val}if(update&&this._val(td,arg,vals)!==undefined&&!tr&&!this._equals(val,editor._oldCellVal)){tr=td.parent()[0]}delete tds[key];this._fire("editCellEnded",eArg,arg);delete this._skip}}}this._skip=1;this._modified=this._prevEdit=this._tds=this._error=null;if(add){this._addTR.closest("div").unbind(this._addFixScroll);this._addTR.show();this._newTR.hide();if(hasFixedCols){this.grid.fixedHeadersTable().find("thead tr[data-add-row]").show();this.grid.fixedHeadersTable().find("thead tr[data-new-row]").hide()}this._adding=null;if(update&&this._fire("rowAdding",eArg,argR)){this._update(vals);this._sel("refresh");this._fire("rowAdded",eArg,argR)}}else if(tr){this._update(this._row_,tr,vals)}this._fire("editRowEnded",eArg,argR);this._rowIndex=-3;this._row_=null;this._sel("end",e);delete this._skip},_scrollDiv:function(){var me=this,div=me._scrl,tbl=me.grid.element;if(div&&me._sEvts){return div}me._scrl=div=tbl?tbl.parent():null;if(div&&!me._sEvts&&div.is("div")){me._scrollX=div.scrollLeft;me._sEvts={scroll:function(e){me._onEvt(e,9)}};div.bind(me._sEvts)}return div},_scrollTo:function(td,editor,checkError,delay,toggle){var cur,rect,div,x,y,lbl,xy,shift,add=this._adding,errorWidth=0,errorHeight=0,foc=editor;if(!editor&&typeof td==="string"){td=this._tds?this._tds[td]:null;if(!td){return}editor=this.editorForCell(td);if(!editor){return}checkError=1}if(foc){editor.igEditorFilter("setFocus",100,toggle);if(delay){editor.igEditorFilter("setFocus",delay)}}if(editor&&checkError){lbl=_filter(editor,"validator");lbl=lbl?lbl._lbl:null;if(lbl&&(add||td.has(lbl).length!==0)){errorWidth=lbl[0]._width0||80;errorHeight=lbl[0]._height0||18;cur=this._cur(td)}}div=this._scrollDiv();xy=td.offset();rect=div.offset();div=div[0];rect.w=div.clientWidth;rect.h=div.clientHeight;xy.w=td.outerWidth();xy.h=td.outerHeight();x=xy.left-rect.left;y=xy.top-rect.top;if(errorWidth>xy.w){delay=cur.col;shift=xy.w;errorWidth+=5;xy.w=errorWidth;while(shift<errorWidth&&this._nextTD(cur,1)){shift+=cur.td[0].offsetWidth}shift-=errorWidth;if(shift<0){xy.x+=shift;if(xy.x<0&&!add){shift-=xy.x;xy.x=0}if(this.grid._hasVerticalScrollbar){shift-=this.grid._scrollbarWidth()}lbl.css("marginLeft",shift+"px")}}if(!add&&errorHeight>1&&cur.row>1){cur.col=delay;errorHeight+=3;shift=errorHeight;while(shift>0&&this._nextTD(cur,0)){shift-=cur.td[0].offsetHeight}if(shift>0){lbl.css("marginTop","-"+errorHeight+"px");y-=errorHeight}}if(div.nodeName!=="DIV"){return}if(x>0){x=Math.max(x+xy.w-rect.w,0)}if(y>0){y=Math.max(y+errorHeight+xy.h-rect.h,0)}if(x!==0){this._hscroll()[0].scrollLeft+=x}if(!add&&y!==0){div.scrollTop+=y}},_upDown:function(td){td=td.parent();if(td.prev().length<1){return 1}if(td.next().length>0){return 0}td=this.grid.element;var par=td.parent()[0];return par&&par.clientHeight-td[0].offsetHeight>25?0:-1},_minWidth:function(td,div){var par=div[0];if(par.id.indexOf("_container")<0&&div.parents(".ui-iggrid").length>0){par=div.parent()[0]}div=Math.min(div[0].clientWidth||div[0].offsetWidth,par.clientWidth||par.offsetWidth);return td?Math.min(div,td.closest("table")[0].clientWidth):div},_doButtons:function(td){var xyTD,xyBut,htBut,htTD,txt,div,cont,scroll,down,x,oldOverflow=this._oldOverflow,add=this._adding,css=this.css,grid=this.grid.element,hasHeight=!_aNull(this.grid.options.height),buts=this._buts;if(td===1||td===2){if(oldOverflow){delete this._oldOverflow;oldOverflow.e.css("overflowX",oldOverflow.x).css("overflowY",oldOverflow.y)}if(buts){buts.hide();if(td===2){buts.remove();this._buts=null}}if(td===2&&this._delBut){this._delHover();this._delBut.remove();delete this._delBut}return}div=this._scrollDiv();if(td){cont=hasHeight?grid.parent():grid.closest(".ui-iggrid");x=cont[0]?Math.max(cont[0].scrollHeight,cont[0].offsetHeight):-1;if(x>=0&&x<20){this._oldOverflow={e:cont,x:cont.css("overflowX"),y:cont.css("overflowY")};cont.css("overflowX","visible").css("overflowY","visible")}if(!buts){buts=this._buts=$("<div />").css("position","absolute").addClass(css.buttonContainer).attr("unselectable","on");if(hasHeight){buts.prependTo(cont)}else{buts.appendTo(cont)}this._butDone=x=$("<span />").addClass("done_id").addClass(css.button).addClass(css.doneButton).attr("unselectable","on").attr("tabIndex",this._ti+1).attr("title",this._loc("done",1)).appendTo(buts).bind(this._evts);$("<span />").css("display","inline-block").addClass(css.doneIcon).attr("unselectable","on").appendTo(x);txt=this._loc("done");if(txt){$("<span />").css("display","inline-block").attr("unselectable","on").html(txt).appendTo(x)}else{x.addClass(css.buttonIconOnly)}this._butCancel=x=$("<span />").addClass(css.button).addClass(css.cancelButton).attr("unselectable","on").attr("tabIndex",this._ti+1).attr("title",this._loc("cancel",1)).appendTo(buts).bind(this._evts);$("<span />").css("display","inline-block").addClass(css.cancelIcon).attr("unselectable","on").appendTo(x);txt=this._loc("cancel");if(txt){$("<span />").css("display","inline-block").attr("unselectable","on").html(txt).appendTo(x)}else{x.addClass(css.buttonIconOnly)}if(this._renderTouchUI&&this.options.enableDeleteRow){this._butDelete=x=$("<span />").addClass(css.button).addClass(css.doneButton).attr({unselectable:"on",tabIndex:this._ti+1,title:this._loc("deleteRow",1)}).prependTo(buts);$("<span />").css("display","inline-block").addClass(css.deleteIcon).attr("unselectable","on").appendTo(x).css("left",0).bind(this._evts);txt=this._loc("deleteRow",true);$("<span />").css("display","inline-block").attr("unselectable","on").html(txt).appendTo(x);x.css("float","left");this._butCancel.css("float","right");this._butDone.css("float","right");buts.css("width",this._minWidth(td,div)-6)}buts._height=buts[0].offsetHeight;buts._width=buts[0].offsetWidth}this._tdelTR=td.parent()}if(!buts){return}if(td){x=Math.max(grid[0].offsetHeight,grid.parent()[0].offsetHeight);buts.show();if(add&&this.findInvalid()===null){this._butDone.removeClass(css.buttonDisabled)}else{this._butDone.addClass(css.buttonDisabled)}this._butsX=0;buts.css({marginLeft:this._butsX+"px",marginTop:"0px"});xyBut=buts.offset();htBut=buts[0].offsetHeight;xyTD=td.offset();htTD=td[0].offsetHeight;xyTD.top-=xyBut.top;scroll=div[0].scrollTop;down=add?1:this._upDown(td);if(!down){down=div[0].clientHeight+scroll-xyTD.top-htTD-5-htBut;if(down<1&&down>xyTD.top-htBut-scroll-5){down=1}}down=down>0?xyTD.top+htTD+5:xyTD.top-htBut-5;if(down+htBut>x){if(down+htBut<x+6){down=x-htBut-2}else{down-=10+htBut+htTD}down=Math.max(0,down)}buts.css({marginTop:down+"px"});this._butsY=add&&grid.has(this._addTR).length===1?down:0}x=this._minWidth(td,div)-(buts.offset().left+buts._width+3-div.offset().left);if(this._renderTouchUI&&this.options.enableDeleteRow){x+=1}if(x!==0){this._butsX+=x;buts.css("marginLeft",this._butsX+"px")}if(add&&this.grid.options.fixedHeaders!==false){buts.css("marginTop",this._butsY+div[0].scrollTop+2+"px")}},_isEditor:function(e){var end,el,editor,key,td,tds=this._tds,o=this.options;if(!tds||_aNull(e)){return}td=this._findCell(e);if(td&&o.editMode==="row"&&this._row(td)===this._rowIndex){return 1}end=this.grid.element[0];for(key in tds){if(tds.hasOwnProperty(key)){td=tds[key];if(td){editor=this.editorForCell(td);if(editor){el=e;editor=editor[0];while(el&&el!==end){if(el===editor){return 1}el=el.parentNode}}}}}},_aCell:function(){var td,i=-1,sel=this._sel("get");td=sel?sel.activeCell():null;if(td){return td.element}td=sel?sel.activeRow():null;if(td){td=td.element.children("td:not([data-parent='true'],[data-skip='true'])");while(++i<td.length){if(td[i].offsetWidth>0){return $(td[i])}}}},_sel:function(flag,td){var i,obj,elem,sel=this.grid.element.data("igGridSelection");if(!sel||flag==="get"){return sel}if(flag==="end"){delete sel._suspend;if(td&&td.type==="mousedown"){sel._mouseDown(td)}return}if(flag==="wait"){obj=sel.selectedRows();i=obj?obj.length:0;while(i-->0){elem=obj[i].element;if(elem&&elem.has(td).length){return}}obj=sel.selectedCells();i=obj?obj.length:0;while(i-->0){elem=obj[i].element;if(elem&&elem[0]===td[0]){return}}obj=sel.selectedRow();elem=obj?obj.element:null;if(elem&&elem.has(td).length){return}obj=sel.selectedCell();elem=obj?obj.element:null;if(elem&&elem[0]===td[0]){return}if(this.grid.hasFixedColumns()){obj=sel.selectedFixedRows();i=obj?obj.length:0;while(i-->0){elem=obj[i].element;if(elem&&elem.has(td).length){return}}obj=sel.selectedFixedCells();i=obj?obj.length:0;while(i-->0){elem=obj[i].element;if(elem&&elem[0]===td[0]){return}}obj=sel.selectedFixedRow();elem=obj?obj.element:null;if(elem&&elem.has(td).length){return}}return 1}if(flag==="refresh"){return sel._refresh()}if(flag==="act"&&sel.options.activation){sel._suspend=1;if(!td){return}if(sel.options.mode==="row"){sel._realActiveRow={element:td.parent(),index:this._row(td)+this.grid._startRowIndex||0,id:this._prime(td)};return sel._activateRow(sel._realActiveRow)}td=sel._cellFromElement(td[0],this._row(td),td.index());return sel._activateCell(td)}},_doDelete:function(e,tr){var i,sel,arg;if(!tr){sel=this._sel("get");arg=sel?sel.selectedRows():null;for(i=0;i<(arg?arg.length:0);i++){this._doDelete(e,arg[i].element)}arg=sel?sel.selectedRow():null;if(arg){this._doDelete(e,arg.element)}}arg={element:tr,rowID:this._prime($(tr.children()[0]))};if(!tr||!this._fire("rowDeleting",e,arg)){return}this._delHover();this._update(arg.rowID,tr[0]);if(e){this._sel("refresh")}this._fire("rowDeleted",e,arg);return 1},_checkRow:function(tr){var tbody;tr=tr&&tr.index()<this.grid.rows().length?tr[0]:null;if(tr&&tr.className.indexOf(this.grid.css.deletedRecord)<0&&!$(tr).attr("data-grouprow")&&$(tr).parent().is("tbody")){if(this.grid.hasFixedColumns()&&$(tr).closest("div").attr("data-fixed-container")){tbody=$("#"+this.grid.id()+"_fixed").find("tbody")}else{tbody=this.grid.element.find("tbody")}if($(tr).parent()[0]===tbody[0]){return tr}}return null},_delHover:function(src){var i,v,left,iBut,iTD,iDiv,iScroll,shift,xyBut,xyTD,div,tds,td,down,but=this._delBut,tr=this._delTR,hasFixedColumns=this.grid.hasFixedColumns(),css=this.css;if(but){this._doHov(this._isSrc(but,src)?but[0]:null,css.buttonHover)}if(src!==null&&src!==undefined&&hasFixedColumns){if(this.grid._isFixedElement($(src))){src=this.grid.element.find('tbody tr[data-id="'+$(src).closest("tr").attr("data-id")+'"]')}}src=src?this._checkRow($(src).closest("tr")):null;if(src===tr||!tr&&!src||!but&&!src){return}this._delTR=src;if(!but){this._delBut=but=$("<span />").css("position","absolute").addClass(css.deleteButton).attr("unselectable","on").attr("title",this._loc("deleteRow",1));$("<span />").css("display","inline-block").addClass(css.deleteIcon).attr("unselectable","on").appendTo(but);v=this._loc("deleteRow");if(v){$("<span />").css("display","inline-block").attr("unselectable","on").html(v).appendTo(but)}}if(tr){but.hide()}if(!src){return}i=this._colShift(null,src)-1;tds=src.childNodes;while(++i<tds.length){if(tds[i].offsetWidth>0){break}}src=tds[i];if(!src){return}td=$(src);div=this.grid.element.parent();if(hasFixedColumns&&this.grid.element.data("igGridColumnFixing").options.fixingDirection==="right"){div=this.grid.fixedBodyContainer();td=div.find("tbody tr").eq(td.closest("tr").index()).find("td:last")}v=but[0].parentNode;if(v!==div&&v!==div[0]){if(!v){but.bind(this._evts).mouseup(function(e){_stop(e)})}but.prependTo(div)}but.css({marginLeft:"0px",marginTop:"0px"}).show();xyBut=but.offset();xyTD=td.offset();iBut=but[0].offsetHeight;iTD=src.offsetHeight;shift=xyTD.top-xyBut.top;down=shift+Math.round((iTD-iBut)/2);iScroll=div[0].scrollLeft;iDiv=this._minWidth(td,div);iBut=but[0].offsetWidth;left=iDiv+iScroll-iBut-_int(td,"paddingLeft")-_int(td,"borderLeftWidth")-5;but.css({marginTop:down+"px",marginLeft:left+"px"});shift=iBut+but.offset().left-xyTD.left-iScroll-iDiv+5;if(shift>0){but.css("marginLeft",left-shift+"px")}},_isSrc:function(e,src){if(e&&src&&(e[0]===src||e[0]===src[0]||e.has(src).length>0)){return e}},_doHov:function(e,css){var hov=this._hov;if(hov&&css&&hov.e[0]===e){return 1}if(hov){hov.e.removeClass(hov.css)}if(css){e=$(e);this._hov={e:e,css:css};return e.addClass(css)}delete this._hov},_noMove:function(check){var x,y,div,id,noMove=this._nm;if(noMove===1||check&&!noMove){return}if(!noMove){id=this.grid.element[0].id;div=$("#"+id+"_scroll");if(div.length!==1){div=$("#"+id+"_displayContainer")}if(!div.length){this._nm=1;return}}noMove=this._nm=this._nm||{x:0,y:0,div:div[0]};noMove.ex=noMove.ex||$("#"+id+"_hscroller")[0]||$("#"+id+"_horizontalScrollContainer")[0]||noMove.div;x=noMove.ex.scrollLeft;noMove.ey=noMove.ey||$("#"+id+"_scrollContainer")[0]||noMove.div;y=noMove.ey.scrollTop;if(check){return Math.abs(noMove.x-x)>1||Math.abs(noMove.y-y)>1}noMove.x=x;noMove.y=y},_onEvt:function(e,type){var td,cancel,done,addTD,tbody,but,next,me=this,now=_now(),touch=me._hovTouch,src=e?e.target:null,k=e?e.keyCode:0,x=me._lastEvt,y,css=me.css,delBut=me._delBut,rdelBut=me._butDelete,newTR=me._newTR,addTR=me._addTR,tbl=me.grid.element,hasFixedCols=me.grid.hasFixedColumns(),o=me.options,editor,key,touchX,scrollLeft,scrollWidth;if(type===2&&me._skipMD&&now-me._skipMD<999){me._skipMD=now+200}if(hasFixedCols&&$(src).closest("div").attr("data-fixed-container")!==undefined){tbl=$(src).closest("table")}if(type===1&&me._skipMD&&me._skipMD-now>0||$.ig.util.evtButton(e)){return}if(o.excelNavigationMode===true&&this._isEditor(src)){td=this._findCell(src);if(td){editor=this.editorForCell(td);if(!editor){return}editor=editor.data("igEditor")||editor.data("igCombo")||editor.data("igEditorFilter");key=this._keyForEditor(editor.element);if($.ig.indexInArray([39,37],k)>=0){if(editor._old===null||editor._old===undefined||editor._old!==null&&editor._old!==undefined&&editor.value()!==null&&editor._old.toString()===editor.value().toString()){if(this.options.editMode==="row"){next=this._nextEditor(key,k===37?-1:0);if(next){this._scrollTo(next.parent(),next);return}but=this._butDone;if(!but||but[0].offsetWidth===0){this._nextEdit(e,k===37?-1:0);return}}else{if(k===37){this._nextEdit(e,-1)}if(k===39){this._nextEdit(e,1)}return}}}if(k===38){this._nextEdit(e,"-tr1",key);return}if(k===40){this._nextEdit(e,0,key);return}}}if(!tbl||!src||(type<4||k===13)&&(e.shiftKey||e.ctrlKey)||k===13&&me._13){return}if(k===8&&src.readOnly){_stop(e)}if(type!==9&&x&&x.src===src&&x.type===type&&x.x===e.pageX&&x.y===e.pageY&&now<x.now+500){return}me._lastEvt={src:src,now:now,type:type,x:e.pageX,y:e.pageY};if(type>=11&&type!==14){touchX=e.originalEvent.touches&&e.originalEvent.touches[0]?e.originalEvent.touches[0].pageX:e.originalEvent.clientX;switch(type){case 11:me._firstTouchX=touchX;me._lastTouchX=touchX;me._firstTouchRow=e.originalEvent.touches?$(e.originalEvent.touches[0].target).closest("tr"):$(e.originalEvent.target).closest("tr");break;case 12:if(Math.abs(me._lastTouchX-me._firstTouchX)>parseInt(me.options.swipeDistance,10)&&me._firstTouchRow){this._delHover();this._delHover(me._firstTouchRow)}delete me._firstTouchX;delete me._lastTouchX;delete me._firstTouchRow;break;case 13:scrollLeft=me.grid.scrollContainer().scrollLeft()||0;scrollWidth=me.grid.scrollContainer().width()||0;if(touchX>me._lastTouchX&&scrollLeft===0||touchX<me._lastTouchX&&scrollLeft>=me.grid._hscrollbarinner().width()-scrollWidth){e.preventDefault()}if(me._firstTouchRow){me._lastTouchX=touchX}break}return}if(type===8){if(touch){return}this._delHover();return this._doHov()}x=delBut?me._isSrc(delBut,src):null;y=rdelBut&&!rdelBut.hasClass(me.css.buttonDisabled)?me._isSrc(rdelBut,src):null;tbody=tbl.find("tbody");if(type===7){if(o.enableDeleteRow){if(x){delBut.addClass(me.css.buttonHover)}else{if(delBut){delBut.removeClass(me.css.buttonHover)}this._delHover(this._tds||!this._isSrc(tbody,src)||this._noMove(true)?null:src)}}return}if((x||y)&&(type<4||type===14)){if((type===2&&!($.ig.util.isIE&&$.ig.util.browserVersion>=10)||type===14)&&(this._delTR||this._tdelTR)){_stop(e);this._endEdit();if(this._doDelete(e,$(this._delTR||this._tdelTR))){delete this._delTR;delete this._tdelTR}}return}addTD=addTR?addTR.children()[addTR.children().length-1]:null;if(k===46){return o.enableDeleteRow?this._doDelete(e):null}if(type===9){if(this._nm&&!this._noMove(true)){return}this._delHover();x=src.scrollLeft;if(this._tds){this._doButtons()}if(addTR&&x!==this._scrollX){$(addTD).css("paddingLeft",this._addLeft+x+"px")}this._scrollX=x;return}if(this._isSrc(addTR,src)){if(!this._isSrc($(addTD),src)){return}this._delHover();src=addTD;if(type===5){return $(src).addClass(css.addRowActive)}if(type===6){return $(src).removeClass(css.addRowActive)}if(type===7){return this._doHov(src,css.addRowHover)}if(k===32||k===13){return this.startAddRowEdit(e)}}if(k===27){return this._endEdit(e,null,50)}done=this._isSrc(this._butDone,src);cancel=this._isSrc(this._butCancel,src);td=this._isSrc(this._buts,src);if(td||done||cancel){if(done||cancel){if(type<5){_stop(e)}src=done||cancel;if(type===2){if(src.hasClass(css.buttonDisabled)){return}this._endEdit(e,done,1)}else if(type===7&&!src.hasClass(css.buttonDisabled)){this._doHov(src[0],css.buttonHover)}else if(type===5){src.addClass(css.buttonActive)}else if(type===6){src.removeClass(css.buttonActive)}else if(k===13||k===32){this._endEdit(e,done,1)}else if(k===9){if(e.shiftKey){td=done||this._butDone.hasClass(css.buttonDisabled)?null:this._butDone}else{if(!td){return}td=this._butCancel}if(td){td[0].focus();return}src=this._lastEditor();td=src?src.parent():null;if(td){this._scrollTo(td,src)}}}return}if(newTR&&type<4){if(this._isSrc(newTR,src)){return}if(hasFixedCols&&this.grid._isFixedElement($(src))){addTR=this.grid.fixedHeadersTable().find("thead tr[data-add-row]")}if(this._isSrc(addTR,src)){if(type===2){if(o.editMode==="rowedittemplate"){this._startEditRowTemplate(e,null,td,1)}else{this.startAddRowEdit(e)}}return}}if(type<4&&!this._isSrc(tbody,src)){if(hasFixedCols&&this.grid._isFixedElement($(src))&&!$(src).is("th")&&!$(src).parent().is("th")&&$(src).closest("div").attr("data-fixed-container")===tbody.closest("div").attr("data-fixed-container")){return}if(this._tds&&src!==tbl.parent()[0]&&src!==this._div()[0]&&src!==this._hscroll(1)[0]){this._endEdit(e)}return}if(k===13){this._nextEdit(e,0);if(this._tds){return}}if(this._isEditor(src)||this._isEditor($(src).find("input")[0])){return}td=this._findCell(src);if(this._tds&&type<4&&(type>1||td)){if(this._endEdit(e,this._adding?null:1)){return}}if(type===1){if(td&&this._sel("get")){this._waitSel=this._sel("wait",td)}return}x=o.editMode==="cell";src=o.startEditTriggers;if(src&&!this._tds&&(x||o.editMode==="row"||o.editMode==="rowedittemplate")){if(!src.toLowerCase){src=src.toString()}src=src.toLowerCase();if(k===113&&src.indexOf("f2")>=0||k===13&&src.indexOf("enter")>=0){td=this._aCell()}else if(src.indexOf(e.type)<0||type===2&&src.indexOf("dbl")>=0){td=null}if(touch&&type<3&&touch!==me._delTR){return}if(td&&(this._isToggle(e)||(!this._waitSel||type===4)&&!this._sel("wait",td))){if(o.editMode==="rowedittemplate"&&td.parent().attr("data-grouprow")!=="true"){this._startEditRowTemplate(e,null,td);return}if(this._startEdit(td,e,x)){return}}}},_startEditRowTemplate:function(e,tr,td,addNewRow){var dialog=$("#"+this.grid.container().attr("id")+"_ret"),arg;tr=!_aNull(td)&&td.parent().length>0?td.parent():tr;arg={rowAdding:addNewRow?true:false,rowID:addNewRow?-1:this._prime(td||tr.children().first())};if(!this._fire("editRowStarting",e,arg)){return}if(this._checkRow(tr)||addNewRow){if(dialog[0]===undefined){this._renderRowEditDialog(e,tr)}if(this._openRowEditDialog(e,tr)){this._fire("editRowStarted",e,arg);return 1}}return 0},_calcRowDialogLeftTop:function(dialog){var left,top,pos,h,w,bh,dh,dw,bw,block=$("#"+this.grid.container().attr("id")+"_block_ret"),rootWidget,rootContainer,hScrollbar,cc,bc,tc;if(this.element.closest(".ui-iggrid-root").data("igHierarchicalGrid")){rootWidget=this.element.closest(".ui-iggrid-root").data("igHierarchicalGrid").rootWidget()}else{rootWidget=this.grid}rootContainer=rootWidget.container();hScrollbar=rootWidget.container().children("[id$='_hscroller_container']");pos=rootContainer.offset();left=pos.left;top=pos.top;if(block.outerWidth()!==rootContainer.outerWidth()||$.ig.util.isIE7===true){block.css("width",rootContainer.outerWidth())}if(block.outerHeight()!==rootContainer.outerHeight()||$.ig.util.isIE7===true){block.css("height",rootContainer.outerHeight()+($.ig.util.isIE7?hScrollbar.height():0))}$("#"+this.grid.container().attr("id")+"_dialog_error").hide();block.css({left:0,top:0}).fadeToggle();w=rootContainer.outerWidth();h=rootContainer.outerHeight();bw=$(window).width();bh=$(window).height();if(w+left>bw){w=w-(w+left-bw)}if(w<=0){w=rootContainer.outerWidth()}if(h+top>bh){h=h-(h+top-bh)}if(h<=0){h=rootContainer.outerHeight()}dh=parseInt(this.options.rowEditDialogHeight,10);dw=parseInt(this.options.rowEditDialogWidth,10);if(isNaN(dh)||dh<=0){dh=dialog.outerHeight()}if(isNaN(dw)||dw<=0){dw=dialog.outerWidth()}top=parseInt(h/2,10)-dh/2;left=parseInt(w/2,10)-dw/2;cc=dialog.children(".ui-dialog-content");tc=dialog.children(".ui-dialog-titlebar");bc=dialog.children(".ui-dialog-buttonpane");dialog.css({left:left,top:top,width:dw,height:dh});dialog.fadeToggle($.proxy(this._setResizableEnv,this));cc.css("height",dialog.height()-tc.outerHeight(true)-bc.outerHeight(true)-cc.outerHeight()+cc.height())},_getColumnSettingsByKey:function(colKey){var i;for(i=0;i<this.options.columnSettings.length;++i){if(this.options.columnSettings[i].columnKey===colKey){return this.options.columnSettings[i]}}return null},_doType:function(type,val){if(type==="text"){type=0}if(type==="mask"){type=1}if(type==="date"){type=2}if(type==="datepicker"){type=3}if(type==="numeric"){type=4}if(type==="currency"){type=5}if(type==="percent"){type=6}if(typeof type!=="number"||type<0||type>6){if(typeof val==="number"){type=4}else if(val&&val.getMonth){type=2}else{type=0}}this._type=type;return type},_fillRowEditDialogTable:function(event_tr){var tableBody,cols=this.grid.options.columns,i,tr,input,colVal,colSettings,newColSettings,colKey,templateData,rowEditDialogRowTemplate=this.options.rowEditDialogRowTemplate,rowEditDialogRowTemplateID=this.options.rowEditDialogRowTemplateID,buttonId="#"+this.grid.container().attr("id")+"_igButton",parent;tableBody=$("#"+this.grid.container().attr("id")+"_ret table tbody");tableBody.empty();this._editors=this._editors||{};if(!event_tr){this._adding=true}for(i=0;i<cols.length;++i){templateData=[];colKey=cols[i].key;colSettings=this._getColumnSettingsByKey(colKey);shouldAdd=colSettings===null?true:false;colSettings=colSettings||{};if(event_tr){colVal=this._getVal(this._fixPrime(event_tr.attr("data-id")),colKey)}else{colVal=this._defVal(colKey,true)}if(colSettings&&colSettings.readOnly&&!this.options.showReadonlyEditors||cols[i].hidden){continue}templateData.push({headerText:cols[i].headerText,dataKey:colKey});if(rowEditDialogRowTemplateID){tr=this._jsr?$($("#"+rowEditDialogRowTemplateID).render(templateData)):$($.ig.tmpl($("#"+rowEditDialogRowTemplateID).html().fullTrim(),templateData))}else if(rowEditDialogRowTemplate){tr=this._jsr?$($.render[this.grid.id()+"_rowEditDialogRowTemplate"](templateData)):$($.ig.tmpl(this.options.rowEditDialogRowTemplate,templateData))}else{tr=$("<tr><td>"+cols[i].headerText+"</td><td data-key='"+colKey+"'><input /></td></tr>")}tr.appendTo(tableBody);input=$(tr.find(">td[data-key] input")[0]);if(!input.length){input=$(tr.find(">td[data-key] textarea")[0])}if(cols[i].dataType==="bool"){$.extend(true,colSettings,{editorOptions:{listItems:[true,false],button:"dropdown"}})}if(colSettings.readOnly){$.extend(true,colSettings,{editorOptions:{readOnly:true}})}if(colSettings.editorOptions){colSettings.editorOptions.width=_aNull(colSettings.editorOptions.width)?this.options.rowEditDialogFieldWidth:colSettings.editorOptions.width}else{colSettings.editorOptions={width:this.options.rowEditDialogFieldWidth}}if(shouldAdd){this.options.columnSettings.push($.extend(true,{},colSettings,{columnKey:colKey}))}this._createEditor(event_tr?event_tr.children().eq(i):this._newTR.children().eq(i),colKey,input);this._editors[colKey]=input;_filter(input,"setValue",colVal)}$(buttonId).igButton("option","disabled",true)},_openRowEditDialog:function(event,tr){var dialog=$("#"+this.grid.container().attr("id")+"_ret"),noCancel,$this=this;noCancel=this._fire("rowEditDialogOpening",event,{dialogElement:dialog,owner:this});if(noCancel){dialog.data("tr",tr);this._fillRowEditDialogTable(tr);this._calcRowDialogLeftTop(dialog);setTimeout(function(){if(dialog.find("input")[0]){dialog.find("input")[0].focus()}dialog.focus();$this._fire("rowEditDialogOpened",event,{dialogElement:dialog,owner:$this})},100);if(event!==null&&event!==undefined){event.preventDefault();event.stopPropagation()}return 1}return 0},_renderRowEditDialog:function(e,tr){var dialog,caption,dialogContent,noCancel,limit,f=this,okCancelContainer;dialog=$("<div></div>").appendTo(this.grid._rootContainer()).attr("id",this.grid.container().attr("id")+"_ret").css("position","absolute").addClass(this.css.rowEditDialog).data("efh","1").hide();dialog.data("tr",tr);noCancel=this._fire("rowEditDialogContentsRendering",e,{dialogElement:dialog,owner:f});if(noCancel){$("<div></div>").appendTo(this.grid._rootContainer()).attr("id",this.grid.container().attr("id")+"_block_ret").css("position","absolute").addClass(this.css.blockArea).data("efh","1").hide();caption=$("<div></div>").appendTo(dialog).addClass(this.css.rowEditDialogHeaderCaption);$("<span></span>").appendTo(caption).text(this._loc("rowEditDialogCaption")).addClass(this.css.rowEditDialogHeaderCaptionTitle);$("<span></span>").appendTo($("<a></a>").appendTo(caption).attr("href","#").attr("role","button").addClass("ui-dialog-titlebar-close ui-corner-all")).bind({click:$.proxy(this._closeRowEditDialog,this)}).addClass("ui-icon ui-icon-closethick");dialogContent=$("<div></div>").appendTo(dialog).addClass("ui-dialog-content").css("overflow","auto").css("height",this.options.rowEditDialogContentHeight);$("<table><tbody></tbody></table>").appendTo(dialogContent).addClass(this.css.rowEditDialogTable);okCancelContainer=$("<div></div>").appendTo($("<div></div>").appendTo(dialog).addClass(this.css.rowEditDialogOkCancelButton)).addClass("ui-dialog-buttonset");$("<button/>").appendTo(okCancelContainer).igButton({labelText:this._loc("cancel"),width:this.options.rowEditDialogOkCancelButtonWidth}).bind({mousedown:$.proxy(this._closeRowEditDialog,this)});$("<button/>").appendTo(okCancelContainer).igButton({labelText:this._loc("done"),disabled:true,width:this.options.rowEditDialogOkCancelButtonWidth}).bind({click:$.proxy(this._rowEditDialogDoUpdate,this)}).attr("id",this.grid.container().attr("id")+"_igButton");if(this._hc===true){limit=$("#"+this.grid.element[0].id.split("_")[0]+"_container")}else if(this.options.rowEditDialogContainment==="owner"){limit=this.grid.container()}else{limit="window"}dialog.bind({keydown:function(e){if(e.keyCode===$.ui.keyCode.ESCAPE){f._closeRowEditDialog(e)}}}).draggable({containment:limit,handle:caption}).attr("role","dialog").attr("tabIndex",-1);if(typeof Modernizr!=="object"||Modernizr.touch===false){dialog.resizable({minHeight:dialog.outerHeight()/4,minWidth:dialog.outerWidth()/2,containment:"parent",resize:$.proxy(this._resizeHandler,this)})}this._fire("rowEditDialogContentsRendered",e,{dialogElement:dialog,owner:this})}},_setResizableEnv:function(){var e=$("#"+this.grid.container().attr("id")+"_ret"),rCont=e.find(">.ui-dialog-content"),hCont=e.find(">.ui-dialog-titlebar"),bCont=e.find(">.ui-dialog-buttonpane"),pad=rCont.outerHeight()-rCont.height();this._resizeCont=rCont;this._heightDifference=hCont.outerHeight(true)+bCont.outerHeight(true)+pad},_resizeHandler:function(event,ui){var u=ui.originalElement;this._resizeCont.css({height:u.height()-this._heightDifference+"px"})},_rowEditDialogDoUpdate:function(e){var ret=$("#"+this.grid.container().attr("id")+"_ret"),tds=ret.find("table tbody [data-key]"),tr=ret.data("tr"),i,vals={},oldvals={},colKey,arg,rowID,addRow;if(this.findInvalid()){return 0}for(i=0;i<tds.length;++i){colKey=tds.eq(i).attr("data-key");vals[colKey]=_filter(this._editors[colKey],"getValue");oldvals[colKey]=this._editors[colKey]._oldCellVal}addRow=!(tr!==null&&tr!==undefined&&tr.length>0);rowID=addRow?-1:this._prime(tr.children().first());arg={oldValues:oldvals,values:vals,rowID:rowID,keepEditing:false,update:true,rowAdding:addRow};if(!this._fire("editRowEnding",e,arg)){return 0}if(!addRow){this._update(tr.data().id,tr[0],vals)}else{if(this._fire("rowAdding",e,arg)){this._update(vals);this._fire("rowAdded",e,arg)}}this._fire("editRowEnded",e,arg);this._closeRowEditDialog(e);return 1},_closeRowEditDialog:function(e){var noCancel=true,dialog=$("#"+this.grid.container().attr("id")+"_ret");noCancel=this._fire("rowEditDialogClosing",e,{dialogElement:dialog,owner:this});if(noCancel){$("#"+this.grid.container().attr("id")+"_block_ret").fadeToggle();$("#"+this.grid.container().attr("id")+"_ret").data("tr",null).fadeToggle();delete this._defValue;if(e){e.preventDefault();e.stopPropagation()}delete this._editors;this._fire("rowEditDialogClosed",e,{dialogElement:dialog,owner:this});return 1}return 0},_lastEditor:function(){var key,last=this._prevEdit,all=this._editors;if(!last){for(key in all){if(all.hasOwnProperty(key)){last=all[key]||last}}}return last},_end:function(){this._delHover();this._endEdit()},destroy:function(){var div=this._div(),grid=this.grid,el=grid.element;if(!this._evts||!el||!div){return this}this._hComboRemove(true);this._doButtons(2);div.unbind(this._evts);if(this._renderTouchUI&&this.options.editMode!=="row"){div.unbind(this._tEvts)}if(this._sEvts){el.parent().unbind(this._sEvts)}el.unbind(this._gEvts);this._end();if(grid.hasFixedColumns()&&this._evts){grid.fixedContainer().unbind(this._evts)}this._headerRendered(1);this._evts=this._sEvts=this._gEvts=null;$.Widget.prototype.destroy.call(this);if(this.options.editMode==="rowedittemplate"){$("#"+this.grid.container().attr("id")+"_block_ret").remove();$("#"+this.grid.container().attr("id")+"_ret").remove()}return this},_hidingFinished:function(){this._headerRendered()},_hidingFinishing:function(){var key,shift,tr=this._addTR,grid=this.grid,edits=this._editors;if(!grid._initialized){return}this._endEdit();this._doButtons(2);if(this._groupTD1){this._groupTD1.remove();this._groupTD2.remove();delete this._groupTD1;delete this._groupTD2;this._cShift=this._cShiftAdd=-1}if(tr){shift=this._colShift(null,tr[0]);this._addTrShift=[];this._newTrShift=[];while(shift-->0){this._addTrShift[shift]=tr.children()[shift];this._newTrShift[shift]=this._newTR.children()[shift]}tr.remove();this._newTR.remove();if(this.grid.hasFixedColumns()){this.grid.fixedHeadersTable().find("thead tr[data-new-row], thead tr[data-add-row]").remove()}}for(key in edits){if(edits.hasOwnProperty(key)&&edits[key]){edits[key].remove()}}this._newTR=this._addTR=this._editors=this._mapAdd=this._map=null;this._cShiftAdd=this._cShift=-1;this._hComboRemove()},_rerender:function(args){var iTD,val,ta,row,cell,col,td,tds,key,grid=this.grid,tx=grid.pendingTransactions(),i=tx?tx.length:0,tbody=grid.element.children("tbody"),tmpl=grid.options.jQueryTemplating;
if(args&&args.owner&&args.owner.id()!==grid.id()){return}while(i-->0){ta=tx[i];cell=ta.type==="cell";row=tbody.find('[data-id="'+ta.rowId+'"]');if(ta.type==="row"||ta.type==="newrow"||cell){row.addClass(grid.css.modifiedRecord);tds=row.length&&!tmpl?row.children("td"):null;iTD=tds?tds.length:0;while(iTD-->0){td=$(tds[iTD]);key=this._key(td);val=undefined;if(ta.row){val=ta.row[key]}else if(cell&&key===ta.col){val=ta.value}if(val!==undefined){col=_aNull(key)?null:this._gridCol(key);val=col?grid._renderCell(val,col):$.ig.formatter(val);td.html(val)}}}if(ta.type==="deleterow"||ta.type==="insertrow"){row.addClass(grid.css.deletedRecord);$("#"+this.grid.id()+"_fixed").find('[data-id="'+ta.rowId+'"]').addClass(grid.css.deletedRecord)}}},_bind:function(args){var t1,t2,grid=this.grid,data=grid.dataSource._data,i=data?data.length:0,txNew=this.grid.dataSource.pendingTransactions(),len=txNew?txNew.length:0,txLast=this._txLast,lenLast=txLast?txLast.length:0;this._addRowNum=Math.max(this._addRowNum||1,i+1);this._endEdit();if(!args){if(i&&_aNull(grid.options.primaryKey)&&_aNull(data[0].ig_pk)){while(i-->0){data[i].ig_pk=i}}}else if(args.owner&&args.owner.id()!==this.grid.id()){return}if(len<1){return}if(len===lenLast){while(lenLast-->0){t1=txNew[lenLast];t2=txLast[lenLast];if(t1.tid!==t2.tid||t1.value!==t2.value||t1.row!==t2.row){break}}if(lenLast<0){return}}txLast=this._txLast=[];while(len-->0){txLast[len]={tid:txNew[len].tid,value:txNew[len].value,row:txNew[len].row}}if(this._fire("dataDirty",this._evt||{},{})&&this.options.enableDataDirtyException){_throw("dataDirtyException")}},_fixPrime:function(key,ds){var grid=this.grid,o=grid.options,prime=o.primaryKey,primeType,col=_aNull(prime)?null:this._gridCol(prime),data=grid.dataSource._data;if(ds){if(!col){key.ig_pk=ds=data.length;return ds}ds=key[prime];if(_aNull(ds)){ds=key[prime]=this._defVal(prime,1)}key=ds}primeType=data&&data.length>0&&!_aNull(data[0][prime])?typeof data[0][prime]:null;key=col&&(col.dataType==="number"||col.dataType==="numeric"||primeType==="number")?parseInt(key,10):key;if(!col&&(!data[key]||data[key].ig_pk!==key)){_throw("noPrimaryKeyException")}return key},_getRecord:function(id){var i=-1,data=this.grid.dataSource._data,len=data.length,prime=this.grid.options.primaryKey;id=this._fixPrime(id);if(_aNull(prime)){prime="ig_pk"}while(++i<len){if(data[i][prime]===id){return data[i]}}},_getVal:function(rowId,key){var val,ta,grid=this.grid,tx=grid.dataSource.pendingTransactions(),i=tx?tx.length:0;while(i-->0&&val===undefined){ta=tx[i];if(ta.rowId===rowId){if(ta.row){val=ta.row[key]}else if(ta.type==="cell"&&ta.col===key){val=ta.value}}}if(val===undefined){rowId=this._getRecord(rowId);val=rowId?rowId[key]:null}return grid._fixDate(val,this._gridCol(key))},_childrenWithAddRowEnabled:function(opts,inheritedRule){var i,j,cl,clr;if(opts.columnLayouts){for(i=0;i<opts.columnLayouts.length;i++){cl=opts.columnLayouts[i];clr=inheritedRule||false;if(cl.features&&cl.features.length>0){for(j=0;j<cl.features.length;j++){if(cl.features[j].name==="Updating"){clr=_aNull(cl.features[j].enableAddRow)?clr:cl.features[j].enableAddRow;break}}}if(clr){return true}}}return false},_update:function(rowId,tr,val,col,td){var tx,i,vDiv,vScroll,del=val===undefined,grid=this.grid,oGrid=grid.options,autoCommit=oGrid.autoCommit,ds=grid.dataSource,hasFixedCols=this.grid.hasFixedColumns(),key=this._fixPrime(rowId,tr?null:ds),virt=grid._virtualDom,cols,gridCol,nr,updateObj={},recObj,groupedGrid,layoutKeys=[],tdContent;if(col&&td){updateObj[col]=val;recObj=jQuery.extend(true,{},updateObj)}else{updateObj=jQuery.extend(true,{},val);recObj=this.grid.findRecordByKey(rowId);if(recObj){if(grid.options.columnLayouts&&grid.options.columnLayouts.length){for(i=0;i<grid.options.columnLayouts.length;++i){layoutKeys.push(grid.options.columnLayouts[i].key)}}$.each(recObj,function(prop,propVal){if(updateObj&&!updateObj.hasOwnProperty(prop)&&$.ig.indexInArray(layoutKeys,prop)===-1){updateObj[prop]=propVal}})}}if(del){this._isRowDeleted=true}i=tr?del?ds.deleteRow(rowId,autoCommit):col?ds.setCellValue(key,col,val,autoCommit):ds.updateRow(key,updateObj,autoCommit):ds.addRow(key,rowId,autoCommit);tx=ds.pendingTransactions();i=tx?tx.length:0;while(i-->0){if(rowId===tx[i].rowId){if(tx[i].row&&col){tx[i].row[col]=val}break}}if(!del&&(virt||autoCommit&&(rowId===null||rowId===undefined||recObj===null||recObj[grid.options.primaryKey]===null))){vDiv=$("#"+grid.id()+(virt?"_scrollContainer":"_scroll"))[0];vScroll=vDiv?vDiv.scrollTop:0;if(virt&&oGrid.virtualizationMode==="continuous"){grid._rerenderVirtualRecordsContinuous()}if(virt&&oGrid.virtualizationMode==="fixed"){grid._renderVirtualRecords()}if(vScroll){vDiv.scrollTop=vScroll}if(virt){grid._onVirtualVerticalScroll()}return}if(autoCommit&&grid.options.primaryKey&&recObj&&recObj[grid.options.primaryKey]){if(hasFixedCols){if(grid._isFixedElement($(tr))){this.grid.element.find('tbody tr[data-id="'+tr.getAttribute("data-id")+'"]').data("id",recObj[grid.options.primaryKey]).attr("data-id",recObj[grid.options.primaryKey])}else{$("#"+grid.id()+"_fixed").find('[data-id="'+tr.getAttribute("data-id")+'"]').data("id",recObj[grid.options.primaryKey]).attr("data-id",recObj[grid.options.primaryKey])}}$(tr).data("id",recObj[grid.options.primaryKey]);$(tr).attr("data-id",recObj[grid.options.primaryKey])}if(!tr){groupedGrid=grid.element.children("tbody").children("tr.ui-iggrid-groupedrow").length>0;tr=groupedGrid===true?grid.element.data("igGridGroupBy")._renderNewRow(rowId,key):grid.renderNewRow(rowId,key);tr=grid.element.children("tbody").children("tr");tr=tr[tr.length-1];this._addRowNum++;delete this._defValue;this._trigger("internalrowadded")}else{if(del){if(autoCommit){if(oGrid.virtualization||oGrid.rowVirtualization){if(oGrid.virtualizationMode==="continuous"){grid._rerenderVirtualRecordsContinuous()}else{if(this.grid._startRowIndex+this.grid._virtualRowCount===this.grid._totalRowCount){this.grid._startRowIndex--}this.grid._totalRowCount--;grid._renderVirtualRecords()}tr=null}else{nr=$(tr).next("tr[data-container='true']");$(tr).remove();if(nr.length===1){nr.remove()}if(hasFixedCols){$("#"+this.grid.id()+"_fixed").find('[data-id="'+$(tr).attr("data-id")+'"]').remove();this.grid.element.data("igGridColumnFixing")._syncContainerHeights()}}this._trigger("internalrowdeleted")}else if(hasFixedCols){$("#"+this.grid.id()+"_fixed").find('[data-id="'+$(tr).attr("data-id")+'"]').addClass(grid.css.deletedRecord)}return $(tr).addClass(grid.css.deletedRecord)}cols=oGrid.columns;val={};i=cols.length;while(i-->0){key=cols[i].key;val[key]=this._getVal(rowId,key)}val=tr!==1?grid._renderRow(col&&td?val:updateObj,tr,rowId):null;if(!_aNull(val)){tr=val}}if(tr&&tr!==1&&!autoCommit){if(hasFixedCols){if(grid._isFixedElement($(tr))){this.grid.element.find('tbody tr[data-id="'+tr.getAttribute("data-id")+'"]').addClass(grid.css.modifiedRecord)}else{$("#"+this.grid.id()+"_fixed").find('[data-id="'+tr.getAttribute("data-id")+'"]').addClass(grid.css.modifiedRecord)}}$(tr).addClass(grid.css.modifiedRecord)}},_columnFixed:function(args){this._cfUpdateDataSkipRows(args);if(args.isFixed){if(args.isInit){this.grid.fixedContainer().bind(this._evts);if(this.options.enableAddRow){this._newTR=this.grid.headersTable().find("thead tr[data-new-row]")}if(this._isRowDeleted){this.grid.element.data("igGridColumnFixing")._syncRowStyles()}}}this._mapAdd=null},_cfUpdateDataSkipRows:function(args){if(args.visibleIndex===-1){return}var $td,colspan,visibleIndex=args.visibleIndex,isDataSkip=args.colInd===-1,$unfixedTR=this.grid.headersTable().find("thead tr[data-new-row]"),$fixedTR=this.grid.fixedHeadersTable().find("thead tr[data-new-row]");if(args.isFixed){if(isDataSkip){$unfixedTR.find("[data-skip]:nth-child(1)").detach().appendTo($fixedTR);$unfixedTR=this.grid.headersTable().find("thead tr[data-add-row]");$fixedTR=this.grid.fixedHeadersTable().find("thead tr[data-add-row]");$unfixedTR.find("[data-skip]:nth-child(1)").detach().appendTo($fixedTR)}else{$td=$unfixedTR.find("td:nth-child("+visibleIndex+")");$td.detach().appendTo($fixedTR);$unfixedTR=this.grid.headersTable().find("thead tr[data-add-row]");$fixedTR=this.grid.fixedHeadersTable().find("thead tr[data-add-row]");$td=$unfixedTR.find("td[colspan]").eq(0);colspan=parseInt($td.attr("colspan"),10);$td.attr("colspan",colspan-1);if($fixedTR.find("td[colspan]").length===0){$td.clone().appendTo($fixedTR).attr("colspan",1)}else{$td=$fixedTR.find("td[colspan]");colspan=parseInt($td.attr("colspan"),10);$td.attr("colspan",colspan+1)}}}else{if(isDataSkip){$fixedTR.find("[data-skip]:last-child").detach().prependTo($unfixedTR);$unfixedTR=this.grid.headersTable().find("thead tr[data-add-row]");$fixedTR=this.grid.fixedHeadersTable().find("thead tr[data-add-row]");$fixedTR.find("[data-skip]:last-child").detach().prependTo($unfixedTR)}else{$td=$fixedTR.find("td:nth-child("+visibleIndex+")");$td.detach().prependTo($unfixedTR);$unfixedTR=this.grid.headersTable().find("thead tr[data-add-row]");$fixedTR=this.grid.fixedHeadersTable().find("thead tr[data-add-row]");$td=$fixedTR.find("td[colspan]").eq(0);colspan=parseInt($td.attr("colspan"),10);if(colspan-1===0){$td.remove()}else{$td.attr("colspan",colspan-1)}$td=$unfixedTR.find("td[colspan]");colspan=parseInt($td.attr("colspan"),10);$td.attr("colspan",colspan+1)}}},_addDSSuccessHandler:function(){var me=this,fS,grid=me.grid;if(me._addChangesSuccessHandler!==null&&me._addChangesSuccessHandler!==undefined){grid.dataSource._removeChangesSuccessHandler(me._addChangesSuccessHandler)}fS=me.options.saveChangesSuccessHandler;if(fS){if($.type(fS)==="string"&&window[fS]&&$.type(window[fS])==="function"){fS=window[fS]}}if($.type(fS)!=="function"){fS=null}me._addChangesSuccessHandler=function(data){if(data.Success){if(grid.rows().parent().find("."+grid.css.deletedRecord).length){grid._renderData()}grid.rows().removeClass(grid.css.modifiedRecord);if(fS){fS(data)}}};grid.dataSource._addChangesSuccessHandler(me._addChangesSuccessHandler)},_addDSErrorHandler:function(){var me=this,fE,grid=me.grid;if(me._addChangesErrorHandler!==null&&me._addChangesErrorHandler!==undefined){grid.dataSource._removeChangesErrorHandler(me._addChangesErrorHandler)}if(me.options.saveChangesErrorHandler){fE=me.options.saveChangesErrorHandler;if($.type(fE)==="string"&&window[fE]&&$.type(window[fE])==="function"){fE=window[fE]}if($.type(fE)==="function"){me._addChangesErrorHandler=function(jqXHR,textStatus,errorThrown){fE(jqXHR,textStatus,errorThrown)};grid.dataSource._addChangesErrorHandler(me._addChangesErrorHandler)}}},_injectGrid:function(grid){var me=this,hg,cl,opts=me.options;me.grid=grid;me._cShiftAdd=me._cShift=-1;if(me._gEvts!==undefined&&me._gEvts!==null){grid.element.unbind(this._gEvts)}me._gEvts={iggridvirtualrendering:function(){me._end()},ighierarchicalgridrowexpanded:function(){me._end()},iggriddatabinding:function(e,args){me._bind(args)},iggriddatarendering:function(e,args){me._bind(args)},iggridrowsrendering:function(e,args){me._bind(args)},iggriduidirty:function(){me._end()},iggridresizingcolumnresizing:function(){me._end()},iggridvirtualrecordsrender:function(e,args){me._rerender(args)},iggridrowsrendered:function(e,args){me._rerender(args)}};if(this.options.enableAddRow){me._gEvts.iggridheaderrenderedinternal=function(){me._headerRendered()};me._gEvts.iggridheaderextracellsmodified=function(){me._hierHeaderInit()}}me._gEvts.iggridgroupbygroupedcolumnschanged=function(e,args){me._groupedColumnsChanged(args)};grid.element.bind(this._gEvts);me._ti=parseInt(grid.options.tabIndex||1,10);me._evts={iggridselectionmousedown:function(e){me._onEvt(e,1)},mousedown:function(e){var origEvt;if($.ig.util.isIE7===true||$.ig.util.isIE8===true){origEvt=$.extend(true,{},e)}else{origEvt=e}setTimeout(function(){me._onEvt(origEvt,1)},0)},click:function(e){me._onEvt(e,2)},dblclick:function(e){me._onEvt(e,3)},keydown:function(e){me._onEvt(e,4)},focus:function(e){me._onEvt(e,5)},blur:function(e){me._onEvt(e,6)},mousemove:function(e){me._onEvt(e,7)},mouseleave:function(e){me._onEvt(e,8)},MSPointerUp:function(e){me._onEvt(e,14)},pointerup:function(e){me._onEvt(e,14)}};me._tEvts={touchstart:function(e){me._onEvt(e,11)},touchend:function(e){me._onEvt(e,12)},touchmove:function(e){me._onEvt(e,13)}};me._addDSSuccessHandler();me._addDSErrorHandler();if(me.grid.options._isHierarchicalGrid&&me.grid._originalOptions){if(opts.inherit){me.grid._shouldAlwaysRenderChildIndicator=me._childrenWithAddRowEnabled(me.grid.options,opts.enableAddRow)}else{me.grid._shouldAlwaysRenderChildIndicator=me._childrenWithAddRowEnabled(me.grid.options)}if(!me.grid.dataSource.settings.schema.layouts){hg=me.grid.element.closest(".ui-iggrid-root").data("igHierarchicalGrid");cl=[];hg._parseLayouts(cl,"",me.grid._originalOptions);me.grid.dataSource.settings.schema.layouts=cl}}this._renderTouchUI=typeof Modernizr==="object"&&Modernizr.touch===true;if(window.navigator.msPointerEnabled||window.navigator.pointerEnabled){me.grid.element.css("-ms-touch-action","none")}if(String(grid.options.templatingEngine).toLowerCase()==="jsrender"){this._jsr=true;if(opts.rowEditDialogRowTemplate&&typeof opts.rowEditDialogRowTemplate==="string"){$.templates(this.grid.id()+"_rowEditDialogRowTemplate",opts.rowEditDialogRowTemplate)}}}});$.extend($.ui.igGridUpdating,{version:"14.1.20141.1020"});$.widget("ui.igEditorFilter",{setFocus:function(delay,toggle){var provider=this.options.provider;setTimeout(function(){provider.setFocus(toggle)},delay)},remove:function(){if(!this.options.provider.removeFromParent()){var p,e=this.element;p=e[0].parentNode;if(p&&p.tagName){p.removeChild(e[0])}e=this.validator();if(e){e.hide()}}},validator:function(){return this.options.provider.validator()},hasInvalidMessage:function(){var validator=this.validator();return validator?validator.isMessageDisplayed():false},destroy:function(){this.options.provider.destroy()}});$.extend($.ui.igEditorFilter,{version:"14.1.20141.1020"});$.ig.EditorProvider=$.ig.EditorProvider||Class.extend({createEditor:function(updating,key,columnSetting,tabIndex,format,dataType,cellValue,element){return null},getValue:function(){return""},setValue:function(val,updating){return false},setFocus:function(toggle){return null},setSize:function(width,height){return null},removeFromParent:function(){return false},destroy:function(){return this},validator:function(){return null},validate:function(noLabel){var validator=this.validator();return validator?!validator.validate():true},isValid:function(){var validator=this.validator();return validator?validator.isValidState():true}});$.ig.EditorProviderDefault=$.ig.EditorProviderDefault||$.ig.EditorProvider.extend({createEditor:function(updating,key,columnSetting,tabIndex,format,dataType,cellValue,element){var v,o={};if(columnSetting){o=columnSetting.editorOptions||o;o.type=columnSetting.editorType||o.type}v=o.type;if(o.enableUTCDates!==false&&updating.grid.options.enableUTCDates){o.enableUTCDates=true}if(!v){if(dataType==="bool"){o.listItems=["true","false"];o.button="dropdown";this._bool=o.readOnly=o.dropDownOnReadOnly=o.spinOnReadOnly=o.spinWrapAround=true}else if(format==="currency"||format==="percent"||format==="date"){v=format;o.displayFactor=o.displayFactor||1}else if(dataType==="number"){v="numeric"}else if(dataType==="date"){v="date"}else if(!dataType){v=cellValue;v=typeof v==="number"?"numeric":v&&v.getTime?"date":null}o.type=v}if(format==="int"){o.maxDecimals=0}else if(format==="double"&&!o.maxDecimals){o.maxDecimals=100}else if(format&&v&&v.toString().indexOf("date")===0&&!o.dateInputFormat){o.dateInputFormat=format}if((v==="datepicker"||v===3)&&!o.button){o.button="dropdown"}o.tabIndex=tabIndex;o._eo=o._eo||{tc:o.textChanged,kd:o.keydown};o.textChanged=function(e,ui){updating._notifyChanged();if(o._eo.tc){o._eo.tc(e,ui)}};o.keydown=function(e,ui){updating._13=o.textMode&&!o.hideEnterKey;updating._notifyEditorKey(e,key);if(o._eo.kd){o._eo.kd(e,ui)}};v=element||$("<span />");if(!v.igEditor){_throw("igEditorException")}if(o.id){v.attr("id",o.id)}o.excelNavigationMode=updating.options.excelNavigationMode;v=v.igEditor(o);this.editor=v.data("igEditor");return v},getValue:function(){var val=this.editor.value();return this._bool?val==="true":val},setValue:function(val){return this.editor.value(this._bool?val&&val!=="false"?"true":"false":val)},setSize:function(width,height){this.editor._listRemove();this.editor._width(width);this.editor._height(height)},setFocus:function(){this.editor.setFocus(-1)},removeFromParent:function(){return this.editor.remove()},destroy:function(){this.editor.destroy()},validator:function(){return this.editor.validator()},validate:function(noLabel){return this.editor.validate(noLabel)},isValid:function(){return this.editor.isValid()}});$.ig.EditorProviderCombo=$.ig.EditorProviderCombo||$.ig.EditorProvider.extend({createEditor:function(updating,key,columnSetting,tabIndex,format,dataType,cellValue,element){var v,o={};if(columnSetting){o=columnSetting.editorOptions||o}o.tabIndex=tabIndex;o._eo=o._eo||{tc:o.textChanged,kd:o.keydown};o.textChanged=function(e,ui){updating._notifyChanged();if(o._eo.tc){o._eo.tc(e,ui)}};o.keydown=function(e,ui){if(!ui||ui.keyCode===9||!ui.owner||!ui.owner._ddOn){updating._notifyEditorKey(e,key)}if(o._eo.kd){return o._eo.kd(e,ui)}};v=element||$("<span />");if(!v.igCombo){_throw("igComboException")}if(o.id){v.attr("id",o.id)}v=v.igCombo(o);this.editor=v.data("igCombo");return v},getValue:function(){return this.editor.options.allowCustomValue?this.editor.text():this.editor.value()},setValue:function(val){var combo=this.editor,o=combo.options;if(o.filteringType){combo.selectedIndex(-1);combo.activeIndex(-1);if(!o.parentCombo){combo.dataBind()}}return o.allowCustomValue?combo.text(val===null?o.nullText||"":val):combo.value(val)},setSize:function(width,height){this.editor.options.width=width;this.editor.options.height=height;this.editor._doSize()},setFocus:function(){this.editor.setFocus(-1);this.editor.fieldElem[0].select()},removeFromParent:function(){return this.editor.remove()},validator:function(){return this.editor.validator()},destroy:function(){this.editor.destroy()}});$.ig.EditorProviderRating=$.ig.EditorProviderRating||$.ig.EditorProvider.extend({createEditor:function(updating,key,columnSetting,tabIndex,format,dataType,cellValue,element){var foc,v,o={};if(columnSetting){o=columnSetting.editorOptions||o}o._eo=o._eo||{vc:o.valueChange};o.valueChange=function(e,ui){updating._notifyChanged();if(o._eo.vc){return o._eo.vc(e,ui)}};v=element||$("<div />");if(!v.igRating){_throw("igRatingException")}if(o.id){v.attr("id",o.id)}v=v.igRating(o);this.editor=v.data("igRating");foc=this.editor._foc;if(foc){foc.attr("tabIndex",tabIndex);foc.keydown(function(e){updating._notifyEditorKey(e,key)})}return v},getValue:function(){return this.editor.value()},setValue:function(val){return this.editor.value(val||0)},setSize:function(width,height){if(!this._once){this.editor._doVotes(this.editor.options)}this._once=1;var back=this.editor.element.parent().css("backgroundColor");this.editor.element.css({width:width,height:height,backgroundColor:back})},setFocus:function(){this.editor.focus()},validator:function(){return this.editor.validator()},destroy:function(){this.editor.destroy()}});$.ig.EditorProviderCheckbox=$.ig.EditorProviderCheckbox||$.ig.EditorProvider.extend({createEditor:function(updating,key,columnSetting,tabIndex,format,dataType){var elem,me=this,o=columnSetting;me.updating=updating;me.none=dataType==="bool"?false:null;me.element=elem=$('<span tabindex="'+tabIndex+'"/>').addClass("ui-igedit-field ui-state-default ui-corner-all").css({overflow:"hidden",textAlign:"center",outline:0,background:"#ffffff",display:"block"}).click(function(){me.setValue(0,updating)}).focus(function(){me.css(true,true)}).blur(function(){me.css(true)}).mouseover(function(){me.css(null,true)}).mouseleave(function(){me.css()}).keydown(function(e){updating._notifyEditorKey(e,key);if(e&&e.keyCode===32){_stop(e);me.setValue(0,updating)}});o=o?o.editorOptions:null;if(o&&o.id){elem.attr("id",o.id)}elem=$('<span class="ui-state-default ui-corner-all ui-igcheckbox-small" />').css("display","inline-block").appendTo(elem);$('<span class="ui-icon ui-icon-check ui-igcheckbox-small-on" />').css("display","block").appendTo(elem);return this.element},el:function(depth){var e=this.element;while(depth-->0){e=$(e.children()[0])}return e},getValue:function(){return this.value},setValue:function(val,updating){var css="ui-igcheckbox-small-off";if(updating){val=!this.value}this.value=val||val===false?val:this.none;if(val){this.el(2).removeClass(css)}else{this.el(2).addClass(css)}if(updating){updating._notifyChanged()}},css:function(foc,on){var i=2,css=foc?"ui-state-focus":"ui-state-hover";while(i-->0){if(on){this.el(i).addClass(css)}else{this.el(i).removeClass(css)}}},setSize:function(width,height){var elem=this.el(0);this.el(1).css("marginTop",Math.floor((height-15)/2)+"px");this.css();this.css(true);elem.css({width:width-_int(elem,"borderLeftWidth")-_int(elem,"borderRightWidth"),height:height-_int(elem,"borderTopWidth")-_int(elem,"borderBottomWidth")})},setFocus:function(toggle){this.el(0).focus();if(toggle){this.setValue(0,this.updating)}}})})(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);