diff --git a/navbar.js b/navbar.js index b4fb1ab..b3e56f8 100644 --- a/navbar.js +++ b/navbar.js @@ -6,7 +6,15 @@ Drupal.navbar = Drupal.navbar || {}; * Fix internal padding to the height of the navigation bar. */ Drupal.behaviors.navbar = { - attach: function(context) { + attach: function(context, settings) { + // Initialize settings. + settings.navbar = $.extend({ + suppress: false, + }, settings.navbar || {}); + // Check whether navbar should be suppressed. + if (settings.navbar.suppress) { + return; + } $('body').css('paddingTop', Drupal.navbar.height() + Drupal.navbar.drawerHeight()); $('#navbar-drawer').css('top', Drupal.navbar.height()); } diff --git a/navbar.module b/navbar.module index 15b1f43..cfb4a70 100644 --- a/navbar.module +++ b/navbar.module @@ -34,6 +34,9 @@ function navbar_theme($existing, $type, $theme, $path) { * Add navigation bar to the page_top region automatically. */ function navbar_page_build(&$page) { + if (navbar_suppress(FALSE)) { + return; + } $page['page_top']['navbar'] = array( '#pre_render' => array('navbar_pre_render'), '#access' => user_access('access navbar'), @@ -123,3 +126,26 @@ function navbar_view() { return $build; } + +/** + * Implementation of hook_suppress() + * + * Allows other modules to suppress display of Navbar + * + * This function should be called from within another module's page callback + * (preferably using module_invoke()) when the menu should not be displayed. + * This is useful for modules that implement popup pages or other special + * pages where the chat would be distracting or break the layout. + * + * @param $set + * Defaults to TRUE. If called before hook_footer(), the navbar will not be + * displayed. If FALSE is passed, the suppression state is returned. + **/ +function navbar_suppress($set = TRUE) { + static $suppress = FALSE; + if (!empty($set) && $suppress === FALSE) { + $suppress = TRUE; + drupal_add_js(array('navbar' => array('suppress' => 1)), 'setting'); + } + return $suppress; +}