Ticket #20614: 20614-8.patch
File 20614-8.patch, 7.1 KB (added by , 12 years ago) |
---|
-
wp-admin/js/common.js
211 211 el.addClass('opensub'); 212 212 } 213 213 }); 214 } else { 215 menu.find('li.wp-has-submenu').hoverIntent({ 216 over: function(e){ 217 var b, h, o, f, m = $(this).find('.wp-submenu'), menutop, wintop, maxtop, top = parseInt( m.css('top'), 10 ); 214 } 218 215 219 if ( isNaN(top) || top > -5 ) // meaning the submenu is visible 220 return; 216 menu.find('li.wp-has-submenu').hoverIntent({ 217 over: function(e){ 218 var b, h, o, f, m = $(this).find('.wp-submenu'), menutop, wintop, maxtop, top = parseInt( m.css('top'), 10 ); 221 219 222 menutop = $(this).offset().top; 223 wintop = $(window).scrollTop(); 224 maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar 220 if ( isNaN(top) || top > -5 ) // meaning the submenu is visible 221 return; 225 222 226 b = menutop + m.height() + 1; // Bottom offset of the menu 227 h = $('#wpwrap').height(); // Height of the entire page 228 o = 60 + b - h; 229 f = $(window).height() + wintop - 15; // The fold 223 menutop = $(this).offset().top; 224 wintop = $(window).scrollTop(); 225 maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar 230 226 231 if ( f < (b - o) ) 232 o = b - f; 227 b = menutop + m.height() + 1; // Bottom offset of the menu 228 h = $('#wpwrap').height(); // Height of the entire page 229 o = 60 + b - h; 230 f = $(window).height() + wintop - 15; // The fold 233 231 234 if ( o > maxtop)235 o = maxtop;232 if ( f < (b - o) ) 233 o = b - f; 236 234 237 if ( o > 1 ) 238 m.css('margin-top', '-'+o+'px'); 239 else 240 m.css('margin-top', ''); 235 if ( o > maxtop ) 236 o = maxtop; 241 237 242 menu.find('li.menu-top').removeClass('opensub'); 243 $(this).addClass('opensub'); 244 }, 245 out: function(){ 246 $(this).removeClass('opensub').find('.wp-submenu').css('margin-top', ''); 247 }, 248 timeout: 200, 249 sensitivity: 7, 250 interval: 90 251 }); 238 if ( o > 1 ) 239 m.css('margin-top', '-'+o+'px'); 240 else 241 m.css('margin-top', ''); 252 242 253 menu.on('focus.adminmenu', '.wp-submenu a', function(e){ 254 $(e.target).closest('li.menu-top').addClass('opensub'); 255 }).on('blur.adminmenu', '.wp-submenu a', function(e){ 256 $(e.target).closest('li.menu-top').removeClass('opensub'); 257 }); 258 } 243 menu.find('li.menu-top').removeClass('opensub'); 244 $(this).addClass('opensub'); 245 }, 246 out: function(){ 247 $(this).removeClass('opensub').find('.wp-submenu').css('margin-top', ''); 248 }, 249 timeout: 200, 250 sensitivity: 7, 251 interval: 90 252 }); 259 253 254 menu.on('focus.adminmenu', '.wp-submenu a', function(e){ 255 $(e.target).closest('li.menu-top').addClass('opensub'); 256 }).on('blur.adminmenu', '.wp-submenu a', function(e){ 257 $(e.target).closest('li.menu-top').removeClass('opensub'); 258 }); 259 260 260 // Move .updated and .error alert boxes. Don't move boxes designed to be inline. 261 261 $('div.wrap h2:first').nextAll('div.updated, div.error').addClass('below-h2'); 262 262 $('div.updated, div.error').not('.below-h2, .inline').insertAfter( $('div.wrap h2:first') ); -
wp-includes/js/admin-bar.js
4 4 (function(a){a.fn.hoverIntent=function(l,j){var m={sensitivity:7,interval:100,timeout:0};m=a.extend(m,j?{over:l,out:j}:l);var o,n,h,d;var e=function(f){o=f.pageX;n=f.pageY};var c=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);if((Math.abs(h-o)+Math.abs(d-n))<m.sensitivity){a(f).unbind("mousemove",e);f.hoverIntent_s=1;return m.over.apply(f,[g])}else{h=o;d=n;f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}};var i=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);f.hoverIntent_s=0;return m.out.apply(f,[g])};var b=function(q){var f=this;var g=(q.type=="mouseover"?q.fromElement:q.toElement)||q.relatedTarget;while(g&&g!=this){try{g=g.parentNode}catch(q){g=this}}if(g==this){if(a.browser.mozilla){if(q.type=="mouseout"){f.mtout=setTimeout(function(){k(q,f)},30)}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}}}return}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}k(q,f)}};var k=function(p,f){var g=jQuery.extend({},p);if(f.hoverIntent_t){f.hoverIntent_t=clearTimeout(f.hoverIntent_t)}if(p.type=="mouseover"){h=g.pageX;d=g.pageY;a(f).bind("mousemove",e);if(f.hoverIntent_s!=1){f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}}else{a(f).unbind("mousemove",e);if(f.hoverIntent_s==1){f.hoverIntent_t=setTimeout(function(){i(g,f)},m.timeout)}}};return this.mouseover(b).mouseout(b)}})(jQuery); 5 5 6 6 jQuery(document).ready(function($){ 7 var adminbar = $('#wpadminbar'), refresh ;7 var adminbar = $('#wpadminbar'), refresh, touchOpen, touchClose, disableHoverIntent = false; 8 8 9 9 refresh = function(i, el){ // force the browser to refresh the tabbing index 10 10 var node = $(el), tab = node.attr('tabindex'); … … 12 12 node.attr('tabindex', '0').attr('tabindex', tab); 13 13 }; 14 14 15 adminbar.removeClass('nojq').removeClass('nojs'); 16 17 if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device 18 // close any open drop-downs when the click/touch is not on the toolbar 19 $(document.body).on('click.wp-mobile-hover', function(e) { 20 if ( !$(e.target).closest('#wpadminbar').length ) 21 adminbar.find('li.menupop.hover').removeClass('hover'); 22 }); 23 15 touchOpen = function(unbind) { 24 16 adminbar.find('li.menupop').on('click.wp-mobile-hover', function(e) { 25 17 var el = $(this); 26 18 … … 29 21 adminbar.find('li.menupop.hover').removeClass('hover'); 30 22 el.addClass('hover'); 31 23 } 24 25 if ( unbind ) { 26 $('li.menupop').off('click.wp-mobile-hover'); 27 disableHoverIntent = false; 28 } 32 29 }); 33 } else { 34 adminbar.find('li.menupop').hoverIntent({ 35 over: function(e){ 36 $(this).addClass('hover'); 37 }, 38 out: function(e){ 39 $(this).removeClass('hover'); 40 }, 41 timeout: 180, 42 sensitivity: 7, 43 interval: 100 30 }; 31 32 touchClose = function() { 33 // close any open drop-downs when the click/touch is not on the toolbar 34 $(document.body).on('click.wp-mobile-hover', function(e) { 35 if ( !$(e.target).closest('#wpadminbar').length ) 36 adminbar.find('li.menupop.hover').removeClass('hover'); 44 37 }); 38 }; 39 40 adminbar.removeClass('nojq').removeClass('nojs'); 41 42 if ( 'ontouchstart' in window ) { 43 adminbar.on('touchstart', function(){ 44 touchOpen(true); 45 disableHoverIntent = true; 46 }); 47 touchClose(); 48 } else if ( /IEMobile\/[1-9]/.test(navigator.userAgent) ) { 49 touchOpen(); 50 touchClose(); 45 51 } 46 52 53 adminbar.find('li.menupop').hoverIntent({ 54 over: function(e){ 55 if ( disableHoverIntent ) 56 return; 57 58 $(this).addClass('hover'); 59 }, 60 out: function(e){ 61 if ( disableHoverIntent ) 62 return; 63 64 $(this).removeClass('hover'); 65 }, 66 timeout: 180, 67 sensitivity: 7, 68 interval: 100 69 }); 70 47 71 $('#wp-admin-bar-get-shortlink').click(function(e){ 48 72 e.preventDefault(); 49 73 $(this).addClass('selected').children('.shortlink-input').blur(function(){