From b157fad0b646d636973c1a8748248277e5f2ea47 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Wed, 15 May 2019 15:41:38 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B02166:=20Portal:=20fields=20in=20CKEditor?= =?UTF-8?q?=20modals=20are=20inactive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../portal/src/views/layout.html.twig | 8 +----- .../portal/web/js/bootstrap-patches.js | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 datamodels/2.x/itop-portal-base/portal/web/js/bootstrap-patches.js diff --git a/datamodels/2.x/itop-portal-base/portal/src/views/layout.html.twig b/datamodels/2.x/itop-portal-base/portal/src/views/layout.html.twig index c09adb756..e0356a14f 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/views/layout.html.twig +++ b/datamodels/2.x/itop-portal-base/portal/src/views/layout.html.twig @@ -94,6 +94,7 @@ + {# Visible.js to check if an element is visible on screen #} @@ -458,13 +459,6 @@ $(this).removeData('bs.modal'); $(this).find('.modal-content').html(GetContentLoaderTemplate()); }); - // Hack to enable multiple modals by making sure the .modal-open class is set to the when there is at least one modal open left - $('body').on('hidden.bs.modal', function () { - if($('.modal.in').length > 0) - { - $('body').addClass('modal-open'); - } - }); // Hide tooltips when a modal is opening, otherwise it might be overlapping it $('body').on('show.bs.modal', function () { $(this).find('.tooltip.in').tooltip('hide'); diff --git a/datamodels/2.x/itop-portal-base/portal/web/js/bootstrap-patches.js b/datamodels/2.x/itop-portal-base/portal/web/js/bootstrap-patches.js new file mode 100644 index 000000000..576995eb5 --- /dev/null +++ b/datamodels/2.x/itop-portal-base/portal/web/js/bootstrap-patches.js @@ -0,0 +1,26 @@ +/* + * Patches for bootstrap 3 as it is no longer maintained by its editor + */ + +//N°2166: Fix a boostrap/CKeditor incompatibility with their respective modals (source: https://stackoverflow.com/a/23667151) +$.fn.modal.Constructor.prototype.enforceFocus = function () { + var $modalElement = this.$element; + $(document).on('focusin.modal', function (e) { + var $parent = $(e.target.parentNode); + if ($modalElement[0] !== e.target && !$modalElement.has(e.target).length + // add whatever conditions you need here: + && + !$parent.hasClass('cke_dialog_ui_input_select') && !$parent.hasClass('cke_dialog_ui_input_text')) { + $modalElement.focus() + } + }) +}; + +// Hack to enable multiple modals by making sure the .modal-open class is set to the when there is at least one modal open left +$(document).ready(function() { + $('body').on('hidden.bs.modal', function () { + if ($('.modal.in').length > 0) { + $('body').addClass('modal-open'); + } + }); +});