From 6be987bbf8b60fbffbaf5606c216490f197cdeb9 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Wed, 8 Dec 2010 15:02:51 +0100 Subject: [PATCH] More protection against re-loading current view. Fixes double click issues (Bug #9436). --- kronolith/js/kronolith.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index fe74cb986..4925c0b78 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -41,8 +41,31 @@ KronolithCore = { search: 'future', effectDur: 0.4, macos: navigator.appVersion.indexOf('Mac') != -1, + + /** + * The location that was open before the current location. + * + * @var string + */ lastLocation: '', + + /** + * The currently open location. + * + * @var string + */ + openLocation: '', + + /** + * The current (main) location. + * + * This is different from openLocation as it isn't updated for any + * locations that are opened in a popup view, e.g. events. + * + * @var string + */ currentLocation: '', + kronolithBody: $('kronolithBody'), doActionOpts: { @@ -299,6 +322,10 @@ KronolithCore = { return; } + if (this.openLocation == fullloc) { + return; + } + this.viewLoading.push([ fullloc, data ]); switch (loc) { @@ -488,6 +515,11 @@ KronolithCore = { return; } + if (this.currentLocation == fullloc) { + this.loadNextView(); + return; + } + this.addHistory(fullloc, false); switch (locParts.length) { case 0: @@ -3800,6 +3832,17 @@ KronolithCore = { return event.value.sort; }, + /** + * Adds a new location to the history and displays it in the URL hash. + * + * This is not really a history, because only the current and the last + * location are stored. + * + * @param string loc The location to save. + * @param boolean save Whether to actually save the location. This should + * be false for any location that are displayed on top + * of another location, i.e. in a popup view. + */ addHistory: function(loc, save) { location.hash = encodeURIComponent(loc); @@ -3807,6 +3850,7 @@ KronolithCore = { if (Object.isUndefined(save) || save) { this.currentLocation = loc; } + this.openLocation = loc; }, /** -- 2.11.0