You are here

function _hierarchical_select_setup_js in Hierarchical Select 5.3

Same name and namespace in other branches
  1. 6.3 hierarchical_select.module \_hierarchical_select_setup_js()

Helper function to add the required Javascript files and settings.

1 call to _hierarchical_select_setup_js()
hierarchical_select_process in ./hierarchical_select.module
Hierarchical select form element type #process callback.

File

./hierarchical_select.module, line 1235
This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.

Code

function _hierarchical_select_setup_js() {
  static $ran_once;
  $jquery_ui_components = array(
    'effects.core',
    'effects.drop',
  );
  if (!$ran_once) {
    $ran_once = TRUE;
    $url = base_path();
    $url .= variable_get('clean_url', 0) ? '' : 'index.php?q=';
    $url .= 'hierarchical_select_json';

    // Add the CSS and JS, set the URL that should be used by all hierarchical
    // selects.
    drupal_add_css(drupal_get_path('module', 'hierarchical_select') . '/hierarchical_select.css');
    drupal_add_js(drupal_get_path('module', 'hierarchical_select') . '/hierarchical_select.js');
    if (variable_get('hierarchical_select_js_cache_system', 0) == 1) {
      drupal_add_js(drupal_get_path('module', 'hierarchical_select') . '/hierarchical_select_cache.js');
    }
    if (!module_exists('jquery_form')) {
      drupal_add_js(drupal_get_path('module', 'hierarchical_select') . '/hierarchical_select_formtoarray.js');
    }
    else {
      jquery_form_add();
    }
    if (!module_exists('jquery_ui')) {
      foreach ($jquery_ui_components as $component) {
        drupal_add_js(drupal_get_path('module', 'hierarchical_select') . "/js/jquery.ui/{$component}.js");
      }
    }
    else {
      jquery_ui_add($jquery_ui_components);
    }
    drupal_add_js(array(
      'HierarchicalSelect' => array(
        'url' => $url,
        'getArguments' => drupal_query_string_encode($_GET, array(
          'q',
        )),
      ),
    ), 'setting');
  }
}