From 5712c1484f45c32012417429c450d4862407f019 Mon Sep 17 00:00:00 2001 From: Darren Date: Fri, 31 Aug 2012 21:26:58 +0100 Subject: [PATCH] Part/Quit messages showing --- client_backbone/model.js | 12 +++++++----- client_backbone/model_application.js | 26 ++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/client_backbone/model.js b/client_backbone/model.js index ea1fdcc..db18689 100644 --- a/client_backbone/model.js +++ b/client_backbone/model.js @@ -315,12 +315,14 @@ kiwi.model.Channel = kiwi.model.Panel.extend({ this.addMsg(' ', '--> ' + member.displayNick(true) + ' has joined', 'action join'); }, this); - members.bind("remove", function (member, options) { - this.addMsg(' ', '<-- ' + member.displayNick(true) + ' has left ' + ((options.message) ? '(' + options.message + ')' : ''), 'action part'); - }, this); + members.bind("remove", function (member, members, options) { + var msg = (options.message) ? '(' + options.message + ')' : ''; - members.bind("quit", function (args) { - this.addMsg(' ', '<-- ' + member.displayNick(true) + ' has quit ' + ((args.message) ? '(' + args.message + ')' : ''), 'action quit'); + if (options.type === 'quit') { + this.addMsg(' ', '<-- ' + member.displayNick(true) + ' has quit ' + msg, 'action quit'); + } else { + this.addMsg(' ', '<-- ' + member.displayNick(true) + ' has left ' + msg, 'action part'); + } }, this); } }); diff --git a/client_backbone/model_application.js b/client_backbone/model_application.js index 65f77ff..f1a5faa 100644 --- a/client_backbone/model_application.js +++ b/client_backbone/model_application.js @@ -81,7 +81,11 @@ kiwi.model.Application = Backbone.Model.extend(new (function () { gw.on('onpart', function (event) { - var channel, members, user; + var channel, members, user, + part_options = {}; + + part_options.type = 'part'; + part_options.message = event.message || ''; channel = that.panels.getByName(event.channel); if (!channel) return; @@ -98,7 +102,25 @@ kiwi.model.Application = Backbone.Model.extend(new (function () { user = members.getByNick(event.nick); if (!user) return; - members.remove(user); + members.remove(user, part_options); + }); + + + gw.on('onquit', function (event) { + var member, members, + quit_options = {}; + + quit_options.type = 'quit'; + quit_options.message = event.message || ''; + + $.each(that.panels.models, function (index, panel) { + if (!panel.isChannel()) return; + + member = panel.get('members').getByNick(event.nick); + if (member) { + panel.get('members').remove(member, quit_options); + } + }); }); -- 2.25.1