Topicbar usability improvements
authorDarren <darren@darrenwhitlen.com>
Sat, 27 Oct 2012 13:02:12 +0000 (14:02 +0100)
committerDarren <darren@darrenwhitlen.com>
Sat, 27 Oct 2012 15:53:35 +0000 (16:53 +0100)
client/assets/dev/view.js
client/index.html

index 07c7f4bbff473043cb842d8baee330aeca6d4431..f98ac086b5944d9c6c34e2a37bb6a039846a38cd 100644 (file)
@@ -582,7 +582,16 @@ kiwi.view.TopicBar = Backbone.View.extend({
 \r
     initialize: function () {\r
         kiwi.app.panels.bind('active', function (active_panel) {\r
-            this.setCurrentTopic(active_panel.get('topic'));\r
+            // If it's a channel topic, update and make editable\r
+            if (active_panel.isChannel()) {\r
+                this.setCurrentTopic(active_panel.get('topic') || '');\r
+                this.$el.find('div').attr('contentEditable', true);\r
+\r
+            } else {\r
+                // Not a channel topic.. clear and make uneditable\r
+                this.$el.find('div').attr('contentEditable', false)\r
+                    .text('');\r
+            }\r
         }, this);\r
     },\r
 \r
@@ -590,13 +599,16 @@ kiwi.view.TopicBar = Backbone.View.extend({
         var inp = $(ev.currentTarget),\r
             inp_val = inp.text();\r
         \r
-        if (kiwi.app.panels.active.isChannel()) {\r
-            if (ev.keyCode !== 13) return;\r
+        // Only allow topic editing if this is a channel panel\r
+        if (!kiwi.app.panels.active.isChannel()) {\r
+            return false;\r
+        }\r
 \r
+        // If hit return key, update the current topic\r
+        if (ev.keyCode === 13) {\r
             kiwi.gateway.topic(kiwi.app.panels.active.get('name'), inp_val);\r
+            return false;\r
         }\r
-        \r
-        return false;\r
     },\r
 \r
     setCurrentTopic: function (new_topic) {\r
@@ -897,7 +909,7 @@ kiwi.view.Application = Backbone.View.extend({
         }\r
 \r
         // If we're typing into an input box somewhere, ignore\r
-        if ((ev.target.tagName.toLowerCase() === 'input') || (ev.target.id === 'edittopic')) {\r
+        if ((ev.target.tagName.toLowerCase() === 'input') || $(ev.target).attr('contenteditable')) {\r
             return;\r
         }\r
 \r
index fccd4ac6db857e32b126f79f2dd35437ea70f19c..d54a34a50c65b1fb9468664e3e95fa17b41496b6 100644 (file)
@@ -22,7 +22,7 @@
             </div>
 
             <div id="topic">
-                <div id="edittopic" contenteditable="true" ></div>
+                <div contenteditable="true" ></div>
             </div>
 
             <div id="status_message"></div>