summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Mathiesen <marius@shortcut.no>2009-12-03 14:18:25 +0100
committerMarius Mathiesen <marius@shortcut.no>2009-12-03 14:18:59 +0100
commiteca9da8b2a50e9233bc9be5c10db6aa47ed7b15b (patch)
tree906c4ae064698f03800dd1f217d5b315f3a37383
parent8927ba8a0f72eb57d5e5264200d22f93f6618a81 (diff)
downloadgitorious-mainline-outdated-eca9da8b2a50e9233bc9be5c10db6aa47ed7b15b.zip
gitorious-mainline-outdated-eca9da8b2a50e9233bc9be5c10db6aa47ed7b15b.tar.gz
gitorious-mainline-outdated-eca9da8b2a50e9233bc9be5c10db6aa47ed7b15b.tar.bz2
Caching the current activity selection
-rw-r--r--public/javascripts/application.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index a222807..7b8717a 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -199,12 +199,21 @@ $(document).ready(function() {
if ($(this).parent().hasClass("off")) { // User clicked something else
var tabBar = $(this).parents(".tab-bar");
+ var url = $(this).attr("href")
+ var cacheKey = "cached_" + url;
tabBar.addClass("waiting");
- jQuery.ajax({
- url: $(this).attr("href"),
- type: "get",
- success: function (d,t) {onComplete(d, tabBar)}
- });
+ if (cachedData = tabBar.data(cacheKey)) {
+ onComplete(cachedData, tabBar)
+ } else {
+ jQuery.ajax({
+ url: url,
+ type: "get",
+ success: function (d,t) {
+ tabBar.data(cacheKey, d);
+ onComplete(d, tabBar)
+ }
+ });
+ }
}
return false;
});