/*!@license
 * Infragistics.Web.ClientUI Grid Feature Chooser 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.popover.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.igGridFeatureChooserPopover",$.ui.igPopover,{options:{gridId:"",targetButton:null,closeOnBlur:true,containment:null},_create:function(){$.extend($.ui.igGridFeatureChooserPopover.prototype.options,$.ui.igPopover.prototype.options);$.extend($.ui.igGridFeatureChooserPopover.prototype.css,$.ui.igPopover.prototype.css);$.ui.igPopover.prototype._create.apply(this)},isShown:function(){return this.container().is(":visible")},_setFCElementFocus:function(focus,$target){if($target===undefined||$target===null){$target=this.options.targetButton}this.options.targetButton.data("onFocus",focus);if(focus){$target.focus()}},registerElements:function(elements){var events,$targetButton=this.options.targetButton,self=this;events={focus:function(e){setTimeout(function(){$targetButton.data("onFocus",true)},1)},blur:function(e){$targetButton.data("onFocus",false);setTimeout(function(){if(!$targetButton.data("onFocus")&&self.isShown()){self._closePopover()}},10)}};elements.bind(events)},_createWidget:function(options,element){var self=this,$targetButton;this._attachedToBody=true;this.options.content="";$.Widget.prototype._createWidget.apply(this,arguments);$.ui.igPopover.prototype._createWidget.apply(this,arguments);this._detachEventsFromTarget();$targetButton=this.options.targetButton;if(this.options.closeOnBlur){$targetButton.attr("tabindex","0");this._eventsFC={iggridfeaturechooserpopovershown:function(events,args){self._setFCElementFocus(true)},iggridfeaturechooserpopoverhidden:function(events,args){self._setFCElementFocus(false);self.popover.width("");self.popover.css({left:""})},mousedown:function(event){setTimeout(function(){self._setFCElementFocus(true)},1)},touchstart:function(){setTimeout(function(){self._setFCElementFocus(true)},1)}};this.element.bind(this._eventsFC);this.registerElements($targetButton)}},_positionPopover:function(trg){var $popover,w=this.popover.outerWidth(),availableWidth,top,left,rOffset,mw=this.options.maxWidth,$containment=this.options.containment,$window=$(window);if(mw&&mw<w){w=mw}$popover=this.popover;if($popover){if($containment.offset().left>=$window.scrollLeft()){availableWidth=$window.width()+$window.scrollLeft()-$containment.offset().left}else{availableWidth=$window.width()}if(w>availableWidth){w=parseInt(availableWidth,10)}this.popover.width(w)}$.ui.igPopover.prototype._positionPopover.apply(this,arguments);$popover.width(w);top=parseFloat($popover.css("top"));left=parseFloat($popover.css("left"));if(this._attachedToBody){$popover.detach().appendTo($containment);this._attachedToBody=false}rOffset=$.ig.util.getRelativeOffset($popover);if(!isNaN(top)){$popover.css("top",top-rOffset.top)}if(!isNaN(left)){$popover.css("left",left-rOffset.left)}},destroy:function(){var $targetButton;if(this._eventsFCTargetButton){$targetButton=this.options.targetButton;$targetButton.unbind(this._eventsFCTargetButton)}if(this._eventsFC){this.element.unbind(this._eventsFC)}$.ui.igPopover.prototype.destroy.apply(this,arguments)}});$.extend($.ui.igGridFeatureChooserPopover,{version:"14.1.20141.1020"});$.ig=$.ig||{};$.ig.GridFeatureChooserSections=$.ig.GridFeatureChooserSections||{click:"click",toggle:"toggle",modalDialog:"modalDialog"};$.widget("ui.igGridFeatureChooser",{css:{featureChooserDropDown:"",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",listItemContainer:"ui-iggrid-featurechooser-li-container",listItemIconContainer:"ui-iggrid-featurechooser-li-iconcontainer",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:"",containerDelimiter:"ui-iggrid-featurechooser-container-delimiter",containerSection:"ui-iggrid-featurechooser-container-section",itemNoIcon:"ui-iggrid-featurechooserbutton ui-icon ui-icon-close",submenu:"ui-iggrid-featurechooser-submenu ui-widget-content ui-corner-all",submenuIcon:"ui-iggrid-featurechooser-submenuicon ui-icon ui-icon-triangle-1-s"},options:{dropDownWidth:null,animationDuration:400},events:{featureChooserRendering:"featureChooserRendering",featureChooserRendered:"featureChooserRendered",featureChooserDropDownOpening:"featureChooserDropDownOpening",featureChooserDropDownOpened:"featureChooserDropDownOpened",menuToggling:"menuToggling",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},_isMetroIE:function(){var isFullScreen=window.innerWidth===screen.width&&window.innerHeight===screen.height,errorName,supported=null;if(!isFullScreen){return false}try{supported=new ActiveXObject("")}catch(e){errorName=e.name}try{supported=new ActiveXObject("htmlfile");supported=!!supported}catch(e){supported=false}if(supported===false&&errorName!=="ReferenceError"){supported=false}else{supported=true}return!supported},_isTouchDevice:function(){if(this._isTouch===undefined){this._isTouch=typeof Modernizr==="object"&&Modernizr.touch===true||this._isMetroIE()}return this._isTouch},_callFeatureMethod:function(feature,isSelected,columnKey,event){var method,returnType=true,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"){returnType=featureData[feature.method](event,columnKey,isSelected,feature.methodData)}else{returnType=feature.method(event,columnKey,isSelected,feature.methodData)}return returnType},_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)})},_touchStart:function(e,columnKey){if($(e.target).attr("data-skip-event")){return e}this.toggleDropDown(columnKey);e.preventDefault();e.stopPropagation()},_initFC:function(columnKey,elem){var 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);cancelFunc=function(e){e.preventDefault();e.stopPropagation()};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;if(this._isTouchDevice()){$columnCell.bind({click:function(e){self._touchStart(e,columnKey)}})}else{$theadCell=thead.find("#"+self.grid.element[0].id+"_"+columnKey);this.grid._enableHeaderCellFeature($theadCell);$headerContainer=$theadCell.find(".ui-iggrid-indicatorcontainer");if($headerContainer.length===0){$headerContainer=$("<div></div>").appendTo($theadCell).addClass("ui-iggrid-indicatorcontainer")}$button=$("<span></span>").appendTo($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(columnKey);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)}}},mousedown:function(event){self.toggleDropDown(columnKey);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()}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)},_renderMenu:function(columnKey){var i,data,self=this,listItems,popoverInstance,$targetButton,$headerCell=$("#"+this.grid.id()+"_"+columnKey),dropDownId=this._id("featureChooser_dd",columnKey),$dropDown=$("#"+dropDownId);if($dropDown.length>0){return}$dropDown=$('<div tabindex="0"></div>').attr("id",dropDownId).appendTo(this.grid._rootContainer());$targetButton=$("#"+this._id("featureChooser_headerButton",columnKey)).find("span");if($targetButton.length===0){$targetButton=$headerCell}$dropDown.igGridFeatureChooserPopover({position:"auto",targetButton:$targetButton,maxWidth:this.grid.container().width(),direction:"bottom",maxHeight:null,containment:this.grid.container()});popoverInstance=$dropDown.data("igGridFeatureChooserPopover");$dropDown.bind("iggridfeaturechooserpopovershown",function(events,args){self._visiblePopover=dropDownId});$dropDown.bind("iggridfeaturechooserpopoverhiding",function(events,args){if(self._activeSubmenuId){$("#"+self._activeSubmenuId).hide();self._activeSubmenuId=null}});data=this.data[columnKey];if(data){for(i=0;i<data.length;i++){this._renderDropDownItem(columnKey,data[i])}listItems=popoverInstance.container().find("li[data-fc-order]");$dropDown.igGridFeatureChooserPopover("registerElements",listItems);$targetButton.bind({keydown:function(e){if(e.keyCode===$.ui.keyCode.ESCAPE){popoverInstance._closePopover()}else if(e.keyCode===$.ui.keyCode.TAB&&!e.shiftKey&&popoverInstance.isShown()){popoverInstance.popover.find("li[data-fc-order]:first").focus();e.stopPropagation();e.preventDefault()}}});listItems.bind({keydown:function(e){var $elem,keyCode=e.keyCode;switch(keyCode){case $.ui.keyCode.ESCAPE:$targetButton.data("onFocus",false).focus();popoverInstance._closePopover();break;case $.ui.keyCode.TAB:$elem=$(this);if(!e.shiftKey){if($elem.is(":last-child")){$elem.closest("ul").find("li:first-child").focus();e.preventDefault()}}else{if($elem.is(":first-child")){$elem.closest("ul").find("li:last-child").focus();e.preventDefault()}}break;case $.ui.keyCode.RIGHT:$elem=$(this);$elem=$elem.nextAll("li[data-fc-order]").eq(0);if($elem.length===0){$elem=$(this).closest("ul").find("li:first-child")}$elem.focus();e.preventDefault();break;case $.ui.keyCode.LEFT:$elem=$(this);$elem=$elem.prevAll("li[data-fc-order]").eq(0);if($elem.length===0){$elem=$(this).closest("ul").find("li:last-child")}$elem.focus();e.preventDefault();break}}})}$dropDown.bind({keydown:function(event){if(event.keyCode===$.ui.keyCode.ESCAPE&&popoverInstance.container().is(":visible")){self.toggleDropDown(columnKey);popoverInstance.container().blur()}}})},_renderDropDownItem:function(columnKey,data){var dropDownId=this._id("featureChooser_dd",columnKey),$dropDownContainer=$("#"+dropDownId).igGridFeatureChooserPopover("container"),$li,listId,$list,funcClickOnFeature,$iconContainer,$span,cssClassIcon="",self=this,isSelected=data.isSelected,featureName=data.name,innerData,liId=this._id("featurechooser_dd_li_"+columnKey,featureName),groupName=data.groupName,groupOrder=data.groupOrder,listItemsGroup,insertElementObj,labelText;if($("#"+liId).length>0){return}if(groupName===undefined||groupName===null){groupName="click"}listId=this._id("featurechooser_dd_list",columnKey);$list=$("#"+listId);if($list.length===0){$dropDownContainer.html("");$list=$("<ul></ul>").attr("id",listId).addClass(this.css.listClass).appendTo($dropDownContainer)}if(isSelected===undefined||isSelected===null){isSelected=false}$li=$('<li tabindex="0"></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)}innerData={columnKey:columnKey,featureName:featureName,updateOnClickAll:data.updateOnClickAll,iconClass:data.iconClass,iconClassOff:data.iconClassOff,groupName:groupName,groupOrder:groupOrder,type:data.type,textHide:data.textHide,state:data.state,text:data.text};$li.data("data",innerData);funcClickOnFeature=function(event){var submenuId=self._id("featurechooser_submenu_"+columnKey,featureName),e=event,$submenu,keyCode=event.keyCode;if(data.type!=="dropdown"){if(!keyCode||keyCode===$.ui.keyCode.ENTER||keyCode===$.ui.keyCode.SPACE){if(event.target===undefined){e.target=event.srcElement}self._clickFeature(event);self.toggleDropDown(columnKey)}}else{if(self._visiblePopover){if(!keyCode){self._toggleSubmenu(columnKey,featureName,data);setTimeout(function(){$("#"+self._visiblePopover).data("igGridFeatureChooserPopover")._setFCElementFocus(true)},5)}else{if(keyCode===$.ui.keyCode.DOWN){$submenu=$("#"+submenuId);if($submenu.is(":visible")){$submenu.find("[data-fc-item]:first").focus()}else{self._toggleSubmenu(columnKey,featureName,data)}}else if(keyCode===$.ui.keyCode.ENTER||keyCode===$.ui.keyCode.SPACE){self._toggleSubmenu(columnKey,featureName,data)}else if(keyCode===$.ui.keyCode.UP){$submenu=$("#"+submenuId);if($submenu.is(":visible")){self._toggleSubmenu(columnKey,featureName,data)}}}}if(event.preventDefault){event.preventDefault()}}};$li.bind({keydown:funcClickOnFeature,mousedown:funcClickOnFeature});if(data.iconClass!==null&&data.iconClass!==undefined&&data.iconClass!==""){if(data.iconClassOff&&data.isSelected===false){cssClassIcon=data.iconClassOff}else{cssClassIcon=data.iconClass}}$iconContainer=$("<div></div>").addClass(this.css.listItemContainer).appendTo($li);$span=$("<span></span>").addClass(this.css.listItemIconContainer).appendTo($iconContainer);if(cssClassIcon!==""){$span.addClass(cssClassIcon)}else{$span.addClass(this.css.itemNoIcon)}labelText=data.text;$li.attr("title",labelText);$("<span></span>").text(data.text).addClass(this.css.listItemText).appendTo($iconContainer);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)}if(data.type==="dropdown"){$('<span class="'+this.css.submenuIcon+'" data-submenu-arrow="true"></span>').appendTo($iconContainer);self._renderSubmenu(columnKey,featureName,data)}},_renderSubmenu:function(columnKey,featureName,data){var submenuId=this._id("featurechooser_submenu_"+columnKey,featureName),$submenu;if($("#"+submenuId).length>0){$("#"+submenuId).remove()}if(this._submenus===null||this._submenus===undefined){this._submenus=[]}this._submenus.push(submenuId);$submenu=$('<div id="'+submenuId+'" style="position:absolute" class="'+this.css.submenu+'"></div>').appendTo(this.grid._rootContainer());$submenu.data("buttonId",this._id("featurechooser_dd_li_"+columnKey,featureName));$submenu.hide();if(data.methodRenderSubmenu){data.methodRenderSubmenu(columnKey,$submenu);$("#"+this._id("featureChooser_dd",columnKey)).igGridFeatureChooserPopover("registerElements",$submenu.find("[data-fc-item]"))}},_toggleSubmenu:function(columnKey,featureName,data){var rOffset,$li=$("#"+this._id("featurechooser_dd_li_"+columnKey,featureName)),$innerDiv=$li.find("div:nth-child(1)"),targetWidth=$innerDiv.outerWidth(),targetLeft=$innerDiv.offset().left,submenuId=this._id("featurechooser_submenu_"+columnKey,featureName),$submenu=$("#"+submenuId),left=targetLeft-Math.abs($submenu.outerWidth()-targetWidth)/2,top=$innerDiv.offset().top+$innerDiv.outerHeight();rOffset=$.ig.util.getRelativeOffset($submenu);$submenu.css({left:left-rOffset.left,top:top-rOffset.top});if(data.methodToggleSubmenu){data.methodToggleSubmenu(columnKey,!$submenu.is(":visible"),$submenu)}if(this._activeSubmenuId&&this._activeSubmenuId!==submenuId){$("#"+this._activeSubmenuId).hide()}this._activeSubmenuId=submenuId;$submenu.toggle("slide",{duration:150,direction:"up"})},_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,labelText,$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);labelText=textShow;if($label!==null&&textShow!==null&&textShow!==undefined){$label.text(labelText)}if(innerData.iconClassOff){$listItem.find("span.ui-iggrid-featurechooser-li-iconcontainer").removeClass(innerData.iconClassOff).addClass(innerData.iconClass)}}else{$listItem.removeClass(this.css.itemSelected);labelText=textHide;if($label!==null&&textHide!==null&&textHide!==undefined){$label.text(labelText)}if(innerData.iconClassOff){$listItem.find("span.ui-iggrid-featurechooser-li-iconcontainer").removeClass(innerData.iconClass).addClass(innerData.iconClassOff)}}$listItem.attr("title",labelText)},_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(columnKey){var dropDownId=this._id("featureChooser_dd",columnKey),$dropDown,$targetButton,isVisible,self=this;this._renderMenu(columnKey);$dropDown=$("#"+dropDownId);isVisible=$dropDown.igGridFeatureChooserPopover("isShown");self._trigger(self.events.menuToggling,null,{isVisible:isVisible,columnKey:columnKey,owner:self});if(isVisible){$dropDown.igGridFeatureChooserPopover("hide");this.grid._focusedElement=null}else{this.grid._focusedElement=$("#"+self._id("featureChooser_headerButton",columnKey)).find("span");$targetButton=$("#"+this._id("featureChooser_headerButton",columnKey)).find("span");if(self._visiblePopover&&dropDownId!==self._visiblePopover){$("#"+self._visiblePopover).data("igGridFeatureChooserPopover")._closePopover();setTimeout(function(){$dropDown.igGridFeatureChooserPopover("show",$targetButton)},100)}else{$dropDown.igGridFeatureChooserPopover("show",$targetButton)}}},_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 i,l,self=this,sbm=this._submenus;this.data=null;$.each(this.grid.options.columns,function(ind,column){var $dd=$("#"+self._id("featureChooser_dd",column.key));if($dd.length>0){$dd.igGridFeatureChooserPopover("destroy");$dd.remove()}});if(sbm){l=sbm.length;for(i=0;i<l;i++){$("#"+sbm[i]).remove()}}if(this._headerRenderedHandler){this.grid.element.unbind("iggridheaderrendered",this._headerRenderedHandler)}if(this._gridDestroyedHandler){this.grid.element.unbind("igcontroldestroyed",this._gridDestroyedHandler)}if(this._gridRenderedHandler){this.grid.element.unbind("iggridrendered",this._gridRenderedHandler)}delete this._gridRenderedHandler;delete this._headerRenderedHandler;delete this._gridDestroyedHandler;$.Widget.prototype.destroy.apply(this,arguments);return this}});$.extend($.ui.igGridFeatureChooser,{version:"14.1.20141.1020"})})(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,rOffset,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(this.gridContainer).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())}rOffset=$.ig.util.getRelativeOffset(block);block.css({left:pos.left-rOffset.left,top:pos.top-rOffset.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);rOffset=$.ig.util.getRelativeOffset(modalDialog);modalDialog.css({left:modalDialogLeft-rOffset.left,top:modalDialogTop-rOffset.top,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){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:"14.1.20141.1020"})})(jQuery);(function($){$(document).ready(function(){var wm=$("#__ig_wm__").length>0?$("#__ig_wm__"):$('<div id="__ig_wm__"></div>').appendTo(document.body);wm.css({position:"fixed",bottom:0,right:0,zIndex:1e3}).addClass("ui-igtrialwatermark")})})(jQuery);