Ticket #29356: 29356.patch
File 29356.patch, 4.8 KB (added by , 10 years ago) |
---|
-
src/wp-admin/js/common.js
175 175 lastClicked = false, 176 176 menu = $('#adminmenu'), 177 177 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; 179 181 180 182 // when the menu is folded, make the fly-out submenu header clickable 181 183 menu.on('click.wp-submenu-head', '.wp-submenu-head', function(e){ … … 224 226 225 227 if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device 226 228 // iOS Safari works with touchstart, the rest work with click 227 mobileEvent = /Mobile\/.+Safari/.test(navigator.userAgent)? 'touchstart' : 'click';229 mobileEvent = isIOS ? 'touchstart' : 'click'; 228 230 229 231 // close any open submenus when touch/click is not on the menu 230 232 $(document.body).on( mobileEvent+'.wp-mobile-hover', function(e) { … … 282 284 }); 283 285 } 284 286 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 ); 288 291 289 if ( isNaN(top) || top > -5 ) { // meaning the submenu is visible290 return;291 }292 if ( isNaN(top) || top > -5 ) { // meaning the submenu is visible 293 return; 294 } 292 295 293 if ( menu.data('wp-responsive') ) {294 // The menu is in responsive mode, bail295 return;296 }296 if ( menu.data('wp-responsive') ) { 297 // The menu is in responsive mode, bail 298 return; 299 } 297 300 298 menutop = $(this).offset().top;299 wintop = $(window).scrollTop();300 maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar301 menutop = $(this).offset().top; 302 wintop = $(window).scrollTop(); 303 maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar 301 304 302 b = menutop + m.height() + 1; // Bottom offset of the menu303 h = $('#wpwrap').height(); // Height of the entire page304 o = 60 + b - h;305 f = $(window).height() + wintop - 15; // The fold305 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 306 309 307 if ( f < (b - o) ) {308 o = b - f;309 }310 if ( f < (b - o) ) { 311 o = b - f; 312 } 310 313 311 if ( o > maxtop ) {312 o = maxtop;313 }314 if ( o > maxtop ) { 315 o = maxtop; 316 } 314 317 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; 319 344 } 320 345 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){ 325 348 if ( menu.data('wp-responsive') ) { 326 349 // The menu is in responsive mode, bail 327 350 return; 328 351 } 329 352 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 } 336 356 337 menu.on('focus.adminmenu', '.wp-submenu a', function(e){338 if ( menu.data('wp-responsive') ) {339 // The menu is in responsive mode, bail340 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, bail347 return;348 }349 350 $(e.target).closest('li.menu-top').removeClass('opensub');351 });352 353 357 // Move .updated and .error alert boxes. Don't move boxes designed to be inline. 354 358 $('div.wrap h2:first').nextAll('div.updated, div.error').addClass('below-h2'); 355 359 $('div.updated, div.error').not('.below-h2, .inline').insertAfter( $('div.wrap h2:first') );