]> iEval git - gruntmaster-page.git/commitdiff
Highlight current nav via javascript
authorMarius Gavrilescu <marius@ieval.ro>
Wed, 10 Dec 2014 11:50:43 +0000 (13:50 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Wed, 10 Dec 2014 11:50:43 +0000 (13:50 +0200)
MANIFEST
js/90-nav.js [new file with mode: 0644]
tmpl/skel.en

index 14d91b8ab9cd9fdb756e06cc50ce1f7441afb72d..93228f41868b985cc30e193ca0c5b877abb7c6bf 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -16,6 +16,7 @@ js/10-bootstrap-dropdown.js
 js/10-bootstrap-modal.js
 js/90-custom.js
 js/90-form.js
+js/90-nav.js
 lib/Plack/App/Gruntmaster.pm
 lib/Plack/App/Gruntmaster/HTML.pm
 log.conf
diff --git a/js/90-nav.js b/js/90-nav.js
new file mode 100644 (file)
index 0000000..3a59943
--- /dev/null
@@ -0,0 +1,20 @@
+(function(){
+       'use strict';
+
+       var NAVS = {
+               'home': /^\/$/,
+               'pb': /^\/pb\//,
+               'ct': /^\/ct\//,
+               'log': /^\/log\//,
+               'account': /^\/account$/
+       };
+
+       $( document ).ready(function(){
+               var path = location.pathname;
+               for (var nav in NAVS)
+                       if(path.match(NAVS[nav])) {
+                               $('#nav-' + nav).addClass('active');
+                               break;
+                       }
+       });
+})();
index d9ce6fc37962b21dcc799ee3fed9d6188d5592da..72df525d79223383bee24c682b5591a210eea979 100644 (file)
 <nav role="navigation">
 <div class="container-fluid">
 <ul class="nav nav-pills nav-justified">
-<li><a href="/">Gruntmaster 6000</a>
-<li><a href="/pb/">Problems</a>
-<li><a href="/ct/">Contests</a>
-<li><a href="/log/">Job log</a>
-<li><a href="/account">Account</a>
+<li id="nav-home"><a href="/">Gruntmaster 6000</a>
+<li id="nav-pb"><a href="/pb/">Problems</a>
+<li id="nav-ct"><a href="/ct/">Contests</a>
+<li id="nav-log"><a href="/log/">Job log</a>
+<li id="nav-account"><a href="/account">Account</a>
 <li id="theme-selector" class="hidden"><a class="dropdown-toggle" data-toggle="dropdown"> Theme <span class="caret"></span></a>
 <ul class="dropdown-menu" role="menu">
 <li><a href="#" id="theme_slate">Gunmetal gray</a>
This page took 0.025676 seconds and 4 git commands to generate.