You are here

function _service_links_add_js in Service links 7.2

Same name and namespace in other branches
  1. 6.2 service_links.module \_service_links_add_js()

Load correctly the needed javascripts.

1 call to _service_links_add_js()
_service_links_render in ./service_links.module
The common render function used privately.

File

./service_links.module, line 643
Adds social network links to the content.

Code

function _service_links_add_js($javascript) {
  global $is_https;
  static $external_js;
  if (!is_array($javascript)) {
    $javascript = array(
      $javascript,
    );
  }
  if (!isset($external_js)) {
    $external_js = array();
  }
  foreach ($javascript as $js) {
    if (strpos($js, '://') !== FALSE) {
      if ($is_https) {

        // Ensure that we embed the https js library.
        $js = str_replace('http://', 'https://', $js);
      }
      if (!in_array($js, $external_js)) {
        drupal_add_js($js, array(
          'type' => 'external',
        ));
        $external_js[] = $js;
      }
    }
    else {
      drupal_add_js(service_links_expand_path($js, 'javascript'));
    }
  }
}