wishthis/semantic/dist/components/accordion.min.js
2022-02-23 22:46:34 +01:00

11 lines
No EOL
7.3 KiB
JavaScript

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