You are here

function beautytips_add_js in BeautyTips 8

Same name and namespace in other branches
  1. 7.2 beautytips.module \beautytips_add_js()

Add the basic beautytips javascript to the page.

1 call to beautytips_add_js()
beautytips_add_beautytips in ./beautytips.module
This is the API. Call this function to add beautytips.

File

./beautytips.module, line 75
Provides API for adding beautytips to pages.

Code

function beautytips_add_js(&$element) {
  $added =& drupal_static(__FUNCTION__, FALSE);
  if (!$added) {

    // Add beautytips jQuery plugin and module js.
    $element['#attached']['library'][] = 'beautytips/beautytips-module';
    $path = drupal_get_path('module', 'beautytips');
    if (file_exists($path . '/other_libs/excanvas_r3/excanvas.compiled.js')) {

      // Add this for ie compatibility
      $element['#attached']['library'][] = 'beautytips/excanvas_r3';
    }
    if (\Drupal::config('beautytips.basic')
      ->get('beautytips_ltr')) {
      $element['#attached']['library'][] = 'beautytips/beautytips-ltr';
    }

    // Add the styles info.
    $styles = beautytips_get_styles();
    $element['#attached']['drupalSettings']['beautytipStyles'] = $styles;

    // Mark as added so we don't do it again.
    $added = TRUE;
  }
}