diff --git a/css/80_app.css b/css/80_app.css index 834b99137..3f0b6f13c 100644 --- a/css/80_app.css +++ b/css/80_app.css @@ -3096,7 +3096,7 @@ img.tile-removing { .modal-shortcuts .tabs-bar { text-align: center; - padding-bottom: 20px; + padding-bottom: 10px; } .modal-shortcuts .tab { @@ -3118,20 +3118,23 @@ img.tile-removing { } .modal-shortcuts .kbd-row { + display: inline-block; padding-right: 10px; color: #767676; text-align: right; white-space: nowrap; padding-bottom: 3px; + } -.modal-shortcuts .shorctut-desc { +.modal-shortcuts .shortcut-desc { + display: inline-block; padding-bottom: 3px; } .modal-shortcuts kbd { display: inline-block; text-align: right; padding: 3px 5px; - font: 11px; + font-size: 11px; line-height: 10px; letter-spacing: 1px; color: #555; diff --git a/dist/locales/en.json b/dist/locales/en.json index d00bcd664..ebacea12e 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -883,6 +883,33 @@ "start": "Start mapping!" } }, + "shortcuts": { + "display": { + "desc": "Display", + "pan_map": "Pan map", + "pan_map_screen": "Pan map by one screenful", + "zoom": "Zoom in / Zoom out", + "zoom_large": "Zoom in / Zoom out by a lot", + "bg_switcher": "Display background layer switcher", + "bg": "Switch between backgrounds", + "wireframe": "Toggle wireframe mode", + "help": "Show in-editor help/documentation", + "minimap": "Toggle minimap", + "infobox": "Toggle info/measurements box", + "radial_menu": "Toggle radial menu for selected object" + }, + "edit": { + "desc": "Editing", + "add_point": "Switch to 'add point' mode", + "add_line": "Switch to 'add line' mode", + "add_area": "Switch to 'add area' mode", + "continue_line": "Continue drawing a line at the selected node", + "stop_line": "Stop drawing of a line or area", + "undo": "Undo last action", + "redo": "Redo last action", + "save": "Save changes" + } + }, "presets": { "categories": { "category-barrier": { diff --git a/modules/ui/shortcuts.js b/modules/ui/shortcuts.js index 758564888..1c40208a5 100644 --- a/modules/ui/shortcuts.js +++ b/modules/ui/shortcuts.js @@ -5,12 +5,34 @@ import { d3keybinding } from '../lib/d3.keybinding.js'; import { t } from '../util/locale'; import { shortcuts as shortcutsData } from '../../data'; -export function uiShortcuts(context) { +export function uiShortcuts() { var key = uiCmd('⇧/'); var activeTab = 0; + function shortcuts(selection) { - if (!d3.selectAll('.modal').empty()) return; var modalSelection; + + function show() { + modalSelection = uiModal(selection); + + modalSelection.select('.modal') + .attr('class', 'modal fillL col6'); + + var shortcutsModal = modalSelection.select('.content'); + + shortcutsModal + .attr('class', 'cf modal-shortcuts'); + + shortcutsModal + .append('div') + .attr('class', 'modal-section') + .append('h3') + .text('Keyboard shortcuts'); + + shortcutsModal + .call(render); + } + function render(selection) { var wrapper = selection .selectAll('.wrapper') @@ -57,6 +79,7 @@ export function uiShortcuts(context) { return i === activeTab; }); + var shortcuts = shortcutsList .selectAll('.shortcut-tab') .data(shortcutsData); @@ -84,81 +107,34 @@ export function uiShortcuts(context) { shortcutsRow .selectAll('kbd') .data(function (d) { return d.shortcut; }) - .enter().append('kbd') - .text(function (d) { return uiCmd(d); }); + .enter() + .append('kbd') + .text(function (d) { return d; }); - var description = row + row .append('div') - .attr('class', 'shorctut-desc col6') + .attr('class', 'shortcut-desc ') .text(function (d) { return t(d.key); }); shortcuts = shortcuts .merge(shortcutsEnter); + // Update wrapper.selectAll('.shortcut-tab') .style('display', function (d, i) { return i === activeTab ? 'block' : 'none'; }); - - } - function show() { - if (!d3.selectAll('.modal').empty()) return; - - modalSelection = uiModal(selection); - - modalSelection.select('.modal') - .attr('class', 'modal fillL col6'); - - var shortcutsModal = modalSelection.select('.content'); - - shortcutsModal - .attr('class', 'cf modal-shortcuts'); - - shortcutsModal - .append('div') - .attr('class', 'modal-section') - .append('h3') - .text('Keyboard shortcuts'); - - // var wrap = shortcutsModal.selectAll('.wrapper') - // - .data([0]); - - // wrap = wrap.enter() - // .append('div') - // .attr('class', 'preset-input-wrap') - // .merge(wrap); - shortcutsModal.call(render); - - - // section - // .append('h4') - // .text(function(d) { return t(d.desc); }); - - // var row = section - // .selectAll('.shortcut-row') - // .data(function(d) { return d.shortcuts; }) - // .enter() - // .append('div') - // .attr('class', 'shortcut-row'); - - // var shortcuts = row - // .append('div') - // .attr('class', 'kbd-row col4'); - - // shortcuts - // .selectAll('kbd') - // .data(function(d) { return d.shortcut; }) - // .enter().append('kbd') - // .text(function(d) { return uiCmd(d); }); - - // var description = row - // .append('div') - // .attr('class', 'shorctut-desc col6') - // .text(function(d) { return t(d.key); }); } var keybinding = d3keybinding('shortcuts') - .on(key, show); + .on(key, function () { + if (modalSelection) { + modalSelection.close(); + modalSelection = null; + return; + } + show(); + }); d3.select(document) .call(keybinding);