* v1.0.4 - 05-04-2021 20:10
* JQuery UI Dialog Extended
* Copyright 2013-2015, Felix Nagel (http://www.felixnagel.com)
* Copyright 2021, Team Updraft
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://github.com/fnagel/jquery-ui-extensions
* Option width and height normally set the overall dialog dimensions.
* This extensions make these options the dimensions of the content pane if
* option useContentSize is enabled. This way it's possible to set the real
* Please note you won't get the original size but the calculated overall size
* when using the width and height option getter.
$.widget("ui.dialog", $.ui.dialog, {
height: 200, // auto is not allowed when using animation
resizeOnWindowResize: false,
scrollWithViewport: false,
resizeAccordingToViewport: true,
resizeToBestPossibleSize: false,
// width and height set the content size, not overall size
// Changes content and resizes dialog
change: function(content, width, height, animate) {
if (typeof animate !== "boolean") {
animate = this.options.useAnimation;
this.element.one(this.widgetEventPrefix + "resized", this, function(event) {
event.data.element.html(content);
event.data.setAriaLive(false);
event.data.focusTabbable();
this.element.html(content);
this.changeSize(width, height);
changeSize: function(width, height) {
_setOption: function(key, value) {
this._oldSize.width = value;
this._oldSize.height = value;
// we need to adjust the size as we need to set the overall dialog size
if (this.options.useAnimation && this.options.useContentSize && this._isVisible) {
value = value + ( this.uiDialog.width() - this.element.width() );
value = value + ( this.uiDialog.outerHeight() - this.element.height() );
// calculate actual displayed size, data contains already the overall dimensions
_getSize: function(data) {
var options = this.options,
feedback = $.position.getWithinInfo(options.position.of),
portrait = ( feedback.height >= feedback.width ) ? true : false,
width: feedback.width - ( this.uiDialog.outerWidth() - this.uiDialog.width() ),
if (options.forceFullscreen) {
if (options.resizeToBestPossibleSize) {
data = this._calcSize(data, viewport.width, "width", "height");
data = this._calcSize(data, viewport.height, "height", "width");
if (options.resizeAccordingToViewport || options.resizeToBestPossibleSize) {
if (viewport.width < data.width) {
data = this._calcSize(data, viewport.width, "width", "height");
if (viewport.height < data.height) {
data = this._calcSize(data, viewport.height, "height", "width");
_calcSize: function( data, value, sortBy, toSort ) {
newData[toSort] = Math.max(0, (data[ toSort ] / data[ sortBy ]) * value);
// overwrite options with recalculated dimensions
$.extend(this.options, this._getSize(this.options));
if (this._isVisible && this.options.useAnimation) {
if (this.options.useContentSize) {
* Sets the size of the dialog
* Options width and height define content size, not overall size
_contentSize: function() {
// 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
var nonContentHeight, nonContentWidth, actualSize,
nonContentWidth = this.element.show().css({
}).outerWidth() - options.width;
this.element.css("width", "auto");
if (options.minWidth > options.width + nonContentWidth) {
options.width = options.minWidth;
// determine the height of all the non-content elements
nonContentHeight = this.uiDialog.css({
width: options.width + nonContentWidth
actualSize = this._getSize({
width: options.width + nonContentWidth,
height: options.height + nonContentHeight
this.uiDialog.css("width", actualSize.width);
this.element.height(Math.max(0, actualSize.height - nonContentHeight));
if (this.uiDialog.is(":data(ui-resizable)") ) {
this.uiDialog.resizable("option", "minHeight", this._minHeight());
// save calculated overall size
$.extend(options, actualSize);
// Processes the animated positioning (position using callback), works with any width and height options
_animateUsing: function( position, data ) {
// calculate new position based on the viewport
position.left = ( data.target.left + ( data.target.width - this.options.width - ( this.uiDialog.outerWidth() - this.uiDialog.width() ) ) / 2 );
position.top = ( data.target.top + ( data.target.height - this.options.height ) / 2 );
this.uiDialog.animate(position, $.extend({}, this.options.animateOptions, {
that._trigger("resized");
// animated the size, uses width and height options like default dialog widget (overall size)
_animateSize: function() {
var options = this.options;
}, options.animateOptions);
// options.height is overall size, we need content size
height: options.height - ( this.uiDialog.outerHeight() - this.element.height() )
}, options.animateOptions);
// position overwrite for animated positioning
this._positionOptions = this.options.position;
// change position.using mechanism
if (this.options.useAnimation && this._isVisible) {
this.options.position.using = function(position, feedback) {
that._animateUsing(position, feedback);
// reset position.using mechanism
this.options.position = this._positionOptions;
setAriaLive: function(busy) {
"aria-live": "assertive",
"aria-relevant": "additions removals text",
// all following functions add a variable to determine if the dialog is visible
width: this.options.width,
height: this.options.height
// make dialog responsive to viewport changes
this._on(window, this._windowResizeEvents);
if (this.options.resizeOnWindowResize) {
if (window === e.target) {
this._addTimeout(function() {
this._setOptions(this._oldSize);
this._addTimeout(function() {
// second test prevents initial page load scroll event
if (this.options.scrollWithViewport && this.timeout) {
this._addTimeout(function() {
_addTimeout: function(callback) {
clearTimeout(this.timeout);
this.timeout = this._delay(callback, 250);
_makeResizable: function() {
this.element.on(this.widgetEventPrefix + "resizestop", this, function(event) {
event.data.element.css("width", "auto");
event.data.uiDialog.css("height", "auto");
_makeDraggable: function() {
this.element.on(this.widgetEventPrefix + "dragstop", this, function(event) {
event.data.options.position = event.data._positionOptions;
focusTabbable: function() {
_createOverlay: function() {
if (this.options.modal && this.options.closeModalOnClick) {
mousedown: function(event) {