git ssb

0+

k4ml / belajar-js



Commit ce4b7beb55a8ce0ae7e807490fa7dcb9fc37190d

set active on current view

Kamal Mustafa committed on 3/19/2015, 12:33:46 AM
Parent: dd63fd2e084657c42584b0c568c51cae9c306aa7

Files changed

javascripts/nav.jschanged
javascripts/nav.jsView
@@ -3,15 +3,18 @@
33 nav_elm = document.getElementsByClassName('nav nav-tabs')[0];
44 viewport_view = document.getElementById('viewport-view');
55 if (!current_view) {
66 viewport_view.innerHTML = document.getElementById('viewport-home').innerHTML;
7+ current_view = nav_elm.children[0];
78 }
89 nav_elm.addEventListener('click', function (e) {
910 var hash, viewport;
1011 if (e.target.hash) {
1112 hash = e.target.hash.split('#')[1];
1213 viewport = document.getElementById('viewport-' + hash);
1314 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;
1518 }
1619 });
1720 }());

Built with git-ssb-web