From 99565357dd9e1580a51dcb4bb46c9b17f2e92713 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Sat, 7 Mar 2015 02:13:41 -0500 Subject: [PATCH] hotkey bindings for save and open --- js/models/AppState.js | 18 +++++++++++------- js/models/Lattice.js | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/js/models/AppState.js b/js/models/AppState.js index 0933d331..61830789 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -111,8 +111,7 @@ AppState = Backbone.Model.extend({ this.downKeys[e.keyCode] = true; } else this.downKeys[e.keyCode] = false; - - console.log(e.keyCode); +// console.log(e.keyCode); switch(e.keyCode){ case 16://shift e.preventDefault(); @@ -136,11 +135,16 @@ AppState = Backbone.Model.extend({ this.lattice.set("inverseMode", !this.lattice.get("inverseMode")); break; case 83://s save -// e.preventDefault(); -// if (e.ctrlKey || e.metaKey){//command -// console.log("here"); -// dmaGlobals.lattice.saveAsJSON(); -// } + e.preventDefault(); + if (e.ctrlKey || e.metaKey){//command + dmaGlobals.lattice.saveAsJSON(); + } + break; + case 79://o open + e.preventDefault(); + if (e.ctrlKey || e.metaKey){//command + $("#jsonInput").click(); + } break; default: break; diff --git a/js/models/Lattice.js b/js/models/Lattice.js index ac221c3a..f6d6d4af 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -147,7 +147,7 @@ Lattice = Backbone.Model.extend({ //todo send clear all to three anddestroy without sceneRemove to cell clearCells: function(){ this._iterCells(this.get("cells"), function(cell){ - if (cell) cell.destroy(); + if (cell && cell.destroy) cell.destroy(); }); this.set("cells", [[[null]]]); this._clearInverseCells(); -- GitLab