Load the menu folded (if set), load the editor earlier

git-svn-id: https://develop.svn.wordpress.org/trunk@11118 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2009-04-29 05:43:03 +00:00
parent 61f7821b34
commit 4a911beaf3
8 changed files with 53 additions and 27 deletions

View File

@ -39,7 +39,7 @@ var pagenow = '<?php echo substr($pagenow, 0, -4); ?>';
<?php <?php
if ( in_array( $pagenow, array('post.php', 'post-new.php', 'page.php', 'page-new.php') ) ) { if ( in_array( $pagenow, array('post.php', 'post-new.php', 'page.php', 'page-new.php') ) ) {
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 ); add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 5 );
wp_enqueue_script('quicktags'); wp_enqueue_script('quicktags');
} }
@ -60,6 +60,9 @@ do_action("admin_head-$hook_suffix");
do_action('admin_head'); do_action('admin_head');
$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
if ( get_user_setting('mfold') ) {
$admin_body_class .= ' folded';
}
if ( $is_iphone ) { ?> if ( $is_iphone ) { ?>
<style type="text/css">.row-actions{visibility:visible;}</style> <style type="text/css">.row-actions{visibility:visible;}</style>
@ -71,9 +74,6 @@ if ( $is_iphone ) { ?>
(function(){ (function(){
var c = document.body.className; var c = document.body.className;
c = c.replace(/no-js/, 'js'); c = c.replace(/no-js/, 'js');
<?php if ( get_user_setting('mfold') == 'f' ) { ?>
c += ' folded';
<?php } ?>
document.body.className = c; document.body.className = c;
})(); })();
//]]> //]]>

View File

@ -362,3 +362,12 @@ function set_screen_options() {
exit; exit;
} }
} }
add_action( 'admin_init', 'wp_menu_unfold' );
function wp_menu_unfold() {
if ( isset($_GET['unfoldmenu']) && $user = get_current_user() ) {
delete_user_setting('mfold');
wp_redirect( remove_query_arg( 'unfoldmenu', stripslashes($_SERVER['REQUEST_URI']) ) );
exit;
}
}

View File

@ -13,20 +13,21 @@ adminMenu = {
$('#adminmenu li.menu-top .wp-menu-image').click( function() { window.location = $(this).siblings('a.menu-top')[0].href; } ); $('#adminmenu li.menu-top .wp-menu-image').click( function() { window.location = $(this).siblings('a.menu-top')[0].href; } );
this.favorites(); this.favorites();
$('.wp-menu-separator').click(function(){ $('a.separator').click(function(){
if ( $('body').hasClass('folded') ) { if ( $('body').hasClass('folded') ) {
adminMenu.fold(1); adminMenu.fold(1);
setUserSetting( 'mfold', 'o' ); deleteUserSetting( 'mfold' );
} else { } else {
adminMenu.fold(); adminMenu.fold();
setUserSetting( 'mfold', 'f' ); setUserSetting( 'mfold', 'f' );
} }
return false;
}); });
if ( 'f' != getUserSetting( 'mfold' ) ) { if ( $('body').hasClass('folded') ) {
this.restoreMenuState();
} else {
this.fold(); this.fold();
} else {
this.restoreMenuState();
} }
}, },

File diff suppressed because one or more lines are too long

View File

@ -61,32 +61,32 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$img = ''; $img = '';
if ( isset($item[6]) && ! empty($item[6]) ) { if ( isset($item[6]) && ! empty($item[6]) ) {
if ( 'div' === $item[6] ) if ( 'div' === $item[6] )
$img = '<div class="wp-menu-image"><br /></div>'; $img = '<br />';
else else
$img = '<img class="wp-menu-image" src="' . $item[6] . '" alt="" />'; $img = '<img src="' . $item[6] . '" alt="" />';
} }
$toggle = '<div class="wp-menu-toggle"><br /></div>'; $toggle = '<div class="wp-menu-toggle"><br /></div>';
echo "\n\t<li$class$id>"; echo "\n\t<li$class$id>";
if ( false !== strpos($class, 'wp-menu-separator') ) { if ( false !== strpos($class, 'wp-menu-separator') ) {
echo '<br />'; echo '<a class="separator" href="?unfoldmenu=1"><br /></a>';
} elseif ( $submenu_as_parent && !empty($submenu[$item[2]]) ) { } elseif ( $submenu_as_parent && !empty($submenu[$item[2]]) ) {
$submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
$menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
if ( ( ('index.php' != $submenu[$item[2]][0][2]) && file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") ) || !empty($menu_hook)) { if ( ( ('index.php' != $submenu[$item[2]][0][2]) && file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") ) || !empty($menu_hook)) {
$admin_is_parent = true; $admin_is_parent = true;
echo "$img$toggle<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class$tabindex>{$item[0]}</a>"; echo "<div class='wp-menu-image'><a href='admin.php?page={$submenu[$item[2]][0][2]}'>$img</a></div>$toggle<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class$tabindex>{$item[0]}</a>";
} else { } else {
echo "\n\t$img$toggle<a href='{$submenu[$item[2]][0][2]}'$class$tabindex>{$item[0]}</a>"; echo "\n\t<div class='wp-menu-image'><a href='{$submenu[$item[2]][0][2]}'>$img</a></div>$toggle<a href='{$submenu[$item[2]][0][2]}'$class$tabindex>{$item[0]}</a>";
} }
} else if ( current_user_can($item[1]) ) { } else if ( current_user_can($item[1]) ) {
$menu_hook = get_plugin_page_hook($item[2], 'admin.php'); $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
if ( ('index.php' != $item[2]) && file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) ) { if ( ('index.php' != $item[2]) && file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) ) {
$admin_is_parent = true; $admin_is_parent = true;
echo "\n\t$img$toggle<a href='admin.php?page={$item[2]}'$class$tabindex>{$item[0]}</a>"; echo "\n\t<div class='wp-menu-image'><a href='admin.php?page={$item[2]}'>$img</a></div>$toggle<a href='admin.php?page={$item[2]}'$class$tabindex>{$item[0]}</a>";
} else { } else {
echo "\n\t$img$toggle<a href='{$item[2]}'$class$tabindex>{$item[0]}</a>"; echo "\n\t<div class='wp-menu-image'><a href='{$item[2]}'>$img</a></div>$toggle<a href='{$item[2]}'$class$tabindex>{$item[0]}</a>";
} }
} }
@ -144,4 +144,4 @@ _wp_menu_output( $menu, $submenu );
do_action( 'adminmenu' ); do_action( 'adminmenu' );
?> ?>
</ul> </ul>

View File

@ -1038,7 +1038,12 @@ div.comment-item:hover .row-actions {
height: 21px; height: 21px;
padding: 0; padding: 0;
margin: 0; margin: 0;
}
#adminmenu a.separator {
cursor: w-resize; cursor: w-resize;
height: 20px;
padding: 0;
} }
.folded #adminmenu li.wp-menu-separator { .folded #adminmenu li.wp-menu-separator {
@ -1102,6 +1107,15 @@ div.comment-item:hover .row-actions {
border-bottom-width: 1px; border-bottom-width: 1px;
border-bottom-style: solid; border-bottom-style: solid;
} }
#adminmenu .wp-menu-image a {
height: 24px;
}
#adminmenu .wp-menu-image img {
padding: 6px 0 0 1px;
}
/* end side admin menu */ /* end side admin menu */
/* comments/plugins bubble in menu */ /* comments/plugins bubble in menu */

View File

@ -826,7 +826,7 @@ function delete_user_setting( $names ) {
$settings = rtrim($settings, '&'); $settings = rtrim($settings, '&');
update_user_option( $current_user->ID, 'user-settings', $settings ); update_user_option( $current_user->ID, 'user-settings', $settings );
setcookie('wp-settings-'.$current_user->ID, $settings, time() + 31536000, SITECOOKIEPATH); setcookie('wp-settings-' . $current_user->ID, $settings, time() + 31536000, SITECOOKIEPATH);
} }
} }
@ -843,16 +843,18 @@ function get_all_user_settings() {
if ( ! $user = wp_get_current_user() ) if ( ! $user = wp_get_current_user() )
return array(); return array();
if ( isset($_COOKIE['wp-settings-'.$user->ID]) ) { $arr = array();
$cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-'.$user->ID] ); if ( isset($_COOKIE['wp-settings-' . $user->ID]) ) {
$cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user->ID] );
if ( $cookie && strpos($cookie, '=') ) { // the '=' cannot be 1st char if ( $cookie && strpos($cookie, '=') ) // the '=' cannot be 1st char
parse_str($cookie, $arr); parse_str($cookie, $arr);
return $arr;
} } elseif ( isset($user->wp_usersettings) && is_string($user->wp_usersettings) ) {
parse_str( $user->wp_usersettings, $arr );
} }
return array(); return $arr;
} }
/** /**

View File

@ -60,7 +60,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' ); $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090416' ); $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090428' );
$scripts->add_data( 'common', 'group', 1 ); $scripts->add_data( 'common', 'group', 1 );
$scripts->localize( 'common', 'commonL10n', array( $scripts->localize( 'common', 'commonL10n', array(
'warnDelete' => __("You are about to delete the selected items.\n 'Cancel' to stop, 'OK' to delete."), 'warnDelete' => __("You are about to delete the selected items.\n 'Cancel' to stop, 'OK' to delete."),
@ -418,7 +418,7 @@ function wp_default_styles( &$styles ) {
$rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'farbtastic' ); $rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'farbtastic' );
$styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20090415' ); $styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20090428' );
$styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' ); $styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' );
$styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20090415' ); $styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20090415' );