Alternative javascript/jQuery snippet
| Project: | Administration Menu Dropdown |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Hi,
I have created an alternative version of the javascript used by this awesome module that I thought it would be nice to share.
It uses jQuery to collapse/expand the admin menu on mouse over/out. When the menu is "collapsed", only the icon on the left is visible, mouseovering the icon expands de whole menu using jQuery animation. The display state of the icon itself can still be toggled with the keyboard, though this version needs to press ctrl+alt+shift at a time, so it doesn't conflict (or it is at least a bit more difficult to) with other "hotkeys" that one can have installed on the browser.
By default, only the icon is displayed. And that's it. I hope that some out there might find it useful. It's been a good excuse for me to learn how jQuery works.
Cheers
| Attachment | Size |
|---|---|
| admin_menu_dropdown.js_.txt | 1.93 KB |

#1
That's pretty slick. When I initially played around with doing this module my first attempt was something similar like this. I decided on keeping the entire menu hidden to keep things a minimal as possible. This will help for those that would prefer to just use a mouse. Thanks for contrib!
#2
Hi,
Here's another version which is compatible with recent version of admin_menu D6.
if (Drupal.jsEnabled) {Drupal.admin_menu_fix = {
init: function() {
$("div#admin-menu").children("ul:first").children("li:gt(0)").hide();
$("div#admin-menu").width("24px").height("24px").css("overflow","hidden");
Drupal.admin_menu_fix.is_ready = true;
Drupal.admin_menu_fix.is_collapsed = true;
$("div#admin-menu ul:first li.admin-menu-icon:first a:first").css("padding","4px").attr({
href: "#",
title: "Click here to toggle administration menu visibility!"
}).click(function() {
this.blur();
if (!Drupal.admin_menu_fix.is_ready) return;
Drupal.admin_menu_fix.is_ready = false;
if (Drupal.admin_menu_fix.is_collapsed) {
$("div#admin-menu").width("100%").css("overflow","visible").children("ul:first").children("li:gt(0)").show();
Drupal.admin_menu_fix.is_collapsed = false;
}
else {
$("div#admin-menu").width("24px").css("overflow","hidden").children("ul:first").children("li:gt(0)").hide();
Drupal.admin_menu_fix.is_collapsed = true;
}
Drupal.admin_menu_fix.is_ready = true;
return false;
});
}
};
$(document).ready(Drupal.admin_menu_fix.init);
}
I hope that helps someone.
#3
Duplicate: #234914: New behavior for Admin Menu Dropdown