You are here

simple_responsive_table.module in Simple Responsive Table 8

File

simple_responsive_table.module
View source
<?php

/**
 * @file
 * Contains simple_responsive_table.module..
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function simple_responsive_table_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the simple_responsive_table module.
    case 'help.page.simple_responsive_table':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Simple module to make table responsive.') . '</p>';
      return $output;
    default:
  }
}

/**
 * Implements hook_page_attachments().
 */
function simple_responsive_table_page_attachments(array &$page) {
  $is_admin = \Drupal::service('router.admin_context')
    ->isAdminRoute();
  $config = \Drupal::config('simple_responsive_table.settings')
    ->get();
  if (!$is_admin || $config['enable_admin_page']) {
    $page['#attached']['library'][] = 'simple_responsive_table/global-styling';
    $page['#attached']['drupalSettings']['simpleResponsiveTable'] = [
      'maxWidth' => $config['max_width'],
      'modulePath' => drupal_get_path('module', 'simple_responsive_table'),
    ];
  }
}