-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
794 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# The mentions plugin takes care of highlighting the @useranme and passing the users to the atwho plugin. | ||
# The show_activities addMessage method is the responsible of changing the look of a message body when a user is mentioned | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.