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