You are here

function jcarousel_page_attachments in jCarousel 8.4

Same name and namespace in other branches
  1. 8.5 jcarousel.module \jcarousel_page_attachments()

Implements hook_page_attachments().

File

./jcarousel.module, line 699
Provides integration with 3rd party modules and the jCarousel library.

Code

function jcarousel_page_attachments(&$page) {
  if (!\Drupal::config('jcarousel.settings')
    ->get('global_load')) {
    return;
  }
  $options = [
    'skin' => 'default',
    'scroll' => 1,
    'vertical' => 0,
    'navigation' => 'after',
  ];

  // Add the jCarousel library and any global settings.
  $page['#attached']['library'][] = 'jcarousel/jcarousel';

  // Allow other modules to modify these settings.
  \Drupal::moduleHandler()
    ->alter('jcarousel_options', $options, $class_name);
  $skins = \Drupal::service('jcarousel.skins.manager')
    ->getDefinitions();
  foreach ($skins as $id => $skin) {
    $variables['#attached']['library'][] = 'jcarousel/skin.' . $id;
  }
}