Don't refresh the admin menu after page load, apply the user-state from PHP, fix behaviour after folding the menu, props nacin, props nuxwin, fixes #10646, fixes #17058

git-svn-id: http://svn.automattic.com/wordpress/trunk@17623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-04-07 18:45:22 +00:00
parent b1f3de70e7
commit 9ac90e3262
6 changed files with 22 additions and 22 deletions

File diff suppressed because one or more lines are too long

View File

@ -854,19 +854,23 @@ form.upgrade .hint {
}
.folded #adminmenu div.wp-submenu-head,
.folded #adminmenu li.wp-has-submenu div.sub-open {
body.js.folded #adminmenu li.wp-has-submenu div.sub-open {
display: block;
}
.folded #adminmenu a.menu-top,
.folded #adminmenu .wp-submenu,
.folded #adminmenu li.wp-menu-open .wp-submenu,
.folded #adminmenu li.wp-has-current-submenu .wp-submenu,
body.no-js.folded #adminmenu .open-if-no-js .wp-submenu,
body.js.folded #adminmenu li.wp-menu-open .wp-submenu,
body.no-js #adminmenu .wp-menu-toggle,
.folded #adminmenu div.wp-menu-toggle {
display: none;
}
#adminmenu li.wp-menu-open .wp-submenu,
.no-js #adminmenu .open-if-no-js .wp-submenu {
body.js #adminmenu li.wp-menu-open .wp-submenu,
body.no-js #adminmenu .open-if-no-js .wp-submenu,
body.no-js #adminmenu li.wp-has-current-submenu .wp-submenu {
display: block;
}

View File

@ -28,26 +28,15 @@ adminMenu = {
if ( $('body').hasClass('folded') )
this.fold();
this.restoreMenuState();
},
restoreMenuState : function() {
$('li.wp-has-submenu', '#adminmenu').each(function(i, e) {
var v = getUserSetting( 'm'+i );
if ( $(e).hasClass('wp-has-current-submenu') )
return true; // leave the current parent open
if ( 'o' == v )
$(e).addClass('wp-menu-open');
else if ( 'c' == v )
$(e).removeClass('wp-menu-open');
});
// (perhaps) needed for back-compat
},
toggle : function(el) {
el.slideToggle(150, function() {
var id = el.parent().toggleClass( 'wp-menu-open' ).attr('id');
var id = el.removeAttr('style').parent().toggleClass( 'wp-menu-open' ).attr('id');
if ( id ) {
$('li.wp-has-submenu', '#adminmenu').each(function(i, e) {
if ( id == e.id ) {

File diff suppressed because one or more lines are too long

View File

@ -36,6 +36,9 @@ get_admin_page_parent();
function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
global $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $typenow;
$menu_setting_increment = -1;
$user_settings = get_all_user_settings();
$first = true;
// 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src
foreach ( $menu as $key => $item ) {
@ -45,14 +48,18 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
$class[] = 'wp-first-item';
$first = false;
}
if ( !empty($submenu[$item[2]]) )
if ( !empty($submenu[$item[2]]) ) {
$class[] = 'wp-has-submenu';
$menu_setting_increment++;
}
if ( ( $parent_file && $item[2] == $parent_file ) || ( empty($typenow) && $self == $item[2] ) ) {
if ( !empty($submenu[$item[2]]) )
$class[] = 'wp-has-current-submenu wp-menu-open';
else
$class[] = 'current';
} elseif ( ! empty( $submenu[ $item[2] ] ) && isset( $user_settings[ 'm' . $menu_setting_increment ] ) && 'o' == $user_settings[ 'm' . $menu_setting_increment ] ) {
$class[] = 'wp-menu-open';
}
if ( ! empty($item[4]) )

View File

@ -64,7 +64,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20101211' );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20110407' );
$scripts->add_data( 'common', 'group', 1 );
$scripts->localize( 'common', 'commonL10n', array(
'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete."),
@ -473,7 +473,7 @@ function wp_default_styles( &$styles ) {
// Any rtl stylesheets that don't have a .dev version for ltr
$no_suffix = array( 'farbtastic' );
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20110214' );
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20110407' );
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20101102' );
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );