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