You are here

function views_timelinejs_library in Views TimelineJS integration 7.3

Implements hook_library().

The views_timelinejs_css_library_group variable provides backward compatibility for sites that originally installed version 7.x-3.0 which gave the TimelineJS CSS libraries a weight of 200.

@todo Remove this variable in the next major version of the module.

See also

https://www.drupal.org/node/2856403

3 string references to 'views_timelinejs_library'
template_preprocess_views_timelinejs in theme/views_timelinejs.theme.inc
Prepares variables for the TimelineJS style template.
views_timelinejs_plugin_style_timelinejs::prepare_timeline_options in ./views_timelinejs_plugin_style_timelinejs.inc
Processes timeline options before theming.
views_timelinejs_settings_form in ./views_timelinejs.module
Admin settings menu callback.

File

./views_timelinejs.module, line 28
Views TimelineJS API, theming, libraries, etc.

Code

function views_timelinejs_library() {
  global $base_url;
  $libraries = array();
  $libraries['timelinejs.cdn'] = array(
    'title' => 'TimelineJS CDN',
    'website' => 'https://timeline.knightlab.com',
    'version' => '3.3.15',
    'js' => array(
      'timeline.js' => array(
        'data' => 'https://cdn.knightlab.com/libs/timeline3/latest/js/timeline.js',
        'type' => 'external',
        'group' => JS_LIBRARY,
      ),
    ),
    'css' => array(
      'timeline.css' => array(
        'data' => 'https://cdn.knightlab.com/libs/timeline3/latest/css/timeline.css',
        'type' => 'external',
        'group' => variable_get('views_timelinejs_css_library_group', CSS_DEFAULT),
      ),
    ),
  );
  $libraries['timelinejs.local'] = array(
    'title' => 'TimelineJS',
    'website' => 'https://timeline.knightlab.com',
    'version' => '3.3.15',
    'js' => array(
      'timeline.js' => array(
        'data' => $base_url . '/sites/all/libraries/TimelineJS3/compiled/js/timeline.js',
        'type' => 'external',
        'group' => JS_LIBRARY,
      ),
    ),
    'css' => array(
      'timeline.css' => array(
        'data' => $base_url . '/sites/all/libraries/TimelineJS3/compiled/css/timeline.css',
        'type' => 'external',
        'group' => variable_get('views_timelinejs_css_library_group', CSS_DEFAULT),
      ),
    ),
  );

  // Create a library for each TimelineJS3 alternate font set.
  foreach (array_keys(_views_timelinejs_list_font_sets()) as $set) {
    $libraries['timelinejs.' . $set . '.cdn'] = array(
      'title' => 'TimelineJS CDN ' . $set,
      'website' => 'https://timeline.knightlab.com',
      'version' => '3.3.15',
      'css' => array(
        'font.' . $set . '.css' => array(
          'data' => 'https://cdn.knightlab.com/libs/timeline3/latest/css/fonts/font.' . $set . '.css',
          'type' => 'external',
          'group' => variable_get('views_timelinejs_css_library_group', CSS_DEFAULT),
        ),
      ),
    );
    $libraries['timelinejs.' . $set . '.local'] = array(
      'title' => 'TimelineJS ' . $set,
      'website' => 'https://timeline.knightlab.com',
      'version' => '3.3.15',
      'css' => array(
        'font.' . $set . '.css' => array(
          'data' => $base_url . '/sites/all/libraries/TimelineJS3/compiled/css/fonts/font.' . $set . '.css',
          'type' => 'external',
          'group' => variable_get('views_timelinejs_css_library_group', CSS_DEFAULT),
        ),
      ),
    );
  }
  return $libraries;
}