tagName: "div",\r
className: "messages",\r
events: {\r
- "click .chan": "chanClick"\r
+ "click .chan": "chanClick",\r
+ 'mouseenter .msg .nick': 'msgEnter',\r
+ 'mouseleave .msg .nick': 'msgLeave'\r
},\r
\r
initialize: function (options) {\r
newMsg: function (msg) {\r
// TODO: make sure that the message pane is scrolled to the bottom (Or do we? ~Darren)\r
var re, line_msg, $this = this.$el,\r
- nick_colour_hex;\r
+ nick_colour_hex, nick_hex;\r
\r
// Escape any HTML that may be in here\r
msg.msg = $('<div />').text(msg.msg).html();\r
\r
msg.nick_style = 'color:' + nick_colour_hex + ';';\r
\r
+ // Generate a hex string from the nick to be used as a CSS class name\r
+ nick_hex = msg.nick_css_class = '';\r
+ if (msg.nick) {\r
+ _.map(msg.nick.split(''), function (char) {\r
+ nick_hex += char.charCodeAt(0).toString(16);\r
+ });\r
+ msg.nick_css_class = 'nick_' + nick_hex;\r
+ }\r
+\r
// Build up and add the line\r
- line_msg = '<div class="msg <%= type %>"><div class="time"><%- time %></div><div class="nick" style="<%= nick_style %>"><%- nick %></div><div class="text" style="<%= style %>"><%= msg %> </div></div>';\r
+ line_msg = '<div class="msg <%= type %> <%= nick_css_class %>"><div class="time"><%- time %></div><div class="nick" style="<%= nick_style %>"><%- nick %></div><div class="text" style="<%= style %>"><%= msg %> </div></div>';\r
$this.append(_.template(line_msg, msg));\r
\r
// Activity/alerts based on the type of new message\r
_kiwi.gateway.join($(event.srcElement).text());\r
}\r
},\r
+\r
+ msgEnter: function (event) {\r
+ var nick_class;\r
+\r
+ // Find a valid class that this element has\r
+ _.each($(event.currentTarget).parent('.msg').attr('class').split(' '), function (css_class) {\r
+ if (css_class.match(/^nick_[a-z0-9]+/i)) {\r
+ nick_class = css_class;\r
+ }\r
+ });\r
+\r
+ // If no class was found..\r
+ if (!nick_class) return;\r
+\r
+ $('.'+nick_class).addClass('global_nick_highlight');\r
+ },\r
+\r
+ msgLeave: function (event) {\r
+ var nick_class;\r
+\r
+ // Find a valid class that this element has\r
+ _.each($(event.currentTarget).parent('.msg').attr('class').split(' '), function (css_class) {\r
+ if (css_class.match(/^nick_[a-z0-9]+/i)) {\r
+ nick_class = css_class;\r
+ }\r
+ });\r
+\r
+ // If no class was found..\r
+ if (!nick_class) return;\r
+\r
+ $('.'+nick_class).removeClass('global_nick_highlight');\r
+ },\r
+\r
show: function () {\r
var $this = this.$el;\r
\r