diff --git a/core/modules/toolbar/toolbar.js b/core/modules/toolbar/toolbar.js index 2353050..5f66228 100644 --- a/core/modules/toolbar/toolbar.js +++ b/core/modules/toolbar/toolbar.js @@ -12,13 +12,31 @@ Drupal.behaviors.toolbar = { var $toolbar = $('#toolbar').once('toolbar'); if ($toolbar.length) { + // Hide the toolbar menu items underneath an "Administer" link when the + // screen is small enough that they will spill over and cause the toolbar + // to grow vertically. @todo: Run this whenever the browser window + // resizes (rather than on initial page load) if we want to make it fully + // responsive. + var $toggle = $toolbar.find('a.toggle'); + var $menu = $toolbar.find('#toolbar-menu'); + if ($menu.offset().top > 5) { + $menu.hide(); + // Clicking the "Administer" link toggles the menu items, and also + // hides the drawer toggle (since that looks out-of-place whenever the + // toolbar is expanded vertically). + $('' + Drupal.t('Administer') + '').insertBefore($menu).click(function() { + $menu.toggle(); + $toggle.toggle(); + }); + } + // Set the initial state of the toolbar. Drupal.toolbar.init(); $(window).on('resize.toolbar', Drupal.toolbar.height); // Toggling toolbar drawer. - $toolbar.find('a.toggle').once('toolbar-toggle').click(function(e) { + $toggle.once('toolbar-toggle').click(function(e) { e.preventDefault(); Drupal.toolbar.toggle(); // Allow resize event handlers to recalculate sizes/positions.