wishthis/semantic/dist/components/dropdown.min.js

11 lines
59 KiB
JavaScript
Raw Normal View History

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