From 7413a09b9ef1ca45b3a0a0c8c794568f55952f71 Mon Sep 17 00:00:00 2001 From: Zachary Vance Date: Wed, 27 May 2015 17:53:46 -0700 Subject: [PATCH] Maintain cursor position while un-completing an item --- dist/flowy.js | 8 +++++--- dist/flowy.unwrapped.js | 8 +++++--- src/views/todo.js | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/dist/flowy.js b/dist/flowy.js index fefa3a4..395bb7a 100644 --- a/dist/flowy.js +++ b/dist/flowy.js @@ -461,9 +461,11 @@ var TodoView = Backbone.View.extend({ }, toggleComplete: function() { if (this.model.get("completed")) { - this.stopEditingText(); - this.model.toggleComplete(); - this.startEditingText(); // TODO: Don't lose place + var self = this; + this._maintainingFocus(function() { + self.stopEditingText(); + self.model.toggleComplete(); + }); } else { this.stopEditingText(); this.model.toggleComplete(); diff --git a/dist/flowy.unwrapped.js b/dist/flowy.unwrapped.js index 20777ee..6fee3ce 100644 --- a/dist/flowy.unwrapped.js +++ b/dist/flowy.unwrapped.js @@ -460,9 +460,11 @@ var TodoView = Backbone.View.extend({ }, toggleComplete: function() { if (this.model.get("completed")) { - this.stopEditingText(); - this.model.toggleComplete(); - this.startEditingText(); // TODO: Don't lose place + var self = this; + this._maintainingFocus(function() { + self.stopEditingText(); + self.model.toggleComplete(); + }); } else { this.stopEditingText(); this.model.toggleComplete(); diff --git a/src/views/todo.js b/src/views/todo.js index f5df801..12b9c2b 100644 --- a/src/views/todo.js +++ b/src/views/todo.js @@ -64,9 +64,11 @@ var TodoView = Backbone.View.extend({ }, toggleComplete: function() { if (this.model.get("completed")) { - this.stopEditingText(); - this.model.toggleComplete(); - this.startEditingText(); // TODO: Don't lose place + var self = this; + this._maintainingFocus(function() { + self.stopEditingText(); + self.model.toggleComplete(); + }); } else { this.stopEditingText(); this.model.toggleComplete(); -- 2.47.3