Make WordPress Core

Changeset 26743


Ignore:
Timestamp:
12/06/2013 08:49:46 PM (11 years ago)
Author:
azaozz
Message:

Responsive menu: fix calculation of the responsive trigger width from JS. It is affected by a vertical scrollbar width in some browsers. See #26458.

File:
1 edited

Legend:

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

    r26627 r26743  
    185185        $('#adminmenu div.wp-submenu').css('margin-top', '');
    186186
    187         // WebKit excludes the width of the vertical scrollbar when applying the CSS "@media screen and (max-width: ...)"
    188         // and matches $(window).width().
    189         // Firefox and IE > 8 include the scrollbar width, so after the jQuery normalization
    190         // $(window).width() is 884px but window.innerWidth is 900px.
    191         // (using window.innerWidth also excludes IE < 9)
    192         respWidth = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $(window).width() : window.innerWidth;
     187        if ( window.innerWidth ) {
     188            // window.innerWidth is affected by zooming on phones
     189            respWidth = Math.max( window.innerWidth, document.documentElement.clientWidth );
     190        } else {
     191            // Exclude IE < 9, it doesn't support @media CSS rules
     192            return;
     193        }
    193194
    194195        if ( respWidth && respWidth < 900 ) {
     
    604605
    605606        trigger: function() {
    606             var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth;
     607            var width;
     608
     609            if ( window.innerWidth ) {
     610                // window.innerWidth is affected by zooming on phones
     611                width = Math.max( window.innerWidth, document.documentElement.clientWidth );
     612            } else {
     613                // Exclude IE < 9, it doesn't support @media CSS rules
     614                return;
     615            }
    607616
    608617            if ( width <= 782 ) {
Note: See TracChangeset for help on using the changeset viewer.