I’m setting up a photo gallery (powered by Galleria).
I would like to link an image to a URL and also have the option to ‘Save As’ that same image using the right click on a mouse.
When I right click with the standard set up for Galleria I get the standard right click menu options pop up but I’m also taken to my URL (before I have time to save the image).
Is there a way to differentiate between a right click and a left click in jQuery so I can, for example, specify that the right click shouldn’t action the hyperlink?
There isn’t really an easy way (as far as I can tell).
You designated a “longdesc” attribute for each image. That’s how Galleria knows where to link the bigger versions of the images.
Unfortunately, Galleria doesn’t simply insert each <img> in an <a> element ([sarcasm]that would be silly[/sarcasm]). Nor does it wait for a normal “click” event (which, if I remember right, is only fired by left-click). It sends you to the “longdesc” location on mouseup.
Even worse, the function that actually decides whether or not to do this isn’t in a normal event listener, so it doesn’t have access to the “e” object, so you can’t just do something as simple as check e.which!
There are workarounds, but they get exponentially more complicated and infuriating the deeper into it you go…
Edit
In retrospect, this post probably isn’t that much help. To OP, or anyone else interested in pursuing this: The madness begins at about line 3,750 of galleria-1.2.6.js; that’s where it decides whether or not to open the link.
I really appreciate your taking the time to try and help (and for writing a witty reply).
I found myself trying to take in the lines around #3750 - but experience was telling I would not make a breakthrough.
I’m reassured that, at least sometimes, I know my limits.