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