Move keybindings from map panes to uiInit

This commit is contained in:
Quincy Morgan
2020-03-25 13:59:09 -07:00
parent 9731b93cec
commit ad327befc7
3 changed files with 39 additions and 52 deletions
+39 -1
View File
@@ -311,7 +311,45 @@ export function uiInit(context) {
.on(['⇧←', uiCmd('⌘←')], pan([map.dimensions()[0], 0]))
.on(['⇧↑', uiCmd('⌘↑')], pan([0, map.dimensions()[1]]))
.on(['⇧→', uiCmd('⌘→')], pan([-map.dimensions()[0], 0]))
.on(['⇧↓', uiCmd('⌘↓')], pan([0, -map.dimensions()[1]]));
.on(['⇧↓', uiCmd('⌘↓')], pan([0, -map.dimensions()[1]]))
.on(uiCmd('⌘' + t('background.key')), function quickSwitch() {
if (d3_event) {
d3_event.stopImmediatePropagation();
d3_event.preventDefault();
}
var previousBackground = context.background().findSource(context.storage('background-last-used-toggle'));
if (previousBackground) {
var currentBackground = context.background().baseLayerSource();
context.storage('background-last-used-toggle', currentBackground.id);
context.storage('background-last-used', previousBackground.id);
context.background().baseLayerSource(previousBackground);
}
})
.on(t('area_fill.wireframe.key'), function toggleWireframe() {
d3_event.preventDefault();
d3_event.stopPropagation();
context.map().toggleWireframe();
})
.on(uiCmd('⌥' + t('area_fill.wireframe.key')), function toggleOsmData() {
d3_event.preventDefault();
d3_event.stopPropagation();
// Don't allow layer changes while drawing - #6584
var mode = context.mode();
if (mode && /^draw/.test(mode.id)) return;
var layer = context.layers().layer('osm');
if (layer) {
layer.enabled(!layer.enabled());
if (!layer.enabled()) {
context.enter(modeBrowse(context));
}
}
})
.on(t('map_data.highlight_edits.key'), function toggleHighlightEdited() {
d3_event.preventDefault();
context.map().toggleHighlightEdited();
});
context.enter(modeBrowse(context));
-19
View File
@@ -1,7 +1,5 @@
import { event as d3_event } from 'd3-selection';
import { t } from '../../util/locale';
import { uiCmd } from '../cmd';
import { uiPane } from '../pane';
import { uiSectionBackgroundDisplayOptions } from '../sections/background_display_options';
@@ -11,23 +9,6 @@ import { uiSectionOverlayList } from '../sections/overlay_list';
export function uiPaneBackground(context) {
context.keybinding()
.on(uiCmd('⌘' + t('background.key')), quickSwitch);
function quickSwitch() {
if (d3_event) {
d3_event.stopImmediatePropagation();
d3_event.preventDefault();
}
var previousBackground = context.background().findSource(context.storage('background-last-used-toggle'));
if (previousBackground) {
var currentBackground = context.background().baseLayerSource();
context.storage('background-last-used-toggle', currentBackground.id);
context.storage('background-last-used', previousBackground.id);
context.background().baseLayerSource(previousBackground);
}
}
var backgroundPane = uiPane('background', context)
.key(t('background.key'))
.title(t('background.title'))
-32
View File
@@ -1,10 +1,5 @@
import {
event as d3_event
} from 'd3-selection';
import { t } from '../../util/locale';
import { modeBrowse } from '../../modes/browse';
import { uiCmd } from '../cmd';
import { uiPane } from '../pane';
import { uiSectionDataLayers } from '../sections/data_layers';
@@ -14,33 +9,6 @@ import { uiSectionPhotoOverlays } from '../sections/photo_overlays';
export function uiPaneMapData(context) {
context.keybinding()
.on(t('area_fill.wireframe.key'), function toggleWireframe() {
d3_event.preventDefault();
d3_event.stopPropagation();
context.map().toggleWireframe();
})
.on(uiCmd('⌥' + t('area_fill.wireframe.key')), function toggleOsmData() {
d3_event.preventDefault();
d3_event.stopPropagation();
// Don't allow layer changes while drawing - #6584
var mode = context.mode();
if (mode && /^draw/.test(mode.id)) return;
var layer = context.layers().layer('osm');
if (layer) {
layer.enabled(!layer.enabled());
if (!layer.enabled()) {
context.enter(modeBrowse(context));
}
}
})
.on(t('map_data.highlight_edits.key'), function toggleHighlightEdited() {
d3_event.preventDefault();
context.map().toggleHighlightEdited();
});
var mapDataPane = uiPane('map-data', context)
.key(t('map_data.key'))
.title(t('map_data.title'))