? fancybox-743010.patch
Index: fancybox.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fancybox/Attic/fancybox.module,v
retrieving revision 1.1.4.2
diff -u -p -r1.1.4.2 fancybox.module
--- fancybox.module	14 Mar 2010 10:52:37 -0000	1.1.4.2
+++ fancybox.module	15 Mar 2010 17:00:33 -0000
@@ -21,30 +21,11 @@ define('FANCYBOX_DEFAULT_PATH', 'sites/a
  * Implementation of hook_init().
  */
 function fancybox_init() {
-
   $settings = variable_get('fancybox_settings', array());
 
   if (!empty($settings) && fancybox_active($settings)) {
-    // 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.
-    $module_path = drupal_get_path('module', 'fancybox');
-    drupal_add_js($module_path .'/js/fancybox.js');
+    fancybox_activate($settings);
   }
-  
 }
 
 /**
@@ -135,6 +116,40 @@ function fancybox_active($settings) {
 }
 
 /**
+ * Include the Fancybox JS.
+ */
+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.
+    $module_path = drupal_get_path('module', 'fancybox');
+    drupal_add_js($module_path .'/js/fancybox.js');
+    
+    $active = TRUE;
+  }
+}
+
+/**
  * Define form elements for the Fancybox plugin's options.
  */
 function fancybox_options($values = array()) {
