From a93be39aeb968ef9a8501d1cc64ab349bb03fddf Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Wed, 26 Jun 2019 14:15:04 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B02166:=20Fix=20regression=20introduced=20?= =?UTF-8?q?in=20b157fad?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../portal/web/js/bootstrap-patches.js | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) 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 index 576995eb5..2e47532fb 100644 --- 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 @@ -2,18 +2,20 @@ * 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() - } - }) +//N°2166: Fix a boostrap/CKeditor incompatibility with their respective modals (source: https://stackoverflow.com/a/31679096) +$.fn.modal.Constructor.prototype.enforceFocus = function() { + $( document ) + .off( 'focusin.bs.modal' ) // guard against infinite focus loop + .on( 'focusin.bs.modal', $.proxy( function( e ) { + if ( + this.$element[ 0 ] !== e.target && !this.$element.has( e.target ).length + // CKEditor compatibility fix start. + && !$( e.target ).closest( '.cke_dialog, .cke' ).length + // CKEditor compatibility fix end. + ) { + this.$element.trigger( 'focus' ); + } + }, this ) ); }; // 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