Tabs now a list of network tabs
authorDarren <darren@Darrens-MacBook-Pro.local>
Wed, 24 Apr 2013 18:33:17 +0000 (19:33 +0100)
committerDarren <darren@Darrens-MacBook-Pro.local>
Wed, 24 Apr 2013 18:33:17 +0000 (19:33 +0100)
client/assets/css/style.css
client/assets/dev/model_application.js
client/assets/dev/model_gateway.js
client/assets/dev/model_network.js
client/assets/dev/model_panellist.js
client/assets/dev/view.js

index e48a7c8cfaf46db61e20dbc14db6d1df5ab69242..e11828fb7be870f8c322d170f1ac2e4d402601b9 100644 (file)
@@ -31,7 +31,7 @@ html, body { height:100%; }
     overflow: hidden;
     display:block;
 }
-#kiwi #toolbar .panellist li {
+#kiwi #toolbar .panellist .connection li {
     float: left; list-style: inline;
     display:inline; position:relative;
     padding:5px; margin:3px;
@@ -43,10 +43,11 @@ html, body { height:100%; }
 #kiwi #toolbar .panellist .alert_activity { font-weight: bold; }
 #kiwi #toolbar .panellist .alert_action { font-weight: bold; }
 
-#kiwi #toolbar .panellist li .part { position: absolute; top: 5px; right: 5px; }
-#kiwi #toolbar .panellist li .part:before { content:"[x]"; }
-#kiwi #toolbar .panellist li .part:hover { color: #900; }
-#kiwi #toolbar .panellist li img.icon { left:5px; top:2px; height:auto; width:auto; }
+#kiwi #toolbar .panellist .connection { display: inline; }
+#kiwi #toolbar .panellist .connection li .part { position: absolute; top: 5px; right: 5px; }
+#kiwi #toolbar .panellist .connection li .part:before { content:"[x]"; }
+#kiwi #toolbar .panellist .connection li .part:hover { color: #900; }
+#kiwi #toolbar .panellist .connection li img.icon { left:5px; top:2px; height:auto; width:auto; }
 
 #kiwi #status_message {
     background: #FFF;
@@ -301,14 +302,14 @@ html, body { height:100%; }
 #kiwi.theme_relaxed #memberlists_resize_handle {
     /*background:url('../img/resize_handle.png') no-repeat; background-position:center;*/
 }
-#kiwi.theme_relaxed #toolbar .panellist li {
+#kiwi.theme_relaxed #toolbar .panellist .connection li {
     line-height: 1.4em;
     vertical-align: middle;
     
-    border-radius:5px;
     -moz-border-radius:5px;
     -webkit-border-radius:5px;
     -khtml-border-radius:5px;
+    border-radius:5px;
     behavior: url(border-radius.htc);
 
     background-image: -webkit-gradient(
@@ -328,23 +329,23 @@ html, body { height:100%; }
     background-color: #eee;
 }
 
-#kiwi.theme_relaxed #toolbar .panellist .alert_highlight { /*background: #990000;*/ }
-#kiwi.theme_relaxed #toolbar .panellist .alert_activity { font-weight:normal; }
-#kiwi.theme_relaxed #toolbar .panellist .alert_action { font-weight:normal; }
+#kiwi.theme_relaxed #toolbar .panellist .connection .alert_highlight { /*background: #990000;*/ }
+#kiwi.theme_relaxed #toolbar .panellist .connection .alert_activity { font-weight:normal; }
+#kiwi.theme_relaxed #toolbar .panellist .connection .alert_action { font-weight:normal; }
 
-#kiwi.theme_relaxed #toolbar .panellist .active { padding-right:23px; }
-#kiwi.theme_relaxed #toolbar .panellist li .part:before { content:"\f00d"; }
+#kiwi.theme_relaxed #toolbar .panellist .connection .active { padding-right:23px; }
+#kiwi.theme_relaxed #toolbar .panellist .connection li .part:before { content:"\f00d"; }
 
-#kiwi.theme_relaxed #toolbar .panellist li.server span { padding-left: 5px; }
-#kiwi.theme_relaxed.connected #toolbar .panellist li.server:before { content: "\f0ec"; color:#3F9532; }
+#kiwi.theme_relaxed #toolbar .panellist .connection li.server span { padding-left: 5px; }
+#kiwi.theme_relaxed.connected #toolbar .panellist .connection li.server:before { content: "\f0ec"; color:#3F9532; }
 #kiwi.theme_relaxed #toolbar .panellist li.server:before { content: "\f06a"; color:#900; font-size:1.5em; line-height:1em; vertical-align:middle; }
 
 /* Tab texts are within a span */
-#kiwi.theme_relaxed #toolbar .panellist li span  { line-height:20px; vertical-align:middle; display:inline-block; }
+#kiwi.theme_relaxed #toolbar .panellist .connection li span  { line-height:20px; vertical-align:middle; display:inline-block; }
 
-#kiwi.theme_relaxed #toolbar .panellist li.active .activity { display:none; }
-#kiwi.theme_relaxed #toolbar .panellist li .activity.zero { visibility:hidden; }
-#kiwi.theme_relaxed #toolbar .panellist li .activity {
+#kiwi.theme_relaxed #toolbar .panellist .connection li.active .activity { display:none; }
+#kiwi.theme_relaxed #toolbar .panellist .connection li .activity.zero { visibility:hidden; }
+#kiwi.theme_relaxed #toolbar .panellist .connection li .activity {
     padding: 1px 3px; margin-left:1em;
     border-radius: 4px;
     background: #3F9532; color:#000; /*color: #ff5300;*/
@@ -352,7 +353,7 @@ html, body { height:100%; }
     display:inline-block;
     width:2em;
 }
-#kiwi.theme_relaxed #toolbar .panellist li.alert_highlight .activity {
+#kiwi.theme_relaxed #toolbar .panellist .connection li.alert_highlight .activity {
     color: #fff; background: #a60400;
 }
 
index dcae63ff7a0ffb6f6ebc385073ea2c31fe03c541..c5ff111cfaba5b870512a6b91fa0ac973288681f 100644 (file)
@@ -758,7 +758,7 @@ _kiwi.model.Application = function () {
             _.each(this.connections.models, function(connection) {\r
                 _.each(connection.panels.model, fn);\r
             });\r
-        }\r
+        };\r
 \r
     };\r
 \r
index d1e7faa703153dce8741fc2b5fccf9628f365dae..9db724b248ef97fb9d2f1957209d222a9bdeca85 100644 (file)
@@ -238,14 +238,14 @@ _kiwi.model.Gateway = function () {
 \r
         this.socket.emit('kiwi', {command: 'connect', nick: h.nick, hostname: h.host, port: h.port, ssl: h.ssl, password: h.password}, function (err, server_num) {\r
             if (!err) {\r
-                that.server_num = server_num;\r
-\r
                 // TODO: Remove this whole premature connection thing when panel code is tidied\r
                 if (server_num != 0 && !_kiwi.app.connections.getByConnectionId(server_num)){\r
                     _kiwi.app.connections.add(new _kiwi.model.Network({connection_id: server_num}));\r
                 }\r
 \r
                 console.log("_kiwi.gateway.socket.on('connect')");\r
+                callback_fn && callback_fn(err);\r
+                \r
             } else {\r
                 console.log("_kiwi.gateway.socket.on('error')", {reason: err});\r
                 callback_fn && callback_fn(err);\r
index 854a9e12075cc92b8149a5bbef4f1600c57ef9bf..b48fdf23df689ead793b1091b01066fc975df286 100644 (file)
@@ -39,8 +39,9 @@
             this.gateway = _kiwi.global.components.Network(this.get('connection_id'));
             this.bindGatewayEvents();
 
+            // Create our panel list (tabs)
             this.panels = new _kiwi.model.PanelList([], this);
-            this.panels.network = this;
+            //this.panels.network = this;
 
             // Automatically create a server tab
             var server_panel = new _kiwi.model.Server({name: 'Server'});
index 46cdaebf1ea825353b5d3ee772887cd5ce66f87f..929c2911ebd2c5cc7298cb8760100864aa2d7422 100644 (file)
@@ -37,6 +37,8 @@ _kiwi.model.NetworkPanelList = Backbone.Collection.extend({
     model: _kiwi.model.Network,\r
 \r
     initialize: function() {\r
+        this.view = new _kiwi.view.NetworkTabs({model: this});\r
+        \r
         this.on('add', this.onNetworkAdd, this);\r
         this.on('remove', this.onNetworkRemove, this);\r
 \r
index fdb958488f5cc860cdf913157ab034c8669bcd83..f84b7ed5252d5a9a8ef2985de18dd4d5c79fb800 100644 (file)
@@ -669,7 +669,7 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({
         if (typeof topic !== 'string' || !topic) {\r
             topic = this.model.get("topic");\r
         }\r
-        \r
+\r
         this.model.addMsg('', '== Topic for ' + this.model.get('name') + ' is: ' + topic, 'topic');\r
 \r
         // If this is the active channel then update the topic bar\r
@@ -679,6 +679,35 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({
     }\r
 });\r
 \r
+\r
+\r
+// Model for this = _kiwi.model.NetworkPanelList\r
+_kiwi.view.NetworkTabs = Backbone.View.extend({\r
+    tagName: 'ul',\r
+    className: 'panellist channels',\r
+\r
+    initialize: function() {\r
+        this.model.on('add', this.networkAdded, this);\r
+        this.model.on('remove', this.networkRemoved, this);\r
+\r
+        this.$el.appendTo($('#kiwi #tabs'));\r
+    },\r
+\r
+    networkAdded: function(network) {\r
+        $('<li class="connection"></li>')\r
+            .append(network.panels.view.$el)\r
+            .appendTo(this.$el);\r
+    },\r
+\r
+    networkRemoved: function(network) {\r
+        network.panels.view.remove();\r
+\r
+        _kiwi.app.view.doLayout();\r
+    }\r
+});\r
+\r
+\r
+\r
 // Model for this = _kiwi.model.PanelList\r
 _kiwi.view.Tabs = Backbone.View.extend({\r
     tagName: 'ul',\r
@@ -698,9 +727,6 @@ _kiwi.view.Tabs = Backbone.View.extend({
         this.model.network.on('change:name', function (network, new_val) {\r
             $('span', this.model.server.tab).text(new_val);\r
         }, this);\r
-\r
-        this.$tab_container = $('#kiwi .panellist.channels');\r
-        this.$tab_container.append(this.$el);\r
     },\r
 \r
     render: function () {\r
@@ -759,7 +785,7 @@ _kiwi.view.Tabs = Backbone.View.extend({
     panelActive: function (panel, previously_active_panel) {\r
         // Remove any existing tabs or part images\r
         $('.part', this.$el).remove();\r
-        this.$tab_container.find('.active').removeClass('active');\r
+        this.$el.parent().find('.active').removeClass('active');\r
 \r
         panel.tab.addClass('active');\r
 \r
@@ -771,7 +797,7 @@ _kiwi.view.Tabs = Backbone.View.extend({
 \r
     tabClick: function (e) {\r
         var tab = $(e.currentTarget);\r
-        \r
+\r
         var panel = tab.data('panel');\r
         if (!panel) {\r
             // A panel wasn't found for this tab... wadda fuck\r