function dblclick() { var target = d3_select(d3_event.target); var datum = target.datum(); var entity = datum && datum.properties && datum.properties.entity; if (!entity) return; if (entity instanceof osmWay && target.classed('target')) { var choice = geoChooseEdge(context.childNodes(entity), context.mouse(), context.projection); var prev = entity.nodes[choice.index - 1]; var next = entity.nodes[choice.index]; context.perform( actionAddMidpoint({loc: choice.loc, edge: [prev, next]}, osmNode()), t('operations.add.annotation.vertex') ); d3_event.preventDefault(); d3_event.stopPropagation(); } else if (entity.type === 'midpoint') { context.perform( actionAddMidpoint({loc: entity.loc, edge: entity.edge}, osmNode()), t('operations.add.annotation.vertex')); d3_event.preventDefault(); d3_event.stopPropagation(); } }
.on('click', function () { d3_event.stopPropagation(); d3_event.preventDefault(); this.blur(); // avoid keeping focus on the button - #4641 var container = d3_select(this.parentNode.parentNode.parentNode); var info = container.selectAll('.issue-info'); var isExpanded = info.classed('expanded'); if (isExpanded) { info .transition() .duration(200) .style('max-height', '0px') .style('opacity', '0') .on('end', function () { info.classed('expanded', false); }); } else { info .classed('expanded', true) .transition() .duration(200) .style('max-height', '200px') .style('opacity', '1'); } });
return function(data, index) { const elem = this; selectAll(".d3-context-menu") .html(""); var list = selectAll(".d3-context-menu") .on("contextmenu", function(d) { select(".d3-context-menu").style("display", "none"); event.preventDefault(); event.stopPropagation(); }) .append("ul"); list.selectAll("li") .data(typeof menu === "function" ? menu(data, elem, index) : menu) .enter() .append("li") .classed("is-divider", d => d.divider) .classed("is-disabled", d => d.disabled) .classed("is-header", d => !d.action) .classed("is-action", d => d.action != null) .html((d) => { if (d.divider) { return "<hr>"; } if (!d.title) { console.error("No title attribute set. Check the spelling of your options."); } return (typeof d.title === "string") ? d.title : d.title(data); }) .on("click", (d, i) => { if (d.disabled) return; // do nothing if disabled if (!d.action) return; // headers have no "action" const result = d.action(elem, data, index); select(".d3-context-menu") .style("display", "none"); if (closeCallback) { closeCallback(result); } }); // the openCallback allows an action to fire before the menu is displayed // an example usage would be closing a tooltip if (openCallback) { if (openCallback(data, index) === false) { return; } } // display context menu select(".d3-context-menu") .style("left", (event.pageX - 2) + "px") .style("top", (event.pageY - 2) + "px") .style("display", "block"); event.preventDefault(); event.stopPropagation(); };
function keydown() { if (d3_event.keyCode === 93) { // context menu d3_event.preventDefault(); d3_event.stopPropagation(); down.menu = d3_event.timeStamp; tooltip.classed('rightclick', true); } }
.on('click', function () { d3_event.stopPropagation(); d3_event.preventDefault(); context.presets().toggleFavorite(preset, geom); update(); });
function toggleWireframe() { if (d3_event) { d3_event.preventDefault(); d3_event.stopPropagation(); } setFill((fillSelected === 'wireframe' ? fillDefault : 'wireframe')); context.map().pan([0,0]); // trigger a redraw }
function quickSwitch() { if (d3_event) { d3_event.stopImmediatePropagation(); d3_event.preventDefault(); } if (_previousBackground) { chooseBackground(_previousBackground); } }
function quickSwitch() { if (d3_event) { d3_event.stopImmediatePropagation(); d3_event.preventDefault(); } if (previous) { clickSetSource(previous); } }
.on('click', function () { d3_event.stopPropagation(); d3_event.preventDefault(); if (_body.classed('hide')) { show(); } else { hide(); } });
.on('click', function() { d3_event.preventDefault(); d3_event.stopPropagation(); context.perform( actionReverse(_entityID), t('operations.reverse.annotation') ); d3_select(this) .call(reverserSetText); });
function remove(d) { d3_event.stopPropagation(); d3_event.preventDefault(); var t = {}; d.keys.forEach(function(key) { t[key] = undefined; }); dispatch.call('change', d, t); }
function contextmenu() { d3_event.preventDefault(); d3_event.stopPropagation(); if (!down[2] && !down.menu) { tooltip.classed('rightclick', true); window.setTimeout(function() { tooltip.classed('rightclick', false); }, minTime); dispatch.call('click', this, 'right'); } }
function keydown() { // down arrow if (d3_event.keyCode === utilKeybinding.keyCodes['↓'] && // if insertion point is at the end of the string search.node().selectionStart === search.property('value').length) { d3_event.preventDefault(); d3_event.stopPropagation(); // move focus to the first item in the preset list var buttons = list.selectAll('.preset-list-button'); if (!buttons.empty()) buttons.nodes()[0].focus(); } }
.on('mousedown', function () { // prevent the form element from blurring. it blurs // on mousedown d3_event.stopPropagation(); d3_event.preventDefault(); if (!shown) { input.node().focus(); fetch('', render); } else { hide(); } });
function revert(d) { d3_event.stopPropagation(); d3_event.preventDefault(); if (!entity) return false; var original = context.graph().base().entities[entity.id], t = {}; d.keys.forEach(function(key) { t[key] = original ? original.tags[key] : undefined; }); dispatch.call('change', d, t); }
function toggleWireframe() { if (d3_event) { d3_event.preventDefault(); d3_event.stopPropagation(); } if (_fillSelected === 'wireframe') { _fillSelected = context.storage('area-fill-toggle') || 'partial'; } else { _fillSelected = 'wireframe'; } setFill(_fillSelected); context.map().pan([0,0]); // trigger a redraw }
/** * Call on event in order to reset the container view. */ function reset() { if (focus !== null) { focus = null; transform(0, 0, 1); } event.stopPropagation(); }
function doCopy() { if (!getSelectionText()) { d3_event.preventDefault(); } var graph = context.graph(); var selected = groupEntities(context.selectedIDs(), graph); var canCopy = []; var skip = {}; var entity; var i; for (i = 0; i < selected.relation.length; i++) { entity = selected.relation[i]; if (!skip[entity.id] && entity.isComplete(graph)) { canCopy.push(entity.id); skip = getDescendants(entity.id, graph, skip); } } for (i = 0; i < selected.way.length; i++) { entity = selected.way[i]; if (!skip[entity.id]) { canCopy.push(entity.id); skip = getDescendants(entity.id, graph, skip); } } for (i = 0; i < selected.node.length; i++) { entity = selected.node[i]; if (!skip[entity.id]) { canCopy.push(entity.id); } } context.copyIDs(canCopy); }
.on('click', function() { if (d3_event.button !== 0) return; var exp = d3_select(this).classed('expanded'); nudgeContainer.style('display', exp ? 'none' : 'block'); d3_select(this).classed('expanded', !exp); d3_event.preventDefault(); });
function click() { d3_event.preventDefault(); var osm = context.connection(); if (!osm) return; if (context.inIntro()) return; if (context.history().hasChanges() && !window.confirm(t('source_switch.lose_changes'))) return; var isLive = d3_select(this) .classed('live'); isLive = !isLive; context.enter(modeBrowse(context)); context.history().clearSaved(); // remove saved history context.flush(); // remove stored data d3_select(this) .text(isLive ? t('source_switch.live') : t('source_switch.dev')) .classed('live', isLive); osm.switch(isLive ? keys[0] : keys[1]); // switch connection (warning: dispatches 'change' event) }
function toggle() { if (d3_event) d3_event.preventDefault(); isHidden = !isHidden; d3_select('.minimap-toggle-item') .classed('active', !isHidden) .select('input') .property('checked', !isHidden); if (isHidden) { wrap .style('display', 'block') .style('opacity', '1') .transition() .duration(200) .style('opacity', '0') .on('end', function() { selection.selectAll('.map-in-map') .style('display', 'none'); }); } else { wrap .style('display', 'block') .style('opacity', '0') .transition() .duration(200) .style('opacity', '1') .on('end', function() { redraw(); }); } }
export default function() { event.on("drag.noclick", null).on("end.noclick", function() { var click = "click.noclick-" + event.identifier, view = select(event.sourceEvent.view).on(click, cancel, true); setTimeout(function() { view.on(click, null); }, 0); }); }
function keyup() { 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; window.setTimeout(function() { tooltip.classed('rightclick', false); down.menu = undefined; // delayed, for Windows }, delay); dispatch.call('click', this, 'right'); } }
function toggle() { if (d3_event) { d3_event.preventDefault(); } tooltipBehavior.hide(button); setVisible(!button.classed('active')); }
function focusSearch() { var mode = context.mode() && context.mode().id; if (mode !== 'browse') return; d3_event.preventDefault(); search.node().focus(); }
function noselectstart() { var selectstart = "selectstart.noselect-" + event.identifier, view = select(event.sourceEvent.view).on(selectstart, cancel, true); event.on("end.noselect", function() { view.on(selectstart, null); }); }
// fast submit if user presses cmd+enter function keydown() { if (!(d3_event.keyCode === 13 && d3_event.metaKey)) return; var osm = services.osm; if (!osm) return; var hasAuth = osm.authenticated(); if (!hasAuth) return; if (!_note.newComment) return; d3_event.preventDefault(); d3_select(this) .on('keydown.note-input', null); // focus on button and submit window.setTimeout(function() { if (_note.isNew()) { noteSave.selectAll('.save-button').node().focus(); clickSave(_note); } else { noteSave.selectAll('.comment-button').node().focus(); clickComment(_note); } }, 10); }
keybinding.on(_operation.keys, function() { d3_event.preventDefault(); var disabled = _operation.disabled(); var flash; if (disabled) { flash = uiFlash() .duration(4000) .iconName('#iD-operation-' + _operation.id) .iconClass('operation disabled') .text(_operation.tooltip); flash(); } else { flash = uiFlash() .duration(2000) .iconName('#iD-operation-' + _operation.id) .iconClass('operation') .text(_operation.annotation() || _operation.title); flash(); _operation(); } });
export default function() { var dragstart = "dragstart.nodrag-" + event.identifier, view = select(event.sourceEvent.view).on(dragstart, cancel, true); event.on("end.nodrag", function() { view.on(dragstart, null); }); }
function dragOffset() { if (d3_event.button !== 0) return; var origin = [d3_event.clientX, d3_event.clientY]; context.container() .append('div') .attr('class', 'nudge-surface'); d3_select(window) .on('mousemove.offset', function() { var latest = [d3_event.clientX, d3_event.clientY]; var d = [ -(origin[0] - latest[0]) / 4, -(origin[1] - latest[1]) / 4 ]; origin = latest; nudge(d); }) .on('mouseup.offset', function() { if (d3_event.button !== 0) return; d3_selectAll('.nudge-surface') .remove(); d3_select(window) .on('mousemove.offset', null) .on('mouseup.offset', null); }); d3_event.preventDefault(); }