Permalink
Browse files

Add support for display topic changes

  • Loading branch information...
1 parent 3fbffe4 commit af96dc905fbe1e1d661ce504a05a370eba42823c David Petersen committed Jan 25, 2012
Showing with 14 additions and 5 deletions.
  1. +6 −2 assets/css/subway.css
  2. BIN assets/images/topic.png
  3. +3 −1 assets/js/client.js
  4. +3 −0 assets/js/models.js
  5. +2 −2 assets/js/views/chat.js
View
@@ -180,11 +180,11 @@
background: #F9F9F9;
}
-.joinpart{
+.message_notification{
padding: 1% 0% 1% 1%;
}
-.join_img, .part_img{
+.join_img, .part_img, .topic_img{
width: 16px;
height: 16px;
padding-right: 1%;
@@ -201,6 +201,10 @@
background-image:url('/assets/images/part.png');
}
+.topic_img{
+ background-image:url('/assets/images/topic.png');
+}
+
.chat_name{
display: table-cell;
width: 14%;
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -113,9 +113,11 @@ $(function() {
});
irc.socket.on('topic', function(data) {
- console.log(data);
var channel = irc.chatWindows.getByName(data.channel);
channel.set({topic: data.topic});
+ var topicMessage = new Message({type: 'topic', nick: data.nick, topic: data.topic});
+ topicMessage.setText();
+ channel.stream.add(topicMessage);
});
irc.socket.on('error', function(data) {
View
@@ -50,6 +50,9 @@ var Message = Backbone.Model.extend({
case 'nick':
text = '<b>' + this.get('oldNick') + '</b> is now known as ' + this.get('newNick');
break;
+ case 'topic':
+ text = '<span class="topic_img"></span><b>' + this.get('nick') + '</b> has changed the topic to <i>' + this.get('topic') + '</i>';
+ break;
}
this.set({text: text});
},
View
@@ -110,8 +110,8 @@ var ChatView = Backbone.View.extend({
$(view.el).addClass('message-me');
}
- if(type === 'join' || type === 'part'){
- $(view.el).addClass('joinpart');
+ if(['join', 'part', 'topic'].indexOf(type) !== -1){
+ $(view.el).addClass('message_notification');
}
// Scroll down to show new message

0 comments on commit af96dc9

Please sign in to comment.