wp/wp-includes/js/jquery/ui/dialog.js
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
     1 /*!
     1 /*!
     2  * jQuery UI Dialog 1.13.1
     2  * jQuery UI Dialog 1.13.3
     3  * http://jqueryui.com
     3  * https://jqueryui.com
     4  *
     4  *
     5  * Copyright jQuery Foundation and other contributors
     5  * Copyright OpenJS Foundation and other contributors
     6  * Released under the MIT license.
     6  * Released under the MIT license.
     7  * http://jquery.org/license
     7  * https://jquery.org/license
     8  */
     8  */
     9 
     9 
    10 //>>label: Dialog
    10 //>>label: Dialog
    11 //>>group: Widgets
    11 //>>group: Widgets
    12 //>>description: Displays customizable dialog windows.
    12 //>>description: Displays customizable dialog windows.
    13 //>>docs: http://api.jqueryui.com/dialog/
    13 //>>docs: https://api.jqueryui.com/dialog/
    14 //>>demos: http://jqueryui.com/dialog/
    14 //>>demos: https://jqueryui.com/dialog/
    15 //>>css.structure: ../../themes/base/core.css
    15 //>>css.structure: ../../themes/base/core.css
    16 //>>css.structure: ../../themes/base/dialog.css
    16 //>>css.structure: ../../themes/base/dialog.css
    17 //>>css.theme: ../../themes/base/theme.css
    17 //>>css.theme: ../../themes/base/theme.css
    18 
    18 
    19 ( function( factory ) {
    19 ( function( factory ) {
    26 			"jquery",
    26 			"jquery",
    27 			"./button",
    27 			"./button",
    28 			"./draggable",
    28 			"./draggable",
    29 			"./mouse",
    29 			"./mouse",
    30 			"./resizable",
    30 			"./resizable",
    31 			"./core"
    31 			"../focusable",
       
    32 			"../keycode",
       
    33 			"../position",
       
    34 			"../safe-active-element",
       
    35 			"../safe-blur",
       
    36 			"../tabbable",
       
    37 			"../unique-id",
       
    38 			"../version",
       
    39 			"../widget"
    32 		], factory );
    40 		], factory );
    33 	} else {
    41 	} else {
    34 
    42 
    35 		// Browser globals
    43 		// Browser globals
    36 		factory( jQuery );
    44 		factory( jQuery );
    37 	}
    45 	}
    38 } )( function( $ ) {
    46 } )( function( $ ) {
    39 "use strict";
    47 "use strict";
    40 
    48 
    41 $.widget( "ui.dialog", {
    49 $.widget( "ui.dialog", {
    42 	version: "1.13.1",
    50 	version: "1.13.3",
    43 	options: {
    51 	options: {
    44 		appendTo: "body",
    52 		appendTo: "body",
    45 		autoOpen: true,
    53 		autoOpen: true,
    46 		buttons: [],
    54 		buttons: [],
    47 		classes: {
    55 		classes: {
   352 
   360 
   353 		this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
   361 		this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
   354 		this._on( this.uiDialog, {
   362 		this._on( this.uiDialog, {
   355 			keydown: function( event ) {
   363 			keydown: function( event ) {
   356 				if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
   364 				if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
   357 					event.keyCode === $.ui.keyCode.ESCAPE ) {
   365 						event.keyCode === $.ui.keyCode.ESCAPE ) {
   358 					event.preventDefault();
   366 					event.preventDefault();
   359 					this.close( event );
   367 					this.close( event );
   360 					return;
   368 					return;
   361 				}
   369 				}
   362 
   370 
   367 				var tabbables = this.uiDialog.find( ":tabbable" ),
   375 				var tabbables = this.uiDialog.find( ":tabbable" ),
   368 					first = tabbables.first(),
   376 					first = tabbables.first(),
   369 					last = tabbables.last();
   377 					last = tabbables.last();
   370 
   378 
   371 				if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
   379 				if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
   372 					!event.shiftKey ) {
   380 						!event.shiftKey ) {
   373 					this._delay( function() {
   381 					this._delay( function() {
   374 						first.trigger( "focus" );
   382 						first.trigger( "focus" );
   375 					} );
   383 					} );
   376 					event.preventDefault();
   384 					event.preventDefault();
   377 				} else if ( ( event.target === first[ 0 ] ||
   385 				} else if ( ( event.target === first[ 0 ] ||
   378 					event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
   386 						event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
   379 					this._delay( function() {
   387 					this._delay( function() {
   380 						last.trigger( "focus" );
   388 						last.trigger( "focus" );
   381 					} );
   389 					} );
   382 					event.preventDefault();
   390 					event.preventDefault();
   383 				}
   391 				}
   871 				var instance = this._trackingInstances()[ 0 ];
   879 				var instance = this._trackingInstances()[ 0 ];
   872 				if ( !instance._allowInteraction( event ) ) {
   880 				if ( !instance._allowInteraction( event ) ) {
   873 					event.preventDefault();
   881 					event.preventDefault();
   874 					instance._focusTabbable();
   882 					instance._focusTabbable();
   875 
   883 
   876 					// Support: jQuery >=3.4 <3.6 only
   884 					// Support: jQuery >=3.4 <3.7 only
   877 					// Focus re-triggering in jQuery 3.4/3.5 makes the original element
   885 					// In jQuery 3.4-3.6, there are multiple issues with focus/blur
   878 					// have its focus event propagated last, breaking the re-targeting.
   886 					// trigger chains or when triggering is done on a hidden element
   879 					// Trigger focus in a delay in addition if needed to avoid the issue
   887 					// at least once.
       
   888 					// Trigger focus in a delay in addition if needed to avoid the issues.
   880 					// See https://github.com/jquery/jquery/issues/4382
   889 					// See https://github.com/jquery/jquery/issues/4382
   881 					if ( jqMinor === "3.4." || jqMinor === "3.5." ) {
   890 					// See https://github.com/jquery/jquery/issues/4856
       
   891 					// See https://github.com/jquery/jquery/issues/4950
       
   892 					if ( jqMinor === "3.4." || jqMinor === "3.5." || jqMinor === "3.6." ) {
   882 						instance._delay( instance._restoreTabbableFocus );
   893 						instance._delay( instance._restoreTabbableFocus );
   883 					}
   894 					}
   884 				}
   895 				}
   885 			}.bind( this ) );
   896 			}.bind( this ) );
   886 		}
   897 		}