From f24c4ee1b3374fbe28ee387773d3cf9710382bb8 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 9 Jul 2013 21:26:32 +0000 Subject: [PATCH] Collapse Menu: use jQuery normalized window width only for WebKit. Use window.innerWidth in Firefox, IE > 8, etc. so the window width in JS and for the @media rules match. Fixes #23817. git-svn-id: https://develop.svn.wordpress.org/trunk@24619 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/js/common.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index cd9ede70ad..b1327f9973 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -169,16 +169,22 @@ $(document).ready( function() { }); $('#collapse-menu').on('click.collapse-menu', function(e){ - var body = $(document.body); + var body = $( document.body ), respWidth; // reset any compensation for submenus near the bottom of the screen $('#adminmenu div.wp-submenu').css('margin-top', ''); - if ( $(window).width() < 900 ) { + // WebKit excludes the width of the vertical scrollbar when applying the CSS "@media screen and (max-width: ...)" + // and matches $(window).width(). + // Firefox and IE > 8 include the scrollbar width, so after the jQuery normalization + // $(window).width() is 884px but window.innerWidth is 900px. + // (using window.innerWidth also excludes IE < 9) + respWidth = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $(window).width() : window.innerWidth; + + if ( respWidth && respWidth < 900 ) { if ( body.hasClass('auto-fold') ) { - body.removeClass('auto-fold'); + body.removeClass('auto-fold').removeClass('folded'); setUserSetting('unfold', 1); - body.removeClass('folded'); deleteUserSetting('mfold'); } else { body.addClass('auto-fold');