/*!@license
* Infragistics.Web.ClientUI Combo 21.2.12
*
* Copyright (c) 2011-2022 Infragistics Inc.
*
* http://www.infragistics.com/
*
* Depends on:
* jquery.js
* jquery.ui.core.js
* jquery.ui.widget.js
* infragistics.templating.js
* infragistics.util.js
* infragistics.util.jquery.js
* infragistics.dataSource.js
* infragistics.ui.widget.js
*
* Example to use:
*   <script type="text/javascript">
*   $(function () {
*       $("#combo").igCombo();
*   });
*   </script>
*   <input id="combo" />
*/
"use strict";(function(factory){if(typeof define==="function"&&define.amd){define(["./infragistics.ui.widget","./infragistics.templating","./infragistics.datasource","./infragistics.ui.scroll","./infragistics.ui.validator"],factory)}else{return factory(jQuery)}})(function($){/*!@license
* Infragistics.Web.ClientUI Combo localization resources 21.2.12
*
* Copyright (c) 2011-2022 Infragistics Inc.
*
* http://www.infragistics.com/
*
*/
(function($){$.ig=$.ig||{};$.ig.locale=$.ig.locale||{};$.ig.locale.en=$.ig.locale.en||{};$.ig.Combo=$.ig.Combo||{};$.ig.locale.en.Combo={noMatchFoundText:"No matches found",dropDownButtonTitle:"Show drop-down",clearButtonTitle:"Clear value",placeHolder:"select...",notSuported:"Operation is not supported.",errorNoSupportedTextsType:"A different filtering text is required. Provide a value that is either a string or an array of strings.",errorUnrecognizedHighlightMatchesMode:"A different highlight matches mode is required. Choose a value between 'multi', 'contains', 'startsWith', 'full' and 'null'.",errorIncorrectGroupingKey:"Grouping key is not correct."};$.ig.Combo.locale=$.ig.Combo.locale||$.ig.locale.en.Combo;return $.ig.locale.en.Combo})($);$.widget("ui.igCombo",$.ui.igWidget,{options:{width:null,height:null,dropDownWidth:null,dataSource:null,dataSourceType:null,dataSourceUrl:null,responseTotalRecCountKey:null,responseDataKey:null,responseDataType:null,responseContentType:null,requestType:"GET",valueKey:null,textKey:null,itemTemplate:null,headerTemplate:null,footerTemplate:null,inputName:null,animationShowDuration:100,animationHideDuration:100,dropDownAttachedToBody:true,filteringType:"local",filterExprUrlKey:null,filteringCondition:"contains",filteringLogic:"OR",noMatchFoundText:undefined,dropDownButtonTitle:undefined,clearButtonTitle:undefined,placeHolder:undefined,locale:{noMatchFoundText:undefined,dropDownButtonTitle:undefined,clearButtonTitle:undefined,placeHolder:undefined},loadOnDemandSettings:{enabled:false,pageSize:16},visibleItemsCount:15,mode:"editable",virtualization:false,multiSelection:{enabled:false,addWithKeyModifier:false,showCheckboxes:false,itemSeparator:", "},grouping:{key:null,dir:"asc"},validatorOptions:null,highlightMatchesMode:"multi",caseSensitive:false,autoSelectFirstMatch:true,autoComplete:false,allowCustomValue:false,closeDropDownOnBlur:true,delayInputChangeProcessing:250,tabIndex:null,dropDownOnFocus:false,closeDropDownOnSelect:true,selectItemBySpaceKey:false,initialSelectedItems:[{index:-1,value:null}],preventSubmitOnEnter:true,format:"auto",suppressKeyboard:false,enableClearButton:true,dropDownOrientation:"auto"},events:{rendered:"rendered",dataBinding:"dataBinding",dataBound:"dataBound",filtering:"filtering",filtered:"filtered",itemsRendering:"itemsRendering",itemsRendered:"itemsRendered",dropDownOpening:"dropDownOpening",dropDownOpened:"dropDownOpened",dropDownClosing:"dropDownClosing",dropDownClosed:"dropDownClosed",selectionChanging:"selectionChanging",selectionChanged:"selectionChanged"},css:{comboWrapper:"ui-igcombo-wrapper",combo:"ui-igcombo ui-widget ui-state-default ui-corner-all ui-unselectable",dropDownMode:"ui-igcombo-mode-dropdown",readOnlyMode:"ui-igcombo-mode-readonly",readOnlyListMode:"ui-igcombo-mode-readonlylist",textBox:"ui-igcombo-textbox ui-state-default ui-corner-all",field:"ui-igcombo-field ui-corner-all",fieldHolder:"ui-igcombo-fieldholder",fieldHolderLTR:"ui-igcombo-fieldholder-ltr ui-corner-left",fieldHolderRTL:"ui-igcombo-fieldholder-rtl ui-corner-right",dropDownListRTL:"ig-rtl",button:"ui-igcombo-button ui-state-default ui-unselectable",buttonIcon:"ui-igcombo-buttonicon ui-icon-triangle-1-s ui-icon",buttonLTR:"ui-igcombo-button-ltr ui-corner-right",buttonRTL:"ui-igcombo-button-rtl ui-corner-left",clear:"ui-igcombo-clear ui-unselectable",clearRTL:"ui-igcombo-clear-rtl ui-unselectable",clearHover:"ui-igcombo-clear-hover ui-state-hover",clearIcon:"ui-igcombo-clearicon ui-icon-circle-close ui-icon",dropDown:"ui-igcombo-dropdown ui-widget ui-widget-content ui-corner-all",list:"ui-igcombo-list",listOverflow:"ui-igcombo-list-overflow",listItemHolder:"ui-igcombo-listitemholder",listItem:"ui-igcombo-listitem ui-state-default ui-unselectable",header:"ui-igcombo-header",footer:"ui-igcombo-footer",group:"ui-igcombo-group",groupHeader:"ui-igcombo-group-header ui-state-default ui-unselectable",itemInFocus:"ui-igcombo-item-in-focus",listItemHighlighted:"ui-igcombo-highlight",noMatchFound:"ui-igcombo-nomatchfound",listItemTextWithCheckbox:"ui-igcombo-listitemtextwithcheckbox",checkbox:"ui-igcombo-checkbox ui-state-default ui-corner-all ui-igcheckbox-small",checkboxOff:"ui-icon ui-igcombo-checkbox-off ui-igcheckbox-small-off",checkboxOn:"ui-icon ui-icon-check ui-igcombo-checkbox-on ui-igcheckbox-small-on",hiddenField:"ui-igcombo-hidden-field",hover:"ui-state-hover",active:"ui-state-active",unselectable:"ui-unselectable",noBorder:"ui-igcombo-no-border",scrollHolder:"ui-igcombo-scrollholder ui-unselectable",scroll:"ui-igcombo-scroll ui-unselectable",recordsView:"ui-igcombo-records-view",recordsData:"ui-igcombo-records-data",recordsServer:"ui-igcombo-records-server",recordsServerTotal:"ui-igcombo-records-server-total",loading:"ui-igcombo-loading",hidden:"ui-helper-hidden",disabled:"ui-state-disabled",orientationTop:"ui-igcombo-orientation-top",orientationBottom:"ui-igcombo-orientation-bottom"},RECORDS_VIEW:"{0}",RECORDS_DATA:"{1}",RECORDS_SERVER:"{2}",RECORDS_SERVER_TOTAL:"{3}",_createWidget:function(options){var mode;this._options={$window:$(window),$comboWrapper:null,$combo:null,$input:null,$hiddenInput:null,$fieldCont:null,$clearCont:null,$clearIcon:null,$dropDownBtnCont:null,$dropDownBtnIcon:null,$dropDownCont:null,$dropDownListCont:null,$dropDownList:null,$header:undefined,$footer:undefined,$dropDownScrollCont:null,$dropDownScroll:null,$loading:null,$noMatchFound:null,$itemsToSelectOnShiftUpDown:$(),$itemsToSelectOnShiftClick:$(),selectedData:[],keyNavItemData:null,autoSelectedItemData:null,autoCompleteItemData:null,inputVal:"",highlightElement:"span",ltr:true,dropDownOpened:false,deltaItemsForLoadOnDemand:5,dataBinding:false,shiftKeyCode:16,validator:null,shiftDown:false,nameAttribute:"",internalSelChangeSubs:[],initialDataBinding:true,remoteFilteringTriggerEvt:null,preventInputBlur:false,mouseDownStartedFromListItem:false,cachedData:[],strDataSource:null,updateInputValuesOnRemoteFilter:false,hasFooterVariables:false,hadInputSelectionOnKeydown:false,expression:null,preventItemSeparatorOnFocus:false,preventDropDownOnFocus:false,keyUpTimeout:null,repositionInterval:null,disableScroll:false,cachedGroupLength:null,dropDownModeSearchBy:"",dropDownModeSearchByResetTimeout:null,dropDownModeSearchByResetDelay:1e3,originalOptions:options,checkboxItemTemplate:"<span class='{css.checkbox}'>"+"<span class='{css.checkboxOff}''></span></span>"+"<div class='{css.listItemTextWithCheckbox}'>{innerMarkup}</div>",scrollCallback:null,closingDropDownOnBlur:false,composition:null};if(options){mode=options.mode;if(options.multiSelection&&options.multiSelection.enabled&&options.closeDropDownOnSelect===undefined){options.closeDropDownOnSelect=false}if(mode==="readonly"||mode==="readonlylist"||mode==="dropdown"&&!(options.multiSelection&&options.multiSelection.enabled)&&options.enableClearButton===undefined){options.enableClearButton=false}}this._superApply(arguments)},_create:function(){this._handlers={windowResize:$.proxy(this._windowResize,this),documentMouseUp:$.proxy(this._documentMouseUp,this),inputFocus:$.proxy(this._inputFocus,this),inputBlur:$.proxy(this._inputBlur,this),inputClick:$.proxy(this._inputClick,this),inputKeyDown:$.proxy(this._inputKeyDown,this),inputPaste:$.proxy(this._inputPaste,this),inputKeyUp:$.proxy(this._inputKeyUp,this),inputKeyPress:$.proxy(this._inputKeyPress,this),inputMouseDown:$.proxy(this._inputMouseDown,this),inputCompositionUpdate:$.proxy(this._inputCompositionUpdate,this),inputCompositionEnd:$.proxy(this._inputCompositionEnd,this),inputInput:$.proxy(this._inputInputHandler,this)};this._analyzeOptions();this._analyzeInitialElem();this._render();this.validator();this._attachEvents();this.dataBind();this._initCompositionObject()},_analyzeOptions:function(){var key,firstDataItem,options=this.options,$combo=$(this.element),lod=options.loadOnDemandSettings;if(this.options.dataSource){if($.isArray(this.options.dataSource)){firstDataItem=this.options.dataSource[0]}else if(this.options.dataSource&&typeof this.options.dataSource._xmlToArray==="function"&&typeof this.options.dataSource._encodePkParams==="function"){firstDataItem=this.options.dataSource.data()[0]}}if(options.mode!=="editable"&&options.mode!=="dropdown"&&options.mode!=="readonly"&&options.mode!=="readonlylist"){options.mode="editable"}if(lod&&lod.enabled&&lod.pageSize&&options.loadOnDemandSettings.pageSize<5){lod.pageSize=5}else if(lod&&lod.enabled&&!lod.pageSize){lod.pageSize=this.options.visibleItemsCount+1}if(!options.textKey){if(options.valueKey){options.textKey=options.valueKey}else if(firstDataItem&&$.type(firstDataItem)==="object"){for(key in firstDataItem){if(firstDataItem.hasOwnProperty(key)){options.textKey=key;break}}}}if(!options.valueKey){options.valueKey=options.textKey}if(!options.textKey&&!options.valueKey){options.textKey="text";options.valueKey="value"}if(options.filteringType!=="local"&&options.filteringType!=="remote"&&options.filteringType!=="none"){options.filteringType="none"}if($combo.attr("name")&&this._options.originalOptions.inputName===undefined){options.inputName=$combo.attr("name")}if($combo.attr("multiple")==="multiple"&&(this._options.originalOptions.multiSelection===undefined||this._options.originalOptions.multiSelection.enabled===undefined)){this.options.multiSelection.enabled=true}if($combo.attr("dir")==="rtl"){this._options.ltr=false}if(this.options.grouping.key&&firstDataItem&&firstDataItem[this.options.grouping.key]===undefined){throw new Error(this._getLocaleValue("errorIncorrectGroupingKey"))}},_analyzeInitialElem:function(){var element=this.element,_options=this._options;if(element.is("div")||element.is("span")){_options.$comboWrapper=element}else if(element.is("input")){_options.$input=element;_options.nameAttribute=element.attr("name");element.removeAttr("name")}else if(element.is("select")){element.hide();_options.nameAttribute=element.attr("name");element.removeAttr("name")}},_setupInput:function(){var _options=this._options;_options.$input.attr({placeholder:this._getLocaleValue("placeHolder"),"data-localeid":"placeHolder","data-localeattr":"placeholder"});if(this.options.mode!=="editable"){_options.$input.attr({readonly:true,unselectable:"on"}).addClass(this.css.unselectable)}},_renderHeaderTemplate:function(css,options,parent){var $header,headerClass,$existingHeader;headerClass="."+css.header;$existingHeader=parent.find(headerClass);if($existingHeader.length){if(typeof options.headerTemplate==="string"){$existingHeader.remove()}}$header=$("<div>").addClass(css.header).html(options.headerTemplate);$header.prependTo(parent);this._options.$header=$header},_renderFooterTemplate:function(css,options,parent,combo){var $footer,footerMarkup,footerClass,$existingFooter;footerClass="."+css.footer;$existingFooter=parent.find(footerClass);if($existingFooter.length){if(typeof options.footerTemplate==="string"){$existingFooter.remove()}}footerMarkup=options.footerTemplate.replace(combo.RECORDS_VIEW,"<span class="+css.recordsView+"></span>").replace(combo.RECORDS_DATA,"<span class="+css.recordsData+"></span>").replace(combo.RECORDS_SERVER,"<span class="+css.recordsServer+"></span>").replace(combo.RECORDS_SERVER_TOTAL,"<span class="+css.recordsServerTotal+"></span>");combo._options.hasFooterVariables=footerMarkup!==options.footerTemplate;if(combo._options.hasFooterVariables){$footer=$("<div>").addClass(css.footer).html(footerMarkup);$footer.appendTo(parent);combo._options.$footer=$footer;return}$footer=$("<div>").addClass(css.footer).html(footerMarkup);$footer.appendTo(parent);this._options.$footer=$footer},_render:function(){var css=this.css,options=this.options,_options=this._options,$comboWrapper=(_options.$comboWrapper||$("<div>")).addClass(css.comboWrapper),$combo=$("<div>").addClass(css.combo).attr("unselectable","on"),$input=(_options.$input||$("<input type='text'>")).addClass(css.field).attr({tabIndex:options.tabIndex,autocomplete:"off"}),$hiddenInput=$("<input type='hidden'>").addClass(css.hiddenField),$fieldCont=$("<div>").addClass(css.fieldHolder),$clearCont=$("<div>").addClass(css.clear).attr({unselectable:"on",title:this._getLocaleValue("clearButtonTitle"),"data-localeid":"clearButtonTitle","data-localeattr":"title"}),$clearIcon=$("<div>").addClass(css.clearIcon),$dropDownBtnCont=$("<div>").addClass(css.button).attr({unselectable:"on",title:this._getLocaleValue("dropDownButtonTitle"),"data-localeid":"dropDownButtonTitle","data-localeattr":"title"}),$dropDownBtnIcon=$("<div>").addClass(css.buttonIcon),$dropDownCont=$("<div>").addClass(css.dropDown).width(options.dropDownWidth),$dropDownListCont=$("<div>").addClass(css.list),$dropDownList=$("<ul>").addClass(css.listItemHolder),$dropDownScrollCont=$("<div>").addClass(css.scrollHolder).attr("unselectable","on"),$dropDownScroll=$("<div>").addClass(css.scroll).attr("unselectable","on"),$loading=$("<div>").addClass(css.loading);switch(options.mode){case"dropdown":$combo.addClass(css.dropDownMode);break;case"readonlylist":$combo.addClass(css.readOnlyListMode);break;case"readonly":$combo.addClass(css.readOnlyMode);$comboWrapper.addClass(css.disabled);break}$fieldCont.addClass(css.fieldHolderLTR);if(!_options.ltr){$dropDownList.addClass(css.dropDownListRTL);$dropDownBtnCont.addClass(css.buttonRTL);$clearCont.addClass(css.clearRTL)}else{$dropDownBtnCont.addClass(css.buttonLTR)}if(options.grouping.key){$dropDownList.addClass(css.group)}$clearIcon.appendTo($clearCont);$dropDownBtnIcon.appendTo($dropDownBtnCont);$dropDownList.appendTo($dropDownListCont);$dropDownListCont.appendTo($dropDownCont);if(typeof options.headerTemplate==="string"){this._renderHeaderTemplate(css,options,$dropDownCont)}if(typeof options.footerTemplate==="string"){this._renderFooterTemplate(this.css,this.options,$dropDownCont,this)}if(options.virtualization){$dropDownListCont.addClass(css.listOverflow);$dropDownScrollCont.insertBefore($dropDownList);$dropDownScroll.appendTo($dropDownScrollCont)}if(this.element.is("input")){$input.wrap($fieldCont);$fieldCont=$input.parent();$fieldCont.wrap($combo);$combo=$fieldCont.parent();$combo.wrap($comboWrapper);$comboWrapper=$combo.parent();$clearCont.prependTo($combo);$dropDownBtnCont.prependTo($combo)}else{$input.appendTo($fieldCont);$dropDownBtnCont.appendTo($combo);$clearCont.appendTo($combo);$fieldCont.appendTo($combo);$combo.appendTo($comboWrapper)}$clearCont.hide();$hiddenInput.attr("name",options.inputName).appendTo($combo);$dropDownCont.css({height:0,top:-99999,left:-99999,overflow:"hidden"}).addClass(css.noBorder);if(options.dropDownAttachedToBody){$dropDownCont.appendTo($("body"))}else{$dropDownCont.appendTo($comboWrapper)}if(this.element.is("select")){$comboWrapper.insertBefore(this.element)}$comboWrapper.outerWidth(options.width);$comboWrapper.outerHeight(options.height);_options.$comboWrapper=$comboWrapper;_options.$combo=$combo;_options.$input=$input;_options.$hiddenInput=$hiddenInput;_options.$fieldCont=$fieldCont;_options.$clearCont=$clearCont;_options.$clearIcon=$clearIcon;_options.$dropDownBtnCont=$dropDownBtnCont;_options.$dropDownBtnIcon=$dropDownBtnIcon;_options.$dropDownCont=$dropDownCont;_options.$dropDownListCont=$dropDownListCont;_options.$dropDownList=$dropDownList;_options.$loading=$loading;this._setInputVal($input.val());if(options.virtualization){_options.$dropDownScrollCont=$dropDownScrollCont;_options.$dropDownScroll=$dropDownScroll}this._setupInput();if(options.disabled){this._disableCombo(true)}this._triggerRendered()},_itemInnerMarkup:function(data){var unwrappedData,dataItem,unwrappedDataItem;unwrappedData=this._unwrapData(data);dataItem=unwrappedData[this.options.textKey];unwrappedDataItem=this._unwrapData(dataItem);unwrappedDataItem=this._formatItem(unwrappedDataItem);unwrappedDataItem=$.ig.encode(unwrappedDataItem);return this.options.itemTemplate?$.ig.tmpl(this.options.itemTemplate,data):unwrappedDataItem},_formatItem:function(item){if($.ig&&$.ig.formatter){if(this.options.format==="auto"&&($.type(item)==="date"||$.type(item)==="number")){item=$.ig.formatter({val:item,reg:$.ig.regional[this.options.regional]})}else if(this._formatEnabled()){item=$.ig.formatter({val:item,format:this.options.format,reg:$.ig.regional[this.options.regional]})}}return item},_formatEnabled:function(){return!(this.options.format===""||this.options.format===null||this.options.format==="none")},_itemsToRenderCount:function(){return this._isPossibleToVirtualize()?this.options.visibleItemsCount:this.options.dataSource.dataView().length},_sortDataSource:function(){var options=this.options;options.dataSource.sort([{fieldName:options.grouping.key}],options.grouping.dir)},_groups:function(data){var prevGroup,curGroup,curData,len,i,options=this.options,groupKey=options.grouping.key,groups=[];data=data||options.dataSource.dataView();for(i=0,len=data.length;i<len;i++){curData=data[i];if(curData[groupKey]===undefined){throw new Error(this._getLocaleValue("errorIncorrectGroupingKey"))}curGroup=curData[groupKey];if(prevGroup===curGroup){groups[groups.length-1].members.push(curData)}else{prevGroup=curGroup;groups[groups.length]={name:curGroup,members:[curData]}}}return groups},_itemMarkup:function(data){var css=this.css,value=this._unwrapData(this._unwrapData(data)[this.options.valueKey]),innerMarkup=this._itemInnerMarkup(data),markup,escapedValue;escapedValue=$.ig.encode(value);markup='<li class="'+css.listItem+'" data-value="'+escapedValue+'" unselectable="on">';if(this._checkBoxesEnabled()){markup+=this._options.checkboxItemTemplate.replace("{css.checkbox}",css.checkbox).replace("{css.checkboxOff}",css.checkboxOff).replace("{css.listItemTextWithCheckbox}",css.listItemTextWithCheckbox).replace("{innerMarkup}",innerMarkup)}else{markup+=innerMarkup}markup+="</li>";return markup},_itemsMarkup:function(){var i,dataView=this.options.dataSource.dataView(),dataLen=this._itemsToRenderCount(),markup="";for(i=0;i<dataLen;i++){markup+=this._itemMarkup(dataView[i])}return markup},_groupHeaderMarkup:function(groupName){return'<li class="'+this.css.groupHeader+'">'+groupName+"</li>"},_groupMarkup:function(group){var len,i,members=group.members,itemsMarkup="";for(i=0,len=members.length;i<len;i++){itemsMarkup+=this._itemMarkup(members[i])}return this._groupHeaderMarkup(group.name)+itemsMarkup},_groupsMarkup:function(){var groups,groupsLen,i,dataView,dataLen=this._itemsToRenderCount(),headers=1,markup="";this._sortDataSource();dataView=this.options.dataSource.dataView();if(this.options.virtualization&&!this._options.cachedGroupLength){this._options.cachedGroupLength=this._groups(dataView).length}dataView=dataView.slice(0,dataLen);groups=this._groups(dataView);if(this._isPossibleToVirtualize()){for(i=0;i<dataLen;i++){if(this._isBoundaryOfGroups(dataView,i)){headers++;i++}}dataView=dataView.slice(0,dataLen-headers);groups=this._groups(dataView)}for(i=0,groupsLen=groups.length;i<groupsLen;i++){markup+=this._groupMarkup(groups[i])}return markup},_noMatchMarkup:function(){return'<li unselectable="on" class="'+this.css.noMatchFound+" "+this.css.unselectable+'" data-localeid="noMatchFoundText">'+this._getLocaleValue("noMatchFoundText")+"</li>"},_renderItems:function(success,msg,data){var markup,dropDownScrollHeight,schema,noCancel,options=this.options,_options=this._options,lod=this.options.loadOnDemandSettings,dataView=data.dataView(),dataLen=this._itemsToRenderCount();if(success!==null){this._triggerDataBound(success,msg)}this._convertToArrayOfObjects(options);if(!options.dataSource.settings.schema&&options.dataSource&&dataView.length>0){schema=this._initSchema(this._unwrapData(dataView)[0]);options.dataSource.settings.schema=schema;options.dataSource._initSchema()}noCancel=this._triggerItemsRendering();if(noCancel){if(dataLen>0){if(options.grouping.key){markup=this._groupsMarkup()}else{markup=this._itemsMarkup()}}else{markup=this._noMatchMarkup()}_options.$dropDownList.html(markup);if(dataLen>0){this._setListContMaxHeight()}if(options.virtualization){dropDownScrollHeight=data.totalLocalRecordsCount()*this._itemHeight();_options.$dropDownScroll.height(dropDownScrollHeight);_options.$dropDownScrollCont.width($.ig.util.getScrollWidth()+1);this._updateVirtualScrollVisibility();if(lod&&lod.enabled&&lod.pageSize<=options.visibleItemsCount){_options.$dropDownScroll.height(dropDownScrollHeight+this._itemHeight());_options.$dropDownScrollCont.removeClass(this.css.hidden)}}this._updateFooterVariables();if(_options.initialDataBinding){this._handleInitialSelection();_options.initialDataBinding=false}this._triggerItemsRendered()}},_handleRemoteFiltering:function(success,msg,data){var $items,selectedData,_options=this._options,event=_options.remoteFilteringTriggerEvt;this._renderItems(success,msg,data);this.positionDropDown();$items=this._$items();selectedData=_options.selectedData;_options.selectedData=[];this._selectData(selectedData,{focusCombo:true,keepFiltering:true,keepInputText:true,keepNavItem:true});this._updateSelection(event);this._updateAutoComplete();if(_options.keyNavItemData&&!this._isDataSelected(_options.keyNavItemData)){this._setKeyNavigationItem({data:_options.keyNavItemData,addStyles:true,resetDataOnNonFound:true})}if(_options.updateInputValuesOnRemoteFilter){this._updateInputValues();this._updateHighlighting();_options.updateInputValuesOnRemoteFilter=false}if(_options.inputVal){this._showClearButton()}else{this._hideClearButton()}this._updateFooterVariables();if(_options.validator){_options.validator._validateInternal(this.element,event)}if(event){this._triggerFiltered(event);_options.remoteFilteringTriggerEvt=null}},_handleLocalFilteringWithVirt:function(data){var $items,selectedData,_options=this._options;this._renderItems(null,null,data);this.positionDropDown();$items=this._$items();selectedData=_options.selectedData;_options.selectedData=[];this._selectData(selectedData,{focusCombo:true,keepFiltering:true,keepInputText:true});this._updateHighlighting()},_handleLoadOnDemand:function(err,success,data){var $items,selectedData,_options=this._options;this._renderItems(err,success,data);this.positionDropDown();$items=this._$items();selectedData=_options.selectedData;_options.selectedData=[];this._selectData(selectedData,{focusCombo:true,keepFiltering:true,keepInputText:true,keepScrollPosition:true});this._updateHighlighting();if(this.options.multiSelection.enabled&&_options.keyNavItemData&&!this._isDataSelected(_options.keyNavItemData)){this._setKeyNavigationItem({data:_options.keyNavItemData,addStyles:true})}if(this.options.filteringType!=="remote"&&_options.expression){this._updateFiltering()}this._updateFooterVariables()},_updateGroupHeader:function($item,data){if(this.options.grouping.key&&this._isItem($item)){this._setVisualStylesToGroupHeader($item)}this._updateMarkupForGroupHeader($item,data);$item.attr("data-value",null);return this},_updateItem:function($item,data){var unwrappedDataItem,unwrappedDataValue,innerMarkup=this._itemInnerMarkup(data);if(this.options.grouping.key&&this._isGroupHeader($item)){this._setVisualStylesToItem($item);if(this._checkBoxesEnabled()){$item.html(this._options.checkboxItemTemplate.replace("{css.checkbox}",this.css.checkbox).replace("{css.checkboxOff}",this.css.checkboxOff).replace("{css.listItemTextWithCheckbox}",this.css.listItemTextWithCheckbox).replace("{innerMarkup}",""))}}this._updateMarkupForItem($item,innerMarkup);unwrappedDataItem=this._unwrapData(data);unwrappedDataValue=this._unwrapData(unwrappedDataItem[this.options.valueKey]);$item.attr("data-value",unwrappedDataValue);return this},_removePlaceholderOnEmptyTextVal:function(){var _options=this._options,placeholderAttr=_options.$input.attr("placeholder");if(_options.inputVal===""&&_options.selectedData.length>0&&(typeof placeholderAttr!==typeof undefined||placeholderAttr!==false)){_options.$input.removeAttr("placeholder")}},_addPlaceholderWhenEmptyTextVal:function(){var _options=this._options,placeholderAttr=_options.$input.attr("placeholder");if(_options.inputVal===""&&_options.selectedData.length===0&&(typeof placeholderAttr===typeof undefined||placeholderAttr===false)){_options.$input.attr({placeholder:this.options.placeHolder,"data-localeid":"placeHolder","data-localeattr":"placeholder"})}},_convertToArrayOfObjects:function(options){var curData,len,i,ds;if($.type(options.dataSource)==="object"&&(options.dataSource._data!==null&&options.dataSource._data!==undefined)){ds=options.dataSource._data}else{ds=options.dataSource}if($.type(ds)==="array"&&($.type(ds[0])==="number"||$.type(ds[0])==="string"||$.type(ds[0])==="date")){for(i=0,len=ds.length;i<len;i++){curData=ds[i];ds[i]={};ds[i][options.textKey]=curData;ds[i][options.valueKey]=curData}}},_isGroupHeader:function($item){return $item.hasClass(this.css.groupHeader)},_isItem:function($item){return $item.hasClass(this.css.listItem)},_setVisualStylesToGroupHeader:function($item){$item.removeClass(this.css.listItem);$item.addClass(this.css.groupHeader)},_setVisualStylesToItem:function($item){$item.removeClass(this.css.groupHeader);$item.addClass(this.css.listItem)},_updateMarkupForGroupHeader:function($item,data){if(this.options.grouping.key&&data[this.options.grouping.key]!==undefined){$item.html(data[this.options.grouping.key])}},_updateMarkupForItem:function($item,innerMarkup){var $listItem=$item;if(this._checkBoxesEnabled()){$listItem=$item.find("."+this.css.listItemTextWithCheckbox)}var templateItems=jQuery.parseHTML(innerMarkup);if(templateItems[0].nodeName!=="#text"){this._setItemHTML(templateItems,$listItem)}else{$listItem.html(innerMarkup)}},_setItemHTML:function(templateItems,$listItem){for(var i=0;i<templateItems.length;i++){var item=templateItems[i];if(item.childElementCount>0){this._setItemHTML(item.children,$listItem.children())}else{$listItem[0].children[i].defaultValue=item.defaultValue;$listItem[0].children[i].innerHTML=item.innerHTML}}},_$items:function(includeGroupHeaders){var selector="."+this.css.listItem.split(" ",1)[0];if(this.options.grouping.key&&includeGroupHeaders){selector+=",."+this.css.groupHeader.split(" ",1)[0]}return this._options.$dropDownList.children(selector)},_$noMatchFoundItem:function(){var selector="."+this.css.noMatchFound;return this._options.$dropDownList.children(selector)},_$filteredItems:function(){return this._$items().not("."+this.css.hidden)},_$elementFromData:function(data,$items){var curData,i,len,valueKey=this.options.valueKey,values=[];$items=$items||this._$items();if($.type(data)!=="array"){data=[data]}for(i=0,len=data.length;i<len;i++){curData=data[i];if(curData!==null&&curData!==undefined){values.push(curData[valueKey])}}return this._$elementFromValue(values,$items)},_$elementFromValue:function(value,$items){var i,currentValue,result=$();$items=$items||this._$items();if($.type(value)!=="array"){value=[value]}for(i=0;i<value.length;i++){currentValue=value[i];if(value[i]){currentValue=$.ig.util.escapeStr(value[i].toString())}result=result.add($items.filter("[ data-value='"+currentValue+"' ]"))}return result},_$elementsFromItems:function(items){var i,result=$();if($.type(items)!=="array"){items=[items]}for(i=0;i<items.length;i++){result=result.add(items[i].element)}return result},_$selectedItems:function(){var i,selItems=this.selectedItems(),$selItems=$(),len=selItems.length;for(i=0;i<len;i++){$selItems=$selItems.add(selItems[i].element)}return $selItems},_isDataEqual:function(data1,data2){var data1Value,data2Value;if(data1!==null&&data1!==undefined&&data2!==null&&data2!==undefined){data1Value=this._unwrapData(this._unwrapData(data1)[this.options.valueKey]);data2Value=this._unwrapData(this._unwrapData(data2)[this.options.valueKey]);return data1Value===data2Value}return false},_isDataSelected:function(data){return this.isValueSelected(data[this.options.valueKey])},_filterData:function(data1,data2){var data2Len,self=this;if($.type(data1)!=="array"){data1=[data1]}if($.type(data2)!=="array"){data2=[data2]}data2Len=data2.length;return data1.filter(function(data){var i;for(i=0;i<data2Len;i++){if(self._isDataEqual(data,data2[i])){return false}}return true})},_filterItems:function(items1,items2){var result,valKey=this.options.valueKey,self=this;result=items1.filter(function(item){var i,unwrappedDataItem,unwrappedDataValue,unwrappedDataItemToCompare,unwrappedDataValueToCompare,matchFound=false;unwrappedDataItem=self._unwrapData(item.data);unwrappedDataValue=self._unwrapData(unwrappedDataItem[valKey]);for(i=0;i<items2.length&&!matchFound;i++){unwrappedDataItemToCompare=self._unwrapData(items2[i].data);unwrappedDataValueToCompare=self._unwrapData(unwrappedDataItemToCompare[valKey]);if(unwrappedDataValue===unwrappedDataValueToCompare){matchFound=true}}return!matchFound});return result},_valuesFromData:function(data){var unwrappedDataItem,unwrappedDataValue,i,len=data.length,valKey=this.options.valueKey,values=[];for(i=0;i<len;i++){unwrappedDataItem=this._unwrapData(data[i]);unwrappedDataValue=this._unwrapData(unwrappedDataItem[valKey]);values.push(unwrappedDataValue)}return values},_valuesFromElements:function($items){var i,values=[];for(i=0;i<$items.length;i++){values.push($items.eq(i).attr("data-value"))}return values},_valuesFromItems:function(item){var i,unwrappedDataItem,unwrappedDataValue,values=[],valueKey=this.options.valueKey;if(!item){return}if($.type(item)!=="array"){item=[item]}for(i=0;i<item.length;i++){unwrappedDataItem=this._unwrapData(item[i].data);unwrappedDataValue=this._unwrapData(unwrappedDataItem[valueKey]);values.push(unwrappedDataValue)}return values},_dataFromItems:function(items){var len,i,data=[];for(i=0,len=items.length;i<len;i++){data.push(items[i].data)}return data},_dataFromIndex:function(index){var data=this.options.dataSource.data();return data.length>index?data[index]:null},_dataForValues:function(value){var data,i,len,result=[];if($.type(value)!=="array"){value=[value]}for(i=0,len=value.length;i<len;i++){data=this.dataForValue(value[i]);if(data!==null){result.push(data)}}return result},_dataIndexByValue:function(value,searchDataViewOnly){var unwrappedDataItem,unwrappedDataValue,i,result=-1,data=searchDataViewOnly?this.options.dataSource.dataView():this.options.dataSource.data(),len=data.length,valKey=this.options.valueKey;for(i=0;i<len;i++){unwrappedDataItem=this._unwrapData(data[i]);unwrappedDataValue=this._unwrapData(unwrappedDataItem[valKey]);if(this._areValuesEqual(unwrappedDataValue,value)){result=i;break}}return result},_itemsFromData:function(data){var curData,len,i,$items=this._$items(),result=[];if($.type(data)!=="array"){data=[data]}for(i=0,len=data.length;i<len;i++){curData=data[i];if(curData!==null&&curData!==undefined){result.push({element:this._$elementFromData(curData,$items),data:curData})}}return result.length>0?result:null},_$keyNavItem:function(){return this._$elementFromData(this._options.keyNavItemData)},_updateFooterVariables:function(){var ds,recordsView,recordsData,recordsServer,recordsServerTotal;if(this._options.hasFooterVariables){ds=this.options.dataSource;recordsView=ds.dataView().length;recordsData=ds.data().length;recordsServer=Math.max(ds.totalRecordsCount(),recordsData);recordsServerTotal=Math.max(recordsServer,parseInt(this._options.totalAll||0,10));this._options.$footer.find("."+this.css.recordsView).html(recordsView);this._options.$footer.find("."+this.css.recordsData).html(recordsData);this._options.$footer.find("."+this.css.recordsServer).html(recordsServer);this._options.$footer.find("."+this.css.recordsServerTotal).html(recordsServerTotal)}},_moveCaretToInputEnd:function(preventItemSeparatorOnFocus){var range,input=this._options.$input[0],readonly=this._options.$input.attr("readonly");if(document.activeElement===input){return}if(readonly&&!($.ig.util.isEdge||$.ig.util.isIE)){this._options.$input.removeAttr("readonly")}this._safeFocusInput(preventItemSeparatorOnFocus);if(typeof input.selectionStart==="number"&&!$.ig.util.isIE&&!$.ig.util.isEdge){if(!this._options.ltr&&this._options.selectedData.length>0){input.selectionStart=input.selectionEnd=this._options.selectedData[this._options.selectedData.length-1][this.options.textKey].length;
}else{input.selectionStart=input.selectionEnd=input.value.length}}else if(typeof input.createTextRange!=="undefined"&&$(input).is(":visible")&&!readonly){range=input.createTextRange();range.collapse(false);range.select()}if(readonly){this._options.$input.attr("readonly",readonly)}},_refreshVisualStylesForItem:function($item,data){var isSelected=this._isDataSelected(data);if(isSelected){this._addItemSelectionStyles($item)}else{this._removeItemSelectionStyles($item)}if(this.options.multiSelection.enabled){if(this._isDataEqual(this._options.keyNavItemData,data)&&!isSelected){$item.addClass(this.css.itemInFocus)}else{$item.removeClass(this.css.itemInFocus)}}},_handleInitialSelection:function(){var curSelItem,selectOptions,selectedOptions,curIndex,i,curDataItem,selItems=this.options.initialSelectedItems,data=this.options.dataSource.data(),dataToSel=[],mode=this.options.mode;if($.type(selItems)==="array"){for(i=0;i<selItems.length;i++){curSelItem=selItems[i];curIndex=curSelItem.index;if(curIndex>=0&&data.length>=curIndex){curDataItem=data[curIndex]}else if(curSelItem.value!==undefined&&curSelItem.value!==null){curDataItem=this.dataForValue(curSelItem.value)}if(curDataItem&&dataToSel.indexOf(curDataItem)===-1){dataToSel.push(curDataItem)}}}if(this.element.is("select")){selectOptions=this.element.find("option");selectedOptions=selectOptions.filter(":selected");for(i=0;i<selectedOptions.length;i++){dataToSel.push(data[selectOptions.index(selectedOptions.eq(i))])}}this._selectFirstItemInNonEditableModes(mode,dataToSel,data)},_selectFirstItemInNonEditableModes:function(mode,dataToSel,data){if((mode==="dropdown"&&!this.options.multiSelection.enabled||mode==="readonly"||mode==="readonlylist")&&dataToSel.length===0){if(data[0]!==null&&data[0]!==undefined){dataToSel.push(data[0])}}if(dataToSel.length>0){this._selectData(dataToSel,{additive:true,keepScrollPosition:true})}},_checkBoxesEnabled:function(){return this.options.multiSelection.enabled&&this.options.multiSelection.showCheckboxes},_isPossibleToVirtualize:function(){return this.options.virtualization&&this.options.dataSource.dataView().length>this.options.visibleItemsCount},_areItemsLowerInVir:function(){return this.options.virtualization&&this.options.dataSource.dataView().length<=this.options.visibleItemsCount},_itemHeight:function(){return this._$items().first().outerHeight()},_isFilteringEnabled:function(){return this.options.filteringType!=="none"},_updateItems:function(offset){var elementIndex,lengthOfElements,itemIndex,$this,curData,self=this,options=this.options,dataView=options.dataSource.dataView(),$items=this._$items(true),realOffset=0;offset=offset>0?offset:0;this._unhighlight();for(elementIndex=0,itemIndex=0,lengthOfElements=$items.length;elementIndex<lengthOfElements;elementIndex++){$this=$items.eq(elementIndex);realOffset=itemIndex+offset;curData=dataView[realOffset];if(curData&&this.options.grouping.key&&(self._isBoundaryOfGroups(dataView,realOffset)||self._isFirstItem(dataView,realOffset))){this._updateGroupHeader($this,curData)._refreshVisualStylesForItem($this,curData[options.grouping.key]);elementIndex++;$this=$items.eq(elementIndex)}if($this){this._updateItem($this,curData)._refreshVisualStylesForItem($this,curData)}itemIndex++}this._updateHighlighting()},_isFirstItem:function(data,itemIndex){if(!data[itemIndex-1]){return true}return false},_isBoundaryOfGroups:function(data,itemIndex){if(this.options.grouping.key&&data[itemIndex-1]&&data[itemIndex-1][this.options.grouping.key]!==data[itemIndex][this.options.grouping.key]){return true}return false},_toggleDropDownState:function(event){if(this._options.dropDownOpened){this.closeDropDown(null,event)}else{this.openDropDown(null,this._focusInInputWhenUsingTouchDevice(),event)}},_lastValAfterItemSep:function(){return this._options.inputVal.split(this.options.multiSelection.itemSeparator).pop()},_startsWith:function(text,fragment){return fragment!==""&&text.indexOf(fragment)===0},_endsPartialyWithItemSep:function(text){var separator=this.options.multiSelection.itemSeparator,i=separator.length,matchFound=0;for(;i>0&&!matchFound;i--){if(text.endsWith(separator.slice(0,i))){matchFound=i}}return matchFound},_filterItemSeparator:function(text){return text.slice(0,text.length-this._endsPartialyWithItemSep(text))},_separatedInputTexts:function(){var result=this._options.inputVal.split(this.options.multiSelection.itemSeparator);result[result.length-1]=this._filterItemSeparator(result[result.length-1]);return result},_updateSelection:function(event){var textsLen,dataLen,curText,curData,curDataValue,curDataText,setAsKeyNav,matchFound,isLastText,unwrappedData,i,j,options=this.options,_options=this._options,texts=_options.inputVal,data=options.dataSource.data(),textKey=options.textKey,valueKey=options.valueKey,justSelectedData=[],multiSelect=options.multiSelection.enabled;if(options.filteringType==="remote"){data=this._filterData(_options.cachedData,data).concat(data)}dataLen=data.length;if(multiSelect){texts=this._separatedInputTexts(texts)}else{texts=[texts]}if(options.autoSelectFirstMatch){_options.autoSelectedItemData=null}unwrappedData=this._unwrapData(data);for(i=0,textsLen=texts.length;i<textsLen;i++){curText=texts[i];matchFound=false;isLastText=i===textsLen-1;if(!options.caseSensitive){curText=curText.toLowerCase()}for(j=0;j<dataLen&&!matchFound;j++){curData=this._unwrapData(unwrappedData[j]);curDataText=this._unwrapData(curData[textKey]).toString();curDataValue=this._unwrapData(curData[valueKey]);setAsKeyNav=isLastText&&!this.isValueSelected(curDataValue);if(!options.caseSensitive){curDataText=curDataText.toLowerCase()}if(options.autoSelectFirstMatch){if(this._startsWith(curDataText,curText)){if(multiSelect){if(this._filterData(curData,justSelectedData).length===1){if(setAsKeyNav){this._setKeyNavigationItem({data:curData,addStyles:true,clearPrevItem:true,scrollToItem:true})}else{this._selectData(curData,{additive:true,focusCombo:true,keepInputText:true,keepHighlighting:true,keepFiltering:true},event)}matchFound=true;if(curDataText!==curText){_options.autoSelectedItemData=curData}}if(!setAsKeyNav){justSelectedData.push(curData)}}else{this._selectData(curData,{focusCombo:true,keepInputText:true,keepHighlighting:true,keepFiltering:true},event);_options.autoSelectedItemData=curData;matchFound=true;justSelectedData.push(curData)}}}else if(curDataText===curText){if(multiSelect){if(this._filterData(curData,justSelectedData).length===1){if(setAsKeyNav){this._setKeyNavigationItem({data:curData,addStyles:true,clearPrevItem:true,scrollToItem:true})}else{this._selectData(curData,{additive:true,focusCombo:true,keepInputText:true,keepHighlighting:true,keepFiltering:true},event)}matchFound=true}if(!setAsKeyNav){justSelectedData.push(curData)}}else{this._selectData(curData,{additive:true,focusCombo:true,keepInputText:true,keepHighlighting:true,keepFiltering:true},event);matchFound=true;justSelectedData.push(curData)}}}}this._deselectData(this._filterData(_options.selectedData,justSelectedData),{focusCombo:true,keepInputText:true},event);if(multiSelect&&_options.inputVal.endsWith(options.multiSelection.itemSeparator)){this._updateInputValues(false)}this._updateHighlighting()},_updateAutoComplete:function(){var text,curData,curDataText,unwrappedData,i,options=this.options,_options=this._options,texts=_options.inputVal,data=options.dataSource.data(),dataLen=data.length,textKey=options.textKey,multiSelect=options.multiSelection.enabled;if(multiSelect){texts=this._options.inputVal.split(options.multiSelection.itemSeparator)}else{texts=[texts]}if(texts.length>this._fullySelectedItemsLen()){text=texts[texts.length-1];if(multiSelect&&this._endsPartialyWithItemSep(text)){return}if(!options.caseSensitive){text=text.toLowerCase()}if(_options.autoSelectedItemData){_options.autoCompleteItemData=_options.autoSelectedItemData;this._autoComplete(_options.autoCompleteItemData[textKey].toString().slice(text.length))}else{for(i=0;i<dataLen;i++){unwrappedData=this._unwrapData(data);curData=this._unwrapData(unwrappedData[i]);curDataText=this._unwrapData(curData[textKey]).toString();if(!options.caseSensitive){curDataText=curDataText.toLowerCase()}if(!(curData!==_options.autoSelectedItemData&&this._isDataSelected(curData))&&this._startsWith(curDataText,text)){_options.autoCompleteItemData=curData;this._autoComplete(this._unwrapData(curData[textKey]).toString().slice(text.length));break}}}}},_autoComplete:function(autoCompleteText){var oldInputVal,newInputVal;if(this.options.autoComplete&&this._options.composition.isAutocompleteNeeded()){oldInputVal=this._options.inputVal;newInputVal=oldInputVal+autoCompleteText;this._options.composition.autocompleteText=autoCompleteText;this._options.composition.inputVal=oldInputVal;this._options.$input.val(newInputVal);this._setInputSelection(oldInputVal.length,newInputVal.length)}},_setInputSelection:function(start,end){var selRange,field=this._options.$input[0];if(field.createTextRange){selRange=field.createTextRange();selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();field.focus()}else if(field.setSelectionRange){field.focus();field.setSelectionRange(start,end)}else if(typeof field.selectionStart!=="undefined"){field.selectionStart=start;field.selectionEnd=end;field.focus()}},_hasInputSelection:function(){var field=this._options.$input[0],result=false;if(typeof field.selectionStart!=="undefined"){result=field.selectionStart!==field.selectionEnd}return result},_scrollToItem:function(data){var listContHeight,listContTop,listContScrollTop,itemTop,itemHeight,itemIndex,$item=this._$elementFromData(data);if(this._options.dropDownOpened){if($item.length>0){listContHeight=this._options.$dropDownListCont.height();listContTop=this._options.$dropDownListCont.igOffset().top;listContScrollTop=this.listScrollTop();itemTop=$item.igOffset().top;itemHeight=$item.outerHeight();if(!(itemTop>listContTop&&itemTop+itemHeight<listContHeight+listContTop)){this.listScrollTop(itemTop+listContScrollTop+itemHeight-listContTop-listContHeight)}}else if(this.options.virtualization){itemIndex=this._dataIndexByValue(data[this.options.valueKey]);this.listScrollTop((itemIndex-this.options.visibleItemsCount+2)*this._itemHeight())}}},_scrollToLastSelItem:function(){if(this._options.keyNavItemData!==null){this._scrollToItem(this._options.keyNavItemData)}else if(this._options.selectedData.length>0){this._scrollToItem(this._options.selectedData[this._options.selectedData.length-1])}},_positionItemInVisibleArea:function($item){var $listCont=this._options.$dropDownListCont,listContHeight=$listCont.height(),listContTop=$listCont.igOffset().top,listContScrollTop=this.listScrollTop(),itemTop=$item.igOffset().top,itemHeight=$item.outerHeight(true);if(listContTop>itemTop){this.listScrollTop(this._$items().filter(":visible").index($item)*itemHeight)}if(itemTop+itemHeight>listContHeight+listContTop){this.listScrollTop(itemTop+itemHeight+listContScrollTop-listContHeight-listContTop)}},_setKeyNavigationItem:function(options){var $item,$prevKeyNavItem,data=options.data,addStyles=options.addStyles,clearPrevItem=options.clearPrevItem,scrollToItem=options.scrollToItem,resetDataOnNonFound=options.resetDataOnNonFound;if(data instanceof $){$item=data;data=this.dataForValue($item.attr("data-value"))}else{$item=this._$elementFromData(data)}if(clearPrevItem){$prevKeyNavItem=this._$elementFromData(this._options.keyNavItemData);if($prevKeyNavItem.length>0){$prevKeyNavItem.removeClass(this.css.itemInFocus)}}if(addStyles&&$item.length>0){$item.addClass(this.css.itemInFocus)}if($item.length===0&&resetDataOnNonFound){this._options.keyNavItemData=null}else{this._options.keyNavItemData=data}if(scrollToItem){this._scrollToItem(data)}},_navigateToItem:function($item,addStyles,clearPrevItem,event,keepScrollPosition){if($item.length===0){return}if(!this.options.multiSelection.enabled){this.select($item,{focusCombo:true,keepFiltering:true,keepScrollPosition:keepScrollPosition},event)}else{this._setKeyNavigationItem({data:$item,addStyles:addStyles,clearPrevItem:clearPrevItem})}this._positionItemInVisibleArea($item)},_prevVisibleItem:function($item){do{$item=$item.prev()}while($item.length>0&&(!$item.is("."+this.css.listItem.split(" ",1)[0])||!$item.is(":visible")));return $item},_nextVisibleItem:function($item){do{$item=$item.next()}while($item.length>0&&(!$item.is("."+this.css.listItem.split(" ",1)[0])||!$item.is(":visible")));return $item},_visibleItemByIndex:function(index){return this._$items().filter(":visible").eq(index)},_handleInputChange:function(openDropDown,event){var options=this.options,_options=this._options,curVal=_options.$input.val();if(options.autoComplete&&event&&event.which===8&&_options.hadInputSelectionOnKeydown){curVal=curVal.slice(0,curVal.length-1);_options.$input.val(curVal)}if(options.autoComplete&&this._hasInputSelection()){return}if(curVal!==_options.inputVal){this._setInputVal(curVal);if(options.filteringType==="remote"){this._updateFiltering(event)}else{if(options.filteringType==="local"){_options.disableScroll=true;this._updateFiltering(event);setTimeout(function(){_options.disableScroll=false},0)}if(curVal){this._showClearButton()}else{this._hideClearButton()}this._updateSelection(event);this._updateAutoComplete();if(_options.validator){_options.validator._validateInternal(this.element,event)}}if(openDropDown){this.openDropDown(null,false,event)}}},_handleShiftNavigation:function($itemToNavigate,event){var _options=this._options,$keyNavItem=this._$keyNavItem();if($itemToNavigate.is(_options.$itemsToSelectOnShiftUpDown)){$keyNavItem.removeClass(this.css.itemInFocus);_options.$itemsToSelectOnShiftUpDown=_options.$itemsToSelectOnShiftUpDown.not($keyNavItem)}else{$itemToNavigate.addClass(this.css.itemInFocus);_options.$itemsToSelectOnShiftUpDown=_options.$itemsToSelectOnShiftUpDown.add($itemToNavigate)}this._navigateToItem($itemToNavigate,false,false,event)},_handleShiftUp:function(event){var _options=this._options;if(_options.$itemsToSelectOnShiftUpDown.length>1){this.select(_options.$itemsToSelectOnShiftUpDown,{additive:true,focusCombo:true,keepNavItem:true,keepFiltering:true},event);_options.$itemsToSelectOnShiftUpDown.removeClass(this.css.itemInFocus)}_options.$itemsToSelectOnShiftUpDown=$();_options.shiftDown=false},_handleShiftClick:function(event){var _options=this._options;if(_options.$itemsToSelectOnShiftClick.length>1){this.select(_options.$itemsToSelectOnShiftClick,{additive:true,focusCombo:true,keepNavItem:true,keepFiltering:true},event);_options.$itemsToSelectOnShiftClick.removeClass(this.css.itemInFocus);this._setKeyNavigationItem({data:$(event.target),clearPrevItem:true})}_options.$itemsToSelectOnShiftClick=$()},_groupHeaderClass:function(){return"."+this.css.groupHeader.split(" ",1)[0]},_$groupHeaders:function(){return this._$items(true).filter(this._groupHeaderClass())},_handleKeyNavigation:function(event){var $item,index,multiSelect,closeDropDown,isAutoSelectedActive,$lastSelectedItem,visibleItemsCount,self=this,options=this.options,_options=this._options,lod=this.options.loadOnDemandSettings,multiSelection=options.multiSelection.enabled,$keyNavItem=this._$keyNavItem(),$visibleItems=this._$items().filter(":visible"),currentScrollTop=this.listScrollTop(),activeIndex=this.activeIndex(),itemHeight=this._itemHeight(),addScrollCallback=false;if(event.keyCode===$.ui.keyCode.ESCAPE){if(options.multiSelection.enabled){if(this._lastValAfterItemSep().length===0){this.closeDropDown(null,event)}else{this._updateInputValues();this.clearFiltering(event);this._unhighlight()}}else{if(_options.inputVal.length===0){this.closeDropDown(null,event)}else if(_options.selectedData.length===0){this._updateInputValues();this.clearFiltering(event);this._unhighlight()}else if(_options.autoSelectedItemData){this._deselectData(_options.autoSelectedItemData,null,event);this.clearFiltering(event);this._unhighlight()}else{this.closeDropDown(null,event)}}event.preventDefault()}if(event.keyCode===$.ui.keyCode.DOWN){if(event.altKey||!_options.dropDownOpened){this.openDropDown(null,true,event)}else{$item=$keyNavItem.length>0?this._nextVisibleItem($keyNavItem):$visibleItems.eq(0);if(event.shiftKey&&multiSelection&&_options.dropDownOpened){this._handleShiftNavigation($item,event)}else{this._navigateToItem($item,true,true,event)}visibleItemsCount=options.visibleItemsCount-1;if(options.grouping){visibleItemsCount-=this._$groupHeaders().length}if(options.virtualization&&activeIndex>=visibleItemsCount){this.listScrollTop(currentScrollTop+itemHeight+1)}if(options.virtualization&&lod&&lod.enabled&&this.activeIndex()+1===this.listItems().length&&this.listItems().length<options.visibleItemsCount){self._callNextChunk(_options.$dropDownListCont,self._itemHeight())}}event.preventDefault()}if(event.keyCode===$.ui.keyCode.UP){if(_options.dropDownOpened){if(event.altKey||$keyNavItem.length===0||this._isDataEqual(_options.keyNavItemData,options.dataSource.dataView()[0])){this.closeDropDown(null,event)}else{$item=this._prevVisibleItem($keyNavItem);if(event.shiftKey&&multiSelection&&_options.dropDownOpened){this._handleShiftNavigation($item,event)}else{this._navigateToItem($item,true,true,event)}if(options.virtualization&&activeIndex-1<0){this.listScrollTop(currentScrollTop-itemHeight-1)}}}event.preventDefault()}if(event.keyCode===$.ui.keyCode.ENTER||options.selectItemBySpaceKey&&event.keyCode===$.ui.keyCode.SPACE){if(event.shiftKey&&_options.$itemsToSelectOnShiftUpDown.length===1){$lastSelectedItem=this._$elementFromData(_options.selectedData[_options.selectedData.length-1]);this.select(this._itemsBetweenTwoItems($keyNavItem,$lastSelectedItem),{additive:true})}else{isAutoSelectedActive=$keyNavItem.is(_options.$autoSelectedItem);multiSelect=multiSelection&&(!options.multiSelection.addWithKeyModifier||event.ctrlKey||isAutoSelectedActive);if(multiSelect&&this.isSelected($keyNavItem)&&!isAutoSelectedActive){this._deselectData(_options.keyNavItemData,{focusCombo:true},event)}else{closeDropDown=multiSelect?false:options.closeDropDownOnSelect;if(options.autoComplete&&$keyNavItem.length===0&&_options.autoCompleteItemData){this._selectData(_options.autoCompleteItemData,{additive:multiSelect,closeDropDown:closeDropDown,focusCombo:true},event)}else{this._selectData(_options.keyNavItemData,{additive:multiSelect,closeDropDown:closeDropDown,focusCombo:true},event)}}}if(event.keyCode===$.ui.keyCode.ENTER&&options.preventSubmitOnEnter||event.keyCode===$.ui.keyCode.SPACE){event.preventDefault()}}if(event.keyCode===$.ui.keyCode.HOME&&event.ctrlKey&&_options.dropDownOpened){if(options.virtualization){this.listScrollTop(0);addScrollCallback=true}if(addScrollCallback){this._options.scrollCallback=function(){self._navigateToItem($visibleItems.first(),true,true,event)}}else{this._navigateToItem($visibleItems.first(),true,true,event)}event.preventDefault()}if(event.keyCode===$.ui.keyCode.END&&event.ctrlKey&&_options.dropDownOpened){if(options.virtualization){this.listScrollTop(this.options.dataSource.totalLocalRecordsCount()*itemHeight);addScrollCallback=true}if(addScrollCallback){this._options.scrollCallback=function(){self._navigateToItem($visibleItems.last(),true,true,event)}}else{this._navigateToItem($visibleItems.last(),true,true,event)}event.preventDefault()}if(event.keyCode===$.ui.keyCode.PAGE_UP&&_options.dropDownOpened){index=-options.visibleItemsCount+1;if($keyNavItem.length>0){index+=$visibleItems.index($keyNavItem)}if(index<0){if(options.virtualization&&currentScrollTop>0){this.listScrollTop(currentScrollTop+itemHeight*index);addScrollCallback=true}index=0}if(addScrollCallback){this._options.scrollCallback=function(){self._navigateToItem($visibleItems.eq(index),true,true,event,true)}}else{this._navigateToItem($visibleItems.eq(index),true,true,event,true)}event.preventDefault()}if(event.keyCode===$.ui.keyCode.PAGE_DOWN&&_options.dropDownOpened){index=options.visibleItemsCount-1;if($keyNavItem.length>0){index+=$visibleItems.index($keyNavItem)}if(index>$visibleItems.length-1){if(options.virtualization){index-=options.visibleItemsCount-1;this.listScrollTop(currentScrollTop+itemHeight*index);addScrollCallback=currentScrollTop<this.listScrollTop()}index=$visibleItems.length-1}if(addScrollCallback){this._options.scrollCallback=function(){self._navigateToItem($visibleItems.eq(index),true,true,event)}}else{this._navigateToItem($visibleItems.eq(index),true,true,event)}event.preventDefault()}if(event.keyCode===_options.shiftKeyCode&&multiSelection&&_options.dropDownOpened&&!_options.shiftDown){_options.shiftDown=true;_options.$itemsToSelectOnShiftUpDown=$keyNavItem;$keyNavItem.addClass(this.css.itemInFocus)}},_dropDownContHeight:function(){var _options=this._options,dropDownContainerHeight=parseInt(_options.$dropDownListCont.outerHeight(true),10);if(_options.$header!==undefined){dropDownContainerHeight+=_options.$header.outerHeight(true)}if(_options.$footer!==undefined){dropDownContainerHeight+=_options.$footer.outerHeight(true)}return dropDownContainerHeight},_itemsBetweenTwoItems:function($item1,$item2){var firstIndex,sndIndex,temp,$items=this._$items(),$result=$();firstIndex=$items.index($item1);sndIndex=$items.index($item2);if(firstIndex>sndIndex){temp=firstIndex;firstIndex=sndIndex;sndIndex=temp}for(;firstIndex<=sndIndex;firstIndex++){$result=$result.add(this._visibleItemByIndex(firstIndex))}return $result},_safeFocusInput:function(preventItemSeparatorOnFocus){var $input=this._options.$input,input=$input[0];this._options.preventDropDownOnFocus=true;this._options.preventItemSeparatorOnFocus=preventItemSeparatorOnFocus;if(!$input.is(":focus")){input.focus()}else{$input.focus()}},_windowResize:function(){this.positionDropDown()},_documentMouseUp:function(){var _options=this._options;if(_options.$itemsToSelectOnShiftClick.length>0){_options.$itemsToSelectOnShiftClick=$()}_options.mouseDownStartedFromListItem=false},_inputFocus:function(event){var mode=this.options.mode;if(this.options.disabled){return}if(mode==="editable"||mode==="dropdown"){this._options.$combo.addClass(this.css.active)}if(mode==="editable"){if(this._options.preventItemSeparatorOnFocus){this._options.preventItemSeparatorOnFocus=false}else{this._addItemSeparatorToEnd()}}if(mode==="editable"&&this.options.dropDownOnFocus){if(this._options.preventDropDownOnFocus){this._options.preventDropDownOnFocus=false}else{this.openDropDown(null,true,event)}}},_inputBlur:function(event){var _options=this._options,$activeEl=$(document.activeElement);if(this.options.disabled){return}if($activeEl.is(_options.$dropDownListCont)||$activeEl.is(_options.$dropDownBtnIcon)||$activeEl.is(_options.$clearIcon)){_options.preventInputBlur=true;this._safeFocusInput(true)}if(!_options.preventInputBlur){if(this.options.mode==="editable"||this.options.mode==="dropdown"){_options.$combo.removeClass(this.css.active)}if(this.options.mode==="editable"){this._removeItemSeparatorFromEnd();if(_options.selectedData.length===0&&!this.options.allowCustomValue){this._setInputVal("");_options.$input.val("")}}if(this.options.closeDropDownOnBlur){_options.closingDropDownOnBlur=true;this.closeDropDown(null,event)}if(_options.validator){_options.validator._validateInternal(this.element,event,true)}}else{_options.preventInputBlur=false}},_inputClick:function(event){if(this.options.disabled){return}if(this.options.mode==="dropdown"||this.options.mode==="readonlylist"){this._toggleDropDownState(event)}},_inputKeyDown:function(event){if(this.options.disabled){return}if(this.options.mode==="editable"||this.options.mode==="dropdown"){this._handleKeyNavigation(event);if(this.options.autoComplete){this._options.hadInputSelectionOnKeydown=this._hasInputSelection()}}},_inputPaste:function(event){var self=this;if(this.options.disabled){return}if(this.options.mode==="editable"){setTimeout(function(){self._handleInputChange(!self._options.dropDownOpened,event)},0)}},_handleDropDownModeKeypress:function(event){var curText,curData,value,startValue,startIndex,i,options=this.options,_options=this._options,curChar=String.fromCharCode(event.which),data=options.dataSource.dataView(),len=data.length,textKey=options.textKey;clearTimeout(_options.dropDownModeSearchByResetTimeout);if(_options.dropDownModeSearchBy!==curChar){_options.dropDownModeSearchBy+=curChar}if(options.multiSelection.enabled){startValue=_options.keyNavItemData}else{startValue=_options.selectedData.length?_options.selectedData[_options.selectedData.length-1][options.valueKey]:0}startIndex=this._dataIndexByValue(startValue,true);if(_options.dropDownModeSearchBy.length===1){startIndex+=1}for(i=0;i<len;i++){curData=this._unwrapData(data[(i+startIndex)%len]);if(curData){curText=this._unwrapData(curData[textKey]);if(!options.caseSensitive){curText=curText.toLowerCase();_options.dropDownModeSearchBy=_options.dropDownModeSearchBy.toLowerCase()}if(curText.startsWith(_options.dropDownModeSearchBy)){if(options.multiSelection.enabled){this._setKeyNavigationItem({data:curData,addStyles:true,clearPrevItem:true})}else{this._selectData(curData,{},event)}break}}}if(value!==undefined){if(options.multiSelection.enabled){this._scrollToItem(_options.keyNavItemData)}else{this._scrollToLastSelItem()}}_options.dropDownModeSearchByResetTimeout=setTimeout(function(){_options.dropDownModeSearchBy=""},_options.dropDownModeSearchByResetDelay)},_inputKeyPress:function(event){if(this.options.disabled){return}if(this.options.mode==="dropdown"){this._handleDropDownModeKeypress(event)}},_inputKeyUp:function(event){var self=this;if(this.options.disabled){return}if(this.options.mode==="editable"){clearTimeout(this._options.keyUpTimeout);this._options.autoCompleteItemData=null;this._options.keyUpTimeout=setTimeout(function(){self._handleInputChange(!self._options.dropDownOpened,event)},this.options.delayInputChangeProcessing)}if(this.options.mode==="editable"||this.options.mode==="dropdown"){if(event.keyCode===this._options.shiftKeyCode&&this.options.multiSelection.enabled){this._handleShiftUp(event)}}},_inputMouseDown:function(event){if(this.options.disabled){return}if(!this._options.$input.is(":focus")){this._options.$input.focus();this._moveCaretToInputEnd(true);event.preventDefault()}},_inputCompositionUpdate:function(){this._options.composition.isConfirmationNeeded=true},_inputCompositionEnd:function(){if($.ig.util.isFF){return}this._options.composition.isCompositionEndFired=true;if(this._options.composition.isConfirmationNeeded){this._options.composition.isConfirmationNeeded=false;if($.ig.util.isIE||$.ig.util.isEdge){this._inputInputHandler()}this._updateAutoComplete()}},_inputInputHandler:function(){this._options.composition.handleInput()},_initCompositionObject:function(){var comboContext=this;this._options.composition={isCompositionEndFired:false,isConfirmationNeeded:false,autocompleteText:"",isAutocompleteNeeded:function(){return $.ig.util.isFF||!this.isConfirmationNeeded},autocompleteAfterComposition:function(newInputVal,oldInputVal){comboContext._options.$input.val(newInputVal);comboContext._setInputSelection(oldInputVal.length,newInputVal.length)},handleInput:function(){var val,newInputVal,oldInputVal,compositionContext=this;if($.ig.util.isSafari&&this.isCompositionEndFired&&this.autoCompleteText){val=comboContext._options.$input.val();if($.ig.util.isOpera){oldInputVal=val}else{oldInputVal=val.slice(0,-val.length/2)}if(oldInputVal.length===this.inputVal.length-1&&oldInputVal===this.inputVal.slice(0,-1)){oldInputVal=this.inputVal}newInputVal=oldInputVal+this.autocompleteText;if($.ig.util.isSafari){setTimeout(function(){compositionContext.autocompleteAfterComposition(newInputVal,oldInputVal)},0)}else{this.autocompleteAfterComposition(newInputVal,oldInputVal)}}this.isCompositionEndFired=false;this.autocompleteText=""}}},_attachEvents:function(){var lastY,self=this,css=this.css,options=this.options,_options=this._options,_handlers=this._handlers;_options.$window.on({resize:_handlers.windowResize});$(document).on({mouseup:_handlers.documentMouseUp});_options.$combo.on({mouseenter:function(){if(options.disabled){return}if(options.mode!=="readonly"){_options.$combo.addClass(css.hover)}},mouseleave:function(){if(options.disabled){return}_options.$combo.removeClass(css.hover);if(!((options.mode==="editable"||options.mode==="dropdown")&&_options.$input.is(":focus"))){_options.$combo.removeClass(css.active)}},mousedown:function(){if(options.disabled){return}if(options.mode!=="readonly"){_options.$combo.addClass(css.active)}},mouseup:function(){if(options.disabled){return}if(options.mode==="readonlylist"){_options.$combo.removeClass(css.active)}}});_options.$dropDownBtnCont.on({mouseenter:function(){if(options.disabled){return}if(options.mode!=="readonly"){_options.$dropDownBtnCont.addClass(css.hover)}},mouseleave:function(){if(options.disabled){return}if(options.mode!=="readonly"){_options.$dropDownBtnCont.removeClass(css.hover)}},mousedown:function(event){if(options.disabled){return}event.preventDefault()},click:function(event){if(options.disabled||!(self._$items().length>0||_options.$dropDownListCont.find("."+css.noMatchFound).length>0)){return}if(options.mode!=="readonly"){if(_options.dropDownOpened){self.closeDropDown(null,event)}else{if(self.options.suppressKeyboard&&$.ig.util.isTouchDevice()){event.stopPropagation();if(self._options.$input.is(":focus")){self._options.$input.blur()}self.openDropDown(null,false,event);return}self.openDropDown(null,true,event)}}event.stopPropagation()}});_options.$clearCont.on({mouseenter:function(){if(options.disabled){return}if(options.mode!=="readonly"){_options.$clearCont.addClass(css.clearHover)}},mouseleave:function(){if(options.disabled){return}if(options.mode!=="readonly"){_options.$clearCont.removeClass(css.clearHover)}},mousedown:function(event){if(options.disabled){return}event.preventDefault()},click:function(event){if(options.disabled||_options.dataBinding){return}if(options.mode==="editable"||options.mode==="dropdown"){self._hideClearButton();self.clearInput({focusCombo:true},event);if(self._focusInInputWhenUsingTouchDevice()){self._moveCaretToInputEnd(true)}}}});_options.$input.on({focus:_handlers.inputFocus,blur:_handlers.inputBlur,click:_handlers.inputClick,keydown:_handlers.inputKeyDown,paste:_handlers.inputPaste,keyup:_handlers.inputKeyUp,keypress:_handlers.inputKeyPress,mousedown:_handlers.inputMouseDown,compositionupdate:_handlers.inputCompositionUpdate,compositionend:_handlers.inputCompositionEnd,input:_handlers.inputInput});_options.$dropDownListCont.on({mouseenter:function(){var $this,$prevItems;if(options.disabled){return}if(options.mode==="editable"||options.mode==="dropdown"){$this=$(this);if(_options.$itemsToSelectOnShiftClick.length>0){$prevItems=_options.$itemsToSelectOnShiftClick;_options.$itemsToSelectOnShiftClick=self._itemsBetweenTwoItems(self._$keyNavItem(),$this);$prevItems.not(_options.$itemsToSelectOnShiftClick).removeClass(css.itemInFocus);_options.$itemsToSelectOnShiftClick.addClass(css.itemInFocus)}else{$this.addClass(css.hover);if(_options.mouseDownStartedFromListItem){$this.addClass(css.itemInFocus)}}}},mouseleave:function(){var $this;if(options.disabled){return}if(options.mode==="editable"||options.mode==="dropdown"){$this=$(this);$this.removeClass(css.hover);if(!($this.is(self._$keyNavItem())||$this.is(_options.$itemsToSelectOnShiftUpDown))){$this.removeClass(css.itemInFocus)}if(_options.$itemsToSelectOnShiftClick.length>0){_options.$itemsToSelectOnShiftClick.removeClass(css.itemInFocus)}}},mousedown:function(event){var $this,$keyNavItem;if(options.disabled){return}if(options.mode==="editable"||options.mode==="dropdown"){if(event.which===1){$this=$(this);$keyNavItem=self._$keyNavItem();if(event.shiftKey&&options.multiSelection.enabled){if($keyNavItem.length===0){$keyNavItem=self._$items().filter(":visible").eq(0);self._setKeyNavigationItem({data:$keyNavItem,addStyles:true})}_options.$itemsToSelectOnShiftClick=self._itemsBetweenTwoItems($this,$keyNavItem);_options.$itemsToSelectOnShiftClick.addClass(css.itemInFocus);
}else{$this.addClass(css.itemInFocus)}_options.mouseDownStartedFromListItem=true}}},mouseup:function(event){var $this,multiSelect,closeDropDown,shouldSuppress=options.suppressKeyboard&&$.ig.util.isTouchDevice();if(options.disabled){return}if(options.mode==="editable"||options.mode==="dropdown"){if(_options.mouseDownStartedFromListItem&&event.which===1){$this=$(this);if(event.shiftKey&&options.multiSelection.enabled){self._handleShiftClick(event)}else{multiSelect=options.multiSelection.enabled&&(!options.multiSelection.addWithKeyModifier||event.ctrlKey);closeDropDown=multiSelect?false:options.closeDropDownOnSelect;if(multiSelect&&self.isSelected($this)&&!self._$keyNavItem().is(_options.$autoSelectedItem)){self.deselect($this,{focusCombo:!shouldSuppress},event)}else{self.select($this,{additive:multiSelect,closeDropDown:closeDropDown,focusCombo:!shouldSuppress},event)}}$this.removeClass(css.itemInFocus)}}}},"."+css.listItem.split(" ",1)[0]);_options.$dropDownListCont.on({mousedown:function(event){if(options.disabled){return}event.preventDefault()},scroll:function(){if(options.disabled){return}_options.$loading.css({top:self.listScrollTop()});if(!(_options.dataBinding||_options.disableScroll)){self._callNextChunk(_options.$dropDownListCont,self._itemHeight())}}});_options.$dropDownCont.on({mousedown:function(event){event.preventDefault()}},"."+css.header+", ."+css.footer);if(_options.$dropDownScrollCont){_options.$dropDownScrollCont.on("scroll",function(){if(options.disabled){return}self._scrollVirtualization($(this));if(_options.scrollCallback){_options.scrollCallback();_options.scrollCallback=null}});_options.$dropDownListCont.on("mousewheel DOMMouseScroll",function(event){var currentScrollTop=self.listScrollTop(),itemHeight=self._itemHeight();if(options.disabled){return}if(event.originalEvent.wheelDelta>0||event.originalEvent.detail<0){self.listScrollTop(currentScrollTop-itemHeight)}else{self.listScrollTop(currentScrollTop+itemHeight)}if(options.virtualization){return false}});_options.$dropDownListCont.on("touchmove",function(event){var currentY=event.originalEvent.touches[0].clientY,currentScrollTop=self.listScrollTop(),itemHeight=self._itemHeight();if(options.disabled){return}if(currentY<lastY){self.listScrollTop(currentScrollTop+itemHeight)}else if(currentY>lastY){self.listScrollTop(currentScrollTop-itemHeight)}lastY=currentY;if(options.virtualization){return false}})}},_scrollVirtualization:function($this){var itemHeight,offset,dropDownScrollHeight,options=this.options,self=this,_options=this._options;if(!options.virtualization||_options.dataBinding){return}if(options.filteringType==="local"&&_options.inputVal!==""&&_options.expression!==undefined&&_options.expression!==null){options.dataSource.filter(_options.expression,options.filteringLogic,true)}itemHeight=this._itemHeight();offset=this._calculateOffset();this._updateItems(offset);options.dataSource.settings.callback=function(err,success,data){dropDownScrollHeight=data.totalLocalRecordsCount()*itemHeight;_options.$dropDownScroll.height(dropDownScrollHeight);self._updateFooterVariables()};this._callNextChunk($this,itemHeight)},_calculateOffset:function(){var offset,offsetCeil,offsetFloor,itemsLength=this.options.dataSource.dataView().length,visibleItems=this.options.visibleItemsCount,containerRatio=this.listScrollTop()/this._options.$dropDownScrollCont.prop("scrollHeight");offset=containerRatio*itemsLength;offsetCeil=Math.ceil(offset);if(visibleItems+offsetCeil>itemsLength){offsetFloor=Math.floor(offset);return offsetFloor}return offsetCeil},_callNextChunk:function($element,itemHeight){var delta=this._options.deltaItemsForLoadOnDemand*itemHeight;if(this.listScrollTop()+$element.innerHeight()+delta>=$element.prop("scrollHeight")){this._nextChunk()}},_disableCombo:function(value){this._options.$comboWrapper.toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!value).attr("aria-disabled",value);this.hoverable.removeClass("ui-state-hover");this.focusable.removeClass("ui-state-focus");if(value){this._options.$input.attr("disabled",true);this._options.$hiddenInput.attr("disabled",true)}else{this._options.$input.removeAttr("disabled");this._options.$hiddenInput.removeAttr("disabled")}},changeLocale:function(){this._super();var $noMatchFound=this._options.$noMatchFound;if($noMatchFound&&$noMatchFound.length){this._changeLocaleForElement($noMatchFound)}},changeRegional:function(){this.dataBind()},_setOption:function(option,value){var options=this.options,_options=this._options;if(options[option]===value){return}if(option==="dropDownAttachedToBody"||option==="virtualization"||option==="mode"||option==="format"){throw new Error(this._getLocaleValue("notSuported"))}if(option==="multiSelection"){value=$.extend(true,{},options.multiSelection,value)}if(option==="loadOnDemandSettings"){value=$.extend(true,{},options.loadOnDemandSettings,value)}if(option==="disabled"){this._disableCombo(value)}if(option==="grouping"){value=$.extend(true,{},options.grouping,value)}this._super(option,value);this._analyzeOptions();switch(option){case"enableClearButton":if(_options.inputVal){if(value===true){this._showClearButton(true)}else{this._hideClearButton()}}break;case"width":_options.$comboWrapper.outerWidth(value);break;case"height":_options.$comboWrapper.outerHeight(value);break;case"headerTemplate":this._renderHeaderTemplate(this.css,this.options,_options.$dropDownCont);break;case"footerTemplate":this._renderFooterTemplate(this.css,this.options,_options.$dropDownCont,this);this._updateFooterVariables();break;case"dropDownWidth":this.positionDropDown();break;case"itemTemplate":this._renderItems(null,null,this.options.dataSource);break;case"inputName":_options.$hiddenInput.attr("name",value);break;case"visibleItemsCount":this._setListContMaxHeight();break;case"multiSelection":this._selectData(this._options.selectedData[0]);this._renderItems(null,null,this.options.dataSource);this.clearInput();break;case"tabIndex":this._options.$input.attr("tabIndex",value);break;case"validatorOptions":if(this._options.validator){this.element.igValidator(this.options.validatorOptions)}else{this.validator()}break;case"dataSource":case"dataSourceType":case"dataSourceUrl":case"responseTotalRecCountKey":case"responseDataKey":case"responseDataType":case"responseContentType":case"requestType":case"filteringType":case"filterExprUrlKey":case"filteringCondition":case"filteringLogic":case"loadOnDemandSettings":case"grouping":this.dataBind();break;case"valueKey":case"textKey":this._updateItems();break}},_initDataSource:function(){var dataSourceOptions,schema,pagingOptions,self=this,lod=this.options.loadOnDemandSettings,options=this.options,isStringDataSource=$.type(options.dataSource)==="string",url=options.dataSourceUrl;if(!options.dataSource&&this.element.is("select")){options.dataSource=this.element[0];schema=this._initSelectSchema()}else if(!options.dataSource&&url){options.dataSource=url;isStringDataSource=true}if($.type(options.dataSource)==="function"){options.dataSource=options.dataSource()}if(!(options.dataSource&&this._isInstanceOfDataSource(options.dataSource))){this._convertToArrayOfObjects(options);if(!schema&&options.dataSource&&($.isArray(options.dataSource)||$.isFunction(options.dataSource))){schema=this._initSchema(this._unwrapData(options.dataSource)[0])}dataSourceOptions={callback:this._renderItems,callee:this,dataSource:options.dataSource,type:options.dataSourceType||undefined,requestType:options.requestType||"GET",responseContentType:options.responseContentType||null,responseDataType:options.responseDataType||null,responseDataKey:options.responseDataKey||null,responseTotalRecCountKey:options.responseTotalRecCountKey||null,localSchemaTransform:false,schema:schema||null,dataBinding:function(){if(!self._options.dropDownOpened||self._options.dataBinding){return}self._options.dataBinding=true;self._options.$loading.insertBefore(self._options.$dropDownList)},dataBound:function(){self._options.$loading.remove();self._options.dataBinding=false}};if(lod&&lod.enabled&&(url||isStringDataSource)){pagingOptions={enabled:true,appendPage:true,pageSize:lod.pageSize,pageIndex:0,pageSizeUrlKey:lod.pageSizeUrlKey||null,pageIndexUrlKey:lod.pageIndexUrlKey||null};$.extend(dataSourceOptions,{paging:pagingOptions})}if($.type(options.dataSource)==="string"&&!options.dataSourceType&&$.ig.util.isJsonpUrl(options.dataSource)){this._options.strDataSource=options.dataSource;options.dataSource=new $.ig.JSONPDataSource(dataSourceOptions)}else{options.dataSource=new $.ig.DataSource(dataSourceOptions)}if(url){options.dataSource.settings.dataSource=url;options.dataSource.settings.type="remoteUrl";options.dataSource._runtimeType=options.dataSource.analyzeDataSource();options.dataSource.settings.urlParamsEncoded=$.proxy(function(data,params){params=params?params.filteringParams:null;if(params){params.textKey=options.textKey||options.valueKey;params.valueKey=options.valueKey;if(!options.caseSensitive){params.toLower="1"}if(options.compactData){params.compact="1"}}},this)}var _aNull=function(v,nan){return v===null||v===undefined||nan&&typeof v==="number"&&isNaN(v)};options.dataSource._responseData=function(data){var len=data?data.length:0,count=len>0?data[len-1][":totals:"]:null;if(count){data.pop();count=count.split(":");options.dataSource.totalRecordsCount(_aNull(len=parseInt(count[0],10),true)?0:len);len=_aNull(len=parseInt(count[1],10),true)?0:len;if(len){self._options.totalAll=len}}}}},_isInstanceOfDataSource:function(ds){return typeof ds._xmlToArray==="function"&&typeof ds._encodePkParams==="function"},_nextChunk:function(){var lod=this.options.loadOnDemandSettings,ds=this.options.dataSource;if(lod&&ds&&lod.enabled){ds.settings.paging.appendPage=true;if(!this.options.virtualization){this.options.dataSource.settings.callback=this._handleLoadOnDemand}ds.nextPage()}return this},_initSelectSchema:function(){var schema={};schema.fields=[{name:this.options.valueKey,type:"string"},{name:this.options.textKey,type:"string"}];return schema},_initSchema:function(firstDsRow){var field,schema={fields:[]};for(field in firstDsRow){if(firstDsRow.hasOwnProperty(field)){schema.fields.push({name:field,type:$.type(firstDsRow[field])})}}return schema},_filteringCondition:function(){return this.options.autoComplete?"startsWith":this.options.filteringCondition},_generateExpressions:function(texts){var i,expressions=[];if($.type(texts)==="string"){if(texts.length>0||this._options.expression&&this._options.expression.length>0){if(texts.indexOf("\u0131")>-1&&!this.options.caseSensitive){texts=texts.replace("\u0131","\u0131|I");texts=new RegExp(texts)}expressions.push({fieldName:this.options.textKey,expr:texts,cond:this._filteringCondition()})}}else if($.type(texts)==="array"){for(i=0;i<texts.length;i++){if($.type(texts[i])==="string"){expressions.push({fieldName:this.options.textKey,expr:texts[i],cond:this._filteringCondition(),logic:this.options.filteringLogic})}else{throw new Error(this._getLocaleValue("errorNoSupportedTextType"))}}}else{throw new Error(this._getLocaleValue("errorNoSupportedTextsType"))}return expressions},_generateRegExpPattern:function(texts){var pattern=null,types={multi:function(texts){return"("+texts.join("|")+")"},startsWith:function(texts){return"^("+texts.join("|")+")"},full:function(texts){return"^"+texts.join("|")+"$"},contains:function(texts){return texts.join("|")}};if($.type(texts)==="string"){texts=[texts]}texts=$.grep(texts,function(text){return text!==""});texts=$.map(texts,function(text){return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")});if(texts.length>0){if($.type(types[this.options.highlightMatchesMode])==="function"){pattern=types[this.options.highlightMatchesMode](texts)}else{throw new Error(this._getLocaleValue("errorUnrecognizedHighlightMatchesMode"))}}return pattern},_highlight:function(texts){var pattern,regex,$curContents,$matchingTextNodes,filterMatches,highlighMatches,len,i,$items=this._$items(),highlightElement=this._options.highlightElement,highlightCssClass=this.css.listItemHighlighted,regExpFlag=this.options.caseSensitive?"":"i";if(this.options.highlightMatchesMode===null||this.options.itemTemplate){return}if(this.options.highlightMatchesMode!=="contains"){regExpFlag+="g"}pattern=this._generateRegExpPattern(texts);if(pattern){regex=new RegExp(pattern,regExpFlag);if(pattern.indexOf("\u0131")>-1&&!this.options.caseSensitive){pattern=pattern.replace("\u0131","\u0131|I");regex=new RegExp(pattern,regExpFlag)}filterMatches=function(){return this.nodeType===3&&regex.test(this.nodeValue)};highlighMatches=function(){return(this.nodeValue||"").replace(regex,function(match){return"<"+highlightElement+' class="'+highlightCssClass+'">'+match+"</"+highlightElement+">"})};for(i=0,len=$items.length;i<len;i++){if(this._checkBoxesEnabled()){$curContents=$items.eq(i).children("."+this.css.listItemTextWithCheckbox).contents()}else{$curContents=$items.eq(i).contents()}$matchingTextNodes=$curContents.filter(filterMatches);$matchingTextNodes.replaceWith(highlighMatches)}}},_unhighlight:function(){var $highlightedItems,curItem,curParent,len,i;if(this.options.highlightMatchesMode===null){return this}if(this._checkBoxesEnabled()){$highlightedItems=this._$items().children("."+this.css.listItemTextWithCheckbox).children("."+this.css.listItemHighlighted)}else{$highlightedItems=this._$items().children("."+this.css.listItemHighlighted)}for(i=0,len=$highlightedItems.length;i<len;i++){curItem=$highlightedItems.eq(i)[0];curParent=curItem.parentNode;curParent.replaceChild(curItem.firstChild,curItem);curParent.normalize()}},_updateFiltering:function(event){var val=this._options.inputVal;if(this.options.multiSelection.enabled){if(this._endsPartialyWithItemSep(val)){val=""}else{val=this._lastValAfterItemSep()}}this.filter(val,event)},_updateHighlighting:function(){var val=this._options.inputVal,selItemsLen=this._fullySelectedItemsLen(),skipHighlight=false;if(!this.options.multiSelection.enabled){if(selItemsLen===1){skipHighlight=true}}else{if(this._separatedInputTexts(val).length===selItemsLen){skipHighlight=true}else{val=this._lastValAfterItemSep(val)}}this._unhighlight();if(!skipHighlight){this._highlight(val)}},_updateInputValues:function(keepInputText,selectedItems){var curText,curData,len,i,options=this.options,_options=this._options,inputVal="",hiddenInputVal="",itemSeparator=options.multiSelection.itemSeparator;selectedItems=selectedItems||this.selectedItems();len=selectedItems?selectedItems.length:0;if(options.allowCustomValue&&!len){inputVal=_options.$input.val();hiddenInputVal=inputVal}for(i=0;i<len;i++){curData=this._unwrapData(selectedItems[i].data);curText=this._unwrapData(curData[options.textKey]);if(i!==0){if(!_options.ltr){inputVal=itemSeparator+inputVal;hiddenInputVal=itemSeparator+hiddenInputVal}else{inputVal+=itemSeparator;hiddenInputVal+=itemSeparator}}if(!_options.ltr){if(curText!==""){inputVal=this._formatItem(curText)+inputVal}hiddenInputVal=this._unwrapData(curData[options.valueKey])+hiddenInputVal}else{if(curText!==""){inputVal+=this._formatItem(curText)}hiddenInputVal+=this._unwrapData(curData[options.valueKey])}}if(!keepInputText){if(options.multiSelection.enabled&&len>0&&options.mode==="editable"&&_options.$input.is(":focus")){inputVal+=itemSeparator}_options.$input.val(inputVal);this._setInputVal(inputVal);_options.autoSelectedItemData=null}_options.$hiddenInput.val(hiddenInputVal)},_handleLocalFilteringWithGrouping:function(){var groupsLen,i,$group,visibleItems=[],self=this,$groupHeaders=this._$groupHeaders(),filterVisible=function(index,item){return!$(item).hasClass(self.css.hidden)&&!$(item).hasClass(self.css.noMatchFound)};for(i=0,groupsLen=$groupHeaders.length;i<groupsLen;i++){$group=$($groupHeaders[i]);visibleItems=$group.nextUntil(self._groupHeaderClass()).filter(filterVisible);if(visibleItems.length===0){$group.addClass(this.css.hidden)}else{$group.removeClass(this.css.hidden)}}},_handleLocalFiltering:function(dataSource){var $curItem,curKey,filterItem,dataLen,i,j,unwrappedDataViewItem,unwrappedDataViewValue,$noMatchFoundItem,_options=this._options,valKey=this.options.valueKey,dataView=dataSource.dataView().slice(),initialDataLen=dataView.length,$items=this._$items(),len=$items.length,$keyNavItem=this._$keyNavItem(),cssHidden=this.css.hidden;for(i=0;i<len;i++){$curItem=$items.eq(i);curKey=$curItem.attr("data-value");filterItem=true;for(j=0,dataLen=dataView.length;j<dataLen&&filterItem;j++){unwrappedDataViewItem=this._unwrapData(dataView[j]);unwrappedDataViewValue=this._unwrapData(unwrappedDataViewItem[valKey]);if(this._areValuesEqual(curKey,unwrappedDataViewValue)){filterItem=false;dataView.splice(j,1)}}if(filterItem){$curItem.addClass(cssHidden)}else{$curItem.removeClass(cssHidden)}}if(this.options.grouping.key){this._handleLocalFilteringWithGrouping()}if($keyNavItem.length>0&&$keyNavItem.hasClass(cssHidden)){this._setKeyNavigationItem({data:$(),clearPrevItem:true})}if(initialDataLen===0){if(!_options.$noMatchFound){$noMatchFoundItem=this._$noMatchFoundItem();if($noMatchFoundItem.length===0){_options.$noMatchFound=$(this._noMatchMarkup())}else{_options.$noMatchFound=$noMatchFoundItem}}if(_options.$noMatchFound.parent().length===0){_options.$noMatchFound.appendTo(_options.$dropDownList)}}else if(_options.$noMatchFound&&_options.$noMatchFound.parent().length>0){_options.$noMatchFound.detach()}},_setInputVal:function(val){this._options.inputVal=val},_setListContMaxHeight:function(){this._options.$dropDownListCont.css("maxHeight",this.options.visibleItemsCount*this._itemHeight())},_updateVirtualScrollVisibility:function(){if(this._isPossibleToVirtualize()){this._options.$dropDownScrollCont.removeClass(this.css.hidden)}else if(this._areItemsLowerInVir()){this._options.$dropDownScrollCont.addClass(this.css.hidden)}},_addItemSelectionStyles:function($items){var $curItem,len,i;for(i=0,len=$items.length;i<len;i++){$curItem=$items.eq(i);if(this._isGroupHeader($curItem)){continue}$curItem.addClass(this.css.active);if(this._checkBoxesEnabled()){$curItem.find(".ui-igcombo-checkbox .ui-icon").removeClass(this.css.checkboxOff).addClass(this.css.checkboxOn)}}},_removeItemSelectionStyles:function($items){var $curItem,len,i;for(i=0,len=$items.length;i<len;i++){$curItem=$items.eq(i);$curItem.removeClass(this.css.active);if(this._checkBoxesEnabled()){$curItem.find(".ui-igcombo-checkbox .ui-icon").removeClass(this.css.checkboxOn).addClass(this.css.checkboxOff)}}},_addItemSeparatorToEnd:function(){var newVal,inputVal=this._options.inputVal,itemSep=this.options.multiSelection.itemSeparator,sepTexts=this._separatedInputTexts(inputVal),selItemsLen=this._fullySelectedItemsLen();if(inputVal.length>0&&this.options.multiSelection.enabled&&!inputVal.endsWith(itemSep)&&sepTexts.length===selItemsLen){newVal=inputVal+itemSep;this._options.$input.val(newVal);this._setInputVal(newVal)}},_removeItemSeparatorFromEnd:function(){var newVal,inputVal=this._options.inputVal,itemSep=this.options.multiSelection.itemSeparator;if(this.options.multiSelection.enabled&&inputVal.endsWith(itemSep)){newVal=inputVal.slice(0,inputVal.length-itemSep.length);this._options.$input.val(newVal);this._setInputVal(newVal)}},_callInternalSelChangeSubs:function(event){var curCallback,i,callbacks=this._options.internalSelChangeSubs;if($.type(callbacks)==="array"){for(i=0;i<callbacks.length;i++){curCallback=callbacks[i];if(typeof curCallback==="function"){curCallback()}}}if(this._options.validator){this._options.validator._validateInternal(this.element,event)}},_fullySelectedItemsLen:function(){var autoSelItemLen=this._options.autoSelectedItemData===null?0:1;return this._options.selectedData.length-autoSelItemLen},_unwrapData:function(data){if(typeof data==="function"){data=data()}return data},_dropDownOrientation:function(){var dropDownAndComboHeight,_options=this._options,direction=this.options.dropDownOrientation,$combo=_options.$combo,comboOffset=$combo.igOffset(),comboTopOffset=comboOffset.top,comboOuterHeight=parseInt($combo.outerHeight(),10),dropDownContainerHeight=this._dropDownContHeight(),windowHeight=_options.$window.height(),windowScrollTop=comboOffset.documentScrollTop?comboOffset.documentScrollTop:_options.$window.scrollTop();dropDownAndComboHeight=parseInt(comboTopOffset+comboOuterHeight+dropDownContainerHeight,10);if(direction==="auto"){if(dropDownAndComboHeight<windowHeight+windowScrollTop){direction="bottom"}else if(comboTopOffset-dropDownContainerHeight>0){direction="top"}else{direction="bottom"}}if(direction==="top"){if(_options.$dropDownCont.hasClass(this.css.orientationBottom)){_options.$dropDownCont.removeClass(this.css.orientationBottom).addClass(this.css.orientationTop)}}else{if(_options.$dropDownCont.hasClass(this.css.orientationTop)){_options.$dropDownCont.removeClass(this.css.orientationTop).addClass(this.css.orientationBottom)}}return direction},_startRepositionInterval:function(){var self=this;this._options.repositionInterval=setInterval(function(){self.positionDropDown()},200)},_clearRepositionInterval:function(){clearInterval(this._options.repositionInterval)},_areValuesEqual:function(val1,val2){return val1!==null&&val1!==undefined&&val2!==null&&val2!==undefined?$.ig.encode(val1.toString())===$.ig.encode(val2.toString()):false},_isValueInArray:function(val,vals){var i=0,len=vals.length;val=val&&val.toString();for(;i<len;i++){if(this._areValuesEqual(val,vals[i])){return i}}return-1},_focusInInputWhenUsingTouchDevice:function(){return!("ontouchstart"in window&&this.options.mode!=="editable")},_triggerItemsRendering:function(){var args={owner:this,dataSource:this.options.dataSource};return this._trigger(this.events.itemsRendering,null,args)},_triggerItemsRendered:function(){var args={owner:this,dataSource:this.options.dataSource};this._trigger(this.events.itemsRendered,null,args)},_triggerRendered:function(){var args={owner:this,element:this._options.$comboWrapper};this._trigger(this.events.rendered,null,args)},_triggerDataBinding:function(){var args={owner:this,dataSource:this.options.dataSource};return this._trigger(this.events.dataBinding,null,args)},_triggerDataBound:function(success,msg){var args={owner:this,success:success,errorMessage:msg,dataSource:this.options.dataSource};this._trigger(this.events.dataBound,null,args)},_triggerFiltering:function(event){var args={owner:this,expression:this._options.expression};return this._trigger(this.events.filtering,event,args)},_triggerFiltered:function(event){var args={owner:this,elements:this._$filteredItems()};this._trigger(this.events.filtered,event,args)},_triggerDropDownOpening:function(event){var args={owner:this,list:this._options.$dropDownCont};return this._trigger(this.events.dropDownOpening,event,args)},_triggerDropDownOpened:function(event){var args={owner:this,list:this._options.$dropDownCont};this._trigger(this.events.dropDownOpened,event,args)},_triggerDropDownClosing:function(event){var args={owner:this,list:this._options.$dropDownCont};return this._trigger(this.events.dropDownClosing,event,args)},_triggerDropDownClosed:function(event){var args={owner:this,list:this._options.$dropDownCont};this._trigger(this.events.dropDownClosed,event,args)},_triggerSelectionChanging:function(newSelItems,currentSelItems,event){var args={owner:this,items:newSelItems,currentItems:currentSelItems};return this._trigger(this.events.selectionChanging,event,args)},_triggerSelectionChanged:function(newSelItems,oldItems,event){var args={owner:this,items:newSelItems,oldItems:oldItems};this._trigger(this.events.selectionChanged,event,args)},dataBind:function(){var noCancel;this._initDataSource();this._options.cachedData=[];noCancel=this._triggerDataBinding();if(noCancel){if(!this._options.initialDataBinding){this.clearInput();this._options.selectedData=[]}this.options.dataSource.dataBind(this._renderItems,this)}return this},refreshValue:function(){this._updateInputValues(true)},dataForValue:function(value){var data,unwrappedDataItem,unwrappedDataValue,len,i,valKey=this.options.valueKey,cachedData=this._options.cachedData,matchFound=false,result=null;if(!this.options.dataSource||value===null||value===undefined){return null}data=this.options.dataSource.data();for(i=0,len=data.length;i<len&&!matchFound;i++){unwrappedDataItem=this._unwrapData(data[i]);unwrappedDataValue=this._unwrapData(unwrappedDataItem[valKey]);if(this._areValuesEqual(unwrappedDataValue,value)){result=data[i];matchFound=true}}if(!matchFound&&this.options.filteringType==="remote"){for(i=0,len=cachedData.length;i<len&&!matchFound;i++){unwrappedDataItem=this._unwrapData(cachedData[i]);unwrappedDataValue=this._unwrapData(unwrappedDataItem[valKey]);if(this._areValuesEqual(unwrappedDataValue,value)){result=cachedData[i];matchFound=true}}}return result},dataForElement:function($element){if(!($element instanceof $&&$element.is(this._$items()))){return null}return this.dataForValue($element.attr("data-value"))},itemsFromElement:function($element){var i,result,$curElement;if(!($element instanceof $&&$element.is(this._$items()))){return null}if($element.length===1){result={element:$element,data:this.dataForElement($element)}}else{result=[];for(i=0;i<$element.length;i++){$curElement=$element.eq(i);result.push({element:$curElement,data:this.dataForElement($curElement)})}}return result},itemsFromValue:function(value){var data,i,len,self=this,$items=this._$items(),result=null;if($.type(value)==="array"){value=$.grep(value,function(val,index){return self._isValueInArray(val,value)===index});for(i=0,len=value.length;i<len;i++){data=this.dataForValue(value[i]);if(data){if(!result){result=[]}result.push({element:this._$elementFromValue(value[i],$items),data:data})}}}else{data=this.dataForValue(value);if(data){result={element:this._$elementFromValue(value,$items),data:data}}}return result},itemsFromIndex:function(index){var value,i,data=this.options.dataSource.data(),dataLen=data.length,valKey=this.options.valueKey;if($.type(index)==="array"){value=[];for(i=0;i<index.length;i++){if(typeof index[i]==="number"&&index[i]>=0&&index[i]<dataLen){value.push(data[index[i]][valKey])}}}else if(typeof index==="number"&&index>=0&&index<dataLen){value=this._unwrapData(this._unwrapData(data[index])[valKey])}return this.itemsFromValue(value)},items:function(){return this._itemsFromData(this.options.dataSource.data())},filteredItems:function(){return this._itemsFromData(this.options.dataSource.dataView())},selectedItems:function(){return this._options.selectedData.length>0?this._itemsFromData(this._options.selectedData):null},filter:function(texts,event){var expressions=[],type=this.options.filteringType,clearFiltering=texts==="",ds=this.options.dataSource;if(!this._isFilteringEnabled()){return this}expressions=this._options.expression=this._generateExpressions(texts);if(type==="local"){if(clearFiltering){this._options.expression=null;ds.clearLocalFilter()}}this.filterByExpressions(expressions,event)},filterByExpressions:function(expressions,event){var noCancel,logic=this.options.filteringLogic,filterExprUrlKey=this.options.filterExprUrlKey,type=this.options.filteringType,ds=this.options.dataSource,paging=ds.settings.paging,filtering=ds.settings.filtering,textKeyValueOption=this.options.textKey;if(!this._isFilteringEnabled()){return this}filtering.type=type;filtering.caseSensitive=this.options.caseSensitive;filtering.expressions=expressions;filtering.expressions.forEach(function(element){if(element.fieldName===undefined){element.fieldName=textKeyValueOption}});noCancel=event?this._triggerFiltering(event):true;if(noCancel){if(type==="local"){ds.filter(filtering.expressions,logic,true);if(this.options.virtualization){this._handleLocalFilteringWithVirt(ds)}else{this._handleLocalFiltering(ds)}}if(type==="remote"){if(paging){paging.pageIndex=0;paging.appendPage=false}if(filterExprUrlKey){filtering.filterExprUrlKey=filterExprUrlKey}this._options.remoteFilteringTriggerEvt=event;ds.dataBind(this._handleRemoteFiltering,this)}if(this._options.dropDownOpened){this.listScrollTop(0)}if(event&&!this._options.remoteFilteringTriggerEvt){this._triggerFiltered(event)}}return this},clearFiltering:function(event){var ds=this.options.dataSource,expression=this._options.expression;if(!ds||!expression||expression.length<=0||expression.length===1&&expression[0].expr===""){if(this._options.updateInputValuesOnRemoteFilter&&this._endsPartialyWithItemSep(this._options.inputVal)){this._updateInputValues();this._hideClearButton()}this._options.updateInputValuesOnRemoteFilter=false;return}this.filter("",event);this.positionDropDown();return this},openDropDown:function(callback,focusCombo,event){var offset,noCancel,newAnimationStyle,_options=this._options,borderWidth=parseInt(_options.$combo.css("borderTopWidth"),10),topPosition=$.ig.util.offset(_options.$combo).top-borderWidth,self=this,$ddCont=_options.$dropDownCont,orientation=this._dropDownOrientation(),autoHeight=this._dropDownContHeight();if(focusCombo===undefined){focusCombo=true}if(self.options.suppressKeyboard&&$.ig.util.isTouchDevice()){focusCombo=false}if(!_options.dropDownOpened){noCancel=event?this._triggerDropDownOpening(event):true;if(noCancel){_options.dropDownOpened=true;this.positionDropDown();this._scrollToLastSelItem();if(orientation==="top"){$ddCont.addClass(this.css.orientationTop).removeClass(this.css.orientationBottom).css({top:parseInt($ddCont.css("top"),10)-1});if(this.options.dropDownAttachedToBody){newAnimationStyle={height:autoHeight,top:topPosition-autoHeight}}else{newAnimationStyle={height:autoHeight,top:-autoHeight-borderWidth}}}else{$ddCont.addClass(this.css.orientationBottom).removeClass(this.css.orientationTop);newAnimationStyle={height:autoHeight}}this._startRepositionInterval();$ddCont.stop().removeClass(this.css.noBorder).animate(newAnimationStyle,{duration:this.options.animationShowDuration,queue:false,easing:"swing",complete:function(){$ddCont.height("").css("overflow","");if(self.options.virtualization){offset=self._calculateOffset();self._updateItems(offset)}if($.type(callback)==="function"){callback()}if(event){self._triggerDropDownOpened(event)}}});if(focusCombo){this._moveCaretToInputEnd(false)}}}return this},closeDropDown:function(callback,event){var noCancel,newAnimationStyle,_options=this._options,self=this,borderWidth=parseInt(_options.$combo.css("borderTopWidth"),10),orientation=this._dropDownOrientation();if(_options.dropDownOpened&&(!_options.dataBinding||_options.closingDropDownOnBlur)){noCancel=event?this._triggerDropDownClosing(event):true;if(noCancel){this.positionDropDown();if(orientation==="top"){if(this.options.dropDownAttachedToBody){newAnimationStyle={height:0,top:$.ig.util.offset(_options.$combo).top-borderWidth,left:$.ig.util.offset(_options.$dropDownCont).left}}else{newAnimationStyle={height:0,top:0}}}else{newAnimationStyle={height:0}}_options.$dropDownCont.stop().css("overflow","hidden").animate(newAnimationStyle,{duration:this.options.animationHideDuration,queue:false,easing:"swing",complete:function(){self._clearRepositionInterval();_options.$dropDownCont.addClass(self.css.noBorder).removeClass(self.css.orientationBottom).removeClass(self.css.orientationTop).css({top:-99999,left:-99999});if(self.options.filteringType!=="remote"){self._updateInputValues();self._unhighlight();self.clearFiltering(event);if(self.options.multiSelection.enabled){self._setKeyNavigationItem({data:$(),clearPrevItem:true})}if(!self.options.allowCustomValue&&_options.selectedData.length===0||self.options.allowCustomValue&&_options.$input.val()===""){self._hideClearButton()}self._removePlaceholderOnEmptyTextVal();if(_options.validator){_options.validator._validateInternal(self.element,event,true)}}else{_options.updateInputValuesOnRemoteFilter=true;self.clearFiltering(event)}if($.type(callback)==="function"){callback()}_options.dropDownOpened=false;_options.closingDropDownOnBlur=false;if(event){self._triggerDropDownClosed(event)}}})}}return this},clearInput:function(options,event){options=options||{};this._options.$input.val("");this._options.$hiddenInput.val("");this._setInputVal("");
this.deselectAll(options,event);this.clearFiltering(event);this._unhighlight();this._hideClearButton();this._setKeyNavigationItem({data:$(),clearPrevItem:true});return this},_hideClearButton:function(){if(!this.options.enableClearButton){return}this._options.$clearCont.hide()},_showClearButton:function(force){if(!force&&!this.options.enableClearButton){return}this._options.$clearCont.show()},isSelected:function($item){return $item instanceof $?this.isValueSelected($item.attr("data-value")):false},isValueSelected:function(value){return this._isValueInArray(value,this._valuesFromData(this._options.selectedData))!==-1},isIndexSelected:function(index){return this.isValueSelected(this.options.dataSource.data()[index][this.options.valueKey])},_selectData:function(data,options,event){var items,itemsLen,selectedValues,newSelItems,selAutoSelectedItem,selChanged,additive,prevSelValues,newSelData,skipEventTrigger,noCancel,i,comboOptions=this.options,_options=this._options,multiSelEnabled=comboOptions.multiSelection.enabled,prevSelItems=this.selectedItems(),returnValue={combo:this,selectionCanceled:false};data=$.type(data)==="array"&&!multiSelEnabled?data[0]:data;items=this._itemsFromData(data);options=options||{};if(items===null){if(!options.additive){this.deselectAll(options,event)}return returnValue}if($.type(items)!=="array"){items=[items]}additive=options.additive&&multiSelEnabled;itemsLen=items.length;selectedValues=this._valuesFromItems(items);if(additive){for(i=0;i<itemsLen&&!selChanged;i++){if(!this.isValueSelected(items[i].data[comboOptions.valueKey])){selChanged=true}}}else{prevSelValues=this._valuesFromItems(prevSelItems);if(!$.ig.util.areSetsEqual(selectedValues,prevSelValues)){selChanged=true}}if(this._isValueInArray(_options.autoSelectedItemData&&_options.autoSelectedItemData[comboOptions.valueKey],selectedValues)!==-1){selAutoSelectedItem=true;if(this._options.selectedData.length>0){if(itemsLen===1&&this._options.autoSelectedItemData[comboOptions.valueKey]===this._options.selectedData[0][comboOptions.valueKey]){skipEventTrigger=itemsLen===1&&this._options.autoSelectedItemData[comboOptions.valueKey]===this._options.selectedData[0][comboOptions.valueKey]}}}if(selChanged||selAutoSelectedItem){if(additive&&prevSelItems){newSelItems=prevSelItems.concat(this._filterItems(items,prevSelItems));newSelData=this._dataFromItems(newSelItems)}else{newSelItems=items;newSelData=this._dataFromItems(newSelItems)}if(event&&!skipEventTrigger){noCancel=this._triggerSelectionChanging(newSelItems,prevSelItems,event)}else{noCancel=true}returnValue.selectionCanceled=!noCancel;if(noCancel){_options.selectedData=newSelData;if(prevSelItems&&prevSelItems.length>0&&!additive){this._removeItemSelectionStyles(this._$elementsFromItems(this._filterItems(prevSelItems,items)))}this._addItemSelectionStyles(this._$elementsFromItems(newSelItems));this._updateInputValues(options.keepInputText,newSelItems);if(!options.keepHighlighting){this._unhighlight()}this._showClearButton();if(options.focusCombo){if(!(options.autoComplete&&this._hasInputSelection())){this._moveCaretToInputEnd(true)}}if(!options.keepNavItem){this._setKeyNavigationItem({data:items[itemsLen-1].data?items[itemsLen-1].data:$(),clearPrevItem:true})}if(comboOptions.filteringType==="remote"){this._options.cachedData=this._dataFromItems(newSelItems)}if(options.closeDropDown){this.closeDropDown(null,event)}if(!options.keepFiltering){this.clearFiltering(event)}this._removePlaceholderOnEmptyTextVal();if(!options.keepScrollPosition){this._scrollToLastSelItem()}this._callInternalSelChangeSubs(event);if(event&&!skipEventTrigger){this._triggerSelectionChanged(newSelItems,prevSelItems,event)}}}else if(options.closeDropDown){noCancel=event?this._triggerDropDownClosing(event):true;if(noCancel){this.closeDropDown(null,event)}}return returnValue},value:function(value,options,event){var selectedValues,selectedItems,i,retValue;if(value===undefined){selectedValues=[];selectedItems=this.selectedItems();if(selectedItems){for(i=0;i<selectedItems.length;i++){selectedValues.push(selectedItems[i].data[this.options.valueKey])}}else if(this.options.allowCustomValue&&this._options.$hiddenInput.val()!==""){selectedValues.push(this._options.$hiddenInput.val())}if(!this.options.multiSelection.enabled&&selectedItems){selectedValues=selectedValues.length>0?selectedValues[0]:null}return selectedValues}retValue=this._selectData(this._dataForValues(value),options,event);if(this.options.allowCustomValue&&!this.selectedItems()&&!retValue.selectionCanceled){this._options.$input.val(value);this._updateInputValues();this._showClearButton()}},select:function($items,options,event){if($items instanceof $){this.value(this._valuesFromElements($items),options,event)}return this},index:function(index,options,event){var selectedItems,indexes,unwrappedDataItem,unwrappedDataValue,i,len,dataToSel=[];if(index===undefined){selectedItems=this.selectedItems();if(selectedItems.length===1){unwrappedDataItem=this._unwrapData(selectedItems[0].data);unwrappedDataValue=this._unwrapData(unwrappedDataItem[this.options.valueKey]);indexes=this._dataIndexByValue(unwrappedDataValue)}else{indexes=[];for(i=0;i<selectedItems.length;i++){unwrappedDataItem=this._unwrapData(selectedItems[i].data);unwrappedDataValue=this._unwrapData(unwrappedDataItem[this.options.valueKey]);indexes.push(this._dataIndexByValue(unwrappedDataValue))}}return indexes}if($.type(index)!=="array"){index=[index]}for(i=0,len=index.length;i<len;i++){dataToSel.push(this._dataFromIndex(index[i]))}this._selectData(dataToSel,options,event);return this},selectAll:function(options,event){options=options||{};this._selectData(this.options.dataSource.data(),options,event);return this},_deselectData:function(data,options,event){var newSelItems,selChanged,noCancel,len,i,_options=this._options,items=this._itemsFromData(data),prevSelItems=this.selectedItems();options=options||{};if(items===null){return this}if($.type(items)!=="array"){items=[items]}for(i=0,len=items.length;i<len&&!selChanged;i++){if(this.isValueSelected(items[i].data[this.options.valueKey])){selChanged=true}}if(selChanged){newSelItems=this._filterItems(prevSelItems,items);noCancel=event?this._triggerSelectionChanging(newSelItems,prevSelItems,event):true;if(noCancel){_options.selectedData=this._dataFromItems(newSelItems);this._removeItemSelectionStyles(this._$elementsFromItems(items));this._updateInputValues(options.keepInputText,newSelItems);this._unhighlight();if(_options.selectedData.length===0){this._setKeyNavigationItem({data:$(),clearPrevItem:true})}if(_options.inputVal===""){this._hideClearButton()}if(options.focusCombo){if(this._focusInInputWhenUsingTouchDevice()){this._moveCaretToInputEnd(true)}}if(this.options.filteringType==="remote"){this._options.cachedData=this._dataFromItems(newSelItems)}this._addPlaceholderWhenEmptyTextVal();this._callInternalSelChangeSubs(event);if(event){this._triggerSelectionChanged(newSelItems,prevSelItems,event)}}}return this},deselectByValue:function(value,options,event){options=options||{};if(value===undefined&&this._options.selectedData.length===1){value=this._options.selectedData[0][this.options.valueKey]}this._deselectData(this._dataForValues(value),options,event)},deselect:function($items,options,event){if($items===undefined){this.deselectByValue()}if($items instanceof $){$items=$items.filter(this._$items());this.deselectByValue(this._valuesFromElements($items),options,event)}return this},deselectByIndex:function(index,options,event){var i,len,dataToDeselect=[];if($.type(index)!=="array"){index=[index]}for(i=0,len=index.length;i<len;i++){dataToDeselect.push(this._dataFromIndex(index[i]))}this._deselectData(dataToDeselect,options,event);return this},deselectAll:function(options,event){this._deselectData(this._options.selectedData,options,event);this._selectFirstItemInNonEditableModes(this.options.mode,[],this.options.dataSource.dataView());return this},activeIndex:function(index){if(index===undefined){return this._$items().index(this._$keyNavItem())}this._setKeyNavigationItem({data:this._dataFromIndex(index),addStyles:true,clearPrevItem:true});return this},text:function(text){if(text===undefined){return this._options.$input.val()}this._options.$input.val(text);this._handleInputChange(false);return this},listScrollTop:function(value){var $listCont,_options=this._options;if(value!==undefined&&!_options.dropDownOpened){this.openDropDown()}$listCont=_options.$dropDownScrollCont||_options.$dropDownListCont;if(value===undefined){return $listCont?$listCont.prop("scrollTop"):0}if($listCont){$listCont.prop("scrollTop",value||0)}return this},listItems:function(){return this._$items()},comboWrapper:function(){return this._options.$comboWrapper},dropDown:function(){return this._options.$dropDownCont},list:function(){return this._options.$dropDownListCont},textInput:function(){return this._options.$input},valueInput:function(){return this._options.$hiddenInput},validator:function(destroy){var validatorOptions=this.options.validatorOptions,validator=this._options.validator;if(validator&&(destroy||!validatorOptions)&&validator.owner===this){validator.destroy();this._options.validator=validator=null}else if(!validator&&!destroy&&validatorOptions&&this.element.igValidator){this._options.validator=validator=this.element.igValidator(validatorOptions).data("igValidator");this._options.validator.owner=this}return validator},validate:function(){return this._options.validator?this._options.validator.validate():null},dropDownOpened:function(){return this._options.dropDownOpened},positionDropDown:function(){var comboOffset,width,_options=this._options,$combo=_options.$combo,orientation=this.options.dropDownOrientation;if(orientation==="auto"){orientation=this._dropDownOrientation()}if(this.options.dropDownAttachedToBody){comboOffset=$.ig.util.offset($combo);width=this.options.dropDownWidth||$combo.outerWidth();_options.$dropDownCont.outerWidth(width);if(orientation==="top"){_options.$dropDownCont.css({left:comboOffset.left,top:comboOffset.top-_options.$dropDownCont.outerHeight()})}else{_options.$dropDownCont.css({left:comboOffset.left,top:comboOffset.top+$combo.outerHeight()})}}else{if(orientation==="top"){_options.$dropDownCont.css({left:"",top:-_options.$dropDownCont.outerHeight()})}else{_options.$dropDownCont.css({left:"",top:""})}}},_unsetupInput:function(){var _handlers=this._handlers;this.element.insertAfter(this._options.$comboWrapper);this._options.$comboWrapper.remove();this.element.removeClass(this.css.field).val("").removeAttr("placeholder").removeAttr("tabIndex").attr("name",this._options.nameAttribute);if(this.options.mode!=="editable"){this.element.removeAttr("readonly").removeAttr("unselectable").removeClass(this.css.unselectable)}this.element.off({focus:_handlers.inputFocus,blur:_handlers.inputBlur,click:_handlers.inputClick,keydown:_handlers.inputKeyDown,paste:_handlers.inputPaste,keyup:_handlers.inputKeyUp,keypress:_handlers.inputKeyPress,mousedown:_handlers.inputMouseDown,compositionupdate:_handlers.inputCompositionUpdate,compositionend:_handlers.inputCompositionEnd,input:_handlers.inputInput})},destroy:function(){var _options=this._options,_handlers=this._handlers;this.validator(true);_options.$window.off("resize",_handlers.windowResize);$(document).off("mouseup",_handlers.documentMouseUp);this._clearRepositionInterval();_options.$dropDownCont.remove();if(this.element.is("input")){this._unsetupInput()}else if(this.element.is("select")){_options.$comboWrapper.remove();this.element.show().attr("name",_options.nameAttribute)}else{this.element.empty().removeClass(this.css.comboWrapper)}_options=null;this._superApply(arguments);return this}});$.extend($.ui.igCombo,{version:"21.2.12"});return $});