You are here

function fieldset_helper_js_alter in Fieldset helper 7.2

Implements hook_js_alter().

File

./fieldset_helper.module, line 112

Code

function fieldset_helper_js_alter(&$javascript) {
  static $altered;
  if ($altered !== TRUE && fieldset_helper_number_of_collapsible_fieldset() !== 0) {

    // Immediately set $altered to avoid recursions when using drupal_add_js().
    $altered = TRUE;

    // Make sure to add 'misc/form.js'.
    if (!isset($javascript['misc/form.js'])) {
      drupal_add_js('misc/form.js');
    }

    // Make sure to add 'misc/collapse.js'.
    if (!isset($javascript['misc/collapse.js'])) {
      drupal_add_js('misc/collapse.js');
    }

    // Add 'fieldset_helper.js'.
    $fieldset_helper_js = drupal_get_path('module', 'fieldset_helper') . '/fieldset_helper.js';
    if (!isset($javascript[$fieldset_helper_js])) {
      drupal_add_js($fieldset_helper_js);
    }

    // Add settings. (includes lookups ids and cookie duration)
    $settings['fieldset_helper_state_manager'] = array(
      'ids' => fieldset_helper_state_manager_get_lookup_id(),
      'cookie_duration' => variable_get('fieldset_helper_cookie_duration', 0),
    );
    drupal_add_js($settings, 'setting');
  }
}