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

(function(e,n,o,t){e.fn.accordion=function(n){var o,i=e(this),c=e.isPlainObject(n)?e.extend(!0,{},e.fn.accordion.settings,n):e.fn.accordion.settings,a=("."+c.namespace,"module-"+c.namespace,i.selector||""),s=(new Date).getTime(),r=[],l=arguments[0],d="string"==typeof l,u=[].slice.call(arguments,1);return i.each(function(){var n,i=e(this),m=i.find(c.selector.title),p=(i.find(c.selector.icon),i.find(c.selector.content)),g=(i.selector||"",this),f=i.data("module-"+c.namespace),v=c.className,b=(c.metadata,c.namespace),h=(c.animation,c.errors);n={initialize:function(){n.debug("Initializing accordion with bound events",i),m.on("click",n.event.click),i.data("module",n)},destroy:function(){n.debug("Destroying previous accordion for",i),i.off(b)},event:{click:function(){var o=e(this),t=m.index(o),i=o.next(p).hasClass(v.active);n.verbose("Accordion title clicked",o),i?c.collapsible?n.close(t):n.debug("Cannot close accordion content collapsing is disabled"):n.open(t)}},open:function(o){var t=m.eq(o),i=t.next(p),a=m.filter("."+v.active),s=a.next(m),r=a.size()>0;n.debug("Opening accordion content",t),c.exclusive&&r&&(a.removeClass(v.active),s.stop().children().animate({opacity:0},c.speed).end().slideUp(c.speed,c.easing,function(){s.removeClass(v.active).removeAttr("style").children().removeAttr("style")})),t.addClass(v.active),i.stop().children().removeAttr("style").end().slideDown(c.speed,c.easing,function(){i.addClass(v.active).removeAttr("style"),e.proxy(c.onOpen,i)(),e.proxy(c.onChange,i)()})},close:function(o){var t=m.eq(o),i=t.next(p);n.debug("Closing accordion content",t),t.removeClass(v.active),i.removeClass(v.active).show().stop().slideUp(c.speed,c.easing,function(){i.removeAttr("style"),e.proxy(c.onClose,i)(),e.proxy(c.onChange,i)()})},setting:function(o,i){return n.debug("Changing setting",o,i),i===t?c[o]:(e.isPlainObject(o)?e.extend(!0,c,o):c[o]=i,t)},internal:function(o,i){return n.debug("Changing internal",o,i),i===t?n[o]:(e.isPlainObject(o)?e.extend(!0,n,o):n[o]=i,t)},debug:function(){c.debug&&(c.performance?n.performance.log(arguments):n.debug=Function.prototype.bind.call(console.info,console,c.moduleName+":"))},verbose:function(){c.verbose&&c.debug&&(c.performance?n.performance.log(arguments):n.verbose=Function.prototype.bind.call(console.info,console,c.moduleName+":"))},error:function(){n.error=Function.prototype.bind.call(console.log,console,c.moduleName+":")},performance:{log:function(e){var o,t,i;c.performance&&(o=(new Date).getTime(),i=s||o,t=o-i,s=o,r.push({Element:g,Name:e[0],Arguments:e[1]||"","Execution Time":t})),clearTimeout(n.performance.timer),n.performance.timer=setTimeout(n.performance.display,100)},display:function(){var n=c.moduleName+":",o=0;s=!1,e.each(r,function(e,n){o+=n["Execution Time"]}),n+=" "+o+"ms",a&&(n+=" '"+a+"'"),(console.group!==t||console.table!==t)&&r.length>0&&(console.groupCollapsed(n),console.table?console.table(r):e.each(r,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),r=[]}},invoke:function(o,i,c){var a,s;return i=i||u,c=g||c,"string"==typeof o&&f!==t&&(o=o.split("."),a=o.length-1,e.each(o,function(o,i){return e.isPlainObject(f[i])&&o!=a?(f=f[i],!0):f[i]!==t?(s=f[i],!0):(n.error(h.method),!1)})),e.isFunction(s)?(f.verbose("Executing invoked function",s),s.apply(c,i)):s||!1}},d?(f===t&&n.initialize(),o=n.invoke(l)):(f!==t&&n.destroy(),n.initialize())}),o?o:this},e.fn.accordion.settings={moduleName:"Accordion",debug:!0,verbose:!0,performance:!1,exclusive:!0,collapsible:!0,onOpen:function(){},onClose:function(){},onChange:function(){},errors:{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);