From: Zachary Vance Date: Sat, 23 May 2015 02:12:20 +0000 (-0700) Subject: Fix splitting a node in half; was messing up completed/collapsed status X-Git-Url: https://git.za3k.com/?a=commitdiff_plain;h=f671c6fa12b2b39f1c70708ec8b4d81ad23118a8;p=flowy.git Fix splitting a node in half; was messing up completed/collapsed status --- diff --git a/dist/flowy.js b/dist/flowy.js index ddb473c..35f9d0f 100644 --- a/dist/flowy.js +++ b/dist/flowy.js @@ -461,7 +461,7 @@ var TodoView = Backbone.View.extend({ if (!next) return false; next.getView().startEditingText(); } - return false; // Don't propogate + return false; }, next: function() { var nextNode = this.model.nextNode(this.model.collection, { childrenAllowed: true }); @@ -529,6 +529,8 @@ var TodoView = Backbone.View.extend({ }, expand: function() { console.log("Expand not implemented"); // TODO + this.model.toggleCollapsed(); // TODO: Display change + return false; }, zoomIn: function() { console.log("Zoom not implemented"); // TODO @@ -578,10 +580,10 @@ var TodoView = Backbone.View.extend({ this.stopEditingText(); emptyBefore.getView().startEditingText(); } else if (lines.length === 2) { // Line break in middle - var newNode = this.model.addTodoBefore({text: this.decodeText(lines[0])}, collection); - this.model.setText(this.decodeText(lines[1])); + var newNode = this.model.addTodoAfter({text: this.decodeText(lines[1])}, collection); + this.model.setText(this.decodeText(lines[0])); this.stopEditingText(); // For re-render - this.startEditingText(); // Keep focus on current node (second half) + newNode.getView().startEditingText(); // Keep focus on current node (second half) } else if (lines.length > 2) { console.log(lines.length); console.log($(e.target).html()); diff --git a/dist/flowy.unwrapped.js b/dist/flowy.unwrapped.js index 7f61de8..f6b97dc 100644 --- a/dist/flowy.unwrapped.js +++ b/dist/flowy.unwrapped.js @@ -460,7 +460,7 @@ var TodoView = Backbone.View.extend({ if (!next) return false; next.getView().startEditingText(); } - return false; // Don't propogate + return false; }, next: function() { var nextNode = this.model.nextNode(this.model.collection, { childrenAllowed: true }); @@ -528,6 +528,8 @@ var TodoView = Backbone.View.extend({ }, expand: function() { console.log("Expand not implemented"); // TODO + this.model.toggleCollapsed(); // TODO: Display change + return false; }, zoomIn: function() { console.log("Zoom not implemented"); // TODO @@ -577,10 +579,10 @@ var TodoView = Backbone.View.extend({ this.stopEditingText(); emptyBefore.getView().startEditingText(); } else if (lines.length === 2) { // Line break in middle - var newNode = this.model.addTodoBefore({text: this.decodeText(lines[0])}, collection); - this.model.setText(this.decodeText(lines[1])); + var newNode = this.model.addTodoAfter({text: this.decodeText(lines[1])}, collection); + this.model.setText(this.decodeText(lines[0])); this.stopEditingText(); // For re-render - this.startEditingText(); // Keep focus on current node (second half) + newNode.getView().startEditingText(); // Keep focus on current node (second half) } else if (lines.length > 2) { console.log(lines.length); console.log($(e.target).html()); diff --git a/src/views/todo.js b/src/views/todo.js index 91fd153..8cdaa1d 100644 --- a/src/views/todo.js +++ b/src/views/todo.js @@ -71,7 +71,7 @@ var TodoView = Backbone.View.extend({ if (!next) return false; next.getView().startEditingText(); } - return false; // Don't propogate + return false; }, next: function() { var nextNode = this.model.nextNode(this.model.collection, { childrenAllowed: true }); @@ -139,6 +139,8 @@ var TodoView = Backbone.View.extend({ }, expand: function() { console.log("Expand not implemented"); // TODO + this.model.toggleCollapsed(); // TODO: Display change + return false; }, zoomIn: function() { console.log("Zoom not implemented"); // TODO @@ -188,10 +190,10 @@ var TodoView = Backbone.View.extend({ this.stopEditingText(); emptyBefore.getView().startEditingText(); } else if (lines.length === 2) { // Line break in middle - var newNode = this.model.addTodoBefore({text: this.decodeText(lines[0])}, collection); - this.model.setText(this.decodeText(lines[1])); + var newNode = this.model.addTodoAfter({text: this.decodeText(lines[1])}, collection); + this.model.setText(this.decodeText(lines[0])); this.stopEditingText(); // For re-render - this.startEditingText(); // Keep focus on current node (second half) + newNode.getView().startEditingText(); // Keep focus on current node (second half) } else if (lines.length > 2) { console.log(lines.length); console.log($(e.target).html());