Skip to content

Commit

Permalink
Adds title to emoticons
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Manohar J <akash@akash.im>
  • Loading branch information
HashNuke committed Apr 13, 2012
1 parent 2d4d784 commit 6290306
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/assets/javascripts/backbone/plugins/emoticons.js.coffee
Expand Up @@ -3,7 +3,7 @@ class Kandan.Plugins.Emoticons
@options:
regex: /\([a-zA-Z]+\)/g
template: _.template '''
<img class="emoticon-embed" src="/assets/emoticons/<%= emoticon %>" height="30" width="30" />
<img class="emoticon-embed" src="/assets/emoticons/<%= emoticon %>" title="<%= title %>" height="30" width="30" />
'''


Expand Down Expand Up @@ -37,10 +37,11 @@ class Kandan.Plugins.Emoticons
matches = message.content.match(@options.regex)
for match in _.unique(matches)
emoticon = @emoticons[match]
title = match.replace(/\(|\)/g, "")
needle = match.replace('(', '\\(').replace(')', '\\)')
search = new RegExp(needle, 'g')
console.log(search)
replacement = @options.template({ emoticon: emoticon })
replacement = @options.template({ emoticon: emoticon, title: title})
message.content = message.content.replace(search, replacement) if emoticon
console.log(message.content)
return Kandan.Helpers.Activities.buildFromBaseTemplate(message)
Expand Down

0 comments on commit 6290306

Please sign in to comment.