From: Zachary Vance Date: Wed, 20 May 2015 22:48:15 +0000 (-0700) Subject: Mark complete and mark incomplete don't move focus the same X-Git-Url: https://git.za3k.com/?a=commitdiff_plain;h=d3edb9479cb656d2f97d4e13107556859a65ae6c;p=flowy.git Mark complete and mark incomplete don't move focus the same --- diff --git a/dist/flowy.js b/dist/flowy.js index c0885a0..0c259cf 100644 --- a/dist/flowy.js +++ b/dist/flowy.js @@ -357,11 +357,17 @@ var TodoView = Backbone.View.extend({ return $("
").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() { diff --git a/dist/flowy.unwrapped.js b/dist/flowy.unwrapped.js index 4ceec4b..952da17 100644 --- a/dist/flowy.unwrapped.js +++ b/dist/flowy.unwrapped.js @@ -356,11 +356,17 @@ var TodoView = Backbone.View.extend({ return $("
").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() { diff --git a/src/views/todo.js b/src/views/todo.js index 6d3f45f..d9ce2b2 100644 --- a/src/views/todo.js +++ b/src/views/todo.js @@ -47,11 +47,17 @@ var TodoView = Backbone.View.extend({ return $("
").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() {