You are here

function flot_add_js in Flot 7

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

Helper to add flot's js

1 call to flot_add_js()
template_preprocess_flot_graph in ./flot.module

File

./flot.module, line 256

Code

function flot_add_js($type = 'core') {
  drupal_add_js(drupal_get_path('module', 'flot') . '/flot.utils.js');
  static $added = array();
  $path = _flot_get_library_path();
  if (!isset($added['core']) && ($type = 'core')) {
    $forie = array(
      '#type' => 'markup',
      '#markup' => '<!--[if IE]><script language="javascript" type="text/javascript" src="' . base_path() . $path . '/excanvas.js"></script><![endif]-->',
    );
    drupal_add_html_head($forie, 'flot');
    drupal_add_js($path . '/jquery.flot.js');
    drupal_add_js('Drupal.flot = {};', 'inline');
    drupal_add_css(drupal_get_path('module', 'flot') . '/flot.legend.css');
    $added['core'] = TRUE;
  }
  if (!isset($added['stack']) && $type == 'stack') {
    drupal_add_js($path . '/jquery.flot.stack.js');
    $added['stack'] = TRUE;
  }
  if (!isset($added['pie']) && $type == 'pie') {
    drupal_add_js($path . '/jquery.flot.pie.js');
    drupal_add_css(drupal_get_path('module', 'flot') . '/flot.pie.css');
    $added['pie'] = TRUE;
  }
  if (!isset($added['selection']) && $type == 'selection') {
    drupal_add_js($path . '/jquery.flot.selection.js');
    $added['selection'] = TRUE;
  }
  if (!isset($added['orderBars']) && $type == 'orderBars') {
    drupal_add_js(drupal_get_path('module', 'flot') . '/js/jquery.flot.orderBars.js');
    $added['orderBars'] = TRUE;
  }
}