diff --git a/Resources/Public/Scripts/Tabs.js b/Resources/Public/Scripts/Tabs.js index d49c83940ac195f893c5c8f42b449dbfe296742b..6e53a1960f83f1d31530a0def5d8f28041ae0137 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'); } };