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
5.6 KiB

!function(a,b,c,d){"use strict";a.fn.accordion=function(c){{var e,f=a(this),g=(new Date).getTime(),h=[],i=arguments[0],j="string"==typeof i,k=[].slice.call(arguments,1);b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||b.msRequestAnimationFrame||function(a){setTimeout(a,0)}}return f.each(function(){var b,l,m=a.isPlainObject(c)?a.extend(!0,{},a.fn.accordion.settings,c):a.extend({},a.fn.accordion.settings),n=m.className,o=m.namespace,p=m.selector,q=(m.error,"."+o),r="module-"+o,s=f.selector||"",t=a(this),u=t.find(p.title),v=t.find(p.content),w=this,x=t.data(r);l={initialize:function(){l.debug("Initializing accordion with bound events",t),t.on("click"+q,p.title,l.event.click),l.observeChanges(),l.instantiate()},instantiate:function(){x=l,t.data(r,l)},destroy:function(){l.debug("Destroying previous accordion for",t),t.removeData(r),u.off(q)},refresh:function(){u=t.find(p.title),v=t.find(p.content)},observeChanges:function(){MutationObserver!==d&&(b=new MutationObserver(function(){l.debug("DOM tree modified, updating selector cache"),l.refresh()}),b.observe(w,{childList:!0,subtree:!0}),l.debug("Setting up mutation observer",b))},event:{click:function(){a.proxy(l.toggle,this)()}},toggle:function(b){var c=b!==d?"number"==typeof b?u.eq(b):a(b):a(this),e=c.next(v),f=e.is(":visible");l.debug("Toggling visibility of content",c),f?m.collapsible?a.proxy(l.close,c)():l.debug("Cannot close accordion content collapsing is disabled"):a.proxy(l.open,c)()},open:function(b){var c=b!==d?"number"==typeof b?u.eq(b):a(b):a(this),e=c.next(v),f=e.is(":animated"),g=e.hasClass(n.active);f||g||(l.debug("Opening accordion content",c),m.exclusive&&a.proxy(l.closeOthers,c)(),c.addClass(n.active),e.stop().children().stop().animate({opacity:1},m.duration,l.reset.display).end().slideDown(m.duration,m.easing,function(){e.addClass(n.active),a.proxy(l.reset.display,this)(),a.proxy(m.onOpen,this)(),a.proxy(m.onChange,this)()}))},close:function(b){var c=b!==d?"number"==typeof b?u.eq(b):a(b):a(this),e=c.next(v),f=e.hasClass(n.active);f&&(l.debug("Closing accordion content",e),c.removeClass(n.active),e.removeClass(n.active).show().stop().children().stop().animate({opacity:0},m.duration,l.reset.opacity).end().slideUp(m.duration,m.easing,function(){a.proxy(l.reset.display,this)(),a.proxy(m.onClose,this)(),a.proxy(m.onChange,this)()}))},closeOthers:function(b){var c,e,f,g=b!==d?u.eq(b):a(this),h=g.parents(p.content).prev(p.title),i=g.closest(p.accordion),j=p.title+"."+n.active+":visible",k=p.content+"."+n.active+":visible";m.closeNested?(c=i.find(j).not(h),f=c.next(v)):(c=i.find(j).not(h),e=i.find(k).find(j).not(h),c=c.not(e),f=c.next(v)),c.size()>0&&(l.debug("Exclusive enabled, closing other content",c),c.removeClass(n.active),f.stop().children().stop().animate({opacity:0},m.duration,l.resetOpacity).end().slideUp(m.duration,m.easing,function(){a(this).removeClass(n.active),a.proxy(l.reset.display,this)()}))},reset:{display:function(){l.verbose("Removing inline display from element",this),a(this).css("display",""),""===a(this).attr("style")&&a(this).attr("style","").removeAttr("style")},opacity:function(){l.verbose("Removing inline opacity from element",this),a(this).css("opacity",""),""===a(this).attr("style")&&a(this).attr("style","").removeAttr("style")}},setting:function(b,c){if(l.debug("Changing setting",b,c),a.isPlainObject(b))a.extend(!0,m,b);else{if(c===d)return m[b];m[b]=c}},internal:function(b,c){return l.debug("Changing internal",b,c),c===d?l[b]:void(a.isPlainObject(b)?a.extend(!0,l,b):l[b]=c)},debug:function(){m.debug&&(m.performance?l.performance.log(arguments):(l.debug=Function.prototype.bind.call(console.info,console,m.name+":"),l.debug.apply(console,arguments)))},verbose:function(){m.verbose&&m.debug&&(m.performance?l.performance.log(arguments):(l.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),l.verbose.apply(console,arguments)))},error:function(){l.error=Function.prototype.bind.call(console.error,console,m.name+":"),l.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;m.performance&&(b=(new Date).getTime(),d=g||b,c=b-d,g=b,h.push({Name:a[0],Arguments:[].slice.call(a,1)||"",Element:w,"Execution Time":c})),clearTimeout(l.performance.timer),l.performance.timer=setTimeout(l.performance.display,100)},display:function(){var b=m.name+":",c=0;g=!1,clearTimeout(l.performance.timer),a.each(h,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",s&&(b+=" '"+s+"'"),(console.group!==d||console.table!==d)&&h.length>0&&(console.groupCollapsed(b),console.table?console.table(h):a.each(h,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),h=[]}},invoke:function(b,c,f){var g,h,i,j=x;return c=c||k,f=w||f,"string"==typeof b&&j!==d&&(b=b.split(/[\. ]/),g=b.length-1,a.each(b,function(c,e){var f=c!=g?e+b[c+1].charAt(0).toUpperCase()+b[c+1].slice(1):b;if(a.isPlainObject(j[f])&&c!=g)j=j[f];else{if(j[f]!==d)return h=j[f],!1;if(!a.isPlainObject(j[e])||c==g)return j[e]!==d?(h=j[e],!1):!1;j=j[e]}})),a.isFunction(h)?i=h.apply(f,c):h!==d&&(i=h),a.isArray(e)?e.push(i):e!==d?e=[e,i]:i!==d&&(e=i),h}},j?(x===d&&l.initialize(),l.invoke(i)):(x!==d&&l.destroy(),l.initialize())}),e!==d?e:this},a.fn.accordion.settings={name:"Accordion",namespace:"accordion",debug:!1,verbose:!0,performance:!0,exclusive:!0,collapsible:!0,closeNested:!1,duration:500,easing:"easeInOutQuint",onOpen:function(){},onClose:function(){},onChange:function(){},error:{method:"The method you called is not defined"},className:{active:"active"},selector:{accordion:".accordion",title:".title",content:".content"}},a.extend(a.easing,{easeInOutQuint:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b*b*b*b+c:d/2*((b-=2)*b*b*b*b+2)+c}})}(jQuery,window,document);