You are here

function datex_popup_js_alter in Datex 7.2

Same name and namespace in other branches
  1. 7.3 datex_popup/datex_popup.module \datex_popup_js_alter()

Imlements hook_js_alter().

Whenever date_popup.js is loaded, Remove it and inject datex library.

File

datex_popup/datex_popup.module, line 61

Code

function datex_popup_js_alter(&$js) {
  if (!libraries_load('jquery.calendars')) {
    return;
  }
  foreach (preg_grep('#(date_popup.js)#', array_keys($js)) as $component) {
    unset($js[$component]);
  }
  static $loaded = FALSE;
  if ($loaded) {
    return;
  }
  $path = drupal_get_path('module', 'datex_popup');
  drupal_add_js("{$path}/datex_popup.js");
  drupal_add_css("{$path}/datex_popup.css");

  // @TODO Make configurable.
  $path = libraries_get_path('jquery.calendars') . '/';
  $name = 'smoothness.calendars.picker.css';
  drupal_add_css($path . $name);
  $loaded = TRUE;
}