From 4b4a81371ead43b2f9e01a924625eda1e5275199 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Wed, 10 Dec 2014 13:50:43 +0200 Subject: [PATCH] Highlight current nav via javascript --- MANIFEST | 1 + js/90-nav.js | 20 ++++++++++++++++++++ tmpl/skel.en | 10 +++++----- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 js/90-nav.js diff --git a/MANIFEST b/MANIFEST index 14d91b8..93228f4 100644 --- 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 index 0000000..3a59943 --- /dev/null +++ b/js/90-nav.js @@ -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; + } + }); +})(); diff --git a/tmpl/skel.en b/tmpl/skel.en index d9ce6fc..72df525 100644 --- a/tmpl/skel.en +++ b/tmpl/skel.en @@ -10,11 +10,11 @@