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

11 lines
57 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 2022 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
2022-03-15 09:43:53 +00:00
!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(z){var d,e,t,n,i,a,s,o,r,v=te.isPlainObject(B)?te.extend(!0,{},te.fn.dropdown.settings,B):te.extend({},te.fn.dropdown.settings),m=v.className,h=v.message,l=v.fields,f=v.keys,g=v.metadata,F=v.namespace,c=v.regExp,p=v.selector,u=v.error,P=v.templates,b="."+F,w="module-"+F,C=te(this),y=te(v.context),x=C.find(p.text),S=C.find(p.search),A=C.find(p.sizer),T=C.find(p.input),N=C.find(p.icon),H=C.find(p.clearIcon),L=0<C.prev().find(p.text).length?C.prev().find(p.text):C.prev(),I=C.children(p.menu),D=I.find(p.item),k=v.hideDividers?D.parent().children(p.divider):te(),O=!1,j=!1,U=!1,q=!1,R=this,V=!1,E=C.data(w),M={initialize:function(){M.debug("Initializing dropdown",v),M.is.alreadySetup()?M.setup.reference():(v.ignoreDiacritics&&!String.prototype.normalize&&(v.ignoreDiacritics=!1,M.error(u.noNormalize,R)),M.setup.layout(),v.values&&(M.set.initialLoad(),M.change.values(v.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),E=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(m.visible).addClass(m.hidden),C.off(b).removeData(w),I.off(b),Q.off(i),M.disconnect.menuObserver(),M.disconnect.selectObserver(),M.disconnect.classObserver()},observeChanges:function(){"MutationObserver"in ne&&(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],{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").substr(2,8),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],te.each(e,function(e,t){!1===M.get.item(t)&&(i=v.templates.addition(M.add.variables(h.addResult,t)),i=te("<div />").html(i).attr("data-"+g.value,t).attr("data-"+g.text,t).addClass(m.addition).addClass(m.item),v.hideAdditions&&i.addClass(m.hidden),n=n===ae?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),te.each(t,function(e,t){M.verbose("Adding custom user value"),M.add.label(t,t)}))},menu:function(){I=te("<div />").addClass(m.menu).appendTo(C)},sizer:function(){A=te("<span />").addClass(m.sizer).insertAfter(S)}},search:function(e){e=e!==ae?e:M.get.query(),M.verbose("Searching for query",e),!1===v.fireOnInit&&M.is.initialLoad()?M.verbose("Skipping callback on initial load",v.onSearch):M.has.minCharacters(e)&&!1!==v.onSearch.call(R,e)?M.filter(e):M.hide(null,!0)},select:{firstUnfiltered:function(){M.verbose("Selecting first non-filtered element"),M.remove.selectedItem(),D.not(p.unselectable).not(p.addition+p.hidden).eq(0).addClass(m.selected)},nextAvailable:function(e){var t=(e=e.eq(0)).nextAll(p.item).not(p.unselectable).eq(0),e=e.prevAll(p.item).not(p.unselectable).eq(0);0<t.length?(M.verbose("Moving selection to",t),t.addClass(m.selected)):(M.verbose("Moving selection to",e),e.addClass