From 257a3ad0e317d9686f2de2f18fd9b14c1f280ffa Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Fri, 1 Aug 2014 20:14:43 +0000 Subject: [PATCH] Disable background page scrolling when modals are open. props celloexpressions. fixes #29074. git-svn-id: https://develop.svn.wordpress.org/trunk@29346 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/css/common.css | 4 ++++ src/wp-admin/css/themes.css | 4 ---- src/wp-admin/js/theme.js | 4 ++-- src/wp-includes/js/media-views.js | 6 ++++++ src/wp-includes/js/thickbox/thickbox.js | 2 ++ 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/css/common.css b/src/wp-admin/css/common.css index a0d3b3fc41..076794fb6d 100644 --- a/src/wp-admin/css/common.css +++ b/src/wp-admin/css/common.css @@ -218,6 +218,10 @@ body.iframe { padding-top: 1px; } +body.modal-open { + overflow: hidden; +} + iframe, img { border: 0; diff --git a/src/wp-admin/css/themes.css b/src/wp-admin/css/themes.css index 2add665641..99a52d3f00 100644 --- a/src/wp-admin/css/themes.css +++ b/src/wp-admin/css/themes.css @@ -409,10 +409,6 @@ z-index: 10; } -body.theme-overlay-open { - overflow: hidden; -} - .theme-overlay .theme-header { position: absolute; top: 0; diff --git a/src/wp-admin/js/theme.js b/src/wp-admin/js/theme.js index 2236498a29..67e125a9be 100644 --- a/src/wp-admin/js/theme.js +++ b/src/wp-admin/js/theme.js @@ -701,7 +701,7 @@ themes.view.Details = wp.Backbone.View.extend({ // Performs the actions to effectively close // the theme details overlay closeOverlay: function() { - $( 'body' ).removeClass( 'theme-overlay-open' ); + $( 'body' ).removeClass( 'modal-open' ); this.remove(); this.unbind(); this.trigger( 'theme:collapse' ); @@ -1000,7 +1000,7 @@ themes.view.Themes = wp.Backbone.View.extend({ // Sets this.view to 'detail' this.setView( 'detail' ); - $( 'body' ).addClass( 'theme-overlay-open' ); + $( 'body' ).addClass( 'modal-open' ); // Set up the theme details view this.overlay = new themes.view.Details({ diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 65ea481d2b..3d2b11236b 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -3228,6 +3228,9 @@ }; } + // Disable page scrolling. + $( 'body' ).addClass( 'modal-open' ); + $el.show().find( '.media-modal-close' ).focus(); return this.propagate('open'); }, @@ -3243,6 +3246,9 @@ return this; } + // Enable page scrolling. + $( 'body' ).removeClass( 'modal-open' ); + // Hide modal and remove restricted media modal tab focus once it's closed this.$el.hide().undelegate( 'keydown' ); diff --git a/src/wp-includes/js/thickbox/thickbox.js b/src/wp-includes/js/thickbox/thickbox.js index 0371bd28d0..6cbefb21c8 100644 --- a/src/wp-includes/js/thickbox/thickbox.js +++ b/src/wp-includes/js/thickbox/thickbox.js @@ -46,6 +46,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic if(document.getElementById("TB_overlay") === null){ jQuery("body").append("
"); jQuery("#TB_overlay").click(tb_remove); + jQuery( 'body' ).addClass( 'modal-open' ); } } @@ -264,6 +265,7 @@ function tb_remove() { jQuery("#TB_imageOff").unbind("click"); jQuery("#TB_closeWindowButton").unbind("click"); jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("tb_unload").unbind().remove();}); + jQuery( 'body' ).removeClass( 'modal-open' ); jQuery("#TB_load").remove(); if (typeof document.body.style.maxHeight == "undefined") {//if IE 6 jQuery("body","html").css({height: "auto", width: "auto"});