Commit ce4b7beb55a8ce0ae7e807490fa7dcb9fc37190d
set active on current view
Kamal Mustafa committed on 3/19/2015, 12:33:46 AMParent: dd63fd2e084657c42584b0c568c51cae9c306aa7
Files changed
javascripts/nav.js | changed |
javascripts/nav.js | ||
---|---|---|
@@ -3,15 +3,18 @@ | ||
3 | 3 | nav_elm = document.getElementsByClassName('nav nav-tabs')[0]; |
4 | 4 | viewport_view = document.getElementById('viewport-view'); |
5 | 5 | if (!current_view) { |
6 | 6 | viewport_view.innerHTML = document.getElementById('viewport-home').innerHTML; |
7 | + current_view = nav_elm.children[0]; | |
7 | 8 | } |
8 | 9 | nav_elm.addEventListener('click', function (e) { |
9 | 10 | var hash, viewport; |
10 | 11 | if (e.target.hash) { |
11 | 12 | hash = e.target.hash.split('#')[1]; |
12 | 13 | viewport = document.getElementById('viewport-' + hash); |
13 | 14 | viewport_view.innerHTML = viewport.innerHTML; |
14 | - current_view = hash; | |
15 | + e.target.parentElement.className = 'active'; | |
16 | + current_view.className = ''; | |
17 | + current_view = e.target.parentElement; | |
15 | 18 | } |
16 | 19 | }); |
17 | 20 | }()); |
Built with git-ssb-web