diff --git a/core/misc/dialog/dialog.js b/core/misc/dialog/dialog.js index 3d18cad811..7aaaa8a0e7 100644 --- a/core/misc/dialog/dialog.js +++ b/core/misc/dialog/dialog.js @@ -75,8 +75,8 @@ openDialog({modal: true}); }, close: closeDialog, - container: getContainer, - options: setOptions, + getContainer: getContainer, + setOptions: setOptions, handleDialogResize: handleDialogResize }; @@ -97,12 +97,29 @@ $(window).trigger('dialog:afterclose', [dialog, $element]); } + /** + * Gets the HTMLElement that contains the dialog. + * + * jQuery UI dialogs are contained in outer HTMLElement. + * For themes or modules that override the Drupal.dialog with non jQuery UI + * dialogs that do not have a containing element other than the dialog + * itself should just return the dialog element. + * + * @return {HTMLElement} element + * The HTMLElement that contains the dialog. + */ function getContainer() { return $element.dialog('widget')[0]; } - function setOptions($options) { - $element.dialog('option', $options); + /** + * Sets the options for the dialog. + * + * @param {object} options + * jQuery UI options to be passed to the dialog. + */ + function setOptions(options) { + $element.dialog('option', options); } /** diff --git a/core/modules/outside_in/js/off-canvas.js b/core/modules/outside_in/js/off-canvas.js index bbaf95c675..f69aed9fec 100644 --- a/core/modules/outside_in/js/off-canvas.js +++ b/core/modules/outside_in/js/off-canvas.js @@ -34,7 +34,7 @@ var offsets = displace.offsets; var $element = event.data.$element; var dialog = event.data.dialog; - var $container = $(dialog.container()); + var $container = $(dialog.getContainer()); var adjustedOptions = { // @see http://api.jqueryui.com/position/ @@ -50,7 +50,7 @@ height: ($(window).height() - (offsets.top + offsets.bottom)) + 'px' }); - dialog.options(adjustedOptions); + dialog.setOptions(adjustedOptions); $element.trigger('dialogContentResize.off-canvas'); } @@ -66,7 +66,7 @@ if ($('body').outerWidth() < minDisplaceWidth) { return; } - var $container = $(event.data.dialog.container()); + var $container = $(event.data.dialog.getContainer()); var width = $container.outerWidth(); var mainCanvasPadding = $mainCanvasWrapper.css('padding-' + edge); @@ -100,7 +100,7 @@ .on('dialogContentResize.off-canvas', eventData, debounce(bodyPadding, 100)) .trigger('dialogresize.off-canvas'); - $(dialog.container()).attr('data-offset-' + edge, ''); + $(dialog.getContainer()).attr('data-offset-' + edge, ''); $(window) .on('resize.off-canvas scroll.off-canvas', eventData, debounce(resetSize, 100))