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

!function(a,b,c,d){a.fn.accordion=function(b){var c,e=a(this),f=a.isPlainObject(b)?a.extend(!0,{},a.fn.accordion.settings,b):a.fn.accordion.settings,g=f.className,h=f.namespace,i=f.selector,j=f.error,k="."+h,l="module-"+h,m=e.selector||"",n=(new Date).getTime(),o=[],p=arguments[0],q="string"==typeof p,r=[].slice.call(arguments,1);return e.each(function(){var b,h=a(this),s=h.find(i.title),t=(h.find(i.icon),h.find(i.content)),u=this,v=h.data(l);b={initialize:function(){b.debug("Initializing accordion with bound events",h),s.on("click"+k,b.event.click),b.instantiate()},instantiate:function(){h.data(l,b)},destroy:function(){b.debug("Destroying previous accordion for",h),h.removeData(l),s.off(k)},event:{click:function(){b.verbose("Title clicked",this);var c=a(this),d=s.index(c);b.toggle(d)},resetStyle:function(){b.verbose("Resetting styles on element",this),a(this).removeAttr("style").children().removeAttr("style")}},toggle:function(a){b.debug("Toggling content content at index",a);var c=s.eq(a),d=c.next(t),e=d.is(":visible");e?f.collapsible?b.close(a):b.debug("Cannot close accordion content collapsing is disabled"):b.open(a)},open:function(c){var d=s.eq(c),e=d.next(t),h=s.filter("."+g.active),i=h.next(s),j=h.size()>0;e.is(":animated")||(b.debug("Opening accordion content",d),f.exclusive&&j&&(h.removeClass(g.active),i.stop().children().animate({opacity:0},f.speed,b.event.resetStyle).end().slideUp(f.speed,f.easing,function(){i.removeClass(g.active).removeAttr("style").children().removeAttr("style")})),d.addClass(g.active),e.stop().children().removeAttr("style").end().slideDown(f.speed,f.easing,function(){e.addClass(g.active).removeAttr("style"),a.proxy(f.onOpen,e)(),a.proxy(f.onChange,e)()}))},close:function(c){var d=s.eq(c),e=d.next(t);b.debug("Closing accordion content",d),d.removeClass(g.active),e.removeClass(g.active).show().stop().children().animate({opacity:0},f.speed,b.event.resetStyle).end().slideUp(f.speed,f.easing,function(){e.removeAttr("style"),a.proxy(f.onClose,e)(),a.proxy(f.onChange,e)()})},setting:function(c,e){return b.debug("Changing setting",c,e),e===d?f[c]:(a.isPlainObject(c)?a.extend(!0,f,c):f[c]=e,void 0)},internal:function(c,e){return b.debug("Changing internal",c,e),e===d?b[c]:(a.isPlainObject(c)?a.extend(!0,b,c):b[c]=e,void 0)},debug:function(){f.debug&&(f.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,f.moduleName+":"),b.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,f.moduleName+":"),b.verbose.apply(console,arguments)))},error:function(){b.error=Function.prototype.bind.call(console.error,console,f.moduleName+":"),b.error.apply(console,arguments)},performance:{log:function(a){var c,d,e;f.performance&&(c=(new Date).getTime(),e=n||c,d=c-e,n=c,o.push({Element:u,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":d})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,100)},display:function(){var c=f.name+":",g=0;n=!1,clearTimeout(b.performance.timer),a.each(o,function(a,b){g+=b["Execution Time"]}),c+=" "+g+"ms",m&&(c+=" '"+m+"'"),e.size()>1&&(c+=" ("+e.size()+")"),(console.group!==d||console.table!==d)&&o.length>0&&(console.groupCollapsed(c),console.table?console.table(o):a.each(o,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),o=[]}},invoke:function(e,f,g){var h,i,k;return f=f||r,g=u||g,"string"==typeof e&&v!==d&&(e=e.split(/[\. ]/),h=e.length-1,a.each(e,function(c,f){var g=c!=h?f+e[c+1].charAt(0).toUpperCase()+e[c+1].slice(1):e;if(a.isPlainObject(v[f])&&c!=h)v=v[f];else{if(!a.isPlainObject(v[g])||c==h)return v[f]!==d?(i=v[f],!1):v[g]!==d?(i=v[g],!1):(b.error(j.method),!1);v=v[g]}})),a.isFunction(i)?k=i.apply(g,f):i!==d&&(k=i),a.isArray(c)?c.push(k):"string"==typeof c?c=[c,k]:k!==d&&(c=k),i}},q?(v===d&&b.initialize(),b.invoke(p)):(v!==d&&b.destroy(),b.initialize())}),c!==d?c:this},a.fn.accordion.settings={name:"Accordion",namespace:"accordion",debug:!0,verbose:!0,performance:!0,exclusive:!0,collapsible:!0,onOpen:function(){},onClose:function(){},onChange:function(){},error:{method:"The method you called is not defined"},className:{active:"active",hover:"hover"},selector:{title:".title",icon:".icon",content:".content"},speed:500,easing:"easeInOutQuint"}}(jQuery,window,document);