You are here

function flot_add_js in Flot 6

Same name and namespace in other branches
  1. 7 flot.module \flot_add_js()

Helper to add flot's js

1 call to flot_add_js()
theme_flot_graph in ./flot.module
Main flot graphing function

File

./flot.module, line 86

Code

function flot_add_js() {
  static $added;
  if ($added !== true) {
    if (module_exists('libraries') && libraries_get_path('flot')) {
      $path = libraries_get_path('flot');
    }
    if (!isset($path)) {
      $path = drupal_get_path('module', 'flot') . '/flot';
    }

    // Different versions of flot have used different packing methods. Attempt to support both.
    $excanvas = file_exists("{$path}/excanvas.min.js") ? "{$path}/excanvas.min.js" : "{$path}/excanvas.pack.js";
    drupal_set_html_head('<!--[if IE]><script language="javascript" type="text/javascript" src="' . base_path() . $excanvas . '"></script><![endif]-->');
    drupal_add_js($path . '/jquery.flot.js');
    drupal_add_js('if (Drupal.jsEnabled) { Drupal.flot = {}; }', 'inline');
    $added = true;
  }
}