From cd000ad897a2c5eb59e48297cf750fcc92bd4b2c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 13 Dec 2012 21:31:24 +0100 Subject: [PATCH] Fixed image viewer Fixes #975 Fixes #976 --- wcfsetup/install/files/js/WCF.ImageViewer.js | 34 ++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.ImageViewer.js b/wcfsetup/install/files/js/WCF.ImageViewer.js index 3b25476e90..962c59f445 100644 --- a/wcfsetup/install/files/js/WCF.ImageViewer.js +++ b/wcfsetup/install/files/js/WCF.ImageViewer.js @@ -11,12 +11,7 @@ WCF.ImageViewer = Class.extend({ * Initializes the ImageViewer for every a-tag with the attribute rel = imageviewer. */ init: function() { - WCF.DOMNodeInsertedHandler.addCallback('WCF.ImageViewer', $.proxy(this._initImageSizeCheck, this)); - - $('a[rel^=imageviewer]').slimbox({ - counterText: WCF.Language.get('wcf.imageViewer.counter'), - loop: true - }); + WCF.DOMNodeInsertedHandler.addCallback('WCF.ImageViewer', $.proxy(this._domNodeInserted, this)); WCF.DOMNodeInsertedHandler.enable(); @@ -32,6 +27,33 @@ WCF.ImageViewer = Class.extend({ // handle enlarge button $buttonEnlarge.click($.proxy(this._enlarge, this)); + + this._initImageViewer(); + }, + + /** + * Executes actions upon DOMNodeInserted events. + */ + _domNodeInserted: function() { + this._initImageSizeCheck(); + this._initImageViewer(); + }, + + /** + * Initializes the image viewer for all links with class ".jsImageViewer" + */ + _initImageViewer: function() { + WCF.DOMNodeInsertedHandler.enable(); + + $('a.jsImageViewer').each(function(index, link) { + var $link = $(link).removeClass('jsImageViewer'); + $link.slimbox({ + counterText: WCF.Language.get('wcf.imageViewer.counter'), + loop: true + }); + }); + + WCF.DOMNodeInsertedHandler.disable(); }, /** -- 2.20.1