/*! * # Semantic UI 2.2.0 - Dropdown * http://github.com/semantic-org/semantic-ui/ * * * Copyright 2015 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT * */ !function(e,t,n,i){"use strict";t="undefined"!=typeof t&&t.Math==Math?t:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),e.fn.dropdown=function(a){var o,s=e(this),r=e(n),l=s.selector||"",c="ontouchstart"in n.documentElement,u=(new Date).getTime(),d=[],v=arguments[0],m="string"==typeof v,f=[].slice.call(arguments,1);return s.each(function(h){var g,p,b,w,x,y,C,S,A=e.isPlainObject(a)?e.extend(!0,{},e.fn.dropdown.settings,a):e.extend({},e.fn.dropdown.settings),T=A.className,k=A.message,L=A.fields,D=A.keys,I=A.metadata,q=A.namespace,R=A.regExp,V=A.selector,E=A.error,O=A.templates,F="."+q,M="module-"+q,P=e(this),H=e(A.context),j=P.find(V.text),z=P.find(V.search),U=P.find(V.input),N=P.find(V.icon),W=P.prev().find(V.text).length>0?P.prev().find(V.text):P.prev(),B=P.children(V.menu),K=B.find(V.item),Q=!1,$=!1,Y=!1,G=this,J=P.data(M);S={initialize:function(){S.debug("Initializing dropdown",A),S.is.alreadySetup()?S.setup.reference():(S.setup.layout(),S.refreshData(),S.save.defaults(),S.restore.selected(),S.create.id(),S.bind.events(),S.observeChanges(),S.instantiate())},instantiate:function(){S.verbose("Storing instance of dropdown",S),J=S,P.data(M,S)},destroy:function(){S.verbose("Destroying previous dropdown",P),S.remove.tabbable(),P.off(F).removeData(M),B.off(F),r.off(w),y&&y.disconnect(),C&&C.disconnect()},observeChanges:function(){"MutationObserver"in t&&(y=new MutationObserver(function(e){S.debug("").addClass(T.search).prop("autocomplete","off").insertBefore(j)),A.allowTab&&S.set.tabbable()},select:function(){var t=S.get.selectValues();S.debug("Dropdown initialized on a select",t),P.is("select")&&(U=P),U.parent(V.dropdown).length>0?(S.debug("UI dropdown already exists. Creating dropdown menu only"),P=U.closest(V.dropdown),S.has.menu()||S.create.menu(),B=P.children(V.menu),S.setup.menu(t)):(S.debug("Creating entire dropdown from select"),P=e("
").attr("class",U.attr("class")).addClass(T.selection).addClass(T.dropdown).html(O.dropdown(t)).insertBefore(U),U.hasClass(T.multiple)&&U.prop("multiple")===!1&&(S.error(E.missingMultiple),U.prop("multiple",!0)),U.is("[multiple]")&&S.set.multiple(),U.prop("disabled")&&(S.debug("Disabling dropdown"),P.addClass(T.disabled)),U.removeAttr("class").detach().prependTo(P)),S.refresh()},menu:function(e){B.html(O.menu(e,L)),K=B.find(V.item)},reference:function(){S.debug("Dropdown behavior was called on select, replacing with closest dropdown"),P=P.parent(V.dropdown),S.refresh(),S.setup.returnedObject(),m&&(J=S,S.invoke(v))},returnedObject:function(){var e=s.slice(0,h),t=s.slice(h+1);s=e.add(P).add(t)}},refresh:function(){S.refreshSelectors(),S.refreshData()},refreshSelectors:function(){S.verbose("Refreshing selector cache"),j=P.find(V.text),z=P.find(V.search),U=P.find(V.input),N=P.find(V.icon),W=P.prev().find(V.text).length>0?P.prev().find(V.text):P.prev(),B=P.children(V.menu),K=B.find(V.item)},refreshData:function(){S.verbose("Refreshing cached metadata"),K.removeData(I.text).removeData(I.value)},clearData:function(){S.verbose("Clearing metadata"),K.removeData(I.text).removeData(I.value),P.removeData(I.defaultText).removeData(I.defaultValue).removeData(I.placeholderText)},toggle:function(){S.verbose("Toggling menu visibility"),S.is.active()?S.hide():S.show()},show:function(t){if(t=e.isFunction(t)?t:function(){},S.can.show()&&!S.is.active()){if(S.debug("Showing dropdown"),!S.has.message()||S.has.maxSelections()||S.has.allResultsFiltered()||S.remove.message(),S.is.allFiltered())return!0;A.onShow.call(G)!==!1&&S.animate.show(function(){S.can.click()&&S.bind.intent(),S.set.visible(),t.call(G)})}},hide:function(t){t=e.isFunction(t)?t:function(){},S.is.active()&&(S.debug("Hiding dropdown"),A.onHide.call(G)!==!1&&S.animate.hide(function(){S.remove.visible(),t.call(G)}))},hideOthers:function(){S.verbose("Finding other dropdowns to hide"),s.not(P).has(V.menu+"."+T.visible).dropdown("hide")},hideMenu:function(){S.verbose("Hiding menu instantaneously"),S.remove.active(),S.remove.visible(),B.transition("hide")},hideSubMenus:function(){var e=B.children(V.item).find(V.menu);S.verbose("Hiding sub menus",e),e.transition("hide")},bind:{events:function(){c&&S.bind.touchEvents(),S.bind.keyboardEvents(),S.bind.inputEvents(),S.bind.mouseEvents()},touchEvents:function(){S.debug("Touch device detected binding additional touch events"),S.is.searchSelection()||S.is.single()&&P.on("touchstart"+F,S.event.test.toggle),B.on("touchstart"+F,V.item,S.event.item.mouseenter)},keyboardEvents:function(){S.verbose("Binding keyboard events"),P.on("keydown"+F,S.event.keydown),S.has.search()&&P.on(S.get.inputEvent()+F,V.search,S.event.input),S.is.multiple()&&r.on("keydown"+w,S.event.document.keydown)},inputEvents:function(){S.verbose("Binding input change events"),P.on("change"+F,V.input,S.event.change)},mouseEvents:function(){S.verbose("Binding mouse events"),S.is.multiple()&&P.on("click"+F,V.label,S.event.label.click).on("click"+F,V.remove,S.event.remove.click),S.is.searchSelection()?(P.on("mousedown"+F,S.event.mousedown).on("mouseup"+F,S.event.mouseup).on("mousedown"+F,V.menu,S.event.menu.mousedown).on("mouseup"+F,V.menu,S.event.menu.mouseup).on("click"+F,V.icon,S.event.icon.click).on("focus"+F,V.search,S.event.search.focus).on("click"+F,V.search,S.event.search.focus).on("blur"+F,V.search,S.event.search.blur).on("click"+F,V.text,S.event.text.focus),S.is.multiple()&&P.on("click"+F,S.event.click)):("click"==A.on?P.on("click"+F,V.icon,S.event.icon.click).on("click"+F,S.event.test.toggle):"hover"==A.on?P.on("mouseenter"+F,S.delay.show).on("mouseleave"+F,S.delay.hide):P.on(A.on+F,S.toggle),P.on("mousedown"+F,S.event.mousedown).on("mouseup"+F,S.event.mouseup).on("focus"+F,S.event.focus).on("blur"+F,S.event.blur)),B.on("mouseenter"+F,V.item,S.event.item.mouseenter).on("mouseleave"+F,V.item,S.event.item.mouseleave).on("click"+F,V.item,S.event.item.click)},intent:function(){S.verbose("Binding hide intent event to document"),c&&r.on("touchstart"+w,S.event.test.touch).on("touchmove"+w,S.event.test.touch),r.on("click"+w,S.event.test.hide)}},unbind:{intent:function(){S.verbose("Removing hide intent event from document"),c&&r.off("touchstart"+w).off("touchmove"+w),r.off("click"+w)}},filter:function(e){var t=e!==i?e:S.get.query(),n=function(){S.is.multiple()&&S.filterActive(),S.select.firstUnfiltered(),S.has.allResultsFiltered()?A.onNoResults.call(G,t)?A.allowAdditions?A.hideAdditions&&(S.verbose("User addition with no menu, setting empty style"),S.set.empty(),S.hideMenu()):(S.verbose("All items filtered, showing message",t),S.add.message(k.noResults)):(S.verbose("All items filtered, hiding dropdown",t),S.hideMenu()):(S.remove.empty(),S.remove.message()),A.allowAdditions&&S.add.userSuggestion(e),S.is.searchSelection()&&S.can.show()&&S.is.focusedOnSearch()&&S.show()};A.useLabels&&S.has.maxSelections()||(A.apiSettings?S.can.useAPI()?S.queryRemote(t,function(){n()}):S.error(E.noAPI):(S.filterItems(t),n()))},queryRemote:function(t,n){var i={errorDuration:!1,cache:"local",throttle:A.throttle,urlData:{query:t},onError:function(){S.add.message(k.serverError),n()},onFailure:function(){S.add.message(k.serverError),n()},onSuccess:function(e){S.remove.message(),S.setup.menu({values:e[L.remoteValues]}),n()}};P.api("get request")||S.setup.api(),i=e.extend(!0,{},i,A.apiSettings),P.api("setting",i).api("query")},filterItems:function(t){var n=t!==i?t:S.get.query(),a=null,o=S.escape.regExp(n),s=new RegExp("^"+o,"igm");S.has.query()&&(a=[],S.verbose("Searching for matching values",n),K.each(function(){var t,i,o=e(this);if("both"==A.match||"text"==A.match){if(t=String(S.get.choiceText(o,!1)),-1!==t.search(s))return a.push(this),!0;if(A.fullTextSearch&&S.fuzzySearch(n,t))return a.push(this),!0}if("both"==A.match||"value"==A.match){if(i=String(S.get.choiceValue(o,t)),-1!==i.search(s))return a.push(this),!0;if(A.fullTextSearch&&S.fuzzySearch(n,i))return a.push(this),!0}})),S.debug("Showing only matched items",n),S.remove.filteredItem(),a&&K.not(a).addClass(T.filtered)},fuzzySearch:function(e,t){var n=t.length,i=e.length;if(e=e.toLowerCase(),t=t.toLowerCase(),i>n)return!1;if(i===n)return e===t;e:for(var a=0,o=0;i>a;a++){for(var s=e.charCodeAt(a);n>o;)if(t.charCodeAt(o++)===s)continue e;return!1}return!0},filterActive:function(){A.useLabels&&K.filter("."+T.active).addClass(T.filtered)},focusSearch:function(e){S.is.search()&&!S.is.focusedOnSearch()&&(e?(P.off("focus"+F,V.search),z.focus(),P.on("focus"+F,V.search,S.event.search.focus)):z.focus())},forceSelection:function(){var e=K.not(T.filtered).filter("."+T.selected).eq(0),t=K.not(T.filtered).filter("."+T.active).eq(0),n=e.length>0?e:t,i=n.size()>0;if(S.has.query()){if(i)return S.debug("Forcing partial selection to selected item",n),void S.event.item.click.call(n,{},!0);A.allowAdditions?(S.set.selected(S.get.query()),S.remove.searchTerm()):S.remove.searchTerm()}S.hide()},event:{change:function(){Y||(S.debug("Input changed, updating selection"),S.set.selected())},focus:function(){A.showOnFocus&&!Q&&S.is.hidden()&&!p&&S.show()},click:function(t){var n=e(t.target);n.is(P)&&(S.is.focusedOnSearch()?S.show():S.focusSearch())},blur:function(e){p=n.activeElement===this,Q||p||(S.remove.activeLabel(),S.hide())},mousedown:function(){S.is.searchSelection()?b=!0:Q=!0},mouseup:function(){S.is.searchSelection()?b=!1:Q=!1},search:{focus:function(){Q=!0,S.is.multiple()&&S.remove.activeLabel(),A.showOnFocus&&S.search()},blur:function(e){p=n.activeElement===this,b||($||p?p&&A.forceSelection&&S.forceSelection():A.forceSelection?S.forceSelection():S.hide()),b=!1}},icon:{click:function(e){S.toggle(),e.stopPropagation()}},text:{focus:function(e){Q=!0,S.focusSearch()}},input:function(e){(S.is.multiple()||S.is.searchSelection())&&S.set.filtered(),clearTimeout(S.timer),S.timer=setTimeout(S.search,A.delay.search)},label:{click:function(t){var n=e(this),i=P.find(V.label),a=i.filter("."+T.active),o=n.nextAll("."+T.active),s=n.prevAll("."+T.active),r=o.length>0?n.nextUntil(o).add(a).add(n):n.prevUntil(s).add(a).add(n);t.shiftKey?(a.removeClass(T.active),r.addClass(T.active)):t.ctrlKey?n.toggleClass(T.active):(a.removeClass(T.active),n.addClass(T.active)),A.onLabelSelect.apply(this,i.filter("."+T.active))}},remove:{click:function(){var t=e(this).parent();t.hasClass(T.active)?S.remove.activeLabels():S.remove.activeLabels(t)}},test:{toggle:function(e){var t=S.is.multiple()?S.show:S.toggle;S.determine.eventOnElement(e,t)&&e.preventDefault()},touch:function(e){S.determine.eventOnElement(e,function(){"touchstart"==e.type?S.timer=setTimeout(function(){S.hide()},A.delay.touch):"touchmove"==e.type&&clearTimeout(S.timer)}),e.stopPropagation()},hide:function(e){S.determine.eventInModule(e,S.hide)}},menu:{mousedown:function(){$=!0},mouseup:function(){$=!1}},item:{mouseenter:function(t){var n=e(t.target),i=e(this),a=i.children(V.menu),o=i.siblings(V.item).children(V.menu),s=a.length>0,r=a.find(n).length>0;!r&&s&&(clearTimeout(S.itemTimer),S.itemTimer=setTimeout(function(){S.verbose("Showing sub-menu",a),e.each(o,function(){S.animate.hide(!1,e(this))}),S.animate.show(!1,a)},A.delay.show),t.preventDefault())},mouseleave:function(t){var n=e(this).children(V.menu);n.length>0&&(clearTimeout(S.itemTimer),S.itemTimer=setTimeout(function(){S.verbose("Hiding sub-menu",n),S.animate.hide(!1,n)},A.delay.hide))},click:function(t,n){var i=e(this),a=e(t?t.target:""),o=i.find(V.menu),s=S.get.choiceText(i),r=S.get.choiceValue(i,s),l=o.length>0,c=o.find(a).length>0;c||l&&!A.allowCategorySelection||(S.is.searchSelection()&&(A.allowAdditions&&S.remove.userAddition(),S.remove.searchTerm(),S.is.focusedOnSearch()||1==n||S.focusSearch(!0)),A.useLabels||(S.remove.filteredItem(),S.set.scrollPosition(i)),S.determine.selectAction.call(this,s,r))}},document:{keydown:function(e){var t=e.which,n=S.is.inObject(t,D);if(n){var i=P.find(V.label),a=i.filter("."+T.active),o=(a.data(I.value),i.index(a)),s=i.length,r=a.length>0,l=a.length>1,c=0===o,u=o+1==s,d=S.is.searchSelection(),v=S.is.focusedOnSearch(),m=S.is.focused(),f=v&&0===S.get.caretPosition();if(d&&!r&&!v)return;t==D.leftArrow?!m&&!f||r?r&&(e.shiftKey?S.verbose("Adding previous label to selection"):(S.verbose("Selecting previous label"),i.removeClass(T.active)),c&&!l?a.addClass(T.active):a.prev(V.siblingLabel).addClass(T.active).end(),e.preventDefault()):(S.verbose("Selecting previous label"),i.last().addClass(T.active)):t==D.rightArrow?(m&&!r&&i.first().addClass(T.active),r&&(e.shiftKey?S.verbose("Adding next label to selection"):(S.verbose("Selecting next label"),i.removeClass(T.active)),u?d?v?i.removeClass(T.active):S.focusSearch():l?a.next(V.siblingLabel).addClass(T.active):a.addClass(T.active):a.next(V.siblingLabel).addClass(T.active),e.preventDefault())):t==D.deleteKey||t==D.backspace?r?(S.verbose("Removing active labels"),u&&d&&!v&&S.focusSearch(),a.last().next(V.siblingLabel).addClass(T.active),S.remove.activeLabels(a),e.preventDefault()):f&&!r&&t==D.backspace&&(S.verbose("Removing last label on input backspace"),a=i.last().addClass(T.active),S.remove.activeLabels(a)):a.removeClass(T.active)}}},keydown:function(e){var t=e.which,n=S.is.inObject(t,D);if(n){var i,a,o=K.not(V.unselectable).filter("."+T.selected).eq(0),s=B.children("."+T.active).eq(0),r=o.length>0?o:s,l=r.length>0?r.siblings(":not(."+T.filtered+")").andSelf():B.children(":not(."+T.filtered+")"),c=r.children(V.menu),u=r.closest(V.menu),d=u.hasClass(T.visible)||u.hasClass(T.animating)||u.parent(V.menu).length>0,v=c.length>0,m=r.length>0,f=r.not(V.unselectable).length>0,h=t==D.delimiter&&A.allowAdditions&&S.is.multiple();if(S.is.visible()||A.allowAdditions){if((t==D.enter||h)&&(t==D.enter&&m&&v&&!A.allowCategorySelection?(S.verbose("Pressed enter on unselectable category, opening sub menu"),t=D.rightArrow):f&&(S.verbose("Selecting item from keyboard shortcut",r),S.event.item.click.call(r,e),S.is.searchSelection()&&S.remove.searchTerm()),e.preventDefault()),m&&(t==D.leftArrow&&(a=u[0]!==B[0],a&&(S.verbose("Left key pressed, closing sub-menu"),S.animate.hide(!1,u),r.removeClass(T.selected),u.closest(V.item).addClass(T.selected),e.preventDefault())),t==D.rightArrow&&v&&(S.verbose("Right key pressed, opening sub-menu"),S.animate.show(!1,c),r.removeClass(T.selected),c.find(V.item).eq(0).addClass(T.selected),e.preventDefault())),t==D.upArrow){if(i=m&&d?r.prevAll(V.item+":not("+V.unselectable+")").eq(0):K.eq(0),l.index(i)<0)return S.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();S.verbose("Up key pressed, changing active item"),r.removeClass(T.selected),i.addClass(T.selected),S.set.scrollPosition(i),e.preventDefault()}if(t==D.downArrow){if(i=m&&d?i=r.nextAll(V.item+":not("+V.unselectable+")").eq(0):K.eq(0),0===i.length)return S.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();S.verbose("Down key pressed, changing active item"),K.removeClass(T.selected),i.addClass(T.selected),S.set.scrollPosition(i),e.preventDefault()}t==D.pageUp&&(S.scrollPage("up"),e.preventDefault()),t==D.pageDown&&(S.scrollPage("down"),e.preventDefault()),t==D.escape&&(S.verbose("Escape key pressed, closing dropdown"),S.hide())}else h&&e.preventDefault(),t==D.downArrow&&(S.verbose("Down key pressed, showing dropdown"),S.show(),e.preventDefault())}else S.is.search()||S.set.selectedLetter(String.fromCharCode(t))}},trigger:{change:function(){var e=n.createEvent("HTMLEvents"),t=U[0];t&&(S.verbose("Triggering native change event"),e.initEvent("change",!0,!1),t.dispatchEvent(e))}},determine:{selectAction:function(t,n){S.verbose("Determining action",A.action),e.isFunction(S.action[A.action])?(S.verbose("Triggering preset action",A.action,t,n),S.action[A.action].call(this,t,n)):e.isFunction(A.action)?(S.verbose("Triggering user action",A.action,t,n),A.action.call(this,t,n)):S.error(E.action,A.action)},eventInModule:function(t,i){var a=e(t.target),o=a.closest(n.documentElement).length>0,s=a.closest(P).length>0;return i=e.isFunction(i)?i:function(){},o&&!s?(S.verbose("Triggering event",i),i(),!0):(S.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(t,i){var a=e(t.target),o=a.closest(V.siblingLabel),s=n.body.contains(t.target),r=0===P.find(o).length,l=0===a.closest(B).length;return i=e.isFunction(i)?i:function(){},s&&r&&l?(S.verbose("Triggering event",i),i(),!0):(S.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(t,n){if(n=n!==i?n:t,S.can.activate(e(this))){if(S.set.selected(n,e(this)),S.is.multiple()&&!S.is.allFiltered())return;S.hideAndClear()}},select:function(e,t){S.action.activate.call(this)},combo:function(t,n){n=n!==i?n:t,S.set.selected(n,e(this)),S.hideAndClear()},hide:function(e,t){S.set.value(t,e),S.hideAndClear()}},get:{id:function(){return x},defaultText:function(){return P.data(I.defaultText)},defaultValue:function(){return P.data(I.defaultValue)},placeholderText:function(){return P.data(I.placeholderText)||""},text:function(){return j.text()},query:function(){return e.trim(z.val())},searchWidth:function(e){return e*A.glyphWidth+"em"},selectionCount:function(){var t,n=S.get.values();return t=S.is.multiple()?e.isArray(n)?n.length:0:""!==S.get.value()?1:0},transition:function(e){return"auto"==A.transition?S.is.upward(e)?"slide up":"slide down":A.transition},userValues:function(){var t=S.get.values();return t?(t=e.isArray(t)?t:[t],e.grep(t,function(e){return S.get.item(e)===!1})):!1},uniqueArray:function(t){return e.grep(t,function(n,i){return e.inArray(n,t)===i})},caretPosition:function(){var e,t,i=z.get(0);return"selectionStart"in i?i.selectionStart:n.selection?(i.focus(),e=n.selection.createRange(),t=e.text.length,e.moveStart("character",-i.value.length),e.text.length-t):void 0},value:function(){var t=U.length>0?U.val():P.data(I.value),n=e.isArray(t)&&1===t.length&&""===t[0];return t===i||n?"":t},values:function(){var e=S.get.value();return""===e?"":!S.has.selectInput()&&S.is.multiple()?"string"==typeof e?e.split(A.delimiter):"":e},remoteValues:function(){var t=S.get.values(),n=!1;return t&&("string"==typeof t&&(t=[t]),e.each(t,function(e,t){var i=S.read.remoteData(t);S.verbose("Restoring value from session data",i,t),i&&(n||(n={}),n[t]=i)})),n},choiceText:function(t,n){return n=n!==i?n:A.preserveHTML,t?(t.find(V.menu).length>0&&(S.verbose("Retreiving text of element with sub-menu"),t=t.clone(),t.find(V.menu).remove(),t.find(V.menuIcon).remove()),t.data(I.text)!==i?t.data(I.text):n?e.trim(t.html()):e.trim(t.text())):void 0},choiceValue:function(t,n){return n=n||S.get.choiceText(t),t?t.data(I.value)!==i?String(t.data(I.value)):"string"==typeof n?e.trim(n.toLowerCase()):String(n):!1},inputEvent:function(){var e=z[0];return e?e.oninput!==i?"input":e.onpropertychange!==i?"propertychange":"keyup":!1},selectValues:function(){var t={};return t.values=[],P.find("option").each(function(){var n=e(this),a=n.html(),o=n.attr("disabled"),s=n.attr("value")!==i?n.attr("value"):a;"auto"===A.placeholder&&""===s?t.placeholder=a:t.values.push({name:a,value:s,disabled:o})}),A.placeholder&&"auto"!==A.placeholder&&(S.debug("Setting placeholder value to",A.placeholder),t.placeholder=A.placeholder),A.sortSelect?(t.values.sort(function(e,t){return e.name>t.name?1:-1}),S.debug("Retrieved and sorted values from select",t)):S.debug("Retreived values from select",t),t},activeItem:function(){return K.filter("."+T.active)},selectedItem:function(){var e=K.not(V.unselectable).filter("."+T.selected);return e.length>0?e:K.eq(0)},itemWithAdditions:function(e){var t=S.get.item(e),n=S.create.userChoice(e),i=n&&n.length>0;return i&&(t=t.length>0?t.add(n):n),t},item:function(t,n){var a,o,s=!1;return t=t!==i?t:S.get.values()!==i?S.get.values():S.get.text(),a=o?t.length>0:t!==i&&null!==t,o=S.is.multiple()&&e.isArray(t),n=""===t||0===t?!0:n||!1,a&&K.each(function(){var a=e(this),r=S.get.choiceText(a),l=S.get.choiceValue(a,r);if(null!==l&&l!==i)if(o)(-1!==e.inArray(String(l),t)||-1!==e.inArray(r,t))&&(s=s?s.add(a):a);else if(n){if(S.verbose("Ambiguous dropdown value using strict type check",a,t),l===t||r===t)return s=a,!0}else if(String(l)==String(t)||r==t)return S.verbose("Found select item by value",l,t),s=a,!0}),s}},check:{maxSelections:function(e){return A.maxSelections?(e=e!==i?e:S.get.selectionCount(),e>=A.maxSelections?(S.debug("Maximum selection count reached"),A.useLabels&&(K.addClass(T.filtered),S.add.message(k.maxSelections)),!0):(S.verbose("No longer at maximum selection count"),S.remove.message(),S.remove.filteredItem(),S.is.searchSelection()&&S.filterItems(),!1)):!0}},restore:{defaults:function(){S.clear(),S.restore.defaultText(),S.restore.defaultValue()},defaultText:function(){var e=S.get.defaultText(),t=S.get.placeholderText;e===t?(S.debug("Restoring default placeholder text",e),S.set.placeholderText(e)):(S.debug("Restoring default text",e),S.set.text(e))},placeholderText:function(){S.set.placeholderText()},defaultValue:function(){var e=S.get.defaultValue();e!==i&&(S.debug("Restoring default value",e),""!==e?(S.set.value(e),S.set.selected()):(S.remove.activeItem(),S.remove.selectedItem()))},labels:function(){A.allowAdditions&&(A.useLabels||(S.error(E.labels),A.useLabels=!0),S.debug("Restoring selected values"),S.create.userLabels()),S.check.maxSelections()},selected:function(){S.restore.values(),S.is.multiple()?(S.debug("Restoring previously selected values and labels"),S.restore.labels()):S.debug("Restoring previously selected values")},values:function(){S.set.initialLoad(),A.apiSettings&&A.saveRemoteData&&S.get.remoteValues()?S.restore.remoteValues():S.set.selected(),S.remove.initialLoad()},remoteValues:function(){var t=S.get.remoteValues();S.debug("Recreating selected from session data",t),t&&(S.is.single()?e.each(t,function(e,t){S.set.text(t)}):e.each(t,function(e,t){S.add.label(e,t)}))}},read:{remoteData:function(e){var n;return t.Storage===i?void S.error(E.noStorage):(n=sessionStorage.getItem(e),n!==i?n:!1)}},save:{defaults:function(){S.save.defaultText(),S.save.placeholderText(),S.save.defaultValue()},defaultValue:function(){var e=S.get.value();S.verbose("Saving default value as",e),P.data(I.defaultValue,e)},defaultText:function(){var e=S.get.text();S.verbose("Saving default text as",e),P.data(I.defaultText,e)},placeholderText:function(){var e;A.placeholder!==!1&&j.hasClass(T.placeholder)&&(e=S.get.text(),S.verbose("Saving placeholder text as",e),P.data(I.placeholderText,e))},remoteData:function(e,n){return t.Storage===i?void S.error(E.noStorage):(S.verbose("Saving remote data to session storage",n,e),void sessionStorage.setItem(n,e))}},clear:function(){S.is.multiple()?S.remove.labels():(S.remove.activeItem(),S.remove.selectedItem()),S.set.placeholderText(),S.clearValue()},clearValue:function(){S.set.value("")},scrollPage:function(e,t){var n,i,a,o=t||S.get.selectedItem(),s=o.closest(V.menu),r=s.outerHeight(),l=s.scrollTop(),c=K.eq(0).outerHeight(),u=Math.floor(r/c),d=(s.prop("scrollHeight"),"up"==e?l-c*u:l+c*u),v=K.not(V.unselectable);a="up"==e?v.index(o)-u:v.index(o)+u,n="up"==e?a>=0:a0&&(S.debug("Scrolling page",e,i),o.removeClass(T.selected),i.addClass(T.selected),s.scrollTop(d))},set:{filtered:function(){var e=S.is.multiple(),t=S.is.searchSelection(),n=e&&t,i=t?S.get.query():"",a="string"==typeof i&&i.length>0,o=S.get.searchWidth(i.length),s=""!==i;e&&a&&(S.verbose("Adjusting input width",o,A.glyphWidth),z.css("width",o)),a||n&&s?(S.verbose("Hiding placeholder text"),j.addClass(T.filtered)):(!e||n&&!s)&&(S.verbose("Showing placeholder text"),j.removeClass(T.filtered))},empty:function(){P.addClass(T.empty)},loading:function(){P.addClass(T.loading)},placeholderText:function(e){e=e||S.get.placeholderText(),S.debug("Setting placeholder text",e),S.set.text(e),j.addClass(T.placeholder)},tabbable:function(){S.has.search()?(S.debug("Added tabindex to searchable dropdown"),z.val("").attr("tabindex",0),B.attr("tabindex",-1)):(S.debug("Added tabindex to dropdown"),P.attr("tabindex")===i&&(P.attr("tabindex",0),B.attr("tabindex",-1)))},initialLoad:function(){S.verbose("Setting initial load"),g=!0},activeItem:function(e){A.allowAdditions&&e.filter(V.addition).length>0?e.addClass(T.filtered):e.addClass(T.active)},scrollPosition:function(e,t){var n,a,o,s,r,l,c,u,d,v=5;e=e||S.get.selectedItem(),n=e.closest(V.menu),a=e&&e.length>0,t=t!==i?t:!1,e&&n.length>0&&a&&(s=e.position().top,n.addClass(T.loading),l=n.scrollTop(),r=n.offset().top,s=e.offset().top,o=l-r+s,t||(c=n.height(),d=o+v>l+c,u=l>o-v),S.debug("Scrolling to active item",o),(t||u||d)&&n.scrollTop(o),n.removeClass(T.loading))},text:function(e){"select"!==A.action&&("combo"==A.action?(S.debug("Changing combo button text",e,W),A.preserveHTML?W.html(e):W.text(e)):(e!==S.get.placeholderText()&&j.removeClass(T.placeholder),S.debug("Changing text",e,j),j.removeClass(T.filtered),A.preserveHTML?j.html(e):j.text(e)))},selectedLetter:function(t){var n,i=K.filter("."+T.selected),a=i.length>0&&S.has.firstLetter(i,t),o=!1;a&&(n=i.nextAll(K).eq(0),S.has.firstLetter(n,t)&&(o=n)),o||K.each(function(){return S.has.firstLetter(e(this),t)?(o=e(this),!1):void 0}),o&&(S.verbose("Scrolling to next value with letter",t),S.set.scrollPosition(o),i.removeClass(T.selected),o.addClass(T.selected))},direction:function(e){"auto"==A.direction?S.is.onScreen(e)?S.remove.upward(e):S.set.upward(e):"upward"==A.direction&&S.set.upward(e)},upward:function(e){var t=e||P;t.addClass(T.upward)},value:function(e,t,n){var a=S.escape.value(e),o=U.length>0,s=(!S.has.value(e),S.get.values()),r=e!==i?String(e):e;if(o){if(r==s&&(S.verbose("Skipping value update already same value",e,s),!S.is.initialLoad()))return;S.is.single()&&S.has.selectInput()&&S.can.extendSelect()&&(S.debug("Adding user option",e),S.add.optionValue(e)),S.debug("Updating input value",a,s),Y=!0,U.val(a),A.fireOnInit===!1&&S.is.initialLoad()?S.debug("Input native change event ignored on initial load"):S.trigger.change(),Y=!1}else S.verbose("Storing value in metadata",a,U),a!==s&&P.data(I.value,r);A.fireOnInit===!1&&S.is.initialLoad()?S.verbose("No callback on initial load",A.onChange):A.onChange.call(G,e,t,n)},active:function(){P.addClass(T.active)},multiple:function(){P.addClass(T.multiple)},visible:function(){P.addClass(T.visible)},exactly:function(e,t){S.debug("Setting selected to exact values"),S.clear(),S.set.selected(e,t)},selected:function(t,n){var i=S.is.multiple();n=A.allowAdditions?n||S.get.itemWithAdditions(t):n||S.get.item(t),n&&(S.debug("Setting selected menu item to",n),S.is.multiple()&&S.remove.searchWidth(),S.is.single()?(S.remove.activeItem(),S.remove.selectedItem()):A.useLabels&&S.remove.selectedItem(),n.each(function(){var t=e(this),a=S.get.choiceText(t),o=S.get.choiceValue(t,a),s=t.hasClass(T.filtered),r=t.hasClass(T.active),l=t.hasClass(T.addition),c=i&&1==n.length;i?!r||l?(A.apiSettings&&A.saveRemoteData&&S.save.remoteData(a,o),A.useLabels?(S.add.value(o,a,t),S.add.label(o,a,c),S.set.activeItem(t),S.filterActive(),S.select.nextAvailable(n)):(S.add.value(o,a,t),S.set.text(S.add.variables(k.count)),S.set.activeItem(t))):s||(S.debug("Selected active value, removing label"),S.remove.selected(o)):(A.apiSettings&&A.saveRemoteData&&S.save.remoteData(a,o),S.set.text(a),S.set.value(o,a,t),t.addClass(T.active).addClass(T.selected))}))}},add:{label:function(t,n,i){var a,o=S.is.searchSelection()?z:j,s=S.escape.value(t);return a=e("").addClass(T.label).attr("data-value",s).html(O.label(s,n)),a=A.onLabelCreate.call(a,s,n),S.has.label(t)?void S.debug("Label already exists, skipping",s):(A.label.variation&&a.addClass(A.label.variation),void(i===!0?(S.debug("Animating in label",a),a.addClass(T.hidden).insertBefore(o).transition(A.label.transition,A.label.duration)):(S.debug("Adding selection label",a),a.insertBefore(o))))},message:function(t){var n=B.children(V.message),i=A.templates.message(S.add.variables(t));n.length>0?n.html(i):n=e("
").html(i).addClass(T.message).appendTo(B)},optionValue:function(t){var n=S.escape.value(t),i=U.find('option[value="'+n+'"]'),a=i.length>0;a||(y&&(y.disconnect(),S.verbose("Temporarily disconnecting mutation observer",n)),S.is.single()&&(S.verbose("Removing previous user addition"),U.find("option."+T.addition).remove()),e("