From f8d904538dfab3c5dbf75f4a1e2039f5ba10ec7c Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 22 Sep 2008 08:01:42 +0000 Subject: [PATCH] Simple "sticky" menu, remembers the open parents and the current parent is always open git-svn-id: https://develop.svn.wordpress.org/trunk@8953 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/js/common.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index f21c9149ae..5be9584941 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -54,12 +54,28 @@ jQuery( function($) { effect = 'slideToggle'; } ul[effect]().parent().toggleClass( 'wp-menu-open' ); + + $('#adminmenu li.wp-has-submenu').each(function(i, e) { + var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c'; + + setUserSetting( 'm'+i, v ); + }); + return false; }; - jQuery('#adminmenu li.wp-has-submenu > a').click( function() { return menuToggle( jQuery(this).siblings('ul') ); } ); + $('#adminmenu li.wp-has-submenu').each(function(i, e) { + var v = getUserSetting( 'm'+i ); - jQuery('#dashmenu li.wp-has-submenu').bind( 'mouseenter mouseleave', function() { return menuToggle( jQuery(this).children('ul'), 'toggle' ); } ); + 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'); + }); + + $('#adminmenu li.wp-has-submenu > a').click( function() { return menuToggle( $(this).siblings('ul') ); } ); + + $('#dashmenu li.wp-has-submenu').bind( 'mouseenter mouseleave', function() { return menuToggle( $(this).children('ul'), 'toggle' ); } ); } );