this.view = new kiwi.view.Tabs({"el": $('#toolbar .panellist')[0], "model": this});\r
\r
// Automatically create a server tab\r
- this.server = new kiwi.model.Server({'name': kiwi.gateway.get('name')});\r
- kiwi.gateway.on('change:name', this.view.render, this.view);\r
- this.add(this.server);\r
+ this.add(new kiwi.model.Server({'name': kiwi.gateway.get('name')}));\r
+ this.server = this.getByName(kiwi.gateway.get('name'));\r
\r
+ // Keep a tab on the active panel\r
this.bind('active', function (active_panel) {\r
this.active = active_panel;\r
}, this);\r
this.model.on("add", this.panelAdded, this);\r
this.model.on("remove", this.panelRemoved, this);\r
this.model.on("reset", this.render, this);\r
+\r
+ this.model.on('active', this.panelActive, this);\r
+\r
+ kiwi.gateway.on('change:name', function (gateway, new_val) {\r
+ $('span', this.model.server.tab).text(new_val);\r
+ }, this);\r
},\r
render: function () {\r
var that = this;\r
- $this = $(this.el);\r
- $this.empty();\r
+\r
+ this.$el.empty();\r
\r
// Add the server tab first\r
- $('<li><span>' + kiwi.gateway.get('name') + '</span></li>')\r
+ this.model.server.tab\r
.data('panel_id', this.model.server.cid)\r
- .appendTo($this);\r
+ .appendTo(this.$el);\r
\r
+ // Go through each panel adding its tab\r
this.model.forEach(function (panel) {\r
// If this is the server panel, ignore as it's already added\r
if (panel == that.model.server) return;\r
\r
- $('<li><span>' + panel.get("name") + '</span></li>')\r
+ panel.tab\r
.data('panel_id', panel.cid)\r
- .appendTo($this);\r
+ .appendTo(this.$el);\r
});\r
},\r
\r
panel.tab = $('<li><span>' + panel.get("name") + '</span></li>');\r
panel.tab.data('panel_id', panel.cid)\r
.appendTo(this.$el);\r
-\r
- panel.view.on('active', this.panelActive, this);\r
},\r
panelRemoved: function (panel) {\r
panel.tab.remove();\r
},\r
\r
tabClick: function (e) {\r
- var panel = this.model.getByCid($(e.currentTarget).data('panel_id'));\r
+ var tab = $(e.currentTarget);\r
+\r
+ var panel = this.model.getByCid(tab.data('panel_id'));\r
if (!panel) {\r
// A panel wasn't found for this tab... wadda fuck\r
return;\r
},\r
\r
partClick: function (e) {\r
- var panel = this.model.getByCid($(e.currentTarget).parent().data('panel_id'));\r
+ var tab = $(e.currentTarget).parent();\r
+ var panel = this.model.getByCid(tab.data('panel_id'));\r
\r
// Only need to part if it's a channel\r
if (panel.isChannel()) {\r
} else {\r
panel.close();\r
}\r
+ },\r
+\r
+ next: function () {\r
+ var next = kiwi.app.panels.active.tab.next();\r
+ if (!next.length) next = $('li:first', this.$el);\r
+\r
+ next.click();\r
+ },\r
+ prev: function () {\r
+ var prev = kiwi.app.panels.active.tab.prev();\r
+ if (!prev.length) prev = $('li:last', this.$el);\r
+\r
+ prev.click();\r
}\r
});\r
\r
\r
process: function (ev) {\r
var inp = $(ev.currentTarget),\r
- inp_val = inp.val();\r
+ inp_val = inp.val(),\r
+ meta;\r
\r
+ if (navigator.appVersion.indexOf("Mac") !== -1) {\r
+ meta = ev.ctrlKey;\r
+ } else {\r
+ meta = ev.altKey;\r
+ }\r
+ \r
switch (true) {\r
case (ev.keyCode === 13): // return\r
inp_val = inp_val.trim();\r
this.buffer_pos++;\r
inp.val(this.buffer[this.buffer_pos]);\r
}\r
+ break;\r
+\r
+ case (ev.keyCode === 37 && meta): // left\r
+ kiwi.app.panels.view.prev();\r
+ return false;\r
+ break;\r
+\r
+ case (ev.keyCode === 39 && meta): // right\r
+ kiwi.app.panels.view.next();\r
+ return false;\r
+ break;\r
}\r
},\r
\r