/*!@license
 * Infragistics.Web.ClientUI Grid Feature Chooser 13.1.20131.2523
 *
 * 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.igGridFeatureChooser",{css:{featureChooserDropDown:"ui-iggrid-featurechooser-dropdown-dialog ui-widget ui-widget-content ui-corner-all",headerButtonIcon:"ui-iggrid-featurechooserbutton ui-icon ui-icon-gear",headerButtonIconMouseOver:"ui-iggrid-header-icon-mouseover",headerButtonIconSelected:"ui-iggrid-header-icon-selected",listClass:"ui-iggrid-featurechooser-list ui-menu ui-widget ui-widget-content ui-corner-all",listItemClass:"ui-iggrid-featurechooserddlistitemicons ui-state-default",itemIconCotainer:"ui-iggrid-featurechoosericoncontainer",itemSecondaryIconContainer:"ui-iggrid-featurechooser-secondaryicon-container",separator:"ui-iggrid-featurechooser-separator",listItemText:"ui-iggrid-featurechooserddlistitemtext",itemSelected:"item-selected",dropDownListItemHover:"ui-iggrid-featurechooser-listitem-hover ui-state-active ui-state-hover",dropDownButtonClasses:"ui-igbutton",dropDownButtonHoverClasses:"",dropDownButtonActiveClasses:"",dropDownButtonFocusClasses:"",dropDownButtonLabelClass:""},options:{dropDownWidth:null,animationDuration:400},events:{featureChooserRendering:"featureChooserRendering",featureChooserRendered:"featureChooserRendered",featureChooserDropDownOpening:"featureChooserDropDownOpening",featureChooserDropDownOpened:"featureChooserDropDownOpened",featureToggling:"featureToggling",featureToggled:"featureToggled"},_createWidget:function(options,element){$.Widget.prototype._createWidget.apply(this,arguments)},_create:function(){this.analyzedData={};this.data={};this._features=[];this._isFeaturesAnalyzed=false;this.isInitialized=false;this.grid=this.element.data("igGrid");this.gridId=this.element[0].id;this._analyzeGridFeaturesOptions();this._countRenderedFeatures=0;if(this._headerRenderedHandler){this.grid.element.unbind("iggridheaderrendered",this._headerRenderedHandler)}this._headerRenderedHandler=$.proxy(this._headerRendered,this);this.grid.element.bind("iggridheaderrendered",this._headerRenderedHandler);if(this._gridDestroyedHandler){this.grid.element.unbind("igcontroldestroyed",this._gridDestroyedHandler)}this._gridDestroyedHandler=$.proxy(this.destroy,this);this.grid.element.bind("igcontroldestroyed",this._gridDestroyedHandler)},_analyzeGridFeaturesOptions:function(){var i,features=this.grid.options.features,featuresLength=features.length;for(i=0;i<featuresLength;i++){this._features.push(features[i].name)}},shouldShowFeatureIcon:function(key){if(this.analyzedData[key]!==undefined&&this.analyzedData[key]!==null){return this.analyzedData[key].length<=1}return true},_setOption:function(key,value){$.Widget.prototype._setOption.apply(this,arguments)},_id:function(name,suffix){var res=this.gridId+"_"+name;if(suffix!==undefined&&suffix!==null&&$.type(suffix)==="string"){res+="_"+suffix}return res},_callFeatureMethod:function(feature,isSelected,columnKey,event){var method,methodType=$.type(feature.method),featureData=this.grid.element.data("igGrid"+feature.name);if(methodType==="string"){if(featureData===undefined||featureData===null){return false}method=featureData[feature.method]}else if(methodType==="function"){method=feature.method}if(method===undefined||method===null){return false}if($.type(feature.method)==="string"){featureData[feature.method](event,columnKey,isSelected,feature.methodData)}else{feature.method(event,columnKey,isSelected,feature.methodData)}return true},_getFeatureByKeyName:function(columnKey,featureName){var i,feature=null,columnData=this.data[columnKey],columnDataLength=columnData.length;for(i=0;i<columnDataLength;i++){if(columnData[i].name===featureName){feature=columnData[i];break}}return feature},_clickFeature:function(event){var i,j,$target=$(event.target).data("data")!==undefined?$(event.target):$(event.currentTarget),d=$target.data("data"),self=this,isSelected=null,type=d.type,columnKey=d.columnKey,featureName=d.featureName,columnData=this.data[columnKey],columnDataLength=columnData.length,feature=null;feature=this._getFeatureByKeyName(columnKey,featureName);if(feature===null||feature===undefined){return}if(type==="toggle"){isSelected=!feature.isSelected}if(this._trigger(this.events.featureToggling,null,{target:$target,columnKey:columnKey,isToSelect:isSelected,featureName:"igGrid"+feature.name})===false){return}if(this._callFeatureMethod(feature,isSelected,columnKey,event)===false){return}if(type==="toggle"){feature.isSelected=isSelected;self._setSelectedItem(columnKey,isSelected,$("#"+self._id("featurechooser_dd_li_"+columnKey,featureName)));if(feature.updateOnClickAll===true){$.each(self.data,function(index,value){if(index!==columnKey){for(j=0;j<value.length;j++){if(value[j].name===featureName){break}}if(j===value.length){return true}columnData=self.data[index];if(columnData===null||columnData===undefined){return true}columnDataLength=columnData.length;for(i=0;i<columnDataLength;i++){if(columnData[i].name===featureName){columnData[i].isSelected=isSelected;break}}self._setSelectedItem(index,isSelected,$("#"+self._id("featurechooser_dd_li_"+index,value[j].name)))}})}}},_setListItemText:function(columnKey,featureName,text){$("#"+this._id("featurechooser_dd_li_"+columnKey,featureName)+" span.ui-iggrid-featurechooserddlistitemtext").text(text)},_analyzeFeatures:function(){if(this._isFeaturesAnalyzed===true){return}var i,k,cs=this.grid.options.columns,csLength=cs.length,featureName,featuresLength=this._features.length,features=this._features,newFeatures=[],columnsFeature,columnsFeatureLength,featureInstance,columnKey;for(i=0;i<featuresLength;i++){featureName=features[i];featureInstance=this.grid.element.data("igGrid"+featureName);if(featureInstance===undefined||featureInstance===null){continue}if(featureInstance.renderInFeatureChooser!==true){continue}if(featureInstance._columnMap===undefined||featureInstance._columnMap===null){continue}columnsFeature=featureInstance._columnMap();if(columnsFeature===false||columnsFeature===null||columnsFeature===undefined){continue}columnsFeatureLength=columnsFeature.length;if(columnsFeatureLength===0){for(k=0;k<csLength;k++){columnKey=cs[k].key;if(this.analyzedData[columnKey]===undefined||this.analyzedData[columnKey]===null){this.analyzedData[columnKey]=[]}if(this._isFeatureExistByColumnKey(featureName,columnKey)===true){continue}this.analyzedData[columnKey].push({name:featureName,method:null,text:null,iconClass:null,isSelected:false,columnCell:null,isActive:false})}}else{for(k=0;k<columnsFeatureLength;k++){columnKey=columnsFeature[k].columnKey;if(this.analyzedData[columnKey]===undefined||this.analyzedData[columnKey]===null){this.analyzedData[columnKey]=[]}if(columnsFeature[k].enabled!==true||this._isFeatureExistByColumnKey(featureName,columnKey)===true){continue}this.analyzedData[columnKey].push({name:featureName,method:null,text:null,iconClass:null,isSelected:false,columnCell:null,isActive:false})}}newFeatures.push({name:featureName,instance:featureInstance})}this._features=newFeatures;this._isFeaturesAnalyzed=true},_isFeatureExistByColumnKey:function(featureName,columnKey){var aData=this.analyzedData[columnKey],ret=false;if(aData===null||aData===undefined){return true}$.each(aData,function(index,value){if(value.name===featureName){ret=true;return false}});return ret},_shouldRenderInFeatureChooser:function(columnKey){this._analyzeFeatures();if(this.analyzedData[columnKey]!==undefined&&this.analyzedData[columnKey]!==null){return this.analyzedData[columnKey].length>1}return false},_headerRendered:function(sender,args){if(args.owner.element.attr("id")!==this.grid.element.attr("id")){return}if(sender.target.id!==this.grid.element[0].id){return}var self=this;$.each(this.data,function(columnKey,elem){self._initFC(columnKey,elem)})},_initFC:function(columnKey,elem){var j,self=this,thead=this.grid.container().find("thead"),$columnCell,$theadCell,buttonId,cancelFunc,$button,$headerContainer;$columnCell=$("#"+self.grid.element[0].id+"_"+columnKey);buttonId=self._id("featureChooser_headerButton",columnKey);if(elem.isCancelledRendering!==false&&self._trigger(self.events.featureChooserRendering,null,{owner:self.grid,columnKey:columnKey,columnCell:$columnCell})===false){elem.isCancelledRendering=true;return}elem.isCancelledRendering=false;$theadCell=thead.find("#"+self.grid.element[0].id+"_"+columnKey);$headerContainer=$theadCell.find(".ui-iggrid-indicatorcontainer");if($headerContainer.length===0){$headerContainer=$("<div></div>").appendTo($theadCell).addClass("ui-iggrid-indicatorcontainer")}cancelFunc=function(e){e.preventDefault();e.stopPropagation()};$button=$("<span></span>").prependTo($headerContainer).addClass(self.css.headerButtonIcon);$button.wrap('<a id="'+buttonId+'" href="#" title=""></a>');$button.parent().attr("th-remove-focus","").bind({keydown:function(event){var $item,$nextPrevItem,$dialog=$("#"+self._id("featureChooser_dd",columnKey));if(event.keyCode===$.ui.keyCode.ENTER||event.keyCode===$.ui.keyCode.SPACE){$item=$dialog.find("ul li.ui-iggrid-featurechooser-listitem-hover");if($dialog.is(":visible")&&$item.length>0){if($item.find('*[role="button"]').length){event.target=$item.find('*[role="button"]:eq(0)')}else{event.target=$item[0]}self._clickFeature(event)}self._toggleDropDown(event,columnKey,false);cancelFunc(event)}else if(event.keyCode===$.ui.keyCode.DOWN||event.keyCode===$.ui.keyCode.UP){if($dialog.is(":visible")){$item=$dialog.find("ul li.ui-iggrid-featurechooser-listitem-hover");if($item.length>1){$.each($item,function(index,value){self._removeCssSelectionListItem($(value))})}$nextPrevItem=event.keyCode===$.ui.keyCode.DOWN?$item.next():$item.prev();if($nextPrevItem.attr("data-fc-separator")){$nextPrevItem=event.keyCode===$.ui.keyCode.DOWN?$nextPrevItem.next():$nextPrevItem.prev()}if($item.length===0){self._addCssSelectionListItem($dialog.find("ul li:eq(0)"))}else if($nextPrevItem.length>0&&$nextPrevItem.is("li")){self._removeCssSelectionListItem($item);self._addCssSelectionListItem($nextPrevItem)}cancelFunc(event)}}},blur:function(e){self._toggleDropDown(e,columnKey,true)},mousedown:function(event){self._toggleDropDown(event,columnKey,false);cancelFunc(event)},mouseover:function(event){if($button.hasClass(self.css.headerButtonIconSelected)===false){$button.addClass(self.css.headerButtonIconMouseOver)}},mouseout:function(event){$button.removeClass(self.css.headerButtonIconMouseOver)},mouseup:cancelFunc,click:cancelFunc});$("#"+this._id("featureChooser_dd",columnKey)).remove();for(j=0;j<elem.length;j++){self._renderDropDownItem(columnKey,elem[j])}self._trigger(self.events.featureChooserRendered,null,{owner:self.grid,columnKey:columnKey,columnCell:$columnCell})},_renderInFeatureChooser:function(columnKey,data){var i,columnData=this.analyzedData[columnKey],columnDataLength;if(columnData===undefined||columnData===null){return}columnDataLength=columnData.length;if(columnData.isCancelledRendering===true){return}for(i=0;i<columnDataLength;i++){if(columnData[i].name.toLowerCase()===data.name.toLowerCase()){this.analyzedData[columnKey][i]=data;break}}if(i===columnDataLength){this.analyzedData[columnKey].push(data)}if(this.data[columnKey]===null||this.data[columnKey]===undefined){this.data[columnKey]=[]}if($.type(this.data[columnKey].order)!=="number"){this.data[columnKey].order=0}for(i=0;i<this.data[columnKey].length;i++){if(this.data[columnKey][i].name===data.name&&data.name!==undefined){return}}this.data[columnKey].push(data)},_removeFeature:function(featureName){var self=this,cols=this.grid.options.columns;$.each(cols,function(index,col){self._removeDropDownItem(col.key,featureName)})},_removeDropDownItem:function(columnKey,featureName){var $dropDown=$("#"+this._id("featureChooser_dd",columnKey)),$item=$("#"+this._id("featurechooser_dd_li_"+columnKey,featureName));if($item.length>0){$item.remove();if($dropDown.find("li:not([data-fc-separator])").length===0){$dropDown.remove();$("#"+this._id("featureChooser_headerButton",columnKey)).remove()}else{this._removeSeparatorItem(columnKey)}}},_removeSeparatorItem:function(columnKey){var dropDownId=this._id("featureChooser_dd",columnKey),listLiSeparator=$("#"+dropDownId).find("[data-fc-separator]");listLiSeparator.each(function(index){var $li=$(this),$prevLi=$li.prev(),$nextLi=$li.next();if($prevLi.length===0||$prevLi.attr("data-fc-separator")!==undefined||$nextLi.length===0||$nextLi.attr("data-fc-separator")!==undefined){$li.remove();return false}})},_renderDropDownItem:function(columnKey,data){var dropDownId=this._id("featureChooser_dd",columnKey),$dropDown=$("#"+dropDownId),$li,$span,cssClassIcon="",self=this,isSelected=data.isSelected,featureName=data.name,innerData,$button,liId=this._id("featurechooser_dd_li_"+columnKey,featureName),isOnBottom=data.isOnBottom,ddWidth=this.options.dropDownWidth,groupName=data.groupName,groupOrder=data.groupOrder,listId=this._id("featurechooser_dd_list",columnKey),$list=$("#"+listId),listItemsGroup,insertElementObj;if($("#"+liId).length>0){return}if(isSelected===undefined||isSelected===null){isSelected=false}if($dropDown.length===0){$dropDown=$("<div></div>");$dropDown.attr("id",dropDownId).css({position:"absolute",display:"none"}).addClass(this.css.featureChooserDropDown).appendTo("body");$dropDown.width(ddWidth);$list=$("<ul></ul>").attr("id",listId).addClass(this.css.listClass).appendTo($dropDown)}$li=$("<li></li>");$li.addClass(this.css.listItemClass).attr("id",liId).attr("data-fc-order",data.order);if(groupName!==undefined&&groupName!==null){$li.attr("data-fc-groupname",groupName)}if(groupOrder!==undefined&&groupOrder!==null){$li.attr("data-fc-grouporder",groupOrder)}if(isOnBottom===undefined||data.isOnBottom===null){if(data.type==="button"){isOnBottom=true}else{isOnBottom=false}}if(data.type!=="button"){$li.bind({mouseover:$.proxy(this._mouseOverDropDownItem,this),mouseout:$.proxy(this._mouseOutDropDownItem,this)})}innerData={columnKey:columnKey,featureName:featureName,updateOnClickAll:data.updateOnClickAll,isOnBottom:isOnBottom,groupName:groupName,groupOrder:groupOrder,type:data.type,textHide:data.textHide,state:data.state,text:data.text};data.isOnBottom=isOnBottom;$li.data("data",innerData);if(data.type==="button"){$button=$("<a></a>").appendTo($li);$button.igButton({labelText:data.text,mousedown:function(event){self._clickFeature(event);self._toggleDropDown(event,columnKey,true)}});$button.data("data",innerData)}else{$li.bind({mousedown:function(event){self._clickFeature(event);self._toggleDropDown(event,columnKey,true)}});if(data.iconClass!==null&&data.iconClass!==undefined&&data.iconClass!==""){cssClassIcon=data.iconClass}$span=$("<span></span>").addClass(this.css.itemIconCotainer).appendTo($li);$span=$("<span></span>").appendTo($span);if(cssClassIcon!==""){$span.addClass(cssClassIcon)}$("<span></span>").text(data.text).addClass(this.css.listItemText).appendTo($li);if(data.secondaryIconClass!==undefined&&data.secondaryIconClass!==null){$span=$("<span></span>").addClass(this.css.itemSecondaryIconContainer).appendTo($li);$("<span></span>").addClass(data.secondaryIconClass).appendTo($span)}}if(groupName===undefined||groupName===null){listItemsGroup=$("#"+listId+" li:not([data-fc-groupName]):not([data-fc-separator])");insertElementObj=this._getInsertElement(listItemsGroup,data.order,"data-fc-order");this._insertElement(insertElementObj,$list,$li,null)}else{listItemsGroup=$("#"+listId+" li[data-fc-groupName = "+groupName+"]");if(listItemsGroup.length===0){listItemsGroup=$("#"+listId+" li[data-fc-groupName]");insertElementObj=this._getInsertElement(listItemsGroup,groupOrder,"data-fc-grouporder");if(insertElementObj.item!==null){$list=listItemsGroup}this._insertElement(insertElementObj,$list,$li,groupName)}else{insertElementObj=this._getInsertElement(listItemsGroup,data.order,"data-fc-order");this._insertElement(insertElementObj,listItemsGroup,$li,groupName)}}if(data.type==="toggle"){this._setSelectedItem(columnKey,data.isSelected,$li)}},_getSeparatorItem:function(){return $('<li data-fc-separator="1" class="'+this.css.separator+'"></li>')},_insertElement:function(insertElementObj,$list,$li,groupName){var $insertElement=insertElementObj.item,insertElementPosition=insertElementObj.position,$prevElement;if($insertElement===null){$li.appendTo($list);$prevElement=$li.prev();if($prevElement!==undefined&&$prevElement.length>0&&$prevElement.attr("data-fc-separator")!=="1"&&$prevElement.attr("data-fc-groupname")!==undefined&&$prevElement.attr("data-fc-groupname")!==groupName){this._getSeparatorItem().insertBefore($li)}}else{if(insertElementPosition==="after"){$li.insertAfter($insertElement);if($insertElement!==undefined&&$insertElement.length>0&&$insertElement.attr("data-fc-separator")!=="1"&&$insertElement.attr("data-fc-groupname")!==undefined&&$insertElement.attr("data-fc-groupname")!==groupName){this._getSeparatorItem().insertBefore($li)}}else{$li.insertBefore($insertElement);$prevElement=$li.prev();if($prevElement!==undefined&&$prevElement.length>0&&$prevElement.attr("data-fc-separator")!=="1"&&$prevElement.attr("data-fc-groupname")!==undefined&&$prevElement.attr("data-fc-groupname")!==groupName){this._getSeparatorItem().insertBefore($li)}else if($insertElement!==undefined&&$insertElement.length>0&&$insertElement.attr("data-fc-separator")!=="1"&&$insertElement.attr("data-fc-groupname")!==undefined&&$insertElement.attr("data-fc-groupname")!==groupName){this._getSeparatorItem().insertAfter($li)}}}},_getInsertElement:function(listItems,targetOrder,attr){var $item=null,itemOrder,at,i;for(i=0;i<listItems.length;i++){$item=$(listItems[i]);at=$item.attr(attr);if(at===undefined){continue}itemOrder=parseInt(at,10);if(itemOrder>targetOrder){return{item:$item,position:"before"}}}return{item:$item,position:"after"}},_setSelectedState:function(featureName,columnKey,isSelected,executeCallback){var data=this.data[columnKey],$listItem,self=this;if(data===undefined||data===null){return false}$.each(data,function(index,value){if(value.name.toLowerCase()===featureName.toLowerCase()){$listItem=$("#"+self._id("featurechooser_dd_li_"+columnKey,value.name));self._setSelectedItem(columnKey,isSelected,$listItem);self.data[columnKey][index].isSelected=!isSelected;if(executeCallback===true){self._callFeatureMethod(value,isSelected,columnKey,null)}value.isSelected=isSelected;return false}})},_setSelectedItem:function(columnKey,isSelected,$listItem){if($listItem===null||$listItem===undefined||$listItem.length===0){return}var innerData=$listItem.data("data"),textShow,textHide,$label=null;if(innerData!==undefined&&innerData!==null){textShow=innerData.text;textHide=innerData.textHide;$label=$listItem.find("span.ui-iggrid-featurechooserddlistitemtext")}$listItem.attr("data-fc-selected",isSelected);if(isSelected===true){$listItem.addClass(this.css.itemSelected);if($label!==null&&textShow!==null&&textShow!==undefined){$label.text(textShow)}}else{$listItem.removeClass(this.css.itemSelected);if($label!==null&&textHide!==null&&textHide!==undefined){$label.text(textHide)}}},_toggleSelectedItems:function(featureName,selected){var i,$li,columnKey,cols=this.grid.options.columns,colsLength=cols.length,isSelected;if(selected!==undefined){isSelected=selected}for(i=0;i<colsLength;i++){columnKey=cols[i].key;$li=$("#"+this._id("featurechooser_dd_li_"+columnKey,featureName));if($li.data("data")===null||$li.data("data")===undefined){continue}if(selected===undefined){isSelected=$li.attr("data-fc-selected")==="true"}this._setSelectedState(featureName,columnKey,!isSelected)}},_toggleDropDown:function(event,columnKey,isCalledFromBlur){var $button=$("#"+this._id("featureChooser_headerButton",columnKey)),maxZ,left=0,top=0,dropDownId=this._id("featureChooser_dd",columnKey),$headerContainer,$dropDown=$("#"+dropDownId),isVisible=$dropDown.is(":visible")===true,self=this,animationDuration=this.options.animationDuration,$columnCell=null;if($dropDown.data("isAnimating")===true||isVisible===false&&isCalledFromBlur===true){return}$columnCell=$("#"+this.grid.element[0].id+"_"+columnKey);$headerContainer=$("#"+this._id("featureChooser_headerButton",columnKey)).find("span");if(isVisible===false&&this._trigger(this.events.featureChooserDropDownOpening,null,{owner:$dropDown,columnKey:columnKey,columnCell:$columnCell,data:this.data[columnKey]})===false){return}if(!isVisible){maxZ=$.ig.getMaxZIndex(dropDownId);$dropDown.css("zIndex",maxZ);top=$.ig.util.offset($headerContainer).top+$headerContainer.height();left=$.ig.util.offset($headerContainer).left-$dropDown.width()+$headerContainer.width();if(left<0){left=$.ig.util.offset($headerContainer).left}$dropDown.css({top:top,left:left})}$dropDown.data("isAnimating",true);$dropDown.slideToggle(animationDuration,function(){if($dropDown.is(":visible")===true){$button.focus();self._activeDropdown=$dropDown;self._trigger(self.events.featureChooserDropDownOpened,null,{owner:$dropDown,columnKey:columnKey,columnCell:$columnCell,data:self.data[columnKey]});$button.children("span:first").addClass(self.css.headerButtonIconSelected)}else{self._activeDropdown=null;$button.children("span:first").removeClass(self.css.headerButtonIconSelected)}$dropDown.data("isAnimating",false)})},_mouseOverDropDownItem:function(event){this._addCssSelectionListItem($(event.currentTarget))},_mouseOutDropDownItem:function(event){this._removeCssSelectionListItem($(event.currentTarget))},_addCssSelectionListItem:function($listItem){$listItem.addClass(this.css.dropDownListItemHover)},_removeCssSelectionListItem:function($listItem){$listItem.removeClass(this.css.dropDownListItemHover)},destroy:function(){var self=this;this.data=null;$.each(this.grid.options.columns,function(ind,column){$("#"+self._id("featureChooser_dd",column.key)).remove()});this.grid.element.unbind("iggridheaderrendered",this._headerRenderedHandler);this.grid.element.unbind("igcontroldestroyed",this._gridDestroyedHandler);delete this._headerRenderedHandler;delete this._gridDestroyedHandler;$.Widget.prototype.destroy.apply(this,arguments);return this}});$.extend($.ui.igGridFeatureChooser,{version:"13.1.20131.2523"})})(jQuery);if(typeof jQuery!=="function"){throw new Error("jQuery is undefined")}(function($){$.widget("ui.igGridModalDialog",{options:{buttonApplyText:"Apply",buttonCancelText:"Cancel",modalDialogCaptionText:"Header",modalDialogWidth:250,modalDialogHeight:"",renderFooterButtons:true,animationDuration:200},css:{modalDialog:"ui-dialog ui-draggable ui-resizable ui-iggrid-dialog ui-widget ui-widget-content ui-corner-all",modalDialogHeaderCaption:"ui-dialog-titlebar ui-widget-header ui-corner-top ui-helper-reset ui-corner-all ui-helper-clearfix",modalDialogHeaderCaptionTitle:"ui-dialog-title",modalDialogContent:"ui-dialog-content ui-widget-content",modalDialogHandleBar:"",captionButtonContainer:"ui-iggrid-modaldialog-caption-buttoncontainer",modalDialogFooter:"ui-dialog-buttonpane ui-widget-content ui-helper-clearfix",buttonset:"ui-dialog-buttonset",blockArea:"ui-widget-overlay ui-iggrid-blockarea"},events:{modalDialogOpening:"modalDialogOpening",modalDialogOpened:"modalDialogOpened",modalDialogMoving:"modalDialogMoving",modalDialogClosing:"modalDialogClosing",modalDialogClosed:"modalDialogClosed",modalDialogContentsRendering:"modalDialogContentsRendering",modalDialogContentsRendered:"modalDialogContentsRendered",buttonOKClick:"buttonOKClick"},_createWidget:function(options,element){this.gridContainer=options.gridContainer;this.containment=options.containment||options.gridContainer;$.Widget.prototype._createWidget.apply(this,arguments)},_create:function(){this._setGridWidthHeight();this._renderModalDialog()},_setGridWidthHeight:function(){this.element.css("width",this.options.modalDialogWidth).css("height",this.options.modalDialogHeight)},openModalDialog:function(){var maxZ=1e4,scrollLeft,scrollTop,pageLeft,pageTop,pageRight,pageBottom,pos,h,w,bh,bw,mdW,mdH,caption,content,footer,modalDialogTop,modalDialogLeft,noCancel=true,modalDialog=this.element,modalDialogBody,block,animationDuration=this._getAnimationDuration(),blockId=this._id("_modaldialog_block");if(this._modalDialogOpened){return}noCancel=this._trigger(this.events.modalDialogOpening,null,{modalDialog:modalDialog,owner:this});if(noCancel){$("#"+blockId).remove();this._setGridWidthHeight();modalDialogBody=modalDialog.find("table tbody");modalDialogBody.empty();pos=$.ig.util.offset(this.gridContainer);w=this.gridContainer.outerWidth();h=this.gridContainer.outerHeight();scrollLeft=$(window).scrollLeft();scrollTop=$(window).scrollTop();pageLeft=pos.left-scrollLeft;pageTop=pos.top-scrollTop;pageRight=pageLeft+w;pageBottom=pageTop+h;mdW=parseInt(this.options.modalDialogWidth,10);mdH=parseInt(this.options.modalDialogHeight,10);block=$("<div></div>").appendTo("body").attr("id",blockId).css("position","absolute").addClass(this.css.blockArea).hide();if(block.outerWidth()!==this.gridContainer.outerWidth()){block.css("width",this.gridContainer.outerWidth())}if(block.outerHeight()!==this.gridContainer.outerHeight()){block.css("height",this.gridContainer.outerHeight())}block.css({left:pos.left,top:pos.top}).fadeToggle(animationDuration);if(!mdW){mdW=this.element.width()}if(!mdH){mdH=this.element.height()}if(pageLeft<0){pageLeft=0}if(pageTop<0){pageTop=0}bw=$(window).width();bh=$(window).height();if(pageRight>bw){pageRight=bw}if(pageBottom>bh){pageBottom=bh}modalDialogTop=pageTop+scrollTop+(pageBottom-pageTop)/2-mdH/2;modalDialogLeft=pageLeft+scrollLeft+(pageRight-pageLeft)/2-mdW/2;if(modalDialogTop<0){modalDialogTop=pageTop}if(modalDialogLeft<0){modalDialogLeft=pageLeft}maxZ=$.ig.getMaxZIndex(this.element[0].id);modalDialog.css({left:modalDialogLeft,top:modalDialogTop,zIndex:maxZ+2}).fadeToggle(animationDuration);block.css({zIndex:maxZ+1});caption=modalDialog.children("div.ui-dialog-titlebar");content=modalDialog.children("div.ui-dialog-content");footer=modalDialog.children("div.ui-dialog-buttonpane");content.css("height",modalDialog.height()-caption.outerHeight()-(content.outerHeight()-content.height())-footer.outerHeight());$("#"+this._id("content")).css({width:""});this._modalDialogOpened=true;this._trigger(this.events.modalDialogOpened,null,{modalDialogElement:modalDialog,owner:this});modalDialog.focus()}},_getAnimationDuration:function(){var animationDuration=this.options.animationDuration;if(animationDuration===null||animationDuration===undefined){animationDuration=200}return animationDuration},_setOption:function(key,value){$.Widget.prototype._setOption.apply(this,arguments);switch(key){case"buttonApplyText":$("#"+this._id("footer_buttonok")).igButton("option","labelText",value);break;case"buttonCancelText":$("#"+this._id("footer_buttoncancel")).igButton("option","labelText",value);break;case"modalDialogCaptionText":this.element.find("span.ui-dialog-title:eq(0)").html(value);break;case"modalDialogWidth":this.element.css("width",value);break;case"modalDialogHeight":this.element.css("height",value);break;case"renderFooterButtons":if(this.element.is(":visible")){this.closeModalDialog()}this.element.empty();this._renderModalDialog();break;default:break}},closeModalDialog:function(){var noCancel=true,modalDialog=this.element,animationDuration=this._getAnimationDuration();if(!this._modalDialogOpened){return}noCancel=this._trigger(this.events.modalDialogClosing,null,{modalDialog:modalDialog,owner:this});if(noCancel){modalDialog.fadeToggle(animationDuration);$("#"+this._id("_modaldialog_block")).fadeToggle(animationDuration);this._modalDialogOpened=false;this._trigger(this.events.modalDialogClosed,null,{modalDialog:modalDialog,owner:this})}},_modalDialogMove:function(e,ui){var oPos=ui.originalPosition,pos=ui.position;if(pos.top<0&&this.options.containment!=="window"){pos.top=this.gridContainer.position().top}this._trigger(this.events.modalDialogMoving,null,{modalDialog:e.target,owner:this,originalPosition:oPos,position:pos})},getCaptionButtonContainer:function(){return $("#"+this._id("caption_button_container"))},getFooter:function(){return $("#"+this._id("footer"))},getContent:function(){return $("#"+this._id("content"))},_renderModalDialog:function(){var self=this,css=this.css,modalDialog=this.element,caption,modalDialogContent,footer,o=this.options,$buttonSet,$buttonOK,$buttonCancel,noCancel=true;modalDialog.css("position","absolute").addClass(this.css.modalDialog).hide();noCancel=this._trigger(this.events.modalDialogContentsRendering,null,{modalDialog:modalDialog,owner:this});if(noCancel){caption=$("<div></div>").addClass(this.css.modalDialogHeaderCaption).appendTo(modalDialog);$("<span></span>").text(this.options.modalDialogCaptionText).addClass(this.css.modalDialogHeaderCaptionTitle).appendTo(caption);$("<div></div>").attr("id",this._id("caption_button_container")).addClass(css.captionButtonContainer).appendTo(caption);modalDialogContent=$("<div></div>").css("overflow","auto").addClass(this.css.modalDialogContent).attr("id",this._id("content")).appendTo(modalDialog);if(o.renderFooterButtons===true){footer=$("<div></div>").addClass(this.css.modalDialogFooter).attr("id",this._id("footer")).appendTo(modalDialog);$buttonSet=$("<div></div>").addClass(this.css.buttonset).appendTo(footer);$buttonOK=$("<button></button>").attr("id",this._id("footer_buttonok")).appendTo($buttonSet);$buttonOK.igButton({labelText:o.buttonApplyText});$buttonCancel=$("<button></button>").attr("id",this._id("footer_buttoncancel")).appendTo($buttonSet);$buttonCancel.igButton({labelText:o.buttonCancelText});$buttonCancel.bind({click:function(e,args){noCancel=self._trigger(self.events.buttonCancelClick,e,{modalDialog:modalDialog,owner:self});if(noCancel){self.closeModalDialog();e.preventDefault();e.stopPropagation()}}})}modalDialog.bind({keydown:function(e){if(e.keyCode===$.ui.keyCode.ESCAPE){self.closeModalDialog()}}}).draggable({containment:this.containment,handle:caption,drag:$.proxy(this._modalDialogMove,this)}).attr("role","dialog").attr("tabIndex",-1);if(typeof Modernizr!=="object"||Modernizr.touch===false){modalDialog.resizable({containment:"parent",alsoResize:modalDialogContent,minHeight:modalDialog.outerHeight()/4,minWidth:modalDialog.outerWidth()/2})}this._trigger(this.events.modalDialogContentsRendered,null,{modalDialog:modalDialog,owner:this})}},_id:function(){var i,ar=arguments,res=this.element[0].id;for(i=0;i<ar.length;i++){res+="_"+ar[i]}return res},destroy:function(){$("#"+this._id("_modaldialog_block")).remove();$.Widget.prototype.destroy.apply(this,arguments);return this}});$.extend($.ui.igGridModalDialog,{version:"13.1.20131.2523"})})(jQuery);