: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* jQuery UI Dialog 1.13.3
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license.
* https://jquery.org/license
//>>description: Displays customizable dialog windows.
//>>docs: https://api.jqueryui.com/dialog/
//>>demos: https://jqueryui.com/dialog/
//>>css.structure: ../../themes/base/core.css
//>>css.structure: ../../themes/base/dialog.css
//>>css.theme: ../../themes/base/theme.css
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
"../safe-active-element",
"ui-dialog": "ui-corner-all",
"ui-dialog-titlebar": "ui-corner-all"
// Ensure the titlebar is always visible
var topOffset = $( this ).css( pos ).offset().top;
$( this ).css( "top", pos.top - topOffset );
resizableRelatedOptions: {
display: this.element[ 0 ].style.display,
width: this.element[ 0 ].style.width,
minHeight: this.element[ 0 ].style.minHeight,
maxHeight: this.element[ 0 ].style.maxHeight,
height: this.element[ 0 ].style.height
this.originalPosition = {
parent: this.element.parent(),
index: this.element.parent().children().index( this.element )
this.originalTitle = this.element.attr( "title" );
if ( this.options.title == null && this.originalTitle != null ) {
this.options.title = this.originalTitle;
// Dialogs can't be disabled
if ( this.options.disabled ) {
this.options.disabled = false;
.appendTo( this.uiDialog );
this._addClass( "ui-dialog-content", "ui-widget-content" );
this._createButtonPane();
if ( this.options.draggable && $.fn.draggable ) {
if ( this.options.resizable && $.fn.resizable ) {
if ( this.options.autoOpen ) {
var element = this.options.appendTo;
if ( element && ( element.jquery || element.nodeType ) ) {
return this.document.find( element || "body" ).eq( 0 );
originalPosition = this.originalPosition;
// Without detaching first, the following becomes really slow
if ( this.originalTitle ) {
this.element.attr( "title", this.originalTitle );
next = originalPosition.parent.children().eq( originalPosition.index );
// Don't try to place the dialog next to itself (#8613)
if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
next.before( this.element );
originalPosition.parent.append( this.element );
close: function( event ) {
if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
this._focusedElement = null;
if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
// Hiding a focused element doesn't trigger blur in WebKit
// so in case we have nothing to focus on, explicitly blur the active element
// https://bugs.webkit.org/show_bug.cgi?id=47182
$.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
this._hide( this.uiDialog, this.options.hide, function() {
that._trigger( "close", event );
_moveToTop: function( event, silent ) {
zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
return +$( this ).css( "z-index" );
zIndexMax = Math.max.apply( null, zIndices );
if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
this.uiDialog.css( "z-index", zIndexMax + 1 );
if ( moved && !silent ) {
this._trigger( "focus", event );
if ( this._moveToTop() ) {
this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
this._moveToTop( null, true );
// Ensure the overlay is moved to the top with the dialog, but only when
// opening. The overlay shouldn't move after the dialog is open so that
// modeless dialogs opened after the modal dialog stack properly.
this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
this._show( this.uiDialog, this.options.show, function() {
that._trigger( "focus" );
// Track the dialog immediately upon opening in case a focus event
// somehow occurs outside of the dialog before an element inside the
// dialog is focused (#10152)
_focusTabbable: function() {
// Set focus to the first match:
// 1. An element that was focused previously
// 2. First element inside the dialog matching [autofocus]
// 3. Tabbable element inside the content element
// 4. Tabbable element inside the buttonpane
var hasFocus = this._focusedElement;
hasFocus = this.element.find( "[autofocus]" );
if ( !hasFocus.length ) {
hasFocus = this.element.find( ":tabbable" );
if ( !hasFocus.length ) {
hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
if ( !hasFocus.length ) {
hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
if ( !hasFocus.length ) {
hasFocus = this.uiDialog;
hasFocus.eq( 0 ).trigger( "focus" );
_restoreTabbableFocus: function() {
var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
isActive = this.uiDialog[ 0 ] === activeElement ||
$.contains( this.uiDialog[ 0 ], activeElement );
_keepFocus: function( event ) {
this._restoreTabbableFocus();
// IE <= 8 doesn't prevent moving focus even with event.preventDefault()
// so we check again later
this._delay( this._restoreTabbableFocus );
_createWrapper: function() {
this.uiDialog = $( "<div>" )
// Setting tabIndex makes the div focusable
.appendTo( this._appendTo() );
this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
this._on( this.uiDialog, {
keydown: function( event ) {
if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
event.keyCode === $.ui.keyCode.ESCAPE ) {
// Prevent tabbing out of dialogs
if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
var tabbables = this.uiDialog.find( ":tabbable" ),
first = tabbables.first(),
if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
this._delay( function() {
first.trigger( "focus" );
} else if ( ( event.target === first[ 0 ] ||
event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
this._delay( function() {
mousedown: function( event ) {
if ( this._moveToTop( event ) ) {
// We assume that any existing aria-describedby attribute means
// that the dialog content is marked up properly
// otherwise we brute force the content as the description
if ( !this.element.find( "[aria-describedby]" ).length ) {
"aria-describedby": this.element.uniqueId().attr( "id" )
_createTitlebar: function() {
this.uiDialogTitlebar = $( "<div>" );
this._addClass( this.uiDialogTitlebar,
"ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
this._on( this.uiDialogTitlebar, {
mousedown: function( event ) {
// Don't prevent click on close button (#8838)
// Focusing a dialog that is partially scrolled out of view
// causes the browser to scroll it into view, preventing the click event
if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
// Dialog isn't getting focus when dragging (#8063)
this.uiDialog.trigger( "focus" );
// Use type="button" to prevent enter keypresses in textboxes from closing the
this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
label: $( "<a>" ).text( this.options.closeText ).html(),
icon: "ui-icon-closethick",
.appendTo( this.uiDialogTitlebar );
this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
this._on( this.uiDialogTitlebarClose, {
click: function( event ) {
uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
this._addClass( uiDialogTitle, "ui-dialog-title" );
this._title( uiDialogTitle );
this.uiDialogTitlebar.prependTo( this.uiDialog );
"aria-labelledby": uiDialogTitle.attr( "id" )
_title: function( title ) {
if ( this.options.title ) {
title.text( this.options.title );
_createButtonPane: function() {
this.uiDialogButtonPane = $( "<div>" );
this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
"ui-widget-content ui-helper-clearfix" );
this.uiButtonSet = $( "<div>" )
.appendTo( this.uiDialogButtonPane );
this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
_createButtons: function() {
buttons = this.options.buttons;
// If we already have a button pane, remove it
this.uiDialogButtonPane.remove();
this.uiButtonSet.empty();
if ( $.isEmptyObject( buttons ) || ( Array.isArray( buttons ) && !buttons.length ) ) {
this._removeClass( this.uiDialog, "ui-dialog-buttons" );
$.each( buttons, function( name, props ) {
var click, buttonOptions;
props = typeof props === "function" ?
{ click: props, text: name } :
// Default to a non-submitting button
props = $.extend( { type: "button" }, props );