mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 17:23:02 +00:00
Don't instantiate uiShortcuts or its keybinding multiple times
This commit is contained in:
@@ -418,7 +418,7 @@ export function uiInit(context) {
|
||||
}
|
||||
|
||||
context.container()
|
||||
.call(uiShortcuts(context));
|
||||
.call(ui.shortcuts);
|
||||
}
|
||||
|
||||
var osm = context.connection();
|
||||
@@ -499,6 +499,8 @@ export function uiInit(context) {
|
||||
|
||||
ui.photoviewer = uiPhotoviewer(context);
|
||||
|
||||
ui.shortcuts = uiShortcuts(context);
|
||||
|
||||
ui.onResize = function(withPan) {
|
||||
var map = context.map();
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import { event as d3_event } from 'd3-selection';
|
||||
import marked from 'marked';
|
||||
import { svgIcon } from '../../svg/icon';
|
||||
import { uiIntro } from '../intro/intro';
|
||||
import { uiShortcuts } from '../shortcuts';
|
||||
import { uiPane } from '../pane';
|
||||
|
||||
import { t, localizer } from '../../core/localizer';
|
||||
@@ -353,7 +352,7 @@ export function uiPaneHelp(context) {
|
||||
|
||||
function clickShortcuts() {
|
||||
d3_event.preventDefault();
|
||||
context.container().call(uiShortcuts(context), true);
|
||||
context.container().call(context.ui().shortcuts, true);
|
||||
}
|
||||
|
||||
var toc = content
|
||||
|
||||
@@ -16,20 +16,6 @@ export function uiShortcuts(context) {
|
||||
var _selection = d3_select(null);
|
||||
|
||||
|
||||
context.keybinding()
|
||||
.on([t('shortcuts.toggle.key'), '?'], function () {
|
||||
if (context.container().selectAll('.modal-shortcuts').size()) { // already showing
|
||||
if (_modalSelection) {
|
||||
_modalSelection.close();
|
||||
_modalSelection = null;
|
||||
}
|
||||
} else {
|
||||
_modalSelection = uiModal(_selection);
|
||||
_modalSelection.call(shortcutsModal);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function shortcutsModal(_modalSelection) {
|
||||
_modalSelection.select('.modal')
|
||||
.classed('modal-shortcuts', true);
|
||||
@@ -264,6 +250,19 @@ export function uiShortcuts(context) {
|
||||
if (show) {
|
||||
_modalSelection = uiModal(selection);
|
||||
_modalSelection.call(shortcutsModal);
|
||||
} else {
|
||||
context.keybinding()
|
||||
.on([t('shortcuts.toggle.key'), '?'], function () {
|
||||
if (context.container().selectAll('.modal-shortcuts').size()) { // already showing
|
||||
if (_modalSelection) {
|
||||
_modalSelection.close();
|
||||
_modalSelection = null;
|
||||
}
|
||||
} else {
|
||||
_modalSelection = uiModal(_selection);
|
||||
_modalSelection.call(shortcutsModal);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user