Fixed image viewer
authorAlexander Ebert <ebert@woltlab.com>
Thu, 13 Dec 2012 20:31:24 +0000 (21:31 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 13 Dec 2012 20:31:24 +0000 (21:31 +0100)
Fixes #975
Fixes #976

wcfsetup/install/files/js/WCF.ImageViewer.js

index 3b25476e905315c07f788702288c69123dc76e6f..962c59f445cdc694d73bf717599fbaf983ddc715 100644 (file)
@@ -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();
        },
        
        /**