\r
initialize: function () {\r
kiwi.app.panels.bind('active', function (active_panel) {\r
- this.setCurrentTopic(active_panel.get('topic'));\r
+ // If it's a channel topic, update and make editable\r
+ if (active_panel.isChannel()) {\r
+ this.setCurrentTopic(active_panel.get('topic') || '');\r
+ this.$el.find('div').attr('contentEditable', true);\r
+\r
+ } else {\r
+ // Not a channel topic.. clear and make uneditable\r
+ this.$el.find('div').attr('contentEditable', false)\r
+ .text('');\r
+ }\r
}, this);\r
},\r
\r
var inp = $(ev.currentTarget),\r
inp_val = inp.text();\r
\r
- if (kiwi.app.panels.active.isChannel()) {\r
- if (ev.keyCode !== 13) return;\r
+ // Only allow topic editing if this is a channel panel\r
+ if (!kiwi.app.panels.active.isChannel()) {\r
+ return false;\r
+ }\r
\r
+ // If hit return key, update the current topic\r
+ if (ev.keyCode === 13) {\r
kiwi.gateway.topic(kiwi.app.panels.active.get('name'), inp_val);\r
+ return false;\r
}\r
- \r
- return false;\r
},\r
\r
setCurrentTopic: function (new_topic) {\r
}\r
\r
// If we're typing into an input box somewhere, ignore\r
- if ((ev.target.tagName.toLowerCase() === 'input') || (ev.target.id === 'edittopic')) {\r
+ if ((ev.target.tagName.toLowerCase() === 'input') || $(ev.target).attr('contenteditable')) {\r
return;\r
}\r
\r