You are here

function qtip_js_alter in qTip (Stylish jQuery Tooltips) 7.2

Implements hook_js_alter().

File

./qtip.module, line 222

Code

function qtip_js_alter(&$javascript) {
  if (!module_exists('jquery_update')) {

    // We set the minimum jQuery version required for qTip because 1.4.4 that ships with Drupal core is not compatible
    switch (variable_get('qtip_jquery_cdn', 'google')) {
      case 'microsoft':
        $jquery_path = 'https://ajax.aspnetcdn.com/ajax/jquery/jquery-' . variable_get('qtip_jquery_version', QTIP_MINIMUM_JQUERY_VERSION) . '.min.js';
        break;
      case 'google':
      default:
        $jquery_path = 'https://ajax.googleapis.com/ajax/libs/jquery/' . variable_get('qtip_jquery_version', QTIP_MINIMUM_JQUERY_VERSION) . '/jquery.min.js';
    }

    // We duplicate the important information from Drupal core
    $javascript[$jquery_path] = $javascript['misc/jquery.js'];

    // then update the necessary information
    $javascript[$jquery_path]['version'] = variable_get('qtip_jquery_version', QTIP_MINIMUM_JQUERY_VERSION);
    $javascript[$jquery_path]['data'] = $jquery_path;

    // Finally, remove the Drupal core version
    unset($javascript['misc/jquery.js']);
  }
}