You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/static/semantic/components/accordion.min.js

1 line
7.0 KiB

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