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.
devdocs/assets/javascripts/views/layout/nav.coffee

25 lines
503 B

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()