Skip to content

Instantly share code, notes, and snippets.

@songjiayang
Last active December 22, 2015 08:39
Show Gist options
  • Save songjiayang/6446384 to your computer and use it in GitHub Desktop.
Save songjiayang/6446384 to your computer and use it in GitHub Desktop.
使用js 添加 actived link ...
class MessageSidebar
constructor: (element) ->
$element = $(element)
compose_regex = "messages\/new"
inbox_regex = 'messages'
outbox_regex = "messages\/outbox"
archived_regex = "messages\/archived"
trash_regex = "messages\/trash"
if window.location.pathname.match(compose_regex)
$element.find('a.compose').addClass('actived')
else if window.location.pathname.match(outbox_regex)
$element.find('a.outbox').addClass('actived')
else if window.location.pathname.match(archived_regex)
$element.find('a.archived').addClass('actived')
else if window.location.pathname.match(trash_regex)
$element.find('a.trash').addClass('actived')
else if window.location.pathname.match(inbox_regex)
$element.find('a.inbox').addClass('actived')
$ ->
$('#message-section-nav').each ->
new MessageSidebar(this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment