-
Notifications
You must be signed in to change notification settings - Fork 405
Plugin Mentions
gabceb edited this page Feb 20, 2013
·
2 revisions
Type @username
@gabceb
This plugin is also responsible for adding users to the At Jquery plugin
class Kandan.Plugins.Mentions
@options:
regex: /@\S*/g
template: _.template '''<span class="mention"><%= mention %></span>'''
@init: ()->
Kandan.Data.ActiveUsers.registerCallback "change", (data)=>
@initUsersMentions(data.extra.active_users)
Kandan.Modifiers.register @options.regex, (message, state) =>
for mention in message.content.match(@options.regex)
replacement = @options.template({mention: mention})
message.content = message.content.replace(mention, replacement)
return Kandan.Helpers.Activities.buildFromMessageTemplate(message)
@initUsersMentions: (activeUsers)->
users = _.map activeUsers, (user)->
user.username
$(".chat-input").atwho("@", {data: users});
return
Copyright © 2012-2013 - KandanApp