From afca7c5643fa567e2f7e0228a980f6d746249adb Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 22 Dec 2015 23:06:41 -0500 Subject: [PATCH] Prevent most keyboard shortcuts during walkthrough (If hit accidently these can really get a user stuck) --- js/id/behavior/copy.js | 1 + js/id/behavior/paste.js | 1 + js/id/modes/select.js | 6 ++++-- js/id/ui.js | 2 +- js/id/ui/undo_redo.js | 4 ++-- js/id/ui/zoom.js | 8 ++++---- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/js/id/behavior/copy.js b/js/id/behavior/copy.js index f2483ebda..1061958b7 100644 --- a/js/id/behavior/copy.js +++ b/js/id/behavior/copy.js @@ -33,6 +33,7 @@ iD.behavior.Copy = function(context) { function doCopy() { d3.event.preventDefault(); + if (context.inIntro()) return; var graph = context.graph(), selected = groupEntities(context.selectedIDs(), graph), diff --git a/js/id/behavior/paste.js b/js/id/behavior/paste.js index 7956e26b4..5d4a71a2b 100644 --- a/js/id/behavior/paste.js +++ b/js/id/behavior/paste.js @@ -19,6 +19,7 @@ iD.behavior.Paste = function(context) { function doPaste() { d3.event.preventDefault(); + if (context.inIntro()) return; var mouse = context.mouse(), projection = context.projection, diff --git a/js/id/modes/select.js b/js/id/modes/select.js index bef505e0a..56e93988e 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -147,7 +147,9 @@ iD.modes.Select = function(context, selectedIDs) { } function ret() { - context.enter(iD.modes.Browse(context)); + if (!context.inIntro()) { + context.enter(iD.modes.Browse(context)); + } } @@ -169,7 +171,7 @@ iD.modes.Select = function(context, selectedIDs) { operations.forEach(function(operation) { operation.keys.forEach(function(key) { keybinding.on(key, function() { - if (!operation.disabled()) { + if (!(context.inIntro() || operation.disabled())) { operation(); } }); diff --git a/js/id/ui.js b/js/id/ui.js index 42cd8ffd0..986decc64 100644 --- a/js/id/ui.js +++ b/js/id/ui.js @@ -176,7 +176,7 @@ iD.ui = function(context) { function pan(d) { return function() { d3.event.preventDefault(); - context.pan(d); + if (!context.inIntro()) context.pan(d); }; } diff --git a/js/id/ui/undo_redo.js b/js/id/ui/undo_redo.js index a5cfa7122..7064d5d9e 100644 --- a/js/id/ui/undo_redo.js +++ b/js/id/ui/undo_redo.js @@ -2,12 +2,12 @@ iD.ui.UndoRedo = function(context) { var commands = [{ id: 'undo', cmd: iD.ui.cmd('⌘Z'), - action: function() { if (!saving()) context.undo(); }, + action: function() { if (!(context.inIntro() || saving())) context.undo(); }, annotation: function() { return context.history().undoAnnotation(); } }, { id: 'redo', cmd: iD.ui.cmd('⌘⇧Z'), - action: function() { if (!saving()) context.redo(); }, + action: function() {if (!(context.inIntro() || saving())) context.redo(); }, annotation: function() { return context.history().redoAnnotation(); } }]; diff --git a/js/id/ui/zoom.js b/js/id/ui/zoom.js index 4fb71b4b3..b163b4160 100644 --- a/js/id/ui/zoom.js +++ b/js/id/ui/zoom.js @@ -15,22 +15,22 @@ iD.ui.Zoom = function(context) { function zoomIn() { d3.event.preventDefault(); - context.zoomIn(); + if (!context.inIntro()) context.zoomIn(); } function zoomOut() { d3.event.preventDefault(); - context.zoomOut(); + if (!context.inIntro()) context.zoomOut(); } function zoomInFurther() { d3.event.preventDefault(); - context.zoomInFurther(); + if (!context.inIntro()) context.zoomInFurther(); } function zoomOutFurther() { d3.event.preventDefault(); - context.zoomOutFurther(); + if (!context.inIntro()) context.zoomOutFurther(); }