hanayo/static/components/accordion.min.js

10 lines
7.1 KiB
JavaScript
Raw Normal View History

2019-02-23 13:29:15 +00:00
/*!
* # Semantic UI 2.2.6 - Accordion
* http://github.com/semantic-org/semantic-ui/
*
*
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
!function(e,n,t,i){"use strict";n="undefined"!=typeof n&&n.Math==Math?n:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),e.fn.accordion=function(t){var o,a=e(this),s=(new Date).getTime(),r=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);n.requestAnimationFrame||n.mozRequestAnimationFrame||n.webkitRequestAnimationFrame||n.msRequestAnimationFrame||function(e){setTimeout(e,0)};return a.each(function(){var d,g,f=e.isPlainObject(t)?e.extend(!0,{},e.fn.accordion.settings,t):e.extend({},e.fn.accordion.settings),m=f.className,p=f.namespace,h=f.selector,v=f.error,b="."+p,y="module-"+p,C=a.selector||"",O=e(this),x=O.find(h.title),F=O.find(h.content),A=this,T=O.data(y);g={initialize:function(){g.debug("Initializing",O),g.bind.events(),f.observeChanges&&g.observeChanges(),g.instantiate()},instantiate:function(){T=g,O.data(y,g)},destroy:function(){g.debug("Destroying previous instance",O),O.off(b).removeData(y)},refresh:function(){x=O.find(h.title),F=O.find(h.content)},observeChanges:function(){"MutationObserver"in n&&(d=new MutationObserver(function(e){g.debug("DOM tree modified, updating selector cache"),g.refresh()}),d.observe(A,{childList:!0,subtree:!0}),g.debug("Setting up mutation observer",d))},bind:{events:function(){g.debug("Binding delegated events"),O.on(f.on+b,h.trigger,g.event.click)}},event:{click:function(){g.toggle.call(this)}},toggle:function(n){var t=n!==i?"number"==typeof n?x.eq(n):e(n).closest(h.title):e(this).closest(h.title),o=t.next(F),a=o.hasClass(m.animating),s=o.hasClass(m.active),r=s&&!a,c=!s&&a;g.debug("Toggling visibility of content",t),r||c?f.collapsible?g.close.call(t):g.debug("Cannot close accordion content collapsing is disabled"):g.open.call(t)},open:function(n){var t=n!==i?"number"==typeof n?x.eq(n):e(n).closest(h.title):e(this).closest(h.title),o=t.next(F),a=o.hasClass(m.animating),s=o.hasClass(m.active),r=s||a;return r?void g.debug("Accordion already open, skipping",o):(g.debug("Opening accordion content",t),f.onOpening.call(o),f.exclusive&&g.closeOthers.call(t),t.addClass(m.active),o.stop(!0,!0).addClass(m.animating),f.animateChildren&&(e.fn.transition!==i&&O.transition("is supported")?o.children().transition({animation:"fade in",queue:!1,useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):o.children().stop(!0,!0).animate({opacity:1},f.duration,g.resetOpacity)),void o.slideDown(f.duration,f.easing,function(){o.removeClass(m.animating).addClass(m.active),g.reset.display.call(this),f.onOpen.call(this),f.onChange.call(this)}))},close:function(n){var t=n!==i?"number"==typeof n?x.eq(n):e(n).closest(h.title):e(this).closest(h.title),o=t.next(F),a=o.hasClass(m.animating),s=o.hasClass(m.active),r=!s&&a,c=s&&a;!s&&!r||c||(g.debug("Closing accordion content",o),f.onClosing.call(o),t.removeClass(m.active),o.stop(!0,!0).addClass(m.animating),f.animateChildren&&(e.fn.transition!==i&&O.transition("is supported")?o.children().transition({animation:"fade out",queue:!1,useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):o.children().stop(!0,!0).animate({opacity:0},f.duration,g.resetOpacity)),o.slideUp(f.duration,f.easing,function(){o.removeClass(m.animating).removeClass(m.active),g.reset.display.call(this),f.onClose.call(this),f.onChange.call(this)}))},closeOthers:function(n){var t,o,a,s=n!==i?x.eq(n):e(this).closest(h.title),r=s.parents(h.content).prev(h.title),c=s.closest(h.accordion),l=h.title+"."+m.active+":visible",u=h.content+"."+m.active+":visible";f.closeNested?(t=c.find(l).not(r),a=t.next(F)):(t=c.find(l).not(r),o=c.find(u).find(l).not(r),t=t.not(o),a=t.next(F)),t.length>0&&(g.debug("Exclusive enabled, closing other content",t),t.removeClass(m.active),a.removeClass(m.animating).stop(!0,!0),f.animateChildren&&(e.fn.transition!==i&&O.transition("is supported")?a.children().transition({animation:"fade out",useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):a.children().stop(!0,!0).animate({opacity:0},f.duration,g.resetOpacity)),a.slideUp(f.duration,f.easing,function(){e(this).removeClass(m.active),g.reset.displa