paginagmbh / redmine_lightbox2

Lightbox for image attachments in Redmine
MIT License
126 stars 96 forks source link

Opening preview pane scrolls to top of page #18

Closed ZaLiTHkA closed 9 years ago

ZaLiTHkA commented 9 years ago

I'm running Redmine 2.6.6.stable (Bitnami VM) with plugin version 0.1.3 and my tweaked version of Tsachi Shlidor's "Theme Flat".

Each time I click the preview link for a PDF or image attachment, my window scrolls to the top of the page.. For the most part where a ticket description is short, this is not an issue, but when the description is long the user needs to scroll down again after closing the preview. If the ticket is a long running one, it becomes even more of pain to find the attachments between the long description and long list of comments/updates.

Some quick Googling revealed this SO question, which covers the same point. Even though the initial user didn't select an answer, the solution provided does indeed work for me. So to fix things on my side, I added the following rule to both the .fancybox({...}) calls in this plugin's assets/javascripts/lightbox.js file:

helpers: {
    overlay: {
        locked: false
    }
}

I'm not sure if this repo is still being maintained though, doesn't seem to be very active anymore. @paginagmbh, I've only updated this in my local copy of the plugin, but if you like I can fork/fix/PR this change for you...?

Please note: I don't have Redmine 3 running anywhere, so I'm not sure if it's still an issue there as well. But since your script file is the same in the master branch, I can only assume it affects the latest version as well.

tofi86 commented 9 years ago

Sounds like a good point. Please send a PR and I will test in Redmine 3 as well... This repo is still maintained.

tofi86 commented 9 years ago

Unfortunately I cannot reproduce your issues with redmine 2.6.8. Can you please update your redmine and test again?

This is how I tested: I have a very long issue description and a few pdf attachments. When clicking the preview link for a pdf attachment, the page stays at the current position and the iframe lightbox preview is shown in the foreground. Scrolling the background is enabled (means locked: false (!!)).

locked: false is the default behaviour. I'm not sure why setting it in the helpers is solving your issues... Applying your PR #19 to my test system doesn't change anything for me...

Which browser on which system are you using?

ZaLiTHkA commented 9 years ago

Strange.. I'll try what you suggested when I get back to work tomorrow.

There could also be something in my theme that's affecting this, I've made many changes and tweaks to the theme I'm running.. Some aren't in the repo I linked to, but they only apply to menus and the sidebar, so I don't think they're related to this in any way.

Either way, I'll see what I can find out and let you know.

tofi86 commented 9 years ago

Alright!

tofi86 commented 9 years ago

Someone else also has this as a fix in his fork: https://github.com/dreamerhyde/redmine_lightbox2/commit/ff078d2c6a5d1f07b3239e23fefa4f1365ac3858

Will considder for next release! Although I still cannot reproduce...

Looking forward to your tests and evironment details @ZaLiTHkA

ZaLiTHkA commented 9 years ago

Alright, so.. I didn't get time while I was at work today, but I fired up the backup copy of my Redmine VM this evening to check and it seems this is an issue with the JS in my theme.

If I switch themes without changing anything else, then the described issue doesn't happen. Switch back to my theme, and through the overlay it looks like the page contents are being reloaded, rather than simply scrolling to the top of the page. It happens so quickly that I barely noticed it.

I am actually overriding some of the default JS functions from Redmine core and, in doing so, I must have changed something relating to the attachment links. Sorry for all the confusion, I should've thought to check that first. (: