diff --git a/admin_menu_toolbar/admin_menu_toolbar.module b/admin_menu_toolbar/admin_menu_toolbar.module index c6111bd..3b8a786 100644 --- a/admin_menu_toolbar/admin_menu_toolbar.module +++ b/admin_menu_toolbar/admin_menu_toolbar.module @@ -16,6 +16,12 @@ function admin_menu_toolbar_form_admin_menu_theme_settings_alter(&$form) { // The shortcut bar consists of two elements, so we target their class names // instead of cluttering the markup with additional IDs. $form['plugins']['admin_menu_components']['shortcut.links']['#attributes']['rel'] = '.shortcut-toggle, .shortcut-toolbar'; + + $form['plugins']['admin_menu_shortcuts_active'] = array( + '#type' => 'checkbox', + '#title' => t('Expand shortcuts by default'), + '#default_value' => variable_get('admin_menu_shortcuts_active', TRUE), + ); } /** @@ -62,6 +68,17 @@ function admin_menu_toolbar_admin_menu_output_build(&$content) { if (empty($content['#components']['shortcut.links']) && !$content['#complete']) { return; } + + // Should the shortcuts toolbar be enabled by default? + $toggle_attributes = array('class' => array('shortcut-toggle')); + $toolbar_classes = 'shortcut-toolbar'; + + $shortcuts_active = variable_get('admin_menu_shortcuts_active', TRUE); + if ($shortcuts_active) { + $toolbar_classes .= ' active'; + $toggle_attributes['class'][] = 'active'; + }; + // Add shortcuts toggle. $content['shortcut-toggle'] = array( '#access' => module_exists('shortcut'), @@ -70,7 +87,7 @@ function admin_menu_toolbar_admin_menu_output_build(&$content) { '#title' => t('Show shortcuts'), '#href' => '', '#options' => array( - 'attributes' => array('class' => array('shortcut-toggle')), + 'attributes' => $toggle_attributes, ), ); @@ -78,7 +95,7 @@ function admin_menu_toolbar_admin_menu_output_build(&$content) { $content['shortcut'] = array( '#access' => module_exists('shortcut'), '#weight' => 200, - '#prefix' => '
', + '#prefix' => '
', '#suffix' => '
', ); $content['shortcut']['shortcuts'] = array(