]> git.za3k.com Git - flowy.git/commitdiff
Add reverse-engineering comments
authorZachary Vance <vanceza@gmail.com>
Sat, 23 May 2015 02:31:24 +0000 (19:31 -0700)
committerZachary Vance <vanceza@gmail.com>
Sat, 23 May 2015 02:31:24 +0000 (19:31 -0700)
dist/flowy.js
dist/flowy.unwrapped.js
src/views/todo.js

index 35f9d0ffadfbd5fa9140343e271a432f80f35b1e..b99ef65beee2520dff517988aa0ed10f741a43bb 100644 (file)
@@ -519,13 +519,18 @@ var TodoView = Backbone.View.extend({
     }   
   },
   "delete": function() {
+    // Delete node and its entire subtree
     console.log("Delete not implemented"); // TODO
   },
   indent: function() {
+    // Last child of previous sibling, then nothing
     console.log("Indent not implemented"); // TODO
+    this.moveTo({keyboard:true});
   },
   outdent: function() {
+    // After parent, then nothing
     console.log("Outdent not implemented"); // TODO
+    this.moveTo({keyboard:true});
   },
   expand: function() {
     console.log("Expand not implemented"); // TODO
@@ -539,10 +544,22 @@ var TodoView = Backbone.View.extend({
     console.log("Zoom not implemented"); // TODO
   },
   moveDown: function() {
+    // After next sibling, then as first child of next node after parent, then up one level, then nothing
     console.log("Move not implemented"); // TODO
+    this.moveTo({keyboard:true});
   },
   moveUp: function() {
+    // Before previous sibling, then as last child of previous node of parent, then before parent, then nothing
     console.log("Move not implemented"); // TODO
+    this.moveTo({keyboard:true});
+  },
+  moveTo: function(loc, options) {
+    loc = _.defaults({}, loc, { parent: this.model.getParent(this.model.collection), index: this.model.getParent(this.model.collection).findChild(this.model.id) });
+    options = _.defaults({}, options, { 
+        keyboard: false, // Whether the action was done with keyboard vs mouse (affects UI focus)
+    });
+    console.log("Move not implemented");
+    return false;
   },
   textChange: function(e) {
     var collection = this.model.collection;
@@ -564,7 +581,6 @@ var TodoView = Backbone.View.extend({
     //  - If there are children, make the new node the first child. Focus the second node.
     // NOTE: Copy-paste is overridden so there can't be more than one line break.
     // NOTE: Shift-enter is overridden and handled seperately, to allow "notes" spanning multiple lines.
-    // NOTE: Line break on empty bullet should shift it up the tree for perfect imitation; this is stupid so I ignored it.
      } else if ((lines.length === 2 && lines[0] === "" && lines[1] === "") || (lines.length === 3 && lines[0] === "" && lines[1] === "" && lines[2] === "")) { // Enter pressed on empty line
         this.model.setText(this.decodeText(lines[0]));
         this.stopEditingText();
index f6b97dcab5ea1948c91acb5f617e38e5978d1dbe..acfa2a68a0d7d756d95eb02f5b1d63fc947e92c4 100644 (file)
@@ -518,13 +518,18 @@ var TodoView = Backbone.View.extend({
     }   
   },
   "delete": function() {
+    // Delete node and its entire subtree
     console.log("Delete not implemented"); // TODO
   },
   indent: function() {
+    // Last child of previous sibling, then nothing
     console.log("Indent not implemented"); // TODO
+    this.moveTo({keyboard:true});
   },
   outdent: function() {
+    // After parent, then nothing
     console.log("Outdent not implemented"); // TODO
+    this.moveTo({keyboard:true});
   },
   expand: function() {
     console.log("Expand not implemented"); // TODO
@@ -538,10 +543,22 @@ var TodoView = Backbone.View.extend({
     console.log("Zoom not implemented"); // TODO
   },
   moveDown: function() {
+    // After next sibling, then as first child of next node after parent, then up one level, then nothing
     console.log("Move not implemented"); // TODO
+    this.moveTo({keyboard:true});
   },
   moveUp: function() {
+    // Before previous sibling, then as last child of previous node of parent, then before parent, then nothing
     console.log("Move not implemented"); // TODO
+    this.moveTo({keyboard:true});
+  },
+  moveTo: function(loc, options) {
+    loc = _.defaults({}, loc, { parent: this.model.getParent(this.model.collection), index: this.model.getParent(this.model.collection).findChild(this.model.id) });
+    options = _.defaults({}, options, { 
+        keyboard: false, // Whether the action was done with keyboard vs mouse (affects UI focus)
+    });
+    console.log("Move not implemented");
+    return false;
   },
   textChange: function(e) {
     var collection = this.model.collection;
@@ -563,7 +580,6 @@ var TodoView = Backbone.View.extend({
     //  - If there are children, make the new node the first child. Focus the second node.
     // NOTE: Copy-paste is overridden so there can't be more than one line break.
     // NOTE: Shift-enter is overridden and handled seperately, to allow "notes" spanning multiple lines.
-    // NOTE: Line break on empty bullet should shift it up the tree for perfect imitation; this is stupid so I ignored it.
      } else if ((lines.length === 2 && lines[0] === "" && lines[1] === "") || (lines.length === 3 && lines[0] === "" && lines[1] === "" && lines[2] === "")) { // Enter pressed on empty line
         this.model.setText(this.decodeText(lines[0]));
         this.stopEditingText();
index 8cdaa1dbfee36f7358898f9205840364c8ce079a..56feefd269e973df0d2d409851a072dbfba7ad7a 100644 (file)
@@ -129,13 +129,18 @@ var TodoView = Backbone.View.extend({
     }   
   },
   "delete": function() {
+    // Delete node and its entire subtree
     console.log("Delete not implemented"); // TODO
   },
   indent: function() {
+    // Last child of previous sibling, then nothing
     console.log("Indent not implemented"); // TODO
+    this.moveTo({keyboard:true});
   },
   outdent: function() {
+    // After parent, then nothing
     console.log("Outdent not implemented"); // TODO
+    this.moveTo({keyboard:true});
   },
   expand: function() {
     console.log("Expand not implemented"); // TODO
@@ -149,10 +154,22 @@ var TodoView = Backbone.View.extend({
     console.log("Zoom not implemented"); // TODO
   },
   moveDown: function() {
+    // After next sibling, then as first child of next node after parent, then up one level, then nothing
     console.log("Move not implemented"); // TODO
+    this.moveTo({keyboard:true});
   },
   moveUp: function() {
+    // Before previous sibling, then as last child of previous node of parent, then before parent, then nothing
     console.log("Move not implemented"); // TODO
+    this.moveTo({keyboard:true});
+  },
+  moveTo: function(loc, options) {
+    loc = _.defaults({}, loc, { parent: this.model.getParent(this.model.collection), index: this.model.getParent(this.model.collection).findChild(this.model.id) });
+    options = _.defaults({}, options, { 
+        keyboard: false, // Whether the action was done with keyboard vs mouse (affects UI focus)
+    });
+    console.log("Move not implemented");
+    return false;
   },
   textChange: function(e) {
     var collection = this.model.collection;
@@ -174,7 +191,6 @@ var TodoView = Backbone.View.extend({
     //  - If there are children, make the new node the first child. Focus the second node.
     // NOTE: Copy-paste is overridden so there can't be more than one line break.
     // NOTE: Shift-enter is overridden and handled seperately, to allow "notes" spanning multiple lines.
-    // NOTE: Line break on empty bullet should shift it up the tree for perfect imitation; this is stupid so I ignored it.
      } else if ((lines.length === 2 && lines[0] === "" && lines[1] === "") || (lines.length === 3 && lines[0] === "" && lines[1] === "" && lines[2] === "")) { // Enter pressed on empty line
         this.model.setText(this.decodeText(lines[0]));
         this.stopEditingText();