Server select improvements
authorDarren <darren@darrenwhitlen.com>
Sun, 26 Aug 2012 19:50:32 +0000 (20:50 +0100)
committerDarren <darren@darrenwhitlen.com>
Sun, 26 Aug 2012 19:50:32 +0000 (20:50 +0100)
client_backbone/index.html
client_backbone/model.js
client_backbone/model_application.js
client_backbone/model_gateway.js
client_backbone/style.css
client_backbone/view.js

index 7fa49ff4af9b33a7726b86fa37f3daaecb7d6def..b9e5d2b7fa8ab637d50910f2a5de4fefa41e0e72 100644 (file)
 
     <script type="text/x-jquery-tmpl" id="tmpl_server_select">
         <div class="server_select">
+            <div class="status"></div>
+
             <form>
                 <div class="basic">
                     <label for="server_select_nick">Nickname</label>
                     <input type="text" class="nick" id="server_select_nick"> <br />
 
-                    <button type="submit">Connect..</button>
+                    <button type="submit">Connect..</button> <br />
                     <a class="show_more">More</a>
                 </div>
 
index c1ef197fa562c5b357b553835cdbfa90a644dac4..e1eb0bd0fddcb09e3a0e69625b5a303113208b24 100644 (file)
@@ -286,7 +286,9 @@ kiwi.model.Server = kiwi.model.Panel.extend({
         //this.addMsg(' ', '--> Kiwi IRC: Such an awesome IRC client', '', {style: 'color:#009900;'});\r
 \r
         this.server_login = new kiwi.view.ServerSelect();\r
+        \r
         this.view.$el.append(this.server_login.$el);\r
+        this.server_login.show();\r
     }\r
 });\r
 \r
index 32e70dd356f38045a254cd59d9436e9ee896ef6b..58e4d677af5cb68979dc2a5139c5b37cc0a2b075 100644 (file)
@@ -20,9 +20,7 @@ kiwi.model.Application = Backbone.Model.extend(new (function () {
 \r
             kiwi.gateway.set('nick', event.nick);\r
             kiwi.gateway.connect(event.server, 6667, false, false, function () {\r
-                console.log('gateway connected');\r
                 that.view.barsShow();\r
-                form.hide();\r
             });\r
         });\r
 \r
@@ -49,7 +47,7 @@ kiwi.model.Application = Backbone.Model.extend(new (function () {
         // Populate the server select box with defaults\r
         this.panels.server.server_login.populateFields({\r
             'nick': getQueryVariable('nick') || 'kiwi_' + Math.ceil(Math.random() * 10000).toString(),\r
-            'server': getQueryVariable('server') || 'irc.anonnet.org',\r
+            'server': getQueryVariable('server') || 'irc.kiwiirc.net',\r
             'channel': window.location.hash || '#test'\r
         });\r
     };\r
index dca83b3ea82699fc60cb6e659a19aa1c90cc037b..d19147c3462c6667e9a887c9ea0c2c2be1e28203 100644 (file)
@@ -87,6 +87,7 @@ kiwi.model.Gateway = Backbone.Model.extend(new (function () {
         this.socket.on('connecting', function (transport_type) {\r
             console.log("kiwi.gateway.socket.on('connecting')");\r
             this.emit("connecting");\r
+            that.trigger("connecting");\r
         });\r
 \r
         this.socket.on('connect', function () {\r
@@ -143,7 +144,7 @@ kiwi.model.Gateway = Backbone.Model.extend(new (function () {
     *   Parses the response from the server\r
     */\r
     this.parse = function (item) {\r
-        console.log('gateway event', item);\r
+        //console.log('gateway event', item);\r
         if (item.event !== undefined) {\r
             that.trigger('on' + item.event, item);\r
 \r
index 05c28dba7eb79cbd4a8b21b042bf848092cd1d48..1125b0bf7d70d50306e314b06554323348318fa0 100644 (file)
@@ -160,9 +160,15 @@ body {
 
 
 
-.server_select { width:300px; margin: 2em auto; }
+.server_select { width:270px; padding:3em 0 2em 0; margin: 0 auto; }
 .server_select .more { display: none; }
-.server_select button { padding:3px 7px; margin-left: 178px; }
-.server_select input { margin-bottom:5px; padding:3px 7px; }
-.server_select label { width:5em; float:left; margin-right:1em; }
-.server_select .basic .show_more { display: block; border-bottom: 1px dashed gray; margin:10px 0; }
\ No newline at end of file
+.server_select button { float:right; padding:3px 7px; }
+.server_select input { float:right; margin-bottom:5px; padding:3px 7px; }
+.server_select label { float:left; width:5em; padding-top:3px }
+.server_select br { clear:both; }
+.server_select .basic .show_more { display: block; border-bottom: 1px dashed gray; margin:10px 0; font-size:0.8em; }
+.server_select .status { text-align: center; font-weight: bold; padding:1em; }
+.server_select .status .ok {
+    border:1px solid #A33F3F; background-color:#D28A8A;
+    padding:0.5em; margin-top:1em; margin-bottom:1em; margin-right:2em;
+}
\ No newline at end of file
index 97e49819e298cdfd481ab0505b56bc278c395108..9861d48fa8561649a132f7fd977bf7ecdd915460 100644 (file)
@@ -74,6 +74,9 @@ kiwi.view.ServerSelect = Backbone.View.extend({
         that = this;\r
 \r
         this.$el = $($('#tmpl_server_select').html());\r
+\r
+        kiwi.gateway.on('onconnect', this.networkConnected);\r
+        kiwi.gateway.on('connecting', this.networkConnecting);\r
     },\r
 \r
     submitLogin: function (event) {\r
@@ -110,7 +113,28 @@ kiwi.view.ServerSelect = Backbone.View.extend({
     },\r
 \r
     show: function () {\r
-        this.$el.slideDown();\r
+        this.$el.show();\r
+        $('.nick', that.$el).focus();\r
+    },\r
+\r
+    setStatus: function (text, class_name) {\r
+        $('.status', this.$el)\r
+            .text(text)\r
+            .attr('class', 'status')\r
+            .addClass(class_name)\r
+            .show();\r
+    },\r
+    clearStatus: function () {\r
+        $('.status', this.$el).hide();\r
+    },\r
+\r
+    networkConnected: function (event) {\r
+        that.setStatus('Connected :)', 'ok');\r
+        $('form', this.$el).hide();\r
+    },\r
+\r
+    networkConnecting: function (event) {\r
+        that.setStatus('Connecting..', 'ok');\r
     }\r
 });\r
 \r
@@ -189,9 +213,11 @@ kiwi.view.Panel = Backbone.View.extend({
         var members = this.model.get("members");\r
         if (members) {\r
             members.view.show();\r
+            this.$container.parent().css('right', '200px');\r
         } else {\r
             // Memberlist not found for this panel, hide any active ones\r
             $('#memberlists').children().removeClass('active');\r
+            this.$container.parent().css('right', '0');\r
         }\r
 \r
         // TODO: Why is kiwi.app not defined when this is fist called :/\r
@@ -441,8 +467,8 @@ kiwi.view.Application = Backbone.View.extend({
             $('#toolbar').slideUp();\r
             $('#controlbox').slideUp(function () { that.doLayout(); });\r
         } else {\r
-            $('#toolbar').hide();\r
-            $('#controlbox').hide();\r
+            $('#toolbar').slideUp(0);\r
+            $('#controlbox').slideUp(0);\r
         }\r
     },\r
 \r
@@ -453,8 +479,8 @@ kiwi.view.Application = Backbone.View.extend({
             $('#toolbar').slideDown();\r
             $('#controlbox').slideDown(function () { that.doLayout(); });\r
         } else {\r
-            $('#toolbar').hide();\r
-            $('#controlbox').hide();\r
+            $('#toolbar').slideDown(0);\r
+            $('#controlbox').slideDown(0);\r
             this.doLayout();\r
         }\r
     }\r