Skip to content
Permalink
Browse files

Added active classes to the header.

chapter13-6
  • Loading branch information
tmeasday committed Oct 19, 2015
1 parent 9014a07 commit 0696e8a39d38dce2e27fb8d41c33eea77776928e
Showing with 15 additions and 3 deletions.
  1. +3 −3 client/templates/includes/header.html
  2. +12 −0 client/templates/includes/header.js
@@ -11,14 +11,14 @@
</div>
<div class="collapse navbar-collapse" id="navigation">
<ul class="nav navbar-nav">
<li>
<li class="{{activeRouteClass 'home' 'newPosts'}}">
<a href="{{pathFor 'newPosts'}}">New</a>
</li>
<li>
<li class="{{activeRouteClass 'bestPosts'}}">
<a href="{{pathFor 'bestPosts'}}">Best</a>
</li>
{{#if currentUser}}
<li>
<li class="{{activeRouteClass 'postSubmit'}}">
<a href="{{pathFor 'postSubmit'}}">Submit Post</a>
</li>
<li class="dropdown">
@@ -0,0 +1,12 @@
Template.header.helpers({
activeRouteClass: function(/* route names */) {
var args = Array.prototype.slice.call(arguments, 0);
args.pop();

var active = _.any(args, function(name) {
return Router.current() && Router.current().route.getName() === name
});

return active && 'active';
}
});

0 comments on commit 0696e8a

Please sign in to comment.
You can’t perform that action at this time.