hibbitts-design / grav-theme-quark-open-publishing

A customized version of the Quark theme with Git Sync and 'chromeless' mode support.
http://demo.hibbittsdesign.org/grav-open-publishing-quark/
MIT License
21 stars 13 forks source link

js/my.js conflicts with grav-plugin-shortcode-gallery-plusplus plugin #41

Closed sal0max closed 3 years ago

sal0max commented 3 years ago

Hi,

I got this issue opened for my Shortcode Gallery++ Plugin: https://github.com/sal0max/grav-plugin-shortcode-gallery-plusplus/issues/6

The lightbox doesn't work properly, as the js/my.js script in Quark Open Publishing intercepts the click on an image and opens it in a blank page. A possible workaround that could be done on your side is described in the linked issue. All links that should open with the GLightbox I'm using have a class glightbox-<random number>.

Maybe you want to have a look at it.

Cheers!

paulhibbitts commented 3 years ago

Thanks for letting me know about this @sal0max , I will add a comment to your issue.

paulhibbitts commented 3 years ago

Looks like this issue was solved by disabling the my.js script, so closing this for now.

sal0max commented 3 years ago

Yeah, it's solved for this case.

However, everyone who is using the Open Publishing theme and also the Shortcode Gallery++ plugin will run into the same issue.

How about that change I proposed in the other issue for js/my.js line 8? I tested it, it works:

$('#body-wrapper').on('click', 'a:not(.external-link):not([href^="#"]), a:not([class^="glightbox"])'), function (e) {

instead of just

$('#body-wrapper').on('click', 'a:not(.external-link):not([href^="#"])', function (e) {
paulhibbitts commented 3 years ago

Oh thanks for testing that possible fix, let me also verify on my end. If everything looks good I will release an update and give you credit for the fix🙂

paulhibbitts commented 3 years ago

Hi @sal0max , today I released an update with that fix for the Shortcode Gallery++ plugin but it caused unexpected issues on my online demo site (see below) home page, though my local test site was fine.

2021-02-15_09-56-47

To be safe I have removed this fix as it looks like further testing is needed. If you happen to know what the issue might be please let me know (I do not know JS and someone on the Grav Discord helped me with that JS you see in the theme).

Thanks, Paul

sal0max commented 3 years ago

That baffles me a bit, as I don't see where the change could break the site.

Let's analyze your original js code:

$('#body-wrapper').on('click', 'a:not(.external-link):not([href^="#"])', function (e) {

My proposed modification just adds another selector filter: a:not([class^="glightbox"]):

But to be sure, I just installed a blank Grav instance, added the Quark Open Publishing theme, added your example pages and tried my modification

I couldn't see anything being broken. You're sure you didn't ran into some caching issue, or had a typo in there?

    $('#body-wrapper').on('click', 'a:not(.external-link, [href^="#"], [class^="glightbox"])', function (e) {

(This is also the correct syntax, according to https://stackoverflow.com/a/6166888/421140)

paulhibbitts commented 3 years ago

Thanks so much @sal0max for looking into what might have been causing the issue - your revised code looks to be working now🙂 https://demo.hibbittsdesign.org/grav-open-publishing-quark/

The homepage now displays correctly, and I manually updated that site's my.js file with your most recent code.

I will now update the theme and re-release🤞

Thanks again! Paul

paulhibbitts commented 3 years ago

Great news @sal0max the release looks good and I have tested it on https://demo.hibbittsdesign.org/grav-open-publishing-quark/ and all is working.

Thanks again for your revised code suggestion! Paul