mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 17:23:02 +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
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
import { t } from '../core/localizer';
|
|
import { behaviorDrawWay } from '../behavior/draw_way';
|
|
|
|
|
|
export function modeDrawArea(context, wayID, startGraph, button) {
|
|
var mode = {
|
|
button: button,
|
|
id: 'draw-area'
|
|
};
|
|
|
|
var behavior;
|
|
|
|
mode.wayID = wayID;
|
|
|
|
mode.enter = function() {
|
|
var way = context.entity(wayID);
|
|
|
|
behavior = behaviorDrawWay(context, wayID, undefined, mode, startGraph)
|
|
.tail(t('modes.draw_area.tail'))
|
|
.on('rejectedSelfIntersection.modeDrawArea', function() {
|
|
context.ui().flash
|
|
.text(t('self_intersection.error.areas'))();
|
|
});
|
|
|
|
var addNode = behavior.addNode;
|
|
|
|
behavior.addNode = function(node, d) {
|
|
var length = way.nodes.length;
|
|
var penultimate = length > 2 ? way.nodes[length - 2] : null;
|
|
|
|
if (node.id === way.first() || node.id === penultimate) {
|
|
behavior.finish();
|
|
} else {
|
|
addNode(node, d);
|
|
}
|
|
};
|
|
|
|
context.install(behavior);
|
|
};
|
|
|
|
|
|
mode.exit = function() {
|
|
context.uninstall(behavior);
|
|
};
|
|
|
|
|
|
mode.selectedIDs = function() {
|
|
return [wayID];
|
|
};
|
|
|
|
|
|
mode.activeID = function() {
|
|
return (behavior && behavior.activeID()) || [];
|
|
};
|
|
|
|
|
|
return mode;
|
|
}
|