Work-around for uploaded images being stuck in the viewer
authorAlexander Ebert <ebert@woltlab.com>
Sun, 22 Mar 2015 10:31:37 +0000 (11:31 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 22 Mar 2015 10:31:37 +0000 (11:31 +0100)
wcfsetup/install/files/js/WCF.ImageViewer.js

index 2c485ed73d3a40fe191b5ed34e2dcf8adbba5c76..42b72a0ac8de8f4f927d9fe0b2889acf1c5be6fb 100644 (file)
@@ -558,6 +558,24 @@ $.widget('ui.wcfImageViewer', {
                        });
                        
                        var $item = this._ui.imageList.children('li:eq(' + $i + ')');
+                       
+                       // check if currently active image does not exist anymore
+                       if (this._active !== -1) {
+                               var $clear = false;
+                               if (this._active != $item.data('index')) {
+                                       $clear = true;
+                               }
+                               
+                               if (this._ui.images[this._activeImage].prop('src') != this._images[this._active].image.url) {
+                                       $clear = true;
+                               }
+                               
+                               if ($clear) {
+                                       // reset active state
+                                       this._active = -1;
+                               }
+                       }
+                       
                        $item.trigger('click');
                        this.moveToImage($item.data('index'));
                }