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.
1 lines
7.0 KiB
1 lines
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)}))},reset:{display:function(){u.verbose("Removing inline display from element",this),e(this).css("display",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")},opacity:function(){u.verbose("Removing inline opacity from element",this),e(this).css("opacity",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")}},setting:function(n,t){if(u.debug("Changing setting",n,t),e.isPlainObject(n))e.extend(!0,g,n);else{if(void 0===t)return g[n];e.isPlainObject(g[n])?e.extend(!0,g[n],t):g[n]=t}},internal:function(n,t){if(u.debug("Changing internal",n,t),void 0===t)return u[n];e.isPlainObject(n)?e.extend(!0,u,n):u[n]=t},debug:function(){!g.silent&&g.debug&&(g.performance?u.performance.log(arguments):(u.debug=Function.prototype.bind.call(console.info,console,g.name+":"),u.debug.apply(console,arguments)))},verbose:function(){!g.silent&&g.verbose&&g.debug&&(g.performance?u.performance.log(arguments):(u.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),u.verbose.apply(console,arguments)))},error:function(){g.silent||(u.error=Function.prototype.bind.call(console.error,console,g.name+":"),u.error.apply(console,arguments))},performance:{log:function(e){var n,t,i;g.performance&&(n=(new Date).getTime(),i=a||n,t=n-i,a=n,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:F,"Execution Time":t})),clearTimeout(u.performance.timer),u.performance.timer=setTimeout(u.performance.display,500)},display:function(){var n=g.name+":",t=0;a=!1,clearTimeout(u.performance.timer),e.each(s,function(e,n){t+=n["Execution Time"]}),n+=" "+t+"ms",y&&(n+=" '"+y+"'"),(void 0!==console.group||void 0!==console.table)&&s.length>0&&(console.groupCollapsed(n),console.table?console.table(s):e.each(s,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(n,t,o){var a,s,r,c=A;return t=t||l,o=F||o,"string"==typeof n&&void 0!==c&&(n=n.split(/[\. ]/),a=n.length-1,e.each(n,function(t,i){var o=t!=a?i+n[t+1].charAt(0).toUpperCase()+n[t+1].slice(1):n;if(e.isPlainObject(c[o])&&t!=a)c=c[o];else{if(void 0!==c[o])return s=c[o],!1;if(!e.isPlainObject(c[i])||t==a)return void 0!==c[i]?(s=c[i],!1):(u.error(p.method,n),!1);c=c[i]}})),e.isFunction(s)?r=s.apply(o,t):void 0!==s&&(r=s),e.isArray(i)?i.push(r):void 0!==i?i=[i,r]:void 0!==r&&(i=r),s}},c?(void 0===A&&u.initialize(),u.invoke(r)):(void 0!==A&&A.invoke("destroy"),u.initialize())}),void 0!==i?i:this},e.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(){},onOpen:function(){},onClosing:function(){},onClose:function(){},onChange:function(){},error:{method:"The method you called is not defined"},className:{active:"active",animating:"animating"},selector:{accordion:".accordion",title:".title",trigger:".title",content:".content"}},e.extend(e.easing,{easeOutQuad:function(e,n,t,i,o){return-i*(n/=o)*(n-2)+t}})}(jQuery,window,document);
|