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