You are here

function shadowbox_library_alter in Shadowbox 8

Implements hook_library_alter().

File

./shadowbox.module, line 84
Shadowbox, a JavaScript media viewer application for displaying content in a modal dialogue.

Code

function shadowbox_library_alter(array &$library, $name, $theme = NULL) {
  if ($name == 'shadowbox/shadowbox') {
    $shadowbox_location = \Drupal::config('shadowbox.settings')
      ->get('shadowbox_location');

    // Alter shadowbox JavaScript library registry.
    $library['js'][] = array(
      'type' => 'setting',
      'data' => _shadowbox_get_settings(),
    );
    $library['js'][] = array(
      'type' => 'inline',
      'scope' => 'header',
      'group' => JS_THEME,
      'data' => 'Shadowbox.path = "' . base_path() . $shadowbox_location . '/";',
    );

    // Alter shadowbox CSS library registry.
    $library['css'][] = array(
      'type' => 'inline',
      'media' => 'print',
      'data' => '
        #sb-container { position: relative; }
        #sb-overlay { display: none; }
        #sb-wrapper { position: relative; top: 0; left: 0; }
        #sb-loading { display: none; }
      ',
    );

    // Shadowbox js and css files location.
    if ($library['js'][0]['data'] != $shadowbox_location . '/shadowbox.js') {
      $library['js'][0]['data'] = $shadowbox_location . '/shadowbox.js';
    }
    if ($library['css'][0]['data'] != $shadowbox_location . '/shadowbox.css') {
      $library['css'][0]['data'] = $shadowbox_location . '/shadowbox.css';
    }
  }
}