popups: 6.x-1.1-beta4
lightbox2: 6.x-1.x-dev
scenario: i use lightbox2 to display custom content type album witch multipile imagefield values, and popups to display node album. popups works fine, but the display of navigation arrows and close buttons in lightbox is uncorrect, see the attachment for detail screenshot. i'll post this bug report crossing both of the two modules.

CommentFileSizeAuthor
#9 lightbox2-302262-9.patch1 KBAnonymous (not verified)
2008-08-31_212304.jpg49.52 KBwilson98

Comments

stella’s picture

Status: Active » Postponed (maintainer needs more info)

Can you provide more information on the setup so I can try to reproduce it on my site? Or could you send me a link to your site? My contact form is enabled if you wish to do so privately.

Cheers,
Stella

wilson98’s picture

here's the detail.
drupal:6.4
modules: CCK-6.x-2.0-rc6, Imagefield-6.x-3.0-alpha, Imagecache-6.x-1.0alpha, Lightbox2-6.x-1.x-dev, Popups-1.1-beta2, and any dependency modules.

1. enable all modules;
2. edit content type 'story', add an image field;
3. add an imagecache preset 'thumb', add an action for example 'scale';
4. back to 'content types'->'edit story'->'display fields', set the image field to be "Lightbox2: thumb->original";
5. add an story node, test whether the lightbox2 works.
6. suggest current theme is garland. open template.php, add this function:

function phptemplate_preprocess_node(&$vars) {
popups_add_popups();
}

7. open node.tpl.php,
replace
if ($page == 0):

print $node_url " title=" print $title "> print $title

endif;

with
if ($page == 0):

print $node_url " title=" print $title " class='popups'> print $title

endif;

8. clear the cache. back to the home page. click the story title, popup the story node, click the images in the node, popup lightbox2.

ncy’s picture

just a shot in the dark, the double close-button reminds me of this:

http://drupal.org/node/295805

and:

http://drupal.org/node/235562

also:

http://drupal.org/node/242086

jQuery conflict?

Anonymous’s picture

Title: lightbox2 conflict with popups » Multiple close buttons

I have seen something similar. Multiple close and navigation buttons when using Lightbox on views. Additionally, the "loading" animation remains visible on top of the image.
The problem happens when visiting all but the first page of a view that spans multiple pages (showing a pager at the bottom).
I was able to work around the issue by selecting the "Disable javascript with Views" in the views module.

It must be a conflict where the javascript code of lightbox.js gets executed twice (or more) causing duplicate elements in the DOM tree:

<div id="bottomNav">
  <a id="bottomNavClose" href="#" style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);"/>
  <a id="bottomNavZoom" href="#"/>
  <a id="bottomNavZoomOut" href="#"/>
  <a id="lightshowPause" style="display: none;" href="#"/>
  <a id="lightshowPlay" style="display: none;" href="#"/>
  <a id="bottomNavClose" href="#"/>
  <a id="bottomNavZoom" href="#"/>
  <a id="bottomNavZoomOut" href="#"/>
  <a id="lightshowPause" style="display: none;" href="#"/>
  <a id="lightshowPlay" style="display: none;" href="#"/>
</div>

PS: I'm changing the issue title because it does not only occur in combination with popups.

stella’s picture

Status: Postponed (maintainer needs more info) » Active

I think this is a different issue and is a duplicate of #276985: Constant animation in I.E 7 and broken image and is caused by the nice menus module. If you don't have nice menus installed, then it's probably because jquery.js is being loaded twice on the same page, either by another module or your theme.

Anonymous’s picture

I'm not using the 'nice menus' module. It must be the views module causing the trouble. I hope to have some time tomorrow to dig a little deeper.
Hopefully we can make the javascript robust enough so that other modules/themes can't break it no matter how often jquery.js gets loaded.

stella’s picture

litrik: I doubt this is an issue with the views module. Can you provide a link to your site perhaps? Can you double-check your theme to ensure it's not printing $scripts twice? Also if using rel="lightmodal", please ensure that the content you are opening in the lightbox window does not contain html, body or header tags - if they are, please use rel="lightframe" instead.

Cheers,
Stella

Anonymous’s picture

I doubt this is an issue with the views module.

The actual issue is not probably in the views module. But I'm sure there is something in the views module (and the popups module) that triggers the issue in the Lightbox2 module.

Can you provide a link to your site perhaps?

That is not going to help because it's a customer site that wen tlive this weekend. I worked around the issue by disabling javasscript support in the views module (as mentioned in #302262-4)

Can you double-check your theme to ensure it's not printing $scripts twice? Also if using rel="lightmodal", please ensure that the content you are opening in the lightbox window does not contain html, body or header tags - if they are, please use rel="lightframe" instead.

My theme (a Zen sub theme) is printing $scripts only once and I'm not using rel="lightmodal".

In the meantime I was able to dig a little deeper and I think I have found the real cause:

lightbox.js contains

Drupal.behaviors.initLightbox = function (context) {
  Lightbox.initialize();
  $('#lightboxAutoModal').triggerHandler('click');
};

The initialize() method contains a lot of calls to append() to add the UI to the current DOM.

If I understand the Drupal.behaviors documentation correctly the code will get executed again whenever an AJAX call is executed. Since the lightbox code doesn't do anything with the context parameter the initialize function executes the exact same code even though only a part of the DOM was modified. This results in duplicate elements (close button, navigation buttons, 'loading' animation,...) in the DOM.

When I add a simple alert(context) to the initLightbox() function I see that the first call to initLightbox() passes a HTMLDocument. After clicking on the pager of a AJAX-ified view there is a second call with an HTMLDivElement as parameter.

I'll see if I can come up with a patch that avoids unnecesssary calls to Lightbox.initialize(). (It might be as simple as adding an if surrounding the Lightbox.initialize())

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new1 KB

Stella, here is a patch that fixes the duplicate DOM elements when the lightbox2 module is used on pages that use AJAX.
I have moved the call to initList() out of initialize(). Initialize is only called when the full document is loaded. initList() is always called().

This patch fixes my problems in combination with AJAX-ified views. I can't verify whether it fixes the conflict with the popups module.

pwhite’s picture

Just on a side note I had exactly the same problem and it was caused by including js files in the theme for some other functionality I needed:

drupal_add_js('misc/jquery.js', 'core', 'header');
print drupal_get_js(); 
stella’s picture

Status: Needs review » Fixed

This has been fixed in the latest dev release of the module, available later today. Thanks.

Cheers,
Stella

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

stella’s picture

Released in Lightbox2 6.x-1.9.

Cheers,
Stella