980c901a32dbc75b12927db366415fbc70ed496d
1 _kiwi
.view
.TopicBar
= Backbone
.View
.extend({
3 'keydown div': 'process'
6 initialize: function () {
7 _kiwi
.app
.panels
.bind('active', function (active_panel
) {
8 // If it's a channel topic, update and make editable
9 if (active_panel
.isChannel()) {
10 this.setCurrentTopicFromChannel(active_panel
);
11 this.$el
.find('div').attr('contentEditable', true);
14 // Not a channel topic.. clear and make uneditable
15 this.$el
.find('div').attr('contentEditable', false)
21 process: function (ev
) {
22 var inp
= $(ev
.currentTarget
),
25 // Only allow topic editing if this is a channel panel
26 if (!_kiwi
.app
.panels().active
.isChannel()) {
30 // If hit return key, update the current topic
31 if (ev
.keyCode
=== 13) {
32 _kiwi
.app
.connections
.active_connection
.gateway
.topic(_kiwi
.app
.panels().active
.get('name'), inp_val
);
37 setCurrentTopic: function (new_topic
) {
38 new_topic
= new_topic
|| '';
40 // We only want a plain text version
41 $('div', this.$el
).html(formatIRCMsg(_
.escape(new_topic
)));
44 setCurrentTopicFromChannel: function(channel
) {
45 var set_by
= channel
.get('topic_set_by'),
48 this.setCurrentTopic(channel
.get("topic"));
51 set_by_text
+= translateText('client_models_network_topic', [set_by
.nick
, _kiwi
.utils
.formatDate(set_by
.when
)]);
52 this.$el
.attr('title', set_by_text
);
54 this.$el
.attr('title', '');