From 6c719c052d49b161a25a7e4bce9cc50d475bcee8 Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 27 Oct 2012 14:02:12 +0100 Subject: [PATCH] Topicbar usability improvements --- client/assets/dev/view.js | 24 ++++++++++++++++++------ client/index.html | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/client/assets/dev/view.js b/client/assets/dev/view.js index 64889d2..e00421d 100644 --- a/client/assets/dev/view.js +++ b/client/assets/dev/view.js @@ -582,7 +582,16 @@ kiwi.view.TopicBar = Backbone.View.extend({ initialize: function () { kiwi.app.panels.bind('active', function (active_panel) { - this.setCurrentTopic(active_panel.get('topic')); + // If it's a channel topic, update and make editable + if (active_panel.isChannel()) { + this.setCurrentTopic(active_panel.get('topic') || ''); + this.$el.find('div').attr('contentEditable', true); + + } else { + // Not a channel topic.. clear and make uneditable + this.$el.find('div').attr('contentEditable', false) + .text(''); + } }, this); }, @@ -590,13 +599,16 @@ kiwi.view.TopicBar = Backbone.View.extend({ var inp = $(ev.currentTarget), inp_val = inp.text(); - if (kiwi.app.panels.active.isChannel()) { - if (ev.keyCode !== 13) return; + // Only allow topic editing if this is a channel panel + if (!kiwi.app.panels.active.isChannel()) { + return false; + } + // If hit return key, update the current topic + if (ev.keyCode === 13) { kiwi.gateway.topic(kiwi.app.panels.active.get('name'), inp_val); + return false; } - - return false; }, setCurrentTopic: function (new_topic) { @@ -914,7 +926,7 @@ kiwi.view.Application = Backbone.View.extend({ } // If we're typing into an input box somewhere, ignore - if ((ev.target.tagName.toLowerCase() === 'input') || (ev.target.id === 'edittopic')) { + if ((ev.target.tagName.toLowerCase() === 'input') || $(ev.target).attr('contenteditable')) { return; } diff --git a/client/index.html b/client/index.html index 94a04a2..ab95be9 100644 --- a/client/index.html +++ b/client/index.html @@ -28,7 +28,7 @@
-
+
-- 2.25.1