From b7bb8213ba9cfa49ab0a0bf9308319146f1cc55d Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Fri, 12 Jun 2020 13:10:15 -0400 Subject: [PATCH] Flash the disabled message for touch interaction for the save button (re: #7699) Don't flash undo/redo tooltip text when the map isn't editable --- modules/ui/tools/save.js | 24 +++++++++++++++++++++++- modules/ui/tools/undo_redo.js | 6 ++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/modules/ui/tools/save.js b/modules/ui/tools/save.js index 4b6573c89..001cdd3a7 100644 --- a/modules/ui/tools/save.js +++ b/modules/ui/tools/save.js @@ -80,10 +80,32 @@ export function uiToolSave(context) { .keys([key]) .scrollContainer(context.container().select('.top-toolbar')); + var lastPointerUpType; + button = selection .append('button') .attr('class', 'save disabled bar-button') - .on('click', save) + .on('pointerup', function() { + lastPointerUpType = d3_event.pointerType; + }) + .on('click', function() { + d3_event.preventDefault(); + + save(); + + if (_numChanges === 0 && ( + lastPointerUpType === 'touch' || + lastPointerUpType === 'pen') + ) { + // there are no tooltips for touch interactions so flash feedback instead + context.ui().flash + .duration(2000) + .iconName('#iD-icon-save') + .iconClass('disabled') + .text(t('save.no_changes'))(); + } + lastPointerUpType = null; + }) .call(tooltipBehavior); button diff --git a/modules/ui/tools/undo_redo.js b/modules/ui/tools/undo_redo.js index e62b6144b..cb7b38540 100644 --- a/modules/ui/tools/undo_redo.js +++ b/modules/ui/tools/undo_redo.js @@ -79,8 +79,10 @@ export function uiToolUndoRedo(context) { d.action(); } - if (lastPointerUpType === 'touch' || - lastPointerUpType === 'pen') { + if (editable() && ( + lastPointerUpType === 'touch' || + lastPointerUpType === 'pen') + ) { // there are no tooltips for touch interactions so flash feedback instead var text = annotation ?