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'); + } + }); +});