You are here

function fancybox_activate in fancyBox 6

Same name and namespace in other branches
  1. 7 fancybox.module \fancybox_activate()

Include the Fancybox JS.

1 call to fancybox_activate()
fancybox_init in ./fancybox.module
Implementation of hook_init().

File

./fancybox.module, line 32
Provides the Fancybox jQuery plugin for displaying images, HTML content and multimedia in an elegant box.

Code

function fancybox_activate($settings = NULL) {
  static $active = FALSE;
  if (!$active) {
    if ($settings == NULL) {
      $settings = variable_get('fancybox_settings', array());
    }

    // Add Fancybox files.
    $path = variable_get('fancybox_path', FANCYBOX_DEFAULT_PATH) . '/';
    $files = variable_get('fancybox_files', array());

    // TODO: add easing

    //drupal_add_js($path .'jquery.easing-1.3.pack.js');
    drupal_add_css($path . $files['css']);
    drupal_add_js($path . $files['js']);

    // Expose settings to the DOM.
    $exposed_settings['options'] = $settings['options'];
    $exposed_settings['selector'] = $settings['activation']['selector'];
    drupal_add_js(array(
      'fancybox' => $exposed_settings,
    ), 'setting');

    // Initialize Fancybox.
    drupal_add_js(drupal_get_path('module', 'fancybox') . '/js/fancybox.js');
    $active = TRUE;
  }
}