Make WordPress Core

Changeset 23518


Ignore:
Timestamp:
02/28/2013 06:05:28 PM (12 years ago)
Author:
nacin
Message:

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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/plugin-install.js

    r21592 r23518  
    2828    $(window).resize(function(){ tb_position(); });
    2929
    30      $('#dashboard_plugins a.thickbox, .plugins a.thickbox').click( function() {
     30    $('#dashboard_plugins, .plugins').on( 'click', 'a.thickbox', function() {
    3131        tb_click.call(this);
    3232
  • trunk/wp-includes/js/admin-bar.js

    r22728 r23518  
    11// use jQuery and hoverIntent if loaded
    22if ( typeof(jQuery) != 'undefined' ) {
    3     if ( typeof(jQuery.fn.hoverIntent) == 'undefined' )
    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 
     3    if ( typeof(jQuery.fn.hoverIntent) == 'undefined' ) {
     4        // hoverIntent r6 - Copy of wp-includes/js/hoverIntent.min.js
     5        (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);
     6    }
    67    jQuery(document).ready(function($){
    78        var adminbar = $('#wpadminbar'), refresh, touchOpen, touchClose, disableHoverIntent = false;
     
    125126            var id = $(this).attr('href');
    126127
    127             if ( $.browser.webkit && id && id.charAt(0) == '#' ) {
     128            var ua = navigator.userAgent.toLowerCase();
     129            if ( ua.indexOf('applewebkit') != -1 && id && id.charAt(0) == '#' ) {
    128130                setTimeout(function () {
    129131                    $(id).focus();
  • trunk/wp-includes/js/autosave.js

    r23110 r23518  
    8888         * https://bugs.webkit.org/show_bug.cgi?id=28633
    8989         */
    90         if ( $.browser.safari ) {
     90        var ua = navigator.userAgent.toLowerCase();
     91        if ( ua.indexOf('safari') != -1 && ua.indexOf('chrome') == -1 ) {
    9192            $('form#post').attr('action', function(index, value) {
    9293                return value + '?t=' + new Date().getTime();
  • trunk/wp-includes/js/thickbox/thickbox.js

    r22378 r23518  
    2121//add thickbox to href & area elements that have a class of .thickbox
    2222function tb_init(domChunk){
    23     jQuery(domChunk).live('click', tb_click);
     23    jQuery('body').on('click', domChunk, tb_click);
    2424}
    2525
     
    231231                }else if(url.indexOf('TB_iframe') != -1){
    232232                    tb_position();
    233                     if(jQuery.browser.safari){//safari needs help because it will not fire iframe onload
    234                         jQuery("#TB_load").remove();
    235                         jQuery("#TB_window").css({'visibility':'visible'});
    236                     }
     233                    jQuery("#TB_load").remove();
     234                    jQuery("#TB_window").css({'visibility':'visible'});
    237235                }else{
    238236                    jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
Note: See TracChangeset for help on using the changeset viewer.