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