wishthis/node_modules/fomantic-ui/dist/components/dropdown.min.js

11 lines
58 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
* # Fomantic UI - 2.8.8
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
* Copyright 2021 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
!function(te,ne,ie,ae){"use strict";te.isFunction=te.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},ne=void 0!==ne&&ne.Math==Math?ne:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),te.fn.dropdown=function(B){var K,W=te(this),Q=te(ie),Y=W.selector||"",$="ontouchstart"in ie.documentElement,X=$?"touchstart":"click",G=(new Date).getTime(),J=[],Z=B,_="string"==typeof Z,ee=[].slice.call(arguments,1);return W.each(function(n){var d,e,t,i,a,s,o,r,l,h,f=te.isPlainObject(B)?te.extend(!0,{},te.fn.dropdown.settings,B):te.extend({},te.fn.dropdown.settings),g=f.className,v=f.message,c=f.fields,p=f.keys,b=f.metadata,u=f.namespace,m=f.regExp,w=f.selector,C=f.error,y=f.templates,x="."+u,S="module-"+u,A=te(this),T=te(f.context),L=A.find(w.text),I=A.find(w.search),D=A.find(w.sizer),k=A.find(w.input),q=A.find(w.icon),O=A.find(w.clearIcon),R=0<A.prev().find(w.text).length?A.prev().find(w.text):A.prev(),V=A.children(w.menu),E=V.find(w.item),M=f.hideDividers?E.parent().children(w.divider):te(),z=!1,F=!1,P=!1,N=!1,H=this,j=!1,U=A.data(S);h={initialize:function(){h.debug("Initializing dropdown",f),h.is.alreadySetup()?h.setup.reference():(f.ignoreDiacritics&&!String.prototype.normalize&&(f.ignoreDiacritics=!1,h.error(C.noNormalize,H)),h.setup.layout(),f.values&&(h.set.initialLoad(),h.change.values(f.values),h.remove.initialLoad()),h.refreshData(),h.save.defaults(),h.restore.selected(),h.create.id(),h.bind.events(),h.observeChanges(),h.instantiate())},instantiate:function(){h.verbose("Storing instance of dropdown",h),U=h,A.data(S,h)},destroy:function(){h.verbose("Destroying previous dropdown",A),h.remove.tabbable(),h.remove.active(),V.transition("stop all"),V.removeClass(g.visible).addClass(g.hidden),A.off(x).removeData(S),V.off(x),Q.off(a),h.disconnect.menuObserver(),h.disconnect.selectObserver(),h.disconnect.classObserver()},observeChanges:function(){"MutationObserver"in ne&&(o=new MutationObserver(h.event.select.mutation),r=new MutationObserver(h.event.menu.mutation),l=new MutationObserver(h.event.class.mutation),h.debug("Setting up mutation observer",o,r,l),h.observe.select(),h.observe.menu(),h.observe.class())},disconnect:{menuObserver:function(){r&&r.disconnect()},selectObserver:function(){o&&o.disconnect()},classObserver:function(){l&&l.disconnect()}},observe:{select:function(){h.has.input()&&o&&o.observe(A[0],{childList:!0,subtree:!0})},menu:function(){h.has.menu()&&r&&r.observe(V[0],{childList:!0,subtree:!0})},class:function(){h.has.search()&&l&&l.observe(A[0],{attributes:!0})}},create:{id:function(){s=(Math.random().toString(16)+"000000000").substr(2,8),a="."+s,h.verbose("Creating unique id for element",s)},userChoice:function(e){var n,i,a;return!!(e=e||h.get.userValues())&&(e=Array.isArray(e)?e:[e],te.each(e,function(e,t){!1===h.get.item(t)&&(a=f.templates.addition(h.add.variables(v.addResult,t)),i=te("<div />").html(a).attr("data-"+b.value,t).attr("data-"+b.text,t).addClass(g.addition).addClass(g.item),f.hideAdditions&&i.addClass(g.hidden),n=n===ae?i:n.add(i),h.verbose("Creating user choices for value",t,i))}),n)},userLabels:function(e){var t=h.get.userValues();t&&(h.debug("Adding user labels",t),te.each(t,function(e,t){h.verbose("Adding custom user value"),h.add.label(t,t)}))},menu:function(){V=te("<div />").addClass(g.menu).appendTo(A)},sizer:function(){D=te("<span />").addClass(g.sizer).insertAfter(I)}},search:function(e){e=e!==ae?e:h.get.query(),h.verbose("Searching for query",e),!1===f.fireOnInit&&h.is.initialLoad()?h.verbose("Skipping callback on initial load",f.onSearch):h.has.minCharacters(e)&&!1!==f.onSearch.call(H,e)?h.filter(e):h.hide(null,!0)},select:{firstUnfiltered:function(){h.verbose("Selecting first non-filtered element"),h.remove.selectedItem(),E.not(w.unselectable).not(w.addition+w.hidden).eq(0).addClass(g.selected)},nextAvailable:function(e){var t=(e=e.eq(0)).nextAll(w.item).not(w.unselectable).eq(0),n=e.prevAll(w.item).not(w.unselectable).eq(0);0<t.length?(h.verbose("Moving selection to",t),t.addClass(g.selected)):(h.verbose("Moving selection to",n),n.addC