2012-02-27 00:49:51 +00:00
|
|
|
/*!
|
2008-09-04 22:03:30 +00:00
|
|
|
* jQuery UI Dialog @VERSION
|
2024-04-26 14:25:34 +00:00
|
|
|
* https://jqueryui.com
|
2008-06-04 02:34:33 +00:00
|
|
|
*
|
2022-07-19 07:36:55 +00:00
|
|
|
* Copyright OpenJS Foundation and other contributors
|
2012-08-09 14:13:24 +00:00
|
|
|
* Released under the MIT license.
|
2024-04-26 14:25:34 +00:00
|
|
|
* https://jquery.org/license
|
2008-06-04 02:34:33 +00:00
|
|
|
*/
|
2014-10-30 19:55:08 +00:00
|
|
|
|
|
|
|
//>>label: Dialog
|
|
|
|
//>>group: Widgets
|
|
|
|
//>>description: Displays customizable dialog windows.
|
2024-04-26 14:25:34 +00:00
|
|
|
//>>docs: https://api.jqueryui.com/dialog/
|
|
|
|
//>>demos: https://jqueryui.com/dialog/
|
2015-10-21 23:08:44 +00:00
|
|
|
//>>css.structure: ../../themes/base/core.css
|
|
|
|
//>>css.structure: ../../themes/base/dialog.css
|
|
|
|
//>>css.theme: ../../themes/base/theme.css
|
2014-10-30 19:55:08 +00:00
|
|
|
|
2015-03-14 11:25:12 +00:00
|
|
|
( function( factory ) {
|
2021-06-06 22:58:12 +00:00
|
|
|
"use strict";
|
|
|
|
|
2013-07-12 16:40:48 +00:00
|
|
|
if ( typeof define === "function" && define.amd ) {
|
|
|
|
|
|
|
|
// AMD. Register as an anonymous module.
|
2015-03-14 11:25:12 +00:00
|
|
|
define( [
|
2013-07-12 16:40:48 +00:00
|
|
|
"jquery",
|
2015-07-15 01:59:10 +00:00
|
|
|
"./button",
|
2015-07-15 01:59:40 +00:00
|
|
|
"./draggable",
|
2015-07-15 02:18:43 +00:00
|
|
|
"./mouse",
|
2015-07-15 02:05:00 +00:00
|
|
|
"./resizable",
|
2015-07-15 01:59:10 +00:00
|
|
|
"../focusable",
|
|
|
|
"../keycode",
|
|
|
|
"../position",
|
|
|
|
"../safe-active-element",
|
|
|
|
"../safe-blur",
|
|
|
|
"../tabbable",
|
|
|
|
"../unique-id",
|
|
|
|
"../version",
|
|
|
|
"../widget"
|
2013-07-12 16:40:48 +00:00
|
|
|
], factory );
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Browser globals
|
|
|
|
factory( jQuery );
|
|
|
|
}
|
2021-06-06 22:58:12 +00:00
|
|
|
} )( function( $ ) {
|
|
|
|
"use strict";
|
2008-06-04 02:34:33 +00:00
|
|
|
|
2014-12-03 16:23:59 +00:00
|
|
|
$.widget( "ui.dialog", {
|
2011-05-28 19:39:55 +00:00
|
|
|
version: "@VERSION",
|
2010-01-07 03:19:50 +00:00
|
|
|
options: {
|
2012-12-07 19:54:21 +00:00
|
|
|
appendTo: "body",
|
2010-01-07 03:19:50 +00:00
|
|
|
autoOpen: true,
|
2012-12-11 21:23:18 +00:00
|
|
|
buttons: [],
|
2014-12-03 16:23:59 +00:00
|
|
|
classes: {
|
|
|
|
"ui-dialog": "ui-corner-all",
|
|
|
|
"ui-dialog-titlebar": "ui-corner-all"
|
|
|
|
},
|
2010-01-07 03:19:50 +00:00
|
|
|
closeOnEscape: true,
|
2013-08-15 20:56:49 +00:00
|
|
|
closeText: "Close",
|
2010-01-07 03:19:50 +00:00
|
|
|
draggable: true,
|
|
|
|
hide: null,
|
2010-12-18 00:53:22 +00:00
|
|
|
height: "auto",
|
2012-12-07 21:57:03 +00:00
|
|
|
maxHeight: null,
|
|
|
|
maxWidth: null,
|
2010-01-07 03:19:50 +00:00
|
|
|
minHeight: 150,
|
|
|
|
minWidth: 150,
|
|
|
|
modal: false,
|
2010-06-06 22:00:49 +00:00
|
|
|
position: {
|
2010-12-18 00:53:22 +00:00
|
|
|
my: "center",
|
|
|
|
at: "center",
|
2010-12-10 18:42:29 +00:00
|
|
|
of: window,
|
2010-12-18 00:53:22 +00:00
|
|
|
collision: "fit",
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
// Ensure the titlebar is always visible
|
2010-12-18 00:53:22 +00:00
|
|
|
using: function( pos ) {
|
|
|
|
var topOffset = $( this ).css( pos ).offset().top;
|
|
|
|
if ( topOffset < 0 ) {
|
|
|
|
$( this ).css( "top", pos.top - topOffset );
|
2010-06-06 22:00:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2010-01-07 03:19:50 +00:00
|
|
|
resizable: true,
|
|
|
|
show: null,
|
2012-11-09 17:26:30 +00:00
|
|
|
title: null,
|
2012-10-27 15:07:13 +00:00
|
|
|
width: 300,
|
|
|
|
|
2015-08-21 04:11:21 +00:00
|
|
|
// Callbacks
|
2012-10-27 15:07:13 +00:00
|
|
|
beforeClose: null,
|
|
|
|
close: null,
|
|
|
|
drag: null,
|
|
|
|
dragStart: null,
|
|
|
|
dragStop: null,
|
|
|
|
focus: null,
|
|
|
|
open: null,
|
|
|
|
resize: null,
|
|
|
|
resizeStart: null,
|
|
|
|
resizeStop: null
|
2010-01-07 03:19:50 +00:00
|
|
|
},
|
2010-07-16 12:54:50 +00:00
|
|
|
|
2013-09-17 13:30:03 +00:00
|
|
|
sizeRelatedOptions: {
|
|
|
|
buttons: true,
|
|
|
|
height: true,
|
|
|
|
maxHeight: true,
|
|
|
|
maxWidth: true,
|
|
|
|
minHeight: true,
|
|
|
|
minWidth: true,
|
|
|
|
width: true
|
|
|
|
},
|
|
|
|
|
|
|
|
resizableRelatedOptions: {
|
|
|
|
maxHeight: true,
|
|
|
|
maxWidth: true,
|
|
|
|
minHeight: true,
|
|
|
|
minWidth: true
|
|
|
|
},
|
|
|
|
|
2010-01-15 18:58:20 +00:00
|
|
|
_create: function() {
|
2012-12-05 16:53:34 +00:00
|
|
|
this.originalCss = {
|
2013-11-15 15:48:31 +00:00
|
|
|
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
|
2012-12-05 16:53:34 +00:00
|
|
|
};
|
2012-12-11 21:23:18 +00:00
|
|
|
this.originalPosition = {
|
2012-04-19 01:57:51 +00:00
|
|
|
parent: this.element.parent(),
|
|
|
|
index: this.element.parent().children().index( this.element )
|
2011-12-15 20:52:49 +00:00
|
|
|
};
|
2013-11-15 15:48:31 +00:00
|
|
|
this.originalTitle = this.element.attr( "title" );
|
2015-03-23 22:37:47 +00:00
|
|
|
if ( this.options.title == null && this.originalTitle != null ) {
|
|
|
|
this.options.title = this.originalTitle;
|
|
|
|
}
|
2012-11-15 22:33:09 +00:00
|
|
|
|
2015-09-21 10:39:09 +00:00
|
|
|
// Dialogs can't be disabled
|
|
|
|
if ( this.options.disabled ) {
|
|
|
|
this.options.disabled = false;
|
|
|
|
}
|
|
|
|
|
2012-11-15 22:33:09 +00:00
|
|
|
this._createWrapper();
|
|
|
|
|
|
|
|
this.element
|
|
|
|
.show()
|
2013-11-15 15:48:31 +00:00
|
|
|
.removeAttr( "title" )
|
2012-11-15 22:33:09 +00:00
|
|
|
.appendTo( this.uiDialog );
|
2010-12-18 00:53:22 +00:00
|
|
|
|
2014-12-03 16:23:59 +00:00
|
|
|
this._addClass( "ui-dialog-content", "ui-widget-content" );
|
|
|
|
|
2012-11-15 22:23:25 +00:00
|
|
|
this._createTitlebar();
|
|
|
|
this._createButtonPane();
|
2012-05-30 04:11:42 +00:00
|
|
|
|
2012-11-15 22:33:09 +00:00
|
|
|
if ( this.options.draggable && $.fn.draggable ) {
|
2012-05-09 20:00:21 +00:00
|
|
|
this._makeDraggable();
|
2010-03-12 01:10:57 +00:00
|
|
|
}
|
2012-11-15 22:33:09 +00:00
|
|
|
if ( this.options.resizable && $.fn.resizable ) {
|
2012-05-09 20:00:21 +00:00
|
|
|
this._makeResizable();
|
2010-03-12 01:10:57 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2012-05-09 20:00:21 +00:00
|
|
|
this._isOpen = false;
|
2013-10-02 15:27:43 +00:00
|
|
|
|
|
|
|
this._trackFocus();
|
2010-01-15 22:17:34 +00:00
|
|
|
},
|
2010-07-16 12:54:50 +00:00
|
|
|
|
2010-01-15 22:17:34 +00:00
|
|
|
_init: function() {
|
|
|
|
if ( this.options.autoOpen ) {
|
|
|
|
this.open();
|
|
|
|
}
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2012-12-07 19:54:21 +00:00
|
|
|
_appendTo: function() {
|
|
|
|
var element = this.options.appendTo;
|
2015-03-14 11:25:12 +00:00
|
|
|
if ( element && ( element.jquery || element.nodeType ) ) {
|
2012-12-07 19:54:21 +00:00
|
|
|
return $( element );
|
|
|
|
}
|
|
|
|
return this.document.find( element || "body" ).eq( 0 );
|
|
|
|
},
|
|
|
|
|
2011-01-14 22:11:22 +00:00
|
|
|
_destroy: function() {
|
2012-05-09 20:00:21 +00:00
|
|
|
var next,
|
2012-12-11 21:23:18 +00:00
|
|
|
originalPosition = this.originalPosition;
|
2011-11-18 11:19:32 +00:00
|
|
|
|
2015-02-18 15:45:11 +00:00
|
|
|
this._untrackInstance();
|
2012-11-17 12:07:03 +00:00
|
|
|
this._destroyOverlay();
|
2012-11-17 12:14:04 +00:00
|
|
|
|
2012-05-09 20:00:21 +00:00
|
|
|
this.element
|
2012-10-26 00:30:10 +00:00
|
|
|
.removeUniqueId()
|
2012-12-05 16:53:34 +00:00
|
|
|
.css( this.originalCss )
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
// Without detaching first, the following becomes really slow
|
2012-11-17 12:14:04 +00:00
|
|
|
.detach();
|
|
|
|
|
2015-03-10 19:40:49 +00:00
|
|
|
this.uiDialog.remove();
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2012-05-09 20:00:21 +00:00
|
|
|
if ( this.originalTitle ) {
|
|
|
|
this.element.attr( "title", this.originalTitle );
|
2010-03-12 01:10:57 +00:00
|
|
|
}
|
2012-04-19 01:57:51 +00:00
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
next = originalPosition.parent.children().eq( originalPosition.index );
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-10-01 19:34:44 +00:00
|
|
|
// Don't try to place the dialog next to itself (#8613)
|
2013-11-15 15:48:31 +00:00
|
|
|
if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
|
2012-05-09 20:00:21 +00:00
|
|
|
next.before( this.element );
|
2011-12-15 20:52:49 +00:00
|
|
|
} else {
|
2012-12-11 21:23:18 +00:00
|
|
|
originalPosition.parent.append( this.element );
|
2012-04-19 01:57:51 +00:00
|
|
|
}
|
2008-09-14 14:49:28 +00:00
|
|
|
},
|
2010-07-16 12:54:50 +00:00
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
widget: function() {
|
2010-07-30 16:38:18 +00:00
|
|
|
return this.uiDialog;
|
2010-01-07 03:19:50 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2012-11-17 10:31:57 +00:00
|
|
|
disable: $.noop,
|
|
|
|
enable: $.noop,
|
|
|
|
|
2010-12-18 00:53:22 +00:00
|
|
|
close: function( event ) {
|
2015-03-09 20:03:22 +00:00
|
|
|
var that = this;
|
2011-11-18 11:19:32 +00:00
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
|
2008-09-19 02:07:54 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2012-05-09 20:00:21 +00:00
|
|
|
this._isOpen = false;
|
2013-10-02 15:27:43 +00:00
|
|
|
this._focusedElement = null;
|
2012-11-17 12:07:03 +00:00
|
|
|
this._destroyOverlay();
|
2013-11-16 11:21:02 +00:00
|
|
|
this._untrackInstance();
|
2009-02-21 17:02:52 +00:00
|
|
|
|
2015-05-14 01:57:04 +00:00
|
|
|
if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
|
2013-09-30 14:49:42 +00:00
|
|
|
|
2015-03-09 20:03:22 +00:00
|
|
|
// 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 ] ) );
|
2012-10-23 14:31:10 +00:00
|
|
|
}
|
|
|
|
|
2012-10-23 15:09:04 +00:00
|
|
|
this._hide( this.uiDialog, this.options.hide, function() {
|
|
|
|
that._trigger( "close", event );
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2008-09-14 14:49:28 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-09-14 14:49:28 +00:00
|
|
|
isOpen: function() {
|
|
|
|
return this._isOpen;
|
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2012-11-09 17:44:29 +00:00
|
|
|
moveToTop: function() {
|
|
|
|
this._moveToTop();
|
|
|
|
},
|
|
|
|
|
|
|
|
_moveToTop: function( event, silent ) {
|
2013-09-27 16:53:15 +00:00
|
|
|
var moved = false,
|
2015-03-14 11:25:12 +00:00
|
|
|
zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
|
2013-09-27 16:53:15 +00:00
|
|
|
return +$( this ).css( "z-index" );
|
2015-03-14 11:25:12 +00:00
|
|
|
} ).get(),
|
2015-02-23 21:33:18 +00:00
|
|
|
zIndexMax = Math.max.apply( null, zIndices );
|
2013-09-27 16:53:15 +00:00
|
|
|
|
|
|
|
if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
|
|
|
|
this.uiDialog.css( "z-index", zIndexMax + 1 );
|
|
|
|
moved = true;
|
|
|
|
}
|
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
if ( moved && !silent ) {
|
2012-10-15 20:12:21 +00:00
|
|
|
this._trigger( "focus", event );
|
2010-03-12 01:10:57 +00:00
|
|
|
}
|
2012-11-09 17:44:29 +00:00
|
|
|
return moved;
|
2008-09-29 13:08:14 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2009-02-25 05:29:01 +00:00
|
|
|
open: function() {
|
2013-01-30 18:30:37 +00:00
|
|
|
var that = this;
|
2010-12-18 00:53:22 +00:00
|
|
|
if ( this._isOpen ) {
|
2012-11-09 17:44:29 +00:00
|
|
|
if ( this._moveToTop() ) {
|
|
|
|
this._focusTabbable();
|
|
|
|
}
|
2010-12-18 00:53:22 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2013-01-31 22:20:19 +00:00
|
|
|
this._isOpen = true;
|
2015-03-09 20:03:22 +00:00
|
|
|
this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
|
2012-10-23 14:31:10 +00:00
|
|
|
|
2012-05-09 20:00:21 +00:00
|
|
|
this._size();
|
2012-11-17 11:10:26 +00:00
|
|
|
this._position();
|
2012-11-17 12:07:03 +00:00
|
|
|
this._createOverlay();
|
2012-11-09 17:44:29 +00:00
|
|
|
this._moveToTop( null, true );
|
2014-07-17 15:08:57 +00:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
if ( this.overlay ) {
|
|
|
|
this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
|
|
|
|
}
|
|
|
|
|
2013-01-30 18:30:37 +00:00
|
|
|
this._show( this.uiDialog, this.options.show, function() {
|
|
|
|
that._focusTabbable();
|
2013-11-15 15:48:31 +00:00
|
|
|
that._trigger( "focus" );
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2012-10-26 14:59:41 +00:00
|
|
|
|
2017-05-11 17:58:08 +00:00
|
|
|
// Track the dialog immediately upon opening in case a focus event
|
2014-07-23 15:10:14 +00:00
|
|
|
// somehow occurs outside of the dialog before an element inside the
|
|
|
|
// dialog is focused (#10152)
|
|
|
|
this._makeFocusTarget();
|
|
|
|
|
2013-11-15 15:48:31 +00:00
|
|
|
this._trigger( "open" );
|
2012-10-26 14:59:41 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_focusTabbable: function() {
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
// Set focus to the first match:
|
2013-10-02 15:27:43 +00:00
|
|
|
// 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
|
|
|
|
// 5. The close button
|
|
|
|
// 6. The dialog itself
|
|
|
|
var hasFocus = this._focusedElement;
|
|
|
|
if ( !hasFocus ) {
|
|
|
|
hasFocus = this.element.find( "[autofocus]" );
|
|
|
|
}
|
2011-05-02 22:03:14 +00:00
|
|
|
if ( !hasFocus.length ) {
|
2013-10-02 15:27:43 +00:00
|
|
|
hasFocus = this.element.find( ":tabbable" );
|
2012-12-11 21:23:18 +00:00
|
|
|
}
|
|
|
|
if ( !hasFocus.length ) {
|
2013-10-02 15:27:43 +00:00
|
|
|
hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
|
2012-12-11 21:23:18 +00:00
|
|
|
}
|
|
|
|
if ( !hasFocus.length ) {
|
2013-10-02 15:27:43 +00:00
|
|
|
hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
|
2012-12-11 21:23:18 +00:00
|
|
|
}
|
|
|
|
if ( !hasFocus.length ) {
|
|
|
|
hasFocus = this.uiDialog;
|
2011-05-02 22:03:14 +00:00
|
|
|
}
|
2015-05-14 01:57:04 +00:00
|
|
|
hasFocus.eq( 0 ).trigger( "focus" );
|
2008-09-14 14:49:28 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2021-02-21 23:02:02 +00:00
|
|
|
_restoreTabbableFocus: function() {
|
|
|
|
var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
|
|
|
|
isActive = this.uiDialog[ 0 ] === activeElement ||
|
|
|
|
$.contains( this.uiDialog[ 0 ], activeElement );
|
|
|
|
if ( !isActive ) {
|
|
|
|
this._focusTabbable();
|
2012-10-23 00:33:15 +00:00
|
|
|
}
|
2021-02-21 23:02:02 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_keepFocus: function( event ) {
|
2012-10-23 00:33:15 +00:00
|
|
|
event.preventDefault();
|
2021-02-21 23:02:02 +00:00
|
|
|
this._restoreTabbableFocus();
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-10-23 00:33:15 +00:00
|
|
|
// support: IE
|
|
|
|
// IE <= 8 doesn't prevent moving focus even with event.preventDefault()
|
|
|
|
// so we check again later
|
2021-02-21 23:02:02 +00:00
|
|
|
this._delay( this._restoreTabbableFocus );
|
2012-10-23 00:33:15 +00:00
|
|
|
},
|
|
|
|
|
2012-11-15 22:33:09 +00:00
|
|
|
_createWrapper: function() {
|
2015-03-14 11:25:12 +00:00
|
|
|
this.uiDialog = $( "<div>" )
|
2012-11-15 22:33:09 +00:00
|
|
|
.hide()
|
2015-03-14 11:25:12 +00:00
|
|
|
.attr( {
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
// Setting tabIndex makes the div focusable
|
2012-11-15 22:33:09 +00:00
|
|
|
tabIndex: -1,
|
|
|
|
role: "dialog"
|
2015-03-14 11:25:12 +00:00
|
|
|
} )
|
2012-12-07 19:54:21 +00:00
|
|
|
.appendTo( this._appendTo() );
|
2012-11-15 22:33:09 +00:00
|
|
|
|
2014-12-03 16:23:59 +00:00
|
|
|
this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
|
2012-11-15 22:33:09 +00:00
|
|
|
this._on( this.uiDialog, {
|
|
|
|
keydown: function( event ) {
|
|
|
|
if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
|
|
|
|
event.keyCode === $.ui.keyCode.ESCAPE ) {
|
|
|
|
event.preventDefault();
|
|
|
|
this.close( event );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-21 04:11:21 +00:00
|
|
|
// Prevent tabbing out of dialogs
|
2014-06-10 11:51:25 +00:00
|
|
|
if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
|
2012-11-15 22:33:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-11-15 15:48:31 +00:00
|
|
|
var tabbables = this.uiDialog.find( ":tabbable" ),
|
2020-01-22 15:44:34 +00:00
|
|
|
first = tabbables.first(),
|
|
|
|
last = tabbables.last();
|
2012-11-15 22:33:09 +00:00
|
|
|
|
2016-03-31 03:41:14 +00:00
|
|
|
if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
|
|
|
|
!event.shiftKey ) {
|
2015-03-14 11:25:12 +00:00
|
|
|
this._delay( function() {
|
2015-05-14 01:57:04 +00:00
|
|
|
first.trigger( "focus" );
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2012-12-11 21:23:18 +00:00
|
|
|
event.preventDefault();
|
2016-03-31 03:41:14 +00:00
|
|
|
} else if ( ( event.target === first[ 0 ] ||
|
|
|
|
event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
|
2015-03-14 11:25:12 +00:00
|
|
|
this._delay( function() {
|
2015-05-14 01:57:04 +00:00
|
|
|
last.trigger( "focus" );
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2012-12-11 21:23:18 +00:00
|
|
|
event.preventDefault();
|
2012-11-15 22:33:09 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mousedown: function( event ) {
|
|
|
|
if ( this._moveToTop( event ) ) {
|
|
|
|
this._focusTabbable();
|
|
|
|
}
|
|
|
|
}
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2012-11-15 22:33:09 +00:00
|
|
|
|
|
|
|
// 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
|
2013-11-15 15:48:31 +00:00
|
|
|
if ( !this.element.find( "[aria-describedby]" ).length ) {
|
2015-03-14 11:25:12 +00:00
|
|
|
this.uiDialog.attr( {
|
2013-11-15 15:48:31 +00:00
|
|
|
"aria-describedby": this.element.uniqueId().attr( "id" )
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2012-11-15 22:33:09 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-11-15 22:20:00 +00:00
|
|
|
_createTitlebar: function() {
|
|
|
|
var uiDialogTitle;
|
|
|
|
|
2014-12-03 16:23:59 +00:00
|
|
|
this.uiDialogTitlebar = $( "<div>" );
|
|
|
|
this._addClass( this.uiDialogTitlebar,
|
|
|
|
"ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
|
2012-11-15 22:20:00 +00:00
|
|
|
this._on( this.uiDialogTitlebar, {
|
2012-11-26 09:08:34 +00:00
|
|
|
mousedown: function( event ) {
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-11-26 09:08:34 +00:00
|
|
|
// 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
|
2013-11-15 15:48:31 +00:00
|
|
|
if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-11-26 09:08:34 +00:00
|
|
|
// Dialog isn't getting focus when dragging (#8063)
|
2015-05-14 01:57:04 +00:00
|
|
|
this.uiDialog.trigger( "focus" );
|
2012-11-26 09:08:34 +00:00
|
|
|
}
|
2012-11-15 22:20:00 +00:00
|
|
|
}
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2012-11-15 22:20:00 +00:00
|
|
|
|
2015-08-21 04:11:21 +00:00
|
|
|
// Support: IE
|
2013-05-23 01:43:40 +00:00
|
|
|
// Use type="button" to prevent enter keypresses in textboxes from closing the
|
|
|
|
// dialog in IE (#9312)
|
|
|
|
this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
|
2015-03-14 11:25:12 +00:00
|
|
|
.button( {
|
2015-10-28 18:11:07 +00:00
|
|
|
label: $( "<a>" ).text( this.options.closeText ).html(),
|
2014-03-28 14:48:18 +00:00
|
|
|
icon: "ui-icon-closethick",
|
|
|
|
showLabel: false
|
2015-03-14 11:25:12 +00:00
|
|
|
} )
|
2012-11-15 22:20:00 +00:00
|
|
|
.appendTo( this.uiDialogTitlebar );
|
2014-12-03 16:23:59 +00:00
|
|
|
|
|
|
|
this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
|
2012-11-15 22:20:00 +00:00
|
|
|
this._on( this.uiDialogTitlebarClose, {
|
2012-12-11 21:23:18 +00:00
|
|
|
click: function( event ) {
|
2012-11-15 22:20:00 +00:00
|
|
|
event.preventDefault();
|
|
|
|
this.close( event );
|
|
|
|
}
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2012-11-15 22:20:00 +00:00
|
|
|
|
2014-12-03 16:23:59 +00:00
|
|
|
uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
|
|
|
|
this._addClass( uiDialogTitle, "ui-dialog-title" );
|
2012-11-26 09:14:36 +00:00
|
|
|
this._title( uiDialogTitle );
|
2012-11-15 22:20:00 +00:00
|
|
|
|
2014-12-03 16:23:59 +00:00
|
|
|
this.uiDialogTitlebar.prependTo( this.uiDialog );
|
|
|
|
|
2015-03-14 11:25:12 +00:00
|
|
|
this.uiDialog.attr( {
|
2013-11-15 15:48:31 +00:00
|
|
|
"aria-labelledby": uiDialogTitle.attr( "id" )
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2012-11-15 22:20:00 +00:00
|
|
|
},
|
|
|
|
|
2012-11-26 09:14:36 +00:00
|
|
|
_title: function( title ) {
|
2015-03-23 22:37:47 +00:00
|
|
|
if ( this.options.title ) {
|
|
|
|
title.text( this.options.title );
|
|
|
|
} else {
|
2013-11-15 15:48:31 +00:00
|
|
|
title.html( " " );
|
2012-11-26 09:14:36 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-11-15 22:23:25 +00:00
|
|
|
_createButtonPane: function() {
|
2014-12-03 16:23:59 +00:00
|
|
|
this.uiDialogButtonPane = $( "<div>" );
|
|
|
|
this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
|
|
|
|
"ui-widget-content ui-helper-clearfix" );
|
2012-11-15 22:23:25 +00:00
|
|
|
|
2013-11-15 15:48:31 +00:00
|
|
|
this.uiButtonSet = $( "<div>" )
|
2012-12-11 21:23:18 +00:00
|
|
|
.appendTo( this.uiDialogButtonPane );
|
2014-12-03 16:23:59 +00:00
|
|
|
this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
|
2012-11-15 22:23:25 +00:00
|
|
|
|
|
|
|
this._createButtons();
|
|
|
|
},
|
|
|
|
|
2012-11-15 21:54:49 +00:00
|
|
|
_createButtons: function() {
|
|
|
|
var that = this,
|
|
|
|
buttons = this.options.buttons;
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2015-08-21 04:11:21 +00:00
|
|
|
// If we already have a button pane, remove it
|
2012-05-22 12:28:53 +00:00
|
|
|
this.uiDialogButtonPane.remove();
|
|
|
|
this.uiButtonSet.empty();
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2019-12-08 21:23:08 +00:00
|
|
|
if ( $.isEmptyObject( buttons ) || ( Array.isArray( buttons ) && !buttons.length ) ) {
|
2014-12-03 16:23:59 +00:00
|
|
|
this._removeClass( this.uiDialog, "ui-dialog-buttons" );
|
2012-12-11 21:23:18 +00:00
|
|
|
return;
|
2008-09-14 14:49:28 +00:00
|
|
|
}
|
2012-12-11 21:23:18 +00:00
|
|
|
|
|
|
|
$.each( buttons, function( name, props ) {
|
|
|
|
var click, buttonOptions;
|
2019-12-08 21:23:08 +00:00
|
|
|
props = typeof props === "function" ?
|
2012-12-11 21:23:18 +00:00
|
|
|
{ click: props, text: name } :
|
|
|
|
props;
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
// Default to a non-submitting button
|
|
|
|
props = $.extend( { type: "button" }, props );
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
// Change the context for the click callback to be the main element
|
|
|
|
click = props.click;
|
|
|
|
buttonOptions = {
|
2014-03-28 14:48:18 +00:00
|
|
|
icon: props.icon,
|
|
|
|
iconPosition: props.iconPosition,
|
2016-07-25 12:16:13 +00:00
|
|
|
showLabel: props.showLabel,
|
|
|
|
|
|
|
|
// Deprecated options
|
|
|
|
icons: props.icons,
|
|
|
|
text: props.text
|
2012-12-11 21:23:18 +00:00
|
|
|
};
|
2014-03-28 14:48:18 +00:00
|
|
|
|
2015-05-14 01:57:04 +00:00
|
|
|
delete props.click;
|
2014-03-28 14:48:18 +00:00
|
|
|
delete props.icon;
|
|
|
|
delete props.iconPosition;
|
|
|
|
delete props.showLabel;
|
2015-05-14 01:57:04 +00:00
|
|
|
|
2016-07-25 12:16:13 +00:00
|
|
|
// Deprecated options
|
|
|
|
delete props.icons;
|
|
|
|
if ( typeof props.text === "boolean" ) {
|
|
|
|
delete props.text;
|
|
|
|
}
|
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
$( "<button></button>", props )
|
|
|
|
.button( buttonOptions )
|
2015-05-14 01:57:04 +00:00
|
|
|
.appendTo( that.uiButtonSet )
|
|
|
|
.on( "click", function() {
|
|
|
|
click.apply( that.element[ 0 ], arguments );
|
|
|
|
} );
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2014-12-03 16:23:59 +00:00
|
|
|
this._addClass( this.uiDialog, "ui-dialog-buttons" );
|
2012-12-11 21:23:18 +00:00
|
|
|
this.uiDialogButtonPane.appendTo( this.uiDialog );
|
2008-09-14 14:49:28 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-09-14 14:49:28 +00:00
|
|
|
_makeDraggable: function() {
|
2012-05-09 20:00:21 +00:00
|
|
|
var that = this,
|
|
|
|
options = this.options;
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-12-18 00:53:22 +00:00
|
|
|
function filteredUi( ui ) {
|
2010-03-05 17:56:34 +00:00
|
|
|
return {
|
2010-03-11 20:48:21 +00:00
|
|
|
position: ui.position,
|
2010-03-05 17:56:34 +00:00
|
|
|
offset: ui.offset
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-03-14 11:25:12 +00:00
|
|
|
this.uiDialog.draggable( {
|
2010-12-18 00:53:22 +00:00
|
|
|
cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
|
|
|
|
handle: ".ui-dialog-titlebar",
|
|
|
|
containment: "document",
|
|
|
|
start: function( event, ui ) {
|
2014-12-03 16:23:59 +00:00
|
|
|
that._addClass( $( this ), "ui-dialog-dragging" );
|
2013-02-03 13:55:34 +00:00
|
|
|
that._blockFrames();
|
2012-05-09 20:00:21 +00:00
|
|
|
that._trigger( "dragStart", event, filteredUi( ui ) );
|
2008-09-14 14:49:28 +00:00
|
|
|
},
|
2010-12-18 00:53:22 +00:00
|
|
|
drag: function( event, ui ) {
|
2012-05-09 20:00:21 +00:00
|
|
|
that._trigger( "drag", event, filteredUi( ui ) );
|
2008-09-14 14:49:28 +00:00
|
|
|
},
|
2010-12-18 00:53:22 +00:00
|
|
|
stop: function( event, ui ) {
|
2013-05-31 19:00:50 +00:00
|
|
|
var left = ui.offset.left - that.document.scrollLeft(),
|
|
|
|
top = ui.offset.top - that.document.scrollTop();
|
|
|
|
|
|
|
|
options.position = {
|
|
|
|
my: "left top",
|
2015-03-14 11:25:12 +00:00
|
|
|
at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
|
|
|
|
"top" + ( top >= 0 ? "+" : "" ) + top,
|
2013-05-31 19:00:50 +00:00
|
|
|
of: that.window
|
|
|
|
};
|
2014-12-03 16:23:59 +00:00
|
|
|
that._removeClass( $( this ), "ui-dialog-dragging" );
|
2013-02-03 13:55:34 +00:00
|
|
|
that._unblockFrames();
|
2012-05-09 20:00:21 +00:00
|
|
|
that._trigger( "dragStop", event, filteredUi( ui ) );
|
2008-09-14 14:49:28 +00:00
|
|
|
}
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2008-09-14 14:49:28 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2012-11-15 22:00:47 +00:00
|
|
|
_makeResizable: function() {
|
2012-05-09 20:00:21 +00:00
|
|
|
var that = this,
|
|
|
|
options = this.options,
|
2012-11-15 22:00:47 +00:00
|
|
|
handles = options.resizable,
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2010-01-28 03:06:43 +00:00
|
|
|
// .ui-resizable has position: relative defined in the stylesheet
|
|
|
|
// but dialogs have to use absolute or fixed positioning
|
2015-03-14 11:25:12 +00:00
|
|
|
position = this.uiDialog.css( "position" ),
|
2012-12-25 17:01:09 +00:00
|
|
|
resizeHandles = typeof handles === "string" ?
|
2015-03-14 11:25:12 +00:00
|
|
|
handles :
|
2010-12-18 00:53:22 +00:00
|
|
|
"n,e,s,w,se,sw,ne,nw";
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-12-18 00:53:22 +00:00
|
|
|
function filteredUi( ui ) {
|
2010-03-05 17:56:34 +00:00
|
|
|
return {
|
|
|
|
originalPosition: ui.originalPosition,
|
|
|
|
originalSize: ui.originalSize,
|
|
|
|
position: ui.position,
|
|
|
|
size: ui.size
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-03-14 11:25:12 +00:00
|
|
|
this.uiDialog.resizable( {
|
2010-12-18 00:53:22 +00:00
|
|
|
cancel: ".ui-dialog-content",
|
|
|
|
containment: "document",
|
2012-05-09 20:00:21 +00:00
|
|
|
alsoResize: this.element,
|
2008-09-14 14:47:06 +00:00
|
|
|
maxWidth: options.maxWidth,
|
|
|
|
maxHeight: options.maxHeight,
|
|
|
|
minWidth: options.minWidth,
|
2012-05-09 20:00:21 +00:00
|
|
|
minHeight: this._minHeight(),
|
2009-07-10 20:00:06 +00:00
|
|
|
handles: resizeHandles,
|
2010-12-18 00:53:22 +00:00
|
|
|
start: function( event, ui ) {
|
2014-12-03 16:23:59 +00:00
|
|
|
that._addClass( $( this ), "ui-dialog-resizing" );
|
2013-02-03 13:55:34 +00:00
|
|
|
that._blockFrames();
|
2012-05-09 20:00:21 +00:00
|
|
|
that._trigger( "resizeStart", event, filteredUi( ui ) );
|
2008-09-14 14:47:06 +00:00
|
|
|
},
|
2010-12-18 00:53:22 +00:00
|
|
|
resize: function( event, ui ) {
|
2012-05-09 20:00:21 +00:00
|
|
|
that._trigger( "resize", event, filteredUi( ui ) );
|
2008-09-14 14:47:06 +00:00
|
|
|
},
|
2010-12-18 00:53:22 +00:00
|
|
|
stop: function( event, ui ) {
|
2013-05-31 19:00:50 +00:00
|
|
|
var offset = that.uiDialog.offset(),
|
|
|
|
left = offset.left - that.document.scrollLeft(),
|
|
|
|
top = offset.top - that.document.scrollTop();
|
|
|
|
|
|
|
|
options.height = that.uiDialog.height();
|
|
|
|
options.width = that.uiDialog.width();
|
|
|
|
options.position = {
|
|
|
|
my: "left top",
|
2015-03-14 11:25:12 +00:00
|
|
|
at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
|
|
|
|
"top" + ( top >= 0 ? "+" : "" ) + top,
|
2013-05-31 19:00:50 +00:00
|
|
|
of: that.window
|
|
|
|
};
|
2014-12-03 16:23:59 +00:00
|
|
|
that._removeClass( $( this ), "ui-dialog-resizing" );
|
2013-02-03 13:55:34 +00:00
|
|
|
that._unblockFrames();
|
2012-05-09 20:00:21 +00:00
|
|
|
that._trigger( "resizeStop", event, filteredUi( ui ) );
|
2008-09-14 14:47:06 +00:00
|
|
|
}
|
2015-03-14 11:25:12 +00:00
|
|
|
} )
|
|
|
|
.css( "position", position );
|
2008-09-14 14:47:06 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2013-10-02 15:27:43 +00:00
|
|
|
_trackFocus: function() {
|
|
|
|
this._on( this.widget(), {
|
2014-07-23 15:10:14 +00:00
|
|
|
focusin: function( event ) {
|
|
|
|
this._makeFocusTarget();
|
2013-10-02 15:27:43 +00:00
|
|
|
this._focusedElement = $( event.target );
|
|
|
|
}
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2013-10-02 15:27:43 +00:00
|
|
|
},
|
|
|
|
|
2014-07-23 15:10:14 +00:00
|
|
|
_makeFocusTarget: function() {
|
|
|
|
this._untrackInstance();
|
|
|
|
this._trackingInstances().unshift( this );
|
|
|
|
},
|
|
|
|
|
2013-11-16 11:21:02 +00:00
|
|
|
_untrackInstance: function() {
|
|
|
|
var instances = this._trackingInstances(),
|
|
|
|
exists = $.inArray( this, instances );
|
|
|
|
if ( exists !== -1 ) {
|
|
|
|
instances.splice( exists, 1 );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_trackingInstances: function() {
|
|
|
|
var instances = this.document.data( "ui-dialog-instances" );
|
|
|
|
if ( !instances ) {
|
|
|
|
instances = [];
|
|
|
|
this.document.data( "ui-dialog-instances", instances );
|
|
|
|
}
|
|
|
|
return instances;
|
|
|
|
},
|
|
|
|
|
2009-06-09 01:10:33 +00:00
|
|
|
_minHeight: function() {
|
|
|
|
var options = this.options;
|
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
return options.height === "auto" ?
|
|
|
|
options.minHeight :
|
|
|
|
Math.min( options.minHeight, options.height );
|
2009-06-09 01:10:33 +00:00
|
|
|
},
|
|
|
|
|
2012-11-17 11:10:26 +00:00
|
|
|
_position: function() {
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
// Need to show the dialog to get the actual offset in the position plugin
|
2013-11-15 15:48:31 +00:00
|
|
|
var isVisible = this.uiDialog.is( ":visible" );
|
2010-12-18 00:53:22 +00:00
|
|
|
if ( !isVisible ) {
|
2010-01-07 04:47:17 +00:00
|
|
|
this.uiDialog.show();
|
|
|
|
}
|
2012-11-21 15:33:46 +00:00
|
|
|
this.uiDialog.position( this.options.position );
|
2010-12-18 00:53:22 +00:00
|
|
|
if ( !isVisible ) {
|
2010-01-07 04:47:17 +00:00
|
|
|
this.uiDialog.hide();
|
|
|
|
}
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2010-09-27 19:15:20 +00:00
|
|
|
_setOptions: function( options ) {
|
2012-05-09 20:00:21 +00:00
|
|
|
var that = this,
|
2012-12-11 21:23:18 +00:00
|
|
|
resize = false,
|
|
|
|
resizableOptions = {};
|
2010-07-16 12:54:50 +00:00
|
|
|
|
2010-09-27 19:15:20 +00:00
|
|
|
$.each( options, function( key, value ) {
|
2012-05-09 20:00:21 +00:00
|
|
|
that._setOption( key, value );
|
2011-11-18 11:19:32 +00:00
|
|
|
|
2013-09-17 13:30:03 +00:00
|
|
|
if ( key in that.sizeRelatedOptions ) {
|
2010-09-27 19:15:20 +00:00
|
|
|
resize = true;
|
|
|
|
}
|
2013-09-17 13:30:03 +00:00
|
|
|
if ( key in that.resizableRelatedOptions ) {
|
2010-09-27 19:15:20 +00:00
|
|
|
resizableOptions[ key ] = value;
|
|
|
|
}
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2010-09-27 19:15:20 +00:00
|
|
|
|
|
|
|
if ( resize ) {
|
|
|
|
this._size();
|
2012-11-25 05:18:51 +00:00
|
|
|
this._position();
|
2010-09-27 19:15:20 +00:00
|
|
|
}
|
2013-11-15 15:48:31 +00:00
|
|
|
if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
|
2010-09-27 19:15:20 +00:00
|
|
|
this.uiDialog.resizable( "option", resizableOptions );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-12-18 00:53:22 +00:00
|
|
|
_setOption: function( key, value ) {
|
2012-04-02 23:12:21 +00:00
|
|
|
var isDraggable, isResizable,
|
2012-05-09 20:00:21 +00:00
|
|
|
uiDialog = this.uiDialog;
|
2010-09-27 19:15:20 +00:00
|
|
|
|
2012-11-17 10:31:57 +00:00
|
|
|
if ( key === "disabled" ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-15 21:51:26 +00:00
|
|
|
this._super( key, value );
|
|
|
|
|
2012-12-07 19:54:21 +00:00
|
|
|
if ( key === "appendTo" ) {
|
|
|
|
this.uiDialog.appendTo( this._appendTo() );
|
|
|
|
}
|
|
|
|
|
2012-11-15 21:54:49 +00:00
|
|
|
if ( key === "buttons" ) {
|
|
|
|
this._createButtons();
|
|
|
|
}
|
|
|
|
|
2012-11-15 21:58:25 +00:00
|
|
|
if ( key === "closeText" ) {
|
2015-03-14 11:25:12 +00:00
|
|
|
this.uiDialogTitlebarClose.button( {
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
// Ensure that we always pass a string
|
2015-10-28 18:11:07 +00:00
|
|
|
label: $( "<a>" ).text( "" + this.options.closeText ).html()
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2012-11-15 21:58:25 +00:00
|
|
|
}
|
2011-11-18 11:19:32 +00:00
|
|
|
|
2012-11-15 21:58:25 +00:00
|
|
|
if ( key === "draggable" ) {
|
2013-11-15 15:48:31 +00:00
|
|
|
isDraggable = uiDialog.is( ":data(ui-draggable)" );
|
2012-11-15 21:58:25 +00:00
|
|
|
if ( isDraggable && !value ) {
|
2013-11-15 15:48:31 +00:00
|
|
|
uiDialog.draggable( "destroy" );
|
2012-11-15 21:58:25 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2012-11-15 21:58:25 +00:00
|
|
|
if ( !isDraggable && value ) {
|
|
|
|
this._makeDraggable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( key === "position" ) {
|
2012-11-17 11:10:26 +00:00
|
|
|
this._position();
|
2012-11-15 21:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( key === "resizable" ) {
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-11-15 21:58:25 +00:00
|
|
|
// currently resizable, becoming non-resizable
|
2013-11-15 15:48:31 +00:00
|
|
|
isResizable = uiDialog.is( ":data(ui-resizable)" );
|
2012-11-15 21:58:25 +00:00
|
|
|
if ( isResizable && !value ) {
|
2013-11-15 15:48:31 +00:00
|
|
|
uiDialog.resizable( "destroy" );
|
2012-11-15 21:58:25 +00:00
|
|
|
}
|
|
|
|
|
2015-08-21 04:11:21 +00:00
|
|
|
// Currently resizable, changing handles
|
2012-11-15 21:58:25 +00:00
|
|
|
if ( isResizable && typeof value === "string" ) {
|
|
|
|
uiDialog.resizable( "option", "handles", value );
|
|
|
|
}
|
|
|
|
|
2015-08-21 04:11:21 +00:00
|
|
|
// Currently non-resizable, becoming resizable
|
2012-11-15 21:58:25 +00:00
|
|
|
if ( !isResizable && value !== false ) {
|
2012-11-15 22:00:47 +00:00
|
|
|
this._makeResizable();
|
2012-11-15 21:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( key === "title" ) {
|
2013-11-15 15:48:31 +00:00
|
|
|
this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
|
2008-09-14 14:49:28 +00:00
|
|
|
}
|
|
|
|
},
|
2008-12-21 16:54:27 +00:00
|
|
|
|
2008-08-16 14:13:55 +00:00
|
|
|
_size: function() {
|
2015-08-24 12:59:54 +00:00
|
|
|
|
2012-10-29 18:37:06 +00:00
|
|
|
// If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
|
|
|
|
// divs will both have width and height set, so we need to reset them
|
2012-12-07 21:57:03 +00:00
|
|
|
var nonContentHeight, minContentHeight, maxContentHeight,
|
2012-10-26 18:36:35 +00:00
|
|
|
options = this.options;
|
2008-12-19 03:05:01 +00:00
|
|
|
|
2012-12-11 21:23:18 +00:00
|
|
|
// Reset content sizing
|
2015-03-14 11:25:12 +00:00
|
|
|
this.element.show().css( {
|
2010-12-18 00:53:22 +00:00
|
|
|
width: "auto",
|
2010-03-26 01:58:08 +00:00
|
|
|
minHeight: 0,
|
2012-12-07 21:57:03 +00:00
|
|
|
maxHeight: "none",
|
2010-03-26 01:58:08 +00:00
|
|
|
height: 0
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2008-12-21 16:54:27 +00:00
|
|
|
|
2010-12-18 00:53:22 +00:00
|
|
|
if ( options.minWidth > options.width ) {
|
2010-04-19 22:42:34 +00:00
|
|
|
options.width = options.minWidth;
|
|
|
|
}
|
|
|
|
|
2015-08-21 04:11:21 +00:00
|
|
|
// Reset wrapper sizing
|
2008-12-21 16:54:27 +00:00
|
|
|
// determine the height of all the non-content elements
|
2015-03-14 11:25:12 +00:00
|
|
|
nonContentHeight = this.uiDialog.css( {
|
|
|
|
height: "auto",
|
|
|
|
width: options.width
|
|
|
|
} )
|
2011-11-28 21:52:10 +00:00
|
|
|
.outerHeight();
|
2010-10-05 20:20:43 +00:00
|
|
|
minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
|
2012-12-07 21:57:03 +00:00
|
|
|
maxContentHeight = typeof options.maxHeight === "number" ?
|
|
|
|
Math.max( 0, options.maxHeight - nonContentHeight ) :
|
|
|
|
"none";
|
2011-11-18 11:19:32 +00:00
|
|
|
|
2010-10-05 20:20:43 +00:00
|
|
|
if ( options.height === "auto" ) {
|
2015-03-14 11:25:12 +00:00
|
|
|
this.element.css( {
|
2012-10-26 18:36:35 +00:00
|
|
|
minHeight: minContentHeight,
|
2012-12-07 21:57:03 +00:00
|
|
|
maxHeight: maxContentHeight,
|
2012-10-26 18:36:35 +00:00
|
|
|
height: "auto"
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2010-10-05 20:20:43 +00:00
|
|
|
} else {
|
2012-12-07 21:57:03 +00:00
|
|
|
this.element.height( Math.max( 0, options.height - nonContentHeight ) );
|
2010-10-05 20:20:43 +00:00
|
|
|
}
|
2009-06-09 01:10:33 +00:00
|
|
|
|
2013-11-15 15:48:31 +00:00
|
|
|
if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
|
2010-12-18 00:53:22 +00:00
|
|
|
this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
|
2010-03-12 01:10:57 +00:00
|
|
|
}
|
2012-11-17 12:07:03 +00:00
|
|
|
},
|
2008-06-04 02:34:33 +00:00
|
|
|
|
2013-02-03 13:55:34 +00:00
|
|
|
_blockFrames: function() {
|
2015-03-14 11:25:12 +00:00
|
|
|
this.iframeBlocks = this.document.find( "iframe" ).map( function() {
|
2013-02-03 13:55:34 +00:00
|
|
|
var iframe = $( this );
|
|
|
|
|
|
|
|
return $( "<div>" )
|
2015-03-14 11:25:12 +00:00
|
|
|
.css( {
|
2013-02-03 13:55:34 +00:00
|
|
|
position: "absolute",
|
|
|
|
width: iframe.outerWidth(),
|
|
|
|
height: iframe.outerHeight()
|
2015-03-14 11:25:12 +00:00
|
|
|
} )
|
2013-02-03 13:55:34 +00:00
|
|
|
.appendTo( iframe.parent() )
|
2015-03-14 11:25:12 +00:00
|
|
|
.offset( iframe.offset() )[ 0 ];
|
|
|
|
} );
|
2013-02-03 13:55:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_unblockFrames: function() {
|
|
|
|
if ( this.iframeBlocks ) {
|
|
|
|
this.iframeBlocks.remove();
|
|
|
|
delete this.iframeBlocks;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-02-20 22:35:48 +00:00
|
|
|
_allowInteraction: function( event ) {
|
2013-11-15 15:48:31 +00:00
|
|
|
if ( $( event.target ).closest( ".ui-dialog" ).length ) {
|
2013-02-20 22:35:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Remove hack when datepicker implements
|
|
|
|
// the .ui-front logic (#8989)
|
2013-11-15 15:48:31 +00:00
|
|
|
return !!$( event.target ).closest( ".ui-datepicker" ).length;
|
2013-02-20 22:35:48 +00:00
|
|
|
},
|
|
|
|
|
2012-11-17 12:07:03 +00:00
|
|
|
_createOverlay: function() {
|
|
|
|
if ( !this.options.modal ) {
|
|
|
|
return;
|
|
|
|
}
|
2012-12-11 21:23:18 +00:00
|
|
|
|
2021-02-21 23:02:02 +00:00
|
|
|
var jqMinor = $.fn.jquery.substring( 0, 4 );
|
|
|
|
|
2013-08-06 19:06:08 +00:00
|
|
|
// We use a delay in case the overlay is created from an
|
|
|
|
// event that we're going to be cancelling (#2804)
|
|
|
|
var isOpening = true;
|
2015-03-14 11:25:12 +00:00
|
|
|
this._delay( function() {
|
2013-08-06 19:06:08 +00:00
|
|
|
isOpening = false;
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2013-08-06 19:06:08 +00:00
|
|
|
|
|
|
|
if ( !this.document.data( "ui-dialog-overlays" ) ) {
|
|
|
|
|
|
|
|
// Prevent use of anchors and inputs
|
2017-05-11 17:58:08 +00:00
|
|
|
// This doesn't use `_on()` because it is a shared event handler
|
|
|
|
// across all open modal dialogs.
|
|
|
|
this.document.on( "focusin.ui-dialog", function( event ) {
|
|
|
|
if ( isOpening ) {
|
|
|
|
return;
|
2012-10-26 14:59:41 +00:00
|
|
|
}
|
2017-05-11 17:58:08 +00:00
|
|
|
|
|
|
|
var instance = this._trackingInstances()[ 0 ];
|
|
|
|
if ( !instance._allowInteraction( event ) ) {
|
|
|
|
event.preventDefault();
|
|
|
|
instance._focusTabbable();
|
2021-02-21 23:02:02 +00:00
|
|
|
|
2023-05-10 08:55:40 +00:00
|
|
|
// Support: jQuery >=3.4 <3.7 only
|
|
|
|
// In jQuery 3.4-3.6, there are multiple issues with focus/blur
|
|
|
|
// trigger chains or when triggering is done on a hidden element
|
|
|
|
// at least once.
|
|
|
|
// Trigger focus in a delay in addition if needed to avoid the issues.
|
2021-02-21 23:02:02 +00:00
|
|
|
// See https://github.com/jquery/jquery/issues/4382
|
2023-05-10 08:55:40 +00:00
|
|
|
// See https://github.com/jquery/jquery/issues/4856
|
|
|
|
// See https://github.com/jquery/jquery/issues/4950
|
|
|
|
if ( jqMinor === "3.4." || jqMinor === "3.5." || jqMinor === "3.6." ) {
|
2021-02-21 23:02:02 +00:00
|
|
|
instance._delay( instance._restoreTabbableFocus );
|
|
|
|
}
|
2017-05-11 17:58:08 +00:00
|
|
|
}
|
|
|
|
}.bind( this ) );
|
2012-10-26 14:59:41 +00:00
|
|
|
}
|
2012-05-07 13:57:18 +00:00
|
|
|
|
2013-11-15 15:48:31 +00:00
|
|
|
this.overlay = $( "<div>" )
|
2013-01-26 10:03:14 +00:00
|
|
|
.appendTo( this._appendTo() );
|
2014-12-03 16:23:59 +00:00
|
|
|
|
|
|
|
this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
|
2012-12-11 21:23:18 +00:00
|
|
|
this._on( this.overlay, {
|
2012-11-17 12:07:03 +00:00
|
|
|
mousedown: "_keepFocus"
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2013-08-06 19:06:08 +00:00
|
|
|
this.document.data( "ui-dialog-overlays",
|
2015-03-14 11:25:12 +00:00
|
|
|
( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
|
2008-06-04 02:34:33 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2012-11-17 12:07:03 +00:00
|
|
|
_destroyOverlay: function() {
|
|
|
|
if ( !this.options.modal ) {
|
|
|
|
return;
|
|
|
|
}
|
2012-12-11 21:23:18 +00:00
|
|
|
|
2013-01-24 01:12:25 +00:00
|
|
|
if ( this.overlay ) {
|
2013-08-06 19:06:08 +00:00
|
|
|
var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
|
|
|
|
|
|
|
|
if ( !overlays ) {
|
2017-05-11 17:58:08 +00:00
|
|
|
this.document.off( "focusin.ui-dialog" );
|
2015-07-17 15:00:44 +00:00
|
|
|
this.document.removeData( "ui-dialog-overlays" );
|
2013-08-06 19:06:08 +00:00
|
|
|
} else {
|
|
|
|
this.document.data( "ui-dialog-overlays", overlays );
|
2013-01-24 01:12:25 +00:00
|
|
|
}
|
2013-08-06 19:06:08 +00:00
|
|
|
|
2013-01-24 01:12:25 +00:00
|
|
|
this.overlay.remove();
|
|
|
|
this.overlay = null;
|
2008-06-04 02:34:33 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2008-06-04 02:34:33 +00:00
|
|
|
|
2014-12-03 16:23:59 +00:00
|
|
|
// DEPRECATED
|
|
|
|
// TODO: switch return back to widget declaration at top of file when this is removed
|
|
|
|
if ( $.uiBackCompat !== false ) {
|
|
|
|
|
|
|
|
// Backcompat for dialogClass option
|
|
|
|
$.widget( "ui.dialog", $.ui.dialog, {
|
|
|
|
options: {
|
|
|
|
dialogClass: ""
|
|
|
|
},
|
|
|
|
_createWrapper: function() {
|
|
|
|
this._super();
|
|
|
|
this.uiDialog.addClass( this.options.dialogClass );
|
|
|
|
},
|
|
|
|
_setOption: function( key, value ) {
|
|
|
|
if ( key === "dialogClass" ) {
|
|
|
|
this.uiDialog
|
|
|
|
.removeClass( this.options.dialogClass )
|
|
|
|
.addClass( value );
|
|
|
|
}
|
|
|
|
this._superApply( arguments );
|
|
|
|
}
|
2015-03-14 11:25:12 +00:00
|
|
|
} );
|
2014-12-03 16:23:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $.ui.dialog;
|
|
|
|
|
2021-06-06 22:58:12 +00:00
|
|
|
} );
|