mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-20 18:13:30 +00:00
Consolidate localization behavior and init to a coreLocalizer function and singleton Explicitly support `en-US` locale Rename coreData to coreFileFetcher and export a singleton rather than using a property of coreContext Add `apiConnections` property of coreContext to simplify adding a source switcher Replace some init functions with re-callable, promise-supporting `ensureLoaded` functions Make coreContext itself load the UI if a container has been specified at init time Fix code tests
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import { select as d3_select } from 'd3-selection';
|
|
|
|
import { t, localizer } from '../core/localizer';
|
|
import { uiTooltip } from './tooltip';
|
|
import { svgIcon } from '../svg/icon';
|
|
|
|
export function uiZoomToSelection(context) {
|
|
|
|
var _button = d3_select(null);
|
|
|
|
function click() {
|
|
if (d3_select(this).classed('disabled')) return;
|
|
|
|
var mode = context.mode();
|
|
if (mode && mode.zoomToSelected) {
|
|
mode.zoomToSelected();
|
|
}
|
|
}
|
|
|
|
function setEnabledState() {
|
|
var mode = context.mode();
|
|
var isEnabled = mode && !!mode.zoomToSelected;
|
|
_button.classed('disabled', !isEnabled);
|
|
}
|
|
|
|
context.on('enter.uiZoomToSelection', setEnabledState);
|
|
|
|
return function(selection) {
|
|
|
|
_button = selection
|
|
.append('button')
|
|
.on('click', click)
|
|
.call(svgIcon('#iD-icon-framed-dot', 'light'))
|
|
.call(uiTooltip()
|
|
.placement((localizer.textDirection() === 'rtl') ? 'right' : 'left')
|
|
.title(t('inspector.zoom_to.title'))
|
|
.keys([t('inspector.zoom_to.key')])
|
|
);
|
|
|
|
setEnabledState();
|
|
};
|
|
}
|