/*! * # Semantic UI 2.1.3 - 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";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,C,S,y=e.isPlainObject(a)?e.extend(!0,{},e.fn.dropdown.settings,a):e.extend({},e.fn.dropdown.settings),T=y.className,A=y.message,k=y.fields,L=y.metadata,D=y.namespace,I=y.regExp,R=y.selector,q=y.error,V=y.templates,E="."+D,O="module-"+D,F=e(this),P=e(y.context),M=F.find(R.text),z=F.find(R.search),H=F.find(R.input),j=F.find(R.icon),U=F.prev().find(R.text).length>0?F.prev().find(R.text):F.prev(),N=F.children(R.menu),K=N.find(R.item),B=!1,W=!1,$=!1,Q=this,Y=F.data(O);S={initialize:function(){S.debug("Initializing dropdown",y),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),Y=S,F.data(O,S)},destroy:function(){S.verbose("Destroying previous dropdown",F),S.remove.tabbable(),F.off(E).removeData(O),N.off(E),r.off(b),x&&x.disconnect(),C&&C.disconnect()},observeChanges:function(){"MutationObserver"in t&&(x=new MutationObserver(function(e){S.debug("").addClass(T.search).insertBefore(M)),y.allowTab&&S.set.tabbable()},select:function(){var t=S.get.selectValues();S.debug("Dropdown initialized on a select",t),F.is("select")&&(H=F),H.parent(R.dropdown).length>0?(S.debug("UI dropdown already exists. Creating dropdown menu only"),F=H.closest(R.dropdown),S.has.menu()||S.create.menu(),N=F.children(R.menu),S.setup.menu(t)):(S.debug("Creating entire dropdown from select"),F=e("
").attr("class",H.attr("class")).addClass(T.selection).addClass(T.dropdown).html(V.dropdown(t)).insertBefore(H),H.hasClass(T.multiple)&&H.prop("multiple")===!1&&(S.error(q.missingMultiple),H.prop("multiple",!0)),H.is("[multiple]")&&S.set.multiple(),H.removeAttr("class").detach().prependTo(F)),S.refresh()},menu:function(e){N.html(V.menu(e,k)),K=N.find(R.item)},reference:function(){S.debug("Dropdown behavior was called on select, replacing with closest dropdown"),F=F.parent(R.dropdown),S.refresh(),S.setup.returnedObject(),m&&(Y=S,S.invoke(v))},returnedObject:function(){var e=s.slice(0,h),t=s.slice(h+1);s=e.add(F).add(t)}},refresh:function(){S.refreshSelectors(),S.refreshData()},refreshSelectors:function(){S.verbose("Refreshing selector cache"),M=F.find(R.text),z=F.find(R.search),H=F.find(R.input),j=F.find(R.icon),U=F.prev().find(R.text).length>0?F.prev().find(R.text):F.prev(),N=F.children(R.menu),K=N.find(R.item)},refreshData:function(){S.verbose("Refreshing cached metadata"),K.removeData(L.text).removeData(L.value),F.removeData(L.defaultText).removeData(L.defaultValue).removeData(L.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.is.multiple()&&!S.has.search()&&S.is.allFiltered())return!0;S.has.message()&&!S.has.maxSelections()&&S.remove.message(),y.onShow.call(Q)!==!1&&S.animate.show(function(){S.can.click()&&S.bind.intent(),S.set.visible(),t.call(Q)})}},hide:function(t){t=e.isFunction(t)?t:function(){},S.is.active()&&(S.debug("Hiding dropdown"),y.onHide.call(Q)!==!1&&S.animate.hide(function(){S.remove.visible(),t.call(Q)}))},hideOthers:function(){S.verbose("Finding other dropdowns to hide"),s.not(F).has(R.menu+"."+T.visible).dropdown("hide")},hideMenu:function(){S.verbose("Hiding menu instantaneously"),S.remove.active(),S.remove.visible(),N.transition("hide")},hideSubMenus:function(){var e=N.children(R.item).find(R.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()&&F.on("touchstart"+E,S.event.test.toggle),N.on("touchstart"+E,R.item,S.event.item.mouseenter)},keyboardEvents:function(){S.verbose("Binding keyboard events"),F.on("keydown"+E,S.event.keydown),S.has.search()&&F.on(S.get.inputEvent()+E,R.search,S.event.input),S.is.multiple()&&r.on("keydown"+b,S.event.document.keydown)},inputEvents:function(){S.verbose("Binding input change events"),F.on("change"+E,R.input,S.event.change)},mouseEvents:function(){S.verbose("Binding mouse events"),S.is.multiple()&&F.on("click"+E,R.label,S.event.label.click).on("click"+E,R.remove,S.event.remove.click),S.is.searchSelection()?(F.on("mousedown"+E,R.menu,S.event.menu.mousedown).on("mouseup"+E,R.menu,S.event.menu.mouseup).on("click"+E,R.icon,S.event.icon.click).on("click"+E,R.search,S.show).on("focus"+E,R.search,S.event.search.focus).on("blur"+E,R.search,S.event.search.blur).on("click"+E,R.text,S.event.text.focus),S.is.multiple()&&F.on("click"+E,S.event.click)):("click"==y.on?F.on("click"+E,R.icon,S.event.icon.click).on("click"+E,S.event.test.toggle):"hover"==y.on?F.on("mouseenter"+E,S.delay.show).on("mouseleave"+E,S.delay.hide):F.on(y.on+E,S.toggle),F.on("mousedown"+E,S.event.mousedown).on("mouseup"+E,S.event.mouseup).on("focus"+E,S.event.focus).on("blur"+E,S.event.blur)),N.on("mouseenter"+E,R.item,S.event.item.mouseenter).on("mouseleave"+E,R.item,S.event.item.mouseleave).on("click"+E,R.item,S.event.item.click)},intent:function(){S.verbose("Binding hide intent event to document"),c&&r.on("touchstart"+b,S.event.test.touch).on("touchmove"+b,S.event.test.touch),r.on("click"+b,S.event.test.hide)}},unbind:{intent:function(){S.verbose("Removing hide intent event from document"),c&&r.off("touchstart"+b).off("touchmove"+b),r.off("click"+b)}},filter:function(e){var t=e!==i?e:S.get.query(),n=function(){S.is.multiple()&&S.filterActive(),S.select.firstUnfiltered(),S.has.allResultsFiltered()?y.onNoResults.call(Q,t)?y.allowAdditions||(S.verbose("All items filtered, showing message",t),S.add.message(A.noResults)):(S.verbose("All items filtered, hiding dropdown",t),S.hideMenu()):S.remove.message(),y.allowAdditions&&S.add.userSuggestion(e),S.is.searchSelection()&&S.can.show()&&S.is.focusedOnSearch()&&S.show()};y.useLabels&&S.has.maxSelections()||(y.apiSettings?S.can.useAPI()?S.queryRemote(t,function(){n()}):S.error(q.noAPI):(S.filterItems(t),n()))},queryRemote:function(t,n){var i={errorDuration:!1,throttle:y.throttle,urlData:{query:t},onError:function(){S.add.message(A.serverError),n()},onFailure:function(){S.add.message(A.serverError),n()},onSuccess:function(e){S.remove.message(),S.setup.menu({values:e.results}),n()}};F.api("get request")||S.setup.api(),i=e.extend(!0,{},i,y.apiSettings),F.api("setting",i).api("query")},filterItems:function(t){var n=t!==i?t:S.get.query(),a=e(),o=S.escape.regExp(n),s=new RegExp("^"+o,"igm");S.has.query()?(S.verbose("Searching for matching values",n),K.each(function(){var t,i,o=e(this);if("both"==y.match||"text"==y.match){if(t=String(S.get.choiceText(o,!1)),-1!==t.search(s))return a=a.add(o),!0;if(y.fullTextSearch&&S.fuzzySearch(n,t))return a=a.add(o),!0}if("both"==y.match||"value"==y.match){if(i=String(S.get.choiceValue(o,t)),-1!==i.search(s))return a=a.add(o),!0;if(y.fullTextSearch&&S.fuzzySearch(n,i))return a=a.add(o),!0}})):a=K,S.debug("Showing only matched items",n),S.remove.filteredItem(),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(){y.useLabels&&K.filter("."+T.active).addClass(T.filtered)},focusSearch:function(){S.is.search()&&!S.is.focusedOnSearch()&&z[0].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;i&&S.has.query()?(S.debug("Forcing partial selection to selected item",n),S.event.item.click.call(n)):S.hide()},event:{change:function(){$||(S.debug("Input changed, updating selection"),S.set.selected())},focus:function(){y.showOnFocus&&!B&&S.is.hidden()&&!p&&S.show()},click:function(t){var n=e(t.target);n.is(F)&&!S.is.focusedOnSearch()&&S.focusSearch()},blur:function(e){p=n.activeElement===this,B||p||(S.remove.activeLabel(),S.hide())},mousedown:function(){B=!0},mouseup:function(){B=!1},search:{focus:function(){B=!0,S.is.multiple()&&S.remove.activeLabel(),y.showOnFocus&&S.show()},blur:function(e){p=n.activeElement===this,W||p?p&&y.forceSelection&&S.forceSelection():S.is.multiple()?(S.remove.activeLabel(),S.hide()):y.forceSelection?S.forceSelection():S.hide()}},icon:{click:function(e){S.toggle(),e.stopPropagation()}},text:{focus:function(e){B=!0,S.focusSearch()}},input:function(e){(S.is.multiple()||S.is.searchSelection())&&S.set.filtered(),clearTimeout(S.timer),S.timer=setTimeout(S.search,y.delay.search)},label:{click:function(t){var n=e(this),i=F.find(R.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)),y.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()},y.delay.touch):"touchmove"==e.type&&clearTimeout(S.timer)}),e.stopPropagation()},hide:function(e){S.determine.eventInModule(e,S.hide)}},menu:{mousedown:function(){W=!0},mouseup:function(){W=!1}},item:{mouseenter:function(t){var n=e(this).children(R.menu),i=e(this).siblings(R.item).children(R.menu);n.length>0&&(clearTimeout(S.itemTimer),S.itemTimer=setTimeout(function(){S.verbose("Showing sub-menu",n),e.each(i,function(){S.animate.hide(!1,e(this))}),S.animate.show(!1,n)},y.delay.show),t.preventDefault())},mouseleave:function(t){var n=e(this).children(R.menu);n.length>0&&(clearTimeout(S.itemTimer),S.itemTimer=setTimeout(function(){S.verbose("Hiding sub-menu",n),S.animate.hide(!1,n)},y.delay.hide))},touchend:function(){},click:function(t){var n=e(this),i=e(t?t.target:""),a=n.find(R.menu),o=S.get.choiceText(n),s=S.get.choiceValue(n,o),r=a.length>0,l=a.find(i).length>0;l||r&&!y.allowCategorySelection||(y.useLabels||(S.remove.filteredItem(),S.remove.searchTerm(),S.set.scrollPosition(n)),S.determine.selectAction.call(this,o,s))}},document:{keydown:function(e){var t=e.which,n=S.get.shortcutKeys(),i=S.is.inObject(t,n);if(i){var a=F.find(R.label),o=a.filter("."+T.active),s=(o.data(L.value),a.index(o)),r=a.length,l=o.length>0,c=o.length>1,u=0===s,d=s+1==r,v=S.is.searchSelection(),m=S.is.focusedOnSearch(),f=S.is.focused(),h=m&&0===S.get.caretPosition();if(v&&!l&&!m)return;t==n.leftArrow?!f&&!h||l?l&&(e.shiftKey?S.verbose("Adding previous label to selection"):(S.verbose("Selecting previous label"),a.removeClass(T.active)),u&&!c?o.addClass(T.active):o.prev(R.siblingLabel).addClass(T.active).end(),e.preventDefault()):(S.verbose("Selecting previous label"),a.last().addClass(T.active)):t==n.rightArrow?(f&&!l&&a.first().addClass(T.active),l&&(e.shiftKey?S.verbose("Adding next label to selection"):(S.verbose("Selecting next label"),a.removeClass(T.active)),d?v?m?a.removeClass(T.active):S.focusSearch():c?o.next(R.siblingLabel).addClass(T.active):o.addClass(T.active):o.next(R.siblingLabel).addClass(T.active),e.preventDefault())):t==n.deleteKey||t==n.backspace?l?(S.verbose("Removing active labels"),d&&v&&!m&&S.focusSearch(),o.last().next(R.siblingLabel).addClass(T.active),S.remove.activeLabels(o),e.preventDefault()):h&&!l&&t==n.backspace&&(S.verbose("Removing last label on input backspace"),o=a.last().addClass(T.active),S.remove.activeLabels(o)):o.removeClass(T.active)}}},keydown:function(e){var t=e.which,n=S.get.shortcutKeys(),i=S.is.inObject(t,n);if(i){var a,o,s=K.not(R.unselectable).filter("."+T.selected).eq(0),r=N.children("."+T.active).eq(0),l=s.length>0?s:r,c=l.length>0?l.siblings(":not(."+T.filtered+")").andSelf():N.children(":not(."+T.filtered+")"),u=l.children(R.menu),d=l.closest(R.menu),v=d.hasClass(T.visible)||d.hasClass(T.animating)||d.parent(R.menu).length>0,m=u.length>0,f=l.length>0,h=l.not(R.unselectable).length>0;if(S.is.visible()){if((t==n.enter||t==n.delimiter)&&(t==n.enter&&f&&m&&!y.allowCategorySelection?(S.verbose("Pressed enter on unselectable category, opening sub menu"),t=n.rightArrow):h&&(S.verbose("Selecting item from keyboard shortcut",l),S.event.item.click.call(l,e),S.is.searchSelection()&&S.remove.searchTerm()),e.preventDefault()),t==n.leftArrow&&(o=d[0]!==N[0],o&&(S.verbose("Left key pressed, closing sub-menu"),S.animate.hide(!1,d),l.removeClass(T.selected),d.closest(R.item).addClass(T.selected),e.preventDefault())),t==n.rightArrow&&m&&(S.verbose("Right key pressed, opening sub-menu"),S.animate.show(!1,u),l.removeClass(T.selected),u.find(R.item).eq(0).addClass(T.selected),e.preventDefault()),t==n.upArrow){if(a=f&&v?l.prevAll(R.item+":not("+R.unselectable+")").eq(0):K.eq(0),c.index(a)<0)return S.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();S.verbose("Up key pressed, changing active item"),l.removeClass(T.selected),a.addClass(T.selected),S.set.scrollPosition(a),e.preventDefault()}if(t==n.downArrow){if(a=f&&v?a=l.nextAll(R.item+":not("+R.unselectable+")").eq(0):K.eq(0),0===a.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),a.addClass(T.selected),S.set.scrollPosition(a),e.preventDefault()}t==n.pageUp&&(S.scrollPage("up"),e.preventDefault()),t==n.pageDown&&(S.scrollPage("down"),e.preventDefault()),t==n.escape&&(S.verbose("Escape key pressed, closing dropdown"),S.hide())}else t==n.delimiter&&e.preventDefault(),t==n.downArrow&&(S.verbose("Down key pressed, showing dropdown"),S.show(),e.preventDefault())}else S.is.selection()&&!S.is.search()&&S.set.selectedLetter(String.fromCharCode(t))}},determine:{selectAction:function(t,n){S.verbose("Determining action",y.action),e.isFunction(S.action[y.action])?(S.verbose("Triggering preset action",y.action,t,n),S.action[y.action].call(this,t,n)):e.isFunction(y.action)?(S.verbose("Triggering user action",y.action,t,n),y.action.call(this,t,n)):S.error(q.action,y.action)},eventInModule:function(t,i){var a=e(t.target),o=a.closest(n.documentElement).length>0,s=a.closest(F).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,n){var i=e(t.target),a=i.closest(R.siblingLabel),o=0===F.find(a).length,s=0===i.closest(N).length;return n=e.isFunction(n)?n:function(){},o&&s?(S.verbose("Triggering event",n),n(),!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),S.hideAndClear()}},get:{id:function(){return w},defaultText:function(){return F.data(L.defaultText)},defaultValue:function(){return F.data(L.defaultValue)},placeholderText:function(){return F.data(L.placeholderText)||""},text:function(){return M.text()},query:function(){return e.trim(z.val())},searchWidth:function(e){return e*y.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"==y.transition?S.is.upward(e)?"slide up":"slide down":y.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},shortcutKeys:function(){return{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,pageUp:33,pageDown:34,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40}},value:function(){var t=H.length>0?H.val():F.data(L.value);return e.isArray(t)&&1===t.length&&""===t[0]?"":t},values:function(){var e=S.get.value();return""===e?"":!S.has.selectInput()&&S.is.multiple()?"string"==typeof e?e.split(y.delimiter):"":e},remoteValues:function(){var t=S.get.values(),n=!1;return t&&("string"==typeof t&&(t=[t]),n={},e.each(t,function(e,t){var i=S.read.remoteData(t);S.verbose("Restoring value from session data",i,t),n[t]=i?i:t})),n},choiceText:function(t,n){return n=n!==i?n:y.preserveHTML,t?(t.find(R.menu).length>0&&(S.verbose("Retreiving text of element with sub-menu"),t=t.clone(),t.find(R.menu).remove(),t.find(R.menuIcon).remove()),t.data(L.text)!==i?t.data(L.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(L.value)!==i?String(t.data(L.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=[],F.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"===y.placeholder&&""===s?t.placeholder=a:t.values.push({name:a,value:s,disabled:o})}),y.placeholder&&"auto"!==y.placeholder&&(S.debug("Setting placeholder value to",y.placeholder),t.placeholder=y.placeholder),y.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(R.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 y.maxSelections?(e=e!==i?e:S.get.selectionCount(),e>=y.maxSelections?(S.debug("Maximum selection count reached"),y.useLabels&&(K.addClass(T.filtered),S.add.message(A.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))},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(){y.allowAdditions&&(y.useLabels||(S.error(q.labels),y.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(),y.apiSettings?y.saveRemoteData?S.restore.remoteValues():S.clearValue():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(q.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),F.data(L.defaultValue,e)},defaultText:function(){var e=S.get.text();S.verbose("Saving default text as",e),F.data(L.defaultText,e)},placeholderText:function(){var e;y.placeholder!==!1&&M.hasClass(T.placeholder)&&(e=S.get.text(),S.verbose("Saving placeholder text as",e),F.data(L.placeholderText,e))},remoteData:function(e,n){return t.Storage===i?void S.error(q.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(R.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(R.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,y.glyphWidth),z.css("width",o)),a||n&&s?(S.verbose("Hiding placeholder text"),M.addClass(T.filtered)):(!e||n&&!s)&&(S.verbose("Showing placeholder text"),M.removeClass(T.filtered))},loading:function(){F.addClass(T.loading)},placeholderText:function(e){e=e||S.get.placeholderText(),S.debug("Setting placeholder text",e),S.set.text(e),M.addClass(T.placeholder)},tabbable:function(){S.has.search()?(S.debug("Added tabindex to searchable dropdown"),z.val("").attr("tabindex",0),N.attr("tabindex",-1)):(S.debug("Added tabindex to dropdown"),F.attr("tabindex")||(F.attr("tabindex",0),N.attr("tabindex",-1)))},initialLoad:function(){S.verbose("Setting initial load"),g=!0},activeItem:function(e){y.allowAdditions&&e.filter(R.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(R.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"!==y.action&&("combo"==y.action?(S.debug("Changing combo button text",e,U),y.preserveHTML?U.html(e):U.text(e)):(e!==S.get.placeholderText()&&M.removeClass(T.placeholder),S.debug("Changing text",e,M),M.removeClass(T.filtered),y.preserveHTML?M.html(e):M.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"==y.direction?S.is.onScreen(e)?S.remove.upward(e):S.set.upward(e):"upward"==y.direction&&S.set.upward(e)},upward:function(e){var t=e||F;t.addClass(T.upward)},value:function(e,t,n){var a=H.length>0,o=(!S.has.value(e),S.get.values()),s=e!==i?String(e):e;if(a){if(s==o&&(S.verbose("Skipping value update already same value",e,o),!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",e,o),$=!0,H.val(e),y.fireOnInit===!1&&S.is.initialLoad()?S.debug("Input native change event ignored on initial load"):H.trigger("change"),$=!1}else S.verbose("Storing value in metadata",e,H),e!==o&&F.data(L.value,s);y.fireOnInit===!1&&S.is.initialLoad()?S.verbose("No callback on initial load",y.onChange):y.onChange.call(Q,e,t,n)},active:function(){F.addClass(T.active)},multiple:function(){F.addClass(T.multiple)},visible:function(){F.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=y.allowAdditions?n||S.get.itemWithAdditions(t):n||S.get.item(t),n&&(S.debug("Setting selected menu item to",n),S.is.single()?(S.remove.activeItem(),S.remove.selectedItem()):y.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?(y.apiSettings&&y.saveRemoteData&&S.save.remoteData(a,o),y.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(A.count)),S.set.activeItem(t))):s||(S.debug("Selected active value, removing label"),S.remove.selected(o)):(y.apiSettings&&y.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:M;return a=e("").addClass(T.label).attr("data-value",t).html(V.label(t,n)),a=y.onLabelCreate.call(a,t,n),S.has.label(t)?void S.debug("Label already exists, skipping",t):(y.label.variation&&a.addClass(y.label.variation),void(i===!0?(S.debug("Animating in label",a),a.addClass(T.hidden).insertBefore(o).transition(y.label.transition,y.label.duration)):(S.debug("Adding selection label",a),a.insertBefore(o))))},message:function(t){var n=N.children(R.message),i=y.templates.message(S.add.variables(t));n.length>0?n.html(i):n=e("
").html(i).addClass(T.message).appendTo(N)},optionValue:function(t){var n=H.find('option[value="'+t+'"]'),i=n.length>0;i||(x&&(x.disconnect(),S.verbose("Temporarily disconnecting mutation observer",t)),S.is.single()&&(S.verbose("Removing previous user addition"),H.find("option."+T.addition).remove()),e("