Make WordPress Core

Ticket #14772: admin-bar-fixes.14772.diff

File admin-bar-fixes.14772.diff, 9.5 KB (added by filosofo, 15 years ago)
  • wp-includes/admin-bar.php

     
    170170function wp_admin_bar_bloginfo_menu() {
    171171        global $wp_admin_bar;
    172172
    173         /* Add the Site Info menu */
    174         $wp_admin_bar->add_menu( array( 'id' => 'bloginfo', 'title' => __( 'Site Info' ), 'href' => '', ) );
    175 
    176         // TODO: Move this js out into a seperate file?
    177         $wp_admin_bar->add_menu( array( 'parent' => 'bloginfo', 'title' => __( 'Get Shortlink' ), 'href' => '', 'meta' => array(
    178                         'onclick' => 'javascript:function wpcomshort() { var url=document.location;var links=document.getElementsByTagName('link');var found=0;for(var i = 0, l; l = links[i]; i++){if(l.getAttribute('rel')=='shortlink') {found=l.getAttribute('href');break;}}if (!found) {for (var i = 0; l = document.links[i]; i++) {if (l.getAttribute('rel') == 'shortlink') {found = l.getAttribute('href');break;}}}if (found) {prompt('' . esc_js( __( 'URL:' ) ) . '', found);} else {alert('' . esc_js( __( 'No shortlink available for this page.' ) ) . ''); } } wpcomshort(); return false;' ) ) );
     173        $wp_admin_bar->add_menu( array( 'id' => 'get-shortlink', 'title' => __( 'Get Shortlink' ), 'href' => '', ) );
    179174}
    180175
    181176/**
     
    208203function wp_admin_bar_header() {
    209204        ?>
    210205        <style type="text/css" media="print">#wpadminbar { display:none; }</style>
    211         <script type="text/javascript">
    212         /*      <![CDATA[ */
    213         (function(d, w) {
    214                 var init = function() {
    215                         var b = d.getElementsByTagName('body')[0],
    216                         aB = d.getElementById('wpadminbar'),
    217                         s = d.getElementById('adminbar-search');
    218 
    219                         if ( b && aB )
    220                                 b.appendChild( aB );
    221 
    222                         if ( s ) {
    223                                 if ( '' == s.value )
    224                                         s.value = s.getAttribute('title');
    225 
    226                                 s.onblur = function() {
    227                                         this.value = '' == this.value ? this.getAttribute('title') : this.value;
    228                                 }
    229                                 s.onfocus = function() {
    230                                         this.value = this.getAttribute('title') == this.value ? '' : this.value;
    231                                 }
    232                         }
    233                        
    234                         if ( w.location.hash )
    235                                 w.scrollBy(0,-32);
    236                 }
    237 
    238                 if ( w.addEventListener )
    239                         w.addEventListener('load', init, false);
    240                 else if ( w.attachEvent )
    241                         w.attachEvent('onload', init);
    242 
    243         })(document, window);
    244         /*      ]]> */
    245         </script>
    246206        <?php
    247207}
    248208
     
    272232        <?php
    273233}
    274234
    275 add_action('wp_head', 'wp_admin_body_style');
    276 add_action('admin_head', 'wp_admin_body_style');
    277 
    278235/**
    279236 * Determine whether the admin bar should be showing.
    280237 *
     
    291248                if ( defined('WP_SHOW_ADMIN_BAR') )
    292249                        $show_admin_bar = (bool) WP_SHOW_ADMIN_BAR;
    293250
    294                 if ( ! is_user_logged_in() )
     251                if ( 
     252                        ! is_user_logged_in() ||
     253                        ( is_admin() && ! is_multisite() )
     254                )
    295255                        $show_admin_bar = false;
    296256        }
    297257
  • wp-includes/js/admin-bar.dev.js

     
     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        },
     8
     9        aB, hc = new RegExp('\\bhover\\b', 'g'), q = [],
     10
     11        getTOID = function(el) {
     12                var i = q.length;
     13                while( i-- )
     14                        if ( q[i] && el == q[i][1] )
     15                                return q[i][0];
     16                return false;
     17        },
     18
     19        addClass = function(t) {
     20                while ( t && t != aB && t != d ) {
     21                        if( 'LI' == t.nodeName.toUpperCase() ) {
     22                                var id = getTOID(t);   
     23                                if ( id )
     24                                        clearTimeout( id );
     25                                t.className = t.className ? ( t.className.replace(hc, '') + ' hover' ) : 'hover';
     26                        }
     27                        t = t.parentNode;
     28                }
     29        },
     30
     31        removeClass = function(t) {
     32                while ( t && t != aB && t != d ) {
     33                        if( 'LI' == t.nodeName.toUpperCase() ) {
     34                                (function(t) {
     35                                        var to = setTimeout(function() {
     36                                                t.className = t.className ? t.className.replace(hc, '') : '';
     37                                        }, 500);
     38                                        q[q.length] = [to, t];
     39                                })(t);
     40                        }
     41                        t = t.parentNode;
     42                }
     43        }
     44
     45        clickShortlink = function(e) {
     46                var t = e.target || e.srcElement, links, i;
     47               
     48
     49                if ( 'undefined' == typeof setAdminBarL10n )
     50                        return;
     51
     52                while( t && t != aB && t != d && (
     53                        ! t.className ||
     54                        -1 == t.className.indexOf('ab-get-shortlink')
     55                ) )
     56                        t = t.parentNode;
     57
     58                if ( t && t.className && -1 != t.className.indexOf('ab-get-shortlink') ) {
     59                        links = d.getElementsByTagName('link');
     60                        if ( ! links.length )
     61                                links = d.links;
     62
     63                        i = links.length;
     64
     65                        if ( e.preventDefault )
     66                                e.preventDefault();
     67                        e.returnValue = false;
     68
     69                        while( i-- ) {
     70                                if ( links[i] && 'shortlink' == links[i].getAttribute('rel') ) {
     71                                        prompt( setAdminBarL10n.url, links[i].href );
     72                                        return false;
     73                                }
     74                        }
     75                       
     76                        alert( setAdminBarL10n.noShortlink );
     77                        return false;
     78                }
     79        },
     80
     81        addEvent(w, 'load', function() {
     82                var b = d.getElementsByTagName('body')[0],
     83                s = d.getElementById('adminbar-search');
     84               
     85                aB = d.getElementById('wpadminbar');
     86
     87                if ( b && aB ) {
     88                        b.appendChild( aB );
     89
     90                        addEvent(aB, 'mouseover', function(e) {
     91                                addClass( e.target || e.srcElement );
     92                        });
     93
     94                        addEvent(aB, 'mouseout', function(e) {
     95                                removeClass( e.target || e.srcElement );       
     96                        });
     97
     98                        addEvent(aB, 'click', clickShortlink );
     99                }
     100
     101                if ( s ) {
     102                        if ( '' == s.value )
     103                                s.value = s.getAttribute('title');
     104
     105                        s.onblur = function() {
     106                                this.value = '' == this.value ? this.getAttribute('title') : this.value;
     107                        }
     108                        s.onfocus = function() {
     109                                this.value = this.getAttribute('title') == this.value ? '' : this.value;
     110                        }
     111                }
     112               
     113                if ( w.location.hash )
     114                        w.scrollBy(0,-32);
     115        });
     116})(document, window);
  • wp-includes/admin-bar/admin-bar-class.php

     
    3333                $this->user->locale = get_locale();
    3434
    3535                add_action( 'wp_head', 'wp_admin_bar_header' );
     36                add_action( 'wp_head', 'wp_admin_body_style');
     37
    3638                add_action( 'admin_head', 'wp_admin_bar_header' );
     39                add_action( 'admin_head', 'wp_admin_body_style');
    3740
     41                wp_enqueue_script( 'admin-bar' );
    3842                wp_enqueue_style( 'admin-bar' );
    3943
    4044                if ( is_super_admin() ) {
  • wp-includes/css/admin-bar-rtl.dev.css

     
    2525        border-right: 1px solid #808080;
    2626}
    2727
    28 #wpadminbar .quicklinks > ul > li.hover > a {
     28#wpadminbar .quicklinks > ul > li:hover > a {
    2929        border-right-color: #707070;
    3030        border-left-color: #686868;
    3131}
     
    3535        float:none;
    3636}
    3737
    38 #wpadminbar .menupop li:hover > ul {
     38#wpadminbar .menupop li:hover > ul,
     39#wpadminbar .menupop li.hover > ul {
    3940        margin-left:-100%;
    4041}
    4142
     
    156157        padding: 0 0.7em 0 1.15em;
    157158}
    158159
    159 #wpadminbar li.ab-me > a.hover,
    160 #wpadminbar li.ab-blog > a.hover {
     160#wpadminbar li.ab-me > a:hover,
     161#wpadminbar li.ab-blog > a:hover {
    161162        background-position: 33% 59.8%;
    162163}
    163164
     
    211212        direction: ltr;
    212213}
    213214
    214 #wpadminbar #admin-bar-micro ul li:hover > ul {
     215#wpadminbar #admin-bar-micro ul li:hover > ul,
     216#wpadminbar #admin-bar-micro ul li.hover > ul {
    215217        left: auto;
    216218        right: 100%;
    217219}
  • wp-includes/css/admin-bar.dev.css

     
    3030#wpadminbar .quicklinks > ul > li:last-child > a {
    3131        border-right: none;
    3232}
    33 #wpadminbar .quicklinks > ul > li:hover > a,
    34 #wpadminbar .quicklinks > ul > li.hover > a {
     33#wpadminbar .quicklinks > ul > li:hover > a {
    3534        border-left-color: #707070;
    3635}
    3736#wpadminbar a {
     
    4544        float:none;
    4645        display:inline !important;
    4746}
    48 #wpadminbar li:hover > ul {
     47#wpadminbar li:hover > ul,
     48#wpadminbar li.hover > ul {
    4949        display:block;
    5050}
    5151
    52 #wpadminbar .menupop li:hover > ul {
     52#wpadminbar .menupop li:hover > ul,
     53#wpadminbar .menupop li.hover > ul {
    5354        margin-left:100%;
    5455        margin-top:-28px;
    5556}
     
    226227        padding: 0 1.15em 0 0.7em;
    227228}
    228229#wpadminbar li.ab-me > a:hover,
    229 #wpadminbar li.ab-me > a.hover,
    230 #wpadminbar li.ab-blog > a:hover,
    231 #wpadminbar li.ab-blog > a.hover {
     230#wpadminbar li.ab-blog > a:hover {
    232231        background-position: 67% 59.8%;
    233232}
    234233#wpadminbar li.ab-me img.avatar,
     
    338337* html #wpadminbar .menupop a span,
    339338* html #wpadminbar .menupop ul li a:hover,
    340339* html #wpadminbar .myaccount a,
    341 * html .quicklinks a:hover,#wpadminbar .menupop:hover {
     340* html .quicklinks a:hover,
     341* html #wpadminbar .menupop:hover {
    342342        background-image: none !important;
    343343}
    344344
  • wp-includes/script-loader.php

     
    5858
    5959        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
    6060
     61        $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20101028');
     62        $scripts->localize( 'admin-bar', 'setAdminBarL10n', array(
     63                'url' => __( 'URL:' ),
     64                'noShortlink' => __( 'No shortlink available for this page.' ),
     65        ) );
    6166        $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' );
    6267
    6368        $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20101007' );