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