#242666 - modified javascript so the larger image is displayed in the lightbox
authorStella Power
Tue, 8 Apr 2008 14:24:50 +0000 (14:24 +0000)
committerStella Power
Tue, 8 Apr 2008 14:24:50 +0000 (14:24 +0000)
instead of the thumbnail for gallery2 images.

js/image_nodes.js
js/lightbox2.js

index eb7a427..2c2cc11 100644 (file)
@@ -79,6 +79,17 @@ if (Drupal.jsEnabled) {
               href = orig_href;
             }
 
+            // Handle gallery2 block images.
+            else if ($(child).attr("class").match("ImageFrame_image")) {
+              var thumb_id = parse_url(href, "g2_itemId");
+              var new_id = parse_url(orig_href, "g2_itemId");
+                                                                                                               if (new_id && thumb_id) {
+                                                                                                                               var pattern = new RegExp("g2_itemId="+thumb_id);
+                                                                                                                               var replacement = "g2_itemId="+ new_id;
+                                                                                                                               var href = href.replace(pattern, replacement);
+                                                                                                               }
+            }
+
 
             // Set the href attribute.
             else if (settings.image_node_sizes != '()') {
@@ -104,4 +115,18 @@ if (Drupal.jsEnabled) {
 
     }
   });
+
+  function parse_url(url, param) {
+    param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
+    url = url.replace(/&/, "&");
+    var regexS = "[\\?&]"+param+"=([^&#]*)";
+    var regex = new RegExp(regexS);
+    var results = regex.exec(url);
+    if (results == null) {
+      return "";
+    }
+    else {
+      return results[1];
+    }
+  }
 }
index 855c7ed..c5c8d1e 100644 (file)
@@ -11,6 +11,7 @@ if (Drupal.jsEnabled) {
     $("input[@name=lightbox2_use_alt_layout]").bind("click", alt_layout_handler);
     $("input[@name=lightbox2_image_node]").bind("click", image_node_handler);
     $("input[@name=lightbox2_flickr]").bind("click", image_node_handler);
+    $("input[@name=lightbox2_gallery2_blocks]").bind("click", image_node_handler);
     $("input[@name=lightbox2_image_assist_custom]").bind("click", image_node_handler);
     $("input[@name=lightbox2_inline]").bind("click", image_node_handler);
     $("textarea[@name=lightbox2_custom_trigger_classes]").bind("change", image_node_handler);
@@ -52,6 +53,7 @@ function lightbox2_lite_auto_handler(event) {
     $("select[@name=lightbox2_display_image_size]").attr("disabled", "disabled");
     $("select[@name='lightbox2_trigger_image_size[]']").attr("disabled", "disabled");
     $("input[@name=lightbox2_flickr]").attr("disabled", "disabled");
+    $("input[@name=lightbox2_gallery2_blocks]").attr("disabled", "disabled");
     $("input[@name=lightbox2_image_assist_custom]").attr("disabled", "disabled");
     $("input[@name=lightbox2_inline]").attr("disabled", "disabled");
     $("textarea[@name=lightbox2_custom_trigger_classes]").attr("disabled", "disabled");
@@ -61,6 +63,7 @@ function lightbox2_lite_auto_handler(event) {
   else {
     $("input[@name=lightbox2_image_node]").removeAttr("disabled");
     $("input[@name=lightbox2_flickr]").removeAttr("disabled");
+    $("input[@name=lightbox2_gallery2_blocks]").removeAttr("disabled");
     $("input[@name=lightbox2_image_assist_custom]").removeAttr("disabled");
     $("input[@name=lightbox2_inline]").removeAttr("disabled");
     $("textarea[@name=lightbox2_custom_trigger_classes]").removeAttr("disabled");
@@ -88,10 +91,11 @@ function alt_layout_handler(event) {
 }
 
 function image_node_handler(event) {
-  // Image node, flickr, inline and custom images stuff.
+  // Image node, flickr, gallery2, inline and custom images stuff.
   if ($("input[@name=lightbox2_lite]").val() != 1) {
     if ($("input[@name=lightbox2_image_node]:checked").val() == 1
       || $("input[@name=lightbox2_flickr]:checked").val() == 1
+      || $("input[@name=lightbox2_gallery2_blocks]:checked").val() == 1
       || $("input[@name=lightbox2_image_assist_custom]:checked").val() == 1
       || $("input[@name=lightbox2_inline]:checked").val() == 1
       || $("textarea[@name=lightbox2_custom_trigger_classes]").val() != ''