diff --git a/static/js/app/landing_pages.js b/static/js/app/landing_pages.js index d14a0188..1486d835 100644 --- a/static/js/app/landing_pages.js +++ b/static/js/app/landing_pages.js @@ -141,5 +141,19 @@ $(document).ready(function(){ $( '.modal-backdrop' ).not( '.fv-modal-stack' ).css( 'z-index', 1039 + (10 * $('body').data( 'fv_open_modals' ))); $( '.modal-backdrop' ).not( 'fv-modal-stack' ).addClass( 'fv-modal-stack' ); }); + $.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 ) ); + }; load() }) diff --git a/static/js/app/templates.js b/static/js/app/templates.js index f8cbd94e..e36291d3 100644 --- a/static/js/app/templates.js +++ b/static/js/app/templates.js @@ -170,5 +170,19 @@ function load(){ } $(document).ready(function(){ + $.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 ) ); + }; load() })