Commit 54e157e4 authored by David Suissa's avatar David Suissa Committed by Adrian Cid Almaguer
Browse files

Initial implementation of the 'toggle_shortcut' feature, based on MR 70.

parent 3f737eed
Loading
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -77,3 +77,13 @@ function admin_toolbar_update_8004() {
    ->save(TRUE);

}

/**
 * Disable the 'toggle_shortcut' feature by default.
 */
function admin_toolbar_update_8005() {
  \Drupal::service('config.factory')
    ->getEditable('admin_toolbar.settings')
    ->set('enable_toggle_shortcut', FALSE)
    ->save(TRUE);
}
+11 −0
Original line number Diff line number Diff line
@@ -36,3 +36,14 @@ toolbar.sticky_behavior:
    js/admin_toolbar.sticky_behavior.js: {}
  dependencies:
    - admin_toolbar/toolbar.tree

# Enable toolbar toggle keyboard shortcut.
toolbar.toggle_shortcut:
  css:
    theme:
      css/admin_toolbar.sticky_behavior.css: {}
      css/admin_toolbar.toggle_shortcut.css: {}
  js:
    js/admin_toolbar.toggle_shortcut.js: {}
  dependencies:
    - admin_toolbar/toolbar.tree
+6 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ function admin_toolbar_toolbar_alter(&$items) {
    default:
      break;
  }
  // Add the hoverIntent behavior library if enabled.
  $hoverintent_behavior = $admin_toolbar_config->get('hoverintent_behavior');
  if ($hoverintent_behavior['enabled'] === TRUE) {
    // Use the hoverIntent plugin library.
@@ -45,6 +46,11 @@ function admin_toolbar_toolbar_alter(&$items) {
    // Use default Admin Toolbar hover library.
    $items['administration']['#attached']['library'][] = 'admin_toolbar/toolbar.tree.hover';
  }

  // Add the toggle toolbar keyboard shortcut library if enabled.
  if ($admin_toolbar_config->get('enable_toggle_shortcut')) {
    $items['administration']['#attached']['library'][] = 'admin_toolbar/toolbar.toggle_shortcut';
  }
}

/**
+1 −0
Original line number Diff line number Diff line
enable_toggle_shortcut: false
menu_depth: 4
sticky_behavior: 'enabled'
hoverintent_behavior:
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@ admin_toolbar.settings:
  type: config_object
  label: 'Admin Toolbar settings'
  mapping:
    enable_toggle_shortcut:
      type: boolean
      label: 'Enable toggle toolbar keyboard shortcut'
    menu_depth:
      type: integer
      label: 'Depth of displayed menu'
Loading