]> git.za3k.com Git - flowy.git/commitdiff
Add up and down arrow keys, fixed some things around the end of the list
authorZachary Vance <vanceza@gmail.com>
Sat, 23 May 2015 00:57:43 +0000 (17:57 -0700)
committerZachary Vance <vanceza@gmail.com>
Sat, 23 May 2015 00:57:43 +0000 (17:57 -0700)
dist/flowy.css
dist/flowy.js
dist/flowy.unwrapped.js
src/css/flowy.less
src/models/todo.js
src/views/app.js
src/views/todo.js

index d931a5239c08024a5de091880263ac6da231167d..1ae3cd256c9a265c646dd2a4b274bc742fe3cb58 100644 (file)
@@ -12,6 +12,7 @@ body {
   padding-right: 60px;
   padding-left: 60px;
   background: #ffffff;
+  min-height: 552px;
 }
 .todo > .text {
   font-size: 20pt;
index 876950d4056b232044edce1dcb3d041c12460467..0542e72bd6f8633750075f3a325ca6bac416c83c 100644 (file)
@@ -404,9 +404,8 @@ var TodoView = Backbone.View.extend({
     'Shortcut("toggleComplete", "Complete", "ctrl+enter") > .text': "toggleComplete",
     'Shortcut("backspace", "Combine an item with the previous item", "backspace") > .text': "backspace",
     'Shortcut("delete", "Combine an item with the next item", "del") > .text': "delete",
-    //'Shortcut("next", "Next", "down") > .text': 'next',
-    //'Shortcut("previous", "Previous", "previous") > .text': 'previous',
-
+    'Shortcut("next", "Next", "down") > .text': 'next',
+    'Shortcut("previous", "Previous", "up") > .text': 'previous',
   },
   initialize: function() {
     this.childViewPositions = [];
@@ -450,12 +449,26 @@ var TodoView = Backbone.View.extend({
     } else {
         this.stopEditingText();
         this.model.toggleComplete();
-        var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false});
+        var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false}) || this.model.getParent(this.model.collection);
         if (!next) return false;
         next.getView().startEditingText();
     }
     return false; // Don't propogate
   },
+  next: function() {
+    var nextNode = this.model.nextNode(this.model.collection, { childrenAllowed: true });
+    if (!nextNode) return false;
+    this.stopEditingText();
+    nextNode.getView().startEditingText();
+    return false;
+  },
+  previous: function() {
+    var previousNode = this.model.previousNode(this.model.collection, { childrenAllowed: true });
+    if (!previousNode) return false;
+    this.stopEditingText();
+    previousNode.getView().startEditingText();
+    return false;
+  },
   backspace: function() {
     if (this.model.hasChildren()) {
         return;
@@ -625,7 +638,7 @@ var TodoModel = Backbone.Model.extend({
         return parent.getChild(collection, index + 1);
     },
     nextNode: function(collection, options) {
-        options = _.defaults({}, options, {"childrenAllowed": true});
+        options = _.defaults({}, options, {childrenAllowed: true});
         if (options.childrenAllowed) {
             if (this.hasChildren()) {
                 return this.getChild(collection, 0);
@@ -637,8 +650,16 @@ var TodoModel = Backbone.Model.extend({
         }
         return undefined;
     },
-    previousNode: function(collection) {
-        var previous = this.getPreviousSibling(collection) || this.getParent(collection);
+    previousNode: function(collection, options) {
+        options = _.defaults({}, options, {childrenAllowed: true});
+        var previous = this.getPreviousSibling(collection);
+        if (previous && options.childrenAllowed) {
+            while (previous.hasChildren()) {
+                previous = previous.getChild(collection, previous.getChildrenCount() - 1);
+            }
+        }
+        if (!previous) previous = this.getParent(collection);
+        if (!previous) return undefined;
         if (previous.id === collection.rootId) {
             return undefined;
         } else {
@@ -771,7 +792,7 @@ var testTodos = [
         parent: 0,
         id: 5,
         text: "To do this year",
-        collapsed: true,
+        collapsed: false,
         bullets: [6],
     }),
     new TodoModel({
@@ -811,7 +832,7 @@ var AppView = Backbone.View.extend({
                 e.save();
             });
         });
-        Shortcut.bindShortcutsDisplay(this.$("#shortcuts-wrapper")[0], {allowRebind: true, noDisplay: ['backspace', 'delete'] });
+        Shortcut.bindShortcutsDisplay(this.$("#shortcuts-wrapper")[0], {allowRebind: true, noDisplay: ['backspace', 'delete', 'next', 'previous'] });
         this.views = {}; // A list of views for each element in the collection
         this.list.fetch();
         this.render();
index 6ddd069e16b59412d34b71a93f08dae393121206..7aa17612d20bfe525a5eb5101f0b344e8882e336 100644 (file)
@@ -403,9 +403,8 @@ var TodoView = Backbone.View.extend({
     'Shortcut("toggleComplete", "Complete", "ctrl+enter") > .text': "toggleComplete",
     'Shortcut("backspace", "Combine an item with the previous item", "backspace") > .text': "backspace",
     'Shortcut("delete", "Combine an item with the next item", "del") > .text': "delete",
-    //'Shortcut("next", "Next", "down") > .text': 'next',
-    //'Shortcut("previous", "Previous", "previous") > .text': 'previous',
-
+    'Shortcut("next", "Next", "down") > .text': 'next',
+    'Shortcut("previous", "Previous", "up") > .text': 'previous',
   },
   initialize: function() {
     this.childViewPositions = [];
@@ -449,12 +448,26 @@ var TodoView = Backbone.View.extend({
     } else {
         this.stopEditingText();
         this.model.toggleComplete();
-        var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false});
+        var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false}) || this.model.getParent(this.model.collection);
         if (!next) return false;
         next.getView().startEditingText();
     }
     return false; // Don't propogate
   },
+  next: function() {
+    var nextNode = this.model.nextNode(this.model.collection, { childrenAllowed: true });
+    if (!nextNode) return false;
+    this.stopEditingText();
+    nextNode.getView().startEditingText();
+    return false;
+  },
+  previous: function() {
+    var previousNode = this.model.previousNode(this.model.collection, { childrenAllowed: true });
+    if (!previousNode) return false;
+    this.stopEditingText();
+    previousNode.getView().startEditingText();
+    return false;
+  },
   backspace: function() {
     if (this.model.hasChildren()) {
         return;
@@ -624,7 +637,7 @@ var TodoModel = Backbone.Model.extend({
         return parent.getChild(collection, index + 1);
     },
     nextNode: function(collection, options) {
-        options = _.defaults({}, options, {"childrenAllowed": true});
+        options = _.defaults({}, options, {childrenAllowed: true});
         if (options.childrenAllowed) {
             if (this.hasChildren()) {
                 return this.getChild(collection, 0);
@@ -636,8 +649,16 @@ var TodoModel = Backbone.Model.extend({
         }
         return undefined;
     },
-    previousNode: function(collection) {
-        var previous = this.getPreviousSibling(collection) || this.getParent(collection);
+    previousNode: function(collection, options) {
+        options = _.defaults({}, options, {childrenAllowed: true});
+        var previous = this.getPreviousSibling(collection);
+        if (previous && options.childrenAllowed) {
+            while (previous.hasChildren()) {
+                previous = previous.getChild(collection, previous.getChildrenCount() - 1);
+            }
+        }
+        if (!previous) previous = this.getParent(collection);
+        if (!previous) return undefined;
         if (previous.id === collection.rootId) {
             return undefined;
         } else {
@@ -770,7 +791,7 @@ var testTodos = [
         parent: 0,
         id: 5,
         text: "To do this year",
-        collapsed: true,
+        collapsed: false,
         bullets: [6],
     }),
     new TodoModel({
@@ -810,7 +831,7 @@ var AppView = Backbone.View.extend({
                 e.save();
             });
         });
-        Shortcut.bindShortcutsDisplay(this.$("#shortcuts-wrapper")[0], {allowRebind: true, noDisplay: ['backspace', 'delete'] });
+        Shortcut.bindShortcutsDisplay(this.$("#shortcuts-wrapper")[0], {allowRebind: true, noDisplay: ['backspace', 'delete', 'next', 'previous'] });
         this.views = {}; // A list of views for each element in the collection
         this.list.fetch();
         this.render();
index 5d03024a4b15bc7d8abc24033ccd01cf30ea6336..9092e00d1b2da9ada9226732b9d7ae0d1a45459a 100644 (file)
@@ -13,6 +13,7 @@ body {
     padding-right: 60px;
     padding-left: 60px;
     background: #ffffff;
+    min-height: 552px;
 }
 
 .todo > .text {
index 08b0410bd957d0963d108f714e29eea9537032f4..c33a2cfa9107711aacf308e2fbbe625863812951 100644 (file)
@@ -50,7 +50,7 @@ var TodoModel = Backbone.Model.extend({
         return parent.getChild(collection, index + 1);
     },
     nextNode: function(collection, options) {
-        options = _.defaults({}, options, {"childrenAllowed": true});
+        options = _.defaults({}, options, {childrenAllowed: true});
         if (options.childrenAllowed) {
             if (this.hasChildren()) {
                 return this.getChild(collection, 0);
@@ -62,8 +62,16 @@ var TodoModel = Backbone.Model.extend({
         }
         return undefined;
     },
-    previousNode: function(collection) {
-        var previous = this.getPreviousSibling(collection) || this.getParent(collection);
+    previousNode: function(collection, options) {
+        options = _.defaults({}, options, {childrenAllowed: true});
+        var previous = this.getPreviousSibling(collection);
+        if (previous && options.childrenAllowed) {
+            while (previous.hasChildren()) {
+                previous = previous.getChild(collection, previous.getChildrenCount() - 1);
+            }
+        }
+        if (!previous) previous = this.getParent(collection);
+        if (!previous) return undefined;
         if (previous.id === collection.rootId) {
             return undefined;
         } else {
index ca9cd2980022ff28ef94e228a2ccb5c5bfec5b8d..ee325d853586862a5269e5384de573dbb66c6833 100644 (file)
@@ -39,7 +39,7 @@ var testTodos = [
         parent: 0,
         id: 5,
         text: "To do this year",
-        collapsed: true,
+        collapsed: false,
         bullets: [6],
     }),
     new TodoModel({
@@ -79,7 +79,7 @@ var AppView = Backbone.View.extend({
                 e.save();
             });
         });
-        Shortcut.bindShortcutsDisplay(this.$("#shortcuts-wrapper")[0], {allowRebind: true, noDisplay: ['backspace', 'delete'] });
+        Shortcut.bindShortcutsDisplay(this.$("#shortcuts-wrapper")[0], {allowRebind: true, noDisplay: ['backspace', 'delete', 'next', 'previous'] });
         this.views = {}; // A list of views for each element in the collection
         this.list.fetch();
         this.render();
index 03a6a4465ed9ccd9a092e8c1e20ee8c5813f4e5d..e4be2e5d0b2139b65f936d0ed210ebc5866272c4 100644 (file)
@@ -14,9 +14,8 @@ var TodoView = Backbone.View.extend({
     'Shortcut("toggleComplete", "Complete", "ctrl+enter") > .text': "toggleComplete",
     'Shortcut("backspace", "Combine an item with the previous item", "backspace") > .text': "backspace",
     'Shortcut("delete", "Combine an item with the next item", "del") > .text': "delete",
-    //'Shortcut("next", "Next", "down") > .text': 'next',
-    //'Shortcut("previous", "Previous", "previous") > .text': 'previous',
-
+    'Shortcut("next", "Next", "down") > .text': 'next',
+    'Shortcut("previous", "Previous", "up") > .text': 'previous',
   },
   initialize: function() {
     this.childViewPositions = [];
@@ -60,12 +59,26 @@ var TodoView = Backbone.View.extend({
     } else {
         this.stopEditingText();
         this.model.toggleComplete();
-        var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false});
+        var next = this.model.nextNode(this.model.collection, {"childrenAllowed":false}) || this.model.getParent(this.model.collection);
         if (!next) return false;
         next.getView().startEditingText();
     }
     return false; // Don't propogate
   },
+  next: function() {
+    var nextNode = this.model.nextNode(this.model.collection, { childrenAllowed: true });
+    if (!nextNode) return false;
+    this.stopEditingText();
+    nextNode.getView().startEditingText();
+    return false;
+  },
+  previous: function() {
+    var previousNode = this.model.previousNode(this.model.collection, { childrenAllowed: true });
+    if (!previousNode) return false;
+    this.stopEditingText();
+    previousNode.getView().startEditingText();
+    return false;
+  },
   backspace: function() {
     if (this.model.hasChildren()) {
         return;