diff --git a/app/assets/javascripts/discourse/components/lightbox.js b/app/assets/javascripts/discourse/components/lightbox.js index fb128c53d04..cbd406d63c1 100644 --- a/app/assets/javascripts/discourse/components/lightbox.js +++ b/app/assets/javascripts/discourse/components/lightbox.js @@ -8,12 +8,9 @@ Discourse.Lightbox = { apply: function($elem) { var _this = this; - $('a.lightbox', $elem).each(function(i, e) { - $LAB.script("/javascripts/jquery.magnific-popup-min.js").wait(function() { - $(e).magnificPopup({ - type: 'image', - closeOnContentClick: true - }); + $LAB.script("/javascripts/jquery.magnific-popup-min.js").wait(function() { + $('a.lightbox', $elem).each(function(i, e) { + $(e).magnificPopup({ type: 'image', closeOnContentClick: true }); }); }); } diff --git a/app/assets/javascripts/discourse/routes/discourse_route.js b/app/assets/javascripts/discourse/routes/discourse_route.js index 55043edf6f6..efcb970de3c 100644 --- a/app/assets/javascripts/discourse/routes/discourse_route.js +++ b/app/assets/javascripts/discourse/routes/discourse_route.js @@ -23,6 +23,8 @@ Discourse.Route = Em.Route.extend({ $('.d-dropdown').hide(); $('header ul.icons li').removeClass('active'); $('[data-toggle="dropdown"]').parent().removeClass('open'); + // close the lightbox + if ($.magnificPopup && $.magnificPopup.instance) { $.magnificPopup.instance.close(); } Discourse.set('notifyCount',0);