/** * @license * Copyright (c) 2014, 2018, Oracle and/or its affiliates. * The Universal Permissive License (UPL), Version 1.0 */ "use strict";define(["ojs/ojcore","jquery","ojs/ojeditablevalue","ojs/ojoptgroup","ojs/ojoption","promise","ojs/ojlistdataproviderview"],function(e,t,i,s){var o,n={properties:{asyncValidators:{type:"Array",value:[]},converter:{type:"object",properties:{type:{type:"string"},options:{type:"object"}}},describedBy:{type:"string"},disabled:{type:"boolean",value:!1},displayOptions:{type:"object",properties:{converterHint:{type:"Array|string",value:["placeholder","notewindow"]},helpInstruction:{type:"Array|string",value:["notewindow"]},messages:{type:"Array|string",value:["inline"]},validatorHint:{type:"Array|string",value:["notewindow"]}}},help:{type:"object",properties:{instruction:{type:"string"}}},helpHints:{type:"object",properties:{definition:{type:"string",value:""},source:{type:"string",value:""}}},labelHint:{type:"string",value:""},messagesCustom:{type:"Array",writeback:!0,value:[]},minLength:{type:"number",value:0},optionRenderer:{type:"function"},options:{type:"Array<(oj.Option|oj.Optgroup)>|oj.DataProvider"},optionsKeys:{type:"object",properties:{childKeys:{type:"object",properties:{label:{type:"string"},value:{type:"string"},children:{type:"string"},childKeys:{type:"object"}}},children:{type:"string"},label:{type:"string"},value:{type:"string"}}},pickerAttributes:{type:"object"},placeholder:{type:"string"},rawValue:{type:"string",writeback:!0,readOnly:!0},required:{type:"boolean",value:!1},translations:{type:"object",value:{},properties:{filterFurther:{type:"string"},noMatchesFound:{type:"string"},required:{type:"object",properties:{hint:{type:"string"},messageDetail:{type:"string"},messageSummary:{type:"string"}}}}},valid:{type:"string",writeback:!0,enumValues:["invalidHidden","invalidShown","pending","valid"],readOnly:!0},validators:{type:"Array",value:[]},value:{type:"Array",writeback:!0},valueOptions:{type:"Array",writeback:!0}},methods:{refresh:{},validate:{},reset:{},showMessages:{},setProperty:{},getProperty:{},setProperties:{},getNodeBySubId:{},getSubIdByNode:{}},events:{ojAnimateStart:{},ojAnimateEnd:{}},extension:{}},a={properties:{asyncValidators:{type:"Array",value:[]},converter:{type:"object",properties:{type:{type:"string"},options:{type:"object"}}},describedBy:{type:"string"},disabled:{type:"boolean",value:!1},displayOptions:{type:"object",properties:{converterHint:{type:"Array|string",value:["placeholder","notewindow"]},helpInstruction:{type:"Array|string",value:["notewindow"]},messages:{type:"Array|string",value:["inline"]},validatorHint:{type:"Array|string",value:["notewindow"]}}},filterOnOpen:{type:"string",enumValues:["none","rawValue"],value:"none"},help:{type:"object",properties:{instruction:{type:"string"}}},helpHints:{type:"object",properties:{definition:{type:"string",value:""},source:{type:"string",value:""}}},labelHint:{type:"string",value:""},messagesCustom:{type:"Array",writeback:!0,value:[]},minLength:{type:"number",value:0},optionRenderer:{type:"function"},options:{type:"Array<(oj.Option|oj.Optgroup)>|oj.DataProvider"},optionsKeys:{type:"object",properties:{childKeys:{type:"object",properties:{label:{type:"string"},value:{type:"string"},children:{type:"string"},childKeys:{type:"object"}}},children:{type:"string"},label:{type:"string"},value:{type:"string"}}},pickerAttributes:{type:"object"},placeholder:{type:"string"},rawValue:{type:"string",writeback:!0,readOnly:!0},required:{type:"boolean",value:!1},translations:{type:"object",value:{},properties:{filterFurther:{type:"string"},noMatchesFound:{type:"string"},required:{type:"object",properties:{hint:{type:"string"},messageDetail:{type:"string"},messageSummary:{type:"string"}}}}},valid:{type:"string",writeback:!0,enumValues:["invalidHidden","invalidShown","pending","valid"],readOnly:!0},validators:{type:"Array",value:[]},value:{type:"any",writeback:!0},valueOption:{type:"object",writeback:!0,properties:{value:{type:"any"},label:{type:"string"}}}},methods:{refresh:{},validate:{},reset:{},showMessages:{},setProperty:{},getProperty:{},setProperties:{},getNodeBySubId:{},getSubIdByNode:{}},events:{ojValueUpdated:{},ojAnimateStart:{},ojAnimateEnd:{}},extension:{}},l={properties:{describedBy:{type:"string"},disabled:{type:"boolean",value:!1},displayOptions:{type:"object",properties:{converterHint:{type:"Array|string",value:["placeholder","notewindow"]},helpInstruction:{type:"Array|string",value:["notewindow"]},messages:{type:"Array|string",value:["inline"]},validatorHint:{type:"Array|string",value:["notewindow"]}}},help:{type:"object",properties:{instruction:{type:"string"}}},helpHints:{type:"object",properties:{definition:{type:"string",value:""},source:{type:"string",value:""}}},labelHint:{type:"string",value:""},messagesCustom:{type:"Array",writeback:!0,value:[]},minimumResultsForSearch:{type:"number",value:15},optionRenderer:{type:"function"},options:{type:"Array<(oj.Option|oj.Optgroup)>|oj.DataProvider"},optionsKeys:{type:"object",properties:{childKeys:{type:"object",properties:{label:{type:"string"},value:{type:"string"},children:{type:"string"},childKeys:{type:"object"}}},children:{type:"string"},label:{type:"string"},value:{type:"string"}}},pickerAttributes:{type:"object"},placeholder:{type:"string"},renderMode:{type:"string"},required:{type:"boolean",value:!1},translations:{type:"object",value:{},properties:{filterFurther:{type:"string"},moreMatchesFound:{type:"string"},noMatchesFound:{type:"string"},oneMatchesFound:{type:"string"},required:{type:"object",properties:{hint:{type:"string"},messageDetail:{type:"string"},messageSummary:{type:"string"}}},searchField:{type:"string"}}},valid:{type:"string",writeback:!0,enumValues:["invalidHidden","invalidShown","pending","valid"],readOnly:!0},value:{type:"Array",writeback:!0},valueOptions:{type:"Array",writeback:!0}},methods:{refresh:{},validate:{},reset:{},showMessages:{},setProperty:{},getProperty:{},setProperties:{},getNodeBySubId:{},getSubIdByNode:{}},events:{ojAnimateStart:{},ojAnimateEnd:{}},extension:{}},r={properties:{describedBy:{type:"string"},disabled:{type:"boolean",value:!1},displayOptions:{type:"object",properties:{converterHint:{type:"Array|string",value:["placeholder","notewindow"]},helpInstruction:{type:"Array|string",value:["notewindow"]},messages:{type:"Array|string",value:["inline"]},validatorHint:{type:"Array|string",value:["notewindow"]}}},help:{type:"object",properties:{instruction:{type:"string"}}},helpHints:{type:"object",properties:{definition:{type:"string",value:""},source:{type:"string",value:""}}},labelHint:{type:"string",value:""},messagesCustom:{type:"Array",writeback:!0,value:[]},minimumResultsForSearch:{type:"number",value:15},optionRenderer:{type:"function"},options:{type:"Array<(oj.Option|oj.Optgroup)>|oj.DataProvider"},optionsKeys:{type:"object",properties:{childKeys:{type:"object",properties:{label:{type:"string"},value:{type:"string"},children:{type:"string"},childKeys:{type:"object"}}},children:{type:"string"},label:{type:"string"},value:{type:"string"}}},pickerAttributes:{type:"object"},placeholder:{type:"string"},renderMode:{type:"string"},required:{type:"boolean",value:!1},translations:{type:"object",value:{},properties:{filterFurther:{type:"string"},moreMatchesFound:{type:"string"},noMatchesFound:{type:"string"},oneMatchesFound:{type:"string"},required:{type:"object",properties:{hint:{type:"string"},messageDetail:{type:"string"},messageSummary:{type:"string"}}},searchField:{type:"string"}}},valid:{type:"string",writeback:!0,enumValues:["invalidHidden","invalidShown","pending","valid"],readOnly:!0},value:{type:"any",writeback:!0,value:"When the value attribute is not set, the first option is used as its initial value if it exists."},valueOption:{type:"object",writeback:!0,properties:{value:{type:"any"},label:{type:"string"}}}},methods:{refresh:{},validate:{},reset:{},showMessages:{},setProperty:{},getProperty:{},setProperties:{},getNodeBySubId:{},getSubIdByNode:{}},events:{ojAnimateStart:{},ojAnimateEnd:{}},extension:{}},h={GENERATED_OPTIONS_SELECTOR:"oj-select-options-generated",KEY:{TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isControl:function(e){switch(e.which){case h.KEY.SHIFT:case h.KEY.CTRL:case h.KEY.ALT:return!0}return!(!e.metaKey&&!e.ctrlKey)},isFunctionKey:function(e){return(e=e.which?e.which:e)>=112&&e<=123}},DEFAULT_FETCH_SIZE:15,DEFAULT_QUERY_DELAY:70,ValueChangeTriggerTypes:{ENTER_PRESSED:"enter_pressed",OPTION_SELECTED:"option_selected",BLUR:"blur",SEARCH_ICON_CLICKED:"search_icon_clicked"},lastMousePosition:{x:0,y:0},nextUid:(o=1,function(){return o++}),scrollBarDimensions:null,each2:function(e,i){for(var s=t.isFunction(e[0])?t(e[0]()):t(e[0]),o=-1,n=e.length;++o");e.appendTo("body");var i={width:e.width()-e[0].clientWidth,height:e.height()-e[0].clientHeight};return e.remove(),i},splitVal:function(e,i){var s,o,n;if(null===e||e.length<1)return[];for(o=0,n=(s=e.split(i)).length;o47&&i<58||i>64&&i<91||i>95&&i<112||i>185&&i<193||i>218&&i<223)&&(i>=96&&i<=105&&(i-=48),t=String.fromCharCode(i),e.shiftKey||(t=t.toLowerCase()),e.preventDefault()),t},installFilteredMouseMove:function(e){e.on("mousemove",function(e){var i=h.lastMousePosition;void 0!==i&&i.x===e.pageX&&i.y===e.pageY||(t(e.target).trigger("mousemove-filtered",e),h.lastMousePosition.x=e.pageX,h.lastMousePosition.y=e.pageY)})},thunk:function(e){var t,i=!1;return function(){return!1===i&&(t=e(),i=!0),t}},_focus:function(t,i){if(i[0]!==document.activeElement){var s=h._addBusyState(t.container,"setting focus");e.TimerUtils.getTimer(40).getPromise().then(function(){var e,t=i[0],o=i.val().length;i.focus(),i.is(":visible")&&t===document.activeElement&&(t.setSelectionRange?t.setSelectionRange(o,o):t.createTextRange&&((e=t.createTextRange()).collapse(!1),e.select())),s()})}},getCursorInfo:function(e){var i=0,s=0;if("selectionStart"in(e=t(e)[0]))i=e.selectionStart,s=e.selectionEnd-i;else if("selection"in document){e.focus();var o=document.selection.createRange();s=document.selection.createRange().text.length,o.moveStart("character",-e.value.length),i=o.text.length-s}return{offset:i,length:s}},killEvent:function(e){e.preventDefault()},killEventImmediately:function(e){e.preventDefault(),e.stopImmediatePropagation()},defaultEscapeMarkup:function(e){var t={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'"};return String(e).replace(/[&<>"'\\]/g,function(e){return t[e]})},local:function(e,i){var s,o,n=e,a=function(e){return""+e.label};t.isArray(n)&&(n={results:o=n}),!1===t.isFunction(n)&&(o=n,n=function(){return o});var l=n();return l&&l.text&&(a=l.text,t.isFunction(a)||(s=l.text,a=function(e){return e[s]})),function(e){var s=e.term,o={results:[]};""!==s||i?(n()&&h.each2(t(n().results),function(t,s){h._processData(e,s,o.results,i,!0,a)}),e.callback(o)):e.callback(n())}},createOptionTag:function(e,i,s,o){var n=t("");return o.addClass("oj-listbox-results-sub"),o.attr("label",s(i)),e.addClass("oj-listbox-result-with-children"),o},listPopulateResults:function(e,i,s){var o=function(e,i,n){var a,l,r,c;i.each(function(i){(l=t(this)).is("li")&&(l.children("ul").length>0?(r=l.contents().filter(function(){return 1!==this.nodeType||"ul"!==this.tagName.toLowerCase()}).text(),a=h.createOptgroupTag(e,r,s),c=l.children("ul"),o(a,c.children(),n+1)):a=h.createOptionTag(n,l.attr("oj-data-value"),l.text(),s),a.appendTo(e))})};o(e,i,0)},ojOptionPopulateResults:function(e,i,s){var o=function(e,i,n){var a,l,r;i.each(function(i){(l=t(this)).is("oj-option")?(r=l.text()||l.attr("label"),a=h.createOptionTag(n,l.prop("value"),r,s)):l.is("oj-optgroup")?(r=l.text()||l.attr("label"),a=h.createOptgroupTag(e,r,s),o(a,l.children(),n+1)):l.is("option")&&(a=l),a.appendTo(e)})};o(e,i,0)},lookupOptionKeys:function(e,t,i){return e[i=t[i]||i]},arrayPopulateResults:function(e,t,i,s){var o=function(e,t,s,n){for(var a,l,r,c,u,d=0,p=t.length;d0?(l=h.createOptgroupTag(e,c,i),o(l,r,s+1,n.childKeys||{})):(u=h.lookupOptionKeys(a,n,"value"),l=h.createOptionTag(s,u,c,i)),l.appendTo(e)};o(e,t,0,s||{})},cleanupResults:function(e){e.children().not("oj-option, oj-optgroup").remove(),e.removeClass("oj-listbox-result-with-children")},_addBusyState:function(t,i){var s={description:"The component identified by '"+t.attr("id")+"' "+i};return e.Context.getContext(t[0]).getBusyContext().addBusyState(s)},_clearBusyState:function(e){e&&e()},isDataProvider:function(t){return!(!t||!e.DataProviderFeatureChecker)&&e.DataProviderFeatureChecker.isIteratingDataProvider(t)},getDataProvider:function(e){if(e){var t=e._dataProvider||e.options;if(h.isDataProvider(t))return t}return null},clearDataProviderWrapper:function(e){e.options._dataProvider=null},_findOption:function(t,i){if(t.children){var s=h._findOption(t.children,i);if(s)return s}else if(e.Object.compareValues(i,t.value))return t;return null},findOption:function(e,t){if(Array.isArray(e)){for(var i=0,s=e.length;i0)o&&o.length&&(s=h.findOptions(o,t)),s&&s.length===o.length||(i=!0);else o&&h.syncValueWithValueOptions(e,o,t)}else{var n,a=e.options.valueOption;if(null!=t)a&&(n=h.findOption(a,t)),n||(i=!0);else a&&h.syncValueWithValueOption(e,a,t)}return i},syncValueWithValueOption:function(t,i,s){var o;o=h.isValueOptionsForPlaceholder(!1,i)?h.isValueForPlaceholder(!1,s)?s:null:i?i.value:null,e.Object.compareValues(o,s)||t._SetValue(o,null,{doValueChangeCheck:!1,_context:{internalSet:!0,writeback:!0}})},syncValueWithValueOptions:function(t,i,s){var o;if(h.isValueOptionsForPlaceholder(!0,i))o=h.isValueForPlaceholder(!0,s)?s:h.getValueForPlaceholder(!0),e.Object.compareValues(o,s)||t._SetValue(o,null,{doValueChangeCheck:!1,_context:{internalSet:!0,writeback:!0}});else if(i){o=[];for(var n=0;n=0&&(o.splice(a,1),s=!0)}s&&e._setOption("value",o)}e._setOption("options",e.options.options)},addDataProviderEventListeners:function(e){var t=h.getDataProvider(e.options);if(t){h.removeDataProviderEventListeners(e);var i=h._handleDataProviderEvents.bind(null,e);e._saveDataProviderEH=i,t.addEventListener("mutate",i),t.addEventListener("refresh",i)}},removeDataProviderEventListeners:function(e){var t=h.getDataProvider(e.options),i=e._saveDataProviderEH;null!=t&&i&&(t.removeEventListener("mutate",i),t.removeEventListener("refresh",i),e._saveDataProviderEH=void 0)},addLoadingIndicator:function(e){if(null==e._saveLoadingIndicator){var i=t(document.createElement("div"));i.uniqueId().attr("role","presentation").addClass("oj-listbox-loading-icon-container");var s=t(document.createElement("div"));s.addClass("oj-icon oj-listbox-loading-icon"),i.append(s),e.prepend(i),e._saveLoadingIndicator=i}},removeLoadingIndicator:function(e){null!=e._saveLoadingIndicator&&e._saveLoadingIndicator.remove(),e._saveLoadingIndicator=void 0},addDropdownMessage:function(e,i,s){if(!e._saveDropdownMessage){var o=t(document.createElement("div"));o.addClass("oj-listbox-filter-message-box");var n=t(document.createElement("div"));n.addClass("oj-listbox-filter-message-text oj-listbox-liveregion"),n.attr({role:"region","aria-live":"polite"});var a=t(document.createElement("div"));a.addClass("oj-listbox-filter-message-separator"),o.append(n),o.append(a),e.prepend(o),n.text(s),e._saveDropdownMessage=o}},removeDropdownMessage:function(e){e._saveDropdownMessage&&(e._saveDropdownMessage.remove(),e._saveDropdownMessage=void 0)},fetchFilteredData:function(t,i,s,o){var n=t,a=h.getDataProvider(n.options),l=[],r={size:i},c=a.getCapability("filter"),u=e.AttributeFilterOperator.AttributeOperator.$co,d=!1;if(c){var p=c.operators;if(p&&p.length>0)for(var v=0;v=r.size)h.addDropdownMessage(o,n,n.getTranslatedString("filterFurther")),n._hasMore=!0;else{if(!t.done&&l.length"):i.is("oj-optgroup")&&(i.wrap("
  • "),s._customOptionRenderer(i.children()),i.children().wrapAll("
      "))})},_init:function(e){var i,s,o=this._classNm,n=this._elemNm;this.ojContext=e.ojContext,this.opts=e=this._prepareOpts(e),this.id=e.id,this.headerInitialized=!1,this.isOjOption=this.ojContext._IsCustomElement()&&!e.options&&e.element.find("oj-option").length>0,void 0!==e.element.data(n)&&null!==e.element.data(n)&&e.element.data(n)._destroy(),this.container=this._createContainer();var a=e.rootAttributes;this.containerId=a&&a.id?a.id:"ojChoiceId_"+(this._getAttribute("id")||"autogen"+h.nextUid()),this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.body=h.thunk(function(){return e.element.closest("body")}),this.container.attr("style",this._getAttribute("style")),this.elementTabIndex=this._getAttribute("tabindex"),this.opts.element.data(n,this).attr("tabindex","-1").before(this.container),this.container.data(n,this),this.dropdown=this.container.find(".oj-listbox-drop"),this.dropdown.data("ojlistbox",this),this._setPickerAttributes(e.pickerAttributes);var l=this.containerId;this.dropdown.attr("data-oj-containerid",l),this.results=i=this.container.find(".oj-listbox-results"),this.results.on("click",h.killEvent);var r=this.ojContext._GetLabelElement();if(r){var c=r.attr("id");c?i.attr("aria-labelledby",c):i.attr("aria-label",r.text())}else{var u=this.ojContext.element.attr("aria-label");u&&i.attr("aria-label",u)}if(e.list&&t("#"+e.list).is("ul")){var d=t("#"+e.list);this.dropdownListParent=d.parent(),d.addClass("oj-listbox-results").attr("role","listbox"),this.results.replaceWith(d),this.results=i=this.container.find(".oj-listbox-results"),this.results.css("display","")}if(this.isOjOption){var p=e.element.children();this._customOptionRenderer(p),this.results.append(e.element.children()),this.datalist=this.results}s="oj-select"==o?this.container.find("input.oj-listbox-input"):this.container.find("input."+o+"-input"),this.search=s,this.queryCount=0,this.resultsPage=0,this.context=null,this._initContainer(),this.container.on("click",h.killEvent),h.installFilteredMouseMove(this.results),this.dropdown.on("mousemove-filtered touchstart touchmove touchend",".oj-listbox-results",this._bind(this._highlightUnderEvent)),t(this.container).on("change","."+o+"-input",function(e){e.stopPropagation()}),t(this.dropdown).on("change","."+o+"-input",function(e){e.stopPropagation()});var v=this;if(h.installKeyUpChangeEvent(s),s.on("keyup-change input paste",this._bind(this._updateResults)),s.on("focus",function(){s.addClass(o+"-focused"),"oj-select"!==o&&v.container.addClass("oj-focus")}),s.on("blur",function(){s.removeClass(o+"-focused"),"oj-select"!==o&&v.container.removeClass("oj-focus")}),this.dropdown.on("mouseup",".oj-listbox-results",this._bind(function(e){t(e.target).closest(".oj-listbox-result-selectable").length>0&&(this._highlightUnderEvent(e),this._selectHighlighted(null,e))})),this.dropdown.on("click mouseup mousedown",function(e){e.stopPropagation()}),t.isFunction(this.opts.initSelection)){this.opts.fetchType="init";var f=this.getValOpts();(!this.ojContext.multiple||f&&0!=f.length)&&(this.ojContext.multiple||f)||(f=null),this._initSelection(f)}var m=e.element.prop("disabled");void 0===m&&(m=!1),this._enable(!m);var _=e.element.prop("readonly");void 0===_&&(_=!1),this._readonly(_),h.scrollBarDimensions=h.scrollBarDimensions||h.measureScrollbar(),this.autofocus=e.element.prop("autofocus"),e.element.prop("autofocus",!1),this.autofocus&&this._focus(),h.addDataProviderEventListeners(e.ojContext)},_clickAwayHandler:function(e){var i=this.dropdown;t(e.target).closest(i).length||t(e.target).closest("#"+i.attr("data-oj-containerid")).length||i.length>0&&i.data("ojlistbox").close(e)},_surrogateRemoveHandler:function(){this.dropdown&&this.dropdown.remove()},_destroy:function(){var e=this._closeDelayTimer;isNaN(e)||(delete this._closeDelayTimer,window.clearTimeout(e));var t=this.opts.element,i=t.data(this._elemNm);this.close(),this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.opts.list&&this.results?(this._cleanupList(this.results),this.dropdownListParent&&this.dropdownListParent.append(this.results)):this.isOjOption&&this.results&&(this._unwrapOjOptions(this.results),this.opts.element.append(this.results.children())),void 0!==i&&(i.container.after(t),i.container.remove(),i.dropdown.remove(),t.removeAttr("aria-hidden").removeData(this._elemNm).off("."+this._classNm).prop("autofocus",this.autofocus||!1),this.elementTabIndex?t.attr({tabindex:this.elementTabIndex}):t.removeAttr("tabindex"),t.show())},_unwrapOjOptions:function(e){var i,s=e.children(),o=this;s.each(function(e){(i=t(this)).is("li")&&(i.hasClass("oj-listbox-result-with-children")||i.children("oj-optgroup").length>0?(i.hasClass("oj-listbox-result-with-children")&&i.children(".oj-listbox-result-label").remove(),o._unwrapOjOptions(i.find("oj-optgroup").children()),i.find("oj-optgroup").children().children().unwrap(),i.find("oj-optgroup").unwrap()):i.hasClass("oj-listbox-result")?i.find("oj-option").unwrap().unwrap():i.find("oj-option").unwrap())})},_cleanupList:function(e){if(e&&e.is("ul")){e.removeClass("oj-listbox-results oj-listbox-result-sub"),e.removeAttr("role");for(var i=e.children().length-1;i>=0;i--)this._cleanupList(t(e.children()[i]))}else if(e.is("li")){(e.hasClass("oj-listbox-placeholder")||e.hasClass("oj-listbox-no-results"))&&e.remove(),e.attr("class")&&e.attr("class",e.attr("class").replace(/\oj-listbox-\S+/g,""));var s=e.children(".oj-listbox-result-label");s&&s.contents().unwrap(),"none"==e.css("display")&&e.css("display",""),this._cleanupList(e.children("ul"))}},_optionToData:function(e){if(e.is("option")||e.is("oj-option"))return{value:e.prop("value")||e.attr("value"),label:e.text().trim()||e.attr("label"),element:e.get(),css:e.attr("class"),disabled:e.prop("disabled"),locked:"locked"===e.attr("locked")||!0===e.data("locked")};if(e.is("optgroup")||e.is("oj-optgroup"))return{label:e.prop("label")||e.attr("label"),disabled:e.prop("disabled"),children:[],element:e.get(),css:e.attr("class")};if(e.is("li")){var t,i,s,o=null,n=e.children();if(n&&n.length>0&&n.is("ul"))t=e.attr("oj-data-label")?e.attr("oj-data-label"):e.clone().children().remove().end().text().trim(),i=e.attr("oj-data-value"),o=[];else if(n&&n.length>0&&n.is("oj-optgroup"))t=n.prop("label"),s=n.prop("disabled"),o=[];else{var a=e.find("oj-option");t=e.attr("oj-data-label")?e.attr("oj-data-label"):e.text().trim(),i=a.length>0?a.prop("value"):e.attr("oj-data-value"),s=a.length>0?a.prop("disabled"):void 0}return{value:i,label:t,disabled:s,element:e.get(),css:e.attr("class"),children:o}}},_prepareOpts:function(e){var i,s=this;e.options&&Array.isArray(e.options)&&e.optionsKeys&&(e.options=t.extend(!0,[],e.options));var o=(i=e.element).get(0).tagName.toLowerCase();if(e.ojContext._IsCustomElement()?!e.options&&e.element.children().length>0&&(this.datalist=t(i)):"input"===o&&i.attr("list")?this.datalist=t("#"+i.attr("list")):"select"===o&&i.children().length>0?this.datalist=i:e.list&&(this.datalist=t("#"+e.list)),(e=t.extend({},{populateResults:function(i,n,a,l){var r,c=this.opts.id,u=this.opts.optionRenderer;"function"!=typeof u&&(u=null),this.opts.ojContext._WrapCustomElementRenderer&&(u=this.opts.ojContext._WrapCustomElementRenderer(u)),(r=function(i,n,l,d,p){var v,f,m,_,b,g,y,j,x=function(e,i){if(i.children&&i.children.length>0){var s=i.element&&t(i.element[0]).is("li")&&t(i.element[0]).children("ul"),o=s?t(i.element[0]).children("ul"):t("
        ");o.hasClass("oj-listbox-result-sub")||o.addClass("oj-listbox-result-sub"),r(i,i.children,o,d+1,!1),s||e.append(o)}},C=function(e,t,i){e.length&&i&&i.length&&e.each(function(){!function e(i,s){var o=0;if(3===i.nodeType){var n=i.data.toUpperCase().indexOf(s);if(n>=0){var a=document.createElement("span");a.className=t;var l=i.splitText(Math.min(n,i.data.length)),r=(l.splitText(Math.min(s.length,l.data.length)),l.cloneNode(!0));a.appendChild(r),l.parentNode.replaceChild(a,l),o=1}}else if(1===i.nodeType&&i.childNodes&&!/(script|style)/i.test(i.tagName))for(var h=0;h")).addClass("oj-listbox-placeholder oj-listbox-results-depth-0 oj-listbox-result oj-listbox-result-selectable"),g.attr("role","presentation"),(y=t(document.createElement("div"))).addClass("oj-listbox-result-label"),y.attr("id","oj-listbox-result-label-"+h.nextUid()),y.attr("role","option"),void 0!==(j=e.formatResult(m))&&y.text(j),y.attr("aria-label",j),g.append(y),g.data(s._elemNm,m),l.prepend(g)),v=0,f=n.length;v")).hasClass("oj-listbox-result"))m.children&&m.children.length>0&&x(g,m),E(t(m.element[0]).children("div")),t(m.element[0]).css("display","");else if(g.addClass("oj-listbox-results-depth-"+d),g.addClass("oj-listbox-result"),g.addClass(_?"oj-listbox-result-selectable":"oj-listbox-result-unselectable"),b&&g.addClass("oj-disabled"),m.children&&g.addClass("oj-listbox-result-with-children"),g.attr("role","presentation"),(y=t(document.createElement("div"))).addClass("oj-listbox-result-label"),y.attr("id","oj-listbox-result-label-"+h.nextUid()),y.attr("role","option"),b&&y.attr("aria-disabled","true"),V||(O(y,m),g.append(y)),m.children&&m.children.length>0&&x(g,m),g.data(s._elemNm,m),V){var w=t(m.element[0]);if(w.children("oj-optgroup").length>0){var P=w.children("oj-optgroup").prop("label")+"";w.prepend(y.text(P))}else w.children("oj-option").length>0?w.contents().wrapAll(y):w.contents().filter(function(){return"UL"!==this.tagName}).wrapAll(y);E(w.children("div")),w.css("display","")}else l.append(g)}})(null,n,i,0,l)},highlightTermInOptions:function(e){return!(!0===e.initial)}},u,e)).id=function(e){return e.value},e.formatResult=function(e){var t=h.getLabel(e);return isNaN(t)?t:this.ojContext._formatValue(t)},e.formatSelection=function(e){var t=h.getLabel(e);return e&&t?isNaN(t)?t:this.ojContext._formatValue(t):void 0},"select"!==o&&null!==e.manageNewEntry&&(e.manageNewEntry=function(e){var i={};return i.value=i.label=t.trim(e),i}),this.datalist)e.query=this._bind(function(e){var t,i,o={results:[],more:!1},n=e.term;i=function(t,o){var a,l,r=t.children()&&t.children().length>0&&(t.children().is("ul")||t.children().is("oj-optgroup"));t.is("option")||t.is("oj-option")||t.is("li")&&!r?e.matcher(n,t.text()||t.attr("label"),t)&&o.push(s._optionToData(t)):(t.is("optgroup")||t.is("oj-optgroup")||t.is("li")&&r)&&(a=s._optionToData(t),t.is("optgroup")||t.is("oj-optgroup")?l=t.children():t.children("oj-optgroup")?l=t.children().children("ul").children():t.children("ul").children(),h.each2(l,function(e,t){i(t,a.children)}),a.children.length>0&&o.push(a))},t=this.datalist.children(),void 0!==this._getPlaceholder()&&t.length>0&&""==t.first().attr("value")&&(t=t.slice(1)),h.each2(t,function(e,t){i(t,o.results)}),e.callback(o)});else if("options"in e){var n=e.options;h.getDataProvider(e)?e.query=function(t){t.value?h.fetchByKeyFromDataProvider(s.container,e,t):h.fetchFromDataProvider(s,e,t)}:t.isFunction(n)?e.query=h.remote(n,e.optionsKeys?e.optionsKeys:null):e.query=h.local(n,e.optionsKeys?e.optionsKeys:null)}return e},_createHeader:function(){var e=this.opts.element.find(".oj-listbox-header");if(e.length){this.header=t("
      • ",{class:"oj-listbox-result-header oj-listbox-result-unselectable",role:"presentation"}),this.header.append(e.children()),this._initializeHeaderItems();var i=t("
          ",{class:"oj-listbox-results-with-header",role:"listbox"});i.append(this.header),i.appendTo(this.results.parent());var s=t("
        • ",{role:"presentation"});i.append(s),this.results.attr("role","presentation"),this.results.appendTo(s)}this.headerInitialized=!0},_initializeHeaderItems:function(){this.headerItems=this.header.find("li[role='option'], li:not([role])"),this.headerItems.uniqueId(),this.header.find("ul").attr("role","presentation"),this.header.find("li:not([role])").attr("role","option");this.header.find("a, input, select, textarea, button, object, .oj-component-initnode").each(function(){t(this).attr("tabIndex",-1)})},_isHeaderItem:function(e){var i=!1;return this.headerItems.each(function(){if(t(this).attr("id")===e)return i=!0,!1}),i},_getNextHeaderItem:function(e){if(!this.headerItems)return null;if(!e)return this.headerItems.first();var i=!1,s=null;return this.headerItems.each(function(){if(i)return s=t(this),!1;i=t(this).attr("id")===e}),s},_getPreviousHeaderItem:function(e){if(!this.headerItems)return null;var i=null;return this.headerItems.each(function(){if(t(this).attr("id")===e)return!1;i=t(this)}),i},_setFocusOnHeaderItem:function(e){var t=e.find(".oj-component .oj-enabled").first();if(0===t.length){0===(t=e.find("a, input, select, textarea, button, object, .oj-component-initnode").first()).length&&(t=e.children().first())}t&&t.addClass("oj-focus oj-focus-highlight oj-focus-only")},_removeHighlightFromHeaderItems:function(){this.headerItems&&this.headerItems.find(".oj-focus").removeClass("oj-focus oj-focus-highlight oj-focus-only")},_triggerSelect:function(e){var i=t.Event(this._elemNm+"-selecting",{val:this.id(e),object:e});return this.opts.element.trigger(i),!i.isDefaultPrevented()},_isInterfaceEnabled:function(){return!0===this.enabledInterface},_enableInterface:function(){var e=this._enabled&&!this._readonly,t=!e;return e!==this.enabledInterface&&(this.container.toggleClass("oj-disabled",t),this.close(),this.enabledInterface=e,!0)},_enable:function(e){void 0===e&&(e=!0),this._enabled!==e&&(this._enabled=e,this.opts.element.prop("disabled",!e),this.container.toggleClass("oj-enabled",e),this._enableInterface())},_disable:function(){this._enable(!1)},_readonly:function(e){return void 0===e&&(e=!1),this._readonly!==e&&(this._readonly=e,this.opts.element.prop("readonly",e),this._enableInterface(),!0)},_opened:function(){return this.container.hasClass("oj-listbox-dropdown-open")},_getDropdownPositionElement:function(){return this.container.children().first()},_usingHandler:function(i,s){if(e.PositionUtils.isAligningPositionClipped(s)){var o=h._addBusyState(this.container,"closing popup");this._closeDelayTimer=window.setTimeout(function(){t.proxy(this.close,this),o()},1)}else{var n=this.container,a=s.element.element;a.css(i),"bottom"===s.vertical?(n.addClass("oj-listbox-drop-above"),a.addClass("oj-listbox-drop-above")):(n.removeClass("oj-listbox-drop-above"),a.removeClass("oj-listbox-drop-above"))}},_getDropdownPosition:function(){var i={my:"start top",at:"start bottom",of:this._getDropdownPositionElement(),collision:"flip",using:t.proxy(this._usingHandler,this)},s="rtl"===e.DomUtils.getReadingDirection();return e.PositionUtils.normalizeHorizontalAlignment(i,s)},_positionDropdown:function(){var e=this.dropdown,t=this._getDropdownPosition(),i=this.container;e.css("width",i.outerWidth()),e.position(t)},_shouldOpen:function(e){if(this._opened())return!1;if(!1===this._enabled||!0===this._readonly)return!1;var t={component:this.opts.element};return this.ojContext._trigger("beforeExpand",e,t)},_clearDropdownAlignmentPreference:function(){this.container.removeClass("oj-listbox-drop-above"),this.dropdown.removeClass("oj-listbox-drop-above")},open:function(e,t){return!!this._shouldOpen(e)&&(this._opening(e,t),!0)},_opening:function(){this.headerInitialized||this._createHeader(),this.container.addClass("oj-listbox-dropdown-open")},_showDropDown:function(){if(this._opened()&&"true"!==this._getActiveContainer().attr("aria-expanded")){this._clearDropdownAlignmentPreference();var i=this.dropdown.parent();if("oj-select"===this._classNm&&!0!==this.opts.multiple&&i&&i.hasClass("oj-listbox-drop-layer"))e.PopupService.getInstance().triggerOnDescendents(i,e.PopupService.EVENT.POPUP_REFRESH);else{this.dropdown[0]!==this.body().children().last()[0]&&this.dropdown.detach().appendTo(this.body()),this.dropdown.appendTo(this.body()),this.header&&(this.dropdown.find(".oj-listbox-results-with-header").prepend(this.header),this.header.show());var s={};s[e.PopupService.EVENT.POPUP_CLOSE]=t.proxy(this.close,this),s[e.PopupService.EVENT.POPUP_REMOVE]=t.proxy(this._surrogateRemoveHandler,this),s[e.PopupService.EVENT.POPUP_AUTODISMISS]=t.proxy(this._clickAwayHandler,this),s[e.PopupService.EVENT.POPUP_REFRESH]=t.proxy(this._positionDropdown,this);var o={};o[e.PopupService.OPTION.POPUP]=this.dropdown,o[e.PopupService.OPTION.LAUNCHER]=this.opts.element,o[e.PopupService.OPTION.EVENTS]=s,o[e.PopupService.OPTION.POSITION]=this._getDropdownPosition(),o[e.PopupService.OPTION.LAYER_SELECTORS]="oj-listbox-drop-layer",o[e.PopupService.OPTION.CUSTOM_ELEMENT]=this.ojContext._IsCustomElement(),e.PopupService.getInstance().open(o),t("#oj-listbox-drop").removeAttr("id"),this.dropdown.attr("id","oj-listbox-drop");var n=this.containerId;this.dropdown.attr("data-oj-containerid",n)}this._positionDropdown(),this._getActiveContainer().attr("aria-expanded",!0)}},close:function(i){if(this._opened()){this.container.removeClass("oj-listbox-dropdown-open");var s=this._getActiveContainer().attr("aria-expanded");if(delete this.ojContext._resolveSearchBoxLater,s&&"false"!==s){var o=this.containerId,n="scroll."+o,a="resize."+o,l="orientationchange."+o;this.container.parents().add(window).each(function(){t(this).off(n).off(a).off(l)}),this._clearDropdownAlignmentPreference();var r={};r[e.PopupService.OPTION.POPUP]=this.dropdown,e.PopupService.getInstance().close(r),this.header&&(this.header.hide(),this.header.appendTo(this.container)),this.dropdown.removeAttr("data-oj-containerid"),this.dropdown.removeAttr("id"),this.opts.list||this.isOjOption?this._removeHighlight():(this.dropdown.detach(),this.results.empty()),this._getActiveContainer().attr("aria-expanded",!1),"ojcombobox"===this._elemNm&&this._getActiveContainer().removeAttr("aria-activedescendant"),t.removeData(this.container,this._classNm+"-last-term")}}},_setPickerAttributes:function(t){e.EditableValueUtils.setPickerAttributes(this.dropdown,t)},_clearSearch:function(){},_ensureHighlightVisible:function(){var e,i,s,o,n,a,l,r=this.results;(i=this._highlight())<0||(e=this._findHighlightableChoices(),o=(s=t(e[i])).offset().top+s.outerHeight(!0),i===e.length-1&&(l=r.find("li.oj-listbox-more-results")).length>0&&(o=l.offset().top+l.outerHeight(!0)),o>(n=r.offset().top+r.outerHeight(!0))&&r.scrollTop(r.scrollTop()+(o-n)),(a=s.offset().top-r.offset().top)<0&&"none"!=s.css("display")&&r.scrollTop(r.scrollTop()+a))},_findHighlightableChoices:function(){return this.results.find(".oj-listbox-result-selectable:not(.oj-disabled, .oj-selected)").filter(function(){return"none"!=t(this).css("display")})},_moveHighlight:function(e){var i=this._findHighlightableChoices(),s=this._highlight();if(this.header&&(s<=0||s===i.length-1)){var o=this._getActiveContainer().attr("aria-activedescendant"),n=this._isHeaderItem(o);n||(o=null);var a=null;if(e>0&&(s<0||s===i.length-1)?a=this._getNextHeaderItem(o):e<0&&(n&&s<0||0===s)&&(a=this._getPreviousHeaderItem(o)),a)return this._removeHighlight(),this._setFocusOnHeaderItem(a),void this._getActiveContainer().attr("aria-activedescendant",a.attr("id"));n&&e<0&&(s=0)}for(;s>=-1&&s=s.length&&(e=s.length-1),e<0&&(e=0),this._removeHighlight(),(i=t(s[e])).hasClass("oj-listbox-result-with-children")){var l=i.children(".oj-listbox-result-label");l.addClass("oj-hover"),n&&this._updateMatchesCount(l.text())}else i.addClass("oj-hover"),n&&this._updateMatchesCount(i.text());this._getActiveContainer().attr("aria-activedescendant",i.find(".oj-listbox-result-label").attr("id")),this._ensureHighlightVisible()},_removeHighlight:function(){this.results.find(".oj-hover").removeClass("oj-hover"),this._removeHighlightFromHeaderItems(),"ojcombobox"===this._elemNm&&this._getActiveContainer().removeAttr("aria-activedescendant")},_highlightUnderEvent:function(e){var i=t(e.target).closest(".oj-listbox-result-selectable");if(i.length>0&&!i.is(".oj-hover")){var s=this._findHighlightableChoices();this._highlight(s.index(i))}else 0==i.length&&this._removeHighlight()},_updateMatchesCount:function(e){if(!this.dropdown.find(".oj-listbox-filter-message-text").length){var t=this.container.find(".oj-listbox-liveregion");t.length&&t.text(e)}},_updateResults:function(i){var s=this.search,o=this,n=s.val(),a=t.data(this.container,this._classNm+"-last-term");if((!0===i||!a||n!==a||!0===this.opts.multiple)&&(a||n||!i||"input"!==i.type)){t.data(this.container,this._classNm+"-last-term",n);var l=this.opts.minLength||0;n.length>=l?(this._queryTimer&&this._queryTimer.clear(),i&&!0!==i?(this._queryResolveBusyState=h._addBusyState(this.container,"query results"),this._queryTimer=e.TimerUtils.getTimer(h.DEFAULT_QUERY_DELAY),this._queryTimer.getPromise().then(function(e){e&&o._queryResults(i)}).then(this._queryResolveBusyState)):this._queryResults(i)):this.close()}},_queryResults:function(e){var t,i,s=this.search,o=this.results,n=this.opts,a=this,l=s.val();function r(){if(a._positionDropdown(),a.header&&a.headerItems.length){var e=a._findHighlightableChoices(),t=a.headerItems.length+e.length;if(a.headerItems.attr("aria-setsize",t),e.length){var i=e.children("[role='option']");i.attr("aria-setsize",t),i.first().attr("aria-posinset",a.headerItems.length+1)}}}(n.minLength||0)>l.length?this.close():(this.open(null,!0),i=++this.queryCount,this._removeHighlight(),l=null!=(t=this.search.val())&&(!0!==e||n.inputSearch||"rawValue"===n.filterOnOpen||n.minLength>0)?t:"",this.resultsPage=1,n.query({element:n.element,term:l,page:this.resultsPage,context:null,matcher:n.matcher,callback:this._bind(function(t){if(i===this.queryCount&&this._opened())if(n.ojContext._hasMore||h.removeDropdownMessage(a.dropdown),this.context=t&&void 0!==t.context?t.context:null,(!t||t.results&&0===t.results.length||this._isDataSelected(t)&&this.ojContext.isValid())&&h.checkFormatter(a.ojContext,n.formatNoMatches,"formatNoMatches")){var l=n.formatNoMatches(a.ojContext,s.val());if("oj-select"===this._classNm||this.header){if(this._showDropDown(),this._preprocessResults(o),r(),h.addDropdownMessage(a.dropdown,a.ojContext,l),!this._hasSearchBox()){var c=a.dropdown.find(".oj-listbox-filter-message-separator");c.length&&c.css("display","none")}}else this.close();this._updateMatchesCount(l)}else h.saveLastQueryResult(this,t.results),this._showDropDown(),this._preprocessResults(o),a.opts.populateResults.call(this,o,t.results,{term:s.val(),page:this.resultsPage,context:null,initial:e},this._showPlaceholder()),this._postprocessResults(t,e),r(),this._updateMatchesCount(n.formatMoreMatches(a.ojContext,this._findHighlightableChoices().length))})}))},_preprocessResults:function(e){if(this.opts.list||this.isOjOption){var t=e.children();t.find(".oj-listbox-highlighter");this._hideResultList(t)}else e.empty()},_normalizeHighlighterLabel:function(e){var i,s;if(e.children("div").children("oj-option").length>0?(i=e.children("div").children("oj-option").children(".oj-listbox-highlighter"),s=e.children("div").children("oj-option")[0]):(i=e.children("div").children(".oj-listbox-highlighter"),s=e.children("div")[0]),i.length>0){for(var o=0;o=1)return i[1]}.call(this);null!==e&&this.container.css("width",e)},getVal:function(){return this.ojContext.option("value")},setVal:function(e,t,i){var s={doValueChangeCheck:!1};i&&(s._context=i);var o=this.ojContext.multiple;if(!this._skipSetValueOptions)if(h.isValueForPlaceholder(o,e)&&null!==this._getPlaceholder())this.setValOpts(h.getValueOptionsForPlaceholder(o));else{var n,a=h.getLastQueryResult(this);a&&(n=o?h.findOptions(a,e):h.findOption(a,e)),n?this.setValOpts(n):"oj-combobox"===this._classNm?this.ojContext._resolveValueOptionsLater=null!=h.findOption(this.getValOpts(),e):this.ojContext._resolveValueOptionsLater=!0}Array.isArray(e)||this.ojContext._IsCustomElement()?this.ojContext._SetValue(e,t,s):this.ojContext._SetValue([e],t,s)},getValOpts:function(){var e=this.ojContext;return e.multiple?e.option("valueOptions"):e.option("valueOption")},setValOpts:function(e){var t=this.ojContext,i=t.multiple;h.isValueOptionsForPlaceholder(i,e)&&null!==this._getPlaceholder()&&(e=h.getValueOptionsForPlaceholder(i)),h.setValueOptions(t,e),i?this.opts.valueOptions=e:this.opts.valueOption=e},_triggerUpdateEvent:function(e,t,i){},_triggerValueUpdatedEvent:function(e,t){},_showPlaceholder:function(){return!1},_getActiveContainer:function(){return this.search},_getAttribute:function(e){return this.opts.ojContext._IsCustomElement()?this.opts.ojContext.OuterWrapper.getAttribute(e):this.opts.element.attr(e)},_showSearchBox:function(e){var i=!1,s=this.dropdown.find(".oj-listbox-search");if(s&&(this._hasSearchBox()?(this.dropdown.find(".oj-listbox-search-wrapper").removeClass("oj-helper-hidden-accessible"),t(s).removeAttr("aria-hidden"),this.search.val(e),i=!0):(this.dropdown.find(".oj-listbox-search-wrapper").addClass("oj-helper-hidden-accessible"),t(s).attr("aria-hidden","true"))),h._focus(this,i?this.search:this.selection),i){var o=this;s.find(".oj-listbox-spyglass-box").on("mouseup click",function(e){o.search.focus(),e.preventDefault()})}},_hasSearchBox:function(){if(this._userTyping)return!0;var e,i=this.opts.minimumResultsForSearch;return this.opts.list?e=t("#"+this.opts.list).find("li").length:h.isDataProvider(this.opts.options)?void 0===this.ojContext._resultCount?(e=i+1,this.ojContext._resolveSearchBoxLater=!0):(e=this.ojContext._resultCount,delete this.ojContext._resolveSearchBoxLater):this.datalist?e=this.ojContext._IsCustomElement()?this.datalist.children().find("oj-option").length:this.datalist[0].length:this.opts.options&&(e=this.opts.options.length),e>i},_isDataSelected:function(e){return!1},_findItem:function(e,i){for(var s=0;s=0},separator:","},d=h.clazz(c,{_enableInterface:function(){d.superclass._enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this._isInterfaceEnabled())},_focus:function(){this._opened()&&this.close()},_destroy:function(){t("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id")),d.superclass._destroy.apply(this,arguments)},_clear:function(t){if(this.selection.data(this._elemNm)){t||e.Logger.warn("Event should not be null when user modified the value in UI");var i=this.ojContext._IsCustomElement()?"":[];"oj-select"===this._classNm&&this.ojContext._IsRequired()||this.setVal(i,t),this.search.val(""),this.selection.removeData(this._elemNm)}this._setPlaceholder()},_initSelection:function(){if(!h.applyValueOptions(this,this.opts)){var e=this.datalist?this.datalist:this.opts.element;this.opts.initSelection.call(null,e,this._bind(this._updateSelectedOption))}},_containerKeydownHandler:function(e){if(this._isInterfaceEnabled())if(e.which!==h.KEY.PAGE_UP&&e.which!==h.KEY.PAGE_DOWN){switch(e.which){case h.KEY.UP:case h.KEY.DOWN:return this._opened()?this._moveHighlight(e.which===h.KEY.UP?-1:1):this.open(e),void e.preventDefault();case h.KEY.ENTER:return this._selectHighlighted(null,e),e.preventDefault(),void(this._opened()||(this._userTyping=!1));case h.KEY.TAB:return this.close(e),void(this._userTyping=!1);case h.KEY.ESC:return this._opened()&&(this._cancel(e),e.preventDefault()),void(this._userTyping=!1)}this._userTyping=!0}else e.preventDefault()},_containerKeyupHandler:function(e){this._isInterfaceEnabled()&&(this._opened()||this.open(e))},_initContainer:function(){var e,i,s=this.container,o=(this.dropdown,this.opts.rootAttributes),n=o&&o.id?o.id:this._getAttribute("id")||h.nextUid();this.selection=e=s.find("."+this._classNm+"-choice"),e.attr("id",this._classNm+"-choice-"+n),(i=t("label[for='"+this._getAttribute("id")+"']")).attr("id")||i.attr("id",this._classNm+"-label-"+n),e.find("."+this._classNm+"-input").attr("id",this._classNm+"-input-"+n),this.results.attr("id")||this.results.attr("id","oj-listbox-results-"+n);var a=s.find(".oj-listbox-liveregion");a.length&&a.attr("id","oj-listbox-live-"+n),"oj-select"!==this._classNm&&this.search.attr("aria-owns",this.results.attr("id")),this.search.attr("aria-labelledby",i.attr("id")),this.opts.element.attr("aria-labelledby",i.attr("id")),this.search.attr("id")&&i.attr("for",this.search.attr("id")),this._getAttribute("aria-label")&&this.search.attr("aria-label",this._getAttribute("aria-label")),this._getAttribute("aria-controls")&&this.search.attr("aria-controls",this._getAttribute("aria-controls")),e.on("keydown",this._bind(this._containerKeydownHandler)),e.on("mousedown","abbr",this._bind(function(e){this._isInterfaceEnabled()&&(this._clear(e),h.killEventImmediately(e),this.close(e),this.selection.focus())})),e.on("mousedown",this._bind(function(i){if(!("end"===i.target.getAttribute("slot")||t(this._endSlot).find(i.target).length>0)){this.opts.element.prop("disabled")&&h.killEvent(i),e.removeClass("oj-focus-highlight"),this._opened()?this.close(i):this._isInterfaceEnabled()&&this.open(i);var s=this.search.parent().attr("aria-hidden");s&&"true"==s?this.selection.focus():this.search.focus(),t(i.target).hasClass("oj-combobox-open-icon")&&h.killEvent(i),this.container.addClass("oj-active")}})),e.on("mouseup",this._bind(function(e){this.container.removeClass("oj-active")})),e.on("focus",this._bind(function(e){h.killEvent(e)})),this.search.on("input",this._bind(function(e){this.ojContext._SetRawValue(this.search.val(),e)})),this.search.on("focus",this._bind(function(){this._previousDisplayValue=this.search.val()})),this.search.on("blur keyup",this._bind(function(e){if("keyup"!==e.type||10===e.keyCode||13===e.keyCode){if(void 0!==this.search.val()&&this.results.find(".oj-hover").length<=0&&("keyup"!==e.type||!this.enterKeyEventHandled))if(this.opts.manageNewEntry){var t=this.search.val(),i=this.opts.manageNewEntry(t),s={trigger:"blur"===e.type?h.ValueChangeTriggerTypes.BLUR:h.ValueChangeTriggerTypes.ENTER_PRESSED},o=this.selection.data(this._elemNm),n=this.getVal();!o&&""!==t||o&&o.label!==t||!this.ojContext.isValid()&&t!==this._previousDisplayValue?(this._onSelect(i,s,e),"blur"!==e.type&&(this._triggerUpdateEvent(i,s,e),this._triggerValueUpdatedEvent(i,n))):"keyup"===e.type&&(o&&o.label===t&&(i=o),this._triggerUpdateEvent(i,s,e),this._triggerValueUpdatedEvent(i,n))}else if(null==this.opts.manageNewEntry){i=this.selection.data(this._elemNm);if(""==this.search.val())"oj-select"!==this._classNm&&this._clear(e);else if(i||""===this.search.val()){if("oj-select"!==this._classNm){var a=this.opts.formatSelection(i);void 0!==a&&this.search.val(a)}}else this._clearSearch()}this.search.removeClass(this._classNm+"-focused"),this.container.removeClass("oj-focus"),this.enterKeyEventHandled=!1}})),this._initContainerWidth(),this.opts.element.hide().attr("aria-hidden",!0),this.container.append(this.opts.element),this._setPlaceholder()},_prepareOpts:function(){var i=d.superclass._prepareOpts.apply(this,arguments),s=this,o=i.element.get(0).tagName.toLowerCase();if("input"===o&&i.element.attr("list")||"select"===o&&i.element.children().length>0||i.ojContext._IsCustomElement()&&!i.options||i.list){var n=i.list?"li":"option";i.ojContext._IsCustomElement()&&(n="oj-option"),i.initSelection=function(a,l){var r,h=s.getVal();Array.isArray(h)&&!i.ojContext._IsCustomElement()&&(h=h[0]),null!=h&&(r=s._optionToData(a.find(n).filter(function(){var t;return"li"==n?t=this.getAttribute("oj-data-value"):"option"!=n&&"oj-option"!=n||(t=this.value),e.Object.compareValues(t,h)})),"select"===o&&void 0===r&&(h=null)),null==h&&(r=s._optionToData(a.find(n).filter(function(){return"li"==n?!0===this.getAttribute("oj-data-selected"):"option"==n?this.selected:void 0})),"oj-select"===s._classNm&&void 0===r&&i.ojContext._IsCustomElement()&&(r=s._optionToData(t(a.find(n)[0])))),l(r)},i.validate=function(t,i){var o;return null!=i&&(o=s._optionToData(t.find(n).filter(function(){var t;return"li"==n?t=this.getAttribute("oj-data-value"):"option"!=n&&"oj-option"!=n||(t=this.value),e.Object.compareValues(t,i)}))),!!o}}else("options"in i||this.getVal()&&this.getVal().length>0)&&(h.isDataProvider(i.options)||t.isFunction(i.options)?i.initSelection=function(o,n){var a=function(t,s){for(var o=0,n=t.length;o=0&&this._highlight(n)},_onSelect:function(e,t,i){var s,o;this._triggerSelect(e)&&(t&&t.trigger&&(s={optionMetadata:{trigger:t.trigger}}),this.close(i),0===this.id(e).length?(o=this.ojContext._IsCustomElement()?"":[],e=[]):o=this.id(e),"oj-combobox"===this._classNm&&(this._skipSetValueOptions=!0,this.setValOpts(h.findOptionFromResult(this,o,e))),this.setVal(o,i,s),this._skipSetValueOptions=!1,"blur"!==i.type&&this._focusSearch())},_clearSearch:function(){this.search.val("")},_getValueItem:function(){var e=null,t=this.getVal();return null!=t&&(e=!this.ojContext._IsCustomElement()&&t.length?t[0]:t),e}}),p=h.clazz(d,{_elemNm:"ojcombobox",_classNm:"oj-combobox",_createContainer:function(){var i=t(document.createElement("div")).attr({class:"oj-combobox oj-component"}).html(["",""].join(""));if(this.ojContext._IsCustomElement()){var s=e.BaseCustomElementBridge.getSlotMap(this.ojContext.OuterWrapper).end;s&&(i.find(".oj-combobox-divider").remove(),i.find(".oj-combobox-arrow").remove(),i.find(".oj-combobox-choice").append(s),this._endSlot=s)}return i},_triggerValueUpdatedEvent:function(e,t){if(this.ojContext._IsCustomElement()){var i=this.id(e);if(null==i&&(i=e.label?e.label:""),void 0!==this.ojContext._Validate(i,null,null)&&this.ojContext.isValid()){var s={},o=this.ojContext.OuterWrapper;s.value=i,s.previousValue=t;var n=new CustomEvent("ojValueUpdated",{detail:s});o.dispatchEvent(n)}}},_enable:function(e){p.superclass._enable.apply(this,arguments),this._enabled?this.container.find(".oj-combobox-arrow").removeClass("oj-disabled"):this.container.find(".oj-combobox-arrow").addClass("oj-disabled")},close:function(e){this._opened()&&p.superclass.close.apply(this,arguments)},_opening:function(e,t){p.superclass._opening.apply(this,arguments),t||this._updateResults(!0)},_containerKeydownHandler:function(e){h.KEY.isControl(e)||h.KEY.isFunctionKey(e)||p.superclass._containerKeydownHandler.apply(this,arguments)},_updateSelection:function(e){var t,i=[];this.selection.data(this._elemNm,e),null!==e&&0!=e.length?(void 0!==(t=this.opts.formatSelection(e))&&this.search.val()!==t&&this.search.val(t),this.search.removeClass(this._classNm+"-default"),i.push(e)):(this.search.val(""),this._setPlaceholder()),this.currentItem=i,this.opts.allowClear&&this.container.addClass(this._classNm+"-allowclear")},_updateSelectedOption:function(e){if(null!=e)this._updateSelection(e),this.setValOpts(e);else{var t,i=this.getVal();t=i?Array.isArray(i)?i.length?{label:i[0]}:null:{label:i}:null,this._updateSelection(t),!e&&i?this.setValOpts({value:i,label:h.getLabel({value:i})}):this.setValOpts(e)}}}),v=h.clazz(d,{_elemNm:"ojselect",_classNm:"oj-select",_userTyping:!1,_createContainer:function(){return t(document.createElement("div")).attr({class:"oj-select oj-component"}).html(["","","
          "].join(""))},_enable:function(e){v.superclass._enable.apply(this,arguments),this._enabled?(this.selection.attr("tabindex","0"),this.container.find(".oj-select-arrow").removeClass("oj-disabled")):(this.selection.attr("tabindex","-1"),this.container.find(".oj-select-arrow").addClass("oj-disabled"))},close:function(e){this._opened()&&(v.superclass.close.apply(this,arguments),this.selection.attr("aria-expanded",!1).removeAttr("aria-haspopup").removeAttr("aria-owns"),this.search.attr("aria-expanded",!1).removeAttr("aria-controls"),this._testClear(e)||this._clearSearch(),e instanceof MouseEvent&&e.target!=this.selection&&e.target!=this.search||h._focus(this,this.selection),this.container.find(".oj-listbox-spyglass-box").off("mouseup click"))},_opening:function(e,t){v.superclass._opening.apply(this,arguments);var i=h.getSearchText(e);this._showSearchBox(i),t||(i?this._updateResults():this._updateResults(!0))},_showDropDown:function(){if(this._opened()){var e="true"!==this.selection.attr("aria-expanded");v.superclass._showDropDown.apply(this,arguments),e&&(this.selection.attr("aria-expanded",!0).attr("aria-haspopup","dialog").attr("aria-owns",this.results.attr("id")),this.search.attr("aria-expanded",!0).attr("aria-controls",this.results.attr("id")+" "+this.container.find(".oj-listbox-liveregion").attr("id")))}},_initContainer:function(){var e=this.containerId+"_selected";this.text=this.container.find(".oj-select-chosen").attr("id",e),v.superclass._initContainer.apply(this,arguments),this.selection.attr({"aria-labelledby":this.search.attr("aria-labelledby"),"aria-describedby":e});var t=this._getAttribute("aria-label");t&&this.selection.attr("aria-label",t),this.search.on("keydown",this._bind(this._containerKeydownHandler)),this.search.on("keyup-change input",this._bind(this._containerKeyupHandler)),this.search.attr("title",this.ojContext.getTranslatedString("searchField"));var i=this;this.selection.on("blur",function(e){i._testClear(e)})},_initSelection:function(){this._isPlaceholderOptionSelected()?(this._updateSelection(null),this.close(),this._setPlaceholder()):v.superclass._initSelection.apply(this,arguments)},_updateSelectedOption:function(t){if(null!=t){var i,s=this.getVal();Array.isArray(s)&&!this.ojContext._IsCustomElement()&&(s=s[0]),void 0===(i=this.opts.id(t))&&(i=null),e.Object.compareValues(s,i)||this.ojContext._setInitialSelectedValue(i),this.setValOpts(t),this._updateSelection(t),this.close()}else this.setValOpts(null)},_updateSelection:function(e){this.selection.data(this._elemNm,e),null!==e&&this.text.text("string"==typeof e?e:h.getLabel(e)),e&&""!=e.id&&this.text.removeClass(this._classNm+"-default"),this.opts.allowClear&&this.container.addClass(this._classNm+"-allowclear")},_getActiveContainer:function(){return this.search.attr("aria-expanded")&&this._hasSearchBox()?this.search:this.selection},_isPlaceholderOptionSelected:function(){if(null===this._getPlaceholder())return!1;var e=this.getVal();return""===(e=Array.isArray(e)?e[0]:e)||null==e},_getPlaceholder:function(){return this.opts.placeholder},_showPlaceholder:function(){return!0},_setPlaceholder:function(){var e=this._getPlaceholder();this._isPlaceholderOptionSelected()&&void 0!==e&&(void 0===e&&(e=""),this.text.text(e).addClass(this._classNm+"-default"),this.container.removeClass(this._classNm+"-allowclear"))},setVal:function(e,t,i){v.superclass.setVal.call(this,e,t,i),this.selection.data("selectVal",e)},_containerKeydownHandler:function(e){if(!(h.KEY.isControl(e)&&e.which!=h.KEY.SHIFT||e.which==h.KEY.SHIFT||h.KEY.isFunctionKey(e))){switch(e.which){case h.KEY.TAB:return this.close(e),this.selection.focus(),void this._testClear(e);case h.KEY.ENTER:if(e.target===this.selection[0]&&!this._opened())return this.open(e),void e.preventDefault()}if(v.superclass._containerKeydownHandler.apply(this,arguments),this._userTyping)if(this._opened()){var i=this.dropdown.find(".oj-listbox-search");if("true"===t(i).attr("aria-hidden")){var s=h.getSearchText(e);s&&(this._showSearchBox(s),this._updateResults())}}else this.open(e)}},_testClear:function(e){return""==this.text.text()&&((!this.datalist||!this.selection.data(this._elemNm).value)&&(this._clear(e),!0))}}),f=h.clazz(c,{_prepareOpts:function(){var i=f.superclass._prepareOpts.apply(this,arguments),s=this,o=i.element.get(0).tagName.toLowerCase();if("input"===o&&i.element.attr("list")||"select"===o&&i.element.children().length>0||i.ojContext._IsCustomElement()&&!i.options||i.list){var n=i.list?"li":"option";i.ojContext._IsCustomElement()&&(n="oj-option"),i.initSelection=function(t,i){var a=[];if(s.getVal())for(var l=s.getVal(),r=0;r=0&&o.push(r),r.children){var h=a(r.children,s);h&&h.length&&t.merge(o,h)}}return o},l=s.getVal(),r=[],c=h.getLastQueryResult(s);c&&(r=a(c,l));var u=function(){for(var t=[],o=0;o0||(this._selectChoice(null),this._opened()?this.close(e):(this.open(e),("ojcombobox"===this._elemNm||this._hasSearchBox())&&this._focusSearch()),e.preventDefault()))})),this.container.on("focus",s,this._bind(function(){this._isInterfaceEnabled()})),this._initContainerWidth(),this.opts.element.hide().attr("aria-hidden",!0),this.container.append(this.opts.element),this._clearSearch()},_containerKeydownHandler:function(e){if(this._isInterfaceEnabled()){++this.keydowns;var t=this.selection.find("."+this._classNm+"-selected-choice.oj-focus"),i=t.prev("."+this._classNm+"-selected-choice:not(."+this._classNm+"-locked)"),s=t.next("."+this._classNm+"-selected-choice:not(."+this._classNm+"-locked)"),o="ojselect"!==this._elemNm||this._userTyping?h.getCursorInfo(this.search):h.getCursorInfo(this.selection);if(t.length&&(e.which==h.KEY.LEFT||e.which==h.KEY.RIGHT||e.which==h.KEY.BACKSPACE||e.which==h.KEY.DELETE||e.which==h.KEY.ENTER)){var n=t;return e.which==h.KEY.LEFT&&i.length?n=i:e.which==h.KEY.RIGHT?n=s.length?s:null:e.which===h.KEY.BACKSPACE?(this._unselect(t.first(),e),this._resetSearchWidth(),n=i.length?i:s):e.which==h.KEY.DELETE?(this._unselect(t.first(),e),this._resetSearchWidth(),n=s.length?s:null):e.which==h.KEY.ENTER&&(n=null),this._selectChoice(n),e.preventDefault(),void(n&&n.length||this.open(e))}if((e.which===h.KEY.BACKSPACE&&1==this.keydowns||e.which==h.KEY.LEFT)&&0==o.offset&&!o.length)return this._selectChoice(this.selection.find("."+this._classNm+"-selected-choice:not(."+this._classNm+"-locked)").last()),void e.preventDefault();if(this._selectChoice(null),this._opened()){switch(e.which){case h.KEY.UP:case h.KEY.DOWN:return this._moveHighlight(e.which===h.KEY.UP?-1:1),void e.preventDefault();case h.KEY.ENTER:return this._selectHighlighted(null,e),void e.preventDefault();case h.KEY.TAB:return void this.close(e);case h.KEY.ESC:return this._cancel(e),void e.preventDefault()}!1!==this._userTyping||h.KEY.isControl(e)||h.KEY.isFunctionKey(e)||(this._userTyping=!0,this.close())}if(!(e.which===h.KEY.TAB||h.KEY.isControl(e)||h.KEY.isFunctionKey(e)||e.which===h.KEY.ESC||e.which===h.KEY.ENTER&&this.search.val()&&"ojcombobox"===this._elemNm)){switch(e.which){case h.KEY.UP:case h.KEY.DOWN:return this.open(e),void e.preventDefault();case h.KEY.PAGE_UP:case h.KEY.PAGE_DOWN:case h.KEY.ENTER:return void e.preventDefault()}this._userTyping=!0}}},_enableInterface:function(){f.superclass._enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this._isInterfaceEnabled())},_initSelection:function(e){if(null!==this.getVal()&&0!==this.getVal().length||"oj-select"!==this._classNm&&""!==this.opts.element.text().trim()||(this._updateSelection(e||[]),this.close(),this._clearSearch()),this.datalist||null!==this.getVal()&&this.getVal().length){var t,i=this;t=this.datalist?this.datalist:this.opts.element,h.applyValueOptions(this,this.opts)||this.opts.initSelection.call(null,t,function(e){null!=e&&0!==e.length&&(i._updateSelection(e),i.close(),i._clearSearch())})}},close:function(e){this._opened()&&f.superclass.close.apply(this,arguments)},_focus:function(){this.close(),this.search.focus()},_updateSelection:function(e){var i=[],s=[],o=this;t(e).each(function(){i.indexOf(o.id(this))<0&&(i.push(o.id(this)),s.push(this))}),e=s,"init"==this.opts.fetchType&&e&&e.length>0&&("oj-combobox"==this._classNm||"oj-select"==this._classNm)&&this.setValOpts(e),this.selection.find("."+this._classNm+"-selected-choice").remove(),this.selection.find(".oj-select-default").remove(),t(e).each(function(){o._addSelectedChoice(this)}),this.currentItem=e,this.currentValue=i,o._postprocessResults()},_onSelect:function(e,i,s){if(this._triggerSelect(e)){var o;i&&i.trigger&&(o={optionMetadata:{trigger:i.trigger}});var n=this.id(e),a=this.getVal()?this.getVal().slice(0):[],l=this.getValOpts()?this.getValOpts().slice(0):[],r="oj-combobox"===this._classNm||"oj-select"===this._classNm;this.ojContext.isValid()||(a=this.currentValue);var c=this;t(e).each(function(t){a.indexOf(n)<0&&""!==n&&(a.push(n),r&&(Array.isArray(e)?l.push(h.findOptionFromResult(c,n,e[t])):l.push(h.findOptionFromResult(c,n,e))))}),r&&(this._skipSetValueOptions=!0,this.setValOpts(l)),this.setVal(a,s,o),this._skipSetValueOptions=!1,!this.select&&this.opts.closeOnSelect||this._postprocessResults(e,!1,!0===this.opts.closeOnSelect),this.opts.closeOnSelect&&(this.close(s),this._resetSearchWidth()),i&&i.noFocus||"ojcombobox"!==this._elemNm||this._focusSearch()}},_cancel:function(e){this.close(e),"ojcombobox"===this._elemNm&&this._focusSearch()},_addSelectedChoice:function(e){var i,s=!e.locked,o=t("
        • "),n=t("
        • "),a=s?o:n;this.id(e);void 0!==(i=this.opts.formatSelection(e))&&(a.find("div").addClass(this._classNm+"-selected-choice-label").text(i),a.find("."+this._classNm+"-clear-entry").attr("aria-label",i+" remove"),a.attr("valueText",i)),s&&a.find("."+this._classNm+"-clear-entry").on("mousedown",h.killEvent).on("click dblclick",this._bind(function(e){this._isInterfaceEnabled()&&(t(e.target).closest("."+this._classNm+"-selected-choice").fadeOut("fast",this._bind(function(){this._unselect(t(e.target),e),this.selection.find("."+this._classNm+"-selected-choice.oj-focus").removeClass("oj-focus"),this.close(e),"ojcombobox"===this._elemNm&&this._focusSearch()})).dequeue(),h.killEvent(e))})),a.data(this._elemNm,e),"ojcombobox"===this._elemNm?a.insertBefore(this.searchContainer):this.selection.append(a)},_syncValueOptions:function(t,i,s){var o=[];if(i&&s){for(var n=0;n=0;)o.splice(s,1),this._syncValueOptions(this.ojContext,o,this.getValOpts()),this._skipSetValueOptions=!0,this.setVal(o,t),this._skipSetValueOptions=!1,this.select&&this._postprocessResults();e.remove()}},_postprocessResults:function(e,t,i){if(this.ojContext.isValid()){var s=this.getVal(),o=this.results.find(".oj-listbox-result"),n=this.results.find(".oj-listbox-result-with-children"),a=this;h.each2(o,function(e,t){var i=a.id(t.data(a._elemNm));s&&s.indexOf(i)>=0&&(t.addClass("oj-selected"),t.find(".oj-listbox-result-selectable").addClass("oj-selected"))}),h.each2(n,function(e,t){t.is(".oj-listbox-result-selectable")||0!==t.find(".oj-listbox-result-selectable:not(.oj-selected)").length||t.addClass("oj-selected")}),!o.filter(".oj-listbox-result:not(.oj-selected)").length>0&&"oj-select"!==this._classNm&&this.close()}},_isDataSelected:function(e){var t=this.getVal();if(!t||0==t.length)return!1;for(var i=e.results,s=0;s","
        •  "," ","
        • ","
        ","
        ",""].join(""))},_opening:function(e,t){this._resizeSearch(),m.superclass._opening.apply(this,arguments),this._focusSearch(),t||this._updateResults(!0),this.search.focus()},_clearSearch:function(){var e=this._getPlaceholder(),t=this._getMaxSearchWidth();void 0===e||this.getVal()&&0!==this.getVal().length||this.getValOpts()&&this.getValOpts().length?(this.search.attr("placeholder",""),this.search.val("").width(10),this.searchContainer.width("auto")):(this.search.attr("placeholder",e),this.search.val("").width(t>0?t:this.container.css("width")),this.searchContainer.width("100%"))},_resetSearchWidth:function(){this.search.width(10)},_getMaxSearchWidth:function(){return this.selection.width()-h.getSideBorderPadding(this.search)},_textWidth:function(e){var i=document.createElement("span"),s=document.createTextNode(e);i.style.display="none",i.appendChild(s),t("body").append(i);var o=t("body").find("span:last").width();return t("body").find("span:last").remove(),o},_resizeSearch:function(){var e,t,i,s,o=h.getSideBorderPadding(this.search);e=this._textWidth(this.search.val())+10,t=this.search.offset().left,(s=(i=this.selection.width())-(t-this.selection.offset().left)-o)
      • ");i.addClass("oj-select-default"),i.text(e),this.selection.append(i)}}}),b=h.clazz(p,{_elemNm:"ojinputsearch",_classNm:"oj-inputsearch",_createContainer:function(){var e=t(document.createElement("div")).attr({class:"oj-inputsearch oj-component"}).html(["","","
        "].join("")),i=e.find(".oj-inputsearch-search-button");return this._attachSearchIconClickHandler(i),e},_attachSearchIconClickHandler:function(e){var t=this;e.on("click",function(e,i){if(t._isInterfaceEnabled()){if(t.opts.manageNewEntry){var s=t.search.val(),o=t.opts.manageNewEntry(s),n={trigger:h.ValueChangeTriggerTypes.SEARCH_ICON_CLICKED},a=t.selection.data(t._elemNm);!a&&""!==s||a&&a.label!==s||!t.ojContext.isValid()&&s!==t._previousDisplayValue?(t._onSelect(o,n,e),t._triggerUpdateEvent(o,n,e)):(a&&a.label===s&&(o=a),t._triggerUpdateEvent(o,n,e))}return!1}}).on("mousedown",function(e){return e.stopPropagation(),!1})},_enable:function(e){b.superclass._enable.apply(this,arguments),this._enabled?this.container.find(".oj-inputsearch-search-button").removeClass("oj-disabled"):this.container.find(".oj-inputsearch-search-button").addClass("oj-disabled")},_triggerUpdateEvent:function(e,t,i){var s;t&&(s=t.trigger);var o={_context:{optionMetadata:{trigger:s}}},n=this.id(e);if(n&&0!==n.length||(n=e.label?e.label:[]),void 0!==this.ojContext._Validate(n,i,o)&&this.ojContext.isValid()){"string"==typeof n&&(n=[n]);var a={value:n,optionMetadata:{trigger:s}};this.ojContext._trigger("update",i,a)}},_prepareOpts:function(e){return(e=b.superclass._prepareOpts.apply(this,arguments)).highlightTermInOptions=function(e){return!0},e}});e.__registerWidget("oj.ojCombobox",t.oj.editableValue,{defaultElement:"",widgetEventPrefix:"oj",options:{asyncValidators:[],converter:null,filterOnOpen:"none",placeholder:null,options:null,optionsKeys:{label:null,value:null,children:null,childKeys:null},pickerAttributes:null,optionRenderer:null,minLength:0,rawValue:void 0,required:!1,validators:[],valueOption:null,valueOptions:null,valueUpdated:null},widget:function(){return this.combobox.container},_ComponentCreate:function(){this._super(),h.wrapDataProviderIfNeeded(this,null),this._setup()},_AfterCreate:function(){if(this._super(),this._IsCustomElement()){var t=this.OuterWrapper.id;t&&e.EditableValueUtils.setSubIdForCustomLabelFor(this._GetContentElement()[0],t)}},_InitOptions:function(t,i){if(this._super(t,i),e.EditableValueUtils.initializeOptionsFromDom([{attribute:"disabled",validateOption:!0},{attribute:"placeholder"},{attribute:"required",coerceDomValue:!0,validateOption:!0},{attribute:"title"}],i,this),this.multiple=this._IsCustomElement()?"OJ-COMBOBOX-MANY"===this.OuterWrapper.nodeName:this.options.multiple,void 0===this.options.value)this._IsCustomElement()||(this.options.value=void 0!==this.element.attr("value")?h.splitVal(this.element.val(),","):null);else{var s=this.options.value;Array.isArray(s)?this._IsCustomElement()||(s=s.slice(0)):"string"==typeof s&&(!0===this.multiple?s=h.splitVal(s,","):this._IsCustomElement()||(s=[s])),this.options.value=s}},_IsRequired:function(){return this.options.required},_AfterSetOptionRequired:e.EditableValueUtils._AfterSetOptionRequired,_AfterSetOptionValidators:e.EditableValueUtils._AfterSetOptionValidators,_AfterSetOptionAsyncValidators:e.EditableValueUtils._AfterSetOptionAsyncValidators,_AfterSetOptionConverter:e.EditableValueUtils._AfterSetOptionConverter,_ResetConverter:e.EditableValueUtils._ResetConverter,_GetConverter:e.EditableValueUtils._GetConverter,_GetNormalizedValidatorsFromOption:e.EditableValueUtils._GetNormalizedValidatorsFromOption,_GetNormalizedAsyncValidatorsFromOption:e.EditableValueUtils._GetNormalizedAsyncValidatorsFromOption,_setup:function(){var e={};e.element=this.element,e.ojContext=this,e=t.extend(this.options,e),this.combobox=this.multiple?new m:new p,this.combobox._init(e),this._refreshRequired(this.options.required),this._resolveValueOptionsLater=h.mergeValueAndValueOptions(this)},_refreshRequired:e.EditableValueUtils._refreshRequired,_AriaRequiredUnsupported:function(){return!1},_destroy:function(){this.combobox._destroy(),this._super()},refresh:function(){this._super(),this.combobox._destroy(),this._setup(),this._SetRootAttributes()},_setOption:function(e,t,i){var s=this.multiple;if("value"===e&&(Array.isArray(t)?this._IsCustomElement()||(t=t.slice(0)):"string"==typeof t&&(!0===s?t=h.splitVal(t,","):this._IsCustomElement()||(t=[t])),i&&i._context&&i._context.optionMetadata?this.combobox.valueChangeTrigger=i._context.optionMetadata.trigger:this.combobox.valueChangeTrigger=null,"string"==typeof this.options.placeholder&&(null==t||t&&0===t.length||this._IsCustomElement()&&h.isValueForPlaceholder(s,t))))return h.setValueOptions(this,h.getValueOptionsForPlaceholder(s)),void this._super(e,t,i);"options"===e?(h.removeDataProviderEventListeners(this),h.clearDataProviderWrapper(this)):("valueOption"===e&&!0!==s||"valueOptions"===e&&!0===s)&&this.combobox.setValOpts(null),this._super(e,t,i),"valueOption"===e&&!0!==s?(this.combobox&&(this.combobox.opts.valueOption=t),h.syncValueWithValueOption(this,t,this.options.value)):"valueOptions"===e&&!0===s?(this.combobox&&(this.combobox.opts.valueOptions=t),h.syncValueWithValueOptions(this,t,this.options.value)):"value"===e?h.updateValueOptions(this.combobox):"options"===e?(h.isDataProvider(t)&&(h.wrapDataProviderIfNeeded(this,this.combobox?this.combobox.opts:null),h.addDataProviderEventListeners(this)),this.combobox.opts.options=t,this.combobox.opts=this.combobox._prepareOpts(this.combobox.opts)):"disabled"===e&&(t?this.combobox._disable():this.combobox._enable())},_AfterSetOption:function(e,t,i){switch(this._superApply(arguments),e){case"required":this._AfterSetOptionRequired(e);break;case"validators":this._AfterSetOptionValidators(e);break;case"converter":this._AfterSetOptionConverter(e);break;case"asyncValidators":this._AfterSetOptionAsyncValidators(e)}},_NotifyDetached:function(){this._superApply(arguments),this.combobox.close()},_NotifyHidden:function(){this._superApply(arguments),this.combobox.close()},_VerifyConnectedForSetup:function(){return!0},_SetDisplayValue:function(e){h.applyValueOptions(this.combobox,this.options)?this.multiple&&this.combobox._clearSearch():this.combobox._initSelection(),this._resolveValueOptionsLater=!1},_SetPlaceholder:function(e){this.combobox&&(this.combobox.opts.placeholder=e,this.combobox._setPlaceholder&&this.combobox._setPlaceholder())},validate:e.EditableValueUtils.validate,_parseValue:function(e){var t;if("string"==typeof e&&(!0===this.multiple?e=h.splitVal(e,","):this._IsCustomElement()||(e=[e])),Array.isArray(e)){t=[];for(var i=0;i",widgetEventPrefix:"oj",options:{placeholder:void 0,required:!1,list:void 0,options:null,optionsKeys:null,pickerAttributes:null,optionRenderer:null,minLength:0,beforeExpand:null,rawValue:void 0,optionChange:null,update:null,validators:void 0},widget:function(){return this.inputSearch.container},_ComponentCreate:function(){this._super(),this._setup()},_InitOptions:function(t,i){if(this._super(t,i),e.EditableValueUtils.initializeOptionsFromDom([{attribute:"disabled",validateOption:!0},{attribute:"placeholder"},{attribute:"required",coerceDomValue:!0,validateOption:!0},{attribute:"title"}],i,this),void 0===this.options.value)this.options.value=void 0!==this.element.attr("value")?h.splitVal(this.element.val(),","):null;else{var s=this.options.value;Array.isArray(s)?s=s.slice(0):"string"==typeof s&&(s=[s]),this.options.value=s}},_AfterSetOption:function(e,t,i){switch(this._superApply(arguments),e){case"required":this._AfterSetOptionRequired(e);break;case"validators":this._AfterSetOptionValidators(e)}},_IsRequired:function(){return this.options.required},_AfterSetOptionRequired:e.EditableValueUtils._AfterSetOptionRequired,_AfterSetOptionValidators:e.EditableValueUtils._AfterSetOptionValidators,_refreshRequired:e.EditableValueUtils._refreshRequired,_GetNormalizedValidatorsFromOption:e.EditableValueUtils._GetNormalizedValidatorsFromOption,_AriaRequiredUnsupported:function(){return!1},_setup:function(){var e={};e.element=this.element,e.ojContext=this,e.inputSearch=!0,e=t.extend(this.options,e),this.inputSearch=new b,this.inputSearch._init(e),this._refreshRequired(this.options.required)},_destroy:function(){this.inputSearch._destroy(),this._super()},refresh:function(){this._super(),this.inputSearch._destroy(),this._setup(),this._SetRootAttributes()},_setOption:function(t,i,s){"value"===t&&(null!=i&&(Array.isArray(i)?i=i.slice(0):"string"==typeof i?i=[i]:e.Logger.error("ojInputSearch value has to be an array of string or a string.")),s&&s._context&&s._context.optionMetadata?this.inputSearch.valueChangeTrigger=s._context.optionMetadata.trigger:this.inputSearch.valueChangeTrigger=null),this._super(t,i,s),"options"===t&&(this.inputSearch.opts.options=i,this.inputSearch.opts=this.inputSearch._prepareOpts(this.inputSearch.opts)),"disabled"===t&&(i?this.inputSearch._disable():this.inputSearch._enable())},_NotifyDetached:function(){this._superApply(arguments),this.inputSearch.close()},_NotifyHidden:function(){this._superApply(arguments),this.inputSearch.close()},_SetDisplayValue:function(e){this.inputSearch._initSelection()},_SetPlaceholder:function(e){this.inputSearch&&(this.inputSearch.opts.placeholder=e,this.inputSearch._setPlaceholder&&this.inputSearch._setPlaceholder())},validate:function(){var e=this.inputSearch.search.val(),t=null,i=[];return this.isValid()&&(i=this.inputSearch.getVal()),t=null==e||""===e?i:[e],this._SetValueReturnBoolean(t,null,this._VALIDATE_METHOD_OPTIONS)},_parseValue:function(t){var i=[];if(null==t)return i;if(Array.isArray(t))for(var s=0;s",widgetEventPrefix:"oj",options:{minimumResultsForSearch:15,placeholder:null,optionRenderer:null,options:null,optionsKeys:{label:null,value:null,children:null,childKeys:null},pickerAttributes:null,required:!1,renderMode:"jet",valueOption:null,valueOptions:null},widget:function(){return this.select?this.select.container:this.element.parent()},_ComponentCreate:function(){this._super(),h.wrapDataProviderIfNeeded(this,null),this._setup()},_AfterCreate:function(){if(this._super(),this._IsCustomElement()){var i=this.uuid+"_Label",s=e.EditableValueUtils.getOjLabelId(t(this.OuterWrapper),i);s&&this._GetContentElement().attr("aria-labelledby",s)}},_AfterSetOption:function(e,t,i){switch(this._superApply(arguments),e){case"required":this._AfterSetOptionRequired(e)}},_IsRequired:function(){return this.options.required},_AfterSetOptionRequired:e.EditableValueUtils._AfterSetOptionRequired,_nativeSetDisabled:function(e){e?(this.element.attr("disabled",""),this.element.parent().addClass("oj-disabled").removeClass("oj-enabled")):(this.element.removeAttr("disabled"),this.element.parent().removeClass("oj-disabled").addClass("oj-enabled"))},_nativeChangeHandler:function(e){var i=[],s=[],o=!this._IsRequired()&&this._HasPlaceholderSet();t(e.target).find("option").each(function(){this.selected&&(this.value||o&&""===this.value)&&(i.push(this.value),s.push({value:this.value,label:this.text}))}),this._IsCustomElement()&&!0!==this.multiple?(this._SetValueReturnBoolean(i[0],e,{doValueChangeCheck:!1,_context:{internalSet:!0}}),h.setValueOptions(this,s[0])):(this._SetValueReturnBoolean(i,e,{doValueChangeCheck:!1,_context:{internalSet:!0}}),h.setValueOptions(this,s))},_nativeQueryCallback:function(e){if(e){var t=this.element;h.arrayPopulateResults(t,e,this._formatValue.bind(this),h.isDataProvider(this.options.options)?null:this.options.optionsKeys),t.addClass(h.GENERATED_OPTIONS_SELECTOR)}},_nativeSetSelected:function(e){var t=null;e?t=e:(this._HasPlaceholderSet()&&(this.options.required&&(t=this._nativeFindFirstEnabledOptionValue()),this._SetPlaceholder(this.options.placeholder)),null===t&&(t=this._nativeFindFirstEnabledOptionValue())),this._setInitialSelectedValue(t)},_nativeFetchFromDataProvider:function(){var e=this;h.fetchFirstBlockFromDataProvider(this.element,e.options).then(function(t){if(e._nativeQueryCallback(t),t.length){var i=e.options.value;i?h.validateFromDataProvider(e.element,e.options,i).then(function(t){if(t){var i=t.valueOptions;Array.isArray(i)&&i.length&&h.setValueOptions(e,i);var s=t.value;Array.isArray(s)&&s.length&&e._nativeSetSelected(e.multiple?s:s[0])}}):e._nativeSetSelected()}})},_nativeSetup:function(){var e=this.element;if(e.wrap("
        ").parent().addClass("oj-select-native oj-component oj-select oj-form-control"),e.addClass("oj-select-select oj-component-initnode"),this.multiple?(e[0].multiple||(e[0].multiple=!0),e.parent().prepend("")):e.parent().prepend(""),this._nativeSetDisabled(this.options.disabled),this.options.list)h.listPopulateResults(e,t("#"+this.options.list).children(),this._formatValue.bind(this)),e.addClass(h.GENERATED_OPTIONS_SELECTOR);else if(this.options.options)h.getDataProvider(this.options)?this._nativeFetchFromDataProvider():this._nativeQueryCallback(this.options.options);else if(this._IsCustomElement()){var i=e.children();1===i.length&&i.hasClass("oj-listbox-placeholder")||(h.ojOptionPopulateResults(e,i,this._formatValue.bind(this)),e.addClass(h.GENERATED_OPTIONS_SELECTOR))}this._focusable({element:e,applyHighlight:!0}),this.options.value||this._HasPlaceholderSet()||h.getDataProvider(this.options)||this._setInitialSelectedValue(this._nativeFindFirstEnabledOptionValue()),e.change(this._nativeChangeHandler.bind(this)),h.addDataProviderEventListeners(this)},_jetSetup:function(){var e={};e.element=this.element,e.ojContext=this,e=t.extend(this.options,e),this.select=this.multiple?new _:new v,this.select._init(e),this.select.container.addClass("oj-select-jet oj-form-control"),this._focusable({element:this.select.selection,applyHighlight:!0})},_setInitialSelectedValue:function(e){var t;t=this._IsCustomElement()?e:Array.isArray(e)?e:[e],this._SetValueReturnBoolean(t,null,{doValueChangeCheck:!1,_context:{internalSet:!0,writeback:!0},changed:!0})},_setup:function(){this._resolveValueOptionsLater=h.mergeValueAndValueOptions(this),this._isNative()?this._nativeSetup():this._jetSetup(),this._refreshRequired(this.options.required)},refresh:function(){this._super(),this._cleanup(),this._setup(),this._isNative()&&this.options.value&&this.element.val(this.options.value),this._SetRootAttributes()},_refreshRequired:e.EditableValueUtils._refreshRequired,_AriaRequiredUnsupported:function(){return!1},_destroy:function(){this._cleanup(),this._super()},_NotifyDetached:function(){this._superApply(arguments),this.select&&this.select.close()},_NotifyHidden:function(){this._superApply(arguments),this.select&&this.select.close()},_VerifyConnectedForSetup:function(){return!0},_SetPlaceholder:function(e){if(this._isNative()&&null!=e){var i=t(this.element.children("option:first-child"));i&&""===i.attr("value")?(i.text(this.options.placeholder),i.attr("value","")):((i=h.createOptionTag(0,"",e,this._formatValue.bind(this))).addClass("oj-listbox-placeholder"),this._hidePlaceholder(i,this._IsRequired()),i.prependTo(this.element))}},_HasPlaceholderSet:function(){return"string"==typeof this.options.placeholder},_ClearPlaceholder:function(){this._SetPlaceholderOption(null),this._SetPlaceholder(null)},_InitOptions:function(t,i){if(this._super(t,i),e.EditableValueUtils.initializeOptionsFromDom([{attribute:"disabled",validateOption:!0},{attribute:"placeholder"},{attribute:"required",coerceDomValue:!0,validateOption:!0},{attribute:"title"}],i,this),this.multiple=this._IsCustomElement()?"OJ-SELECT-MANY"===this.OuterWrapper.nodeName:this.options.multiple,void 0===this.options.value)this._IsCustomElement()||(this.options.value=void 0!==this.element.attr("value")?h.splitVal(this.element.val(),","):null);else{var s=this.options.value;Array.isArray(s)&&(this._IsCustomElement()||(s=s.slice(0))),this.options.value=s}},validate:e.EditableValueUtils.validate,_SetDisplayValue:function(t){if(this.select)h.applyValueOptions(this.select,this.options)||this.select._initSelection(),this._resolveValueOptionsLater=!1;else{var i;if(null==t)this._HasPlaceholderSet()&&(this.element[0].selectedIndex=0,this.element.addClass("oj-select-default")),this._resolveValueOptionsLater&&h.setValueOptions(this,h.getValueOptionsForPlaceholder(this.multiple));else{var s=this._nativeFindLabel(t);if(null!==s||this.multiple?this.element.val(t):(e.Logger.warn("JET select: selected value not found"),this.element[0].options&&this.element[0].options.length>0?(this.element[0].selectedIndex=0,t=this.element[0].value,s=this.element[0].text):(s=String(t),this.element.val(t))),this._resolveValueOptionsLater){if(this.multiple){var o=this.element[0].selectedOptions;i=[];for(var n=0;n0?[t(e[0]).attr("value")]:null},_nativeSetOptions:function(e){var t=this.options.value,i=this.element;if(i.hasClass(h.GENERATED_OPTIONS_SELECTOR))h.cleanupResults(i);else{var s=i.children();s.length>0&&s.remove()}if(h.isDataProvider(e))this._nativeFetchFromDataProvider();else{h.arrayPopulateResults(i,e,this._formatValue.bind(this),this.options.optionsKeys);var o=null;this._HasPlaceholderSet()&&(this.options.required&&(o=this._nativeFindFirstEnabledOptionValue()),this._SetPlaceholder()),null===o&&(o=this._nativeFindFirstEnabledOptionValue()),this.options.value=o,this.option("value",t)}i.addClass(h.GENERATED_OPTIONS_SELECTOR)},_removePlaceholderInMultiValues:function(e){for(var t,i=[],s=0;s0?(1==i.length&&""===i[0]&&i.pop(),i.push(t)):0==i.length&&i.push(t));return i},_nativeFindLabel:function(e){var i=this.element[0].options;if(i&&i.length>0)for(var s=0;s0&&o===a.select.getVal()?a.select._updateSelectedOption(e[0]):(l.call(a,"value",null),r||a.select.text.text(""))});a.select.opts.options=n,a.select.opts=a.select._prepareOpts(a.select.opts)}):(this.select.opts.options=n,this.select.opts=this.select._prepareOpts(this.select.opts),this.select.setValOpts(null),this._super("value",o))):this._nativeSetOptions(n);else if("required"===e&&this._isNative()){var c=t(this.element.find(".oj-listbox-placeholder"));c&&""===c.attr("value")&&this._hidePlaceholder(c,n)}}else{if(this._HasPlaceholderSet()&&(n&&0===n.length||this._IsCustomElement()&&h.isValueForPlaceholder(r,n)))return h.setValueOptions(this,h.getValueOptionsForPlaceholder(r)),void this._super(e,n,s);var u;this.select&&((u=this.select.datalist)||(u=this.select.opts.element));var d=this._IsCustomElement()&&!r;if(Array.isArray(n)||d||(n=[n]),this._isNative()&&(d||(n=this._removePlaceholderInMultiValues(n)),1===n.length&&""===n[0]?this.element.addClass("oj-select-default"):this.element.removeClass("oj-select-default")),h.getDataProvider(this.options)&&n)return this.select&&(this.select.opts.options=this.options.options),void h.validateFromDataProvider(this._isNative()?this.element:this.select.container,this.options,n).then(function(t){if(t){var i=t.valueOptions;Array.isArray(i)&&i.length&&h.setValueOptions(a,i);var s=t.value;Array.isArray(s)&&s.length&&l.call(a,e,r?s:s[0])}});if(!d){for(var p=[],v=0;v0&&p.push(n[v]);return void((p.length>0||r)&&(this._super(e,p,s),h.updateValueOptions(this.select)))}this.select&&this.select.opts.validate&&!this.select.opts.validate(u,n)&&!this._isOptionDataPending()||(this._super(e,n,s),h.updateValueOptions(this.select))}},_isOptionDataPending:function(){var e=this.options.options,t=this.select.datalist;if(t){if(0===t.children().length)return!0}else{if(h.isDataProvider(e))return!0;if(!e||0===e.length)return!0}return!1},_getDropdown:function(){if(this.select&&this.select._opened()){var e=this.select.dropdown;if(e&&e.attr("data-oj-containerid")===this.select.containerId)return e}return null},_hidePlaceholder:function(e,t){t?(e.attr("disabled",""),e.attr("hidden","")):(e.removeAttr("disabled"),e.removeAttr("hidden"))},_isNative:function(){return"native"===this.options.renderMode},_cleanup:function(){var e=this._isNative();e&&this.element.parent().hasClass("oj-select-native")?(this.element.off("change"),this.element.hasClass(h.GENERATED_OPTIONS_SELECTOR)&&h.cleanupResults(this.element),this.element.parent().hasClass("oj-select-native")&&(this.element.parent().children(".oj-select-arrow").remove(),this.element.unwrap()),this.element.removeClass("oj-select-select oj-component-initnode"),this.element.attr({"aria-labelledby":""})):!e&&this.select&&(this.select._destroy(),this.select=void 0)},getNodeBySubId:function(e){var i,s=null;if(null==e){var o=this.widget();return o?o[0]:null}if(this._isNative())return null;if(!(s=this._super(e))){var n=this._getDropdown();switch(i=e.subId){case"oj-select-drop":n&&(s=n[0]);break;case"oj-select-results":n&&(s=n.find(".oj-listbox-results")[0]);break;case"oj-select-search":n&&(s=n.find(".oj-listbox-search")[0]);break;case"oj-select-input":case"oj-listbox-input":n&&(s=n.find(".oj-listbox-input")[0]);break;case"oj-select-choice":case"oj-select-chosen":case"oj-select-arrow":s=this.widget().find("."+i)[0];break;case"oj-listitem":if(n){var a=n.find(".oj-listbox-result");s=this.select._findItem(a,e.value)}break;case"oj-select-remove":var l=this.widget().find(".oj-select-selected-choice"),r=this.select._findItem(l,e.value);s=r?t(r).find(".oj-select-clear-entry-icon")[0]:null;break;case"oj-listbox-result-label":if(n){var h=t("#"+this.select.results.attr("id")).children(),c=e.index;h.length&&c