You are here

function swftools_swfobject2_add_js in SWF Tools 6.3

Places swfobject JavaScript on the page, either using the local code, or from Google APIs.

2 calls to swftools_swfobject2_add_js()
swftools_swfobject2_init in swfobject2/swftools_swfobject2.module
Implementation of hook_init().
theme_swftools_swfobject2 in swfobject2/swftools_swfobject2.module
Turns an SWF Tools data array in to markup and JavaScript for inclusion on the page.

File

swfobject2/swftools_swfobject2.module, line 29
Enables SWF Tools support for swfObject 2 JavaScript flash embedding.

Code

function swftools_swfobject2_add_js() {

  // Set flag to indicate if the JavaScript has been added to the header
  static $swfobject2_has_run;

  // Output JavaScript to the header to load the SWF Object code
  if (!$swfobject2_has_run) {

    // Find out if swfobject2 is available locally and add script accordingly
    if (swftools_swfobject2_available_locally()) {

      // Add the local script library when it is present
      drupal_add_js(swftools_get_library('swfobject') . '/swfobject.js');
    }
    else {

      // We have to add script directly to the head as drupal_add_js can't handle external scripts (drupal.org/node/91250)
      drupal_set_html_head('<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>');
    }

    // Set flag to show script is in place
    $swfobject2_has_run = TRUE;
  }
}