UNPKG

bootstrap-select-dropdown

Version:

A jQuery plugin for Bootstrap 4 that converts <select> and <select multiselect> elements to dropdowns. Uses fuse.js for fuzzy search and Bootstrap's dropdown plugin.

1 lines 23.1 kB
!function(e){var t={};function n(s){if(t[s])return t[s].exports;var i=t[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(s,i,function(t){return e[t]}.bind(null,i));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t){e.exports=$},function(e,t){e.exports=Fuse},function(e,t,n){n(3)},function(e,t,n){"use strict";n.r(t);var s=n(0),i=n.n(s);function o(e){let t=!1;return i()(this).one(l.TRANSITION_END,()=>{t=!0}),setTimeout(()=>{t||l.triggerTransitionEnd(this)},e),this}const l={TRANSITION_END:"bsTransitionEnd",getUID(e){do{e+=~~(1e6*Math.random())}while(document.getElementById(e));return e},getSelectorFromElement(e){let t=e.getAttribute("data-target");if(!t||"#"===t){const n=e.getAttribute("href");t=n&&"#"!==n?n.trim():""}try{return document.querySelector(t)?t:null}catch(e){return null}},getTransitionDurationFromElement(e){if(!e)return 0;let t=i()(e).css("transition-duration"),n=i()(e).css("transition-delay");const s=parseFloat(t),o=parseFloat(n);return s||o?(t=t.split(",")[0],n=n.split(",")[0],1e3*(parseFloat(t)+parseFloat(n))):0},reflow:e=>e.offsetHeight,triggerTransitionEnd(e){i()(e).trigger("transitionend")},supportsTransitionEnd:()=>Boolean("transitionend"),isElement:e=>(e[0]||e).nodeType,typeCheckConfig(e,t,n){for(const i in n)if(Object.prototype.hasOwnProperty.call(n,i)){const o=n[i],r=t[i],a=r&&l.isElement(r)?"element":(s=r,{}.toString.call(s).match(/\s([a-z]+)/i)[1].toLowerCase());if(!new RegExp(o).test(a))throw new Error(`${e.toUpperCase()}: `+`Option "${i}" provided type "${a}" `+`but expected type "${o}".`)}var s},findShadowRoot(e){if(!document.documentElement.attachShadow)return null;if("function"==typeof e.getRootNode){const t=e.getRootNode();return t instanceof ShadowRoot?t:null}return e instanceof ShadowRoot?e:e.parentNode?l.findShadowRoot(e.parentNode):null},jQueryDetection(){if(void 0===i.a)throw new TypeError("Bootstrap's JavaScript requires jQuery. jQuery must be included before Bootstrap's JavaScript.");const e=i.a.fn.jquery.split(" ")[0].split(".");if(e[0]<2&&e[1]<9||1===e[0]&&9===e[1]&&e[2]<1||e[0]>=4)throw new Error("Bootstrap's JavaScript requires at least jQuery v1.9.1 but less than v4.0.0")}};l.jQueryDetection(),i.a.fn.emulateTransitionEnd=o,i.a.event.special[l.TRANSITION_END]={bindType:"transitionend",delegateType:"transitionend",handle(e){if(i()(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}};var r=l,a=n(1),d=n.n(a);function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}var _=1,g=function(e){var t="selectDropdown",n="bs.selectDropdown",s=".".concat(n),i=e.fn[t],o={profile:"default",hideSelect:!0,search:!0,maxHeight:"300px",keyboard:!0,badges:!0,badgesDismissable:!0,maxListLength:0,textNoneSelected:"Select",textMultipleSelected:"%count_selected% selected",textNoResults:"No results",deselectAll:!0,selectAll:!0,showSelected:!0,selectButtons:!1,classBtnDeselectAll:"btn btn-outline-secondary",classBtnSelectAll:"btn btn-outline-secondary",htmlClear:"Clear search",htmlDeselectAll:"Deselect all",htmlSelectAll:"Select all",htmlBadgeRemove:"[X]",classBtnSelect:"btn btn-primary",classBadge:"badge badge-dark mr-1 mb-1",classBadgeLink:"text-white",classBadgeContainer:"mt-2 mb-3",loaded:function(){}},l={maxListLength:"number",hideSelect:"boolean",search:"boolean",maxHeight:"string",keyboard:"boolean",badges:"boolean",badgesDismissable:"boolean",textNoneSelected:"string",textMultipleSelected:"string",textNoResults:"string",deselectAll:"boolean",selectAll:"boolean",selectButtons:"boolean",classBtnDeselectAll:"string",classBtnSelectAll:"string",htmlClear:"string",htmlDeselectAll:"string",htmlSelectAll:"string",htmlBadgeRemove:"string",classBtnSelect:"string",classBadge:"string",classBadgeLink:"string",classBadgeContainer:"string",loaded:"function"},a={CLICK:"click".concat(s),KEYUP:"keyup".concat(s),KEYDOWN:"keydown".concat(s),FOCUS:"focus".concat(s),BLUR:"blur".concat(s),FOCUSIN:"focusin".concat(s),LOAD_DATA_API:"load".concat(s).concat(".data-api")},c="active",u="bg-transparent",g="disabled",v="dropdown",b="dropdown-menu",w="dropdown-item",m="btn-group",y="input-group",S="input-group-append",C="hover",k="bg-light",I="text-muted",A="dropdown-menu-right",x='[data-role="select-dropdown"]',D="%count_selected%",B=function(){function s(t,n){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),this._multiselect=this._isMultiselect(t),this._config=this._getConfig(n),this._element=t,this._prefix="bsd"+this._config.SelectDropdownIndex+"-"+Math.random().toString(36).substring(7)+"-",this._indexes=[],this._lastSearch=null,this._resultsChanged=!1,this._hoverItem=e(),this._keyupTimeout=null,this.ids={},this.ids.dropdownContainerId=this._prefix+"container",this.ids.dropdownButtonId=this._prefix+"button",this.ids.controlSearchId=this._prefix+"search",this.ids.dropdownItemDeselect=this._prefix+"deselect",this.ids.dropdownItemShowSelected=this._prefix+"selected",this.selectors={},this._config.badges&&(this.selectors.badge=this._classListToSelector(this._config.classBadge)),this.els={},this.els.btnSelect=this._buildBtnSelect(),this._config.search&&(this.els.controlSearch=this._buildControlSearch(),this.els.clear=this._buildControlClear()),this._config.deselectAll&&(this.els.deselectAll=this._buildDeselectAll()),this._config.selectAll&&(this.els.selectAll=this._buildSelectAll()),this.els.showSelected=this._buildShowSelected(),this.els.dropdown=this._buildDropdown(),this.els.dropdownMenu=this._buildDropdownMenu(),this.els.dropdownItemsContainer=this._buildDropdownItemsContainer(),this.els.dropdownItemNoResults=this._buildDropdownItemNoResults(),this.els.dropdownItems=this._buildDropdownItems(),this.els.dropdownOptions=this.els.dropdownItems.filter((function(t,n){return i._isOption(e(n))})),this._config.badges&&(this.els.badgeContainer=this._buildBadgeContainer()),this._config.search&&(this._hideClear(),this._haystack=[],this._fuseOptions={keys:["text"],id:"index"},this.els.dropdownOptions.each((function(t,n){i._haystack[t]={index:e(n).data("index"),text:e(n).text()}}))),this._addEventListeners(),this.init()}var i,x,B;return i=s,B=[{key:"_jQueryInterface",value:function(t,i){return this.each((function(){var o=e(this).data(n),l=h({},s.Default,{},e(this).data(),{},"object"===p(t)&&t,{SelectDropdownIndex:_});if(_++,o||(o=new s(this,l),e(this).data(n,o)),"string"==typeof t){if(void 0===o[t])throw new TypeError('No method named "'.concat(t,'"'));o[t](i)}else l.show&&o.show(i)}))}},{key:"VERSION",get:function(){return"0.14.6"}},{key:"Default",get:function(){return o}}],(x=[{key:"toggle",value:function(t){var n=e(this._element),s=t.data("option"),i=n.find("option").eq(s);i.is(":selected")?(i.prop("selected",!1),t.removeClass(c)):(this._multiselect||this.els.dropdownOptions.removeClass(c),i.prop("selected",!0),t.removeClass(k).addClass(c)),this._externalFeedback()}},{key:"deselect",value:function(t){var n=e(this._element),s=t.data("option");n.find("option").eq(s).is(":selected")&&this.toggle(t)}},{key:"select",value:function(t){var n=e(this._element),s=t.data("option");n.find("option").eq(s).is(":selected")||this.toggle(t)}},{key:"deselectAll",value:function(){e(this._element).find("option").prop("selected",!1),this.els.dropdownOptions.removeClass(c),this._externalFeedback(),this._refresh()}},{key:"selectAll",value:function(){e(this._element).find("option").prop("selected",!0),this.els.dropdownOptions.removeClass(k).addClass(c),this._externalFeedback(),this._refresh()}},{key:"_getConfig",value:function(e){return"minimal"==e.profile&&("undefined"!==p(e.search)&&(e.search=!1),"undefined"!==p(e.badges)&&(e.badges=!1),"undefined"!==p(e.deselectAll)&&(e.deselectAll=!1),"undefined"!==p(e.selectAll)&&(e.selectAll=!1),"undefined"!==p(e.showSelected)&&(e.showSelected=!1)),e=h({},o,{},e),r.typeCheckConfig(t,e,l),this._multiselect||(e.deselectAll=!1,e.selectAll=!1,e.showSelected=!1,e.badges=!1),e}},{key:"_addEventListeners",value:function(){var t=this;this._config.search&&(this.els.controlSearch.on(a.KEYUP,(function(n){t._config.keyboard&&t._keyupNav(n),clearTimeout(t._keyupTimeout),t._keyupTimeout=setTimeout((function(){var n=e(t.els.controlSearch).val();t._search(n)}),300)})),this.els.controlSearch.on(a.FOCUS,(function(e){t._hoverSet(),"false"==t.els.btnSelect.attr("aria-expanded")&&(t.els.btnSelect.dropdown("toggle"),setTimeout((function(){t._searchControlFocus()}),1))})),this.els.controlSearch.on(a.BLUR,(function(e){t._hoverRemoveAll()})),this.els.controlSearch.bind({paste:function(){e(this).trigger(a.KEYDOWN)},cut:function(){e(this).trigger(a.KEYDOWN)}})),this._assignClickHandlers()}},{key:"_keyupNav",value:function(e){if(13==e.which)return this.toggle(this.els.dropdown.find(".hover").first()),void(this._multiselect||this.els.btnSelect.dropdown("toggle"));38==e.which?this._hoverUp():40==e.which&&this._hoverDown(),this._dropdownActive()||(this.els.btnSelect.dropdown("toggle"),this._searchControlFocus())}},{key:"_assignClickHandlers",value:function(){var t=this;this.els.dropdownOptions.on(a.CLICK,(function(n){n.preventDefault(),t._multiselect&&t._preventDropdownHide(),t.toggle(e(n.currentTarget))})),this._config.deselectAll&&this.els.deselectAll.on(a.CLICK,(function(n){n.preventDefault(),t._preventDropdownHide(),e(n.currentTarget).hasClass("disabled")||t.deselectAll()})),this._config.selectAll&&this.els.selectAll.on(a.CLICK,(function(n){n.preventDefault(),t._preventDropdownHide(),e(n.currentTarget).hasClass("disabled")||t.selectAll()})),this._config.search&&this.els.clear.on(a.CLICK,(function(e){e.preventDefault(),t.els.controlSearch.val(""),t._preventDropdownHide(),t._refresh(),t._searchControlFocus()})),this.els.showSelected.on(a.CLICK,(function(n){n.preventDefault(),t._preventDropdownHide(),e(n.currentTarget).hasClass("disabled")||t._toggleShowSelected()})),this.els.dropdownItemNoResults.on(a.CLICK,(function(e){e.preventDefault(),t._preventDropdownHide()})),this._config.badges&&this.els.badgeContainer.on(a.CLICK,"a",(function(n){n.preventDefault();var s=e(n.currentTarget);t.deselect(t._dropdownItemByOption(s.data("option"))),s.parent(t.selectors.badge).remove()}))}},{key:"init",value:function(){this._externalFeedback(),this._config.search&&this.els.dropdownMenu.append(this.els.clear),this._config.selectAll&&!this._config.selectButtons&&this.els.dropdownMenu.append(this.els.selectAll),this._config.deselectAll&&!this._config.selectButtons&&this.els.dropdownMenu.append(this.els.deselectAll),this._config.showSelected&&this.els.dropdownMenu.append(this.els.showSelected),this.els.dropdownItemsContainer.append(this.els.dropdownItems),this.els.dropdownMenu.append(this.els.dropdownItemsContainer),this.els.dropdown.append(this.els.dropdownMenu);var t=e(this._element);t.after(this.els.dropdown),this._config.hideSelect&&t.hide(),this._config.badges&&this.els.dropdown.after(this.els.badgeContainer)}},{key:"_isMultiselect",value:function(t){var n=e(t).attr("multiple");return"undefined"!==p(n)&&!1!==n}},{key:"_search",value:function(t){var n=null;if(""==e.trim(t))return this._refresh(),void(null!==this._lastSearch&&(this._resultsChanged=!0,this._lastSearch=null,this._hoverSet()));n=new d.a(this._haystack,this._fuseOptions).search(t),this._resultsChanged=!0,n?(null!==typeof this._lastSearch&&this._arraysEqual(n,this._lastSearch)&&(this._resultsChanged=!1),this._resultsChanged&&this._applySearch(n),this._lastSearch=n):this._refresh()}},{key:"_applySearch",value:function(e){this._softDisableShowSelected(),this._showClear(),this._hoverSet(e[0]),this._hide(e),this._reorder(e),this._resetScroll()}},{key:"_buildBtnSelect",value:function(){return e("<button>",{class:this._config.classBtnSelect+" dropdown-toggle",type:"button",id:this.ids.dropdownButtonId,"data-toggle":"dropdown","data-target":"#"+this.ids.dropdownContainerId,"aria-haspopup":"true","aria-expanded":"false"}).text("Select")}},{key:"_buildControlClear",value:function(){return e("<a>",{href:"#",class:w}).html(this._config.htmlClear)}},{key:"_buildDeselectAll",value:function(){return(this._config.selectButtons?e("<button>",{type:"button",class:this._config.classBtnDeselectAll}):e("<a>",{href:"#",class:w})).html(this._config.htmlDeselectAll).attr("title","Deselect all")}},{key:"_buildSelectAll",value:function(){return(this._config.selectButtons?e("<button>",{type:"button",class:this._config.classBtnSelectAll}):e("<a>",{href:"#",class:w})).html(this._config.htmlSelectAll).attr("title","Select all")}},{key:"_buildShowSelected",value:function(){return e("<a>",{href:"#",class:w,text:"Show selected"})}},{key:"_buildControlSearch",value:function(){return e("<input>",{type:"text",class:"form-control",placeholder:"Search","aria-label":"Search","aria-describedby":this.ids.controlSearchId})}},{key:"_buildDropdown",value:function(){var t=e("<div>",{id:this.ids.dropdownContainerId,class:v});return this._config.search?t.append(this._buildDropdownInputGroup()):this._config.selectButtons?t.append(this._buildDropdownBtnGroup()):t.append(this.els.btnSelect),t}},{key:"_buildDropdownInputGroup",value:function(){var t=e("<div>",{class:y});return t.append(this.els.controlSearch),this._config.selectButtons&&(this._config.deselectAll&&t.append(e("<div>",{class:S}).append(this.els.deselectAll)),this._config.selectAll&&t.append(e("<div>",{class:S}).append(this.els.selectAll))),t.append(e("<div>",{class:S}).append(this.els.btnSelect)),t}},{key:"_buildDropdownBtnGroup",value:function(){var t=e("<div>",{class:m});return this._config.deselectAll&&t.append(this.els.deselectAll),this._config.selectAll&&t.append(this.els.selectAll),t.append(e("<div>",{class:m}).append(this.els.btnSelect)),t}},{key:"_buildDropdownMenu",value:function(){var t=e("<div>",{class:b,"aria-labelledby":this.ids.dropdownButtonId});return this._config.maxHeight&&t.css({height:"auto","max-height":this._config.maxHeight,"overflow-x":"hidden"}),this._config.search&&t.addClass(A),t}},{key:"_buildDropdownItemsContainer",value:function(){return e("<div>")}},{key:"_buildDropdownItemNoResults",value:function(){return e("<span>",{class:w+" "+I+" "+u,text:this._config.textNoResults}).hide()}},{key:"_buildDropdownItems",value:function(){var t=this,n=0,s=0,i=e(),o=e(this._element).find("optgroup");return o.length?o.each((function(o,l){i=i.add(t._buildDropdownHeader(e(l).attr("label")).data("index",n)),n=t._incrementIndex(n),e(l).find("option").each((function(o,l){e(l).data("option",s),i=i.add(t._buildDropdownItem(e(l)).data("index",n).data("option",s)),n=t._incrementIndex(n),s++}))})):e(this._element).find("option").each((function(o,l){e(l).data("option",s),i=i.add(t._buildDropdownItem(e(l)).data("index",n).data("option",s)),n=t._incrementIndex(n),s++})),this._config.search&&(i=i.add(this.els.dropdownItemNoResults)),i}},{key:"_incrementIndex",value:function(e){return this._indexes.push(e.toString()),++e}},{key:"_buildDropdownHeader",value:function(t){return e("<h6>",{class:"dropdown-header",text:t})}},{key:"_buildDropdownItem",value:function(t){var n=e("<a>",{href:"#",class:w,text:t.text()});return t.is(":selected")&&n.addClass("active"),n}},{key:"_buildBadgeContainer",value:function(){return e("<div>",{class:this._config.classBadgeContainer})}},{key:"_buildBadge",value:function(t,n){var s=e("<span>",{class:this._config.classBadge}).text(n);return this._config.badgesDismissable&&s.append(" ").append(e("<a>",{href:"#",class:this._config.classBadgeLink}).html(this._config.htmlBadgeRemove).data("option",t)),s}},{key:"_dropdownActive",value:function(){return!!this.els.dropdownMenu.hasClass("show")}},{key:"_isOption",value:function(e){var t=e.data("option");return"undefined"!==p(t)&&!1!==t}},{key:"_externalFeedback",value:function(){this._setButtonText(),this._config.badges&&this._setBadges()}},{key:"_setButtonText",value:function(){var t,n=e(this._element).val(),s=!1,i=!1;!this._multiselect&&n.length>0?t=e(this._element).find("option:selected").text():n.length<1?(t=this._config.textNoneSelected,s=!0):t=n.length<=this._config.maxListLength?this._getTextValues().join(", "):(t=this._config.textMultipleSelected).replace(D,n.length),n.length==this.els.dropdownOptions.length&&(i=!0),this._refreshInitialControls(i,s),this.els.btnSelect.text(t)}},{key:"_setBadges",value:function(t){var n=this,s=e();e(this._element).find("option:selected").each((function(t,i){s=s.add(n._buildBadge(e(i).data("option"),e(i).text()))})),this.els.badgeContainer.html("").append(s)}},{key:"_getText",value:function(t){return e(this._element).find("option[value='"+t+"']").first().text()}},{key:"_getTextValues",value:function(){return e(this._element).find("option:selected").map((function(t,n){return e(n).text()})).get()}},{key:"_refresh",value:function(){this._hideClear(),this.els.dropdownItemNoResults.hide(),this.els.dropdownOptions.show(),this._sortReset(),this._showInitialControls()}},{key:"_hide",value:function(t){var n=this,s=e(this._indexes).not(t).get();e.each(s,(function(e,t){n._dropdownItemByIndex(t).hide()})),e.each(t,(function(e,t){n._dropdownItemByIndex(t).show()})),this.els.btnSelect.dropdown("update")}},{key:"_dropdownItemByIndex",value:function(t){return this.els.dropdownItems.filter((function(n,s){return e(s).data("index")==t}))}},{key:"_dropdownItemByOption",value:function(t){return this.els.dropdownItems.filter((function(n,s){return e(s).data("option")==t}))}},{key:"_hideInitialControls",value:function(){this._config.selectAll&&!this._config.selectButtons&&this.els.selectAll.hide(),this._config.deselectAll&&!this._config.selectButtons&&this.els.deselectAll.hide(),this._config.showSelected&&this.els.showSelected.hide()}},{key:"_showInitialControls",value:function(){this._config.selectAll&&!this._config.selectButtons&&this.els.selectAll.show(),this._config.deselectAll&&!this._config.selectButtons&&this.els.deselectAll.show(),this._config.showSelected&&this.els.showSelected.show()}},{key:"_refreshInitialControls",value:function(e,t){this._config.selectAll&&this._disableEnable(this.els.selectAll,e),this._config.deselectAll&&this._disableEnable(this.els.deselectAll,t),this._config.showSelected&&this._disableEnable(this.els.showSelected,t||e)}},{key:"_showClear",value:function(){this._config.search&&this.els.clear.show()}},{key:"_hideClear",value:function(){this._config.search&&this.els.clear.hide()}},{key:"_disableEnable",value:function(e,t){t?this._disable(e):this._enable(e)}},{key:"_enable",value:function(e){e.is("button")&&e.prop("disabled",!1),e.removeClass(g),e.is("a")&&e.removeClass(I)}},{key:"_disable",value:function(e){e.is("button")&&e.prop("disabled",!0),e.addClass(g),e.is("a")&&e.addClass(I)}},{key:"_hoverSet",value:function(e){if(this._hoverRemoveAll(),"undefined"===p(e))var t=this.els.dropdownOptions.first();else t=this._dropdownItemByIndex(e);this._hoverItem=t,this._hoverAdd(t)}},{key:"_hoverUp",value:function(){var e=this._hoverItem;if("undefined"!==p(e)&&e.length)var t=e.prevAll("a:visible").first();"undefined"!==p(t)&&t.length&&(this._hoverRemove(e),this._hoverAdd(t),this._hoverItem=t)}},{key:"_hoverDown",value:function(){var e=this._hoverItem;if("undefined"!==p(e)&&e.length)var t=e.nextAll("a:visible").first();"undefined"!==p(t)&&t.length&&(this._hoverRemove(e),this._hoverAdd(t),this._hoverItem=t)}},{key:"_hoverAdd",value:function(e){var t=C;e.hasClass(c)||(t=t+" "+k),e.addClass(t)}},{key:"_hoverRemove",value:function(e){e.removeClass(C+" "+k)}},{key:"_hoverRemoveAll",value:function(){this.els.dropdownOptions.removeClass(C+" "+k)}},{key:"_sortReset",value:function(){var e;for(e=this.els.dropdownItems.length;e>=0;e--)this._dropdownItemByIndex(e).prependTo(this.els.dropdownItemsContainer)}},{key:"_reorder",value:function(t){if(this.els.dropdownItemNoResults.hide(),"undefined"!==p(t)&&0!=t.length){var n=t.slice(0);n=n.reverse(),e.each(n,(function(e,t){this._dropdownItemByIndex(t).prependTo(this.els.dropdownItemsContainer)})),this._hideInitialControls()}else this.els.dropdownItemNoResults.show()}},{key:"_toggleShowSelected",value:function(){this.els.showSelected.hasClass(c)?this.disableShowSelected():this._enableShowSelected()}},{key:"_enableShowSelected",value:function(){var t=this;this.els.showSelected.addClass(c),e(this.els.dropdownItemsContainer.find(".active").get().reverse()).each((function(n,s){e(s).prependTo(t.els.dropdownItemsContainer)})),this._resetScroll()}},{key:"_disableShowSelected",value:function(){this._softDisableShowSelected(),this._sortReset()}},{key:"_softDisableShowSelected",value:function(){this.els.showSelected.removeClass(c)}},{key:"_preventDropdownHide",value:function(){this._dropdownActive()&&this.els.dropdown.one("hide.bs.dropdown",(function(e){e.preventDefault()}))}},{key:"_searchControlFocus",value:function(){this.els.controlSearch.focus().val(this.els.controlSearch.val())}},{key:"_resetScroll",value:function(){this.els.dropdownMenu.scrollTop(0)}},{key:"_classListToSelector",value:function(e){var t=e;return e.length&&(t="."+e.split(/\s+/).join(".")),t}},{key:"_arraysEqual",value:function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!=t.length)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}}])&&f(i.prototype,x),B&&f(i,B),s}();return e(window).on(a.LOAD_DATA_API,(function(){e(x).each((function(){var t=e(this);B._jQueryInterface.call(t,t.data())}))})),e.fn[t]=B._jQueryInterface,e.fn[t].Constructor=B,e.fn[t].noConflict=function(){return e.fn[t]=i,B._jQueryInterface},B}(i.a,d.a);t.default=g}]);