WordPress.org

Make WordPress Core

Changeset 24619


Ignore:
Timestamp:
07/09/2013 09:26:32 PM (8 years ago)
Author:
azaozz
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/common.js

    r23485 r24619  
    170170
    171171    $('#collapse-menu').on('click.collapse-menu', function(e){
    172         var body = $(document.body);
     172        var body = $( document.body ), respWidth;
    173173
    174174        // reset any compensation for submenus near the bottom of the screen
    175175        $('#adminmenu div.wp-submenu').css('margin-top', '');
    176176
    177         if ( $(window).width() < 900 ) {
     177        // WebKit excludes the width of the vertical scrollbar when applying the CSS "@media screen and (max-width: ...)"
     178        // and matches $(window).width().
     179        // Firefox and IE > 8 include the scrollbar width, so after the jQuery normalization
     180        // $(window).width() is 884px but window.innerWidth is 900px.
     181        // (using window.innerWidth also excludes IE < 9)
     182        respWidth = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $(window).width() : window.innerWidth;
     183
     184        if ( respWidth && respWidth < 900 ) {
    178185            if ( body.hasClass('auto-fold') ) {
    179                 body.removeClass('auto-fold');
     186                body.removeClass('auto-fold').removeClass('folded');
    180187                setUserSetting('unfold', 1);
    181                 body.removeClass('folded');
    182188                deleteUserSetting('mfold');
    183189            } else {
Note: See TracChangeset for help on using the changeset viewer.