From bf3bd4e5d049fadba886d489014e205d3421b58c Mon Sep 17 00:00:00 2001 From: Darren Date: Thu, 8 Nov 2012 14:49:50 +0000 Subject: [PATCH] Client: highlight CSS styling #124 --- client/assets/css/style.css | 4 +++- client/assets/dev/view.js | 15 +++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/assets/css/style.css b/client/assets/css/style.css index ec5f62d..477464a 100644 --- a/client/assets/css/style.css +++ b/client/assets/css/style.css @@ -141,7 +141,9 @@ a img { border:none; } padding:0.5em; margin-top:1em; margin-bottom:1em; margin-right:2em; } -.messages .msg.global_nick_highlight { background:#D9D9D9; } +.messages .msg.global_nick_highlight, +.messages .msg.highlight { background:#D9D9D9; } + diff --git a/client/assets/dev/view.js b/client/assets/dev/view.js index 68b4c41..0da683d 100644 --- a/client/assets/dev/view.js +++ b/client/assets/dev/view.js @@ -285,7 +285,13 @@ _kiwi.view.Panel = Backbone.View.extend({ newMsg: function (msg) { // TODO: make sure that the message pane is scrolled to the bottom (Or do we? ~Darren) var re, line_msg, $this = this.$el, - nick_colour_hex, nick_hex; + nick_colour_hex, nick_hex, is_highlight, msg_css_classes = ''; + + // Nick highlight detecting + if ((new RegExp('\\b' + _kiwi.gateway.get('nick') + '\\b', 'i')).test(msg.msg)) { + is_highlight = true; + msg_css_classes += ' highlight'; + } // Escape any HTML that may be in here msg.msg = $('
').text(msg.msg).html(); @@ -338,17 +344,18 @@ _kiwi.view.Panel = Backbone.View.extend({ _.map(msg.nick.split(''), function (char) { nick_hex += char.charCodeAt(0).toString(16); }); - msg.nick_css_class = 'nick_' + nick_hex; + msg_css_classes += ' nick_' + nick_hex; } // Build up and add the line - line_msg = '
<%- time %>
<%- nick %>
<%= msg %>
'; + msg.msg_css_classes = msg_css_classes; + line_msg = '
<%- time %>
<%- nick %>
<%= msg %>
'; $this.append(_.template(line_msg, msg)); // Activity/alerts based on the type of new message if (msg.type.match(/^action /)) { this.alert('action'); - } else if (msg.msg.indexOf(_kiwi.gateway.get('nick')) > -1) { + } else if (is_highlight) { _kiwi.app.view.alertWindow('* People are talking!'); this.alert('highlight'); } else { -- 2.25.1