: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* jQuery UI Accordion 1.13.3
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license.
* https://jquery.org/license
/* eslint-disable max-len */
//>>description: Displays collapsible content panels for presenting information in a limited amount of space.
/* eslint-enable max-len */
//>>docs: https://api.jqueryui.com/accordion/
//>>demos: https://jqueryui.com/accordion/
//>>css.structure: ../../themes/base/core.css
//>>css.structure: ../../themes/base/accordion.css
//>>css.theme: ../../themes/base/theme.css
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
return $.widget( "ui.accordion", {
"ui-accordion-header": "ui-corner-top",
"ui-accordion-header-collapsed": "ui-corner-all",
"ui-accordion-content": "ui-corner-bottom"
header: function( elem ) {
return elem.find( "> li > :first-child" ).add( elem.find( "> :not(li)" ).even() );
activeHeader: "ui-icon-triangle-1-s",
header: "ui-icon-triangle-1-e"
borderBottomWidth: "hide",
borderBottomWidth: "show",
var options = this.options;
this.prevShow = this.prevHide = $();
this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
this.element.attr( "role", "tablist" );
// Don't allow collapsible: false and active: false / null
if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
// handle negative values
if ( options.active < 0 ) {
options.active += this.headers.length;
_getCreateEventData: function() {
panel: !this.active.length ? $() : this.active.next()
_createIcons: function() {
icons = this.options.icons;
this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header );
icon.prependTo( this.headers );
children = this.active.children( ".ui-accordion-header-icon" );
this._removeClass( children, icons.header )
._addClass( children, null, icons.activeHeader )
._addClass( this.headers, "ui-accordion-icons" );
_destroyIcons: function() {
this._removeClass( this.headers, "ui-accordion-icons" );
this.headers.children( ".ui-accordion-header-icon" ).remove();
this.element.removeAttr( "role" );
.removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
// Clean up content panels
contents = this.headers.next()
.removeAttr( "role aria-hidden aria-labelledby" )
if ( this.options.heightStyle !== "content" ) {
contents.css( "height", "" );
_setOption: function( key, value ) {
if ( key === "active" ) {
// _activate() will handle invalid values and update this.options
if ( this.options.event ) {
this._off( this.headers, this.options.event );
this._setupEvents( value );
this._super( key, value );
// Setting collapsible: false while collapsed; open first panel
if ( key === "collapsible" && !value && this.options.active === false ) {
_setOptionDisabled: function( value ) {
this.element.attr( "aria-disabled", value );
// #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
// so we need to add the disabled class to the headers and panels
this._toggleClass( null, "ui-state-disabled", !!value );
this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
_keydown: function( event ) {
if ( event.altKey || event.ctrlKey ) {
var keyCode = $.ui.keyCode,
length = this.headers.length,
currentIndex = this.headers.index( event.target ),
switch ( event.keyCode ) {
toFocus = this.headers[ ( currentIndex + 1 ) % length ];
toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
this._eventHandler( event );
toFocus = this.headers[ 0 ];
toFocus = this.headers[ length - 1 ];
$( event.target ).attr( "tabIndex", -1 );
$( toFocus ).attr( "tabIndex", 0 );
$( toFocus ).trigger( "focus" );
_panelKeyDown: function( event ) {
if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
$( event.currentTarget ).prev().trigger( "focus" );
var options = this.options;
// Was collapsed or no panel
if ( ( options.active === false && options.collapsible === true ) ||
// active false only when collapsible is true
} else if ( options.active === false ) {
// was active, but active panel is gone
} else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
// all remaining panel are disabled
if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
// activate previous panel
this._activate( Math.max( 0, options.active - 1 ) );
// was active, active panel still exists
// make sure active index is correct
options.active = this.headers.index( this.active );
_processPanels: function() {
var prevHeaders = this.headers,
prevPanels = this.panels;
if ( typeof this.options.header === "function" ) {
this.headers = this.options.header( this.element );
this.headers = this.element.find( this.options.header );
this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
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" );
// Avoid memory leaks (#10056)
this._off( prevHeaders.not( this.headers ) );
this._off( prevPanels.not( this.panels ) );
heightStyle = options.heightStyle,
parent = this.element.parent();
this.active = this._findActive( options.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();
headerId = header.uniqueId().attr( "id" ),
panelId = panel.uniqueId().attr( "id" );
header.attr( "aria-controls", panelId );
panel.attr( "aria-labelledby", headerId );
.attr( "role", "tabpanel" );
"aria-selected": "false",
"aria-expanded": "false",
// Make sure at least one header is in the tab order
if ( !this.active.length ) {
this.headers.eq( 0 ).attr( "tabIndex", 0 );
this._setupEvents( options.event );
if ( heightStyle === "fill" ) {
maxHeight = parent.height();
this.element.siblings( ":visible" ).each( function() {
position = elem.css( "position" );
if ( position === "absolute" || position === "fixed" ) {
maxHeight -= elem.outerHeight( true );
this.headers.each( function() {
maxHeight -= $( this ).outerHeight( true );
$( this ).height( Math.max( 0, maxHeight -
$( this ).innerHeight() + $( this ).height() ) );
.css( "overflow", "auto" );
} else if ( heightStyle === "auto" ) {
var isVisible = $( this ).is( ":visible" );
maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
_activate: function( index ) {
var active = this._findActive( index )[ 0 ];
// Trying to activate the already active panel
if ( active === this.active[ 0 ] ) {
// Trying to collapse, simulate a click on the currently active header
active = active || this.active[ 0 ];
_findActive: function( selector ) {
return typeof selector === "number" ? this.headers.eq( selector ) : $();
_setupEvents: function( event ) {
$.each( event.split( " " ), function( index, eventName ) {
events[ eventName ] = "_eventHandler";
this._off( this.headers.add( this.headers.next() ) );
this._on( this.headers, events );
this._on( this.headers.next(), { keydown: "_panelKeyDown" } );
this._hoverable( this.headers );
this._focusable( this.headers );
_eventHandler: function( event ) {
var activeChildren, clickedChildren,
clicked = $( event.currentTarget ),
clickedIsActive = clicked[ 0 ] === active[ 0 ],
collapsing = clickedIsActive && options.collapsible,
toShow = collapsing ? $() : clicked.next(),
newHeader: collapsing ? $() : clicked,
// click on active header, but not collapsible
( clickedIsActive && !options.collapsible ) ||
// allow canceling activation
( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
options.active = collapsing ? false : this.headers.index( clicked );
// When the call to ._toggle() comes after the class changes
// it causes a very odd bug in IE 8 (see #6720)
this.active = clickedIsActive ? $() : clicked;
this._toggle( eventData );
// corner classes on the previously active header stay after the animation
this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
activeChildren = active.children( ".ui-accordion-header-icon" );
this._removeClass( activeChildren, null, options.icons.activeHeader )
._addClass( activeChildren, null, options.icons.header );
if ( !clickedIsActive ) {
this._removeClass( clicked, "ui-accordion-header-collapsed" )
._addClass( clicked, "ui-accordion-header-active", "ui-state-active" );
clickedChildren = clicked.children( ".ui-accordion-header-icon" );
this._removeClass( clickedChildren, null, options.icons.header )
._addClass( clickedChildren, null, options.icons.activeHeader );
this._addClass( clicked.next(), "ui-accordion-content-active" );
_toggle: function( data ) {
var toShow = data.newPanel,
toHide = this.prevShow.length ? this.prevShow : data.oldPanel;