Variable cleanups in intro

This commit is contained in:
Bryan Housel
2018-09-06 10:46:48 -04:00
parent eba115803a
commit f347346e70
8 changed files with 265 additions and 274 deletions
+6 -6
View File
@@ -2,7 +2,7 @@ import { t } from '../util/locale';
import { behaviorDrawWay } from '../behavior';
export function modeDrawLine(context, wayId, startGraph, affix) {
export function modeDrawLine(context, wayID, startGraph, affix) {
var mode = {
button: 'line',
id: 'draw-line'
@@ -12,16 +12,16 @@ export function modeDrawLine(context, wayId, startGraph, affix) {
mode.enter = function() {
var way = context.entity(wayId);
var way = context.entity(wayID);
var index = (affix === 'prefix') ? 0 : undefined;
var headId = (affix === 'prefix') ? way.first() : way.last();
var headID = (affix === 'prefix') ? way.first() : way.last();
behavior = behaviorDrawWay(context, wayId, index, mode, startGraph)
behavior = behaviorDrawWay(context, wayID, index, mode, startGraph)
.tail(t('modes.draw_line.tail'));
var addNode = behavior.addNode;
behavior.addNode = function(node, d) {
if (node.id === headId) {
if (node.id === headID) {
behavior.finish();
} else {
addNode(node, d);
@@ -38,7 +38,7 @@ export function modeDrawLine(context, wayId, startGraph, affix) {
mode.selectedIDs = function() {
return [wayId];
return [wayID];
};
+27 -27
View File
@@ -17,12 +17,12 @@ import { icon, pad, transitionTime } from './helper';
export function uiIntroArea(context, reveal) {
var dispatch = d3_dispatch('done'),
playground = [-85.63552, 41.94159],
playgroundPreset = context.presets().item('leisure/playground'),
descriptionField = context.presets().field('description'),
timeouts = [],
areaId;
var dispatch = d3_dispatch('done');
var playground = [-85.63552, 41.94159];
var playgroundPreset = context.presets().item('leisure/playground');
var descriptionField = context.presets().field('description');
var timeouts = [];
var _areaID;
var chapter = {
@@ -51,7 +51,7 @@ export function uiIntroArea(context, reveal) {
function addArea() {
context.enter(modeBrowse(context));
context.history().reset('initial');
areaId = null;
_areaID = null;
var msec = transitionTime(playground, context.map().center());
if (msec) { reveal(null, null, { duration: 0 }); }
@@ -85,7 +85,7 @@ export function uiIntroArea(context, reveal) {
return chapter.restart();
}
areaId = null;
_areaID = null;
context.map().zoomEase(19.5, 500);
timeout(function() {
@@ -120,7 +120,7 @@ export function uiIntroArea(context, reveal) {
return chapter.restart();
}
areaId = null;
_areaID = null;
revealPlayground(playground,
t('intro.areas.continue_playground', { alt: uiCmd.display('⌥') }),
{ duration: 250 }
@@ -144,7 +144,7 @@ export function uiIntroArea(context, reveal) {
return;
}
} else if (mode.id === 'select') {
areaId = context.selectedIDs()[0];
_areaID = context.selectedIDs()[0];
return continueTo(searchPresets);
} else {
return chapter.restart();
@@ -164,7 +164,7 @@ export function uiIntroArea(context, reveal) {
return chapter.restart();
}
areaId = null;
_areaID = null;
revealPlayground(playground,
t('intro.areas.finish_playground'), { duration: 250 }
);
@@ -181,7 +181,7 @@ export function uiIntroArea(context, reveal) {
if (mode.id === 'draw-area') {
return;
} else if (mode.id === 'select') {
areaId = context.selectedIDs()[0];
_areaID = context.selectedIDs()[0];
return continueTo(searchPresets);
} else {
return chapter.restart();
@@ -197,12 +197,12 @@ export function uiIntroArea(context, reveal) {
function searchPresets() {
if (!areaId || !context.hasEntity(areaId)) {
if (!_areaID || !context.hasEntity(_areaID)) {
return addArea();
}
var ids = context.selectedIDs();
if (context.mode().id !== 'select' || !ids.length || ids[0] !== areaId) {
context.enter(modeSelect(context, [areaId]));
if (context.mode().id !== 'select' || !ids.length || ids[0] !== _areaID) {
context.enter(modeSelect(context, [_areaID]));
}
// disallow scrolling
@@ -222,14 +222,14 @@ export function uiIntroArea(context, reveal) {
}, 400); // after preset list pane visible..
context.on('enter.intro', function(mode) {
if (!areaId || !context.hasEntity(areaId)) {
if (!_areaID || !context.hasEntity(_areaID)) {
return continueTo(addArea);
}
var ids = context.selectedIDs();
if (mode.id !== 'select' || !ids.length || ids[0] !== areaId) {
if (mode.id !== 'select' || !ids.length || ids[0] !== _areaID) {
// keep the user's area selected..
context.enter(modeSelect(context, [areaId]));
context.enter(modeSelect(context, [_areaID]));
// reset pane, in case user somehow happened to change it..
d3_select('.inspector-wrap .panewrap').style('right', '-100%');
@@ -278,11 +278,11 @@ export function uiIntroArea(context, reveal) {
function clickAddField() {
if (!areaId || !context.hasEntity(areaId)) {
if (!_areaID || !context.hasEntity(_areaID)) {
return addArea();
}
var ids = context.selectedIDs();
if (context.mode().id !== 'select' || !ids.length || ids[0] !== areaId) {
if (context.mode().id !== 'select' || !ids.length || ids[0] !== _areaID) {
return searchPresets();
}
@@ -299,7 +299,7 @@ export function uiIntroArea(context, reveal) {
// It's possible for the user to add a description in a previous step..
// If they did this already, just continue to next step.
var entity = context.entity(areaId);
var entity = context.entity(_areaID);
if (entity.tags.description) {
return continueTo(play);
}
@@ -351,11 +351,11 @@ export function uiIntroArea(context, reveal) {
function chooseDescriptionField() {
if (!areaId || !context.hasEntity(areaId)) {
if (!_areaID || !context.hasEntity(_areaID)) {
return addArea();
}
var ids = context.selectedIDs();
if (context.mode().id !== 'select' || !ids.length || ids[0] !== areaId) {
if (context.mode().id !== 'select' || !ids.length || ids[0] !== _areaID) {
return searchPresets();
}
@@ -400,11 +400,11 @@ export function uiIntroArea(context, reveal) {
function describePlayground() {
if (!areaId || !context.hasEntity(areaId)) {
if (!_areaID || !context.hasEntity(_areaID)) {
return addArea();
}
var ids = context.selectedIDs();
if (context.mode().id !== 'select' || !ids.length || ids[0] !== areaId) {
if (context.mode().id !== 'select' || !ids.length || ids[0] !== _areaID) {
return searchPresets();
}
@@ -432,11 +432,11 @@ export function uiIntroArea(context, reveal) {
function retryChooseDescription() {
if (!areaId || !context.hasEntity(areaId)) {
if (!_areaID || !context.hasEntity(_areaID)) {
return addArea();
}
var ids = context.selectedIDs();
if (context.mode().id !== 'select' || !ids.length || ids[0] !== areaId) {
if (context.mode().id !== 'select' || !ids.length || ids[0] !== _areaID) {
return searchPresets();
}
+51 -52
View File
@@ -14,15 +14,15 @@ import { icon, pad, isMostlySquare, selectMenuItem, transitionTime } from './hel
export function uiIntroBuilding(context, reveal) {
var dispatch = d3_dispatch('done'),
house = [-85.62815, 41.95638],
tank = [-85.62732, 41.95347],
buildingCatetory = context.presets().item('category-building'),
housePreset = context.presets().item('building/house'),
tankPreset = context.presets().item('man_made/storage_tank'),
timeouts = [],
houseId = null,
tankId = null;
var dispatch = d3_dispatch('done');
var house = [-85.62815, 41.95638];
var tank = [-85.62732, 41.95347];
var buildingCatetory = context.presets().item('category-building');
var housePreset = context.presets().item('building/house');
var tankPreset = context.presets().item('man_made/storage_tank');
var timeouts = [];
var _houseID = null;
var _tankID = null;
var chapter = {
@@ -76,7 +76,7 @@ export function uiIntroBuilding(context, reveal) {
function addHouse() {
context.enter(modeBrowse(context));
context.history().reset('initial');
houseId = null;
_houseID = null;
var msec = transitionTime(house, context.map().center());
if (msec) { reveal(null, null, { duration: 0 }); }
@@ -110,7 +110,7 @@ export function uiIntroBuilding(context, reveal) {
return continueTo(addHouse);
}
houseId = null;
_houseID = null;
context.map().zoomEase(20, 500);
timeout(function() {
@@ -140,7 +140,7 @@ export function uiIntroBuilding(context, reveal) {
return continueTo(addHouse);
}
houseId = null;
_houseID = null;
revealHouse(house, t('intro.buildings.continue_building'));
@@ -152,13 +152,13 @@ export function uiIntroBuilding(context, reveal) {
if (mode.id === 'draw-area') {
return;
} else if (mode.id === 'select') {
var graph = context.graph(),
way = context.entity(context.selectedIDs()[0]),
nodes = graph.childNodes(way),
points = _uniq(nodes).map(function(n) { return context.projection(n.loc); });
var graph = context.graph();
var way = context.entity(context.selectedIDs()[0]);
var nodes = graph.childNodes(way);
var points = _uniq(nodes).map(function(n) { return context.projection(n.loc); });
if (isMostlySquare(points)) {
houseId = way.id;
_houseID = way.id;
return continueTo(chooseCategoryBuilding);
} else {
return continueTo(retryHouse);
@@ -198,12 +198,12 @@ export function uiIntroBuilding(context, reveal) {
function chooseCategoryBuilding() {
if (!houseId || !context.hasEntity(houseId)) {
if (!_houseID || !context.hasEntity(_houseID)) {
return addHouse();
}
var ids = context.selectedIDs();
if (context.mode().id !== 'select' || !ids.length || ids[0] !== houseId) {
context.enter(modeSelect(context, [houseId]));
if (context.mode().id !== 'select' || !ids.length || ids[0] !== _houseID) {
context.enter(modeSelect(context, [_houseID]));
}
// disallow scrolling
@@ -228,11 +228,11 @@ export function uiIntroBuilding(context, reveal) {
context.on('enter.intro', function(mode) {
if (!houseId || !context.hasEntity(houseId)) {
if (!_houseID || !context.hasEntity(_houseID)) {
return continueTo(addHouse);
}
var ids = context.selectedIDs();
if (mode.id !== 'select' || !ids.length || ids[0] !== houseId) {
if (mode.id !== 'select' || !ids.length || ids[0] !== _houseID) {
return continueTo(chooseCategoryBuilding);
}
});
@@ -247,12 +247,12 @@ export function uiIntroBuilding(context, reveal) {
function choosePresetHouse() {
if (!houseId || !context.hasEntity(houseId)) {
if (!_houseID || !context.hasEntity(_houseID)) {
return addHouse();
}
var ids = context.selectedIDs();
if (context.mode().id !== 'select' || !ids.length || ids[0] !== houseId) {
context.enter(modeSelect(context, [houseId]));
if (context.mode().id !== 'select' || !ids.length || ids[0] !== _houseID) {
context.enter(modeSelect(context, [_houseID]));
}
// disallow scrolling
@@ -274,15 +274,14 @@ export function uiIntroBuilding(context, reveal) {
continueTo(closeEditorHouse);
});
}, 400); // after preset list pane visible..
context.on('enter.intro', function(mode) {
if (!houseId || !context.hasEntity(houseId)) {
if (!_houseID || !context.hasEntity(_houseID)) {
return continueTo(addHouse);
}
var ids = context.selectedIDs();
if (mode.id !== 'select' || !ids.length || ids[0] !== houseId) {
if (mode.id !== 'select' || !ids.length || ids[0] !== _houseID) {
return continueTo(chooseCategoryBuilding);
}
});
@@ -297,12 +296,12 @@ export function uiIntroBuilding(context, reveal) {
function closeEditorHouse() {
if (!houseId || !context.hasEntity(houseId)) {
if (!_houseID || !context.hasEntity(_houseID)) {
return addHouse();
}
var ids = context.selectedIDs();
if (context.mode().id !== 'select' || !ids.length || ids[0] !== houseId) {
context.enter(modeSelect(context, [houseId]));
if (context.mode().id !== 'select' || !ids.length || ids[0] !== _houseID) {
context.enter(modeSelect(context, [_houseID]));
}
context.history().checkpoint('hasHouse');
@@ -325,7 +324,7 @@ export function uiIntroBuilding(context, reveal) {
function rightClickHouse() {
if (!houseId) return chapter.restart();
if (!_houseID) return chapter.restart();
context.enter(modeBrowse(context));
context.history().reset('hasHouse');
@@ -340,7 +339,7 @@ export function uiIntroBuilding(context, reveal) {
context.on('enter.intro', function(mode) {
if (mode.id !== 'select') return;
var ids = context.selectedIDs();
if (ids.length !== 1 || ids[0] !== houseId) return;
if (ids.length !== 1 || ids[0] !== _houseID) return;
timeout(function() {
var node = selectMenuItem('orthogonalize').node();
@@ -367,8 +366,8 @@ export function uiIntroBuilding(context, reveal) {
function clickSquare() {
if (!houseId) return chapter.restart();
var entity = context.hasEntity(houseId);
if (!_houseID) return chapter.restart();
var entity = context.hasEntity(_houseID);
if (!entity) return continueTo(rightClickHouse);
var node = selectMenuItem('orthogonalize').node();
@@ -453,7 +452,7 @@ export function uiIntroBuilding(context, reveal) {
function addTank() {
context.enter(modeBrowse(context));
context.history().reset('doneSquare');
tankId = null;
_tankID = null;
var msec = transitionTime(tank, context.map().center());
if (msec) { reveal(null, null, { duration: 0 }); }
@@ -482,7 +481,7 @@ export function uiIntroBuilding(context, reveal) {
return continueTo(addTank);
}
tankId = null;
_tankID = null;
timeout(function() {
revealTank(tank, t('intro.buildings.start_tank'));
@@ -511,7 +510,7 @@ export function uiIntroBuilding(context, reveal) {
return continueTo(addTank);
}
tankId = null;
_tankID = null;
revealTank(tank, t('intro.buildings.continue_tank'));
@@ -523,7 +522,7 @@ export function uiIntroBuilding(context, reveal) {
if (mode.id === 'draw-area') {
return;
} else if (mode.id === 'select') {
tankId = context.selectedIDs()[0];
_tankID = context.selectedIDs()[0];
return continueTo(searchPresetTank);
} else {
return continueTo(addTank);
@@ -539,12 +538,12 @@ export function uiIntroBuilding(context, reveal) {
function searchPresetTank() {
if (!tankId || !context.hasEntity(tankId)) {
if (!_tankID || !context.hasEntity(_tankID)) {
return addTank();
}
var ids = context.selectedIDs();
if (context.mode().id !== 'select' || !ids.length || ids[0] !== tankId) {
context.enter(modeSelect(context, [tankId]));
if (context.mode().id !== 'select' || !ids.length || ids[0] !== _tankID) {
context.enter(modeSelect(context, [_tankID]));
}
// disallow scrolling
@@ -564,14 +563,14 @@ export function uiIntroBuilding(context, reveal) {
}, 400); // after preset list pane visible..
context.on('enter.intro', function(mode) {
if (!tankId || !context.hasEntity(tankId)) {
if (!_tankID || !context.hasEntity(_tankID)) {
return continueTo(addTank);
}
var ids = context.selectedIDs();
if (mode.id !== 'select' || !ids.length || ids[0] !== tankId) {
if (mode.id !== 'select' || !ids.length || ids[0] !== _tankID) {
// keep the user's area selected..
context.enter(modeSelect(context, [tankId]));
context.enter(modeSelect(context, [_tankID]));
// reset pane, in case user somehow happened to change it..
d3_select('.inspector-wrap .panewrap').style('right', '-100%');
@@ -620,12 +619,12 @@ export function uiIntroBuilding(context, reveal) {
function closeEditorTank() {
if (!tankId || !context.hasEntity(tankId)) {
if (!_tankID || !context.hasEntity(_tankID)) {
return addTank();
}
var ids = context.selectedIDs();
if (context.mode().id !== 'select' || !ids.length || ids[0] !== tankId) {
context.enter(modeSelect(context, [tankId]));
if (context.mode().id !== 'select' || !ids.length || ids[0] !== _tankID) {
context.enter(modeSelect(context, [_tankID]));
}
context.history().checkpoint('hasTank');
@@ -648,7 +647,7 @@ export function uiIntroBuilding(context, reveal) {
function rightClickTank() {
if (!tankId) return continueTo(addTank);
if (!_tankID) return continueTo(addTank);
context.enter(modeBrowse(context));
context.history().reset('hasTank');
@@ -658,7 +657,7 @@ export function uiIntroBuilding(context, reveal) {
context.on('enter.intro', function(mode) {
if (mode.id !== 'select') return;
var ids = context.selectedIDs();
if (ids.length !== 1 || ids[0] !== tankId) return;
if (ids.length !== 1 || ids[0] !== _tankID) return;
timeout(function() {
var node = selectMenuItem('circularize').node();
@@ -689,8 +688,8 @@ export function uiIntroBuilding(context, reveal) {
function clickCircle() {
if (!tankId) return chapter.restart();
var entity = context.hasEntity(tankId);
if (!_tankID) return chapter.restart();
var entity = context.hasEntity(_tankID);
if (!entity) return continueTo(rightClickTank);
var node = selectMenuItem('circularize').node();
+13 -13
View File
@@ -91,10 +91,10 @@ export function localize(obj) {
'postcode', 'province', 'quarter', 'state', 'subdistrict', 'suburb'
];
addrTags.forEach(function(k) {
var key = 'intro.graph.' + k,
tag = 'addr:' + k,
val = obj.tags && obj.tags[tag],
str = t(key, { default: val });
var key = 'intro.graph.' + k;
var tag = 'addr:' + k;
var val = obj.tags && obj.tags[tag];
var str = t(key, { default: val });
if (str) {
if (str.match(/^<.*>$/) !== null) {
@@ -114,10 +114,10 @@ export function localize(obj) {
export function isMostlySquare(points) {
// note: uses 15 here instead of the 12 from actionOrthogonalize because
// actionOrthogonalize can actually straighten some larger angles as it iterates
var threshold = 15, // degrees within right or straight
lowerBound = Math.cos((90 - threshold) * Math.PI / 180), // near right
upperBound = Math.cos(threshold * Math.PI / 180), // near straight
mag;
var threshold = 15; // degrees within right or straight
var lowerBound = Math.cos((90 - threshold) * Math.PI / 180); // near right
var upperBound = Math.cos(threshold * Math.PI / 180); // near straight
var mag;
for (var i = 0; i < points.length; i++) {
mag = Math.abs(normalizedDotProduct(i, points));
@@ -130,11 +130,11 @@ export function isMostlySquare(points) {
function normalizedDotProduct(i, points) {
var a = points[(i - 1 + points.length) % points.length],
b = points[i],
c = points[(i + 1) % points.length],
p = subtractPoints(a, b),
q = subtractPoints(c, b);
var a = points[(i - 1 + points.length) % points.length];
var b = points[i];
var c = points[(i + 1) % points.length];
var p = subtractPoints(a, b);
var q = subtractPoints(c, b);
p = normalizePoint(p);
q = normalizePoint(q);
+110 -118
View File
@@ -15,29 +15,29 @@ import { icon, pad, selectMenuItem, transitionTime } from './helper';
export function uiIntroLine(context, reveal) {
var dispatch = d3_dispatch('done'),
timeouts = [],
tulipRoadId = null,
flowerRoadId = 'w646',
tulipRoadStart = [-85.6297754121684, 41.95805253325314],
tulipRoadMidpoint = [-85.62975395449628, 41.95787501510204],
tulipRoadIntersection = [-85.62974496187628, 41.95742515554585],
roadCategory = context.presets().item('category-road'),
residentialPreset = context.presets().item('highway/residential'),
woodRoadId = 'w525',
woodRoadEndId = 'n2862',
woodRoadAddNode = [-85.62390110349587, 41.95397111462291],
woodRoadDragEndpoint = [-85.623867390213, 41.95466987786487],
woodRoadDragMidpoint = [-85.62386254803509, 41.95430395953872],
washingtonStreetId = 'w522',
twelfthAvenueId = 'w1',
eleventhAvenueEndId = 'n3550',
twelfthAvenueEndId = 'n5',
washingtonSegmentId = null,
eleventhAvenueEnd = context.entity(eleventhAvenueEndId).loc,
twelfthAvenueEnd = context.entity(twelfthAvenueEndId).loc,
deleteLinesLoc = [-85.6219395542764, 41.95228033922477],
twelfthAvenue = [-85.62219310052491, 41.952505413152956];
var dispatch = d3_dispatch('done');
var timeouts = [];
var _tulipRoadID = null;
var flowerRoadID = 'w646';
var tulipRoadStart = [-85.6297754121684, 41.95805253325314];
var tulipRoadMidpoint = [-85.62975395449628, 41.95787501510204];
var tulipRoadIntersection = [-85.62974496187628, 41.95742515554585];
var roadCategory = context.presets().item('category-road');
var residentialPreset = context.presets().item('highway/residential');
var woodRoadID = 'w525';
var woodRoadEndID = 'n2862';
var woodRoadAddNode = [-85.62390110349587, 41.95397111462291];
var woodRoadDragEndpoint = [-85.623867390213, 41.95466987786487];
var woodRoadDragMidpoint = [-85.62386254803509, 41.95430395953872];
var washingtonStreetID = 'w522';
var twelfthAvenueID = 'w1';
var eleventhAvenueEndID = 'n3550';
var twelfthAvenueEndID = 'n5';
var _washingtonSegmentID = null;
var eleventhAvenueEnd = context.entity(eleventhAvenueEndID).loc;
var twelfthAvenueEnd = context.entity(twelfthAvenueEndID).loc;
var deleteLinesLoc = [-85.6219395542764, 41.95228033922477];
var twelfthAvenue = [-85.62219310052491, 41.952505413152956];
var chapter = {
@@ -106,11 +106,9 @@ export function uiIntroLine(context, reveal) {
function startLine() {
if (context.mode().id !== 'add-line') {
return chapter.restart();
}
if (context.mode().id !== 'add-line') return chapter.restart();
tulipRoadId = null;
_tulipRoadID = null;
var padding = 70 * Math.pow(2, context.map().zoom() - 18);
var box = pad(tulipRoadStart, padding, context);
@@ -138,11 +136,9 @@ export function uiIntroLine(context, reveal) {
function drawLine() {
if (context.mode().id !== 'draw-line') {
return chapter.restart();
}
if (context.mode().id !== 'draw-line') return chapter.restart();
tulipRoadId = context.mode().selectedIDs()[0];
_tulipRoadID = context.mode().selectedIDs()[0];
context.map().centerEase(tulipRoadMidpoint, 500);
timeout(function() {
@@ -165,8 +161,10 @@ export function uiIntroLine(context, reveal) {
}, 550); // after easing..
context.history().on('change.intro', function() {
var entity = tulipRoadId && context.hasEntity(tulipRoadId);
if (!entity) return chapter.restart();
var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
if (!entity) {
return chapter.restart();
}
if (isLineConnected()) {
continueTo(continueLine);
@@ -174,14 +172,14 @@ export function uiIntroLine(context, reveal) {
});
context.on('enter.intro', function(mode) {
if (mode.id === 'draw-line')
if (mode.id === 'draw-line') {
return;
else if (mode.id === 'select') {
} else if (mode.id === 'select') {
continueTo(retryIntersect);
return;
}
else
} else {
return chapter.restart();
}
});
function continueTo(nextStep) {
@@ -194,13 +192,13 @@ export function uiIntroLine(context, reveal) {
function isLineConnected() {
var entity = tulipRoadId && context.hasEntity(tulipRoadId);
var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
if (!entity) return false;
var drawNodes = context.graph().childNodes(entity);
return _some(drawNodes, function(node) {
return _some(context.graph().parentWays(node), function(parent) {
return parent.id === flowerRoadId;
return parent.id === flowerRoadID;
});
});
}
@@ -220,7 +218,7 @@ export function uiIntroLine(context, reveal) {
function continueLine() {
if (context.mode().id !== 'draw-line') return chapter.restart();
var entity = tulipRoadId && context.hasEntity(tulipRoadId);
var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
if (!entity) return chapter.restart();
context.map().centerEase(tulipRoadIntersection, 500);
@@ -244,9 +242,7 @@ export function uiIntroLine(context, reveal) {
function chooseCategoryRoad() {
if (context.mode().id !== 'select') {
return chapter.restart();
}
if (context.mode().id !== 'select') return chapter.restart();
context.on('exit.intro', function() {
return chapter.restart();
@@ -282,9 +278,7 @@ export function uiIntroLine(context, reveal) {
function choosePresetResidential() {
if (context.mode().id !== 'select') {
return chapter.restart();
}
if (context.mode().id !== 'select') return chapter.restart();
context.on('exit.intro', function() {
return chapter.restart();
@@ -320,9 +314,7 @@ export function uiIntroLine(context, reveal) {
// selected wrong road type
function retryPresetResidential() {
if (context.mode().id !== 'select') {
return chapter.restart();
}
if (context.mode().id !== 'select') return chapter.restart();
context.on('exit.intro', function() {
return chapter.restart();
@@ -390,7 +382,7 @@ export function uiIntroLine(context, reveal) {
function updateLine() {
context.history().reset('doneAddLine');
if (!context.hasEntity(woodRoadId) || !context.hasEntity(woodRoadEndId)) {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
return chapter.restart();
}
@@ -425,7 +417,7 @@ export function uiIntroLine(context, reveal) {
function addNode() {
context.history().reset('doneAddLine');
if (!context.hasEntity(woodRoadId) || !context.hasEntity(woodRoadEndId)) {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
return chapter.restart();
}
@@ -440,7 +432,7 @@ export function uiIntroLine(context, reveal) {
});
context.history().on('change.intro', function(changed) {
if (!context.hasEntity(woodRoadId) || !context.hasEntity(woodRoadEndId)) {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
return continueTo(updateLine);
}
if (changed.created().length === 1) {
@@ -464,7 +456,7 @@ export function uiIntroLine(context, reveal) {
function startDragEndpoint() {
if (!context.hasEntity(woodRoadId) || !context.hasEntity(woodRoadEndId)) {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
return continueTo(updateLine);
}
var padding = 100 * Math.pow(2, context.map().zoom() - 19);
@@ -472,14 +464,14 @@ export function uiIntroLine(context, reveal) {
reveal(box, t('intro.lines.start_drag_endpoint'));
context.map().on('move.intro drawn.intro', function() {
if (!context.hasEntity(woodRoadId) || !context.hasEntity(woodRoadEndId)) {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
return continueTo(updateLine);
}
var padding = 100 * Math.pow(2, context.map().zoom() - 19);
var box = pad(woodRoadDragEndpoint, padding, context);
reveal(box, t('intro.lines.start_drag_endpoint'), { duration: 0 });
var entity = context.entity(woodRoadEndId);
var entity = context.entity(woodRoadEndID);
if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) <= 4) {
continueTo(finishDragEndpoint);
}
@@ -493,7 +485,7 @@ export function uiIntroLine(context, reveal) {
function finishDragEndpoint() {
if (!context.hasEntity(woodRoadId) || !context.hasEntity(woodRoadEndId)) {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
return continueTo(updateLine);
}
@@ -502,14 +494,14 @@ export function uiIntroLine(context, reveal) {
reveal(box, t('intro.lines.finish_drag_endpoint'));
context.map().on('move.intro drawn.intro', function() {
if (!context.hasEntity(woodRoadId) || !context.hasEntity(woodRoadEndId)) {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
return continueTo(updateLine);
}
var padding = 100 * Math.pow(2, context.map().zoom() - 19);
var box = pad(woodRoadDragEndpoint, padding, context);
reveal(box, t('intro.lines.finish_drag_endpoint'), { duration: 0 });
var entity = context.entity(woodRoadEndId);
var entity = context.entity(woodRoadEndID);
if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) > 4) {
continueTo(startDragEndpoint);
}
@@ -528,11 +520,11 @@ export function uiIntroLine(context, reveal) {
function startDragMidpoint() {
if (!context.hasEntity(woodRoadId) || !context.hasEntity(woodRoadEndId)) {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
return continueTo(updateLine);
}
if (context.selectedIDs().indexOf(woodRoadId) === -1) {
context.enter(modeSelect(context, [woodRoadId]));
if (context.selectedIDs().indexOf(woodRoadID) === -1) {
context.enter(modeSelect(context, [woodRoadID]));
}
var padding = 80 * Math.pow(2, context.map().zoom() - 19);
@@ -540,7 +532,7 @@ export function uiIntroLine(context, reveal) {
reveal(box, t('intro.lines.start_drag_midpoint'));
context.map().on('move.intro drawn.intro', function() {
if (!context.hasEntity(woodRoadId) || !context.hasEntity(woodRoadEndId)) {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
return continueTo(updateLine);
}
var padding = 80 * Math.pow(2, context.map().zoom() - 19);
@@ -557,7 +549,7 @@ export function uiIntroLine(context, reveal) {
context.on('enter.intro', function(mode) {
if (mode.id !== 'select') {
// keep Wood Road selected so midpoint triangles are drawn..
context.enter(modeSelect(context, [woodRoadId]));
context.enter(modeSelect(context, [woodRoadID]));
}
});
@@ -571,7 +563,7 @@ export function uiIntroLine(context, reveal) {
function continueDragMidpoint() {
if (!context.hasEntity(woodRoadId) || !context.hasEntity(woodRoadEndId)) {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
return continueTo(updateLine);
}
@@ -589,7 +581,7 @@ export function uiIntroLine(context, reveal) {
);
context.map().on('move.intro drawn.intro', function() {
if (!context.hasEntity(woodRoadId) || !context.hasEntity(woodRoadEndId)) {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
return continueTo(updateLine);
}
var padding = 100 * Math.pow(2, context.map().zoom() - 19);
@@ -611,9 +603,9 @@ export function uiIntroLine(context, reveal) {
context.history().reset('doneUpdateLine');
context.enter(modeBrowse(context));
if (!context.hasEntity(washingtonStreetId) ||
!context.hasEntity(twelfthAvenueId) ||
!context.hasEntity(eleventhAvenueEndId)) {
if (!context.hasEntity(washingtonStreetID) ||
!context.hasEntity(twelfthAvenueID) ||
!context.hasEntity(eleventhAvenueEndID)) {
return chapter.restart();
}
@@ -683,7 +675,7 @@ export function uiIntroLine(context, reveal) {
context.on('enter.intro', function(mode) {
if (mode.id !== 'select') return;
var ids = context.selectedIDs();
if (ids.length !== 1 || ids[0] !== eleventhAvenueEndId) return;
if (ids.length !== 1 || ids[0] !== eleventhAvenueEndID) return;
timeout(function() {
var node = selectMenuItem('split').node();
@@ -710,9 +702,9 @@ export function uiIntroLine(context, reveal) {
function splitIntersection() {
if (!context.hasEntity(washingtonStreetId) ||
!context.hasEntity(twelfthAvenueId) ||
!context.hasEntity(eleventhAvenueEndId)) {
if (!context.hasEntity(washingtonStreetID) ||
!context.hasEntity(twelfthAvenueID) ||
!context.hasEntity(eleventhAvenueEndID)) {
return continueTo(deleteLines);
}
@@ -721,7 +713,7 @@ export function uiIntroLine(context, reveal) {
var wasChanged = false;
var menuCoords = context.map().mouseCoordinates();
washingtonSegmentId = null;
_washingtonSegmentID = null;
revealEditMenu(menuCoords, t('intro.lines.split_intersection',
{ button: icon('#iD-operation-split', 'pre-text'), street: t('intro.graph.name.washington-street') })
@@ -741,10 +733,10 @@ export function uiIntroLine(context, reveal) {
wasChanged = true;
timeout(function() {
if (context.history().undoAnnotation() === t('operations.split.annotation.line')) {
washingtonSegmentId = changed.created()[0].id;
_washingtonSegmentID = changed.created()[0].id;
continueTo(didSplit);
} else {
washingtonSegmentId = null;
_washingtonSegmentID = null;
continueTo(retrySplit);
}
}, 300); // after any transition (e.g. if user deleted intersection)
@@ -785,11 +777,11 @@ export function uiIntroLine(context, reveal) {
function didSplit() {
if (!washingtonSegmentId ||
!context.hasEntity(washingtonSegmentId) ||
!context.hasEntity(washingtonStreetId) ||
!context.hasEntity(twelfthAvenueId) ||
!context.hasEntity(eleventhAvenueEndId)) {
if (!_washingtonSegmentID ||
!context.hasEntity(_washingtonSegmentID) ||
!context.hasEntity(washingtonStreetID) ||
!context.hasEntity(twelfthAvenueID) ||
!context.hasEntity(eleventhAvenueEndID)) {
return continueTo(rightClickIntersection);
}
@@ -819,17 +811,17 @@ export function uiIntroLine(context, reveal) {
context.on('enter.intro', function() {
var ids = context.selectedIDs();
if (ids.length === 1 && ids[0] === washingtonSegmentId) {
if (ids.length === 1 && ids[0] === _washingtonSegmentID) {
continueTo(multiSelect);
}
});
context.history().on('change.intro', function() {
if (!washingtonSegmentId ||
!context.hasEntity(washingtonSegmentId) ||
!context.hasEntity(washingtonStreetId) ||
!context.hasEntity(twelfthAvenueId) ||
!context.hasEntity(eleventhAvenueEndId)) {
if (!_washingtonSegmentID ||
!context.hasEntity(_washingtonSegmentID) ||
!context.hasEntity(washingtonStreetID) ||
!context.hasEntity(twelfthAvenueID) ||
!context.hasEntity(eleventhAvenueEndID)) {
return continueTo(rightClickIntersection);
}
});
@@ -844,17 +836,17 @@ export function uiIntroLine(context, reveal) {
function multiSelect() {
if (!washingtonSegmentId ||
!context.hasEntity(washingtonSegmentId) ||
!context.hasEntity(washingtonStreetId) ||
!context.hasEntity(twelfthAvenueId) ||
!context.hasEntity(eleventhAvenueEndId)) {
if (!_washingtonSegmentID ||
!context.hasEntity(_washingtonSegmentID) ||
!context.hasEntity(washingtonStreetID) ||
!context.hasEntity(twelfthAvenueID) ||
!context.hasEntity(eleventhAvenueEndID)) {
return continueTo(rightClickIntersection);
}
var ids = context.selectedIDs();
var hasWashington = ids.indexOf(washingtonSegmentId) !== -1;
var hasTwelfth = ids.indexOf(twelfthAvenueId) !== -1;
var hasWashington = ids.indexOf(_washingtonSegmentID) !== -1;
var hasTwelfth = ids.indexOf(twelfthAvenueID) !== -1;
if (hasWashington && hasTwelfth) {
return continueTo(multiRightClick);
@@ -910,11 +902,11 @@ export function uiIntroLine(context, reveal) {
});
context.history().on('change.intro', function() {
if (!washingtonSegmentId ||
!context.hasEntity(washingtonSegmentId) ||
!context.hasEntity(washingtonStreetId) ||
!context.hasEntity(twelfthAvenueId) ||
!context.hasEntity(eleventhAvenueEndId)) {
if (!_washingtonSegmentID ||
!context.hasEntity(_washingtonSegmentID) ||
!context.hasEntity(washingtonStreetID) ||
!context.hasEntity(twelfthAvenueID) ||
!context.hasEntity(eleventhAvenueEndID)) {
return continueTo(rightClickIntersection);
}
});
@@ -930,11 +922,11 @@ export function uiIntroLine(context, reveal) {
function multiRightClick() {
if (!washingtonSegmentId ||
!context.hasEntity(washingtonSegmentId) ||
!context.hasEntity(washingtonStreetId) ||
!context.hasEntity(twelfthAvenueId) ||
!context.hasEntity(eleventhAvenueEndId)) {
if (!_washingtonSegmentID ||
!context.hasEntity(_washingtonSegmentID) ||
!context.hasEntity(washingtonStreetID) ||
!context.hasEntity(twelfthAvenueID) ||
!context.hasEntity(eleventhAvenueEndID)) {
return continueTo(rightClickIntersection);
}
@@ -952,13 +944,13 @@ export function uiIntroLine(context, reveal) {
timeout(function() {
var ids = context.selectedIDs();
if (ids.length === 2 &&
ids.indexOf(twelfthAvenueId) !== -1 &&
ids.indexOf(washingtonSegmentId) !== -1) {
ids.indexOf(twelfthAvenueID) !== -1 &&
ids.indexOf(_washingtonSegmentID) !== -1) {
var node = selectMenuItem('delete').node();
if (!node) return;
continueTo(multiDelete);
} else if (ids.length === 1 &&
ids.indexOf(washingtonSegmentId) !== -1) {
ids.indexOf(_washingtonSegmentID) !== -1) {
return continueTo(multiSelect);
} else {
return continueTo(didSplit);
@@ -967,11 +959,11 @@ export function uiIntroLine(context, reveal) {
}, true);
context.history().on('change.intro', function() {
if (!washingtonSegmentId ||
!context.hasEntity(washingtonSegmentId) ||
!context.hasEntity(washingtonStreetId) ||
!context.hasEntity(twelfthAvenueId) ||
!context.hasEntity(eleventhAvenueEndId)) {
if (!_washingtonSegmentID ||
!context.hasEntity(_washingtonSegmentID) ||
!context.hasEntity(washingtonStreetID) ||
!context.hasEntity(twelfthAvenueID) ||
!context.hasEntity(eleventhAvenueEndID)) {
return continueTo(rightClickIntersection);
}
});
@@ -986,11 +978,11 @@ export function uiIntroLine(context, reveal) {
function multiDelete() {
if (!washingtonSegmentId ||
!context.hasEntity(washingtonSegmentId) ||
!context.hasEntity(washingtonStreetId) ||
!context.hasEntity(twelfthAvenueId) ||
!context.hasEntity(eleventhAvenueEndId)) {
if (!_washingtonSegmentID ||
!context.hasEntity(_washingtonSegmentID) ||
!context.hasEntity(washingtonStreetID) ||
!context.hasEntity(twelfthAvenueID) ||
!context.hasEntity(eleventhAvenueEndID)) {
return continueTo(rightClickIntersection);
}
@@ -1010,13 +1002,13 @@ export function uiIntroLine(context, reveal) {
});
context.on('exit.intro', function() {
if (context.hasEntity(washingtonSegmentId) || context.hasEntity(twelfthAvenueId)) {
if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
return continueTo(multiSelect); // left select mode but roads still exist
}
});
context.history().on('change.intro', function() {
if (context.hasEntity(washingtonSegmentId) || context.hasEntity(twelfthAvenueId)) {
if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
continueTo(retryDelete); // changed something but roads still exist
} else {
continueTo(play);
+12 -12
View File
@@ -12,15 +12,15 @@ import { icon, pointBox, transitionTime } from './helper';
export function uiIntroNavigation(context, reveal) {
var dispatch = d3_dispatch('done'),
timeouts = [],
hallId = 'n2061',
townHall = [-85.63591, 41.94285],
springStreetId = 'w397',
springStreetEndId = 'n1834',
springStreet = [-85.63582, 41.94255],
onewayField = context.presets().field('oneway'),
maxspeedField = context.presets().field('maxspeed');
var dispatch = d3_dispatch('done');
var timeouts = [];
var hallId = 'n2061';
var townHall = [-85.63591, 41.94285];
var springStreetId = 'w397';
var springStreetEndId = 'n1834';
var springStreet = [-85.63582, 41.94255];
var onewayField = context.presets().field('oneway');
var maxspeedField = context.presets().field('maxspeed');
var chapter = {
@@ -409,9 +409,9 @@ export function uiIntroNavigation(context, reveal) {
function checkSearchResult() {
var first = d3_select('.feature-list-item:nth-child(0n+2)'), // skip "No Results" item
firstName = first.select('.entity-name'),
name = t('intro.graph.name.spring-street');
var first = d3_select('.feature-list-item:nth-child(0n+2)'); // skip "No Results" item
var firstName = first.select('.entity-name');
var name = t('intro.graph.name.spring-street');
if (!firstName.empty() && firstName.text() === name) {
reveal(first.node(),
+29 -29
View File
@@ -12,12 +12,12 @@ import { icon, pointBox, pad, selectMenuItem, transitionTime } from './helper';
export function uiIntroPoint(context, reveal) {
var dispatch = d3_dispatch('done'),
timeouts = [],
intersection = [-85.63279, 41.94394],
building = [-85.632422, 41.944045],
cafePreset = context.presets().item('amenity/cafe'),
pointId = null;
var dispatch = d3_dispatch('done');
var timeouts = [];
var intersection = [-85.63279, 41.94394];
var building = [-85.632422, 41.944045];
var cafePreset = context.presets().item('amenity/cafe');
var _pointID = null;
var chapter = {
@@ -66,7 +66,7 @@ export function uiIntroPoint(context, reveal) {
var tooltip = reveal('button.add-point',
t('intro.points.add_point', { button: icon('#iD-icon-point', 'pre-text') }));
pointId = null;
_pointID = null;
tooltip.selectAll('.tooltip-inner')
.insert('svg', 'span')
@@ -102,7 +102,7 @@ export function uiIntroPoint(context, reveal) {
context.on('enter.intro', function(mode) {
if (mode.id !== 'select') return chapter.restart();
pointId = context.mode().selectedIDs()[0];
_pointID = context.mode().selectedIDs()[0];
continueTo(searchPreset);
});
@@ -115,7 +115,7 @@ export function uiIntroPoint(context, reveal) {
function searchPreset() {
if (context.mode().id !== 'select' || !pointId || !context.hasEntity(pointId)) {
if (context.mode().id !== 'select' || !_pointID || !context.hasEntity(_pointID)) {
return addPoint();
}
@@ -131,14 +131,14 @@ export function uiIntroPoint(context, reveal) {
);
context.on('enter.intro', function(mode) {
if (!pointId || !context.hasEntity(pointId)) {
if (!_pointID || !context.hasEntity(_pointID)) {
return continueTo(addPoint);
}
var ids = context.selectedIDs();
if (mode.id !== 'select' || !ids.length || ids[0] !== pointId) {
if (mode.id !== 'select' || !ids.length || ids[0] !== _pointID) {
// keep the user's point selected..
context.enter(modeSelect(context, [pointId]));
context.enter(modeSelect(context, [_pointID]));
// disallow scrolling
d3_select('.inspector-wrap').on('wheel.intro', eventCancel);
@@ -186,7 +186,7 @@ export function uiIntroPoint(context, reveal) {
function aboutFeatureEditor() {
if (context.mode().id !== 'select' || !pointId || !context.hasEntity(pointId)) {
if (context.mode().id !== 'select' || !_pointID || !context.hasEntity(_pointID)) {
return addPoint();
}
@@ -211,7 +211,7 @@ export function uiIntroPoint(context, reveal) {
function addName() {
if (context.mode().id !== 'select' || !pointId || !context.hasEntity(pointId)) {
if (context.mode().id !== 'select' || !_pointID || !context.hasEntity(_pointID)) {
return addPoint();
}
@@ -222,7 +222,7 @@ export function uiIntroPoint(context, reveal) {
// It's possible for the user to add a name in a previous step..
// If so, don't tell them to add the name in this step.
// Give them an OK button instead.
var entity = context.entity(pointId);
var entity = context.entity(_pointID);
if (entity.tags.name) {
var tooltip = reveal('.entity-editor-pane', t('intro.points.add_name'), {
tooltipClass: 'intro-points-describe',
@@ -278,13 +278,13 @@ export function uiIntroPoint(context, reveal) {
function reselectPoint() {
if (!pointId) return chapter.restart();
var entity = context.hasEntity(pointId);
if (!_pointID) return chapter.restart();
var entity = context.hasEntity(_pointID);
if (!entity) return chapter.restart();
// make sure it's still a cafe, in case user somehow changed it..
var oldPreset = context.presets().match(entity, context.graph());
context.replace(actionChangePreset(pointId, oldPreset, cafePreset));
context.replace(actionChangePreset(_pointID, oldPreset, cafePreset));
context.enter(modeBrowse(context));
@@ -298,7 +298,7 @@ export function uiIntroPoint(context, reveal) {
timeout(function() {
context.map().on('move.intro drawn.intro', function() {
var entity = context.hasEntity(pointId);
var entity = context.hasEntity(_pointID);
if (!entity) return chapter.restart();
var box = pointBox(entity.loc, context);
reveal(box, t('intro.points.reselect'), { duration: 0 });
@@ -321,7 +321,7 @@ export function uiIntroPoint(context, reveal) {
function updatePoint() {
if (context.mode().id !== 'select' || !pointId || !context.hasEntity(pointId)) {
if (context.mode().id !== 'select' || !_pointID || !context.hasEntity(_pointID)) {
return continueTo(reselectPoint);
}
@@ -351,7 +351,7 @@ export function uiIntroPoint(context, reveal) {
function updateCloseEditor() {
if (context.mode().id !== 'select' || !pointId || !context.hasEntity(pointId)) {
if (context.mode().id !== 'select' || !_pointID || !context.hasEntity(_pointID)) {
return continueTo(reselectPoint);
}
@@ -376,8 +376,8 @@ export function uiIntroPoint(context, reveal) {
function rightClickPoint() {
if (!pointId) return chapter.restart();
var entity = context.hasEntity(pointId);
if (!_pointID) return chapter.restart();
var entity = context.hasEntity(_pointID);
if (!entity) return chapter.restart();
context.enter(modeBrowse(context));
@@ -387,7 +387,7 @@ export function uiIntroPoint(context, reveal) {
timeout(function() {
context.map().on('move.intro drawn.intro', function() {
var entity = context.hasEntity(pointId);
var entity = context.hasEntity(_pointID);
if (!entity) return chapter.restart();
var box = pointBox(entity.loc, context);
reveal(box, t('intro.points.rightclick'), { duration: 0 });
@@ -397,7 +397,7 @@ export function uiIntroPoint(context, reveal) {
context.on('enter.intro', function(mode) {
if (mode.id !== 'select') return;
var ids = context.selectedIDs();
if (ids.length !== 1 || ids[0] !== pointId) return;
if (ids.length !== 1 || ids[0] !== _pointID) return;
timeout(function() {
var node = selectMenuItem('delete').node();
@@ -415,8 +415,8 @@ export function uiIntroPoint(context, reveal) {
function enterDelete() {
if (!pointId) return chapter.restart();
var entity = context.hasEntity(pointId);
if (!_pointID) return chapter.restart();
var entity = context.hasEntity(_pointID);
if (!entity) return chapter.restart();
var node = selectMenuItem('delete').node();
@@ -436,8 +436,8 @@ export function uiIntroPoint(context, reveal) {
}, 300); // after menu visible
context.on('exit.intro', function() {
if (!pointId) return chapter.restart();
var entity = context.hasEntity(pointId);
if (!_pointID) return chapter.restart();
var entity = context.hasEntity(_pointID);
if (entity) return continueTo(rightClickPoint); // point still exists
});
+17 -17
View File
@@ -9,8 +9,8 @@ import { utilRebind } from '../../util/rebind';
export function uiIntroWelcome(context, reveal) {
var dispatch = d3_dispatch('done'),
listener = clickListener();
var dispatch = d3_dispatch('done');
var listener = clickListener();
var chapter = {
title: 'intro.welcome.title'
@@ -49,8 +49,8 @@ export function uiIntroWelcome(context, reveal) {
function leftClick() {
var counter = 0,
times = 5;
var counter = 0;
var times = 5;
var tooltip = reveal('.intro-nav-wrap .chapter-welcome',
t('intro.welcome.leftclick', { num: times }),
@@ -90,8 +90,8 @@ export function uiIntroWelcome(context, reveal) {
function rightClick() {
var counter = 0,
times = 5;
var counter = 0;
var times = 5;
var tooltip = reveal('.intro-nav-wrap .chapter-welcome',
t('intro.welcome.rightclick', { num: times }),
@@ -163,10 +163,10 @@ export function uiIntroWelcome(context, reveal) {
function clickListener() {
var dispatch = d3_dispatch('click'),
minTime = 120,
tooltip = d3_select(null),
down = {};
var dispatch = d3_dispatch('click');
var minTime = 120;
var tooltip = d3_select(null);
var down = {};
// `down` keeps track of which buttons/keys are down.
// Setting a property in `down` happens immediately.
@@ -187,9 +187,9 @@ function clickListener() {
if (d3_event.keyCode === 93) { // context menu
d3_event.preventDefault();
d3_event.stopPropagation();
var endTime = d3_event.timeStamp,
startTime = down.menu || endTime,
delay = (endTime - startTime < minTime) ? minTime : 0;
var endTime = d3_event.timeStamp;
var startTime = down.menu || endTime;
var delay = (endTime - startTime < minTime) ? minTime : 0;
window.setTimeout(function() {
tooltip.classed('rightclick', false);
@@ -213,10 +213,10 @@ function clickListener() {
function mouseup() {
var button = d3_event.button,
endTime = d3_event.timeStamp,
startTime = down[button] || endTime,
delay = (endTime - startTime < minTime) ? minTime : 0;
var button = d3_event.button;
var endTime = d3_event.timeStamp;
var startTime = down[button] || endTime;
var delay = (endTime - startTime < minTime) ? minTime : 0;
if (button === 0 && !d3_event.ctrlKey) {
window.setTimeout(function() {