You are here

function _bootstrap_carousel_load_javascript in bootstrap_carousel 7

Add bootstrap javascript and library.

2 calls to _bootstrap_carousel_load_javascript()
bootstrap_carousel_ctools_render_alter in ./bootstrap_carousel.module
Implements hook_ctools_render_alter().
bootstrap_carousel_node_view in ./bootstrap_carousel.module
Implements hook_node_view().

File

./bootstrap_carousel.module, line 300
Bootstrap carousel module hooks.

Code

function _bootstrap_carousel_load_javascript($node) {
  $carousel_settings = array(
    'interval' => FALSE,
    'pause' => '',
  );
  $node = entity_metadata_wrapper('node', $node);
  $interval = $node->field_carousel_interval
    ->value();
  if (!empty($interval)) {
    $carousel_settings['interval'] = $interval;
  }
  $control_options = $node->field_control_options
    ->value();
  if (in_array(3, $control_options)) {
    $carousel_settings['pause'] = 'hover';
  }
  foreach ($node->field_slides
    ->value() as $slide) {
    if (isset($slide['carousel_video'])) {
      drupal_add_js(variable_get('bootstrap_carousel_youtube_player_api', 'https://www.youtube.com/player_api'), 'external');
    }
  }
  libraries_load('bootstrap');
  drupal_add_js(drupal_get_path('module', 'bootstrap_carousel') . '/scripts/bootstrap_carousel.js');
  drupal_add_js(array(
    'bootstrap_carousel' => $carousel_settings,
  ), 'setting');
}