diff --git a/js/entity_browser.modal.js b/js/entity_browser.modal.js index 91de938..14df0ae 100644 --- a/js/entity_browser.modal.js +++ b/js/entity_browser.modal.js @@ -7,7 +7,7 @@ 'use strict'; - Drupal.entityBrowser = {}; + Drupal.entityBrowserModal = {}; Drupal.AjaxCommands.prototype.select_entities = function (ajax, response, status) { var uuid = drupalSettings.entity_browser.modal.uuid; @@ -46,67 +46,71 @@ Drupal.behaviors.fluidModal = { attach: function (context) { - // on window resize run function + // Recalculate dialog size on window resize. $(window).resize(function (context) { - Drupal.entityBrowser.fluidDialog(); + Drupal.entityBrowserModal.fluidDialog(); }); - // catch dialog if opened within a viewport smaller than the dialog width - // run function on all dialog opens - $(document).on("dialogopen", ".ui-dialog", function (event, ui) { - Drupal.entityBrowser.fluidDialog(); + // Catch dialog if opened within a viewport smaller than the dialog width + // and recalculate size of all open dialogs. + $(document).on('dialogopen', '.ui-dialog', function (event, ui) { + Drupal.entityBrowserModal.fluidDialog(); }); - // Disable scrolling of the whole browser window to not interfere with a iframe scrollbar + // Disable scrolling of the whole browser window to not interfere with the + // iframe scrollbar. $(window).on({ 'dialog:aftercreate': function (event, dialog, $element, settings) { - $("body").css({ overflow: 'hidden' }) + $('body').css({overflow: 'hidden'}); }, 'dialog:beforeclose': function (event, dialog, $element) { - $("body").css({ overflow: 'inherit' }) + $('body').css({overflow: 'inherit'}); } }); } }; /** - * Allows a fluid modal dialog + * Recalculates size of the modal. */ - Drupal.entityBrowser.fluidDialog = function () { + Drupal.entityBrowserModal.fluidDialog = function () { - var $visible = $(".ui-dialog:visible"); - // each open dialog + var $visible = $('.ui-dialog:visible'); + // For each open dialog. $visible.each(function () { var $this = $(this); - var dialog = $this.find(".ui-dialog-content").data("ui-dialog"); - // if fluid option == true + var dialog = $this.find('.ui-dialog-content').data('ui-dialog'); + // If fluid option == true. if (dialog.options.fluid) { var wWidth = $(window).width(); - // check window width against dialog width + // Check window width against dialog width. if (wWidth < (dialog.options.maxWidth + 50)) { - //if there is a maxWidth, don't allow a bigger size - dialog.option("width", dialog.options.maxWidth); - } else { - // if no maxWidth is defined, make it responsive - dialog.option("width", '92%'); + // If there is a maxWidth, don't allow a bigger size. + dialog.option('width', dialog.options.maxWidth); + } + else { + // If no maxWidth is defined, make it responsive. + dialog.option('width', '92%'); } var vHeight = $(window).height(); - // check window width against dialog width + // Check window width against dialog width. if (vHeight < (dialog.options.maxHeight + 50)) { - //if there is a maxHeight, don't allow a bigger size - dialog.option("height", dialog.options.maxHeight); - } else { - // if no maxHeight is defined, make it responsive - dialog.option("height", vHeight-100); + // If there is a maxHeight, don't allow a bigger size. + dialog.option('height', dialog.options.maxHeight); + } + else { + // If no maxHeight is defined, make it responsive. + dialog.option('height', vHeight - 100); - // Because there is no iframe height 100% in HTML 5, we have to set the height of the iframe as well + // Because there is no iframe height 100% in HTML 5, we have to set + // the height of the iframe as well. var contentHeight = $this.find('.ui-dialog-content').height() - 20; - $this.find("iframe").css("height", contentHeight); + $this.find('iframe').css('height', contentHeight); } - //reposition dialog - dialog.option("position", dialog.options.position); + // Reposition dialog. + dialog.option('position', dialog.options.position); } }); }; diff --git a/src/Plugin/EntityBrowser/Display/Modal.php b/src/Plugin/EntityBrowser/Display/Modal.php index 6c1572e..e3bd93f 100644 --- a/src/Plugin/EntityBrowser/Display/Modal.php +++ b/src/Plugin/EntityBrowser/Display/Modal.php @@ -230,9 +230,9 @@ class Modal extends DisplayBase implements DisplayRouterInterface { 'height' => 'auto', 'maxWidth' => $this->configuration['width'], 'maxHeight' => $this->configuration['height'], - 'fluid' => true, - 'autoResize' => false, - 'resizable' => false, + 'fluid' => 1, + 'autoResize' => 0, + 'resizable' => 0, ])); return $response; }