diff --git a/sites/all/modules/contrib/admin_menu/admin_menu.js b/sites/all/modules/contrib/admin_menu/admin_menu.js index de0bb90..f3c841e 100644 --- a/sites/all/modules/contrib/admin_menu/admin_menu.js +++ b/sites/all/modules/contrib/admin_menu/admin_menu.js @@ -231,6 +231,16 @@ Drupal.admin.behaviors.hover = function (context, settings, $adminMenu) { ); } + // Lock menus when their children are active. + $('ul.dropdown', $adminMenu).hover( + function () { + $(this).parent().closest('.dropdown').addClass('locked'); + }, + function () { + $(this).parent().closest('.dropdown').removeClass('locked'); + } + ); + // Delayed mouseout. $('li.expandable', $adminMenu).hover( function () { @@ -241,12 +251,28 @@ Drupal.admin.behaviors.hover = function (context, settings, $adminMenu) { .css({left: 'auto', display: 'block'}) // Immediately hide nephew lists. .parent().siblings('li').children('ul').css({left: '-999em', display: 'none'}); + + var $list = $('> ul', this), + offset = $list.offset(), + position = $list.position(), + maxHeight = ($(window).innerHeight() - position.top), + height = $list.height(); + + // don't do any animation if list shorter than max + if (height > maxHeight) { + $('> ul', this).mousemove(function(e) { + var relativeY = ((e.pageY - offset.top) - position.top); + if (!$(this).hasClass('locked')) { + $(this).css("top", -relativeY); + } + }); + } }, function () { // Start the timer. var uls = $('> ul', this); this.sfTimer = setTimeout(function () { - uls.css({left: '-999em', display: 'none'}); + uls.css({top: 'auto', left: '-999em', display: 'none'}); }, 400); } );