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.

10 lines
5.9 KiB

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