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.
 
 
 

11 lines
5.8 KiB

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