]> git.za3k.com Git - flowy.git/commitdiff
Mark complete and mark incomplete don't move focus the same
authorZachary Vance <vanceza@gmail.com>
Wed, 20 May 2015 22:48:15 +0000 (15:48 -0700)
committerZachary Vance <vanceza@gmail.com>
Wed, 20 May 2015 22:48:15 +0000 (15:48 -0700)
dist/flowy.js
dist/flowy.unwrapped.js
src/views/todo.js

index c0885a02608755791c7512c216726f9fdab2e128..0c259cfe47fbaff904af00cb71ddecd5a15244fc 100644 (file)
@@ -357,11 +357,17 @@ var TodoView = Backbone.View.extend({
     return $("<div/>").html(encodedText).text();
   },
   toggleComplete: function() {
-    this.stopEditingText();
-    this.model.toggleComplete();
-    var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false});
-    if (!next) return false;
-    next.getView().startEditingText();
+    if (this.model.get("completed")) {
+        this.stopEditingText();
+        this.model.toggleComplete();
+        this.startEditingText(); // TODO: Don't lose place
+    } else {
+        this.stopEditingText();
+        this.model.toggleComplete();
+        var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false});
+        if (!next) return false;
+        next.getView().startEditingText();
+    }
     return false; // Don't propogate
   },
   backspace: function() {
index 4ceec4bb329b9cadd35c7d7fd7a73c549357df7b..952da17b84a4d0df15598c83d1382be5e9eb5cd2 100644 (file)
@@ -356,11 +356,17 @@ var TodoView = Backbone.View.extend({
     return $("<div/>").html(encodedText).text();
   },
   toggleComplete: function() {
-    this.stopEditingText();
-    this.model.toggleComplete();
-    var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false});
-    if (!next) return false;
-    next.getView().startEditingText();
+    if (this.model.get("completed")) {
+        this.stopEditingText();
+        this.model.toggleComplete();
+        this.startEditingText(); // TODO: Don't lose place
+    } else {
+        this.stopEditingText();
+        this.model.toggleComplete();
+        var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false});
+        if (!next) return false;
+        next.getView().startEditingText();
+    }
     return false; // Don't propogate
   },
   backspace: function() {
index 6d3f45fa16c8ade0b78c63b3a9bfd7a18cf759d0..d9ce2b2bf05e41442f0661542b2e4088704d0c09 100644 (file)
@@ -47,11 +47,17 @@ var TodoView = Backbone.View.extend({
     return $("<div/>").html(encodedText).text();
   },
   toggleComplete: function() {
-    this.stopEditingText();
-    this.model.toggleComplete();
-    var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false});
-    if (!next) return false;
-    next.getView().startEditingText();
+    if (this.model.get("completed")) {
+        this.stopEditingText();
+        this.model.toggleComplete();
+        this.startEditingText(); // TODO: Don't lose place
+    } else {
+        this.stopEditingText();
+        this.model.toggleComplete();
+        var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false});
+        if (!next) return false;
+        next.getView().startEditingText();
+    }
     return false; // Don't propogate
   },
   backspace: function() {