this.controlbox = new kiwi.view.ControlBox({el: $('#controlbox')[0]});\r
this.bindControllboxCommands(this.controlbox);\r
\r
+ this.topicbar = new kiwi.view.TopicBar({el: $('#topic')[0]});\r
+\r
// Container for the channels\r
this.panels = new kiwi.model.PanelList();\r
this.panels.server.view.show();\r
\r
// If this is the active channel, update the topic bar too\r
if (c.get('name') === kiwi.current_panel.get('name')) {\r
- that.setCurrentTopic(event.topic);\r
+ that.topicbar.setCurrentTopic(event.topic);\r
}\r
});\r
\r
kiwi.gateway.part(channel);\r
});\r
}\r
+ // TODO: More responsive = close tab now, more accurate = leave until part event\r
//kiwi.app.panels.remove(kiwi.current_panel);\r
};\r
\r
\r
\r
\r
- this.setCurrentTopic = function (new_topic) {\r
- $('#topic input').val(new_topic);\r
- };\r
-\r
this.isChannelName = function (channel_name) {\r
var channel_prefix = kiwi.gateway.get('channel_prefix');\r
\r
\r
// TODO: Why is kiwi.app not defined when this is fist called :/\r
if (kiwi.app) {\r
- kiwi.app.setCurrentTopic(this.model.get("topic") || "");\r
+ kiwi.app.topicbar.setCurrentTopic(this.model.get("topic") || "");\r
}\r
\r
this.scrollToBottom();\r
\r
// If this is the active channel then update the topic bar\r
if (kiwi.current_panel === this) {\r
- kiwi.app.setCurrentTopic(this.model.get("topic"));\r
+ kiwi.app.topicbar.setCurrentTopic(this.model.get("topic"));\r
}\r
}\r
});\r
\r
\r
\r
-kiwi.view.ControlBox = Backbone.View.extend({\r
- that: this,\r
+kiwi.view.TopicBar = Backbone.View.extend({\r
+ events: {\r
+ 'keydown input': 'process'\r
+ },\r
+\r
+ initialize: function () {\r
+ },\r
+\r
+ process: function (ev) {\r
+ var inp = $(ev.currentTarget),\r
+ inp_val = inp.val();\r
\r
+ if (ev.keyCode !== 13) return;\r
+\r
+ if (kiwi.current_panel.isChannel && kiwi.current_panel.isChannel()) {\r
+ kiwi.gateway.topic(kiwi.current_panel.get('name'), inp_val);\r
+ }\r
+ },\r
+\r
+ setCurrentTopic: function (new_topic) {\r
+ $('input', this.$el).val(new_topic);\r
+ }\r
+});\r
+\r
+\r
+\r
+kiwi.view.ControlBox = Backbone.View.extend({\r
buffer: [], // Stores previously run commands\r
buffer_pos: 0, // The current position in the buffer\r
\r
this.buffer.push(inp.val());\r
this.buffer_pos = this.buffer.length;\r
}\r
- \r
+\r
inp.val('');\r
\r
break;\r