/*!
* # Semantic UI 2.2.9 - Dropdown
* http://github.com/semantic-org/semantic-ui/
*
*
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
!function(e,t,n,i){"use strict";t=void 0!==t&&t.Math==Math?t:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),e.fn.dropdown=function(i){var a,o=e(this),s=e(n),r=o.selector||"",l="ontouchstart"in n.documentElement,c=(new Date).getTime(),u=[],d=arguments[0],v="string"==typeof d,m=[].slice.call(arguments,1);return o.each(function(f){var h,g,p,b,w,x,S,C,y=e.isPlainObject(i)?e.extend(!0,{},e.fn.dropdown.settings,i):e.extend({},e.fn.dropdown.settings),A=y.className,T=y.message,k=y.fields,L=y.keys,I=y.metadata,D=y.namespace,q=y.regExp,R=y.selector,O=y.error,V=y.templates,E="."+D,F="module-"+D,M=e(this),P=e(y.context),z=M.find(R.text),H=M.find(R.search),j=M.find(R.sizer),N=M.find(R.input),U=M.find(R.icon),K=M.prev().find(R.text).length>0?M.prev().find(R.text):M.prev(),B=M.children(R.menu),W=B.find(R.item),$=!1,Q=!1,Y=!1,G=this,J=M.data(F);C={initialize:function(){C.debug("Initializing dropdown",y),C.is.alreadySetup()?C.setup.reference():(C.setup.layout(),C.refreshData(),C.save.defaults(),C.restore.selected(),C.create.id(),C.bind.events(),C.observeChanges(),C.instantiate())},instantiate:function(){C.verbose("Storing instance of dropdown",C),J=C,M.data(F,C)},destroy:function(){C.verbose("Destroying previous dropdown",M),C.remove.tabbable(),M.off(E).removeData(F),B.off(E),s.off(b),C.disconnect.menuObserver(),C.disconnect.selectObserver()},observeChanges:function(){"MutationObserver"in t&&(x=new MutationObserver(C.event.select.mutation),S=new MutationObserver(C.event.menu.mutation),C.debug("Setting up mutation observer",x,S),C.observe.select(),C.observe.menu())},disconnect:{menuObserver:function(){S&&S.disconnect()},selectObserver:function(){x&&x.disconnect()}},observe:{select:function(){C.has.input()&&x.observe(N[0],{childList:!0,subtree:!0})},menu:function(){C.has.menu()&&S.observe(B[0],{childList:!0,subtree:!0})}},create:{id:function(){w=(Math.random().toString(16)+"000000000").substr(2,8),b="."+w,C.verbose("Creating unique id for element",w)},userChoice:function(t){var n,i,a;return!!(t=t||C.get.userValues())&&(t=e.isArray(t)?t:[t],e.each(t,function(t,o){C.get.item(o)===!1&&(a=y.templates.addition(C.add.variables(T.addResult,o)),i=e("
").html(a).attr("data-"+I.value,o).attr("data-"+I.text,o).addClass(A.addition).addClass(A.item),y.hideAdditions&&i.addClass(A.hidden),n=void 0===n?i:n.add(i),C.verbose("Creating user choices for value",o,i))}),n)},userLabels:function(t){var n=C.get.userValues();n&&(C.debug("Adding user labels",n),e.each(n,function(e,t){C.verbose("Adding custom user value"),C.add.label(t,t)}))},menu:function(){B=e("").addClass(A.menu).appendTo(M)},sizer:function(){j=e("").addClass(A.sizer).insertAfter(H)}},search:function(e){e=void 0!==e?e:C.get.query(),C.verbose("Searching for query",e),C.has.minCharacters(e)?C.filter(e):C.hide()},select:{firstUnfiltered:function(){C.verbose("Selecting first non-filtered element"),C.remove.selectedItem(),W.not(R.unselectable).not(R.addition+R.hidden).eq(0).addClass(A.selected)},nextAvailable:function(e){e=e.eq(0);var t=e.nextAll(R.item).not(R.unselectable).eq(0),n=e.prevAll(R.item).not(R.unselectable).eq(0);t.length>0?(C.verbose("Moving selection to",t),t.addClass(A.selected)):(C.verbose("Moving selection to",n),n.addClass(A.selected))}},setup:{api:function(){var e={debug:y.debug,urlData:{value:C.get.value(),query:C.get.query()},on:!1};C.verbose("First request, initializing API"),M.api(e)},layout:function(){M.is("select")&&(C.setup.select(),C.setup.returnedObject()),C.has.menu()||C.create.menu(),C.is.search()&&!C.has.search()&&(C.verbose("Adding search input"),H=e("").addClass(A.search).prop("autocomplete","off").insertBefore(z)),C.is.multiple()&&C.is.searchSelection()&&!C.has.sizer()&&C.create.sizer(),y.allowTab&&C.set.tabbable()},select:function(){var t=C.get.selectValues();C.debug("Dropdown initialized on a select",t),M.is("select")&&(N=M),N.parent(R.dropdown).length>0?(C.debug("UI dropdown already exists. Creating dropdown menu only"),M=N.closest(R.dropdown),C.has.menu()||C.create.menu(),B=M.children(R.menu),C.setup.menu(t)):(C.debug("Creating entire dropdown from select"),M=e("").attr("class",N.attr("class")).addClass(A.selection).addClass(A.dropdown).html(V.dropdown(t)).insertBefore(N),N.hasClass(A.multiple)&&N.prop("multiple")===!1&&(C.error(O.missingMultiple),N.prop("multiple",!0)),N.is("[multiple]")&&C.set.multiple(),N.prop("disabled")&&(C.debug("Disabling dropdown"),M.addClass(A.disabled)),N.removeAttr("class").detach().prependTo(M)),C.refresh()},menu:function(e){B.html(V.menu(e,k)),W=B.find(R.item)},reference:function(){C.debug("Dropdown behavior was called on select, replacing with closest dropdown"),M=M.parent(R.dropdown),C.refresh(),C.setup.returnedObject(),v&&(J=C,C.invoke(d))},returnedObject:function(){var e=o.slice(0,f),t=o.slice(f+1);o=e.add(M).add(t)}},refresh:function(){C.refreshSelectors(),C.refreshData()},refreshItems:function(){W=B.find(R.item)},refreshSelectors:function(){C.verbose("Refreshing selector cache"),z=M.find(R.text),H=M.find(R.search),N=M.find(R.input),U=M.find(R.icon),K=M.prev().find(R.text).length>0?M.prev().find(R.text):M.prev(),B=M.children(R.menu),W=B.find(R.item)},refreshData:function(){C.verbose("Refreshing cached metadata"),W.removeData(I.text).removeData(I.value)},clearData:function(){C.verbose("Clearing metadata"),W.removeData(I.text).removeData(I.value),M.removeData(I.defaultText).removeData(I.defaultValue).removeData(I.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.remote()&&(C.debug("No API results retrieved, searching before show"),C.queryRemote(C.get.query(),C.show)),C.can.show()&&!C.is.active()){if(C.debug("Showing dropdown"),!C.has.message()||C.has.maxSelections()||C.has.allResultsFiltered()||C.remove.message(),C.is.allFiltered())return!0;y.onShow.call(G)!==!1&&C.animate.show(function(){C.can.click()&&C.bind.intent(),C.has.menuSearch()&&C.focusSearch(),C.set.visible(),t.call(G)})}},hide:function(t){t=e.isFunction(t)?t:function(){},C.is.active()&&(C.debug("Hiding dropdown"),y.onHide.call(G)!==!1&&C.animate.hide(function(){C.remove.visible(),t.call(G)}))},hideOthers:function(){C.verbose("Finding other dropdowns to hide"),o.not(M).has(R.menu+"."+A.visible).dropdown("hide")},hideMenu:function(){C.verbose("Hiding menu instantaneously"),C.remove.active(),C.remove.visible(),B.transition("hide")},hideSubMenus:function(){var e=B.children(R.item).find(R.menu);C.verbose("Hiding sub menus",e),e.transition("hide")},bind:{events:function(){l&&C.bind.touchEvents(),C.bind.keyboardEvents(),C.bind.inputEvents(),C.bind.mouseEvents()},touchEvents:function(){C.debug("Touch device detected binding additional touch events"),C.is.searchSelection()||C.is.single()&&M.on("touchstart"+E,C.event.test.toggle),B.on("touchstart"+E,R.item,C.event.item.mouseenter)},keyboardEvents:function(){C.verbose("Binding keyboard events"),M.on("keydown"+E,C.event.keydown),C.has.search()&&M.on(C.get.inputEvent()+E,R.search,C.event.input),C.is.multiple()&&s.on("keydown"+b,C.event.document.keydown)},inputEvents:function(){C.verbose("Binding input change events"),M.on("change"+E,R.input,C.event.change)},mouseEvents:function(){C.verbose("Binding mouse events"),C.is.multiple()&&M.on("click"+E,R.label,C.event.label.click).on("click"+E,R.remove,C.event.remove.click),C.is.searchSelection()?(M.on("mousedown"+E,C.event.mousedown).on("mouseup"+E,C.event.mouseup).on("mousedown"+E,R.menu,C.event.menu.mousedown).on("mouseup"+E,R.menu,C.event.menu.mouseup).on("click"+E,R.icon,C.event.icon.click).on("focus"+E,R.search,C.event.search.focus).on("click"+E,R.search,C.event.search.focus).on("blur"+E,R.search,C.event.search.blur).on("click"+E,R.text,C.event.text.focus),C.is.multiple()&&M.on("click"+E,C.event.click)):("click"==y.on?M.on("click"+E,R.icon,C.event.icon.click).on("click"+E,C.event.test.toggle):"hover"==y.on?M.on("mouseenter"+E,C.delay.show).on("mouseleave"+E,C.delay.hide):M.on(y.on+E,C.toggle),M.on("mousedown"+E,C.event.mousedown).on("mouseup"+E,C.event.mouseup).on("focus"+E,C.event.focus),C.has.menuSearch()?M.on("blur"+E,R.search,C.event.search.blur):M.on("blur"+E,C.event.blur)),B.on("mouseenter"+E,R.item,C.event.item.mouseenter).on("mouseleave"+E,R.item,C.event.item.mouseleave).on("click"+E,R.item,C.event.item.click)},intent:function(){C.verbose("Binding hide intent event to document"),l&&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"),l&&s.off("touchstart"+b).off("touchmove"+b),s.off("click"+b)}},filter:function(e){var t=void 0!==e?e:C.get.query(),n=function(){C.is.multiple()&&C.filterActive(),C.select.firstUnfiltered(),C.has.allResultsFiltered()?y.onNoResults.call(G,t)?y.allowAdditions?y.hideAdditions&&(C.verbose("User addition with no menu, setting empty style"),C.set.empty(),C.hideMenu()):(C.verbose("All items filtered, showing message",t),C.add.message(T.noResults)):(C.verbose("All items filtered, hiding dropdown",t),C.hideMenu()):(C.remove.empty(),C.remove.message()),y.allowAdditions&&C.add.userSuggestion(e),C.is.searchSelection()&&C.can.show()&&C.is.focusedOnSearch()&&C.show()};y.useLabels&&C.has.maxSelections()||(y.apiSettings?C.can.useAPI()?C.queryRemote(t,function(){y.filterRemoteData&&C.filterItems(t),n()}):C.error(O.noAPI):(C.filterItems(t),n()))},queryRemote:function(t,n){var i={errorDuration:!1,cache:"local",throttle:y.throttle,urlData:{query:t},onError:function(){C.add.message(T.serverError),n()},onFailure:function(){C.add.message(T.serverError),n()},onSuccess:function(e){C.remove.message(),C.setup.menu({values:e[k.remoteValues]}),n()}};M.api("get request")||C.setup.api(),i=e.extend(!0,{},i,y.apiSettings),M.api("setting",i).api("query")},filterItems:function(t){var n=void 0!==t?t:C.get.query(),i=null,a=C.escape.string(n),o=new RegExp("^"+a,"igm");C.has.query()&&(i=[],C.verbose("Searching for matching values",n),W.each(function(){var t,a,s=e(this);if("both"==y.match||"text"==y.match){if(t=String(C.get.choiceText(s,!1)),t.search(o)!==-1)return i.push(this),!0;if("exact"===y.fullTextSearch&&C.exactSearch(n,t))return i.push(this),!0;if(y.fullTextSearch===!0&&C.fuzzySearch(n,t))return i.push(this),!0}if("both"==y.match||"value"==y.match){if(a=String(C.get.choiceValue(s,t)),a.search(o)!==-1)return i.push(this),!0;if("exact"===y.fullTextSearch&&C.exactSearch(n,a))return i.push(this),!0;if(y.fullTextSearch===!0&&C.fuzzySearch(n,a))return i.push(this),!0}})),C.debug("Showing only matched items",n),C.remove.filteredItem(),i&&W.not(i).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;a-1},filterActive:function(){y.useLabels&&W.filter("."+A.active).addClass(A.filtered)},focusSearch:function(e){C.has.search()&&!C.is.focusedOnSearch()&&(e?(M.off("focus"+E,R.search),H.focus(),M.on("focus"+E,R.search,C.event.search.focus)):H.focus())},forceSelection:function(){var e=W.not(A.filtered).filter("."+A.selected).eq(0),t=W.not(A.filtered).filter("."+A.active).eq(0),n=e.length>0?e:t;if(n.length>0&&!C.is.multiple())return C.debug("Forcing partial selection to selected item",n),void C.event.item.click.call(n,{},!0);y.allowAdditions?(C.set.selected(C.get.query()),C.remove.searchTerm()):C.remove.searchTerm()},event:{change:function(){Y||(C.debug("Input changed, updating selection"),C.set.selected())},focus:function(){y.showOnFocus&&!$&&C.is.hidden()&&!g&&C.show()},blur:function(e){g=n.activeElement===this,$||g||(C.remove.activeLabel(),C.hide())},mousedown:function(){C.is.searchSelection()?p=!0:$=!0},mouseup:function(){C.is.searchSelection()?p=!1:$=!1},click:function(t){e(t.target).is(M)&&(C.is.focusedOnSearch()?C.show():C.focusSearch())},search:{focus:function(){$=!0,C.is.multiple()&&C.remove.activeLabel(),y.showOnFocus&&C.search()},blur:function(e){g=n.activeElement===this,p||Q||g||(y.forceSelection&&C.forceSelection(),C.hide()),p=!1}},icon:{click:function(e){C.toggle()}},text:{focus:function(e){$=!0,C.focusSearch()}},input:function(e){(C.is.multiple()||C.is.searchSelection())&&C.set.filtered(),clearTimeout(C.timer),C.timer=setTimeout(C.search,y.delay.search)},label:{click:function(t){var n=e(this),i=M.find(R.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)),y.onLabelSelect.apply(this,i.filter("."+A.active))}},remove:{click:function(){var t=e(this).parent();t.hasClass(A.active)?C.remove.activeLabels():C.remove.activeLabels(t)}},test:{toggle:function(e){var t=C.is.multiple()?C.show:C.toggle;C.is.bubbledLabelClick(e)||C.is.bubbledIconClick(e)||C.determine.eventOnElement(e,t)&&e.preventDefault()},touch:function(e){C.determine.eventOnElement(e,function(){"touchstart"==e.type?C.timer=setTimeout(function(){C.hide()},y.delay.touch):"touchmove"==e.type&&clearTimeout(C.timer)}),e.stopPropagation()},hide:function(e){C.determine.eventInModule(e,C.hide)}},select:{mutation:function(e){C.debug("