Stop using deprecated jQuery API (.browser and .live). Do manual UA sniffing where still necessary. Improve selector performance by using delegated events. props ocean90. see #22975.

git-svn-id: https://develop.svn.wordpress.org/trunk@23518 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-02-28 18:05:28 +00:00
parent 854f7138f9
commit 57f7ae7af4
4 changed files with 12 additions and 11 deletions

View File

@ -27,7 +27,7 @@ jQuery(document).ready(function($) {
$(window).resize(function(){ tb_position(); });
$('#dashboard_plugins a.thickbox, .plugins a.thickbox').click( function() {
$('#dashboard_plugins, .plugins').on( 'click', 'a.thickbox', function() {
tb_click.call(this);
$('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});

View File

@ -1,8 +1,9 @@
// use jQuery and hoverIntent if loaded
if ( typeof(jQuery) != 'undefined' ) {
if ( typeof(jQuery.fn.hoverIntent) == 'undefined' )
(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);
if ( typeof(jQuery.fn.hoverIntent) == 'undefined' ) {
// hoverIntent r6 - Copy of wp-includes/js/hoverIntent.min.js
(function(a){a.fn.hoverIntent=function(k,j){var l={sensitivity:7,interval:100,timeout:0};l=a.extend(l,j?{over:k,out:j}:k);var n,m,h,d;var e=function(f){n=f.pageX;m=f.pageY};var c=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);if((Math.abs(h-n)+Math.abs(d-m))<l.sensitivity){a(f).unbind("mousemove",e);f.hoverIntent_s=1;return l.over.apply(f,[g])}else{h=n;d=m;f.hoverIntent_t=setTimeout(function(){c(g,f)},l.interval)}};var i=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);f.hoverIntent_s=0;return l.out.apply(f,[g])};var b=function(o){var g=jQuery.extend({},o);var f=this;if(f.hoverIntent_t){f.hoverIntent_t=clearTimeout(f.hoverIntent_t)}if(o.type=="mouseenter"){h=g.pageX;d=g.pageY;a(f).bind("mousemove",e);if(f.hoverIntent_s!=1){f.hoverIntent_t=setTimeout(function(){c(g,f)},l.interval)}}else{a(f).unbind("mousemove",e);if(f.hoverIntent_s==1){f.hoverIntent_t=setTimeout(function(){i(g,f)},l.timeout)}}};return this.bind("mouseenter",b).bind("mouseleave",b)}})(jQuery);
}
jQuery(document).ready(function($){
var adminbar = $('#wpadminbar'), refresh, touchOpen, touchClose, disableHoverIntent = false;
@ -124,7 +125,8 @@ if ( typeof(jQuery) != 'undefined' ) {
var id = $(this).attr('href');
if ( $.browser.webkit && id && id.charAt(0) == '#' ) {
var ua = navigator.userAgent.toLowerCase();
if ( ua.indexOf('applewebkit') != -1 && id && id.charAt(0) == '#' ) {
setTimeout(function () {
$(id).focus();
}, 100);

View File

@ -87,7 +87,8 @@ jQuery(document).ready( function($) {
* Workaround for WebKit bug preventing a form submitting twice to the same action.
* https://bugs.webkit.org/show_bug.cgi?id=28633
*/
if ( $.browser.safari ) {
var ua = navigator.userAgent.toLowerCase();
if ( ua.indexOf('safari') != -1 && ua.indexOf('chrome') == -1 ) {
$('form#post').attr('action', function(index, value) {
return value + '?t=' + new Date().getTime();
});

View File

@ -20,7 +20,7 @@ jQuery(document).ready(function(){
//add thickbox to href & area elements that have a class of .thickbox
function tb_init(domChunk){
jQuery(domChunk).live('click', tb_click);
jQuery('body').on('click', domChunk, tb_click);
}
function tb_click(){
@ -230,10 +230,8 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
jQuery("#TB_window").css({'visibility':'visible'});
}else if(url.indexOf('TB_iframe') != -1){
tb_position();
if(jQuery.browser.safari){//safari needs help because it will not fire iframe onload
jQuery("#TB_load").remove();
jQuery("#TB_window").css({'visibility':'visible'});
}
}else{
jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
tb_position();