Ticket #18758: patch.diff
File patch.diff, 6.1 KB (added by , 13 years ago) |
---|
-
wp-includes/js/admin-bar.dev.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 $('#wpadminbar').removeClass('nojq').find('li.menupop').hoverIntent({ 7 var adminbar = $('#wpadminbar'); 8 adminbar.removeClass('nojq').find('li.menupop').hoverIntent({ 8 9 over: function(e){ 9 10 $(this).addClass('hover'); 10 11 }, … … 15 16 sensitivity: 7, 16 17 interval: 120 17 18 }); 18 19 adminbar.click(function(e){ 20 scroll(0,0); 21 }); 22 $('#wpadminbar li').click(function(e){ 23 e.stopPropagation(); 24 }); 19 25 $('#wp-admin-bar-get-shortlink').click(function(e){ 20 26 e.preventDefault(); 21 27 $(this).addClass('selected').children('.shortlink-input').blur(function(){ … … 31 37 else if (obj.attachEvent) 32 38 obj.attachEvent('on' + type, function() { return fn.call(obj, window.event);}); 33 39 }, 34 40 35 41 aB, hc = new RegExp('\\bhover\\b', 'g'), q = [], 36 42 rselected = new RegExp('\\bselected\\b', 'g'), 37 43 38 44 /** 39 45 * Get the timeout ID of the given element 40 46 */ … … 45 51 return q[i][0]; 46 52 return false; 47 53 }, 48 54 49 55 addHoverClass = function(t) { 50 56 var i, id, inA, hovering, ul, li, 51 57 ancestors = [], 52 58 ancestorLength = 0; 53 59 54 60 while ( t && t != aB && t != d ) { 55 61 if( 'LI' == t.nodeName.toUpperCase() ) { 56 62 ancestors[ ancestors.length ] = t; … … 62 68 } 63 69 t = t.parentNode; 64 70 } 65 71 66 72 // Remove any selected classes. 67 73 if ( hovering && hovering.parentNode ) { 68 74 ul = hovering.parentNode; … … 75 81 } 76 82 } 77 83 } 78 84 79 85 /* remove the hover class for any objects not in the immediate element's ancestry */ 80 86 i = q.length; 81 87 while ( i-- ) { … … 85 91 if ( ancestors[ ancestorLength ] == q[i][1] ) 86 92 inA = true; 87 93 } 88 94 89 95 if ( ! inA ) 90 96 q[i][1].className = q[i][1].className ? q[i][1].className.replace(hc, '') : ''; 91 97 } 92 98 }, 93 99 94 100 removeHoverClass = function(t) { 95 101 while ( t && t != aB && t != d ) { 96 102 if( 'LI' == t.nodeName.toUpperCase() ) { … … 104 110 t = t.parentNode; 105 111 } 106 112 }, 107 113 108 114 clickShortlink = function(e) { 109 var i, l, node, 115 116 if(e.srcElement.id == 'wpadminbar'){ 117 scroll(0,0); 118 } else { 119 var i, l, node, 110 120 t = e.target || e.srcElement; 111 112 // Make t the shortlink menu item, or return. 113 while ( true ) { 114 // Check if we've gone past the shortlink node, 115 // or if the user is clicking on the input. 116 if ( ! t || t == d || t == aB ) 117 return; 118 // Check if we've found the shortlink node. 119 if ( t.id && t.id == 'wp-admin-bar-get-shortlink' ) 120 break; 121 t = t.parentNode; 122 } 123 124 // IE doesn't support preventDefault, and does support returnValue 125 if ( e.preventDefault ) 126 e.preventDefault(); 127 e.returnValue = false; 128 129 if ( -1 == t.className.indexOf('selected') ) 130 t.className += ' selected'; 131 132 for ( i = 0, l = t.childNodes.length; i < l; i++ ) { 133 node = t.childNodes[i]; 134 if ( node.className && -1 != node.className.indexOf('shortlink-input') ) { 135 node.focus(); 136 node.select(); 137 node.onblur = function() { 138 t.className = t.className ? t.className.replace( rselected, '' ) : ''; 139 }; 140 break; 121 122 // Make t the shortlink menu item, or return. 123 while ( true ) { 124 // Check if we've gone past the shortlink node, 125 // or if the user is clicking on the input. 126 if ( ! t || t == d || t == aB ) 127 return; 128 // Check if we've found the shortlink node. 129 if ( t.id && t.id == 'wp-admin-bar-get-shortlink' ) 130 break; 131 t = t.parentNode; 141 132 } 133 134 // IE doesn't support preventDefault, and does support returnValue 135 if ( e.preventDefault ) 136 e.preventDefault(); 137 e.returnValue = false; 138 139 if ( -1 == t.className.indexOf('selected') ) 140 t.className += ' selected'; 141 142 for ( i = 0, l = t.childNodes.length; i < l; i++ ) { 143 node = t.childNodes[i]; 144 if ( node.className && -1 != node.className.indexOf('shortlink-input') ) { 145 node.focus(); 146 node.select(); 147 node.onblur = function() { 148 t.className = t.className ? t.className.replace( rselected, '' ) : ''; 149 }; 150 break; 151 } 152 } 142 153 } 143 154 return false; 144 155 }; 145 156 146 157 addEvent(w, 'load', function() { 147 158 aB = d.getElementById('wpadminbar'); 148 159 149 160 if ( d.body && aB ) { 150 161 d.body.appendChild( aB ); 151 162 152 163 addEvent(aB, 'mouseover', function(e) { 153 164 addHoverClass( e.target || e.srcElement ); 154 165 }); 155 166 156 167 addEvent(aB, 'mouseout', function(e) { 157 168 removeHoverClass( e.target || e.srcElement ); 158 169 }); 159 170 160 171 addEvent(aB, 'click', clickShortlink ); 161 172 } 162 173 163 174 if ( w.location.hash ) 164 175 w.scrollBy(0,-32); 165 176 }); 166 177 })(document, window); 167 178 168 179 } 169