wishthis/node_modules/fomantic-ui/dist/components/accordion.min.js
2023-08-17 11:47:40 +02:00

11 lines
No EOL
7.2 KiB
JavaScript

/*
* # Fomantic UI - 2.9.2
* https://github.com/fomantic/Fomantic-UI
* https://fomantic-ui.com/
*
* Copyright 2023 Contributors
* Released under the MIT license
* https://opensource.org/licenses/MIT
*
*/
!function(k,T){"use strict";T=void 0!==T&&T.Math===Math?T:globalThis,k.fn.accordion=function(p){var m,h=k(this),b=Date.now(),y=[],C=p,O="string"==typeof C,x=[].slice.call(arguments,1);return h.each(function(){var e,a=k.isPlainObject(p)?k.extend(!0,{},k.fn.accordion.settings,p):k.extend({},k.fn.accordion.settings),s=a.className,n=a.namespace,l=a.selector,r=a.error,i="."+n,t="module-"+n,o=h.selector||"",c=k(this),d=c.find(l.title),u=c.find(l.content),g=this,f=c.data(t),v={initialize:function(){v.debug("Initializing",c),v.bind.events(),a.observeChanges&&v.observeChanges(),v.instantiate()},instantiate:function(){f=v,c.data(t,v)},destroy:function(){v.debug("Destroying previous instance",c),c.off(i).removeData(t)},refresh:function(){d=c.find(l.title),u=c.find(l.content)},observeChanges:function(){"MutationObserver"in T&&((e=new MutationObserver(function(e){v.debug("DOM tree modified, updating selector cache"),v.refresh()})).observe(g,{childList:!0,subtree:!0}),v.debug("Setting up mutation observer",e))},bind:{events:function(){v.debug("Binding delegated events"),c.on(a.on+i,l.trigger,v.event.click)}},event:{click:function(e){0===k(e.target).closest(l.ignore).length&&v.toggle.call(this)}},toggle:function(e){var e=void 0!==e?"number"==typeof e?d.eq(e):k(e).closest(l.title):k(this).closest(l.title),n=e.next(u),i=n.hasClass(s.animating),n=n.hasClass(s.active),t=n&&!i,n=!n&&i;v.debug("Toggling visibility of content",e),t||n?a.collapsible?v.close.call(e):v.debug("Cannot close accordion content collapsing is disabled"):v.open.call(e)},open:function(e){var e=void 0!==e?"number"==typeof e?d.eq(e):k(e).closest(l.title):k(this).closest(l.title),n=e.next(u),i=n.hasClass(s.animating);n.hasClass(s.active)||i?v.debug("Accordion already open, skipping",n):(v.debug("Opening accordion content",e),a.onOpening.call(n),a.onChanging.call(n),a.exclusive&&v.closeOthers.call(e),e.addClass(s.active),n.stop(!0,!0).addClass(s.animating),a.animateChildren&&(void 0!==k.fn.transition?n.children().transition({animation:"fade in",queue:!1,useFailSafe:!0,debug:a.debug,verbose:a.verbose,silent:a.silent,duration:a.duration,skipInlineHidden:!0,onComplete:function(){n.children().removeClass(s.transition)}}):n.children().stop(!0,!0).animate({opacity:1},a.duration,v.resetOpacity)),n.slideDown(a.duration,a.easing,function(){n.removeClass(s.animating).addClass(s.active),v.reset.display.call(this),a.onOpen.call(this),a.onChange.call(this)}))},close:function(e){var e=void 0!==e?"number"==typeof e?d.eq(e):k(e).closest(l.title):k(this).closest(l.title),n=e.next(u),i=n.hasClass(s.animating),t=n.hasClass(s.active);!t&&!(!t&&i)||t&&i||(v.debug("Closing accordion content",n),a.onClosing.call(n),a.onChanging.call(n),e.removeClass(s.active),n.stop(!0,!0).addClass(s.animating),a.animateChildren&&(void 0!==k.fn.transition?n.children().transition({animation:"fade out",queue:!1,useFailSafe:!0,debug:a.debug,verbose:a.verbose,silent:a.silent,duration:a.duration,skipInlineHidden:!0}):n.children().stop(!0,!0).animate({opacity:0},a.duration,v.resetOpacity)),n.slideUp(a.duration,a.easing,function(){n.removeClass(s.animating).removeClass(s.active),v.reset.display.call(this),a.onClose.call(this),a.onChange.call(this)}))},closeOthers:function(e){var n,e=void 0!==e?d.eq(e):k(this).closest(l.title),i=e.parents(l.content).prev(l.title),e=e.closest(l.accordion),t=l.title+"."+s.active+":visible",o=l.content+"."+s.active+":visible",o=a.closeNested?(n=e.find(t).not(i)).next(u):(n=e.find(t).not(i),e=e.find(o).find(t).not(i),(n=n.not(e)).next(u));0<n.length&&(v.debug("Exclusive enabled, closing other content",n),n.removeClass(s.active),o.removeClass(s.animating).stop(!0,!0),a.animateChildren&&(void 0!==k.fn.transition?o.children().transition({animation:"fade out",useFailSafe:!0,debug:a.debug,verbose:a.verbose,silent:a.silent,duration:a.duration,skipInlineHidden:!0}):o.children().stop(!0,!0).animate({opacity:0},a.duration,v.resetOpacity)),o.slideUp(a.duration,a.easing,function(){k(this).removeClass(s.active),v.reset.display.call(this)}))},reset:{display:function(){v.verbose("Removing inline display from element",this);var e=k(this);e.css("display",""),""===e.attr("style")&&e.attr("style","").removeAttr("style")},opacity:function(){v.verbose("Removing inline opacity from element",this);var e=k(this);e.css("opacity",""),""===e.attr("style")&&e.attr("style","").removeAttr("style")}},setting:function(e,n){if(v.debug("Changing setting",e,n),k.isPlainObject(e))k.extend(!0,a,e);else{if(void 0===n)return a[e];k.isPlainObject(a[e])?k.extend(!0,a[e],n):a[e]=n}},internal:function(e,n){if(v.debug("Changing internal",e,n),void 0===n)return v[e];k.isPlainObject(e)?k.extend(!0,v,e):v[e]=n},debug:function(){!a.silent&&a.debug&&(a.performance?v.performance.log(arguments):(v.debug=Function.prototype.bind.call(console.info,console,a.name+":"),v.debug.apply(console,arguments)))},verbose:function(){!a.silent&&a.verbose&&a.debug&&(a.performance?v.performance.log(arguments):(v.verbose=Function.prototype.bind.call(console.info,console,a.name+":"),v.verbose.apply(console,arguments)))},error:function(){a.silent||(v.error=Function.prototype.bind.call(console.error,console,a.name+":"),v.error.apply(console,arguments))},performance:{log:function(e){var n,i;a.performance&&(i=(n=Date.now())-(b||n),b=n,y.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:g,"Execution Time":i})),clearTimeout(v.performance.timer),v.performance.timer=setTimeout(v.performance.display,500)},display:function(){var e=a.name+":",i=0;b=!1,clearTimeout(v.performance.timer),k.each(y,function(e,n){i+=n["Execution Time"]}),e+=" "+i+"ms",o&&(e+=" '"+o+"'"),0<y.length&&(console.groupCollapsed(e),console.table?console.table(y):k.each(y,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),y=[]}},invoke:function(t,e,n){var o,a,i,s,l=f;return e=e||x,n=n||g,"string"==typeof t&&void 0!==l&&(t=t.split(/[ .]/),o=t.length-1,k.each(t,function(e,n){var i=e!==o?n+t[e+1].charAt(0).toUpperCase()+t[e+1].slice(1):t;if(k.isPlainObject(l[i])&&e!==o)l=l[i];else{if(void 0!==l[i])return a=l[i],!1;{if(!k.isPlainObject(l[n])||e===o)return void 0!==l[n]?a=l[n]:v.error(r.method,t),!1;l=l[n]}}})),"function"==typeof(s=a)&&"number"!=typeof s.nodeType?i=a.apply(n,e):void 0!==a&&(i=a),Array.isArray(m)?m.push(i):void 0!==m?m=[m,i]:void 0!==i&&(m=i),a}};O?(void 0===f&&v.initialize(),v.invoke(C)):(void 0!==f&&f.invoke("destroy"),v.initialize())}),void 0!==m?m:this},k.fn.accordion.settings={name:"Accordion",namespace:"accordion",silent:!1,debug:!1,verbose:!1,performance:!0,on:"click",observeChanges:!0,exclusive:!0,collapsible:!0,closeNested:!1,animateChildren:!0,duration:350,easing:"easeOutQuad",onOpening:function(){},onClosing:function(){},onChanging:function(){},onOpen:function(){},onClose:function(){},onChange:function(){},error:{method:"The method you called is not defined"},className:{active:"active",animating:"animating",transition:"transition"},selector:{accordion:".accordion",title:".title",trigger:".title",ignore:".ui.dropdown",content:".content"}},k.extend(k.easing,{easeOutQuad:function(e){return 1-(1-e)*(1-e)}})}(jQuery,window,document);