11 lines
No EOL
7.2 KiB
JavaScript
11 lines
No EOL
7.2 KiB
JavaScript
/*
|
|
* # Fomantic UI - 2.9.3
|
|
* https://github.com/fomantic/Fomantic-UI
|
|
* https://fomantic-ui.com/
|
|
*
|
|
* Copyright 2023 Contributors
|
|
* Released under the MIT license
|
|
* https://opensource.org/licenses/MIT
|
|
*
|
|
*/
|
|
!function(O,x){"use strict";x=void 0!==x&&x.Math===Math?x:globalThis,O.fn.accordion=function(v){var p,e=O(this),m=Date.now(),h=[],b=v,y="string"==typeof b,C=[].slice.call(arguments,1);return e.each(function(){var e,a=O.isPlainObject(v)?O.extend(!0,{},O.fn.accordion.settings,v):O.extend({},O.fn.accordion.settings),s=a.className,n=a.namespace,l=a.selector,c=a.error,i="."+n,t="module-"+n,o=O(this),r=o.find(l.title),d=o.find(l.content),u=this,g=o.data(t),f={initialize:function(){f.debug("Initializing",o),f.bind.events(),a.observeChanges&&f.observeChanges(),f.instantiate()},instantiate:function(){g=f,o.data(t,f)},destroy:function(){f.debug("Destroying previous instance",o),o.off(i).removeData(t)},refresh:function(){r=o.find(l.title),d=o.find(l.content)},observeChanges:function(){"MutationObserver"in x&&((e=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",e))},bind:{events:function(){f.debug("Binding delegated events"),o.on(a.on+i,l.trigger,f.event.click)}},event:{click:function(e){0===O(e.target).closest(l.ignore).length&&f.toggle.call(this)}},toggle:function(e){var e=void 0!==e?"number"==typeof e?r.eq(e):O(e).closest(l.title):O(this).closest(l.title),n=e.next(d),i=n.hasClass(s.animating),n=n.hasClass(s.active),t=n&&!i,n=!n&&i;f.debug("Toggling visibility of content",e),t||n?a.collapsible?f.close.call(e):f.debug("Cannot close accordion content collapsing is disabled"):f.open.call(e)},open:function(e){var e=void 0!==e?"number"==typeof e?r.eq(e):O(e).closest(l.title):O(this).closest(l.title),n=e.next(d),i=n.hasClass(s.animating);n.hasClass(s.active)||i?f.debug("Accordion already open, skipping",n):(f.debug("Opening accordion content",e),a.onOpening.call(n),a.onChanging.call(n),a.exclusive&&f.closeOthers.call(e),e.addClass(s.active),n.stop(!0,!0).addClass(s.animating),a.animateChildren&&(void 0!==O.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,f.resetOpacity)),n.slideDown(a.duration,a.easing,function(){n.removeClass(s.animating).addClass(s.active),f.reset.display.call(this),a.onOpen.call(this),a.onChange.call(this)}))},close:function(e){var e=void 0!==e?"number"==typeof e?r.eq(e):O(e).closest(l.title):O(this).closest(l.title),n=e.next(d),i=n.hasClass(s.animating),t=n.hasClass(s.active);!t&&!(!t&&i)||t&&i||(f.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!==O.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,f.resetOpacity)),n.slideUp(a.duration,a.easing,function(){n.removeClass(s.animating).removeClass(s.active),f.reset.display.call(this),a.onClose.call(this),a.onChange.call(this)}))},closeOthers:function(e){var n,e=void 0!==e?r.eq(e):O(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(d):(n=e.find(t).not(i),e=e.find(o).find(t).not(i),(n=n.not(e)).next(d));0<n.length&&(f.debug("Exclusive enabled, closing other content",n),n.removeClass(s.active),o.removeClass(s.animating).stop(!0,!0),a.animateChildren&&(void 0!==O.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,f.resetOpacity)),o.slideUp(a.duration,a.easing,function(){O(this).removeClass(s.active),f.reset.display.call(this)}))},reset:{display:function(){f.verbose("Removing inline display from element",this);var e=O(this);e.css("display",""),""===e.attr("style")&&e.attr("style","").removeAttr("style")},opacity:function(){f.verbose("Removing inline opacity from element",this);var e=O(this);e.css("opacity",""),""===e.attr("style")&&e.attr("style","").removeAttr("style")}},setting:function(e,n){if(f.debug("Changing setting",e,n),O.isPlainObject(e))O.extend(!0,a,e);else{if(void 0===n)return a[e];O.isPlainObject(a[e])?O.extend(!0,a[e],n):a[e]=n}},internal:function(e,n){if(f.debug("Changing internal",e,n),void 0===n)return f[e];O.isPlainObject(e)?O.extend(!0,f,e):f[e]=n},debug:function(){!a.silent&&a.debug&&(a.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,a.name+":"),f.debug.apply(console,arguments)))},verbose:function(){!a.silent&&a.verbose&&a.debug&&(a.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,a.name+":"),f.verbose.apply(console,arguments)))},error:function(){a.silent||(f.error=Function.prototype.bind.call(console.error,console,a.name+":"),f.error.apply(console,arguments))},performance:{log:function(e){var n,i;a.performance&&(i=(n=Date.now())-(m||n),m=n,h.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:u,"Execution Time":i})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(function(){f.performance.display()},500)},display:function(){var e=a.name+":",i=0;m=!1,clearTimeout(f.performance.timer),O.each(h,function(e,n){i+=n["Execution Time"]}),e+=" "+i+"ms",0<h.length&&(console.groupCollapsed(e),console.table?console.table(h):O.each(h,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),h=[]}},invoke:function(t,e,n){var o,a,i,s,l=g;return e=e||C,n=n||u,"string"==typeof t&&void 0!==l&&(t=t.split(/[ .]/),o=t.length-1,O.each(t,function(e,n){var i=e!==o?n+t[e+1].charAt(0).toUpperCase()+t[e+1].slice(1):t;if(O.isPlainObject(l[i])&&e!==o)l=l[i];else{if(void 0!==l[i])return a=l[i],!1;{if(!O.isPlainObject(l[n])||e===o)return void 0!==l[n]?a=l[n]:f.error(c.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(p)?p.push(i):void 0!==p?p=[p,i]:void 0!==i&&(p=i),a}};y?(void 0===g&&f.initialize(),f.invoke(b)):(void 0!==g&&g.invoke("destroy"),f.initialize())}),void 0!==p?p:this},O.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"}},O.extend(O.easing,{easeOutQuad:function(e){return 1-(1-e)*(1-e)}})}(jQuery,window,document); |