From a6abbb0d71f605af7f9b0f752143fddbce8b924b Mon Sep 17 00:00:00 2001 From: Zachary Vance Date: Fri, 22 May 2015 19:31:24 -0700 Subject: [PATCH] Add reverse-engineering comments --- dist/flowy.js | 18 +++++++++++++++++- dist/flowy.unwrapped.js | 18 +++++++++++++++++- src/views/todo.js | 18 +++++++++++++++++- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/dist/flowy.js b/dist/flowy.js index 35f9d0f..b99ef65 100644 --- a/dist/flowy.js +++ b/dist/flowy.js @@ -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(); diff --git a/dist/flowy.unwrapped.js b/dist/flowy.unwrapped.js index f6b97dc..acfa2a6 100644 --- a/dist/flowy.unwrapped.js +++ b/dist/flowy.unwrapped.js @@ -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(); diff --git a/src/views/todo.js b/src/views/todo.js index 8cdaa1d..56feefd 100644 --- a/src/views/todo.js +++ b/src/views/todo.js @@ -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(); -- 2.47.3