Make WordPress Core

Ticket #29356: 29356.patch

File 29356.patch, 4.8 KB (added by azaozz, 10 years ago)
  • src/wp-admin/js/common.js

     
    175175                lastClicked = false,
    176176                menu = $('#adminmenu'),
    177177                pageInput = $('input.current-page'),
    178                 currentPage = pageInput.val();
     178                currentPage = pageInput.val(),
     179                isIOS = /iPhone|iPad|iPod/.test( navigator.userAgent ),
     180                isAndroid = navigator.userAgent.indexOf( 'Android' ) !== -1;
    179181
    180182        // when the menu is folded, make the fly-out submenu header clickable
    181183        menu.on('click.wp-submenu-head', '.wp-submenu-head', function(e){
     
    224226
    225227        if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device
    226228                // iOS Safari works with touchstart, the rest work with click
    227                 mobileEvent = /Mobile\/.+Safari/.test(navigator.userAgent) ? 'touchstart' : 'click';
     229                mobileEvent = isIOS ? 'touchstart' : 'click';
    228230
    229231                // close any open submenus when touch/click is not on the menu
    230232                $(document.body).on( mobileEvent+'.wp-mobile-hover', function(e) {
     
    282284                });
    283285        }
    284286
    285         menu.find('li.wp-has-submenu').hoverIntent({
    286                 over: function() {
    287                         var b, h, o, f, m = $(this).find('.wp-submenu'), menutop, wintop, maxtop, top = parseInt( m.css('top'), 10 );
     287        if ( ! isIOS && ! isAndroid ) {
     288                menu.find('li.wp-has-submenu').hoverIntent({
     289                        over: function() {
     290                                var b, h, o, f, m = $(this).find('.wp-submenu'), menutop, wintop, maxtop, top = parseInt( m.css('top'), 10 );
    288291
    289                         if ( isNaN(top) || top > -5 ) { // meaning the submenu is visible
    290                                 return;
    291                         }
     292                                if ( isNaN(top) || top > -5 ) { // meaning the submenu is visible
     293                                        return;
     294                                }
    292295
    293                         if ( menu.data('wp-responsive') ) {
    294                                 // The menu is in responsive mode, bail
    295                                 return;
    296                         }
     296                                if ( menu.data('wp-responsive') ) {
     297                                        // The menu is in responsive mode, bail
     298                                        return;
     299                                }
    297300
    298                         menutop = $(this).offset().top;
    299                         wintop = $(window).scrollTop();
    300                         maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar
     301                                menutop = $(this).offset().top;
     302                                wintop = $(window).scrollTop();
     303                                maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar
    301304
    302                         b = menutop + m.height() + 1; // Bottom offset of the menu
    303                         h = $('#wpwrap').height(); // Height of the entire page
    304                         o = 60 + b - h;
    305                         f = $(window).height() + wintop - 15; // The fold
     305                                b = menutop + m.height() + 1; // Bottom offset of the menu
     306                                h = $('#wpwrap').height(); // Height of the entire page
     307                                o = 60 + b - h;
     308                                f = $(window).height() + wintop - 15; // The fold
    306309
    307                         if ( f < (b - o) ) {
    308                                 o = b - f;
    309                         }
     310                                if ( f < (b - o) ) {
     311                                        o = b - f;
     312                                }
    310313
    311                         if ( o > maxtop ) {
    312                                 o = maxtop;
    313                         }
     314                                if ( o > maxtop ) {
     315                                        o = maxtop;
     316                                }
    314317
    315                         if ( o > 1 ) {
    316                                 m.css('margin-top', '-'+o+'px');
    317                         } else {
    318                                 m.css('margin-top', '');
     318                                if ( o > 1 ) {
     319                                        m.css('margin-top', '-'+o+'px');
     320                                } else {
     321                                        m.css('margin-top', '');
     322                                }
     323
     324                                menu.find('li.menu-top').removeClass('opensub');
     325                                $(this).addClass('opensub');
     326                        },
     327                        out: function(){
     328                                if ( menu.data('wp-responsive') ) {
     329                                        // The menu is in responsive mode, bail
     330                                        return;
     331                                }
     332
     333                                $(this).removeClass('opensub').find('.wp-submenu').css('margin-top', '');
     334                        },
     335                        timeout: 200,
     336                        sensitivity: 7,
     337                        interval: 90
     338                });
     339
     340                menu.on('focus.adminmenu', '.wp-submenu a', function(e){
     341                        if ( menu.data('wp-responsive') ) {
     342                                // The menu is in responsive mode, bail
     343                                return;
    319344                        }
    320345
    321                         menu.find('li.menu-top').removeClass('opensub');
    322                         $(this).addClass('opensub');
    323                 },
    324                 out: function(){
     346                        $(e.target).closest('li.menu-top').addClass('opensub');
     347                }).on('blur.adminmenu', '.wp-submenu a', function(e){
    325348                        if ( menu.data('wp-responsive') ) {
    326349                                // The menu is in responsive mode, bail
    327350                                return;
    328351                        }
    329352
    330                         $(this).removeClass('opensub').find('.wp-submenu').css('margin-top', '');
    331                 },
    332                 timeout: 200,
    333                 sensitivity: 7,
    334                 interval: 90
    335         });
     353                        $(e.target).closest('li.menu-top').removeClass('opensub');
     354                });
     355        }
    336356
    337         menu.on('focus.adminmenu', '.wp-submenu a', function(e){
    338                 if ( menu.data('wp-responsive') ) {
    339                         // The menu is in responsive mode, bail
    340                         return;
    341                 }
    342 
    343                 $(e.target).closest('li.menu-top').addClass('opensub');
    344         }).on('blur.adminmenu', '.wp-submenu a', function(e){
    345                 if ( menu.data('wp-responsive') ) {
    346                         // The menu is in responsive mode, bail
    347                         return;
    348                 }
    349 
    350                 $(e.target).closest('li.menu-top').removeClass('opensub');
    351         });
    352 
    353357        // Move .updated and .error alert boxes. Don't move boxes designed to be inline.
    354358        $('div.wrap h2:first').nextAll('div.updated, div.error').addClass('below-h2');
    355359        $('div.updated, div.error').not('.below-h2, .inline').insertAfter( $('div.wrap h2:first') );