]> git.za3k.com Git - flowy.git/commitdiff
Fix splitting a node in half; was messing up completed/collapsed status
authorZachary Vance <vanceza@gmail.com>
Sat, 23 May 2015 02:12:20 +0000 (19:12 -0700)
committerZachary Vance <vanceza@gmail.com>
Sat, 23 May 2015 02:12:20 +0000 (19:12 -0700)
dist/flowy.js
dist/flowy.unwrapped.js
src/views/todo.js

index ddb473c78eca7d1517b829ffd14991903804a47b..35f9d0ffadfbd5fa9140343e271a432f80f35b1e 100644 (file)
@@ -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());
index 7f61de89982e0389d8f4228e5ac6c334a1fcba9c..f6b97dcab5ea1948c91acb5f617e38e5978d1dbe 100644 (file)
@@ -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());
index 91fd153706b5110cf7ffecf10bdaa32e296b54a5..8cdaa1dbfee36f7358898f9205840364c8ce079a 100644 (file)
@@ -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());