Fix tapping on the menu in iOS and Android, fixes #29365 for trunk
Built from https://develop.svn.wordpress.org/trunk@29770 git-svn-id: http://core.svn.wordpress.org/trunk@29542 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3a724fcf81
commit
0a4d4a3d93
|
@ -175,7 +175,9 @@ $(document).ready( function() {
|
|||
lastClicked = false,
|
||||
menu = $('#adminmenu'),
|
||||
pageInput = $('input.current-page'),
|
||||
currentPage = pageInput.val();
|
||||
currentPage = pageInput.val(),
|
||||
isIOS = /iPhone|iPad|iPod/.test( navigator.userAgent ),
|
||||
isAndroid = navigator.userAgent.indexOf( 'Android' ) !== -1;
|
||||
|
||||
// when the menu is folded, make the fly-out submenu header clickable
|
||||
menu.on('click.wp-submenu-head', '.wp-submenu-head', function(e){
|
||||
|
@ -224,7 +226,7 @@ $(document).ready( function() {
|
|||
|
||||
if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device
|
||||
// iOS Safari works with touchstart, the rest work with click
|
||||
mobileEvent = /Mobile\/.+Safari/.test(navigator.userAgent) ? 'touchstart' : 'click';
|
||||
mobileEvent = isIOS ? 'touchstart' : 'click';
|
||||
|
||||
// close any open submenus when touch/click is not on the menu
|
||||
$(document.body).on( mobileEvent+'.wp-mobile-hover', function(e) {
|
||||
|
@ -282,73 +284,75 @@ $(document).ready( function() {
|
|||
});
|
||||
}
|
||||
|
||||
menu.find('li.wp-has-submenu').hoverIntent({
|
||||
over: function() {
|
||||
var b, h, o, f, m = $(this).find('.wp-submenu'), menutop, wintop, maxtop, top = parseInt( m.css('top'), 10 );
|
||||
if ( ! isIOS && ! isAndroid ) {
|
||||
menu.find('li.wp-has-submenu').hoverIntent({
|
||||
over: function() {
|
||||
var b, h, o, f, m = $(this).find('.wp-submenu'), menutop, wintop, maxtop, top = parseInt( m.css('top'), 10 );
|
||||
|
||||
if ( isNaN(top) || top > -5 ) { // meaning the submenu is visible
|
||||
return;
|
||||
}
|
||||
if ( isNaN(top) || top > -5 ) { // meaning the submenu is visible
|
||||
return;
|
||||
}
|
||||
|
||||
if ( menu.data('wp-responsive') ) {
|
||||
// The menu is in responsive mode, bail
|
||||
return;
|
||||
}
|
||||
|
||||
menutop = $(this).offset().top;
|
||||
wintop = $(window).scrollTop();
|
||||
maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar
|
||||
|
||||
b = menutop + m.height() + 1; // Bottom offset of the menu
|
||||
h = $('#wpwrap').height(); // Height of the entire page
|
||||
o = 60 + b - h;
|
||||
f = $(window).height() + wintop - 15; // The fold
|
||||
|
||||
if ( f < (b - o) ) {
|
||||
o = b - f;
|
||||
}
|
||||
|
||||
if ( o > maxtop ) {
|
||||
o = maxtop;
|
||||
}
|
||||
|
||||
if ( o > 1 ) {
|
||||
m.css('margin-top', '-'+o+'px');
|
||||
} else {
|
||||
m.css('margin-top', '');
|
||||
}
|
||||
|
||||
menu.find('li.menu-top').removeClass('opensub');
|
||||
$(this).addClass('opensub');
|
||||
},
|
||||
out: function(){
|
||||
if ( menu.data('wp-responsive') ) {
|
||||
// The menu is in responsive mode, bail
|
||||
return;
|
||||
}
|
||||
|
||||
$(this).removeClass('opensub').find('.wp-submenu').css('margin-top', '');
|
||||
},
|
||||
timeout: 200,
|
||||
sensitivity: 7,
|
||||
interval: 90
|
||||
});
|
||||
|
||||
menu.on('focus.adminmenu', '.wp-submenu a', function(e){
|
||||
if ( menu.data('wp-responsive') ) {
|
||||
// The menu is in responsive mode, bail
|
||||
return;
|
||||
}
|
||||
|
||||
menutop = $(this).offset().top;
|
||||
wintop = $(window).scrollTop();
|
||||
maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar
|
||||
|
||||
b = menutop + m.height() + 1; // Bottom offset of the menu
|
||||
h = $('#wpwrap').height(); // Height of the entire page
|
||||
o = 60 + b - h;
|
||||
f = $(window).height() + wintop - 15; // The fold
|
||||
|
||||
if ( f < (b - o) ) {
|
||||
o = b - f;
|
||||
}
|
||||
|
||||
if ( o > maxtop ) {
|
||||
o = maxtop;
|
||||
}
|
||||
|
||||
if ( o > 1 ) {
|
||||
m.css('margin-top', '-'+o+'px');
|
||||
} else {
|
||||
m.css('margin-top', '');
|
||||
}
|
||||
|
||||
menu.find('li.menu-top').removeClass('opensub');
|
||||
$(this).addClass('opensub');
|
||||
},
|
||||
out: function(){
|
||||
$(e.target).closest('li.menu-top').addClass('opensub');
|
||||
}).on('blur.adminmenu', '.wp-submenu a', function(e){
|
||||
if ( menu.data('wp-responsive') ) {
|
||||
// The menu is in responsive mode, bail
|
||||
return;
|
||||
}
|
||||
|
||||
$(this).removeClass('opensub').find('.wp-submenu').css('margin-top', '');
|
||||
},
|
||||
timeout: 200,
|
||||
sensitivity: 7,
|
||||
interval: 90
|
||||
});
|
||||
|
||||
menu.on('focus.adminmenu', '.wp-submenu a', function(e){
|
||||
if ( menu.data('wp-responsive') ) {
|
||||
// The menu is in responsive mode, bail
|
||||
return;
|
||||
}
|
||||
|
||||
$(e.target).closest('li.menu-top').addClass('opensub');
|
||||
}).on('blur.adminmenu', '.wp-submenu a', function(e){
|
||||
if ( menu.data('wp-responsive') ) {
|
||||
// The menu is in responsive mode, bail
|
||||
return;
|
||||
}
|
||||
|
||||
$(e.target).closest('li.menu-top').removeClass('opensub');
|
||||
});
|
||||
$(e.target).closest('li.menu-top').removeClass('opensub');
|
||||
});
|
||||
}
|
||||
|
||||
// Move .updated and .error alert boxes. Don't move boxes designed to be inline.
|
||||
$('div.wrap h2:first').nextAll('div.updated, div.error').addClass('below-h2');
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue