mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-31 01:09:22 +02:00
Update more code for D3 v6
This commit is contained in:
@@ -220,11 +220,11 @@ export function uiConflicts(context) {
|
||||
return (i === 0 && index === 0) ||
|
||||
(i === 1 && index === _conflictList.length - 1) || null;
|
||||
})
|
||||
.on('click', function(d3_event, d, i) {
|
||||
.on('click', function(d3_event, d) {
|
||||
d3_event.preventDefault();
|
||||
|
||||
var container = parent.selectAll('.conflict-container');
|
||||
var sign = (i === 0 ? -1 : 1);
|
||||
var sign = (d === 'previous' ? -1 : 1);
|
||||
|
||||
container
|
||||
.selectAll('.conflict')
|
||||
@@ -256,9 +256,9 @@ export function uiConflicts(context) {
|
||||
.append('input')
|
||||
.attr('type', 'radio')
|
||||
.attr('name', function(d) { return d.id; })
|
||||
.on('change', function(d3_event, d, i) {
|
||||
.on('change', function(d3_event, d) {
|
||||
var ul = this.parentNode.parentNode.parentNode;
|
||||
ul.__data__.chosen = i;
|
||||
ul.__data__.chosen = d.id;
|
||||
choose(d3_event, ul, d);
|
||||
});
|
||||
|
||||
@@ -269,9 +269,9 @@ export function uiConflicts(context) {
|
||||
// update
|
||||
choicesEnter
|
||||
.merge(choices)
|
||||
.each(function(d, i) {
|
||||
.each(function(d) {
|
||||
var ul = this.parentNode;
|
||||
if (ul.__data__.chosen === i) {
|
||||
if (ul.__data__.chosen === d.id) {
|
||||
choose(null, ul, d);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -219,10 +219,10 @@ export function uiFieldHelp(context, fieldName) {
|
||||
.append('div')
|
||||
.attr('class', 'field-help-nav-item')
|
||||
.html(function(d) { return d; })
|
||||
.on('click', function(d3_event, d, i) {
|
||||
.on('click', function(d3_event, d) {
|
||||
d3_event.stopPropagation();
|
||||
d3_event.preventDefault();
|
||||
clickHelp(i);
|
||||
clickHelp(titles.indexOf(d));
|
||||
});
|
||||
|
||||
enter
|
||||
|
||||
@@ -575,7 +575,7 @@ export function uiFieldCombo(field, context) {
|
||||
};
|
||||
targetIndex = null;
|
||||
})
|
||||
.on('drag', function(d3_event, d, index) {
|
||||
.on('drag', function(d3_event) {
|
||||
var x = d3_event.x - dragOrigin.x,
|
||||
y = d3_event.y - dragOrigin.y;
|
||||
|
||||
@@ -583,6 +583,8 @@ export function uiFieldCombo(field, context) {
|
||||
// don't display drag until dragging beyond a distance threshold
|
||||
Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)) <= 5) return;
|
||||
|
||||
var index = selection.nodes().indexOf(this);
|
||||
|
||||
d3_select(this)
|
||||
.classed('dragging', true);
|
||||
|
||||
@@ -648,10 +650,11 @@ export function uiFieldCombo(field, context) {
|
||||
});
|
||||
}
|
||||
})
|
||||
.on('end', function(d, index) {
|
||||
.on('end', function() {
|
||||
if (!d3_select(this).classed('dragging')) {
|
||||
return;
|
||||
}
|
||||
var index = selection.nodes().indexOf(this);
|
||||
|
||||
d3_select(this)
|
||||
.classed('dragging', false);
|
||||
|
||||
@@ -390,7 +390,7 @@ export function uiFieldLocalized(field, context) {
|
||||
}
|
||||
|
||||
|
||||
function changeLang(d) {
|
||||
function changeLang(d3_event, d) {
|
||||
var tags = {};
|
||||
|
||||
// make sure unrecognized suffixes are lowercase - #7156
|
||||
@@ -422,7 +422,7 @@ export function uiFieldLocalized(field, context) {
|
||||
}
|
||||
|
||||
|
||||
function changeValue(d) {
|
||||
function changeValue(d3_event, d) {
|
||||
if (!d.lang) return;
|
||||
var value = context.cleanTagValue(utilGetSetValue(d3_select(this))) || undefined;
|
||||
|
||||
@@ -508,7 +508,7 @@ export function uiFieldLocalized(field, context) {
|
||||
label
|
||||
.append('button')
|
||||
.attr('class', 'remove-icon-multilingual')
|
||||
.on('click', function(d3_event, d, index) {
|
||||
.on('click', function(d3_event, d) {
|
||||
if (field.locked()) return;
|
||||
d3_event.preventDefault();
|
||||
|
||||
|
||||
@@ -343,7 +343,9 @@ export function uiInit(context) {
|
||||
};
|
||||
|
||||
d3_select(window)
|
||||
.on('resize.editor', ui.onResize);
|
||||
.on('resize.editor', function() {
|
||||
ui.onResize();
|
||||
});
|
||||
|
||||
|
||||
var panPixels = 80;
|
||||
|
||||
@@ -279,8 +279,8 @@ export function uiPaneHelp(context) {
|
||||
|
||||
helpPane.renderContent = function(content) {
|
||||
|
||||
function clickHelp(d3_event, d, i) {
|
||||
if (d3_event) d3_event.preventDefault();
|
||||
function clickHelp(d, i) {
|
||||
|
||||
var rtl = (localizer.textDirection() === 'rtl');
|
||||
content.property('scrollTop', 0);
|
||||
helpPane.selection().select('.pane-heading h2').html(d.title);
|
||||
@@ -308,7 +308,7 @@ export function uiPaneHelp(context) {
|
||||
.attr('class', 'next')
|
||||
.on('click', function(d3_event) {
|
||||
d3_event.preventDefault();
|
||||
clickHelp(null, docs[i + 1], i + 1);
|
||||
clickHelp(docs[i + 1], i + 1);
|
||||
});
|
||||
|
||||
nextLink
|
||||
@@ -327,7 +327,7 @@ export function uiPaneHelp(context) {
|
||||
.attr('class', 'previous')
|
||||
.on('click', function(d3_event) {
|
||||
d3_event.preventDefault();
|
||||
clickHelp(null, docs[i - 1], i - 1);
|
||||
clickHelp(docs[i - 1], i - 1);
|
||||
});
|
||||
|
||||
prevLink
|
||||
@@ -363,7 +363,10 @@ export function uiPaneHelp(context) {
|
||||
.append('a')
|
||||
.attr('href', '#')
|
||||
.html(function(d) { return d.title; })
|
||||
.on('click', clickHelp);
|
||||
.on('click', function(d3_event, d) {
|
||||
d3_event.preventDefault();
|
||||
clickHelp(d, docs.indexOf(d));
|
||||
});
|
||||
|
||||
var shortcuts = toc
|
||||
.append('li')
|
||||
@@ -411,8 +414,7 @@ export function uiPaneHelp(context) {
|
||||
.append('div')
|
||||
.attr('class', 'nav');
|
||||
|
||||
clickHelp(null, docs[0], 0);
|
||||
|
||||
clickHelp(docs[0], 0);
|
||||
};
|
||||
|
||||
return helpPane;
|
||||
|
||||
@@ -35,11 +35,7 @@ export function uiSectionBackgroundDisplayOptions(context) {
|
||||
return Math.max(min, Math.min(x, max));
|
||||
}
|
||||
|
||||
function updateValue(d3_event, d, val) {
|
||||
if (!val && d3_event && d3_event.target) {
|
||||
val = d3_event.target.value;
|
||||
}
|
||||
|
||||
function updateValue(d, val) {
|
||||
val = clamp(val, _minVal, _maxVal);
|
||||
|
||||
_options[d] = val;
|
||||
@@ -86,6 +82,9 @@ export function uiSectionBackgroundDisplayOptions(context) {
|
||||
.attr('step', '0.05')
|
||||
.on('input', function(d3_event, d) {
|
||||
var val = d3_select(this).property('value');
|
||||
if (!val && d3_event && d3_event.target) {
|
||||
val = d3_event.target.value;
|
||||
}
|
||||
updateValue(d, val);
|
||||
});
|
||||
|
||||
@@ -107,7 +106,7 @@ export function uiSectionBackgroundDisplayOptions(context) {
|
||||
.html(t.html('background.reset_all'))
|
||||
.on('click', function() {
|
||||
for (var i = 0; i < _sliders.length; i++) {
|
||||
updateValue(_sliders[i],1);
|
||||
updateValue(_sliders[i], 1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ export function uiSectionRawMemberEditor(context) {
|
||||
};
|
||||
targetIndex = null;
|
||||
})
|
||||
.on('drag', function(d3_event, d, index) {
|
||||
.on('drag', function(d3_event) {
|
||||
var x = d3_event.x - dragOrigin.x,
|
||||
y = d3_event.y - dragOrigin.y;
|
||||
|
||||
@@ -282,6 +282,8 @@ export function uiSectionRawMemberEditor(context) {
|
||||
// don't display drag until dragging beyond a distance threshold
|
||||
Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)) <= 5) return;
|
||||
|
||||
var index = items.nodes().indexOf(this);
|
||||
|
||||
d3_select(this)
|
||||
.classed('dragging', true);
|
||||
|
||||
@@ -306,11 +308,11 @@ export function uiSectionRawMemberEditor(context) {
|
||||
return null;
|
||||
});
|
||||
})
|
||||
.on('end', function(d3_event, d, index) {
|
||||
.on('end', function(d3_event, d) {
|
||||
|
||||
if (!d3_select(this).classed('dragging')) {
|
||||
return;
|
||||
}
|
||||
if (!d3_select(this).classed('dragging')) return;
|
||||
|
||||
var index = items.nodes().indexOf(this);
|
||||
|
||||
d3_select(this)
|
||||
.classed('dragging', false);
|
||||
|
||||
Reference in New Issue
Block a user