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.setCurrentTopic(active_panel
.get('topic') || '');
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
.gateway
.topic(null, _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
)));