Make WordPress Core

Changeset 18488


Ignore:
Timestamp:
07/29/2011 10:57:30 PM (13 years ago)
Author:
azaozz
Message:

Admin bar: use jQuery if loaded to improve UX, fixes #18299

Location:
trunk/wp-includes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-admin-bar.php

    r18284 r18488  
    9090    function render() {
    9191        ?>
    92         <div id="wpadminbar">
     92        <div id="wpadminbar" class="nojq">
    9393            <div class="quicklinks">
    9494                <ul>
  • trunk/wp-includes/css/admin-bar.css

    r18097 r18488  
    1 #wpadminbar *{height:auto;width:auto;margin:0;padding:0;position:static;text-transform:none;letter-spacing:normal;line-height:1;font:normal 13px/28px Arial,Helvetica,sans-serif;color:#ddd;text-shadow:#555 0 -1px 0;}#wpadminbar :before,#wpadminbar :after{content:normal;}#wpadminbar a,#wpadminbar a:hover,#wpadminbar a img,#wpadminbar a img:hover{outline:none;border:none;text-decoration:none;background:none;}#wpadminbar{direction:ltr;background-color:#777;background-image:-moz-linear-gradient(bottom,#666,#7f7f7f);background-image:-webkit-gradient(linear,left bottom,left top,from(#666),to(#7f7f7f));color:#ddd;font:normal 12px/28px Arial,Helvetica,sans-serif;height:28px;position:fixed;top:0;left:0;width:100%;z-index:99999;min-width:960px;}#wpadminbar ul,#wpadminbar ul li{background:none;list-style:none;margin:0;padding:0;position:relative;z-index:99999;}#wpadminbar .quicklinks ul{text-align:left;}#wpadminbar .quicklinks ul li{float:left;}#wpadminbar .quicklinks>ul>li>a{border-right:1px solid #686868;border-left:1px solid #808080;}#wpadminbar .quicklinks>ul>li:last-child>a{border-right:none;}#wpadminbar .quicklinks>ul>li:hover>a{border-left-color:#707070;}#wpadminbar .quicklinks a,#wpadminbar .shortlink-input{height:28px;display:block;padding:0 .85em;margin:0;}#wpadminbar .quicklinks a>span{line-height:28px;}#wpadminbar .quicklinks .menupop ul,#wpadminbar .shortlink-input{-moz-box-shadow:0 4px 8px rgba(0,0,0,0.1);-webkit-box-shadow:0 4px 8px rgba(0,0,0,0.1);box-shadow:0 4px 8px rgba(0,0,0,0.1);background:#fff;background:rgba(255,255,255,0.97);display:none;position:absolute;border:1px solid #dfdfdf;border-top:none;float:none;}#wpadminbar .selected .shortlink-input{display:block;}#wpadminbar .quicklinks .menupop ul li{float:none;}#wpadminbar .quicklinks .menupop ul li a strong{font-weight:bold;}#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop ul li a span,#wpadminbar .quicklinks .menupop ul li a strong,#wpadminbar .shortlink-input{color:#555;text-shadow:none;white-space:nowrap;min-width:140px;}#wpadminbar .shortlink-input{width:200px;}#wpadminbar .quicklinks .menupop ul li:hover>a,#wpadminbar .quicklinks .menupop ul li:hover>a span,#wpadminbar .quicklinks .menupop ul li:hover>a strong{color:#fff;text-shadow:#666 0 -1px 0;}#wpadminbar .quicklinks li:hover>ul,#wpadminbar .quicklinks li.hover>ul{display:block;}#wpadminbar .quicklinks .menupop li:hover>ul,#wpadminbar .quicklinks .menupop li.hover>ul{margin-left:100%;margin-top:-28px;}#wpadminbar .quicklinks li:hover,#wpadminbar .quicklinks .selected{background:#555;background:-moz-linear-gradient(bottom,#555,#3e3e3e);background:-webkit-gradient(linear,left bottom,left top,from(#555),to(#3e3e3e));}#wpadminbar .quicklinks .menupop li:hover{background:#888;background:-moz-linear-gradient(bottom,#888,#9d9d9d);background:-webkit-gradient(linear,left bottom,left top,from(#888),to(#9d9d9d));}#wpadminbar .quicklinks .menupop a>span{display:inline;background:url(../images/admin-bar-sprite.png?d=11122010) right -58px no-repeat;padding-right:.8em;}#wpadminbar .quicklinks .menupop ul li a>span{display:block;background:url(../images/admin-bar-sprite.png?d=11122010) right -29px no-repeat;padding-right:1.5em;}#wpadminbar .quicklinks a span#ab-awaiting-mod,#wpadminbar .quicklinks a span#ab-updates{background:#eee;color:#333;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:bold;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;}#wpadminbar .quicklinks a:hover span#ab-awaiting-mod,#wpadminbar .quicklinks a:hover span#ab-updates{background:#fff;color:#000;}#wpadminbar .quicklinks li#wp-admin-bar-my-account>a{border-left:none;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a{border-left:none;background:url(../images/admin-bar-sprite.png?d=11122010) top left no-repeat;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a img{width:16px;height:16px;display:inline;border:1px solid #999;vertical-align:middle;margin:-2px 23px 0 -5px;padding:0;background:#eee;float:none;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul{left:30px;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul ul{left:0;}#wpadminbar .quicklinks .menupop li a img.blavatar{vertical-align:middle;margin:0 8px 0 0;padding:0;}#wpadminbar #adminbarsearch{float:right;height:18px;padding:3px;margin:0;}#wpadminbar #adminbarsearch .adminbar-input{width:140px;height:auto;float:left;font:12px Arial,Helvetica,sans-serif;color:#555;text-shadow:0 1px 0 #fff;border:1px solid #626262;padding:2px 3px;margin:0 3px 0 0;background:#ddd;-moz-box-shadow:inset 2px 2px 1px #cdcdcd;-webkit-box-shadow:inset 2px 2px 1px #cdcdcd;box-shadow:inset 2px 2px 1px #cdcdcd;-webkit-border-radius:0;-khtml-border-radius:0;-moz-border-radius:0;border-radius:0;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;outline:none;}#wpadminbar #adminbarsearch .adminbar-button{font:bold 12px Arial,Helvetica,sans-serif;color:#444;text-shadow:0 1px 0 #eee;cursor:pointer;float:left;background:#aaa;background:-moz-linear-gradient(bottom,#aaa,#cecece);background:-webkit-gradient(linear,left bottom,left top,from(#aaa),to(#cecece));-webkit-border-radius:10px;-khtml-border-radius:10px;-moz-border-radius:10px;border-radius:10px;border:1px solid #626262;padding:2px 13px;margin:0;width:auto;height:auto;}#wpadminbar #adminbarsearch .adminbar-button:active{background:#a0a0a0;background:-moz-linear-gradient(bottom,#a0a0a0,#c1c1c1);background:-webkit-gradient(linear,left bottom,left top,from(#a0a0a0),to(#c1c1c1));-moz-box-shadow:inset 1px 1px 1px #9b9b9b;-webkit-box-shadow:inset 1px 1px 1px #9b9b9b;box-shadow:inset 1px 1px 1px #9b9b9b;}#wpadminbar #adminbarsearch .adminbar-button:hover{color:#000;}#wpadminbar #adminbarsearch .adminbar-button::-moz-focus-inner{border:none;}* html #wpadminbar{overflow:hidden;position:absolute;}* html #wpadminbar .quicklinks ul li a{float:left;}* html #wpadminbar .menupop a span{background-image:none;}
     1#wpadminbar *{height:auto;width:auto;margin:0;padding:0;position:static;text-transform:none;letter-spacing:normal;line-height:1;font:normal 13px/28px Arial,Helvetica,sans-serif;color:#ddd;text-shadow:#555 0 -1px 0;}#wpadminbar :before,#wpadminbar :after{content:normal;}#wpadminbar a,#wpadminbar a:hover,#wpadminbar a img,#wpadminbar a img:hover{outline:none;border:none;text-decoration:none;background:none;}#wpadminbar{direction:ltr;background-color:#777;background-image:-moz-linear-gradient(bottom,#666,#7f7f7f);background-image:-webkit-gradient(linear,left bottom,left top,from(#666),to(#7f7f7f));color:#ddd;font:normal 12px/28px Arial,Helvetica,sans-serif;height:28px;position:fixed;top:0;left:0;width:100%;z-index:99999;min-width:960px;}#wpadminbar ul,#wpadminbar ul li{background:none;list-style:none;margin:0;padding:0;position:relative;z-index:99999;}#wpadminbar .quicklinks ul{text-align:left;}#wpadminbar .quicklinks ul li{float:left;}#wpadminbar .quicklinks>ul>li>a{border-right:1px solid #686868;border-left:1px solid #808080;}#wpadminbar .quicklinks>ul>li:last-child>a{border-right:none;}#wpadminbar .quicklinks>ul>li:hover>a{border-left-color:#707070;}#wpadminbar .quicklinks a,#wpadminbar .shortlink-input{height:28px;display:block;padding:0 .85em;margin:0;}#wpadminbar .quicklinks a>span{line-height:28px;}#wpadminbar .quicklinks .menupop ul,#wpadminbar .shortlink-input{-moz-box-shadow:0 4px 8px rgba(0,0,0,0.1);-webkit-box-shadow:0 4px 8px rgba(0,0,0,0.1);box-shadow:0 4px 8px rgba(0,0,0,0.1);background:#fff;background:rgba(255,255,255,0.97);display:none;position:absolute;border:1px solid #dfdfdf;border-top:none;float:none;}#wpadminbar .selected .shortlink-input{display:block;}#wpadminbar .quicklinks .menupop ul li{float:none;}#wpadminbar .quicklinks .menupop ul li a strong{font-weight:bold;}#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop ul li a span,#wpadminbar .quicklinks .menupop ul li a strong,#wpadminbar .shortlink-input{color:#555;text-shadow:none;white-space:nowrap;min-width:140px;}#wpadminbar .shortlink-input{width:200px;}#wpadminbar .quicklinks .menupop ul li:hover>a,#wpadminbar .quicklinks .menupop ul li:hover>a span,#wpadminbar .quicklinks .menupop ul li:hover>a strong{color:#fff;text-shadow:#666 0 -1px 0;}#wpadminbar.nojq .quicklinks li:hover>ul,#wpadminbar .quicklinks li.hover>ul{display:block;}#wpadminbar .quicklinks .menupop li:hover>ul,#wpadminbar .quicklinks .menupop li.hover>ul{margin-left:100%;margin-top:-28px;}#wpadminbar .quicklinks li:hover,#wpadminbar .quicklinks .selected{background:#555;background:-moz-linear-gradient(bottom,#555,#3e3e3e);background:-webkit-gradient(linear,left bottom,left top,from(#555),to(#3e3e3e));}#wpadminbar .quicklinks .menupop li:hover{background:#888;background:-moz-linear-gradient(bottom,#888,#9d9d9d);background:-webkit-gradient(linear,left bottom,left top,from(#888),to(#9d9d9d));}#wpadminbar .quicklinks .menupop a>span{display:inline;background:url(../images/admin-bar-sprite.png?d=11122010) right -58px no-repeat;padding-right:.8em;}#wpadminbar .quicklinks .menupop ul li a>span{display:block;background:url(../images/admin-bar-sprite.png?d=11122010) right -29px no-repeat;padding-right:1.5em;}#wpadminbar .quicklinks a span#ab-awaiting-mod,#wpadminbar .quicklinks a span#ab-updates{background:#eee;color:#333;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:bold;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;}#wpadminbar .quicklinks a:hover span#ab-awaiting-mod,#wpadminbar .quicklinks a:hover span#ab-updates{background:#fff;color:#000;}#wpadminbar .quicklinks li#wp-admin-bar-my-account>a{border-left:none;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a{border-left:none;background:url(../images/admin-bar-sprite.png?d=11122010) top left no-repeat;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a img{width:16px;height:16px;display:inline;border:1px solid #999;vertical-align:middle;margin:-2px 23px 0 -5px;padding:0;background:#eee;float:none;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul{left:30px;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul ul{left:0;}#wpadminbar .quicklinks .menupop li a img.blavatar{vertical-align:middle;margin:0 8px 0 0;padding:0;}#wpadminbar #adminbarsearch{float:right;height:18px;padding:3px;margin:0;}#wpadminbar #adminbarsearch .adminbar-input{width:140px;height:auto;float:left;font:12px Arial,Helvetica,sans-serif;color:#555;text-shadow:0 1px 0 #fff;border:1px solid #626262;padding:2px 3px;margin:0 3px 0 0;background:#ddd;-moz-box-shadow:inset 2px 2px 1px #cdcdcd;-webkit-box-shadow:inset 2px 2px 1px #cdcdcd;box-shadow:inset 2px 2px 1px #cdcdcd;-webkit-border-radius:0;-khtml-border-radius:0;-moz-border-radius:0;border-radius:0;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;outline:none;}#wpadminbar #adminbarsearch .adminbar-button{font:bold 12px Arial,Helvetica,sans-serif;color:#444;text-shadow:0 1px 0 #eee;cursor:pointer;float:left;background:#aaa;background:-moz-linear-gradient(bottom,#aaa,#cecece);background:-webkit-gradient(linear,left bottom,left top,from(#aaa),to(#cecece));-webkit-border-radius:10px;-khtml-border-radius:10px;-moz-border-radius:10px;border-radius:10px;border:1px solid #626262;padding:2px 13px;margin:0;width:auto;height:auto;}#wpadminbar #adminbarsearch .adminbar-button:active{background:#a0a0a0;background:-moz-linear-gradient(bottom,#a0a0a0,#c1c1c1);background:-webkit-gradient(linear,left bottom,left top,from(#a0a0a0),to(#c1c1c1));-moz-box-shadow:inset 1px 1px 1px #9b9b9b;-webkit-box-shadow:inset 1px 1px 1px #9b9b9b;box-shadow:inset 1px 1px 1px #9b9b9b;}#wpadminbar #adminbarsearch .adminbar-button:hover{color:#000;}#wpadminbar #adminbarsearch .adminbar-button::-moz-focus-inner{border:none;}* html #wpadminbar{overflow:hidden;position:absolute;}* html #wpadminbar .quicklinks ul li a{float:left;}* html #wpadminbar .menupop a span{background-image:none;}
  • trunk/wp-includes/css/admin-bar.dev.css

    r18097 r18488  
    134134}
    135135
    136 #wpadminbar .quicklinks li:hover > ul,
     136#wpadminbar.nojq .quicklinks li:hover > ul,
    137137#wpadminbar .quicklinks li.hover > ul {
    138138    display: block;
  • trunk/wp-includes/js/admin-bar.dev.js

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

    r17279 r18488  
    1 (function(i,k){var c=function(n,m,d){if(n.addEventListener){n.addEventListener(m,d,false)}else{if(n.attachEvent){n.attachEvent("on"+m,function(){return d.call(n,window.event)})}}},e,f=new RegExp("\\bhover\\b","g"),a=[],j=new RegExp("\\bselected\\b","g"),g=function(m){var d=a.length;while(d--){if(a[d]&&m==a[d][1]){return a[d][0]}}return false},h=function(s){var n,d,q,m,p,r,u=[],o=0;while(s&&s!=e&&s!=i){if("LI"==s.nodeName.toUpperCase()){u[u.length]=s;d=g(s);if(d){clearTimeout(d)}s.className=s.className?(s.className.replace(f,"")+" hover"):"hover";m=s}s=s.parentNode}if(m&&m.parentNode){p=m.parentNode;if(p&&"UL"==p.nodeName.toUpperCase()){n=p.childNodes.length;while(n--){r=p.childNodes[n];if(r!=m){r.className=r.className?r.className.replace(j,""):""}}}}n=a.length;while(n--){q=false;o=u.length;while(o--){if(u[o]==a[n][1]){q=true}}if(!q){a[n][1].className=a[n][1].className?a[n][1].className.replace(f,""):""}}},l=function(d){while(d&&d!=e&&d!=i){if("LI"==d.nodeName.toUpperCase()){(function(m){var n=setTimeout(function(){m.className=m.className?m.className.replace(f,""):""},500);a[a.length]=[n,m]})(d)}d=d.parentNode}},b=function(p){var n,d,o,m=p.target||p.srcElement;while(true){if(!m||m==i||m==e){return}if(m.id&&m.id=="wp-admin-bar-get-shortlink"){break}m=m.parentNode}if(p.preventDefault){p.preventDefault()}p.returnValue=false;if(-1==m.className.indexOf("selected")){m.className+=" selected"}for(n=0,d=m.childNodes.length;n<d;n++){o=m.childNodes[n];if(o.className&&-1!=o.className.indexOf("shortlink-input")){o.focus();o.select();o.onblur=function(){m.className=m.className?m.className.replace(j,""):""};break}}return false};c(k,"load",function(){e=i.getElementById("wpadminbar");if(i.body&&e){i.body.appendChild(e);c(e,"mouseover",function(d){h(d.target||d.srcElement)});c(e,"mouseout",function(d){l(d.target||d.srcElement)});c(e,"click",b)}if(k.location.hash){k.scrollBy(0,-32)}})})(document,window);
     1if(typeof(jQuery)!="undefined"){if(typeof(jQuery.fn.hoverIntent)=="undefined"){(function(b){b.fn.hoverIntent=function(p,r){var g={sensitivity:7,interval:100,timeout:0};g=b.extend(g,r?{over:p,out:r}:p);var a,f,t,v;var u=function(c){a=c.pageX;f=c.pageY};var w=function(c,d){d.hoverIntent_t=clearTimeout(d.hoverIntent_t);if((Math.abs(t-a)+Math.abs(v-f))<g.sensitivity){b(d).unbind("mousemove",u);d.hoverIntent_s=1;return g.over.apply(d,[c])}else{t=a;v=f;d.hoverIntent_t=setTimeout(function(){w(c,d)},g.interval)}};var s=function(c,d){d.hoverIntent_t=clearTimeout(d.hoverIntent_t);d.hoverIntent_s=0;return g.out.apply(d,[c])};var x=function(e){var d=this;var c=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(c&&c!=this){try{c=c.parentNode}catch(e){c=this}}if(c==this){if(b.browser.mozilla){if(e.type=="mouseout"){d.mtout=setTimeout(function(){q(e,d)},30)}else{if(d.mtout){d.mtout=clearTimeout(d.mtout)}}}return}else{if(d.mtout){d.mtout=clearTimeout(d.mtout)}q(e,d)}};var q=function(e,d){var c=jQuery.extend({},e);if(d.hoverIntent_t){d.hoverIntent_t=clearTimeout(d.hoverIntent_t)}if(e.type=="mouseover"){t=c.pageX;v=c.pageY;b(d).bind("mousemove",u);if(d.hoverIntent_s!=1){d.hoverIntent_t=setTimeout(function(){w(c,d)},g.interval)}}else{b(d).unbind("mousemove",u);if(d.hoverIntent_s==1){d.hoverIntent_t=setTimeout(function(){s(c,d)},g.timeout)}}};return this.mouseover(x).mouseout(x)}})(jQuery)}jQuery(document).ready(function(a){a("#wpadminbar").removeClass("nojq").find("li.menupop").hoverIntent({over:function(b){a(this).addClass("hover")},out:function(b){a(this).removeClass("hover")},timeout:200,sensitivity:7,interval:120})})}else{(function(i,k){var c=function(n,m,d){if(n.addEventListener){n.addEventListener(m,d,false)}else{if(n.attachEvent){n.attachEvent("on"+m,function(){return d.call(n,window.event)})}}},e,f=new RegExp("\\bhover\\b","g"),a=[],j=new RegExp("\\bselected\\b","g"),g=function(m){var d=a.length;while(d--){if(a[d]&&m==a[d][1]){return a[d][0]}}return false},h=function(s){var n,d,q,m,p,r,u=[],o=0;while(s&&s!=e&&s!=i){if("LI"==s.nodeName.toUpperCase()){u[u.length]=s;d=g(s);if(d){clearTimeout(d)}s.className=s.className?(s.className.replace(f,"")+" hover"):"hover";m=s}s=s.parentNode}if(m&&m.parentNode){p=m.parentNode;if(p&&"UL"==p.nodeName.toUpperCase()){n=p.childNodes.length;while(n--){r=p.childNodes[n];if(r!=m){r.className=r.className?r.className.replace(j,""):""}}}}n=a.length;while(n--){q=false;o=u.length;while(o--){if(u[o]==a[n][1]){q=true}}if(!q){a[n][1].className=a[n][1].className?a[n][1].className.replace(f,""):""}}},l=function(d){while(d&&d!=e&&d!=i){if("LI"==d.nodeName.toUpperCase()){(function(m){var n=setTimeout(function(){m.className=m.className?m.className.replace(f,""):""},500);a[a.length]=[n,m]})(d)}d=d.parentNode}},b=function(p){var n,d,o,m=p.target||p.srcElement;while(true){if(!m||m==i||m==e){return}if(m.id&&m.id=="wp-admin-bar-get-shortlink"){break}m=m.parentNode}if(p.preventDefault){p.preventDefault()}p.returnValue=false;if(-1==m.className.indexOf("selected")){m.className+=" selected"}for(n=0,d=m.childNodes.length;n<d;n++){o=m.childNodes[n];if(o.className&&-1!=o.className.indexOf("shortlink-input")){o.focus();o.select();o.onblur=function(){m.className=m.className?m.className.replace(j,""):""};break}}return false};c(k,"load",function(){e=i.getElementById("wpadminbar");if(i.body&&e){i.body.appendChild(e);c(e,"mouseover",function(d){h(d.target||d.srcElement)});c(e,"mouseout",function(d){l(d.target||d.srcElement)});c(e,"click",b)}if(k.location.hash){k.scrollBy(0,-32)}})})(document,window)};
Note: See TracChangeset for help on using the changeset viewer.