11 lines
6.7 KiB
JavaScript
11 lines
6.7 KiB
JavaScript
|
/*!
|
||
|
* # Semantic UI 1.11.4 - Accordion
|
||
|
* http://github.com/semantic-org/semantic-ui/
|
||
|
*
|
||
|
*
|
||
|
* 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,a=e(this),s=(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 a.each(function(){var d,m,g=e.isPlainObject(t)?e.extend(!0,{},e.fn.accordion.settings,t):e.extend({},e.fn.accordion.settings),f=g.className,p=g.namespace,v=g.selector,h=g.error,b="."+p,y="module-"+p,C=a.selector||"",O=e(this),x=O.find(v.title),F=O.find(v.content),T=this,q=O.data(y);m={initialize:function(){m.debug("Initializing",O),m.bind.events(),m.observeChanges(),m.instantiate()},instantiate:function(){q=m,O.data(y,m)},destroy:function(){m.debug("Destroying previous instance",O),O.off(b).removeData(y)},refresh:function(){x=O.find(v.title),F=O.find(v.content)},observeChanges:function(){"MutationObserver"in n&&(d=new MutationObserver(function(){m.debug("DOM tree modified, updating selector cache"),m.refresh()}),d.observe(T,{childList:!0,subtree:!0}),m.debug("Setting up mutation observer",d))},bind:{events:function(){m.debug("Binding delegated events"),O.on("click"+b,v.trigger,m.event.click)}},event:{click:function(){m.toggle.call(this)}},toggle:function(n){var t=n!==i?"number"==typeof n?x.eq(n):e(n).closest(v.title):e(this).closest(v.title),o=t.next(F),a=o.hasClass(f.animating),s=o.hasClass(f.active),r=s&&!a,c=!s&&a;m.debug("Toggling visibility of content",t),r||c?g.collapsible?m.close.call(t):m.debug("Cannot close accordion content collapsing is disabled"):m.open.call(t)},open:function(n){var t=n!==i?"number"==typeof n?x.eq(n):e(n).closest(v.title):e(this).closest(v.title),o=t.next(F),a=o.hasClass(f.animating),s=o.hasClass(f.active),r=!s&&!a;r&&(m.debug("Opening accordion content",t),g.exclusive&&m.closeOthers.call(t),t.addClass(f.active),o.addClass(f.animating),g.animateChildren&&(e.fn.transition!==i&&O.transition("is supported")?o.children().transition({animation:"fade in",queue:!1,useFailSafe:!0,debug:g.debug,verbose:g.verbose,duration:g.duration}):o.children().stop(!0).animate({opacity:1},g.duration,m.resetOpacity)),o.stop(!0).slideDown(g.duration,g.easing,function(){o.removeClass(f.animating).addClass(f.active),m.reset.display.call(this),g.onOpen.call(this),g.onChange.call(this)}))},close:function(n){var t=n!==i?"number"==typeof n?x.eq(n):e(n).closest(v.title):e(this).closest(v.title),o=t.next(F),a=o.hasClass(f.animating),s=o.hasClass(f.active),r=!s&&a,c=s&&a;!s&&!r||c||(m.debug("Closing accordion content",o),t.removeClass(f.active),o.addClass(f.animating),g.animateChildren&&(e.fn.transition!==i&&O.transition("is supported")?o.children().transition({animation:"fade out",queue:!1,useFailSafe:!0,debug:g.debug,verbose:g.verbose,duration:g.duration}):o.children().stop(!0).animate({opacity:0},g.duration,m.resetOpacity)),o.stop(!0).slideUp(g.duration,g.easing,function(){o.removeClass(f.animating).removeClass(f.active),m.reset.display.call(this),g.onClose.call(this),g.onChange.call(this)}))},closeOthers:function(n){var t,o,a,s=n!==i?x.eq(n):e(this).closest(v.title),r=s.parents(v.content).prev(v.title),c=s.closest(v.accordion),l=v.title+"."+f.active+":visible",u=v.content+"."+f.active+":visible";g.closeNested?(t=c.find(l).not(r),a=t.next(F)):(t=c.find(l).not(r),o=c.find(u).find(l).not(r),t=t.not(o),a=t.next(F)),t.length>0&&(m.debug("Exclusive enabled, closing other content",t),t.removeClass(f.active),g.animateChildren&&(e.fn.transition!==i&&O.transition("is supported")?a.children().transition({animation:"fade out",useFailSafe:!0,debug:g.debug,verbose:g.verbose,duration:g.duration}):a.children().stop().animate({opacity:0},g.duration,m.resetOpacity)),a.stop().slideUp(g.duration,g.easing,function(){e(this).removeClass(f.active),m.reset.display.call(this)}))},reset:{display:function(){m.verbose("Removing inline display from element",this),e(this).css("display",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")},opacity:function(){m.verbose("Removing inline opacity from element",this),e(thi
|