Files
iD/modules/ui/notice.js
Quincy Morgan a1af118f0e Ensure locales and presets are loaded before the UI loads (close #7406)
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
2020-03-31 12:23:31 -07:00

45 lines
1.2 KiB
JavaScript

import _debounce from 'lodash-es/debounce';
import { event as d3_event } from 'd3-selection';
import { t } from '../core/localizer';
import { svgIcon } from '../svg/index';
export function uiNotice(context) {
return function(selection) {
var div = selection
.append('div')
.attr('class', 'notice');
var button = div
.append('button')
.attr('class', 'zoom-to notice fillD')
.on('click', function() {
context.map().zoomEase(context.minEditableZoom());
})
.on('wheel', function() { // let wheel events pass through #4482
var e2 = new WheelEvent(d3_event.type, d3_event);
context.surface().node().dispatchEvent(e2);
});
button
.call(svgIcon('#iD-icon-plus', 'pre-text'))
.append('span')
.attr('class', 'label')
.text(t('zoom_in_edit'));
function disableTooHigh() {
var canEdit = context.map().zoom() >= context.minEditableZoom();
div.style('display', canEdit ? 'none' : 'block');
}
context.map()
.on('move.notice', _debounce(disableTooHigh, 500));
disableTooHigh();
};
}