More admin bar updates. See #14772 props filosofo.

Moves js out into seperate file.
Respects WP_SHOW_ADMIN_BAR.
Moved shortlink to top-level
Removed admin bar from non-multisite admin pages.
Set eol-style on new files.

git-svn-id: http://svn.automattic.com/wordpress/trunk@16070 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2010-10-29 07:25:58 +00:00
parent 00cfb6bd82
commit 693c1f6f60
9 changed files with 152 additions and 62 deletions

View File

@ -170,12 +170,7 @@ function wp_admin_bar_blog_separator() {
function wp_admin_bar_bloginfo_menu() {
global $wp_admin_bar;
/* Add the Site Info menu */
$wp_admin_bar->add_menu( array( 'id' => 'bloginfo', 'title' => __( 'Site Info' ), 'href' => '', ) );
// TODO: Move this js out into a seperate file?
$wp_admin_bar->add_menu( array( 'parent' => 'bloginfo', 'title' => __( 'Get Shortlink' ), 'href' => '', 'meta' => array(
'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;' ) ) );
$wp_admin_bar->add_menu( array( 'id' => 'get-shortlink', 'title' => __( 'Get Shortlink' ), 'href' => '', ) );
}
/**
@ -208,41 +203,6 @@ function wp_admin_bar_edit_menu() {
function wp_admin_bar_header() {
?>
<style type="text/css" media="print">#wpadminbar { display:none; }</style>
<script type="text/javascript">
/* <![CDATA[ */
(function(d, w) {
var init = function() {
var b = d.getElementsByTagName('body')[0],
aB = d.getElementById('wpadminbar'),
s = d.getElementById('adminbar-search');
if ( b && aB )
b.appendChild( aB );
if ( s ) {
if ( '' == s.value )
s.value = s.getAttribute('title');
s.onblur = function() {
this.value = '' == this.value ? this.getAttribute('title') : this.value;
}
s.onfocus = function() {
this.value = this.getAttribute('title') == this.value ? '' : this.value;
}
}
if ( w.location.hash )
w.scrollBy(0,-32);
}
if ( w.addEventListener )
w.addEventListener('load', init, false);
else if ( w.attachEvent )
w.attachEvent('onload', init);
})(document, window);
/* ]]> */
</script>
<?php
}
@ -272,9 +232,6 @@ function wp_admin_body_style() {
<?php
}
add_action('wp_head', 'wp_admin_body_style');
add_action('admin_head', 'wp_admin_body_style');
/**
* Determine whether the admin bar should be showing.
*
@ -291,7 +248,10 @@ function is_admin_bar_showing() {
if ( defined('WP_SHOW_ADMIN_BAR') )
$show_admin_bar = (bool) WP_SHOW_ADMIN_BAR;
if ( ! is_user_logged_in() )
if (
! is_user_logged_in() ||
( is_admin() && ! is_multisite() )
)
$show_admin_bar = false;
}

View File

@ -33,8 +33,12 @@ class WP_Admin_Bar {
$this->user->locale = get_locale();
add_action( 'wp_head', 'wp_admin_bar_header' );
add_action( 'admin_head', 'wp_admin_bar_header' );
add_action( 'wp_head', 'wp_admin_body_style');
add_action( 'admin_head', 'wp_admin_bar_header' );
add_action( 'admin_head', 'wp_admin_body_style');
wp_enqueue_script( 'admin-bar' );
wp_enqueue_style( 'admin-bar' );
if ( is_super_admin() ) {

View File

@ -1 +1 @@
#wpadminbar{background:#666 url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 -222px repeat-x;direction:rtl;font-family:Tahoma,Arial,sans-serif;right:0;left:auto;}#wpadminbar div,#wpadminbar ul,#wpadminbar ul li{min-height:0;}#wpadminbar ul li img{margin-left:8px!important;margin-right:0!important;}#wpadminbar .quicklinks>ul>li>a{border-left:1px solid #686868;border-right:1px solid #808080;}#wpadminbar .quicklinks>ul>li:last-child>a{border-left:none;border-right:1px solid #808080;}#wpadminbar .quicklinks>ul>li.hover>a{border-right-color:#707070;border-left-color:#686868;}#wpadminbar .avatar{margin:-3px 0 0 5px!important;float:none;}#wpadminbar .menupop li:hover>ul{margin-left:-100%;}#wpadminbar .menupop a>span{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 100.4% no-repeat;padding-left:.8em;}#wpadminbar .menupop ul li a>span{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 97.2% no-repeat;padding-right:0;padding-left:1.5em;}#wpadminbar .menupop ul{right:0;width:100%;min-width:150px;}#wpadminbar .ab-my-account ul{width:200px;}#wpadminbar .ab-my-blogs ul{width:300px;}#wpadminbar .ab-my-blogs ul ul{width:200px;}#wpadminbar .ab-bloginfo ul{width:200px;}#wpadminbar .ab-subscribe ul{width:150px;}#wpadminbar .menupop ul li{width:auto;}#wpadminbar .quicklinks a{font-family:Tahoma,Arial,Helvetica,sans-serif;}#wpadminbar li.ab-sadmin{float:left;}#wpadminbar li.ab-sadmin ul{right:auto;left:0;float:left;}#wpadminbar li.ab-sadmin>a{border-right:1px solid #666!important;border-left:none!important;}#wpadminbar li.ab-sadmin ul a{border-right:none!important;border-left:none!important;}#wpadminbar li.ab-sadmin ul li{left:0;right:auto;float:left;text-align:right;}#wpadminbar li.ab-sadmin ul li a{padding-right:1.75em;padding-left:0;}#wpadminbar li.ab-sadmin ul li a>span{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) 100% 101.8% no-repeat;padding-right:1.25em!important;padding-left:0!important;margin-right:-1.25em;margin-left:0;}#wpadminbar li:hover{background:#555 url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 -282px repeat-x;}#wpadminbar li li:hover{background:#888 url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 -222px repeat-x!important;}.quicklinks ul{text-align:right;}.quicklinks ul li{float:right;}#adminbarsearch{display:none;}#adminbarsearch label,#adminbarsearch a{float:right;}#wpadminbar li.ab-me>a,#wpadminbar li.ab-blog>a{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 59.8% no-repeat;padding:0 .7em 0 1.15em;}#wpadminbar li.ab-me>a.hover,#wpadminbar li.ab-blog>a.hover{background-position:33% 59.8%;}#wpadminbar li.ab-my-account a,#wpadminbar li.ab-bloginfo a{border-right:none!important;padding-right:.7em!important;}#wpadminbar li.ab-my-account>ul,#wpadminbar li.ab-bloginfo>ul{right:-7px;left:auto;}#wpadminbar ul li a strong.count{margin-right:5px;margin-left:0;position:static;}.adminbar-input{background:#ddd url(../images/admin-bar-sprite-rtl.png?d=08102010) right top no-repeat!important;float:right!important;font-family:Tahoma,Arial,Helvetica,sans-serif!important;margin-right:3px!important;margin-left:0!important;}button.adminbar-button{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) left -107px no-repeat;float:right;padding:0 0 0 14px;}button.adminbar-button span{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) right -69px no-repeat;padding:3px 14px 0 0;font-family:Tahoma,Arial,Helvetica,sans-serif!important;}button.adminbar-button:active{background-position:left -184px!important;}button.adminbar-button:active span{background-position:right -146px!important;}#querylist{direction:ltr;}#wpadminbar #admin-bar-micro ul li:hover>ul{left:auto;right:100%;}
#wpadminbar{background:#666 url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 -222px repeat-x;direction:rtl;font-family:Tahoma,Arial,sans-serif;right:0;left:auto;}#wpadminbar div,#wpadminbar ul,#wpadminbar ul li{min-height:0;}#wpadminbar ul li img{margin-left:8px!important;margin-right:0!important;}#wpadminbar .quicklinks>ul>li>a{border-left:1px solid #686868;border-right:1px solid #808080;}#wpadminbar .quicklinks>ul>li:last-child>a{border-left:none;border-right:1px solid #808080;}#wpadminbar .quicklinks>ul>li:hover>a{border-right-color:#707070;border-left-color:#686868;}#wpadminbar .avatar{margin:-3px 0 0 5px!important;float:none;}#wpadminbar .menupop li:hover>ul,#wpadminbar .menupop li.hover>ul{margin-left:-100%;}#wpadminbar .menupop a>span{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 100.4% no-repeat;padding-left:.8em;}#wpadminbar .menupop ul li a>span{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 97.2% no-repeat;padding-right:0;padding-left:1.5em;}#wpadminbar .menupop ul{right:0;width:100%;min-width:150px;}#wpadminbar .ab-my-account ul{width:200px;}#wpadminbar .ab-my-blogs ul{width:300px;}#wpadminbar .ab-my-blogs ul ul{width:200px;}#wpadminbar .ab-bloginfo ul{width:200px;}#wpadminbar .ab-subscribe ul{width:150px;}#wpadminbar .menupop ul li{width:auto;}#wpadminbar .quicklinks a{font-family:Tahoma,Arial,Helvetica,sans-serif;}#wpadminbar li.ab-sadmin{float:left;}#wpadminbar li.ab-sadmin ul{right:auto;left:0;float:left;}#wpadminbar li.ab-sadmin>a{border-right:1px solid #666!important;border-left:none!important;}#wpadminbar li.ab-sadmin ul a{border-right:none!important;border-left:none!important;}#wpadminbar li.ab-sadmin ul li{left:0;right:auto;float:left;text-align:right;}#wpadminbar li.ab-sadmin ul li a{padding-right:1.75em;padding-left:0;}#wpadminbar li.ab-sadmin ul li a>span{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) 100% 101.8% no-repeat;padding-right:1.25em!important;padding-left:0!important;margin-right:-1.25em;margin-left:0;}#wpadminbar li:hover{background:#555 url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 -282px repeat-x;}#wpadminbar li li:hover{background:#888 url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 -222px repeat-x!important;}.quicklinks ul{text-align:right;}.quicklinks ul li{float:right;}#adminbarsearch{display:none;}#adminbarsearch label,#adminbarsearch a{float:right;}#wpadminbar li.ab-me>a,#wpadminbar li.ab-blog>a{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) 0 59.8% no-repeat;padding:0 .7em 0 1.15em;}#wpadminbar li.ab-me>a:hover,#wpadminbar li.ab-blog>a:hover{background-position:33% 59.8%;}#wpadminbar li.ab-my-account a,#wpadminbar li.ab-bloginfo a{border-right:none!important;padding-right:.7em!important;}#wpadminbar li.ab-my-account>ul,#wpadminbar li.ab-bloginfo>ul{right:-7px;left:auto;}#wpadminbar ul li a strong.count{margin-right:5px;margin-left:0;position:static;}.adminbar-input{background:#ddd url(../images/admin-bar-sprite-rtl.png?d=08102010) right top no-repeat!important;float:right!important;font-family:Tahoma,Arial,Helvetica,sans-serif!important;margin-right:3px!important;margin-left:0!important;}button.adminbar-button{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) left -107px no-repeat;float:right;padding:0 0 0 14px;}button.adminbar-button span{background:url(../images/admin-bar-sprite-rtl.png?d=08102010) right -69px no-repeat;padding:3px 14px 0 0;font-family:Tahoma,Arial,Helvetica,sans-serif!important;}button.adminbar-button:active{background-position:left -184px!important;}button.adminbar-button:active span{background-position:right -146px!important;}#querylist{direction:ltr;}#wpadminbar #admin-bar-micro ul li:hover>ul,#wpadminbar #admin-bar-micro ul li.hover>ul{left:auto;right:100%;}

View File

@ -25,7 +25,7 @@
border-right: 1px solid #808080;
}
#wpadminbar .quicklinks > ul > li.hover > a {
#wpadminbar .quicklinks > ul > li:hover > a {
border-right-color: #707070;
border-left-color: #686868;
}
@ -35,7 +35,8 @@
float:none;
}
#wpadminbar .menupop li:hover > ul {
#wpadminbar .menupop li:hover > ul,
#wpadminbar .menupop li.hover > ul {
margin-left:-100%;
}
@ -156,8 +157,8 @@
padding: 0 0.7em 0 1.15em;
}
#wpadminbar li.ab-me > a.hover,
#wpadminbar li.ab-blog > a.hover {
#wpadminbar li.ab-me > a:hover,
#wpadminbar li.ab-blog > a:hover {
background-position: 33% 59.8%;
}
@ -211,7 +212,8 @@ button.adminbar-button:active span {
direction: ltr;
}
#wpadminbar #admin-bar-micro ul li:hover > ul {
#wpadminbar #admin-bar-micro ul li:hover > ul,
#wpadminbar #admin-bar-micro ul li.hover > ul {
left: auto;
right: 100%;
}

File diff suppressed because one or more lines are too long

View File

@ -30,8 +30,7 @@
#wpadminbar .quicklinks > ul > li:last-child > a {
border-right: none;
}
#wpadminbar .quicklinks > ul > li:hover > a,
#wpadminbar .quicklinks > ul > li.hover > a {
#wpadminbar .quicklinks > ul > li:hover > a {
border-left-color: #707070;
}
#wpadminbar a {
@ -45,11 +44,13 @@
float:none;
display:inline !important;
}
#wpadminbar li:hover > ul {
#wpadminbar li:hover > ul,
#wpadminbar li.hover > ul {
display:block;
}
#wpadminbar .menupop li:hover > ul {
#wpadminbar .menupop li:hover > ul,
#wpadminbar .menupop li.hover > ul {
margin-left:100%;
margin-top:-28px;
}
@ -226,9 +227,7 @@ html>body #wpadminbar .menupop ul {
padding: 0 1.15em 0 0.7em;
}
#wpadminbar li.ab-me > a:hover,
#wpadminbar li.ab-me > a.hover,
#wpadminbar li.ab-blog > a:hover,
#wpadminbar li.ab-blog > a.hover {
#wpadminbar li.ab-blog > a:hover {
background-position: 67% 59.8%;
}
#wpadminbar li.ab-me img.avatar,
@ -338,7 +337,8 @@ button.adminbar-button::-moz-focus-inner {
* html #wpadminbar .menupop a span,
* html #wpadminbar .menupop ul li a:hover,
* html #wpadminbar .myaccount a,
* html .quicklinks a:hover,#wpadminbar .menupop:hover {
* html .quicklinks a:hover,
* html #wpadminbar .menupop:hover {
background-image: none !important;
}

View File

@ -0,0 +1,116 @@
(function(d, w) {
var addEvent = function( obj, type, fn ) {
if (obj.addEventListener)
obj.addEventListener(type, fn, false);
else if (obj.attachEvent)
obj.attachEvent('on' + type, function() { return fn.call(obj, window.event);});
},
aB, hc = new RegExp('\\bhover\\b', 'g'), q = [],
getTOID = function(el) {
var i = q.length;
while( i-- )
if ( q[i] && el == q[i][1] )
return q[i][0];
return false;
},
addClass = function(t) {
while ( t && t != aB && t != d ) {
if( 'LI' == t.nodeName.toUpperCase() ) {
var id = getTOID(t);
if ( id )
clearTimeout( id );
t.className = t.className ? ( t.className.replace(hc, '') + ' hover' ) : 'hover';
}
t = t.parentNode;
}
},
removeClass = function(t) {
while ( t && t != aB && t != d ) {
if( 'LI' == t.nodeName.toUpperCase() ) {
(function(t) {
var to = setTimeout(function() {
t.className = t.className ? t.className.replace(hc, '') : '';
}, 500);
q[q.length] = [to, t];
})(t);
}
t = t.parentNode;
}
}
clickShortlink = function(e) {
var t = e.target || e.srcElement, links, i;
if ( 'undefined' == typeof adminBarL10n )
return;
while( t && t != aB && t != d && (
! t.className ||
-1 == t.className.indexOf('ab-get-shortlink')
) )
t = t.parentNode;
if ( t && t.className && -1 != t.className.indexOf('ab-get-shortlink') ) {
links = d.getElementsByTagName('link');
if ( ! links.length )
links = d.links;
i = links.length;
if ( e.preventDefault )
e.preventDefault();
e.returnValue = false;
while( i-- ) {
if ( links[i] && 'shortlink' == links[i].getAttribute('rel') ) {
prompt( adminBarL10n.url, links[i].href );
return false;
}
}
alert( adminBarL10n.noShortlink );
return false;
}
},
addEvent(w, 'load', function() {
var b = d.getElementsByTagName('body')[0],
s = d.getElementById('adminbar-search');
aB = d.getElementById('wpadminbar');
if ( b && aB ) {
b.appendChild( aB );
addEvent(aB, 'mouseover', function(e) {
addClass( e.target || e.srcElement );
});
addEvent(aB, 'mouseout', function(e) {
removeClass( e.target || e.srcElement );
});
addEvent(aB, 'click', clickShortlink );
}
if ( s ) {
if ( '' == s.value )
s.value = s.getAttribute('title');
s.onblur = function() {
this.value = '' == this.value ? this.getAttribute('title') : this.value;
}
s.onfocus = function() {
this.value = this.getAttribute('title') == this.value ? '' : this.value;
}
}
if ( w.location.hash )
w.scrollBy(0,-32);
});
})(document, window);

View File

@ -0,0 +1 @@
(function(h,i){var b=function(l,k,d){if(l.addEventListener){l.addEventListener(k,d,false)}else{if(l.attachEvent){l.attachEvent("on"+k,function(){return d.call(l,window.event)})}}},c,e=new RegExp("\\bhover\\b","g"),a=[],f=function(k){var d=a.length;while(d--){if(a[d]&&k==a[d][1]){return a[d][0]}}return false},g=function(d){while(d&&d!=c&&d!=h){if("LI"==d.nodeName.toUpperCase()){var k=f(d);if(k){clearTimeout(k)}d.className=d.className?(d.className.replace(e,"")+" hover"):"hover"}d=d.parentNode}},j=function(d){while(d&&d!=c&&d!=h){if("LI"==d.nodeName.toUpperCase()){(function(k){var l=setTimeout(function(){k.className=k.className?k.className.replace(e,""):""},500);a[a.length]=[l,k]})(d)}d=d.parentNode}};clickShortlink=function(m){var l=m.target||m.srcElement,d,k;if("undefined"==typeof adminBarL10n){return}while(l&&l!=c&&l!=h&&(!l.className||-1==l.className.indexOf("ab-get-shortlink"))){l=l.parentNode}if(l&&l.className&&-1!=l.className.indexOf("ab-get-shortlink")){d=h.getElementsByTagName("link");if(!d.length){d=h.links}k=d.length;if(m.preventDefault){m.preventDefault()}m.returnValue=false;while(k--){if(d[k]&&"shortlink"==d[k].getAttribute("rel")){prompt(adminBarL10n.url,d[k].href);return false}}alert(adminBarL10n.noShortlink);return false}},b(i,"load",function(){var d=h.getElementsByTagName("body")[0],k=h.getElementById("adminbar-search");c=h.getElementById("wpadminbar");if(d&&c){d.appendChild(c);b(c,"mouseover",function(l){g(l.target||l.srcElement)});b(c,"mouseout",function(l){j(l.target||l.srcElement)});b(c,"click",clickShortlink)}if(k){if(""==k.value){k.value=k.getAttribute("title")}k.onblur=function(){this.value=""==this.value?this.getAttribute("title"):this.value};k.onfocus=function(){this.value=this.getAttribute("title")==this.value?"":this.value}}if(i.location.hash){i.scrollBy(0,-32)}})})(document,window);

View File

@ -257,6 +257,13 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20100925' );
$scripts->add_data( 'user-profile', 'group', 1 );
$scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20101028');
$scripts->add_data( 'admin-bar', 'group', 1 );
$scripts->localize( 'admin-bar', 'adminBarL10n', array(
'url' => __( 'URL:' ),
'noShortlink' => __( 'No shortlink available for this page.' ),
) );
if ( is_admin() ) {
$scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' );
@ -493,7 +500,7 @@ function wp_default_styles( &$styles ) {
$styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20100907' );
// Admin bar
$styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20101028' );
$styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20101029' );
$styles->add( 'super-admin-bar', "/wp-includes/css/super-admin-bar$suffix.css", array(), '20101028' );
foreach ( $rtl_styles as $rtl_style ) {