Client: chanlist code moved completely to its applet
authorDarren <darren@Darrens-MacBook-Pro.local>
Fri, 12 Apr 2013 14:38:28 +0000 (15:38 +0100)
committerDarren <darren@Darrens-MacBook-Pro.local>
Fri, 12 Apr 2013 14:38:34 +0000 (15:38 +0100)
client/assets/dev/applet_chanlist.js
client/assets/dev/model_application.js

index 222af410082595ec0e7d9582fba799b93a75199d..7b27735a5635911b82b5d5ff1c528ca2cdb1ee82 100644 (file)
 \r
 \r
 \r
-    _kiwi.applets.Chanlist = Backbone.Model.extend({\r
+    var Applet = Backbone.Model.extend({\r
         initialize: function () {\r
             this.set('title', 'Channel List');\r
             this.view = new View();\r
+\r
+            this.network = _kiwi.global.components.Network();\r
+            this.network.on('onlist_channel', this.onListChannel, this);\r
+            this.network.on('onlist_start', this.onListStart, this);\r
         },\r
 \r
 \r
+        // New channels to add to our list\r
+        onListChannel: function (event) {\r
+            console.log(event);\r
+            this.addChannel(event.chans);\r
+        },\r
+\r
+        // A new, fresh channel list starting\r
+        onListStart: function (event) {\r
+            // TODO: clear out our existing list\r
+        },\r
+\r
         addChannel: function (channels) {\r
             var that = this;\r
 \r
             this.view.$el.html('');\r
             this.view.remove();\r
             this.view = null;\r
+\r
+            // Remove any network event bindings\r
+            this.network.off();\r
         }\r
     });\r
 \r
 \r
+\r
+    _kiwi.model.Applet.register('kiwi_chanlist', Applet);\r
 })();
\ No newline at end of file
index ba9313c41fbe237fe9f1e4b09258726ccaa48559..2b677196c66c85cc72d4fd5b356e43fd4133bc8c 100644 (file)
@@ -719,32 +719,8 @@ _kiwi.model.Application = function () {
 \r
 \r
             gw.on('onlist_start', function (data) {\r
-                if (_kiwi.app.channel_list) {\r
-                    _kiwi.app.channel_list.close();\r
-                    delete _kiwi.app.channel_list;\r
-                }\r
-\r
-                var panel = new _kiwi.model.Applet(),\r
-                    applet = new _kiwi.applets.Chanlist();\r
-\r
-                panel.load(applet);\r
-                \r
-                _kiwi.app.panels.add(panel);\r
-                panel.view.show();\r
-                \r
-                _kiwi.app.channel_list = applet;\r
-            });\r
-\r
-\r
-            gw.on('onlist_channel', function (data) {\r
-                // TODO: Put this listener within the applet itself\r
-                _kiwi.app.channel_list.addChannel(data.chans);\r
-            });\r
-\r
-\r
-            gw.on('onlist_end', function (data) {\r
-                // TODO: Put this listener within the applet itself\r
-                delete _kiwi.app.channel_list;\r
+                var chanlist = _kiwi.model.Applet.loadOnce('kiwi_chanlist');\r
+                chanlist.view.show();\r
             });\r
 \r
 \r