You are here

function toolbar_anti_flicker_preprocess_html in Toolbar Anti-flicker 8.2

Same name and namespace in other branches
  1. 8.3 toolbar_anti_flicker.module \toolbar_anti_flicker_preprocess_html()
  2. 8 toolbar_anti_flicker.module \toolbar_anti_flicker_preprocess_html()
  3. 9.3.x toolbar_anti_flicker.module \toolbar_anti_flicker_preprocess_html()

Implements hook_preprocess_HOOK() for HTML document templates.

File

./toolbar_anti_flicker.module, line 14

Code

function toolbar_anti_flicker_preprocess_html(&$variables) {
  if (!\Drupal::currentUser()
    ->hasPermission('access toolbar')) {
    return;
  }
  $orientation = \Drupal::request()->cookies
    ->get('toolbar');
  $variables['attributes']['class'][] = 'toolbar-loading';
  $variables['attributes']['class'][] = 'toolbar-fixed';
  if ($orientation == 'vertical') {
    $variables['attributes']['class'][] = 'toolbar-vertical';
  }
  else {
    $variables['attributes']['class'][] = 'toolbar-horizontal';
  }

  // Remove left margin for closed Vertical mode.
  $activeTab = \Drupal::request()->cookies
    ->get('toolbarActiveTab');
  if (!empty($activeTab)) {
    $variables['attributes']['class'][] = 'toolbar-tray-open';
  }
}