Touch Gallery takes two clicks to close

Permalink Browser Info Environment
Hello, I have used your Touch Gallery umpteen times with no problems, however recently I have been using the latest version of Mega Menu and I have noticed that when I set it to use the Hamburger setting it disturbs my Touch Gallery block (which always normally works perfectly). Basically you have to click the X twice to get the image to close. It seems to be loading twice. You can see an example here:

https://www.dunheanish.com/accommodation/...

I am assuming it is a javascript conflict, but I have no idea how to attempt to fix it! I contacted the developer of Mega Menu and he took a look but suggested I go to you to ask if you had any ideas. Here is what he wrote:

"That's a very odd bug, and I think you're right that there's a JS clash somewhere. I deliberately design my add-ons to be as robust as possible, trying to avoid JS clashes with other add-ons and themes.

Because of the sheer complexity of the Mega Menu add-on, it would be simpler and quicker to tackle this from the Touch Gallery end. I've looked at the JS code on your site:
https://www.dunheanish.com/packages/touch_gallery/js/touch-gallery.m...
And the "close" functions don't seem to stand out as clashing to me (same names), and the HTML element IDs aren't clashing either. If you were able to get hold of a non-minified version of Touch Gallery's JS code then it would be easier to troubleshoot. Naturally, if the developer for that add-on wouldn't give that up (which I'd understand) then he might be able to troubleshoot it from his end."

I hope you can shed some light on this as I use both these add ons very frequently. I did notice that you are updating the gallery versions for Concrete 5.7 but I rarely use that version as I really don't like it!

Thanks in advance

Lucy

Type: Ticket
Status: Archived
ppisoban
View Replies:
mnakalay replied on at Permalink Reply
mnakalay
Hello,

no problem I'll have a look and will let you know shortly. Thank you for bringing this up to my attention and for your continuous support. You are by far my most frequent Touch Gallery user :-)
mnakalay replied on at Permalink Reply
mnakalay
OK I figured it out. It's due to a weird behaviour of jQuery which is triggered by mega menu.

Here's the explanation so you can tell mega menu's developer.

When Touch Gallery is loaded, first in PHP it creates the thumbnails grid and right below that it inserts a bit of javascript which calls the gallery script to instantiate the gallery.

When the gallery is instantiated, it appends at the end of the body the elements of the lightbox's overlay including the 2 arrows and the close button so they are ready when needed. That's the DIV with class galleryOverlay at the bottom

Then mega menu has a bit of code, inserted directly in the page's markup: $("body").wrapInner('<div id="panel"></div>');

And that is what is creating the problem.

You see, when using wrapInner() on the body like that, it also wraps any javascript inside the body and triggers it again.

So when using wrapInner, Touch Gallery is actually instantiated a second time and we now have a second overlay with exactly the same ID which is not allowed.

If you check your page source in your browser's developer tools, you will find twice the DIV with class galleryOverlay, once at the end of the DIV with ID panel (the one wrapped around everything by mega menu) and one just before the closing BODY tag.

The one inside DIV#panel is the first one created and the other one is the one created when touch gallery was triggered a second time.

If you want to test that, using your browser's developer tool, simply delete the one inside DIV#panel and you will see the gallery will work normally.

There is a possible solution on this page:https://stackoverflow.com/questions/10640620/jquery-wrapinner-trigge...

I am not sure how viable it is though but I'm sure mega menu's dev can figure it out, he knows what he's doing
mnakalay replied on at Permalink Reply
mnakalay
As an aside, can I ask you what you don't like about the 5.7 version?
mnakalay replied on at Permalink Reply
mnakalay
Did you get my answer?
ppisoban replied on at Permalink Reply
ppisoban
Sorry yes! I wrote a message "Thanks so much for your quick response! I have messaged the developer of Mega Menu so hopefully this will all get sorted soon."

And then I started to tell you why I can't get on with Concrete 5.7 but it was such a massive task that I didn't actually post my reply! If I get a chance I'll put it into a separate reply...

Thanks again!
mnakalay replied on at Permalink Reply
mnakalay
oh, don't worry about it. Initially, I thought you said you didn't like Touch gallery for 5.7 :)

So I'm (kind of) glad to hear Touch Gallery is not the issue.

Let me know if there's anything else I can do to help with.
ppisoban replied on at Permalink Reply
ppisoban
Oh sorry for the misunderstanding! I haven't actually used Touch Gallery for Concrete 5.7 as I've only built 2 sites with it and both clients wanted masonry galleries so I used one called ES Galleries. Out of interest do you have any plans for a masonry gallery? I like them!
mnakalay replied on at Permalink Reply
mnakalay
I have to say I have mixed feelings about Masonry Galleries, for several reasons.

First, I find them t be clunky as soon as the screen is resized. Also, it is very hard to find a masonry script that works well but doesn't weight 60ko.

I tried as much as possible to keep Touch Gallery as small and fast as possible so masonry scripts never seemed to fit.

Another problem is I'd have to add several settings just to deal with that...

I have to admit I was asked about it several times and considered it. I think if I ever add it, it will be as a template, not as an option from the settings.

I have had plans to make an advanced version for Touch Gallery for a very long time to include more design possibilities, Masonry layouts, flexible sizing, pagination... all the bells and whistles. But it always seemed that most people just wanted something simple with just the right options for their use case and nobody would really want all the stuff at once.

It's still somewhere on my "future plans" shelf but probably far far future
ConcreteCMS replied on at Permalink Reply
ConcreteCMS
Attention: Since there has been no activity on this issue for two weeks, this issue has been automatically archived.

To re-open this issue, reply to this message.

concrete5 Environment Information

# concrete5 Version
5.6.3.5

# concrete5 Packages
Mega Menu (1.6.0), Touch Gallery (1.7.2), Whale Nivo Image Slider (1.2).

# concrete5 Overrides
themes/headsnook

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - On
Full Page Caching - Off

# Server Software
LiteSpeed

# Server API
litespeed

# PHP Version
5.6.33

# PHP Extensions
bcmath, bz2, calendar, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imap, intl, ionCube Loader, json, libxml, litespeed, mbstring, mcrypt, memcache, mhash, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, posix, pspell, readline, Reflection, session, shmop, SimpleXML, soap, sockets, SourceGuardian, SPL, sqlite3, standard, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, Zend Guard Loader, Zend OPcache, zip, zlib.

# PHP Settings
max_execution_time - 60
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 120
max_input_vars - 5000
memory_limit - 128M
post_max_size - 100M
sql.safe_mode - Off
upload_max_filesize - 100M
memcache.max_failover_attempts - 20
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
session.cache_limiter - nocache
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
opcache.max_accelerated_files - 7963
opcache.max_file_size - 0
opcache.max_wasted_percentage - 5
zend_optimizerplus.max_accelerated_files - 2000
zend_optimizerplus.max_file_size - 0
zend_optimizerplus.max_wasted_percentage - 5

Browser User-Agent String

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.