Skip to content

Commit

Permalink
Merge pull request #11 from Bushido/emoticon_polish
Browse files Browse the repository at this point in the history
Emoticon polish
  • Loading branch information
kevzettler committed Apr 13, 2012
2 parents 55f8ecd + 49ac70c commit e88c0e4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/assets/javascripts/backbone/plugins/emoticons.js.coffee
Original file line number Diff line number Diff line change
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="40" width="40" />
<img class="emoticon-embed" src="/assets/emoticons/<%= emoticon %>" title="<%= title %>" height="40" width="40" />
'''


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')
replacement = @options.template({ emoticon: emoticon })
replacement = @options.template({ emoticon: emoticon, title: title})
message.content = message.content.replace(search, replacement) if emoticon
return Kandan.Helpers.Activities.buildFromBaseTemplate(message)
return Kandan.Helpers.Activities.buildFromMessageTemplate(message)

# Kandan.Plugins.register "Kandan.Plugins.Emoticons"

0 comments on commit e88c0e4

Please sign in to comment.