template.js.base.accordion.min.js Maven / Gradle / Ivy
'use strict';(function(c){"function"===typeof define&&define.amd?define(["jquery","../version","../keycode","../unique-id","../widget"],c):c(jQuery)})(function(c){return c.widget("ui.accordion",{version:"1.12.1",options:{active:0,animate:{},classes:{"ui-accordion-header":"ui-corner-top","ui-accordion-header-collapsed":"ui-corner-all","ui-accordion-content":"ui-corner-bottom"},collapsible:!1,event:"click",header:"\x3e li \x3e :first-child, \x3e :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",
header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},hideProps:{borderTopWidth:"hide",borderBottomWidth:"hide",paddingTop:"hide",paddingBottom:"hide",height:"hide"},showProps:{borderTopWidth:"show",borderBottomWidth:"show",paddingTop:"show",paddingBottom:"show",height:"show"},_create:function(){var a=this.options;this.prevShow=this.prevHide=c();this._addClass("ui-accordion","ui-widget ui-helper-reset");this.element.attr("role","tablist");a.collapsible||!1!==a.active&&null!=a.active||
(a.active=0);this._processPanels();0>a.active&&(a.active+=this.headers.length);this._refresh()},_getCreateEventData:function(){return{header:this.active,panel:this.active.length?this.active.next():c()}},_createIcons:function(){var a,b=this.options.icons;b&&(a=c("\x3cspan\x3e"),this._addClass(a,"ui-accordion-header-icon","ui-icon "+b.header),a.prependTo(this.headers),a=this.active.children(".ui-accordion-header-icon"),this._removeClass(a,b.header)._addClass(a,null,b.activeHeader)._addClass(this.headers,
"ui-accordion-icons"))},_destroyIcons:function(){this._removeClass(this.headers,"ui-accordion-icons");this.headers.children(".ui-accordion-header-icon").remove()},_destroy:function(){var a;this.element.removeAttr("role");this.headers.removeAttr("role aria-expanded aria-selected aria-controls tabIndex").removeUniqueId();this._destroyIcons();a=this.headers.next().css("display","").removeAttr("role aria-hidden aria-labelledby").removeUniqueId();"content"!==this.options.heightStyle&&a.css("height","")},
_setOption:function(a,b){"active"===a?this._activate(b):("event"===a&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(b)),this._super(a,b),"collapsible"!==a||b||!1!==this.options.active||this._activate(0),"icons"===a&&(this._destroyIcons(),b&&this._createIcons()))},_setOptionDisabled:function(a){this._super(a);this.element.attr("aria-disabled",a);this._toggleClass(null,"ui-state-disabled",!!a);this._toggleClass(this.headers.add(this.headers.next()),null,"ui-state-disabled",
!!a)},_keydown:function(a){if(!a.altKey&&!a.ctrlKey){var b=c.ui.keyCode,d=this.headers.length,f=this.headers.index(a.target),e=!1;switch(a.keyCode){case b.RIGHT:case b.DOWN:e=this.headers[(f+1)%d];break;case b.LEFT:case b.UP:e=this.headers[(f-1+d)%d];break;case b.SPACE:case b.ENTER:this._eventHandler(a);break;case b.HOME:e=this.headers[0];break;case b.END:e=this.headers[d-1]}e&&(c(a.target).attr("tabIndex",-1),c(e).attr("tabIndex",0),c(e).trigger("focus"),a.preventDefault())}},_panelKeyDown:function(a){a.keyCode===
c.ui.keyCode.UP&&a.ctrlKey&&c(a.currentTarget).prev().trigger("focus")},refresh:function(){var a=this.options;this._processPanels();!1===a.active&&!0===a.collapsible||!this.headers.length?(a.active=!1,this.active=c()):!1===a.active?this._activate(0):this.active.length&&!c.contains(this.element[0],this.active[0])?this.headers.length===this.headers.find(".ui-state-disabled").length?(a.active=!1,this.active=c()):this._activate(Math.max(0,a.active-1)):a.active=this.headers.index(this.active);this._destroyIcons();
this._refresh()},_processPanels:function(){var a=this.headers,b=this.panels;this.headers=this.element.find(this.options.header);this._addClass(this.headers,"ui-accordion-header ui-accordion-header-collapsed","ui-state-default");this.panels=this.headers.next().filter(":not(.ui-accordion-content-active)").hide();this._addClass(this.panels,"ui-accordion-content","ui-helper-reset ui-widget-content");b&&(this._off(a.not(this.headers)),this._off(b.not(this.panels)))},_refresh:function(){var a,b=this.options,
d=b.heightStyle,f=this.element.parent();this.active=this._findActive(b.active);this._addClass(this.active,"ui-accordion-header-active","ui-state-active")._removeClass(this.active,"ui-accordion-header-collapsed");this._addClass(this.active.next(),"ui-accordion-content-active");this.active.next().show();this.headers.attr("role","tab").each(function(){var a=c(this),b=a.uniqueId().attr("id"),d=a.next(),f=d.uniqueId().attr("id");a.attr("aria-controls",f);d.attr("aria-labelledby",b)}).next().attr("role",
"tabpanel");this.headers.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}).next().attr({"aria-hidden":"true"}).hide();this.active.length?this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}).next().attr({"aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0);this._createIcons();this._setupEvents(b.event);"fill"===d?(a=f.height(),this.element.siblings(":visible").each(function(){var b=c(this),d=b.css("position");"absolute"!==d&&"fixed"!==
d&&(a-=b.outerHeight(!0))}),this.headers.each(function(){a-=c(this).outerHeight(!0)}),this.headers.next().each(function(){c(this).height(Math.max(0,a-c(this).innerHeight()+c(this).height()))}).css("overflow","auto")):"auto"===d&&(a=0,this.headers.next().each(function(){var b=c(this).is(":visible");b||c(this).show();a=Math.max(a,c(this).css("height","").height());b||c(this).hide()}).height(a))},_activate:function(a){a=this._findActive(a)[0];a!==this.active[0]&&(a=a||this.active[0],this._eventHandler({target:a,
currentTarget:a,preventDefault:c.noop}))},_findActive:function(a){return"number"===typeof a?this.headers.eq(a):c()},_setupEvents:function(a){var b={keydown:"_keydown"};a&&c.each(a.split(" "),function(a,c){b[c]="_eventHandler"});this._off(this.headers.add(this.headers.next()));this._on(this.headers,b);this._on(this.headers.next(),{keydown:"_panelKeyDown"});this._hoverable(this.headers);this._focusable(this.headers)},_eventHandler:function(a){var b,d=this.options,f=this.active,e=c(a.currentTarget),
g=(b=e[0]===f[0])&&d.collapsible,k=g?c():e.next(),l=f.next(),k={oldHeader:f,oldPanel:l,newHeader:g?c():e,newPanel:k};a.preventDefault();b&&!d.collapsible||!1===this._trigger("beforeActivate",a,k)||(d.active=g?!1:this.headers.index(e),this.active=b?c():e,this._toggle(k),this._removeClass(f,"ui-accordion-header-active","ui-state-active"),d.icons&&(a=f.children(".ui-accordion-header-icon"),this._removeClass(a,null,d.icons.activeHeader)._addClass(a,null,d.icons.header)),b||(this._removeClass(e,"ui-accordion-header-collapsed")._addClass(e,
"ui-accordion-header-active","ui-state-active"),d.icons&&(b=e.children(".ui-accordion-header-icon"),this._removeClass(b,null,d.icons.header)._addClass(b,null,d.icons.activeHeader)),this._addClass(e.next(),"ui-accordion-content-active")))},_toggle:function(a){var b=a.newPanel,d=this.prevShow.length?this.prevShow:a.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0);this.prevShow=b;this.prevHide=d;this.options.animate?this._animate(b,d,a):(d.hide(),b.show(),this._toggleComplete(a));d.attr({"aria-hidden":"true"});
d.prev().attr({"aria-selected":"false","aria-expanded":"false"});b.length&&d.length?d.prev().attr({tabIndex:-1,"aria-expanded":"false"}):b.length&&this.headers.filter(function(){return 0===parseInt(c(this).attr("tabIndex"),10)}).attr("tabIndex",-1);b.attr("aria-hidden","false").prev().attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_animate:function(a,b,c){var f,e,g,k=this,l=0,p=a.css("box-sizing"),h=a.length&&(!b.length||a.index()
© 2015 - 2024 Weber Informatics LLC | Privacy Policy