From 15a9b08b451dc3cd433a4155f0abe4d2470fed86 Mon Sep 17 00:00:00 2001
From: Stefan Galinski <stefan@sgalinski.de>
Date: Mon, 25 Jul 2016 18:10:18 +0200
Subject: [PATCH] [BUGFIX] Fix tab navigation (MAJOR BUG)

---
 Resources/Public/Scripts/Tabs.js | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/Resources/Public/Scripts/Tabs.js b/Resources/Public/Scripts/Tabs.js
index d49c839..6e53a19 100644
--- a/Resources/Public/Scripts/Tabs.js
+++ b/Resources/Public/Scripts/Tabs.js
@@ -29,6 +29,11 @@ SG.TabListener = function() {
 };
 
 SG.TabListener.prototype = {
+	/**
+	 * @var {int|null} intervalCall
+	 */
+	intervalCall: null,
+
 	/**
 	 * Jumps to the best tab if a tab hash is set
 	 *
@@ -36,14 +41,26 @@ SG.TabListener.prototype = {
 	 */
 	initialize: function() {
 		this.checkAndSwitchActiveTab();
-		setInterval(this.checkAndSwitchActiveTab, 1000);
+		this.intervalCall = setInterval(this.checkAndSwitchActiveTab, 600);
+		$('[data-toggle="tab"]').click(this.handleTabClick);
 	},
 
+	/**
+	 * Checks the segment of the url and activates another tab if requested
+	 */
 	checkAndSwitchActiveTab: function() {
-		var $tabLink = $('a[href="' + location.hash + '"]');
+		var $tabLink = $('a[href$="' + location.hash + '"]');
 		if ($tabLink.length && $tabLink.tab) {
 			$tabLink.tab('show');
 		}
+	},
+
+	/**
+	 * Changes the url on tab click
+	 */
+	handleTabClick: function() {
+		var tab = $(this);
+		location.href = tab.attr('href');
 	}
 };
 
-- 
GitLab