You are here

function webform_bootstrap_js_alter in Webform 8.5

Implements hook_js_alter().

File

modules/webform_bootstrap/webform_bootstrap.module, line 107
Helps support Webform to Bootstrap integration.

Code

function webform_bootstrap_js_alter(&$javascript, AttachedAssetsInterface $assets) {
  if (!_webform_bootstrap_is_active_theme()) {
    return;
  }

  // Make sure jQuery tooltip is never loaded and use
  // bootstrap specific webform.element.help.js.
  foreach ($javascript as $javascript_path => $javascript_item) {
    if (strpos($javascript_path, 'tooltip-min') !== FALSE) {
      unset($javascript[$javascript_path]);
    }
  }
  $webform_help_path = drupal_get_path('module', 'webform') . '/js/webform.element.help.js';
  $webform_bootstrap_help_path = drupal_get_path('module', 'webform_bootstrap') . '/js/webform.element.help.js';
  if (isset($javascript[$webform_help_path])) {
    $javascript[$webform_help_path]['data'] = $webform_bootstrap_help_path;
  }
}