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

1 line
50 KiB
JavaScript
Raw Normal View History

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