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