mirror of https://github.com/freeCodeCamp/devdocs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
503 B
25 lines
503 B
11 years ago
|
class app.views.Nav extends app.View
|
||
|
@el: '._nav'
|
||
|
@activeClass: '_nav-current'
|
||
|
|
||
|
@routes:
|
||
|
after: 'afterRoute'
|
||
|
|
||
|
select: (href) ->
|
||
|
@deselect()
|
||
|
if @current = @find "a[href='#{href}']"
|
||
|
@current.classList.add @constructor.activeClass
|
||
|
return
|
||
|
|
||
|
deselect: ->
|
||
|
if @current
|
||
|
@current.classList.remove @constructor.activeClass
|
||
|
@current = null
|
||
|
return
|
||
|
|
||
|
afterRoute: (route, context) =>
|
||
|
if route is 'page'
|
||
|
@select context.pathname
|
||
|
else
|
||
|
@deselect()
|