Ignore blank lines on control input
authorDarren <darren@darrenwhitlen.com>
Fri, 31 Aug 2012 20:42:13 +0000 (21:42 +0100)
committerDarren <darren@darrenwhitlen.com>
Fri, 31 Aug 2012 20:42:13 +0000 (21:42 +0100)
client_backbone/view.js

index 76bf71e2da210511d296a4351bb8cc5ceabff4bb..1edda45407bebe75a0c9f79698233dc84aa70bbf 100644 (file)
@@ -358,31 +358,36 @@ kiwi.view.ControlBox = Backbone.View.extend({
     },\r
 \r
     process: function (ev) {\r
-        var inp = $(ev.currentTarget);\r
+        var inp = $(ev.currentTarget),\r
+            inp_val = inp.val();\r
 \r
         switch (true) {\r
-            case (ev.keyCode === 13):              // return\r
+        case (ev.keyCode === 13):              // return\r
+            inp_val = inp_val.trim();\r
+\r
+            if (inp_val) {\r
                 this.processInput(inp.val());\r
 \r
                 this.buffer.push(inp.val());\r
                 this.buffer_pos = this.buffer.length;\r
-\r
-                inp.val('');\r
-\r
-                break;\r
-\r
-            case (ev.keyCode === 38):              // up\r
-                if (this.buffer_pos > 0) {\r
-                    this.buffer_pos--;\r
-                    inp.val(this.buffer[this.buffer_pos]);\r
-                }\r
-                break;\r
-\r
-            case (ev.keyCode === 40):              // down\r
-                if (this.buffer_pos < this.buffer.length) {\r
-                    this.buffer_pos++;\r
-                    inp.val(this.buffer[this.buffer_pos]);\r
-                }\r
+            }\r
+            \r
+            inp.val('');\r
+\r
+            break;\r
+\r
+        case (ev.keyCode === 38):              // up\r
+            if (this.buffer_pos > 0) {\r
+                this.buffer_pos--;\r
+                inp.val(this.buffer[this.buffer_pos]);\r
+            }\r
+            break;\r
+\r
+        case (ev.keyCode === 40):              // down\r
+            if (this.buffer_pos < this.buffer.length) {\r
+                this.buffer_pos++;\r
+                inp.val(this.buffer[this.buffer_pos]);\r
+            }\r
         }\r
     },\r
 \r