dropdown.min.js 55 KB

1234567891011
  1. /*
  2. * # Fomantic UI - 2.8.4
  3. * https://github.com/fomantic/Fomantic-UI
  4. * http://fomantic-ui.com/
  5. *
  6. * Copyright 2014 Contributors
  7. * Released under the MIT license
  8. * http://opensource.org/licenses/MIT
  9. *
  10. */
  11. !function(_,ee,te,ne){"use strict";_.isFunction=_.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},ee=void 0!==ee&&ee.Math==Math?ee:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),_.fn.dropdown=function(j){var U,B=_(this),K=_(te),W=B.selector||"",Q="ontouchstart"in te.documentElement,Y=Q?"touchstart":"click",$=(new Date).getTime(),X=[],G=j,J="string"==typeof G,Z=[].slice.call(arguments,1);return B.each(function(n){var c,e,t,i,a,o,s,r,f=_.isPlainObject(j)?_.extend(!0,{},_.fn.dropdown.settings,j):_.extend({},_.fn.dropdown.settings),h=f.className,u=f.message,l=f.fields,g=f.keys,p=f.metadata,d=f.namespace,v=f.regExp,b=f.selector,m=f.error,w=f.templates,C="."+d,x="module-"+d,y=_(this),S=_(f.context),A=y.find(b.text),T=y.find(b.search),L=y.find(b.sizer),I=y.find(b.input),D=y.find(b.icon),k=y.find(b.clearIcon),q=0<y.prev().find(b.text).length?y.prev().find(b.text):y.prev(),R=y.children(b.menu),O=R.find(b.item),E=f.hideDividers?O.parent().children(b.divider):_(),V=!1,M=!1,z=!1,F=!1,P=this,N=y.data(x),H={initialize:function(){H.debug("Initializing dropdown",f),H.is.alreadySetup()?H.setup.reference():(f.ignoreDiacritics&&!String.prototype.normalize&&(f.ignoreDiacritics=!1,H.error(m.noNormalize,P)),H.setup.layout(),f.values&&H.change.values(f.values),H.refreshData(),H.save.defaults(),H.restore.selected(),H.create.id(),H.bind.events(),H.observeChanges(),H.instantiate())},instantiate:function(){H.verbose("Storing instance of dropdown",H),N=H,y.data(x,H)},destroy:function(){H.verbose("Destroying previous dropdown",y),H.remove.tabbable(),H.remove.active(),R.transition("stop all"),R.removeClass(h.visible).addClass(h.hidden),y.off(C).removeData(x),R.off(C),K.off(a),H.disconnect.menuObserver(),H.disconnect.selectObserver()},observeChanges:function(){"MutationObserver"in ee&&(s=new MutationObserver(H.event.select.mutation),r=new MutationObserver(H.event.menu.mutation),H.debug("Setting up mutation observer",s,r),H.observe.select(),H.observe.menu())},disconnect:{menuObserver:function(){r&&r.disconnect()},selectObserver:function(){s&&s.disconnect()}},observe:{select:function(){H.has.input()&&s&&s.observe(y[0],{childList:!0,subtree:!0})},menu:function(){H.has.menu()&&r&&r.observe(R[0],{childList:!0,subtree:!0})}},create:{id:function(){o=(Math.random().toString(16)+"000000000").substr(2,8),a="."+o,H.verbose("Creating unique id for element",o)},userChoice:function(e){var n,i,a;return!!(e=e||H.get.userValues())&&(e=Array.isArray(e)?e:[e],_.each(e,function(e,t){!1===H.get.item(t)&&(a=f.templates.addition(H.add.variables(u.addResult,t)),i=_("<div />").html(a).attr("data-"+p.value,t).attr("data-"+p.text,t).addClass(h.addition).addClass(h.item),f.hideAdditions&&i.addClass(h.hidden),n=n===ne?i:n.add(i),H.verbose("Creating user choices for value",t,i))}),n)},userLabels:function(e){var t=H.get.userValues();t&&(H.debug("Adding user labels",t),_.each(t,function(e,t){H.verbose("Adding custom user value"),H.add.label(t,t)}))},menu:function(){R=_("<div />").addClass(h.menu).appendTo(y)},sizer:function(){L=_("<span />").addClass(h.sizer).insertAfter(T)}},search:function(e){e=e!==ne?e:H.get.query(),H.verbose("Searching for query",e),H.has.minCharacters(e)?H.filter(e):H.hide(null,!0)},select:{firstUnfiltered:function(){H.verbose("Selecting first non-filtered element"),H.remove.selectedItem(),O.not(b.unselectable).not(b.addition+b.hidden).eq(0).addClass(h.selected)},nextAvailable:function(e){var t=(e=e.eq(0)).nextAll(b.item).not(b.unselectable).eq(0),n=e.prevAll(b.item).not(b.unselectable).eq(0);0<t.length?(H.verbose("Moving selection to",t),t.addClass(h.selected)):(H.verbose("Moving selection to",n),n.addClass(h.selected))}},setup:{api:function(){var e={debug:f.debug,urlData:{value:H.get.value(),query:H.get.query()},on:!1};H.verbose("First request, initializing API"),y.api(e)},layout:function(){y.is("select")&&(H.setup.select(),H.setup.returnedObject()),H.has.menu()||H.create.menu(),H.is.selection()&&H.is.clearable()&&!H.has.clearItem()&&(H.verbose("Adding clear icon"),k=_("<i />").addClass("remove icon").insertBefore(A)),H.is.search()&&!H.has.search()&&(H.verbose("Adding search input"),T=_("<input />").addClass(h.search).prop("autocomplete","off").insertBefore(A)),H.is.multiple()&&H.is.searchSelection()&&!H.has.sizer()&&H.create.sizer(),f.allowTab&&H.set.tabbable()},select:function(){var e=H.get.selectValues();H.debug("Dropdown initialized on a select",e),y.is("select")&&(I=y),0<I.parent(b.dropdown).length?(H.debug("UI dropdown already exists. Creating dropdown menu only"),y=I.closest(b.dropdown),H.has.menu()||H.create.menu(),R=y.children(b.menu),H.setup.menu(e)):(H.debug("Creating entire dropdown from select"),y=_("<div />").attr("class",I.attr("class")).addClass(h.selection).addClass(h.dropdown).html(w.dropdown(e,l,f.preserveHTML,f.className)).insertBefore(I),I.hasClass(h.multiple)&&!1===I.prop("multiple")&&(H.error(m.missingMultiple),I.prop("multiple",!0)),I.is("[multiple]")&&H.set.multiple(),I.prop("disabled")&&(H.debug("Disabling dropdown"),y.addClass(h.disabled)),I.removeAttr("required").removeAttr("class").detach().prependTo(y)),H.refresh()},menu:function(e){R.html(w.menu(e,l,f.preserveHTML,f.className)),O=R.find(b.item),E=f.hideDividers?O.parent().children(b.divider):_()},reference:function(){H.debug("Dropdown behavior was called on select, replacing with closest dropdown"),y=y.parent(b.dropdown),N=y.data(x),P=y.get(0),H.refresh(),H.setup.returnedObject()},returnedObject:function(){var e=B.slice(0,n),t=B.slice(n+1);B=e.add(y).add(t)}},refresh:function(){H.refreshSelectors(),H.refreshData()},refreshItems:function(){O=R.find(b.item),E=f.hideDividers?O.parent().children(b.divider):_()},refreshSelectors:function(){H.verbose("Refreshing selector cache"),A=y.find(b.text),T=y.find(b.search),I=y.find(b.input),D=y.find(b.icon),q=0<y.prev().find(b.text).length?y.prev().find(b.text):y.prev(),R=y.children(b.menu),O=R.find(b.item),E=f.hideDividers?O.parent().children(b.divider):_()},refreshData:function(){H.verbose("Refreshing cached metadata"),O.removeData(p.text).removeData(p.value)},clearData:function(){H.verbose("Clearing metadata"),O.removeData(p.text).removeData(p.value),y.removeData(p.defaultText).removeData(p.defaultValue).removeData(p.placeholderText)},toggle:function(){H.verbose("Toggling menu visibility"),H.is.active()?H.hide():H.show()},show:function(e,t){if(e=_.isFunction(e)?e:function(){},!H.can.show()&&H.is.remote()&&(H.debug("No API results retrieved, searching before show"),H.queryRemote(H.get.query(),H.show)),H.can.show()&&!H.is.active()){if(H.debug("Showing dropdown"),!H.has.message()||H.has.maxSelections()||H.has.allResultsFiltered()||H.remove.message(),H.is.allFiltered())return!0;!1!==f.onShow.call(P)&&H.animate.show(function(){H.can.click()&&H.bind.intent(),H.has.search()&&!t&&H.focusSearch(),H.set.visible(),e.call(P)})}},hide:function(e,t){e=_.isFunction(e)?e:function(){},H.is.active()&&!H.is.animatingOutward()?(H.debug("Hiding dropdown"),!1!==f.onHide.call(P)&&H.animate.hide(function(){H.remove.visible(),H.is.focusedOnSearch()&&!0!==t&&T.blur(),e.call(P)})):H.can.click()&&H.unbind.intent()},hideOthers:function(){H.verbose("Finding other dropdowns to hide"),B.not(y).has(b.menu+"."+h.visible).dropdown("hide")},hideMenu:function(){H.verbose("Hiding menu instantaneously"),H.remove.active(),H.remove.visible(),R.transition("hide")},hideSubMenus:function(){var e=R.children(b.item).find(b.menu);H.verbose("Hiding sub menus",e),e.transition("hide")},bind:{events:function(){H.bind.keyboardEvents(),H.bind.inputEvents(),H.bind.mouseEvents()},keyboardEvents:function(){H.verbose("Binding keyboard events"),y.on("keydown"+C,H.event.keydown),H.has.search()&&y.on(H.get.inputEvent()+C,b.search,H.event.input),H.is.multiple()&&K.on("keydown"+a,H.event.document.keydown)},inputEvents:function(){H.verbose("Binding input change events"),y.on("change"+C,b.input,H.event.change)},mouseEvents:function(){H.verbose("Binding mouse events"),H.is.multiple()&&y.on(Y+C,b.label,H.event.label.click).on(Y+C,b.remove,H.event.remove.click),H.is.searchSelection()?(y.on("mousedown"+C,H.event.mousedown).on("mouseup"+C,H.event.mouseup).on("mousedown"+C,b.menu,H.event.menu.mousedown).on("mouseup"+C,b.menu,H.event.menu.mouseup).on(Y+C,b.icon,H.event.icon.click).on(Y+C,b.clearIcon,H.event.clearIcon.click).on("focus"+C,b.search,H.event.search.focus).on(Y+C,b.search,H.event.search.focus).on("blur"+C,b.search,H.event.search.blur).on(Y+C,b.text,H.event.text.focus),H.is.multiple()&&y.on(Y+C,H.event.click)):("click"==f.on?y.on(Y+C,b.icon,H.event.icon.click).on(Y+C,H.event.test.toggle):"hover"==f.on?y.on("mouseenter"+C,H.delay.show).on("mouseleave"+C,H.delay.hide):y.on(f.on+C,H.toggle),y.on("mousedown"+C,H.event.mousedown).on("mouseup"+C,H.event.mouseup).on("focus"+C,H.event.focus).on(Y+C,b.clearIcon,H.event.clearIcon.click),H.has.menuSearch()?y.on("blur"+C,b.search,H.event.search.blur):y.on("blur"+C,H.event.blur)),R.on((Q?"touchstart":"mouseenter")+C,b.item,H.event.item.mouseenter).on("mouseleave"+C,b.item,H.event.item.mouseleave).on("click"+C,b.item,H.event.item.click)},intent:function(){H.verbose("Binding hide intent event to document"),Q&&K.on("touchstart"+a,H.event.test.touch).on("touchmove"+a,H.event.test.touch),K.on(Y+a,H.event.test.hide)}},unbind:{intent:function(){H.verbose("Removing hide intent event from document"),Q&&K.off("touchstart"+a).off("touchmove"+a),K.off(Y+a)}},filter:function(e){function t(){H.is.multiple()&&H.filterActive(),(e||!e&&0==H.get.activeItem().length)&&H.select.firstUnfiltered(),H.has.allResultsFiltered()?f.onNoResults.call(P,n)?f.allowAdditions?f.hideAdditions&&(H.verbose("User addition with no menu, setting empty style"),H.set.empty(),H.hideMenu()):(H.verbose("All items filtered, showing message",n),H.add.message(u.noResults)):(H.verbose("All items filtered, hiding dropdown",n),H.hideMenu()):(H.remove.empty(),H.remove.message()),f.allowAdditions&&H.add.userSuggestion(H.escape.htmlEntities(e)),H.is.searchSelection()&&H.can.show()&&H.is.focusedOnSearch()&&H.show()}var n=e!==ne?e:H.get.query();f.useLabels&&H.has.maxSelections()||(f.apiSettings?H.can.useAPI()?H.queryRemote(n,function(){f.filterRemoteData&&H.filterItems(n);var e=I.val();Array.isArray(e)||(e=e&&""!==e?e.split(f.delimiter):[]),_.each(e,function(e,t){O.filter('[data-value="'+t+'"]').addClass(h.filtered)}),t()}):H.error(m.noAPI):(H.filterItems(n),t()))},queryRemote:function(e,n){var t={errorDuration:!1,cache:"local",throttle:f.throttle,urlData:{query:e},onError:function(){H.add.message(u.serverError),n()},onFailure:function(){H.add.message(u.serverError),n()},onSuccess:function(e){var t=e[l.remoteValues];Array.isArray(t)||(t=[]),H.remove.message(),H.setup.menu({values:t}),0!==t.length||f.allowAdditions||H.add.message(u.noResults),n()}};y.api("get request")||H.setup.api(),t=_.extend(!0,{},t,f.apiSettings),y.api("setting",t).api("query")},filterItems:function(e){var i=H.remove.diacritics(e!==ne?e:H.get.query()),a=null,t=H.escape.string(i),n=(f.ignoreSearchCase?"i":"")+"gm",o=new RegExp("^"+t,n);H.has.query()&&(a=[],H.verbose("Searching for matching values",i),O.each(function(){var e,t,n=_(this);if(n.hasClass(h.unfilterable))return a.push(this),!0;if("both"===f.match||"text"===f.match){if(-1!==(e=H.remove.diacritics(String(H.get.choiceText(n,!1)))).search(o))return a.push(this),!0;if("exact"===f.fullTextSearch&&H.exactSearch(i,e))return a.push(this),!0;if(!0===f.fullTextSearch&&H.fuzzySearch(i,e))return a.push(this),!0}if("both"===f.match||"value"===f.match){if(-1!==(t=H.remove.diacritics(String(H.get.choiceValue(n,e)))).search(o))return a.push(this),!0;if("exact"===f.fullTextSearch&&H.exactSearch(i,t))return a.push(this),!0;if(!0===f.fullTextSearch&&H.fuzzySearch(i,t))return a.push(this),!0}})),H.debug("Showing only matched items",i),H.remove.filteredItem(),a&&O.not(a).addClass(h.filtered),H.has.query()?!0===f.hideDividers?E.addClass(h.hidden):"empty"===f.hideDividers&&E.removeClass(h.hidden).filter(function(){var e=_(this).nextUntil(b.item);return 0===(e.length?e:_(this)).nextUntil(b.divider).filter(b.item+":not(."+h.filtered+")").length}).addClass(h.hidden):E.removeClass(h.hidden)},fuzzySearch:function(e,t){var n=t.length,i=e.length;if(e=f.ignoreSearchCase?e.toLowerCase():e,t=f.ignoreSearchCase?t.toLowerCase():t,n<i)return!1;if(i===n)return e===t;e:for(var a=0,o=0;a<i;a++){for(var s=e.charCodeAt(a);o<n;)if(t.charCodeAt(o++)===s)continue e;return!1}return!0},exactSearch:function(e,t){return e=f.ignoreSearchCase?e.toLowerCase():e,-1<(t=f.ignoreSearchCase?t.toLowerCase():t).indexOf(e)},filterActive:function(){f.useLabels&&O.filter("."+h.active).addClass(h.filtered)},focusSearch:function(e){H.has.search()&&!H.is.focusedOnSearch()&&(e?(y.off("focus"+C,b.search),T.focus(),y.on("focus"+C,b.search,H.event.search.focus)):T.focus())},blurSearch:function(){H.has.search()&&T.blur()},forceSelection:function(){var e=O.not(h.filtered).filter("."+h.selected).eq(0),t=O.not(h.filtered).filter("."+h.active).eq(0),n=0<e.length?e:t,i=0<n.length;f.allowAdditions||i&&!H.is.multiple()?(H.debug("Forcing partial selection to selected item",n),H.event.item.click.call(n,{},!0)):H.remove.searchTerm()},change:{values:function(e){f.allowAdditions||H.clear(),H.debug("Creating dropdown with specified values",e),H.setup.menu({values:e}),_.each(e,function(e,t){if(1==t.selected&&(H.debug("Setting initial selection to",t[l.value]),H.set.selected(t[l.value]),!H.is.multiple()))return!1}),H.has.selectInput()&&(H.disconnect.selectObserver(),I.html(""),I.append("<option disabled selected value></option>"),_.each(e,function(e,t){var n=f.templates.deQuote(t[l.value]),i=f.templates.escape(t[l.name]||"",f.preserveHTML);I.append('<option value="'+n+'">'+i+"</option>")}),H.observe.select())}},event:{change:function(){z||(H.debug("Input changed, updating selection"),H.set.selected())},focus:function(){f.showOnFocus&&!V&&H.is.hidden()&&!t&&H.show()},blur:function(e){t=te.activeElement===this,V||t||(H.remove.activeLabel(),H.hide())},mousedown:function(){H.is.searchSelection()?i=!0:V=!0},mouseup:function(){H.is.searchSelection()?i=!1:V=!1},click:function(e){_(e.target).is(y)&&(H.is.focusedOnSearch()?H.show():H.focusSearch())},search:{focus:function(e){V=!0,H.is.multiple()&&H.remove.activeLabel(),(f.showOnFocus||"focus"!==e.type&&"focusin"!==e.type)&&H.search()},blur:function(e){t=te.activeElement===this,H.is.searchSelection()&&!i&&(M||t||(f.forceSelection?H.forceSelection():f.allowAdditions||H.remove.searchTerm(),H.hide())),i=!1}},clearIcon:{click:function(e){H.clear(),H.is.searchSelection()&&H.remove.searchTerm(),H.hide(),e.stopPropagation()}},icon:{click:function(e){F=!0,H.has.search()?H.is.active()?H.blurSearch():f.showOnFocus?H.focusSearch():H.toggle():H.toggle()}},text:{focus:function(e){V=!0,H.focusSearch()}},input:function(e){(H.is.multiple()||H.is.searchSelection())&&H.set.filtered(),clearTimeout(H.timer),H.timer=setTimeout(H.search,f.delay.search)},label:{click:function(e){var t=_(this),n=y.find(b.label),i=n.filter("."+h.active),a=t.nextAll("."+h.active),o=t.prevAll("."+h.active),s=0<a.length?t.nextUntil(a).add(i).add(t):t.prevUntil(o).add(i).add(t);e.shiftKey?(i.removeClass(h.active),s.addClass(h.active)):e.ctrlKey?t.toggleClass(h.active):(i.removeClass(h.active),t.addClass(h.active)),f.onLabelSelect.apply(this,n.filter("."+h.active))}},remove:{click:function(){var e=_(this).parent();e.hasClass(h.active)?H.remove.activeLabels():H.remove.activeLabels(e)}},test:{toggle:function(e){var t=H.is.multiple()?H.show:H.toggle;H.is.bubbledLabelClick(e)||H.is.bubbledIconClick(e)||H.determine.eventOnElement(e,t)&&e.preventDefault()},touch:function(e){H.determine.eventOnElement(e,function(){"touchstart"==e.type?H.timer=setTimeout(function(){H.hide()},f.delay.touch):"touchmove"==e.type&&clearTimeout(H.timer)}),e.stopPropagation()},hide:function(e){H.determine.eventInModule(e,H.hide)&&P.id&&_(e.target).attr("for")===P.id&&e.preventDefault()}},select:{mutation:function(e){H.debug("<select> modified, recreating menu"),H.is.selectMutation(e)&&(H.disconnect.selectObserver(),H.refresh(),H.setup.select(),H.set.selected(),H.observe.select())}},menu:{mutation:function(e){var t=e[0],n=t.addedNodes?_(t.addedNodes[0]):_(!1),i=t.removedNodes?_(t.removedNodes[0]):_(!1),a=n.add(i),o=a.is(b.addition)||0<a.closest(b.addition).length,s=a.is(b.message)||0<a.closest(b.message).length;o||s?(H.debug("Updating item selector cache"),H.refreshItems()):(H.debug("Menu modified, updating selector cache"),H.refresh())},mousedown:function(){M=!0},mouseup:function(){M=!1}},item:{mouseenter:function(e){var t=_(e.target),n=_(this),i=n.children(b.menu),a=n.siblings(b.item).children(b.menu),o=0<i.length;0<i.find(t).length||!o||(clearTimeout(H.itemTimer),H.itemTimer=setTimeout(function(){H.verbose("Showing sub-menu",i),_.each(a,function(){H.animate.hide(!1,_(this))}),H.animate.show(!1,i)},f.delay.show),e.preventDefault())},mouseleave:function(e){var t=_(this).children(b.menu);0<t.length&&(clearTimeout(H.itemTimer),H.itemTimer=setTimeout(function(){H.verbose("Hiding sub-menu",t),H.animate.hide(!1,t)},f.delay.hide))},click:function(e,t){var n=_(this),i=_(e?e.target:""),a=n.find(b.menu),o=H.get.choiceText(n),s=H.get.choiceValue(n,o),r=0<a.length,l=0<a.find(i).length;"input"!==te.activeElement.tagName.toLowerCase()&&_(te.activeElement).blur(),l||r&&!f.allowCategorySelection||(H.is.searchSelection()&&(f.allowAdditions&&H.remove.userAddition(),H.remove.searchTerm(),H.is.focusedOnSearch()||1==t||H.focusSearch(!0)),f.useLabels||(H.remove.filteredItem(),H.set.scrollPosition(n)),H.determine.selectAction.call(this,o,s))}},document:{keydown:function(e){var t=e.which;if(H.is.inObject(t,g)){var n=y.find(b.label),i=n.filter("."+h.active),a=(i.data(p.value),n.index(i)),o=n.length,s=0<i.length,r=1<i.length,l=0===a,c=a+1==o,u=H.is.searchSelection(),d=H.is.focusedOnSearch(),v=H.is.focused(),m=d&&0===H.get.caretPosition(!1),f=m&&0!==H.get.caretPosition(!0);if(u&&!s&&!d)return;t==g.leftArrow?!v&&!m||s?s&&(e.shiftKey?H.verbose("Adding previous label to selection"):(H.verbose("Selecting previous label"),n.removeClass(h.active)),l&&!r?i.addClass(h.active):i.prev(b.siblingLabel).addClass(h.active).end(),e.preventDefault()):(H.verbose("Selecting previous label"),n.last().addClass(h.active)):t==g.rightArrow?(v&&!s&&n.first().addClass(h.active),s&&(e.shiftKey?H.verbose("Adding next label to selection"):(H.verbose("Selecting next label"),n.removeClass(h.active)),c?u?d?n.removeClass(h.active):H.focusSearch():r?i.next(b.siblingLabel).addClass(h.active):i.addClass(h.active):i.next(b.siblingLabel).addClass(h.active),e.preventDefault())):t==g.deleteKey||t==g.backspace?s?(H.verbose("Removing active labels"),c&&u&&!d&&H.focusSearch(),i.last().next(b.siblingLabel).addClass(h.active),H.remove.activeLabels(i),e.preventDefault()):!m||f||s||t!=g.backspace||(H.verbose("Removing last label on input backspace"),i=n.last().addClass(h.active),H.remove.activeLabels(i)):i.removeClass(h.active)}}},keydown:function(e){var t=e.which;if(H.is.inObject(t,g)){var n,i=O.not(b.unselectable).filter("."+h.selected).eq(0),a=R.children("."+h.active).eq(0),o=0<i.length?i:a,s=0<o.length?o.siblings(":not(."+h.filtered+")").addBack():R.children(":not(."+h.filtered+")"),r=o.children(b.menu),l=o.closest(b.menu),c=l.hasClass(h.visible)||l.hasClass(h.animating)||0<l.parent(b.menu).length,u=0<r.length,d=0<o.length,v=0<o.not(b.unselectable).length,m=t==g.delimiter&&f.allowAdditions&&H.is.multiple();if(f.allowAdditions&&f.hideAdditions&&(t==g.enter||m)&&v&&(H.verbose("Selecting item from keyboard shortcut",o),H.event.item.click.call(o,e),H.is.searchSelection()&&H.remove.searchTerm(),H.is.multiple()&&e.preventDefault()),H.is.visible()){if(t!=g.enter&&!m||(t==g.enter&&d&&u&&!f.allowCategorySelection?(H.verbose("Pressed enter on unselectable category, opening sub menu"),t=g.rightArrow):v&&(H.verbose("Selecting item from keyboard shortcut",o),H.event.item.click.call(o,e),H.is.searchSelection()&&(H.remove.searchTerm(),H.is.multiple()&&T.focus())),e.preventDefault()),d&&(t==g.leftArrow&&l[0]!==R[0]&&(H.verbose("Left key pressed, closing sub-menu"),H.animate.hide(!1,l),o.removeClass(h.selected),l.closest(b.item).addClass(h.selected),e.preventDefault()),t==g.rightArrow&&u&&(H.verbose("Right key pressed, opening sub-menu"),H.animate.show(!1,r),o.removeClass(h.selected),r.find(b.item).eq(0).addClass(h.selected),e.preventDefault())),t==g.upArrow){if(n=d&&c?o.prevAll(b.item+":not("+b.unselectable+")").eq(0):O.eq(0),s.index(n)<0)return H.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();H.verbose("Up key pressed, changing active item"),o.removeClass(h.selected),n.addClass(h.selected),H.set.scrollPosition(n),f.selectOnKeydown&&H.is.single()&&H.set.selectedItem(n),e.preventDefault()}if(t==g.downArrow){if(0===(n=d&&c?n=o.nextAll(b.item+":not("+b.unselectable+")").eq(0):O.eq(0)).length)return H.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();H.verbose("Down key pressed, changing active item"),O.removeClass(h.selected),n.addClass(h.selected),H.set.scrollPosition(n),f.selectOnKeydown&&H.is.single()&&H.set.selectedItem(n),e.preventDefault()}t==g.pageUp&&(H.scrollPage("up"),e.preventDefault()),t==g.pageDown&&(H.scrollPage("down"),e.preventDefault()),t==g.escape&&(H.verbose("Escape key pressed, closing dropdown"),H.hide())}else m&&e.preventDefault(),t!=g.downArrow||H.is.visible()||(H.verbose("Down key pressed, showing dropdown"),H.show(),e.preventDefault())}else H.has.search()||H.set.selectedLetter(String.fromCharCode(t))}},trigger:{change:function(){var e=te.createEvent("HTMLEvents"),t=I[0];t&&(H.verbose("Triggering native change event"),e.initEvent("change",!0,!1),t.dispatchEvent(e))}},determine:{selectAction:function(e,t){c=!0,H.verbose("Determining action",f.action),_.isFunction(H.action[f.action])?(H.verbose("Triggering preset action",f.action,e,t),H.action[f.action].call(P,e,t,this)):_.isFunction(f.action)?(H.verbose("Triggering user action",f.action,e,t),f.action.call(P,e,t,this)):H.error(m.action,f.action),c=!1},eventInModule:function(e,t){var n=_(e.target),i=0<n.closest(te.documentElement).length,a=0<n.closest(y).length;return t=_.isFunction(t)?t:function(){},i&&!a?(H.verbose("Triggering event",t),t(),!0):(H.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(e,t){var n=_(e.target),i=n.closest(b.siblingLabel),a=te.body.contains(e.target),o=0===y.find(i).length||!(H.is.multiple()&&f.useLabels),s=0===n.closest(R).length;return t=_.isFunction(t)?t:function(){},a&&o&&s?(H.verbose("Triggering event",t),t(),!0):(H.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(e,t,n){t=t!==ne?t:e,H.can.activate(_(n))&&(H.set.selected(t,_(n)),H.is.multiple()||H.hideAndClear())},select:function(e,t,n){t=t!==ne?t:e,H.can.activate(_(n))&&(H.set.value(t,e,_(n)),H.is.multiple()||H.hideAndClear())},combo:function(e,t,n){t=t!==ne?t:e,H.set.selected(t,_(n)),H.hideAndClear()},hide:function(e,t,n){H.set.value(t,e,_(n)),H.hideAndClear()}},get:{id:function(){return o},defaultText:function(){return y.data(p.defaultText)},defaultValue:function(){return y.data(p.defaultValue)},placeholderText:function(){return"auto"!=f.placeholder&&"string"==typeof f.placeholder?f.placeholder:y.data(p.placeholderText)||""},text:function(){return A.text()},query:function(){return _.trim(T.val())},searchWidth:function(e){return e=e!==ne?e:T.val(),L.text(e),Math.ceil(L.width()+1)},selectionCount:function(){var e=H.get.values();return H.is.multiple()?Array.isArray(e)?e.length:0:""!==H.get.value()?1:0},transition:function(e){return"auto"==f.transition?H.is.upward(e)?"slide up":"slide down":f.transition},userValues:function(){var e=H.get.values();return!!e&&(e=Array.isArray(e)?e:[e],_.grep(e,function(e){return!1===H.get.item(e)}))},uniqueArray:function(n){return _.grep(n,function(e,t){return _.inArray(e,n)===t})},caretPosition:function(e){var t,n,i=T.get(0);return e&&"selectionEnd"in i?i.selectionEnd:!e&&"selectionStart"in i?i.selectionStart:te.selection?(i.focus(),n=(t=te.selection.createRange()).text.length,e?n:(t.moveStart("character",-i.value.length),t.text.length-n)):void 0},value:function(){var e=0<I.length?I.val():y.data(p.value),t=Array.isArray(e)&&1===e.length&&""===e[0];return e===ne||t?"":e},values:function(){var e=H.get.value();return""===e?"":!H.has.selectInput()&&H.is.multiple()?"string"==typeof e?H.escape.htmlEntities(e).split(f.delimiter):"":e},remoteValues:function(){var e=H.get.values(),i=!1;return e&&("string"==typeof e&&(e=[e]),_.each(e,function(e,t){var n=H.read.remoteData(t);H.verbose("Restoring value from session data",n,t),n&&((i=i||{})[t]=n)})),i},choiceText:function(e,t){if(t=t!==ne?t:f.preserveHTML,e)return 0<e.find(b.menu).length&&(H.verbose("Retrieving text of element with sub-menu"),(e=e.clone()).find(b.menu).remove(),e.find(b.menuIcon).remove()),e.data(p.text)!==ne?e.data(p.text):t?_.trim(e.html()):_.trim(e.text())},choiceValue:function(e,t){return t=t||H.get.choiceText(e),!!e&&(e.data(p.value)!==ne?String(e.data(p.value)):"string"==typeof t?_.trim(f.ignoreSearchCase?t.toLowerCase():t):String(t))},inputEvent:function(){var e=T[0];return!!e&&(e.oninput!==ne?"input":e.onpropertychange!==ne?"propertychange":"keyup")},selectValues:function(){var s={},r=[];return s.values=[],y.find("option").each(function(){var e=_(this),t=e.html(),n=e.attr("disabled"),i=e.attr("value")!==ne?e.attr("value"):t,a=e.data(p.text)!==ne?e.data(p.text):t,o=e.parent("optgroup");"auto"===f.placeholder&&""===i?s.placeholder=t:(o.length===r.length&&o[0]===r[0]||(s.values.push({type:"header",divider:f.headerDivider,name:o.attr("label")||""}),r=o),s.values.push({name:t,value:i,text:a,disabled:n}))}),f.placeholder&&"auto"!==f.placeholder&&(H.debug("Setting placeholder value to",f.placeholder),s.placeholder=f.placeholder),f.sortSelect?(!0===f.sortSelect?s.values.sort(function(e,t){return e.name.localeCompare(t.name)}):"natural"===f.sortSelect?s.values.sort(function(e,t){return e.name.toLowerCase().localeCompare(t.name.toLowerCase())}):_.isFunction(f.sortSelect)&&s.values.sort(f.sortSelect),H.debug("Retrieved and sorted values from select",s)):H.debug("Retrieved values from select",s),s},activeItem:function(){return O.filter("."+h.active)},selectedItem:function(){var e=O.not(b.unselectable).filter("."+h.selected);return 0<e.length?e:O.eq(0)},itemWithAdditions:function(e){var t=H.get.item(e),n=H.create.userChoice(e);return n&&0<n.length&&(t=0<t.length?t.add(n):n),t},item:function(i,a){var e,o,s=!1;return i=i!==ne?i:H.get.values()!==ne?H.get.values():H.get.text(),e=(o=H.is.multiple()&&Array.isArray(i))?0<i.length:i!==ne&&null!==i,a=""===i||!1===i||!0===i||(a||!1),e&&O.each(function(){var e=_(this),t=H.get.choiceText(e),n=H.get.choiceValue(e,t);if(null!==n&&n!==ne)if(o)-1!==_.inArray(H.escape.htmlEntities(String(n)),i.map(function(e){return String(e)}))&&(s=s?s.add(e):e);else if(a){if(H.verbose("Ambiguous dropdown value using strict type check",e,i),n===i)return s=e,!0}else if(f.ignoreCase&&(n=n.toLowerCase(),i=i.toLowerCase()),H.escape.htmlEntities(String(n))===H.escape.htmlEntities(String(i)))return H.verbose("Found select item by value",n,i),s=e,!0}),s}},check:{maxSelections:function(e){return!f.maxSelections||((e=e!==ne?e:H.get.selectionCount())>=f.maxSelections?(H.debug("Maximum selection count reached"),f.useLabels&&(O.addClass(h.filtered),H.add.message(u.maxSelections)),!0):(H.verbose("No longer at maximum selection count"),H.remove.message(),H.remove.filteredItem(),H.is.searchSelection()&&H.filterItems(),!1))}},restore:{defaults:function(e){H.clear(e),H.restore.defaultText(),H.restore.defaultValue()},defaultText:function(){var e=H.get.defaultText();e===H.get.placeholderText?(H.debug("Restoring default placeholder text",e),H.set.placeholderText(e)):(H.debug("Restoring default text",e),H.set.text(e))},placeholderText:function(){H.set.placeholderText()},defaultValue:function(){var e=H.get.defaultValue();e!==ne&&(H.debug("Restoring default value",e),""!==e?(H.set.value(e),H.set.selected()):(H.remove.activeItem(),H.remove.selectedItem()))},labels:function(){f.allowAdditions&&(f.useLabels||(H.error(m.labels),f.useLabels=!0),H.debug("Restoring selected values"),H.create.userLabels()),H.check.maxSelections()},selected:function(){H.restore.values(),H.is.multiple()?(H.debug("Restoring previously selected values and labels"),H.restore.labels()):H.debug("Restoring previously selected values")},values:function(){H.set.initialLoad(),f.apiSettings&&f.saveRemoteData&&H.get.remoteValues()?H.restore.remoteValues():H.set.selected();var e=H.get.value();!e||""===e||Array.isArray(e)&&0===e.length?I.addClass(h.noselection):I.removeClass(h.noselection),H.remove.initialLoad()},remoteValues:function(){var e=H.get.remoteValues();H.debug("Recreating selected from session data",e),e&&(H.is.single()?_.each(e,function(e,t){H.set.text(t)}):_.each(e,function(e,t){H.add.label(e,t)}))}},read:{remoteData:function(e){var t;if(ee.Storage!==ne)return(t=sessionStorage.getItem(e))!==ne&&t;H.error(m.noStorage)}},save:{defaults:function(){H.save.defaultText(),H.save.placeholderText(),H.save.defaultValue()},defaultValue:function(){var e=H.get.value();H.verbose("Saving default value as",e),y.data(p.defaultValue,e)},defaultText:function(){var e=H.get.text();H.verbose("Saving default text as",e),y.data(p.defaultText,e)},placeholderText:function(){var e;!1!==f.placeholder&&A.hasClass(h.placeholder)&&(e=H.get.text(),H.verbose("Saving placeholder text as",e),y.data(p.placeholderText,e))},remoteData:function(e,t){ee.Storage!==ne?(H.verbose("Saving remote data to session storage",t,e),sessionStorage.setItem(t,e)):H.error(m.noStorage)}},clear:function(e){H.is.multiple()&&f.useLabels?H.remove.labels():(H.remove.activeItem(),H.remove.selectedItem(),H.remove.filteredItem()),H.set.placeholderText(),H.clearValue(e)},clearValue:function(e){H.set.value("",null,null,e)},scrollPage:function(e,t){var n=t||H.get.selectedItem(),i=n.closest(b.menu),a=i.outerHeight(),o=i.scrollTop(),s=O.eq(0).outerHeight(),r=Math.floor(a/s),l=(i.prop("scrollHeight"),"up"==e?o-s*r:o+s*r),c=O.not(b.unselectable),u="up"==e?c.index(n)-r:c.index(n)+r,d=("up"==e?0<=u:u<c.length)?c.eq(u):"up"==e?c.first():c.last();0<d.length&&(H.debug("Scrolling page",e,d),n.removeClass(h.selected),d.addClass(h.selected),f.selectOnKeydown&&H.is.single()&&H.set.selectedItem(d),i.scrollTop(l))},set:{filtered:function(){var e=H.is.multiple(),t=H.is.searchSelection(),n=e&&t,i=t?H.get.query():"",a="string"==typeof i&&0<i.length,o=H.get.searchWidth(),s=""!==i;e&&a&&(H.verbose("Adjusting input width",o,f.glyphWidth),T.css("width",o)),a||n&&s?(H.verbose("Hiding placeholder text"),A.addClass(h.filtered)):e&&(!n||s)||(H.verbose("Showing placeholder text"),A.removeClass(h.filtered))},empty:function(){y.addClass(h.empty)},loading:function(){y.addClass(h.loading)},placeholderText:function(e){e=e||H.get.placeholderText(),H.debug("Setting placeholder text",e),H.set.text(e),A.addClass(h.placeholder)},tabbable:function(){H.is.searchSelection()?(H.debug("Added tabindex to searchable dropdown"),T.val("").attr("tabindex",0),R.attr("tabindex",-1)):(H.debug("Added tabindex to dropdown"),y.attr("tabindex")===ne&&(y.attr("tabindex",0),R.attr("tabindex",-1)))},initialLoad:function(){H.verbose("Setting initial load"),e=!0},activeItem:function(e){f.allowAdditions&&0<e.filter(b.addition).length?e.addClass(h.filtered):e.addClass(h.active)},partialSearch:function(e){var t=H.get.query().length;T.val(e.substr(0,t))},scrollPosition:function(e,t){var n,i,a,o,s=(e=e||H.get.selectedItem()).closest(b.menu),r=e&&0<e.length;t=t!==ne&&t,0===H.get.activeItem().length&&(t=!1),e&&0<s.length&&r&&(e.position().top,s.addClass(h.loading),n=(i=s.scrollTop())-s.offset().top+e.offset().top,t||(o=i+s.height()<n+5,a=n-5<i),H.debug("Scrolling to active item",n),(t||a||o)&&s.scrollTop(n),s.removeClass(h.loading))},text:function(e){"combo"===f.action?(H.debug("Changing combo button text",e,q),f.preserveHTML?q.html(e):q.text(e)):"activate"===f.action&&(e!==H.get.placeholderText()&&A.removeClass(h.placeholder),H.debug("Changing text",e,A),A.removeClass(h.filtered),f.preserveHTML?A.html(e):A.text(e))},selectedItem:function(e){var t=H.get.choiceValue(e),n=H.get.choiceText(e,!1),i=H.get.choiceText(e,!0);H.debug("Setting user selection to item",e),H.remove.activeItem(),H.set.partialSearch(n),H.set.activeItem(e),H.set.selected(t,e),H.set.text(i)},selectedLetter:function(e){var t,n=O.filter("."+h.selected),i=0<n.length&&H.has.firstLetter(n,e),a=!1;i&&(t=n.nextAll(O).eq(0),H.has.firstLetter(t,e)&&(a=t)),a||O.each(function(){if(H.has.firstLetter(_(this),e))return a=_(this),!1}),a&&(H.verbose("Scrolling to next value with letter",e),H.set.scrollPosition(a),n.removeClass(h.selected),a.addClass(h.selected),f.selectOnKeydown&&H.is.single()&&H.set.selectedItem(a))},direction:function(e){"auto"==f.direction?(e?H.is.upward(e)&&H.remove.upward(e):H.remove.upward(),H.can.openDownward(e)?H.remove.upward(e):H.set.upward(e),H.is.leftward(e)||H.can.openRightward(e)||H.set.leftward(e)):"upward"==f.direction&&H.set.upward(e)},upward:function(e){(e||y).addClass(h.upward)},leftward:function(e){(e||R).addClass(h.leftward)},value:function(e,t,n,i){e===ne||""===e||Array.isArray(e)&&0===e.length?I.addClass(h.noselection):I.removeClass(h.noselection);var a=H.escape.value(e),o=0<I.length,s=H.get.values(),r=e!==ne?String(e):e;if(o){if(!f.allowReselection&&r==s&&(H.verbose("Skipping value update already same value",e,s),!H.is.initialLoad()))return;H.is.single()&&H.has.selectInput()&&H.can.extendSelect()&&(H.debug("Adding user option",e),H.add.optionValue(e)),H.debug("Updating input value",a,s),z=!0,I.val(a),!1===f.fireOnInit&&H.is.initialLoad()?H.debug("Input native change event ignored on initial load"):!0!==i&&H.trigger.change(),z=!1}else H.verbose("Storing value in metadata",a,I),a!==s&&y.data(p.value,r);!1===f.fireOnInit&&H.is.initialLoad()?H.verbose("No callback on initial load",f.onChange):!0!==i&&f.onChange.call(P,e,t,n)},active:function(){y.addClass(h.active)},multiple:function(){y.addClass(h.multiple)},visible:function(){y.addClass(h.visible)},exactly:function(e,t){H.debug("Setting selected to exact values"),H.clear(),H.set.selected(e,t)},selected:function(e,r){var l=H.is.multiple();(r=f.allowAdditions?r||H.get.itemWithAdditions(e):r||H.get.item(e))&&(H.debug("Setting selected menu item to",r),H.is.multiple()&&H.remove.searchWidth(),H.is.single()?(H.remove.activeItem(),H.remove.selectedItem()):f.useLabels&&H.remove.selectedItem(),r.each(function(){var e=_(this),t=H.get.choiceText(e),n=H.get.choiceValue(e,t),i=e.hasClass(h.filtered),a=e.hasClass(h.active),o=e.hasClass(h.addition),s=l&&1==r.length;l?!a||o?(f.apiSettings&&f.saveRemoteData&&H.save.remoteData(t,n),f.useLabels?(H.add.label(n,t,s),H.add.value(n,t,e),H.set.activeItem(e),H.filterActive(),H.select.nextAvailable(r)):(H.add.value(n,t,e),H.set.text(H.add.variables(u.count)),H.set.activeItem(e))):i||!f.useLabels&&!c||(H.debug("Selected active value, removing label"),H.remove.selected(n)):(f.apiSettings&&f.saveRemoteData&&H.save.remoteData(t,n),H.set.text(t),H.set.value(n,t,e),e.addClass(h.active).addClass(h.selected))}),H.remove.searchTerm())}},add:{label:function(e,t,n){var i,a=H.is.searchSelection()?T:A,o=H.escape.value(e);f.ignoreCase&&(o=o.toLowerCase()),i=_("<a />").addClass(h.label).attr("data-"+p.value,o).html(w.label(o,t,f.preserveHTML,f.className)),i=f.onLabelCreate.call(i,o,t),H.has.label(e)?H.debug("User selection already exists, skipping",o):(f.label.variation&&i.addClass(f.label.variation),!0===n?(H.debug("Animating in label",i),i.addClass(h.hidden).insertBefore(a).transition({animation:f.label.transition,debug:f.debug,verbose:f.verbose,duration:f.label.duration})):(H.debug("Adding selection label",i),i.insertBefore(a)))},message:function(e){var t=R.children(b.message),n=f.templates.message(H.add.variables(e));0<t.length?t.html(n):t=_("<div/>").html(n).addClass(h.message).appendTo(R)},optionValue:function(e){var t=H.escape.value(e);0<I.find('option[value="'+H.escape.string(t)+'"]').length||(H.disconnect.selectObserver(),H.is.single()&&(H.verbose("Removing previous user addition"),I.find("option."+h.addition).remove()),_("<option/>").prop("value",t).addClass(h.addition).html(e).appendTo(I),H.verbose("Adding user addition as an <option>",e),H.observe.select())},userSuggestion:function(e){var t,n=R.children(b.addition),i=H.get.item(e),a=i&&i.not(b.addition).length,o=0<n.length;f.useLabels&&H.has.maxSelections()||(""===e||a?n.remove():(o?(n.data(p.value,e).data(p.text,e).attr("data-"+p.value,e).attr("data-"+p.text,e).removeClass(h.filtered),f.hideAdditions||(t=f.templates.addition(H.add.variables(u.addResult,e)),n.html(t)),H.verbose("Replacing user suggestion with new value",n)):((n=H.create.userChoice(e)).prependTo(R),H.verbose("Adding item choice to menu corresponding with user choice addition",n)),f.hideAdditions&&!H.is.allFiltered()||n.addClass(h.selected).siblings().removeClass(h.selected),H.refreshItems()))},variables:function(e,t){var n,i,a=-1!==e.search("{count}"),o=-1!==e.search("{maxCount}"),s=-1!==e.search("{term}");return H.verbose("Adding templated variables to message",e),a&&(n=H.get.selectionCount(),e=e.replace("{count}",n)),o&&(n=H.get.selectionCount(),e=e.replace("{maxCount}",f.maxSelections)),s&&(i=t||H.get.query(),e=e.replace("{term}",i)),e},value:function(e,t,n){var i,a=H.get.values();H.has.value(e)?H.debug("Value already selected"):""!==e?(i=Array.isArray(a)?(i=a.concat([e]),H.get.uniqueArray(i)):[e],H.has.selectInput()?H.can.extendSelect()&&(H.debug("Adding value to select",e,i,I),H.add.optionValue(e)):(i=i.join(f.delimiter),H.debug("Setting hidden input to delimited value",i,I)),!1===f.fireOnInit&&H.is.initialLoad()?H.verbose("Skipping onadd callback on initial load",f.onAdd):f.onAdd.call(P,e,t,n),H.set.value(i,t,n),H.check.maxSelections()):H.debug("Cannot select blank values from multiselect")}},remove:{active:function(){y.removeClass(h.active)},activeLabel:function(){y.find(b.label).removeClass(h.active)},empty:function(){y.removeClass(h.empty)},loading:function(){y.removeClass(h.loading)},initialLoad:function(){e=!1},upward:function(e){(e||y).removeClass(h.upward)},leftward:function(e){(e||R).removeClass(h.leftward)},visible:function(){y.removeClass(h.visible)},activeItem:function(){O.removeClass(h.active)},filteredItem:function(){f.useLabels&&H.has.maxSelections()||(f.useLabels&&H.is.multiple()?O.not("."+h.active).removeClass(h.filtered):O.removeClass(h.filtered),f.hideDividers&&E.removeClass(h.hidden),H.remove.empty())},optionValue:function(e){var t=H.escape.value(e),n=I.find('option[value="'+H.escape.string(t)+'"]');0<n.length&&n.hasClass(h.addition)&&(s&&(s.disconnect(),H.verbose("Temporarily disconnecting mutation observer")),n.remove(),H.verbose("Removing user addition as an <option>",t),s&&s.observe(I[0],{childList:!0,subtree:!0}))},message:function(){R.children(b.message).remove()},searchWidth:function(){T.css("width","")},searchTerm:function(){H.verbose("Cleared search term"),T.val(""),H.set.filtered()},userAddition:function(){O.filter(b.addition).remove()},selected:function(e,t){if(!(t=f.allowAdditions?t||H.get.itemWithAdditions(e):t||H.get.item(e)))return!1;t.each(function(){var e=_(this),t=H.get.choiceText(e),n=H.get.choiceValue(e,t);H.is.multiple()?f.useLabels?(H.remove.value(n,t,e),H.remove.label(n)):(H.remove.value(n,t,e),0===H.get.selectionCount()?H.set.placeholderText():H.set.text(H.add.variables(u.count))):H.remove.value(n,t,e),e.removeClass(h.filtered).removeClass(h.active),f.useLabels&&e.removeClass(h.selected)})},selectedItem:function(){O.removeClass(h.selected)},value:function(e,t,n){var i,a=H.get.values();e=H.escape.htmlEntities(e),H.has.selectInput()?(H.verbose("Input is <select> removing selected option",e),i=H.remove.arrayValue(e,a),H.remove.optionValue(e)):(H.verbose("Removing from delimited values",e),i=(i=H.remove.arrayValue(e,a)).join(f.delimiter)),!1===f.fireOnInit&&H.is.initialLoad()?H.verbose("No callback on initial load",f.onRemove):f.onRemove.call(P,e,t,n),H.set.value(i,t,n),H.check.maxSelections()},arrayValue:function(t,e){return Array.isArray(e)||(e=[e]),e=_.grep(e,function(e){return t!=e}),H.verbose("Removed value from delimited string",t,e),e},label:function(e,t){var n=y.find(b.label).filter("[data-"+p.value+'="'+H.escape.string(f.ignoreCase?e.toLowerCase():e)+'"]');H.verbose("Removing label",n),n.remove()},activeLabels:function(e){e=e||y.find(b.label).filter("."+h.active),H.verbose("Removing active label selections",e),H.remove.labels(e)},labels:function(e){e=e||y.find(b.label),H.verbose("Removing labels",e),e.each(function(){var e=_(this),t=e.data(p.value),n=t!==ne?String(t):t,i=H.is.userValue(n);!1!==f.onLabelRemove.call(e,t)?(H.remove.message(),i?(H.remove.value(n),H.remove.label(n)):H.remove.selected(n)):H.debug("Label remove callback cancelled removal")})},tabbable:function(){H.is.searchSelection()?(H.debug("Searchable dropdown initialized"),T.removeAttr("tabindex")):(H.debug("Simple selection dropdown initialized"),y.removeAttr("tabindex")),R.removeAttr("tabindex")},diacritics:function(e){return f.ignoreDiacritics?e.normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}},has:{menuSearch:function(){return H.has.search()&&0<T.closest(R).length},clearItem:function(){return 0<k.length},search:function(){return 0<T.length},sizer:function(){return 0<L.length},selectInput:function(){return I.is("select")},minCharacters:function(e){return f.minCharacters&&!F?(e=e!==ne?String(e):String(H.get.query())).length>=f.minCharacters:!(F=!1)},firstLetter:function(e,t){var n;return!(!e||0===e.length||"string"!=typeof t)&&(n=H.get.choiceText(e,!1),(t=t.toLowerCase())==String(n).charAt(0).toLowerCase())},input:function(){return 0<I.length},items:function(){return 0<O.length},menu:function(){return 0<R.length},message:function(){return 0!==R.children(b.message).length},label:function(e){var t=H.escape.value(e),n=y.find(b.label);return f.ignoreCase&&(t=t.toLowerCase()),0<n.filter("[data-"+p.value+'="'+H.escape.string(t)+'"]').length},maxSelections:function(){return f.maxSelections&&H.get.selectionCount()>=f.maxSelections},allResultsFiltered:function(){var e=O.not(b.addition);return e.filter(b.unselectable).length===e.length},userSuggestion:function(){return 0<R.children(b.addition).length},query:function(){return""!==H.get.query()},value:function(e){return f.ignoreCase?H.has.valueIgnoringCase(e):H.has.valueMatchingCase(e)},valueMatchingCase:function(e){var t=H.get.values();return!!(Array.isArray(t)?t&&-1!==_.inArray(e,t):t==e)},valueIgnoringCase:function(n){var e=H.get.values(),i=!1;return Array.isArray(e)||(e=[e]),_.each(e,function(e,t){if(String(n).toLowerCase()==String(t).toLowerCase())return!(i=!0)}),i}},is:{active:function(){return y.hasClass(h.active)},animatingInward:function(){return R.transition("is inward")},animatingOutward:function(){return R.transition("is outward")},bubbledLabelClick:function(e){return _(e.target).is("select, input")&&0<y.closest("label").length},bubbledIconClick:function(e){return 0<_(e.target).closest(D).length},alreadySetup:function(){return y.is("select")&&y.parent(b.dropdown).data(x)!==ne&&0===y.prev().length},animating:function(e){return e?e.transition&&e.transition("is animating"):R.transition&&R.transition("is animating")},leftward:function(e){return(e||R).hasClass(h.leftward)},clearable:function(){return y.hasClass(h.clearable)||f.clearable},disabled:function(){return y.hasClass(h.disabled)},focused:function(){return te.activeElement===y[0]},focusedOnSearch:function(){return te.activeElement===T[0]},allFiltered:function(){return(H.is.multiple()||H.has.search())&&!(0==f.hideAdditions&&H.has.userSuggestion())&&!H.has.message()&&H.has.allResultsFiltered()},hidden:function(e){return!H.is.visible(e)},initialLoad:function(){return e},inObject:function(n,e){var i=!1;return _.each(e,function(e,t){if(t==n)return i=!0}),i},multiple:function(){return y.hasClass(h.multiple)},remote:function(){return f.apiSettings&&H.can.useAPI()},single:function(){return!H.is.multiple()},selectMutation:function(e){var n=!1;return _.each(e,function(e,t){if(_(t.target).is("select")||_(t.addedNodes).is("select"))return!(n=!0)}),n},search:function(){return y.hasClass(h.search)},searchSelection:function(){return H.has.search()&&1===T.parent(b.dropdown).length},selection:function(){return y.hasClass(h.selection)},userValue:function(e){return-1!==_.inArray(e,H.get.userValues())},upward:function(e){return(e||y).hasClass(h.upward)},visible:function(e){return e?e.hasClass(h.visible):R.hasClass(h.visible)},verticallyScrollableContext:function(){var e=S.get(0)!==ee&&S.css("overflow-y");return"auto"==e||"scroll"==e},horizontallyScrollableContext:function(){var e=S.get(0)!==ee&&S.css("overflow-X");return"auto"==e||"scroll"==e}},can:{activate:function(e){return!!f.useLabels||(!H.has.maxSelections()||!(!H.has.maxSelections()||!e.hasClass(h.active)))},openDownward:function(e){var t,n,i=e||R,a=!0;return i.addClass(h.loading),n={context:{offset:S.get(0)===ee?{top:0,left:0}:S.offset(),scrollTop:S.scrollTop(),height:S.outerHeight()},menu:{offset:i.offset(),height:i.outerHeight()}},H.is.verticallyScrollableContext()&&(n.menu.offset.top+=n.context.scrollTop),a=(t={above:n.context.scrollTop<=n.menu.offset.top-n.context.offset.top-n.menu.height,below:n.context.scrollTop+n.context.height>=n.menu.offset.top-n.context.offset.top+n.menu.height}).below?(H.verbose("Dropdown can fit in context downward",t),!0):t.below||t.above?(H.verbose("Dropdown cannot fit below, opening upward",t),!1):(H.verbose("Dropdown cannot fit in either direction, favoring downward",t),!0),i.removeClass(h.loading),a},openRightward:function(e){var t,n,i=e||R,a=!0;return i.addClass(h.loading),n={context:{offset:S.get(0)===ee?{top:0,left:0}:S.offset(),scrollLeft:S.scrollLeft(),width:S.outerWidth()},menu:{offset:i.offset(),width:i.outerWidth()}},H.is.horizontallyScrollableContext()&&(n.menu.offset.left+=n.context.scrollLeft),(t=n.menu.offset.left-n.context.offset.left+n.menu.width>=n.context.scrollLeft+n.context.width)&&(H.verbose("Dropdown cannot fit in context rightward",t),a=!1),i.removeClass(h.loading),a},click:function(){return Q||"click"==f.on},extendSelect:function(){return f.allowAdditions||f.apiSettings},show:function(){return!H.is.disabled()&&(H.has.items()||H.has.message())},useAPI:function(){return _.fn.api!==ne}},animate:{show:function(e,t){var n,i=t||R,a=t?function(){}:function(){H.hideSubMenus(),H.hideOthers(),H.set.active()};e=_.isFunction(e)?e:function(){},H.verbose("Doing menu show animation",i),H.set.direction(t),n=H.get.transition(t),H.is.selection()&&H.set.scrollPosition(H.get.selectedItem(),!0),(H.is.hidden(i)||H.is.animating(i))&&("none"==n?(a(),i.transition("show"),e.call(P)):_.fn.transition!==ne&&y.transition("is supported")?i.transition({animation:n+" in",debug:f.debug,verbose:f.verbose,duration:f.duration,queue:!0,onStart:a,onComplete:function(){e.call(P)}}):H.error(m.noTransition,n))},hide:function(e,t){var n=t||R,i=t?function(){}:function(){H.can.click()&&H.unbind.intent(),H.remove.active()},a=H.get.transition(t);e=_.isFunction(e)?e:function(){},(H.is.visible(n)||H.is.animating(n))&&(H.verbose("Doing menu hide animation",n),"none"==a?(i(),n.transition("hide"),e.call(P)):_.fn.transition!==ne&&y.transition("is supported")?n.transition({animation:a+" out",duration:f.duration,debug:f.debug,verbose:f.verbose,queue:!1,onStart:i,onComplete:function(){e.call(P)}}):H.error(m.transition))}},hideAndClear:function(){H.remove.searchTerm(),H.has.maxSelections()||(H.has.search()?H.hide(function(){H.remove.filteredItem()}):H.hide())},delay:{show:function(){H.verbose("Delaying show event to ensure user intent"),clearTimeout(H.timer),H.timer=setTimeout(H.show,f.delay.show)},hide:function(){H.verbose("Delaying hide event to ensure user intent"),clearTimeout(H.timer),H.timer=setTimeout(H.hide,f.delay.hide)}},escape:{value:function(e){var t=Array.isArray(e),n="string"==typeof e,i=!n&&!t,a=n&&-1!==e.search(v.quote),o=[];return i||!a?e:(H.debug("Encoding quote values for use in select",e),t?(_.each(e,function(e,t){o.push(t.replace(v.quote,"&quot;"))}),o):e.replace(v.quote,"&quot;"))},string:function(e){return(e=String(e)).replace(v.escape,"\\$&")},htmlEntities:function(e){var t={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return/[&<>"'`]/.test(e)?(e=e.replace(/&(?![a-z0-9#]{1,6};)/,"&amp;")).replace(/[<>"'`]/g,function(e){return t[e]}):e}},setting:function(e,t){if(H.debug("Changing setting",e,t),_.isPlainObject(e))_.extend(!0,f,e);else{if(t===ne)return f[e];_.isPlainObject(f[e])?_.extend(!0,f[e],t):f[e]=t}},internal:function(e,t){if(_.isPlainObject(e))_.extend(!0,H,e);else{if(t===ne)return H[e];H[e]=t}},debug:function(){!f.silent&&f.debug&&(f.performance?H.performance.log(arguments):(H.debug=Function.prototype.bind.call(console.info,console,f.name+":"),H.debug.apply(console,arguments)))},verbose:function(){!f.silent&&f.verbose&&f.debug&&(f.performance?H.performance.log(arguments):(H.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),H.verbose.apply(console,arguments)))},error:function(){f.silent||(H.error=Function.prototype.bind.call(console.error,console,f.name+":"),H.error.apply(console,arguments))},performance:{log:function(e){var t,n;f.performance&&(n=(t=(new Date).getTime())-($||t),$=t,X.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:P,"Execution Time":n})),clearTimeout(H.performance.timer),H.performance.timer=setTimeout(H.performance.display,500)},display:function(){var e=f.name+":",n=0;$=!1,clearTimeout(H.performance.timer),_.each(X,function(e,t){n+=t["Execution Time"]}),e+=" "+n+"ms",W&&(e+=" '"+W+"'"),(console.group!==ne||console.table!==ne)&&0<X.length&&(console.groupCollapsed(e),console.table?console.table(X):_.each(X,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),X=[]}},invoke:function(i,e,t){var a,o,n,s=N;return e=e||Z,t=P||t,"string"==typeof i&&s!==ne&&(i=i.split(/[\. ]/),a=i.length-1,_.each(i,function(e,t){var n=e!=a?t+i[e+1].charAt(0).toUpperCase()+i[e+1].slice(1):i;if(_.isPlainObject(s[n])&&e!=a)s=s[n];else{if(s[n]!==ne)return o=s[n],!1;if(!_.isPlainObject(s[t])||e==a)return s[t]!==ne?o=s[t]:H.error(m.method,i),!1;s=s[t]}})),_.isFunction(o)?n=o.apply(t,e):o!==ne&&(n=o),Array.isArray(U)?U.push(n):U!==ne?U=[U,n]:n!==ne&&(U=n),o}};J?(N===ne&&H.initialize(),H.invoke(G)):(N!==ne&&N.invoke("destroy"),H.initialize())}),U!==ne?U:B},_.fn.dropdown.settings={silent:!1,debug:!1,verbose:!1,performance:!0,on:"click",action:"activate",values:!1,clearable:!1,apiSettings:!1,selectOnKeydown:!0,minCharacters:0,filterRemoteData:!1,saveRemoteData:!0,throttle:200,context:ee,direction:"auto",keepOnScreen:!0,match:"both",fullTextSearch:!1,ignoreDiacritics:!1,hideDividers:!1,placeholder:"auto",preserveHTML:!0,sortSelect:!1,forceSelection:!0,allowAdditions:!1,ignoreCase:!1,ignoreSearchCase:!0,hideAdditions:!0,maxSelections:!1,useLabels:!0,delimiter:",",showOnFocus:!0,allowReselection:!1,allowTab:!0,allowCategorySelection:!1,fireOnInit:!1,transition:"auto",duration:200,glyphWidth:1.037,headerDivider:!0,label:{transition:"scale",duration:200,variation:!1},delay:{hide:300,show:200,search:20,touch:50},onChange:function(e,t,n){},onAdd:function(e,t,n){},onRemove:function(e,t,n){},onLabelSelect:function(e){},onLabelCreate:function(e,t){return _(this)},onLabelRemove:function(e){return!0},onNoResults:function(e){return!0},onShow:function(){},onHide:function(){},name:"Dropdown",namespace:"dropdown",message:{addResult:"Add <b>{term}</b>",count:"{count} selected",maxSelections:"Max {maxCount} selections",noResults:"No results found.",serverError:"There was an error contacting the server"},error:{action:"You called a dropdown action that was not defined",alreadySetup:"Once a select has been initialized behaviors must be called on the created ui dropdown",labels:"Allowing user additions currently requires the use of labels.",missingMultiple:"<select> requires multiple property to be set to correctly preserve multiple values",method:"The method you called is not defined.",noAPI:"The API module is required to load resources remotely",noStorage:"Saving remote data requires session storage",noTransition:"This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>",noNormalize:'"ignoreDiacritics" setting will be ignored. Browser does not support String().normalize(). You may consider including <https://cdn.jsdelivr.net/npm/[email protected]/lib/unorm.min.js> as a polyfill.'},regExp:{escape:/[-[\]{}()*+?.,\\^$|#\s:=@]/g,quote:/"/g},metadata:{defaultText:"defaultText",defaultValue:"defaultValue",placeholderText:"placeholder",text:"text",value:"value"},fields:{remoteValues:"results",values:"values",disabled:"disabled",name:"name",value:"value",text:"text",type:"type",image:"image",imageClass:"imageClass",icon:"icon",iconClass:"iconClass",class:"class",divider:"divider"},keys:{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,pageUp:33,pageDown:34,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40},selector:{addition:".addition",divider:".divider, .header",dropdown:".ui.dropdown",hidden:".hidden",icon:"> .dropdown.icon",input:'> input[type="hidden"], > select',item:".item",label:"> .label",remove:"> .label > .delete.icon",siblingLabel:".label",menu:".menu",message:".message",menuIcon:".dropdown.icon",search:"input.search, .menu > .search > input, .menu input.search",sizer:"> input.sizer",text:"> .text:not(.icon)",unselectable:".disabled, .filtered",clearIcon:"> .remove.icon"},className:{active:"active",addition:"addition",animating:"animating",disabled:"disabled",empty:"empty",dropdown:"ui dropdown",filtered:"filtered",hidden:"hidden transition",icon:"icon",image:"image",item:"item",label:"ui label",loading:"loading",menu:"menu",message:"message",multiple:"multiple",placeholder:"default",sizer:"sizer",search:"search",selected:"selected",selection:"selection",upward:"upward",leftward:"left",visible:"visible",clearable:"clearable",noselection:"noselection",delete:"delete",header:"header",divider:"divider",groupIcon:"",unfilterable:"unfilterable"}},_.fn.dropdown.settings.templates={deQuote:function(e){return String(e).replace(/"/g,"")},escape:function(e,t){if(t)return e;var n={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return/[&<>"'`]/.test(e)?(e=e.replace(/&(?![a-z0-9#]{1,6};)/,"&amp;")).replace(/[<>"'`]/g,function(e){return n[e]}):e},dropdown:function(e,t,n,i){var a=e.placeholder||!1,o="",s=_.fn.dropdown.settings.templates.escape;return o+='<i class="dropdown icon"></i>',o+=a?'<div class="default text">'+s(a,n)+"</div>":'<div class="text"></div>',o+='<div class="'+i.menu+'">',o+=_.fn.dropdown.settings.templates.menu(e,t,n,i),o+="</div>"},menu:function(e,r,l,c){var t=e[r.values]||[],u="",d=_.fn.dropdown.settings.templates.escape,v=_.fn.dropdown.settings.templates.deQuote;return _.each(t,function(e,t){var n,i,a,o,s=t[r.type]?t[r.type]:"item";"item"===s?(n=t[r.text]?' data-text="'+v(t[r.text])+'"':"",i=t[r.disabled]?c.disabled+" ":"",u+='<div class="'+i+(t[r.class]?v(t[r.class]):c.item)+'" data-value="'+v(t[r.value])+'"'+n+">",t[r.image]&&(u+='<img class="'+(t[r.imageClass]?v(t[r.imageClass]):c.image)+'" src="'+v(t[r.image])+'">'),t[r.icon]&&(u+='<i class="'+v(t[r.icon])+" "+(t[r.iconClass]?v(t[r.iconClass]):c.icon)+'"></i>'),u+=d(t[r.name]||"",l),u+="</div>"):"header"===s&&(a=d(t[r.name]||"",l),o=t[r.icon]?v(t[r.icon]):c.groupIcon,""===a&&""===o||(u+='<div class="'+(t[r.class]?v(t[r.class]):c.header)+'">',""!==o&&(u+='<i class="'+o+" "+(t[r.iconClass]?v(t[r.iconClass]):c.icon)+'"></i>'),u+=a,u+="</div>"),t[r.divider]&&(u+='<div class="'+c.divider+'"></div>'))}),u},label:function(e,t,n,i){return(0,_.fn.dropdown.settings.templates.escape)(t,n)+'<i class="'+i.delete+' icon"></i>'},message:function(e){return e},addition:function(e){return e}}}(jQuery,window,document);