LocalCDN-Firefox-Chrome-Brave/resources/semantic-ui/2.5.0/components/dropdown.min.jsm

1 line
50 KiB
JavaScript
Raw Normal View History

2022-10-07 06:16:13 +02:00
!function(X,Y,G,J){"use strict";Y=void 0!==Y&&Y.Math==Math?Y:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),X.fn.dropdown=function(z){var P,H=X(this),j=X(G),N=H.selector||"",U="ontouchstart"in G.documentElement,K=(new Date).getTime(),W=[],B=z,$="string"==typeof B,Q=[].slice.call(arguments,1);return H.each(function(n){var e,t,i,a,o,s,r,m=X.isPlainObject(z)?X.extend(!0,{},X.fn.dropdown.settings,z):X.extend({},X.fn.dropdown.settings),h=m.className,c=m.message,l=m.fields,g=m.keys,p=m.metadata,u=m.namespace,d=m.regExp,b=m.selector,v=m.error,f=m.templates,w="."+u,x="module-"+u,C=X(this),S=X(m.context),y=C.find(b.text),A=C.find(b.search),T=C.find(b.sizer),k=C.find(b.input),L=C.find(b.icon),I=0<C.prev().find(b.text).length?C.prev().find(b.text):C.prev(),D=C.children(b.menu),q=D.find(b.item),R=!1,O=!1,V=!1,E=this,M=C.data(x),F={initialize:function(){F.debug("Initializing dropdown",m),F.is.alreadySetup()?F.setup.reference():(F.setup.layout(),m.values&&F.change.values(m.values),F.refreshData(),F.save.defaults(),F.restore.selected(),F.create.id(),F.bind.events(),F.observeChanges(),F.instantiate())},instantiate:function(){F.verbose("Storing instance of dropdown",F),M=F,C.data(x,F)},destroy:function(){F.verbose("Destroying previous dropdown",C),F.remove.tabbable(),C.off(w).removeData(x),D.off(w),j.off(a),F.disconnect.menuObserver(),F.disconnect.selectObserver()},observeChanges:function(){"MutationObserver"in Y&&(s=new MutationObserver(F.event.select.mutation),r=new MutationObserver(F.event.menu.mutation),F.debug("Setting up mutation observer",s,r),F.observe.select(),F.observe.menu())},disconnect:{menuObserver:function(){r&&r.disconnect()},selectObserver:function(){s&&s.disconnect()}},observe:{select:function(){F.has.input()&&s.observe(C[0],{childList:!0,subtree:!0})},menu:function(){F.has.menu()&&r.observe(D[0],{childList:!0,subtree:!0})}},create:{id:function(){o=(Math.random().toString(16)+"000000000").substr(2,8),a="."+o,F.verbose("Creating unique id for element",o)},userChoice:function(e){var n,i,a;return!!(e=e||F.get.userValues())&&(e=X.isArray(e)?e:[e],X.each(e,function(e,t){!1===F.get.item(t)&&(a=m.templates.addition(F.add.variables(c.addResult,t)),i=X("<div />").html(a).attr("data-"+p.value,t).attr("data-"+p.text,t).addClass(h.addition).addClass(h.item),m.hideAdditions&&i.addClass(h.hidden),n=n===J?i:n.add(i),F.verbose("Creating user choices for value",t,i))}),n)},userLabels:function(e){var t=F.get.userValues();t&&(F.debug("Adding user labels",t),X.each(t,function(e,t){F.verbose("Adding custom user value"),F.add.label(t,t)}))},menu:function(){D=X("<div />").addClass(h.menu).appendTo(C)},sizer:function(){T=X("<span />").addClass(h.sizer).insertAfter(A)}},search:function(e){e=e!==J?e:F.get.query(),F.verbose("Searching for query",e),F.has.minCharacters(e)?F.filter(e):F.hide()},select:{firstUnfiltered:function(){F.verbose("Selecting first non-filtered element"),F.remove.selectedItem(),q.not(b.unselectable).not(b.addition+b.hidden).eq(0).addClass(h.selected)},nextAvailable:function(e){var t=(e=e.eq(0)).nextAll(b.item).not(b.unselectable).eq(0),n=e.prevAll(b.item).not(b.unselectable).eq(0);0<t.length?(F.verbose("Moving selection to",t),t.addClass(h.selected)):(F.verbose("Moving selection to",n),n.addClass(h.selected))}},setup:{api:function(){var e={debug:m.debug,urlData:{value:F.get.value(),query:F.get.query()},on:!1};F.verbose("First request, initializing API"),C.api(e)},layout:function(){C.is("select")&&(F.setup.select(),F.setup.returnedObject()),F.has.menu()||F.create.menu(),F.is.search()&&!F.has.search()&&(F.verbose("Adding search input"),A=X("<input />").addClass(h.search).prop("autocomplete","off").insertBefore(y)),F.is.multiple()&&F.is.searchSelection()&&!F.has.sizer()&&F.create.sizer(),m.allowTab&&F.set.tabbable()},select:function(){var e=F.get.selectValues();F.debug("Dropdown initialized on a select",e),C.is("select")&&(k=C),0<k.parent(b.dropdown).length?(F.debug("UI dropdown already exists. Creating dropdown menu only"),C=k.closest(b.dropdown),F.has.menu()||F.create.menu(),D=C.children(b.menu),F.s