c = this.panels.getByName(event.channel);
if (!c) return;
- when = formatDate(new Date(event.when * 1000));
- c.addMsg('', styleText('channel_topic_setby', {text: translateText('client_models_network_topic', [event.nick, when]), channel: event.channel}), 'topic');
+ when = new Date(event.when * 1000);
+ c.set('topic_set_by', {nick: event.nick, when: when});
}
this.$el.append(this.$messages);
this.model.bind('change:topic', this.topic, this);
+ this.model.bind('change:topic_set_by', this.topicSetBy, this);
if (this.model.get('members')) {
this.model.get('members').bind('add', function (member) {
this.model.addMsg('', styleText('channel_topic', {text: topic, channel: this.model.get('name')}), 'topic');
// If this is the active channel then update the topic bar
- if (_kiwi.app.panels().active === this) {
- _kiwi.app.topicbar.setCurrentTopic(this.model.get("topic"));
+ if (_kiwi.app.panels().active === this.model) {
+ _kiwi.app.topicbar.setCurrentTopicFromChannel(this.model);
+ }
+ },
+
+ topicSetBy: function (topic) {
+ // If this is the active channel then update the topic bar
+ if (_kiwi.app.panels().active === this.model) {
+ _kiwi.app.topicbar.setCurrentTopicFromChannel(this.model);
}
},
if (!nick_class) return;
$('.'+nick_class).removeClass('global_nick_highlight');
- },
+ }
});
_kiwi.app.panels.bind('active', function (active_panel) {
// If it's a channel topic, update and make editable
if (active_panel.isChannel()) {
- this.setCurrentTopic(active_panel.get('topic') || '');
+ this.setCurrentTopicFromChannel(active_panel);
this.$el.find('div').attr('contentEditable', true);
} else {
process: function (ev) {
var inp = $(ev.currentTarget),
inp_val = inp.text();
-
+
// Only allow topic editing if this is a channel panel
if (!_kiwi.app.panels().active.isChannel()) {
return false;
// We only want a plain text version
$('div', this.$el).html(formatIRCMsg(_.escape(new_topic)));
+ },
+
+ setCurrentTopicFromChannel: function(channel) {
+ var set_by = channel.get('topic_set_by'),
+ set_by_text = '';
+
+ this.setCurrentTopic(channel.get("topic"));
+
+ if (set_by) {
+ set_by_text += translateText('client_models_network_topic', [set_by.nick, formatDate(set_by.when)]);
+ this.$el.attr('title', set_by_text);
+ } else {
+ this.$el.attr('title', '');
+ }
}
});
\ No newline at end of file