You are here

function views_add_js in Views (for Drupal 7) 8.3

Same name and namespace in other branches
  1. 6.3 views.module \views_add_js()
  2. 6.2 views.module \views_add_js()
  3. 7.3 views.module \views_add_js()

Include views .js files.

2 calls to views_add_js()
DisplayPluginBase::optionLink in lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
Because forms may be split up into sections, this provides an easy URL to exactly the right section. Don't override this.
template_preprocess_views_view in theme/theme.inc
Preprocess the primary theme implementation for a view.

File

./views.module, line 1232
Primarily Drupal hooks and global API functions to manipulate views.

Code

function views_add_js($file) {

  // If javascript has been disabled by the user, never add js files.
  if (config('views.settings')
    ->get('no_javascript')) {
    return;
  }
  $path = drupal_get_path('module', 'views');
  static $base = TRUE, $ajax = TRUE;
  if ($base) {
    drupal_add_js($path . "/js/base.js");
    $base = FALSE;
  }
  if ($ajax && in_array($file, array(
    'ajax',
    'ajax_view',
  ))) {
    drupal_add_library('system', 'drupal.ajax');
    drupal_add_library('system', 'jquery.form');
    $ajax = FALSE;
  }
  drupal_add_js($path . "/js/{$file}.js");
}