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
/*
2022-06-08 10:36:39 +00:00
* # Fomantic UI - 2.9.0-beta.293+2a71b5e
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
2022-06-08 10:36:39 +00:00
* Copyright 2022 Contributors
2022-01-13 13:00:31 +00:00
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
2022-06-08 10:36:39 +00:00
!function(_,ee,te,ne){"use strict";_.isFunction=_.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")(),_.fn.dropdown=function(B){var K,W=_(this),Q=_(te),$=W.selector||"",Y=(new Date).getTime(),X=[],G=B,J="string"==typeof G,Z=[].slice.call(arguments,1);return W.each(function(z){var v,e,t,n,i,a,s,o,r,m=_.isPlainObject(B)?_.extend(!0,{},_.fn.dropdown.settings,B):_.extend({},_.fn.dropdown.settings),f=m.className,h=m.message,l=m.fields,g=m.keys,p=m.metadata,F=m.namespace,c=m.regExp,b=m.selector,u=m.error,P=m.templates,d="."+F,w="module-"+F,C=_(this),y=[ee,te].indexOf(m.context)<0?_(te).find(m.context):_(m.context),x=C.find(b.text),S=C.find(b.search),A=C.find(b.sizer),T=C.find(b.input),H=C.find(b.icon),N=C.find(b.clearIcon),L=0<C.prev().find(b.text).length?C.prev().find(b.text):C.prev(),I=C.children(b.menu),k=I.find(b.item),D=m.hideDividers?k.parent().children(b.divider):_(),O=!1,j=!1,U=!1,q=!1,R=this,E=!1,V=C.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.setup.layout(),m.values&&(M.set.initialLoad(),M.change.values(m.values),M.remove.initialLoad()),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),V=M,C.data(w,M)},destroy:function(){M.verbose("Destroying previous dropdown",C),M.remove.tabbable(),M.remove.active(),I.transition("stop all"),I.removeClass(f.visible).addClass(f.hidden),C.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(C[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(C[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],_.each(e,function(e,t){!1===M.get.item(t)&&(i=m.templates.addition(M.add.variables(h.addResult,t)),i=_("<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),_.each(t,function(e,t){M.verbose("Adding custom user value"),M.add.label(t,t)}))},menu:function(){I=_("<div />").addClass(f.menu).appendTo(C)},sizer:function(){A=_("<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.addClass(f.selected)):(M.verbose("Moving selection to",e),e.addClass(f.selected))}},se