r2570 - photoviewer: fix for checking rightclick, small refactoring

r2570 - photoviewer: fix for checking rightclick, small refactoring


Author: joern.zaefferer
Date: Thu May 14 02:40:36 2009
New Revision: 2570
Modified:
branches/photoviewer/ui/ui.photoviewer.js
Log:
photoviewer: fix for checking rightclick, small refactoring
Modified: branches/photoviewer/ui/ui.photoviewer.js
==============================================================================
--- branches/photoviewer/ui/ui.photoviewer.js    (original)
+++ branches/photoviewer/ui/ui.photoviewer.js    Thu May 14 02:40:36 2009
@@ -25,7 +25,7 @@
            });
            $(document).click(function(event) {
                // ignore right click
-                if (event.button == 0)
+                if (event.button != 2)
                    self.close();
            }).keydown(function(event) {
                if (!self.currentAnchor)
@@ -141,9 +141,13 @@
        _preloadNeighbours: function() {
            var anchors = this._anchors(),
                index = anchors.index(this.currentAnchor);
-            anchors.filter(":eq(" + (index == 0 ? anchors.length - 1 : index - 1)
+ "), :eq(" + (index == anchors.length - 1 ? 0 : index + 1)
+ ")").each(function() {
+            anchors.filter(this._neighbours(anchors.length, index)).each(function()
{
                new Image().src = this.href;
            });
+        },
+        
+        _neighbours: function(index, length) {
+            return ":eq(" + (index == 0 ? length - 1 : index - 1) + "), :eq(" +
(index == length - 1 ? 0 : index + 1) + ")";
        },
        
        _position: function(img) {