From a4d671f8b8acf9c9b744c48e2c0f99707f46b386 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sun, 26 Oct 2014 21:44:09 -0400 Subject: [PATCH] fix popular pill selection --- public/src/client/popular.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/public/src/client/popular.js b/public/src/client/popular.js index 7495f5110d..6edc5a071c 100644 --- a/public/src/client/popular.js +++ b/public/src/client/popular.js @@ -12,8 +12,26 @@ define('forum/popular', ['forum/recent', 'forum/infinitescroll'], function(recen $(this).addClass('hide'); }); - recent.selectActivePill(); + selectActivePill(); }; + function selectActivePill() { + var active = getActiveSection(); + + $('.nav-pills li').removeClass('active'); + $('.nav-pills li a').each(function() { + var $this = $(this); + if ($this.attr('href').match(active)) { + $this.parent().addClass('active'); + return false; + } + }); + }; + + function getActiveSection() { + parts = window.location.href.split('/'); + return parts[parts.length - 1]; + } + return Popular; });