Fix merge conflicts

This commit is contained in:
Nikola Plesa
2020-10-15 18:15:57 +02:00
502 changed files with 8920 additions and 6324 deletions
+10 -9
View File
@@ -30,29 +30,29 @@ export function uiAccount(context) {
.classed('hide', false);
// Link
userLink.append('a')
var userLinkA = userLink.append('a')
.attr('href', osm.userURL(details.display_name))
.attr('target', '_blank');
// Add thumbnail or dont
if (details.image_url) {
userLink.append('img')
userLinkA.append('img')
.attr('class', 'icon pre-text user-icon')
.attr('src', details.image_url);
} else {
userLink
userLinkA
.call(svgIcon('#iD-icon-avatar', 'pre-text light'));
}
// Add user name
userLink.append('span')
userLinkA.append('span')
.attr('class', 'label')
.text(details.display_name);
.html(details.display_name);
logoutLink.append('a')
.attr('class', 'logout')
.attr('href', '#')
.text(t('logout'))
.html(t.html('logout'))
.on('click.logout', function() {
d3_event.preventDefault();
osm.logout();
@@ -62,14 +62,15 @@ export function uiAccount(context) {
return function(selection) {
selection.append('li')
.attr('class', 'logoutLink')
.classed('hide', true);
selection.append('li')
.attr('class', 'userLink')
.classed('hide', true);
selection.append('li')
.attr('class', 'logoutLink')
.classed('hide', true);
if (osm) {
osm.on('change.account', function() { update(selection); });
update(selection);
+2 -2
View File
@@ -56,7 +56,7 @@ export function uiAttribution(context) {
attribution
.append('span')
.attr('class', 'attribution-text')
.text(terms_text);
.html(terms_text);
})
.merge(attributions);
@@ -76,7 +76,7 @@ export function uiAttribution(context) {
.merge(copyright);
copyright
.text(String);
.html(String);
}
+1 -2
View File
@@ -104,11 +104,10 @@ export function uiChangesetEditor(context) {
commentEnter
.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.call(svgIcon('#iD-icon-alert', 'inline'))
.attr('href', t('commit.google_warning_link'))
.append('span')
.text(t('commit.google_warning'));
.html(t.html('commit.google_warning'));
commentEnter
.transition()
+5 -3
View File
@@ -6,8 +6,10 @@ import { utilGetSetValue, utilRebind, utilTriggerEvent } from '../util';
// This code assumes that the combobox values will not have duplicate entries.
// It is keyed on the `value` of the entry. Data should be an array of objects like:
// [{
// value: 'display text', // required
// title: 'hover text' // optional
// value: 'string value', // required
// display: 'label html' // optional
// title: 'hover text' // optional
// terms: ['search terms'] // optional
// }, ...]
var _comboHideTimerID;
@@ -380,7 +382,7 @@ export function uiCombobox(context, klass) {
.append('a')
.attr('class', 'combobox-option')
.attr('title', function(d) { return d.title; })
.text(function(d) { return d.display || d.value; })
.html(function(d) { return d.display || d.value; })
.on('mouseenter', _mouseEnterHandler)
.on('mouseleave', _mouseLeaveHandler)
.merge(options)
+19 -22
View File
@@ -213,21 +213,14 @@ export function uiCommit(context) {
var headerTitle = header.enter()
.append('div')
.attr('class', 'header fillL header-container');
.attr('class', 'header fillL');
headerTitle
.append('div')
.attr('class', 'header-block header-block-outer');
headerTitle
.append('div')
.attr('class', 'header-block')
.append('h3')
.text(t('commit.title'));
.html(t.html('commit.title'));
headerTitle
.append('div')
.attr('class', 'header-block header-block-outer header-block-close')
.append('button')
.attr('class', 'close')
.on('click', function() {
@@ -283,7 +276,7 @@ export function uiCommit(context) {
prose = prose.enter()
.append('p')
.attr('class', 'commit-info')
.text(t('commit.upload_explanation'))
.html(t.html('commit.upload_explanation'))
.merge(prose);
// always check if this has changed, but only update prose.html()
@@ -306,12 +299,12 @@ export function uiCommit(context) {
userLink
.append('a')
.attr('class', 'user-info')
.text(user.display_name)
.html(user.display_name)
.attr('href', osm.userURL(user.display_name))
.attr('target', '_blank');
prose
.html(t('commit.upload_explanation_with_user', { user: userLink.html() }));
.html(t.html('commit.upload_explanation_with_user', { user: userLink.html() }));
});
@@ -337,7 +330,7 @@ export function uiCommit(context) {
labelEnter
.append('span')
.text(t('commit.request_review'));
.html(t.html('commit.request_review'));
// Update
requestReview = requestReview
@@ -362,7 +355,7 @@ export function uiCommit(context) {
.attr('class', 'secondary-action button cancel-button')
.append('span')
.attr('class', 'label')
.text(t('commit.cancel'));
.html(t.html('commit.cancel'));
var uploadButton = buttonEnter
.append('button')
@@ -370,7 +363,7 @@ export function uiCommit(context) {
uploadButton.append('span')
.attr('class', 'label')
.text(t('commit.save'));
.html(t.html('commit.save'));
var uploadBlockerTooltipText = getUploadBlockerMessage();
@@ -388,6 +381,12 @@ export function uiCommit(context) {
.on('click.save', function() {
if (!d3_select(this).classed('disabled')) {
this.blur(); // avoid keeping focus on the button - #4641
for (var key in context.changeset.tags) {
// remove any empty keys before upload
if (!key) delete context.changeset.tags[key];
}
context.uploader().save(context.changeset);
}
});
@@ -547,14 +546,12 @@ export function uiCommit(context) {
k = context.cleanTagKey(k);
if (readOnlyTags.indexOf(k) !== -1) return;
if (k !== '' && v !== undefined) {
if (onInput) {
tags[k] = v;
} else {
tags[k] = context.cleanTagValue(v);
}
} else {
if (v === undefined) {
delete tags[k];
} else if (onInput) {
tags[k] = v;
} else {
tags[k] = context.cleanTagValue(v);
}
});
+24 -23
View File
@@ -27,7 +27,7 @@ export function uiCommitWarnings(context) {
containerEnter
.append('h3')
.text(severity === 'warning' ? t('commit.warnings') : t('commit.errors'));
.html(severity === 'warning' ? t.html('commit.warnings') : t.html('commit.errors'));
containerEnter
.append('ul')
@@ -47,28 +47,8 @@ export function uiCommitWarnings(context) {
.append('li')
.attr('class', issueItem);
itemsEnter
.call(svgIcon('#iD-icon-alert', 'pre-text'));
itemsEnter
.append('strong')
.attr('class', 'issue-message');
itemsEnter.filter(function(d) { return d.tooltip; })
.call(uiTooltip()
.title(function(d) { return d.tooltip; })
.placement('top')
);
items = itemsEnter
.merge(items);
items.selectAll('.issue-message')
.text(function(d) {
return d.message(context);
});
items
var buttons = itemsEnter
.append('button')
.on('mouseover', function(d) {
if (d.entityIds) {
context.surface().selectAll(
@@ -86,6 +66,27 @@ export function uiCommitWarnings(context) {
.on('click', function(d) {
context.validator().focusIssue(d);
});
buttons
.call(svgIcon('#iD-icon-alert', 'pre-text'));
buttons
.append('strong')
.attr('class', 'issue-message');
buttons.filter(function(d) { return d.tooltip; })
.call(uiTooltip()
.title(function(d) { return d.tooltip; })
.placement('top')
);
items = itemsEnter
.merge(items);
items.selectAll('.issue-message')
.html(function(d) {
return d.message(context);
});
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ export function uiConfirm(selection) {
.on('click.confirm', function() {
modalSelection.remove();
})
.text(t('confirm.okay'))
.html(t.html('confirm.okay'))
.node()
.focus();
+10 -10
View File
@@ -66,7 +66,7 @@ export function uiConflicts(context) {
headerEnter
.append('h3')
.text(t('save.conflict.header'));
.html(t.html('save.conflict.header'));
var bodyEnter = selection.selectAll('.body')
.data([0])
@@ -77,7 +77,7 @@ export function uiConflicts(context) {
var conflictsHelpEnter = bodyEnter
.append('div')
.attr('class', 'conflicts-help')
.text(t('save.conflict.help'));
.html(t.html('save.conflict.help'));
// Download changes link
@@ -110,7 +110,7 @@ export function uiConflicts(context) {
linkEnter
.call(svgIcon('#iD-icon-load', 'inline'))
.append('span')
.text(t('save.conflict.download_changes'));
.html(t.html('save.conflict.download_changes'));
bodyEnter
@@ -123,7 +123,7 @@ export function uiConflicts(context) {
.attr('class', 'conflicts-done')
.attr('opacity', 0)
.style('display', 'none')
.text(t('save.conflict.done'));
.html(t.html('save.conflict.done'));
var buttonsEnter = bodyEnter
.append('div')
@@ -133,13 +133,13 @@ export function uiConflicts(context) {
.append('button')
.attr('disabled', _conflictList.length > 1)
.attr('class', 'action conflicts-button col6')
.text(t('save.title'))
.html(t.html('save.title'))
.on('click.try_again', tryAgain);
buttonsEnter
.append('button')
.attr('class', 'secondary-action conflicts-button col6')
.text(t('confirm.cancel'))
.html(t.html('confirm.cancel'))
.on('click.cancel', cancel);
}
@@ -177,13 +177,13 @@ export function uiConflicts(context) {
conflictEnter
.append('h4')
.attr('class', 'conflict-count')
.text(t('save.conflict.count', { num: index + 1, total: _conflictList.length }));
.html(t.html('save.conflict.count', { num: index + 1, total: _conflictList.length }));
conflictEnter
.append('a')
.attr('class', 'conflict-description')
.attr('href', '#')
.text(function(d) { return d.name; })
.html(function(d) { return d.name; })
.on('click', function(d) {
d3_event.preventDefault();
zoomToEntity(d.id);
@@ -215,7 +215,7 @@ export function uiConflicts(context) {
.data(['previous', 'next'])
.enter()
.append('button')
.text(function(d) { return t('save.conflict.' + d); })
.html(function(d) { return t.html('save.conflict.' + d); })
.attr('class', 'conflict-nav-button action col6')
.attr('disabled', function(d, i) {
return (i === 0 && index === 0) ||
@@ -265,7 +265,7 @@ export function uiConflicts(context) {
labelEnter
.append('span')
.text(function(d) { return d.text; });
.html(function(d) { return d.text; });
// update
choicesEnter
+6 -4
View File
@@ -39,24 +39,26 @@ export function uiContributors(context) {
.attr('class', 'user-link')
.attr('href', function(d) { return osm.userURL(d); })
.attr('target', '_blank')
.text(String);
.html(String);
if (u.length > limit) {
var count = d3_select(document.createElement('span'));
var othersNum = u.length - limit + 1;
count.append('a')
.attr('target', '_blank')
.attr('href', function() {
return osm.changesetsURL(context.map().center(), context.map().zoom());
})
.text(u.length - limit + 1);
.html(othersNum);
wrap.append('span')
.html(t('contributors.truncated_list', { users: userList.html(), count: count.html() }));
.html(t.html('contributors.truncated_list', { n: othersNum, users: userList.html(), count: count.html() }));
} else {
wrap.append('span')
.html(t('contributors.list', { users: userList.html() }));
.html(t.html('contributors.list', { users: userList.html() }));
}
if (!u.length) {
+1 -1
View File
@@ -33,7 +33,7 @@ export function uiDataEditor(context) {
headerEnter
.append('h3')
.text(t('map_data.title'));
.html(t.html('map_data.title'));
var body = selection.selectAll('.body')
+1 -1
View File
@@ -32,7 +32,7 @@ export function uiDataHeader() {
headerEnter
.append('div')
.attr('class', 'data-header-label')
.text(t('map_data.layers.custom.title'));
.html(t.html('map_data.layers.custom.title'));
}
+5 -5
View File
@@ -12,7 +12,7 @@ import { localizer } from '../core/localizer';
export function uiDisclosure(context, key, expandedDefault) {
var dispatch = d3_dispatch('toggled');
var _expanded;
var _title = utilFunctor('');
var _label = utilFunctor('');
var _updatePreference = true;
var _content = function () {};
@@ -49,7 +49,7 @@ export function uiDisclosure(context, key, expandedDefault) {
.classed('expanded', _expanded);
hideToggle.selectAll('.hide-toggle-text')
.text(_title());
.html(_label());
hideToggle.selectAll('.hide-toggle-icon')
.attr('xlink:href', _expanded ? '#iD-icon-down'
@@ -103,9 +103,9 @@ export function uiDisclosure(context, key, expandedDefault) {
};
disclosure.title = function(val) {
if (!arguments.length) return _title;
_title = utilFunctor(val);
disclosure.label = function(val) {
if (!arguments.length) return _label;
_label = utilFunctor(val);
return disclosure;
};
+19 -3
View File
@@ -5,6 +5,7 @@ import { geoVecAdd } from '../geo';
import { localizer } from '../core/localizer';
import { uiTooltip } from './tooltip';
import { utilRebind } from '../util/rebind';
import { utilHighlightEntities } from '../util/util';
import { svgIcon } from '../svg/icon';
@@ -89,6 +90,16 @@ export function uiEditMenu(context) {
.on('pointerdown mousedown', function pointerdown() {
// don't let button presses also act as map input - #1869
d3_event.stopPropagation();
})
.on('mouseenter.highlight', function(d) {
if (!d.relatedEntityIds || d3_select(this).classed('disabled')) return;
utilHighlightEntities(d.relatedEntityIds(), true, context);
})
.on('mouseleave.highlight', function(d) {
if (!d.relatedEntityIds) return;
utilHighlightEntities(d.relatedEntityIds(), false, context);
});
buttonsEnter.each(function(d) {
@@ -109,7 +120,7 @@ export function uiEditMenu(context) {
if (showLabels) {
buttonsEnter.append('span')
.attr('class', 'label')
.text(function(d) {
.html(function(d) {
return d.title;
});
}
@@ -140,6 +151,11 @@ export function uiEditMenu(context) {
function click(operation) {
d3_event.stopPropagation();
if (operation.relatedEntityIds) {
utilHighlightEntities(operation.relatedEntityIds(), false, context);
}
if (operation.disabled()) {
if (lastPointerUpType === 'touch' ||
lastPointerUpType === 'pen') {
@@ -148,7 +164,7 @@ export function uiEditMenu(context) {
.duration(4000)
.iconName('#iD-operation-' + operation.id)
.iconClass('operation disabled')
.text(operation.tooltip)();
.label(operation.tooltip)();
}
} else {
if (lastPointerUpType === 'touch' ||
@@ -157,7 +173,7 @@ export function uiEditMenu(context) {
.duration(2000)
.iconName('#iD-operation-' + operation.id)
.iconClass('operation')
.text(operation.annotation() || operation.title)();
.label(operation.annotation() || operation.title)();
}
operation();
+2 -21
View File
@@ -1,5 +1,4 @@
import { dispatch as d3_dispatch } from 'd3-dispatch';
import { event as d3_event } from 'd3-selection';
import deepEqual from 'fast-deep-equal';
import { presetManager } from '../presets';
@@ -41,7 +40,7 @@ export function uiEntityEditor(context) {
// Enter
var headerEnter = header.enter()
.append('div')
.attr('class', 'header fillL cf');
.attr('class', 'header fillL');
headerEnter
.append('button')
@@ -62,7 +61,7 @@ export function uiEntityEditor(context) {
.merge(headerEnter);
header.selectAll('h3')
.text(_entityIDs.length === 1 ? t('inspector.edit') : t('inspector.edit_features'));
.html(_entityIDs.length === 1 ? t.html('inspector.edit') : t.html('inspector.edit_features'));
header.selectAll('.preset-reset')
.on('click', function() {
@@ -112,24 +111,6 @@ export function uiEntityEditor(context) {
body.call(section.render);
});
body
.selectAll('.key-trap-wrap')
.data([0])
.enter()
.append('div')
.attr('class', 'key-trap-wrap')
.append('input')
.attr('type', 'text')
.attr('class', 'key-trap')
.on('keydown.key-trap', function() {
// On tabbing, send focus back to the first field on the inspector-body
// (probably the `name` field) #4159
if (d3_event.keyCode === 9 && !d3_event.shiftKey) {
d3_event.preventDefault();
body.select('input').node().focus();
}
});
context.history()
.on('change.entity-editor', historyChanged);
+2 -3
View File
@@ -12,7 +12,7 @@ export function uiFeatureInfo(context) {
var hiddenList = features.hidden().map(function(k) {
if (stats[k]) {
count += stats[k];
return String(stats[k]) + ' ' + t('feature.' + k + '.description');
return t('inspector.title_count', { title: t.html('feature.' + k + '.description'), count: stats[k] });
}
}).filter(Boolean);
@@ -28,8 +28,7 @@ export function uiFeatureInfo(context) {
selection.append('a')
.attr('class', 'chip')
.attr('href', '#')
.attr('tabindex', -1)
.html(t('feature_info.hidden_warning', { count: count }))
.html(t.html('feature_info.hidden_warning', { count: count }))
.call(tooltipBehavior)
.on('click', function() {
tooltipBehavior.hide();
+28 -25
View File
@@ -31,16 +31,19 @@ export function uiFeatureList(context) {
function featureList(selection) {
var header = selection
.append('div')
.attr('class', 'header fillL cf');
.attr('class', 'header fillL');
header
.append('h3')
.text(t('inspector.feature_list'));
.html(t.html('inspector.feature_list'));
var searchWrap = selection
.append('div')
.attr('class', 'search-header');
searchWrap
.call(svgIcon('#iD-icon-search', 'pre-text'));
var search = searchWrap
.append('input')
.attr('placeholder', t('inspector.search'))
@@ -50,16 +53,13 @@ export function uiFeatureList(context) {
.on('keydown', keydown)
.on('input', inputevent);
searchWrap
.call(svgIcon('#iD-icon-search', 'pre-text'));
var listWrap = selection
.append('div')
.attr('class', 'inspector-body');
var list = listWrap
.append('div')
.attr('class', 'feature-list cf');
.attr('class', 'feature-list');
context
.on('exit.feature-list', clearSearch);
@@ -89,7 +89,9 @@ export function uiFeatureList(context) {
function keypress() {
var q = search.property('value'),
items = list.selectAll('.feature-list-item');
if (d3_event.keyCode === 13 && q.length && items.size()) { // return
if (d3_event.keyCode === 13 && // ↩ Return
q.length &&
items.size()) {
click(items.datum());
}
}
@@ -122,19 +124,6 @@ export function uiFeatureList(context) {
if (!q) return result;
var idMatch = q.match(/(?:^|\W)(node|way|relation|[nwr])\W?0*([1-9]\d*)(?:\W|$)/i);
if (idMatch) {
var elemType = idMatch[1].charAt(0);
var elemId = idMatch[2];
result.push({
id: elemType + elemId,
geometry: elemType === 'n' ? 'point' : elemType === 'w' ? 'line' : 'relation',
type: elemType === 'n' ? t('inspector.node') : elemType === 'w' ? t('inspector.way') : t('inspector.relation'),
name: elemId
});
}
var locationMatch = sexagesimal.pair(q.toUpperCase()) || q.match(/^(-?\d+\.?\d*)\s+(-?\d+\.?\d*)$/);
if (locationMatch) {
@@ -148,6 +137,20 @@ export function uiFeatureList(context) {
});
}
// A location search takes priority over an ID search
var idMatch = !locationMatch && q.match(/(?:^|\W)(node|way|relation|[nwr])\W?0*([1-9]\d*)(?:\W|$)/i);
if (idMatch) {
var elemType = idMatch[1].charAt(0);
var elemId = idMatch[2];
result.push({
id: elemType + elemId,
geometry: elemType === 'n' ? 'point' : elemType === 'w' ? 'line' : 'relation',
type: elemType === 'n' ? t('inspector.node') : elemType === 'w' ? t('inspector.way') : t('inspector.relation'),
name: elemId
});
}
var allEntities = graph.entities;
var localResults = [];
for (var id in allEntities) {
@@ -253,20 +256,20 @@ export function uiFeatureList(context) {
.attr('class', 'entity-name');
list.selectAll('.no-results-item .entity-name')
.text(t('geocoder.no_results_worldwide'));
.html(t.html('geocoder.no_results_worldwide'));
if (services.geocoder) {
list.selectAll('.geocode-item')
.data([0])
.enter()
.append('button')
.attr('class', 'geocode-item')
.attr('class', 'geocode-item secondary-action')
.on('click', geocoderSearch)
.append('div')
.attr('class', 'label')
.append('span')
.attr('class', 'entity-name')
.text(t('geocoder.search'));
.html(t.html('geocoder.search'));
}
list.selectAll('.no-results-item')
@@ -302,12 +305,12 @@ export function uiFeatureList(context) {
label
.append('span')
.attr('class', 'entity-type')
.text(function(d) { return d.type; });
.html(function(d) { return d.type; });
label
.append('span')
.attr('class', 'entity-name')
.text(function(d) { return d.name; });
.html(function(d) { return d.name; });
enter
.style('opacity', 0)
+3 -5
View File
@@ -30,7 +30,7 @@ export function uiField(context, presetField, entityIDs, options) {
var _locked = false;
var _lockedTip = uiTooltip()
.title(t('inspector.lock.suggestion', { label: field.label }))
.title(t.html('inspector.lock.suggestion', { label: field.label }))
.placement('bottom');
@@ -132,7 +132,7 @@ export function uiField(context, presetField, entityIDs, options) {
textEnter
.append('span')
.attr('class', 'label-textvalue')
.text(function(d) { return d.label(); });
.html(function(d) { return d.label(); });
textEnter
.append('span')
@@ -143,7 +143,6 @@ export function uiField(context, presetField, entityIDs, options) {
.append('button')
.attr('class', 'remove-icon')
.attr('title', t('icons.remove'))
.attr('tabindex', -1)
.call(svgIcon('#iD-operation-delete'));
}
@@ -152,7 +151,6 @@ export function uiField(context, presetField, entityIDs, options) {
.append('button')
.attr('class', 'modified-icon')
.attr('title', t('icons.undo'))
.attr('tabindex', -1)
.call(svgIcon((localizer.textDirection() === 'rtl') ? '#iD-icon-redo' : '#iD-icon-undo'));
}
}
@@ -185,7 +183,7 @@ export function uiField(context, presetField, entityIDs, options) {
// instantiate tag reference
if (options.wrap && options.info) {
var referenceKey = d.key;
var referenceKey = d.key || '';
if (d.type === 'multiCombo') { // lookup key without the trailing ':'
referenceKey = referenceKey.replace(/:$/, '');
}
+13 -14
View File
@@ -55,15 +55,15 @@ export function uiFieldHelp(context, fieldName) {
var fieldHelpHeadings = {};
var replacements = {
distField: t('restriction.controls.distance'),
viaField: t('restriction.controls.via'),
fromShadow: icon('#iD-turn-shadow', 'pre-text shadow from'),
allowShadow: icon('#iD-turn-shadow', 'pre-text shadow allow'),
restrictShadow: icon('#iD-turn-shadow', 'pre-text shadow restrict'),
onlyShadow: icon('#iD-turn-shadow', 'pre-text shadow only'),
allowTurn: icon('#iD-turn-yes', 'pre-text turn'),
restrictTurn: icon('#iD-turn-no', 'pre-text turn'),
onlyTurn: icon('#iD-turn-only', 'pre-text turn')
distField: t.html('restriction.controls.distance'),
viaField: t.html('restriction.controls.via'),
fromShadow: icon('#iD-turn-shadow', 'inline shadow from'),
allowShadow: icon('#iD-turn-shadow', 'inline shadow allow'),
restrictShadow: icon('#iD-turn-shadow', 'inline shadow restrict'),
onlyShadow: icon('#iD-turn-shadow', 'inline shadow only'),
allowTurn: icon('#iD-turn-yes', 'inline turn'),
restrictTurn: icon('#iD-turn-no', 'inline turn'),
onlyTurn: icon('#iD-turn-only', 'inline turn')
};
@@ -74,12 +74,12 @@ export function uiFieldHelp(context, fieldName) {
var subkey = helpkey + '.' + part;
var depth = fieldHelpHeadings[subkey]; // is this subkey a heading?
var hhh = depth ? Array(depth + 1).join('#') + ' ' : ''; // if so, prepend with some ##'s
return all + hhh + t(subkey, replacements) + '\n\n';
return all + hhh + t.html(subkey, replacements) + '\n\n';
}, '');
return {
key: helpkey,
title: t(helpkey + '.title'),
title: t.html(helpkey + '.title'),
html: marked(text.trim())
};
});
@@ -149,7 +149,6 @@ export function uiFieldHelp(context, fieldName) {
button.enter()
.append('button')
.attr('class', 'field-help-button')
.attr('tabindex', -1)
.call(svgIcon('#iD-icon-help'))
.merge(button)
.on('click', function () {
@@ -198,7 +197,7 @@ export function uiFieldHelp(context, fieldName) {
titleEnter
.append('h2')
.attr('class', ((localizer.textDirection() === 'rtl') ? 'fr' : 'fl'))
.text(t('help.field.' + fieldName + '.title'));
.html(t.html('help.field.' + fieldName + '.title'));
titleEnter
.append('button')
@@ -220,7 +219,7 @@ export function uiFieldHelp(context, fieldName) {
.enter()
.append('div')
.attr('class', 'field-help-nav-item')
.text(function(d) { return d; })
.html(function(d) { return d; })
.on('click', function(d, i) {
d3_event.stopPropagation();
d3_event.preventDefault();
+1 -1
View File
@@ -40,7 +40,7 @@ export function uiFieldAccess(field, context) {
.append('span')
.attr('class', 'label preset-label-access')
.attr('for', function(d) { return 'preset-input-access-' + d; })
.text(function(d) { return field.t('types.' + d); });
.html(function(d) { return field.t.html('types.' + d); });
enter
.append('div')
+10 -10
View File
@@ -36,14 +36,14 @@ export function uiFieldCheck(field, context) {
if (options) {
for (var k in options) {
values.push(k === 'undefined' ? undefined : k);
texts.push(field.t('options.' + k, { 'default': options[k] }));
texts.push(field.t.html('options.' + k, { 'default': options[k] }));
}
} else {
values = [undefined, 'yes'];
texts = [t('inspector.unknown'), t('inspector.check.yes')];
texts = [t.html('inspector.unknown'), t.html('inspector.check.yes')];
if (field.type !== 'defaultCheck') {
values.push('no');
texts.push(t('inspector.check.no'));
texts.push(t.html('inspector.check.no'));
}
}
@@ -59,7 +59,7 @@ export function uiFieldCheck(field, context) {
for (var key in entity.tags) {
if (key in osmOneWayTags && (entity.tags[key] in osmOneWayTags[key])) {
_impliedYes = true;
texts[0] = t('presets.fields.oneway_yes.options.undefined');
texts[0] = t.html('presets.fields.oneway_yes.options.undefined');
break;
}
}
@@ -83,7 +83,7 @@ export function uiFieldCheck(field, context) {
var icon = pseudoDirection ? '#iD-icon-forward' : '#iD-icon-backward';
selection.selectAll('.reverser-span')
.text(t('inspector.check.reverser'))
.html(t.html('inspector.check.reverser'))
.call(svgIcon(icon, 'inline'));
return selection;
@@ -108,13 +108,13 @@ export function uiFieldCheck(field, context) {
enter
.append('span')
.text(texts[0])
.html(texts[0])
.attr('class', 'value');
if (field.type === 'onewayCheck') {
enter
.append('a')
.attr('class', 'reverser button' + (reverserHidden() ? ' hide' : ''))
.append('button')
.attr('class', 'reverser' + (reverserHidden() ? ' hide' : ''))
.attr('href', '#')
.append('span')
.attr('class', 'reverser-span');
@@ -163,7 +163,7 @@ export function uiFieldCheck(field, context) {
}
return graph;
},
t('operations.reverse.annotation')
t('operations.reverse.annotation.line', { n: 1 })
);
// must manually revalidate since no 'change' event was called
@@ -212,7 +212,7 @@ export function uiFieldCheck(field, context) {
.property('checked', isChecked(_value));
text
.text(isMixed ? t('inspector.multiple_values') : textFor(_value))
.html(isMixed ? t.html('inspector.multiple_values') : textFor(_value))
.classed('mixed', isMixed);
label
+110 -104
View File
@@ -11,6 +11,7 @@ import { uiCombobox } from '../combobox';
import { utilArrayUniq, utilGetSetValue, utilNoAuto, utilRebind, utilTotalExtent, utilUnicodeCharsCount } from '../../util';
export {
uiFieldCombo as uiFieldManyCombo,
uiFieldCombo as uiFieldMultiCombo,
uiFieldCombo as uiFieldNetworkCombo,
uiFieldCombo as uiFieldSemiCombo,
@@ -20,20 +21,18 @@ export {
export function uiFieldCombo(field, context) {
var dispatch = d3_dispatch('change');
var taginfo = services.taginfo;
var isMulti = (field.type === 'multiCombo');
var isNetwork = (field.type === 'networkCombo');
var isSemi = (field.type === 'semiCombo');
var optstrings = field.strings && field.strings.options;
var optarray = field.options;
var snake_case = (field.snake_case || (field.snake_case === undefined));
var caseSensitive = field.caseSensitive;
var combobox = uiCombobox(context, 'combo-' + field.safeid)
.caseSensitive(caseSensitive)
.minItems(isMulti || isSemi ? 1 : 2);
var container = d3_select(null);
var inputWrap = d3_select(null);
var input = d3_select(null);
var _isMulti = (field.type === 'multiCombo' || field.type === 'manyCombo');
var _isNetwork = (field.type === 'networkCombo');
var _isSemi = (field.type === 'semiCombo');
var _optstrings = field.strings && field.strings.options;
var _optarray = field.options;
var _snake_case = (field.snake_case || (field.snake_case === undefined));
var _combobox = uiCombobox(context, 'combo-' + field.safeid)
.caseSensitive(field.caseSensitive)
.minItems(_isMulti || _isSemi ? 1 : 2);
var _container = d3_select(null);
var _inputWrap = d3_select(null);
var _input = d3_select(null);
var _comboData = [];
var _multiData = [];
var _entityIDs = [];
@@ -49,7 +48,7 @@ export function uiFieldCombo(field, context) {
// ensure multiCombo field.key ends with a ':'
if (isMulti && /[^:]$/.test(field.key)) {
if (_isMulti && field.key && /[^:]$/.test(field.key)) {
field.key += ':';
}
@@ -74,7 +73,7 @@ export function uiFieldCombo(field, context) {
function tagValue(dval) {
dval = clean(dval || '');
if (optstrings) {
if (_optstrings) {
var found = _comboData.find(function(o) {
return o.key && clean(o.value) === dval;
});
@@ -87,7 +86,7 @@ export function uiFieldCombo(field, context) {
return 'yes';
}
return (snake_case ? snake(dval) : dval) || undefined;
return (_snake_case ? snake(dval) : dval) || undefined;
}
@@ -96,7 +95,7 @@ export function uiFieldCombo(field, context) {
function displayValue(tval) {
tval = tval || '';
if (optstrings) {
if (_optstrings) {
var found = _comboData.find(function(o) {
return o.key === tval && o.value;
});
@@ -109,7 +108,7 @@ export function uiFieldCombo(field, context) {
return '';
}
return snake_case ? unsnake(tval) : tval;
return _snake_case ? unsnake(tval) : tval;
}
@@ -128,38 +127,39 @@ export function uiFieldCombo(field, context) {
function initCombo(selection, attachTo) {
if (optstrings) {
if (_optstrings) {
selection.attr('readonly', 'readonly');
selection.call(combobox, attachTo);
selection.call(_combobox, attachTo);
setStaticValues(setPlaceholder);
} else if (optarray) {
selection.call(combobox, attachTo);
} else if (_optarray) {
selection.call(_combobox, attachTo);
setStaticValues(setPlaceholder);
} else if (taginfo) {
selection.call(combobox.fetcher(setTaginfoValues), attachTo);
} else if (services.taginfo) {
selection.call(_combobox.fetcher(setTaginfoValues), attachTo);
setTaginfoValues('', setPlaceholder);
}
}
function setStaticValues(callback) {
if (!(optstrings || optarray)) return;
if (!(_optstrings || _optarray)) return;
if (optstrings) {
_comboData = Object.keys(optstrings).map(function(k) {
var v = field.t('options.' + k, { 'default': optstrings[k] });
if (_optstrings) {
_comboData = Object.keys(_optstrings).map(function(k) {
var v = field.t('options.' + k, { 'default': _optstrings[k] });
return {
key: k,
value: v,
title: v
title: v,
display: field.t.html('options.' + k, { 'default': _optstrings[k] })
};
});
} else if (optarray) {
_comboData = optarray.map(function(k) {
var v = snake_case ? unsnake(k) : k;
} else if (_optarray) {
_comboData = _optarray.map(function(k) {
var v = _snake_case ? unsnake(k) : k;
return {
key: k,
value: v,
@@ -168,15 +168,15 @@ export function uiFieldCombo(field, context) {
});
}
combobox.data(objectDifference(_comboData, _multiData));
_combobox.data(objectDifference(_comboData, _multiData));
if (callback) callback(_comboData);
}
function setTaginfoValues(q, callback) {
var fn = isMulti ? 'multikeys' : 'values';
var query = (isMulti ? field.key : '') + q;
var hasCountryPrefix = isNetwork && _countryCode && _countryCode.indexOf(q.toLowerCase()) === 0;
var fn = _isMulti ? 'multikeys' : 'values';
var query = (_isMulti ? field.key : '') + q;
var hasCountryPrefix = _isNetwork && _countryCode && _countryCode.indexOf(q.toLowerCase()) === 0;
if (hasCountryPrefix) {
query = _countryCode + ':';
}
@@ -191,7 +191,7 @@ export function uiFieldCombo(field, context) {
params.geometry = context.graph().geometry(_entityIDs[0]);
}
taginfo[fn](params, function(err, data) {
services.taginfo[fn](params, function(err, data) {
if (err) return;
data = data.filter(function(d) {
@@ -220,16 +220,16 @@ export function uiFieldCombo(field, context) {
}
// hide the caret if there are no suggestions
container.classed('empty-combobox', data.length === 0);
_container.classed('empty-combobox', data.length === 0);
_comboData = data.map(function(d) {
var k = d.value;
if (isMulti) k = k.replace(field.key, '');
var v = snake_case ? unsnake(k) : k;
if (_isMulti) k = k.replace(field.key, '');
var v = _snake_case ? unsnake(k) : k;
return {
key: k,
value: v,
title: isMulti ? v : d.title
title: _isMulti ? v : d.title
};
});
@@ -241,7 +241,7 @@ export function uiFieldCombo(field, context) {
function setPlaceholder(values) {
if (isMulti || isSemi) {
if (_isMulti || _isSemi) {
_staticPlaceholder = field.placeholder() || t('inspector.add');
} else {
var vals = values
@@ -257,13 +257,13 @@ export function uiFieldCombo(field, context) {
}
var ph;
if (!isMulti && !isSemi && _tags && Array.isArray(_tags[field.key])) {
if (!_isMulti && !_isSemi && _tags && Array.isArray(_tags[field.key])) {
ph = t('inspector.multiple_values');
} else {
ph = _staticPlaceholder;
}
container.selectAll('input')
_container.selectAll('input')
.attr('placeholder', ph);
}
@@ -272,17 +272,17 @@ export function uiFieldCombo(field, context) {
var t = {};
var val;
if (isMulti || isSemi) {
val = tagValue(utilGetSetValue(input).replace(/,/g, ';')) || '';
container.classed('active', false);
utilGetSetValue(input, '');
if (_isMulti || _isSemi) {
val = tagValue(utilGetSetValue(_input).replace(/,/g, ';')) || '';
_container.classed('active', false);
utilGetSetValue(_input, '');
var vals = val.split(';').filter(Boolean);
if (!vals.length) return;
if (isMulti) {
if (_isMulti) {
utilArrayUniq(vals).forEach(function(v) {
var key = field.key + v;
var key = (field.key || '') + v;
if (_tags) {
// don't set a multicombo value to 'yes' if it already has a non-'no' value
// e.g. `language:de=main`
@@ -294,16 +294,16 @@ export function uiFieldCombo(field, context) {
t[key] = 'yes';
});
} else if (isSemi) {
} else if (_isSemi) {
var arr = _multiData.map(function(d) { return d.key; });
arr = arr.concat(vals);
t[field.key] = context.cleanTagValue(utilArrayUniq(arr).filter(Boolean).join(';'));
}
window.setTimeout(function() { input.node().focus(); }, 10);
window.setTimeout(function() { _input.node().focus(); }, 10);
} else {
var rawValue = utilGetSetValue(input);
var rawValue = utilGetSetValue(_input);
// don't override multiple values with blank string
if (!rawValue && Array.isArray(_tags[field.key])) return;
@@ -317,11 +317,12 @@ export function uiFieldCombo(field, context) {
function removeMultikey(d) {
d3_event.preventDefault();
d3_event.stopPropagation();
var t = {};
if (isMulti) {
if (_isMulti) {
t[d.key] = undefined;
} else if (isSemi) {
} else if (_isSemi) {
var arr = _multiData.map(function(md) {
return md.key === d.key ? null : md.key;
}).filter(Boolean);
@@ -334,17 +335,17 @@ export function uiFieldCombo(field, context) {
function combo(selection) {
container = selection.selectAll('.form-field-input-wrap')
_container = selection.selectAll('.form-field-input-wrap')
.data([0]);
var type = (isMulti || isSemi) ? 'multicombo': 'combo';
container = container.enter()
var type = (_isMulti || _isSemi) ? 'multicombo': 'combo';
_container = _container.enter()
.append('div')
.attr('class', 'form-field-input-wrap form-field-input-' + type)
.merge(container);
.merge(_container);
if (isMulti || isSemi) {
container = container.selectAll('.chiplist')
if (_isMulti || _isSemi) {
_container = _container.selectAll('.chiplist')
.data([0]);
var listClass = 'chiplist';
@@ -355,67 +356,67 @@ export function uiFieldCombo(field, context) {
listClass += ' full-line-chips';
}
container = container.enter()
_container = _container.enter()
.append('ul')
.attr('class', listClass)
.on('click', function() {
window.setTimeout(function() { input.node().focus(); }, 10);
window.setTimeout(function() { _input.node().focus(); }, 10);
})
.merge(container);
.merge(_container);
inputWrap = container.selectAll('.input-wrap')
_inputWrap = _container.selectAll('.input-wrap')
.data([0]);
inputWrap = inputWrap.enter()
_inputWrap = _inputWrap.enter()
.append('li')
.attr('class', 'input-wrap')
.merge(inputWrap);
.merge(_inputWrap);
input = inputWrap.selectAll('input')
_input = _inputWrap.selectAll('input')
.data([0]);
} else {
input = container.selectAll('input')
_input = _container.selectAll('input')
.data([0]);
}
input = input.enter()
_input = _input.enter()
.append('input')
.attr('type', 'text')
.attr('id', field.domId)
.call(utilNoAuto)
.call(initCombo, selection)
.merge(input);
.merge(_input);
if (isNetwork) {
if (_isNetwork) {
var extent = combinedEntityExtent();
var countryCode = extent && countryCoder.iso1A2Code(extent.center());
_countryCode = countryCode && countryCode.toLowerCase();
}
input
_input
.on('change', change)
.on('blur', change);
input
_input
.on('keydown.field', function() {
switch (d3_event.keyCode) {
case 13: // ↩ Return
input.node().blur(); // blurring also enters the value
_input.node().blur(); // blurring also enters the value
d3_event.stopPropagation();
break;
}
});
if (isMulti || isSemi) {
combobox
if (_isMulti || _isSemi) {
_combobox
.on('accept', function() {
input.node().blur();
input.node().focus();
_input.node().blur();
_input.node().focus();
});
input
.on('focus', function() { container.classed('active', true); });
_input
.on('focus', function() { _container.classed('active', true); });
}
}
@@ -423,19 +424,19 @@ export function uiFieldCombo(field, context) {
combo.tags = function(tags) {
_tags = tags;
if (isMulti || isSemi) {
if (_isMulti || _isSemi) {
_multiData = [];
var maxLength;
if (isMulti) {
if (_isMulti) {
// Build _multiData array containing keys already set..
for (var k in tags) {
if (k.indexOf(field.key) !== 0) continue;
if ((field.key && k.indexOf(field.key) !== 0) || field.keys.indexOf(k) === -1) continue;
var v = tags[k];
if (!v || (typeof v === 'string' && v.toLowerCase() === 'no')) continue;
var suffix = k.substring(field.key.length);
var suffix = field.key ? k.substring(field.key.length) : k;
_multiData.push({
key: k,
value: displayValue(suffix),
@@ -443,13 +444,17 @@ export function uiFieldCombo(field, context) {
});
}
// Set keys for form-field modified (needed for undo and reset buttons)..
field.keys = _multiData.map(function(d) { return d.key; });
if (field.key) {
// Set keys for form-field modified (needed for undo and reset buttons)..
field.keys = _multiData.map(function(d) { return d.key; });
// limit the input length so it fits after prepending the key prefix
maxLength = context.maxCharsForTagKey() - utilUnicodeCharsCount(field.key);
// limit the input length so it fits after prepending the key prefix
maxLength = context.maxCharsForTagKey() - utilUnicodeCharsCount(field.key);
} else {
maxLength = context.maxCharsForTagKey();
}
} else if (isSemi) {
} else if (_isSemi) {
var allValues = [];
var commonValues;
@@ -492,23 +497,23 @@ export function uiFieldCombo(field, context) {
// a negative maxlength doesn't make sense
maxLength = Math.max(0, maxLength);
var allowDragAndDrop = isSemi // only semiCombo values are ordered
var allowDragAndDrop = _isSemi // only semiCombo values are ordered
&& !Array.isArray(tags[field.key]);
// Exclude existing multikeys from combo options..
var available = objectDifference(_comboData, _multiData);
combobox.data(available);
_combobox.data(available);
// Hide 'Add' button if this field uses fixed set of
// translateable optstrings and they're all currently used,
// translateable _optstrings and they're all currently used,
// or if the field is already at its character limit
var hideAdd = (optstrings && !available.length) || maxLength <= 0;
container.selectAll('.chiplist .input-wrap')
var hideAdd = (_optstrings && !available.length) || maxLength <= 0;
_container.selectAll('.chiplist .input-wrap')
.style('display', hideAdd ? 'none' : null);
// Render chips
var chips = container.selectAll('.chip')
var chips = _container.selectAll('.chip')
.data(_multiData);
chips.exit()
@@ -536,12 +541,13 @@ export function uiFieldCombo(field, context) {
}
chips.select('span')
.text(function(d) { return d.value; });
.html(function(d) { return d.value; });
chips.select('a')
.attr('href', '#')
.on('click', removeMultikey)
.attr('class', 'remove')
.text('×');
.html('×');
} else {
var isMixed = Array.isArray(tags[field.key]);
@@ -550,7 +556,7 @@ export function uiFieldCombo(field, context) {
return displayValue(val);
}).filter(Boolean);
utilGetSetValue(input, !isMixed ? displayValue(tags[field.key]) : '')
utilGetSetValue(_input, !isMixed ? displayValue(tags[field.key]) : '')
.attr('title', isMixed ? mixedValues.join('\n') : undefined)
.attr('placeholder', isMixed ? t('inspector.multiple_values') : _staticPlaceholder || '')
.classed('mixed', isMixed);
@@ -585,7 +591,7 @@ export function uiFieldCombo(field, context) {
var draggedTagWidth = d3_select(this).node().offsetWidth;
if (field.key === 'destination') { // meaning tags are full width
container.selectAll('.chip')
_container.selectAll('.chip')
.style('transform', function(d2, index2) {
var node = d3_select(this).node();
@@ -607,7 +613,7 @@ export function uiFieldCombo(field, context) {
return null;
});
} else {
container.selectAll('.chip')
_container.selectAll('.chip')
.each(function(d2, index2) {
var node = d3_select(this).node();
@@ -650,7 +656,7 @@ export function uiFieldCombo(field, context) {
d3_select(this)
.classed('dragging', false);
container.selectAll('.chip')
_container.selectAll('.chip')
.style('transform', null);
if (typeof targetIndex === 'number') {
@@ -678,7 +684,7 @@ export function uiFieldCombo(field, context) {
combo.focus = function() {
input.node().focus();
_input.node().focus();
};
+1 -1
View File
@@ -49,7 +49,7 @@ export function uiFieldCycleway(field, context) {
.append('span')
.attr('class', 'label preset-label-cycleway')
.attr('for', function(d) { return 'preset-input-cycleway-' + stripcolon(d); })
.text(function(d) { return field.t('types.' + d); });
.html(function(d) { return field.t.html('types.' + d); });
enter
.append('div')
+2
View File
@@ -21,6 +21,7 @@ import {
import {
uiFieldCombo,
uiFieldManyCombo,
uiFieldMultiCombo,
uiFieldNetworkCombo,
uiFieldSemiCombo,
@@ -64,6 +65,7 @@ export var uiFields = {
lanes: uiFieldLanes,
localized: uiFieldLocalized,
maxspeed: uiFieldMaxspeed,
manyCombo: uiFieldManyCombo,
multiCombo: uiFieldMultiCombo,
networkCombo: uiFieldNetworkCombo,
number: uiFieldNumber,
-2
View File
@@ -80,7 +80,6 @@ export function uiFieldText(field, context) {
buttons.enter()
.append('button')
.attr('tabindex', -1)
.attr('class', function(d) {
var which = (d === 1 ? 'increment' : 'decrement');
return 'form-field-button ' + which;
@@ -106,7 +105,6 @@ export function uiFieldText(field, context) {
outlinkButton.enter()
.append('button')
.attr('tabindex', -1)
.call(svgIcon('#iD-icon-out-link'))
.attr('class', 'form-field-button foreign-id-permalink')
.attr('title', function() {
+3 -3
View File
@@ -77,7 +77,7 @@ export function uiFieldLanes(field, context) {
.append('text')
.attr('y', 40)
.attr('x', 14)
.text('▲');
.html('▲');
enter
.append('g')
@@ -85,7 +85,7 @@ export function uiFieldLanes(field, context) {
.append('text')
.attr('y', 40)
.attr('x', 14)
.text('▲▼');
.html('▲▼');
enter
.append('g')
@@ -93,7 +93,7 @@ export function uiFieldLanes(field, context) {
.append('text')
.attr('y', 40)
.attr('x', 14)
.text('▼');
.html('▼');
lane = lane
+8 -22
View File
@@ -52,7 +52,7 @@ export function uiFieldLocalized(field, context) {
var _selection = d3_select(null);
var _multilingual = [];
var _buttonTip = uiTooltip()
.title(t('translate.translate'))
.title(t.html('translate.translate'))
.placement('left');
var _wikiTitles;
var _entityIDs = [];
@@ -219,7 +219,6 @@ export function uiFieldLocalized(field, context) {
translateButton = translateButton.enter()
.append('button')
.attr('class', 'localized-add form-field-button')
.attr('tabindex', -1)
.call(svgIcon('#iD-icon-plus'))
.merge(translateButton);
@@ -260,7 +259,6 @@ export function uiFieldLocalized(field, context) {
var preset = presetManager.match(latest, context.graph());
if (preset && preset.suggestion) return; // already accepted
// note: here we are testing against "decorated" names, i.e. 'Starbucks Cafe'
var name = utilGetSetValue(input).trim();
var matched = allSuggestions.filter(function(s) { return name === s.name(); });
@@ -293,25 +291,10 @@ export function uiFieldLocalized(field, context) {
}
// user hit escape, clean whatever preset name appears after the last ' '
// user hit escape
function cancelBrand() {
var name = utilGetSetValue(input);
var clean = cleanName(name);
if (clean !== name) {
utilGetSetValue(input, clean);
dispatch.call('change', this, { name: clean });
}
}
// Remove whatever is after the last ' '
// NOTE: split/join on en-dash, not a hypen (to avoid conflict with fr - nl names in Brussels etc)
function cleanName(name) {
var parts = name.split(' ');
if (parts.length > 1) {
parts.pop();
name = parts.join(' ');
}
return name;
dispatch.call('change', this, { name: name });
}
@@ -333,14 +316,17 @@ export function uiFieldLocalized(field, context) {
var sTag = s.id.split('/', 2);
var sKey = sTag[0];
var sValue = sTag[1];
var subtitle = s.subtitle();
var name = s.name();
if (subtitle) name += ' ' + subtitle;
var dist = utilEditDistance(value, name.substring(0, value.length));
var matchesPreset = (pKey === sKey && (!pValue || pValue === sValue));
if (dist < 1 || (matchesPreset && dist < 3)) {
var obj = {
value: s.name(),
title: name,
value: name,
display: s.nameLabel() + (subtitle ? ' ' + s.subtitleLabel() : ''),
suggestion: s,
dist: dist + (matchesPreset ? 0 : 1) // penalize if not matched preset
};
@@ -513,7 +499,7 @@ export function uiFieldLocalized(field, context) {
text
.append('span')
.attr('class', 'label-textvalue')
.text(t('translate.localized_translation_label'));
.html(t.html('translate.localized_translation_label'));
text
.append('span')
+5 -5
View File
@@ -64,7 +64,7 @@ export function uiFieldRadio(field, context) {
enter
.append('span')
.text(function(d) { return field.t('options.' + d, { 'default': d }); });
.html(function(d) { return field.t.html('options.' + d, { 'default': d }); });
labels = labels
.merge(enter);
@@ -129,7 +129,7 @@ export function uiFieldRadio(field, context) {
.append('span')
.attr('class', 'label structure-label-type')
.attr('for', 'preset-input-' + selected)
.text(t('inspector.radio.structure.type'));
.html(t.html('inspector.radio.structure.type'));
typeEnter
.append('div')
@@ -174,7 +174,7 @@ export function uiFieldRadio(field, context) {
.append('span')
.attr('class', 'label structure-label-layer')
.attr('for', 'preset-input-layer')
.text(t('inspector.radio.structure.layer'));
.html(t.html('inspector.radio.structure.layer'));
layerEnter
.append('div')
@@ -297,9 +297,9 @@ export function uiFieldRadio(field, context) {
var selection = radios.filter(function() { return this.checked; });
if (selection.empty()) {
placeholder.text(t('inspector.none'));
placeholder.html(t.html('inspector.none'));
} else {
placeholder.text(selection.attr('value'));
placeholder.html(selection.attr('value'));
_oldType[selection.datum()] = tags[selection.datum()];
}
+22 -22
View File
@@ -124,7 +124,7 @@ export function uiFieldRestrictions(field, context) {
distControlEnter
.append('span')
.attr('class', 'restriction-control-label restriction-distance-label')
.text(t('restriction.controls.distance') + ':');
.html(t.html('restriction.controls.distance') + ':');
distControlEnter
.append('input')
@@ -151,7 +151,7 @@ export function uiFieldRestrictions(field, context) {
});
selection.selectAll('.restriction-distance-text')
.text(displayMaxDistance(_maxDistance));
.html(displayMaxDistance(_maxDistance));
var viaControl = selection.selectAll('.restriction-via-way')
@@ -167,7 +167,7 @@ export function uiFieldRestrictions(field, context) {
viaControlEnter
.append('span')
.attr('class', 'restriction-control-label restriction-via-way-label')
.text(t('restriction.controls.via') + ':');
.html(t.html('restriction.controls.via') + ':');
viaControlEnter
.append('input')
@@ -193,7 +193,7 @@ export function uiFieldRestrictions(field, context) {
});
selection.selectAll('.restriction-via-way-text')
.text(displayMaxVia(_maxViaWay));
.html(displayMaxVia(_maxViaWay));
}
@@ -487,7 +487,7 @@ export function uiFieldRestrictions(field, context) {
var clickSelect = (!_fromWayID || _fromWayID !== way.id);
help
.append('div') // "Click to select FROM {fromName}." / "FROM {fromName}"
.html(t('restriction.help.' + (clickSelect ? 'select_from_name' : 'from_name'), {
.html(t.html('restriction.help.' + (clickSelect ? 'select_from_name' : 'from_name'), {
from: placeholders.from,
fromName: displayName(way.id, vgraph)
}));
@@ -497,31 +497,31 @@ export function uiFieldRestrictions(field, context) {
} else if (datum instanceof osmTurn) {
var restrictionType = osmInferRestriction(vgraph, datum, projection);
var turnType = restrictionType.replace(/^(only|no)\_/, '');
var indirect = (datum.direct === false ? t('restriction.help.indirect') : '');
var indirect = (datum.direct === false ? t.html('restriction.help.indirect') : '');
var klass, turnText, nextText;
if (datum.no) {
klass = 'restrict';
turnText = t('restriction.help.turn.no_' + turnType, { indirect: indirect });
nextText = t('restriction.help.turn.only_' + turnType, { indirect: '' });
turnText = t.html('restriction.help.turn.no_' + turnType, { indirect: indirect });
nextText = t.html('restriction.help.turn.only_' + turnType, { indirect: '' });
} else if (datum.only) {
klass = 'only';
turnText = t('restriction.help.turn.only_' + turnType, { indirect: indirect });
nextText = t('restriction.help.turn.allowed_' + turnType, { indirect: '' });
turnText = t.html('restriction.help.turn.only_' + turnType, { indirect: indirect });
nextText = t.html('restriction.help.turn.allowed_' + turnType, { indirect: '' });
} else {
klass = 'allow';
turnText = t('restriction.help.turn.allowed_' + turnType, { indirect: indirect });
nextText = t('restriction.help.turn.no_' + turnType, { indirect: '' });
turnText = t.html('restriction.help.turn.allowed_' + turnType, { indirect: indirect });
nextText = t.html('restriction.help.turn.no_' + turnType, { indirect: '' });
}
help
.append('div') // "NO Right Turn (indirect)"
.attr('class', 'qualifier ' + klass)
.text(turnText);
.html(turnText);
help
.append('div') // "FROM {fromName} TO {toName}"
.html(t('restriction.help.from_name_to_name', {
.html(t.html('restriction.help.from_name_to_name', {
from: placeholders.from,
fromName: displayName(datum.from.way, vgraph),
to: placeholders.to,
@@ -539,7 +539,7 @@ export function uiFieldRestrictions(field, context) {
help
.append('div') // "VIA {viaNames}"
.html(t('restriction.help.via_names', {
.html(t.html('restriction.help.via_names', {
via: placeholders.via,
viaNames: names.join(', ')
}));
@@ -548,7 +548,7 @@ export function uiFieldRestrictions(field, context) {
if (!indirect) {
help
.append('div') // Click for "No Right Turn"
.text(t('restriction.help.toggle', { turn: nextText.trim() }));
.html(t.html('restriction.help.toggle', { turn: nextText.trim() }));
}
highlightPathsFrom(null);
@@ -566,7 +566,7 @@ export function uiFieldRestrictions(field, context) {
if (_fromWayID) {
help
.append('div') // "FROM {fromName}"
.html(t('restriction.help.from_name', {
.html(t.html('restriction.help.from_name', {
from: placeholders.from,
fromName: displayName(_fromWayID, vgraph)
}));
@@ -574,7 +574,7 @@ export function uiFieldRestrictions(field, context) {
} else {
help
.append('div') // "Click to select a FROM segment."
.html(t('restriction.help.select_from', {
.html(t.html('restriction.help.select_from', {
from: placeholders.from
}));
}
@@ -596,14 +596,14 @@ export function uiFieldRestrictions(field, context) {
opts = { distance: t('units.meters', { quantity: maxDist }) };
}
return t('restriction.controls.distance_up_to', opts);
return t.html('restriction.controls.distance_up_to', opts);
}
function displayMaxVia(maxVia) {
return maxVia === 0 ? t('restriction.controls.via_node_only')
: maxVia === 1 ? t('restriction.controls.via_up_to_one')
: t('restriction.controls.via_up_to_two');
return maxVia === 0 ? t.html('restriction.controls.via_node_only')
: maxVia === 1 ? t.html('restriction.controls.via_up_to_one')
: t.html('restriction.controls.via_up_to_two');
}
+5 -5
View File
@@ -84,8 +84,10 @@ export function uiFieldWikidata(field, context) {
.call(combobox.fetcher(fetchWikidataItems));
combobox.on('accept', function(d) {
_qid = d.id;
change();
if (d) {
_qid = d.id;
change();
}
}).on('cancel', function() {
setLabelForEntity();
});
@@ -94,7 +96,6 @@ export function uiFieldWikidata(field, context) {
.append('button')
.attr('class', 'form-field-button wiki-link')
.attr('title', t('icons.view_on', { domain: 'wikidata.org' }))
.attr('tabindex', -1)
.call(svgIcon('#iD-icon-out-link'))
.on('click', function() {
d3_event.preventDefault();
@@ -118,7 +119,7 @@ export function uiFieldWikidata(field, context) {
enter
.append('span')
.attr('class', 'label')
.text(function(d) { return t('wikidata.' + d); });
.html(function(d) { return t.html('wikidata.' + d); });
enter
.append('input')
@@ -131,7 +132,6 @@ export function uiFieldWikidata(field, context) {
.append('button')
.attr('class', 'form-field-button')
.attr('title', t('icons.copy'))
.attr('tabindex', -1)
.call(svgIcon('#iD-operation-copy'))
.on('click', function() {
d3_event.preventDefault();
+45 -20
View File
@@ -92,8 +92,6 @@ export function uiFieldWikipedia(field, context) {
.call(langCombo)
.merge(_langInput);
utilGetSetValue(_langInput, language()[1]);
_langInput
.on('blur', changeLang)
.on('change', changeLang);
@@ -130,7 +128,6 @@ export function uiFieldWikipedia(field, context) {
link = link.enter()
.append('button')
.attr('class', 'form-field-button wiki-link')
.attr('tabindex', -1)
.attr('title', t('icons.view_on', { domain: 'wikipedia.org' }))
.call(svgIcon('#iD-icon-out-link'))
.merge(link);
@@ -143,14 +140,33 @@ export function uiFieldWikipedia(field, context) {
}
function language() {
function defaultLanguageInfo(skipEnglishFallback) {
const langCode = localizer.languageCode().toLowerCase();
for (let i in _dataWikipedia) {
let d = _dataWikipedia[i];
// default to the language of iD's current locale
if (d[2] === langCode) return d;
}
// fallback to English
return skipEnglishFallback ? ['', '', ''] : ['English', 'English', 'en'];
}
function language(skipEnglishFallback) {
const value = utilGetSetValue(_langInput).toLowerCase();
const locale = localizer.localeCode().toLowerCase();
let localeLanguage;
return _dataWikipedia.find(d => {
if (d[2] === locale) localeLanguage = d;
return d[0].toLowerCase() === value || d[1].toLowerCase() === value || d[2] === value;
}) || localeLanguage || ['English', 'English', 'en'];
for (let i in _dataWikipedia) {
let d = _dataWikipedia[i];
// return the language already set in the UI, if supported
if (d[0].toLowerCase() === value ||
d[1].toLowerCase() === value ||
d[2] === value) return d;
}
// fallback to English
return defaultLanguageInfo(skipEnglishFallback);
}
@@ -168,10 +184,11 @@ export function uiFieldWikipedia(field, context) {
function change(skipWikidata) {
let value = utilGetSetValue(_titleInput);
const m = value.match(/https?:\/\/([-a-z]+)\.wikipedia\.org\/(?:wiki|\1-[-a-z]+)\/([^#]+)(?:#(.+))?/);
const l = m && _dataWikipedia.find(d => m[1] === d[2]);
const langInfo = m && _dataWikipedia.find(d => m[1] === d[2]);
let syncTags = {};
if (l) {
if (langInfo) {
const nativeLangName = langInfo[1];
// Normalize title http://www.mediawiki.org/wiki/API:Query#Title_normalization
value = decodeURIComponent(m[2]).replace(/_/g, ' ');
if (m[3]) {
@@ -186,7 +203,7 @@ export function uiFieldWikipedia(field, context) {
value += '#' + anchor.replace(/_/g, ' ');
}
value = value.slice(0, 1).toUpperCase() + value.slice(1);
utilGetSetValue(_langInput, l[1]);
utilGetSetValue(_langInput, nativeLangName);
utilGetSetValue(_titleInput, value);
}
@@ -250,14 +267,19 @@ export function uiFieldWikipedia(field, context) {
function updateForTags(tags) {
const value = typeof tags[field.key] === 'string' ? tags[field.key] : '';
// Expect tag format of `tagLang:tagArticleTitle`, e.g. `fr:Paris`, with
// optional suffix of `#anchor`
const m = value.match(/([^:]+):([^#]+)(?:#(.+))?/);
const l = m && _dataWikipedia.find(d => m[1] === d[2]);
const tagLang = m && m[1];
const tagArticleTitle = m && m[2];
let anchor = m && m[3];
const tagLangInfo = tagLang && _dataWikipedia.find(d => tagLang === d[2]);
// value in correct format
if (l) {
utilGetSetValue(_langInput, l[1]);
utilGetSetValue(_titleInput, m[2] + (anchor ? ('#' + anchor) : ''));
if (tagLangInfo) {
const nativeLangName = tagLangInfo[1];
utilGetSetValue(_langInput, nativeLangName);
utilGetSetValue(_titleInput, tagArticleTitle + (anchor ? ('#' + anchor) : ''));
if (anchor) {
try {
// Best-effort `anchorencode:` implementation
@@ -266,16 +288,19 @@ export function uiFieldWikipedia(field, context) {
anchor = anchor.replace(/ /g, '_');
}
}
_wikiURL = 'https://' + m[1] + '.wikipedia.org/wiki/' +
m[2].replace(/ /g, '_') + (anchor ? ('#' + anchor) : '');
_wikiURL = 'https://' + tagLang + '.wikipedia.org/wiki/' +
tagArticleTitle.replace(/ /g, '_') + (anchor ? ('#' + anchor) : '');
// unrecognized value format
} else {
utilGetSetValue(_titleInput, value);
if (value && value !== '') {
utilGetSetValue(_langInput, '');
_wikiURL = `https://en.wikipedia.org/wiki/Special:Search?search=${value}`;
const defaultLangInfo = defaultLanguageInfo();
_wikiURL = `https://${defaultLangInfo[2]}.wikipedia.org/w/index.php?fulltext=1&search=${value}`;
} else {
const shownOrDefaultLangInfo = language(true /* skipEnglishFallback */);
utilGetSetValue(_langInput, shownOrDefaultLangInfo[1]);
_wikiURL = '';
}
}
+6 -13
View File
@@ -6,8 +6,7 @@ export function uiFlash(context) {
var _duration = 2000;
var _iconName = '#iD-icon-no';
var _iconClass = 'disabled';
var _text = '';
var _textClass;
var _label = '';
function flash() {
if (_flashTimer) {
@@ -64,8 +63,8 @@ export function uiFlash(context) {
content
.selectAll('.flash-text')
.attr('class', 'flash-text ' + (_textClass || ''))
.text(_text);
.attr('class', 'flash-text')
.html(_label);
_flashTimer = d3_timeout(function() {
@@ -88,15 +87,9 @@ export function uiFlash(context) {
return flash;
};
flash.text = function(_) {
if (!arguments.length) return _text;
_text = _;
return flash;
};
flash.textClass = function(_) {
if (!arguments.length) return _textClass;
_textClass = _;
flash.label = function(_) {
if (!arguments.length) return _label;
_label = _;
return flash;
};
+7 -8
View File
@@ -52,16 +52,17 @@ export function uiFormFields(context) {
var titles = [];
var moreFields = notShown.map(function(field) {
var label = field.label();
titles.push(label);
var title = field.title();
titles.push(title);
var terms = field.terms();
if (field.key) terms.push(field.key);
if (field.keys) terms = terms.concat(field.keys);
return {
title: label,
value: label,
display: field.label(),
value: title,
title: title,
field: field,
terms: terms
};
@@ -83,7 +84,7 @@ export function uiFormFields(context) {
moreEnter
.append('span')
.text(t('inspector.add_fields'));
.html(t.html('inspector.add_fields'));
more = moreEnter
.merge(more);
@@ -112,9 +113,7 @@ export function uiFormFields(context) {
var field = d.field;
field.show();
selection.call(formFields); // rerender
if (field.type !== 'semiCombo' && field.type !== 'multiCombo') {
field.focus();
}
field.focus();
})
);
-1
View File
@@ -65,7 +65,6 @@ export function uiFullScreen(context) {
// button = selection.append('button')
// .attr('title', t('full_screen'))
// .attr('tabindex', -1)
// .on('click', fullScreen)
// .call(tooltip);
+3 -3
View File
@@ -14,7 +14,7 @@ export function uiGeolocate(context) {
// don't hang indefinitely getting the location
timeout: 6000 // 6sec
};
var _locating = uiLoading(context).message(t('geolocate.locating')).blocking(true);
var _locating = uiLoading(context).message(t.html('geolocate.locating')).blocking(true);
var _layer = context.layers().layer('geolocate');
var _position;
var _extent;
@@ -62,7 +62,7 @@ export function uiGeolocate(context) {
zoomTo();
} else {
context.ui().flash
.text(t('geolocate.location_unavailable'))
.label(t.html('geolocate.location_unavailable'))
.iconName('#iD-icon-geolocate')();
}
@@ -88,7 +88,7 @@ export function uiGeolocate(context) {
.call(svgIcon('#iD-icon-geolocate', 'light'))
.call(uiTooltip()
.placement((localizer.textDirection() === 'rtl') ? 'right' : 'left')
.title(t('geolocate.title'))
.title(t.html('geolocate.title'))
.keys([t('geolocate.key')])
);
+3 -4
View File
@@ -52,23 +52,22 @@ export function uiImproveOsmComments() {
.append('a')
.attr('class', 'comment-author-link')
.attr('href', osm.userURL(d.username))
.attr('tabindex', -1)
.attr('target', '_blank');
}
selection
.text(d => d.username);
.html(d => d.username);
});
metadataEnter
.append('div')
.attr('class', 'comment-date')
.text(d => t('note.status.commented', { when: localeDateString(d.timestamp) }));
.html(d => t.html('note.status.commented', { when: localeDateString(d.timestamp) }));
mainEnter
.append('div')
.attr('class', 'comment-text')
.append('p')
.text(d => d.text);
.html(d => d.text);
})
.catch(err => {
console.log(err); // eslint-disable-line no-console
+4 -3
View File
@@ -16,8 +16,8 @@ export function uiImproveOsmDetails(context) {
if (d.desc) return d.desc;
const issueKey = d.issueKey;
d.replacements = d.replacements || {};
d.replacements.default = t('inspector.unknown'); // special key `default` works as a fallback string
return t(`QA.improveOSM.error_types.${issueKey}.description`, d.replacements);
d.replacements.default = t.html('inspector.unknown'); // special key `default` works as a fallback string
return t.html(`QA.improveOSM.error_types.${issueKey}.description`, d.replacements);
}
@@ -43,7 +43,7 @@ export function uiImproveOsmDetails(context) {
descriptionEnter
.append('h4')
.text(() => t('QA.keepRight.detail_description'));
.html(t.html('QA.keepRight.detail_description'));
descriptionEnter
.append('div')
@@ -53,6 +53,7 @@ export function uiImproveOsmDetails(context) {
// If there are entity links in the error message..
let relatedEntities = [];
descriptionEnter.selectAll('.error_entity_link, .error_object_link')
.attr('href', '#')
.each(function() {
const link = d3_select(this);
const isObjectLink = link.classed('error_object_link');
+7 -7
View File
@@ -36,7 +36,7 @@ export function uiImproveOsmEditor(context) {
headerEnter
.append('h3')
.text(t('QA.improveOSM.title'));
.html(t.html('QA.improveOSM.title'));
let body = selection.selectAll('.body')
.data([0]);
@@ -80,7 +80,7 @@ export function uiImproveOsmEditor(context) {
saveSectionEnter
.append('h4')
.attr('class', '.qa-save-header')
.text(t('note.newComment'));
.html(t.html('note.newComment'));
saveSectionEnter
.append('textarea')
@@ -135,7 +135,7 @@ export function uiImproveOsmEditor(context) {
buttonEnter
.append('button')
.attr('class', 'button comment-button action')
.text(t('QA.keepRight.save_comment'));
.html(t.html('QA.keepRight.save_comment'));
buttonEnter
.append('button')
@@ -160,9 +160,9 @@ export function uiImproveOsmEditor(context) {
});
buttonSection.select('.close-button')
.text(d => {
.html(d => {
const andComment = (d.newComment ? '_comment' : '');
return t(`QA.keepRight.close${andComment}`);
return t.html(`QA.keepRight.close${andComment}`);
})
.on('click.close', function(d) {
this.blur(); // avoid keeping focus on the button - #4641
@@ -174,9 +174,9 @@ export function uiImproveOsmEditor(context) {
});
buttonSection.select('.ignore-button')
.text(d => {
.html(d => {
const andComment = (d.newComment ? '_comment' : '');
return t(`QA.keepRight.ignore${andComment}`);
return t.html(`QA.keepRight.ignore${andComment}`);
})
.on('click.ignore', function(d) {
this.blur(); // avoid keeping focus on the button - #4641
+3 -3
View File
@@ -8,8 +8,8 @@ export function uiImproveOsmHeader() {
function issueTitle(d) {
const issueKey = d.issueKey;
d.replacements = d.replacements || {};
d.replacements.default = t('inspector.unknown'); // special key `default` works as a fallback string
return t(`QA.improveOSM.error_types.${issueKey}.title`, d.replacements);
d.replacements.default = t.html('inspector.unknown'); // special key `default` works as a fallback string
return t.html(`QA.improveOSM.error_types.${issueKey}.title`, d.replacements);
}
@@ -62,7 +62,7 @@ export function uiImproveOsmHeader() {
headerEnter
.append('div')
.attr('class', 'qa-header-label')
.text(issueTitle);
.html(issueTitle);
}
improveOsmHeader.issue = function(val) {
+1 -1
View File
@@ -59,7 +59,7 @@ export function uiInfo(context) {
title
.append('h3')
.text(function(d) { return panels[d].title; });
.html(function(d) { return panels[d].label; });
title
.append('button')
+135 -129
View File
@@ -115,6 +115,7 @@ export function uiInit(context) {
}
container
.attr('lang', localizer.localeCode())
.attr('dir', localizer.textDirection());
// setup fullscreen keybindings (no button shown at this time)
@@ -126,13 +127,15 @@ export function uiInit(context) {
map
.on('hitMinZoom.ui', function() {
ui.flash.text(t('cannot_zoom'))();
ui.flash
.iconName('#iD-icon-no')
.label(t.html('cannot_zoom'))();
});
container
.append('svg')
.attr('id', 'ideditor-defs')
.call(svgDefs(context));
.call(ui.svgDefs);
container
.append('div')
@@ -157,124 +160,21 @@ export function uiInit(context) {
.attr('dir', 'ltr')
.call(map);
content
var overMap = content
.append('div')
.attr('class', 'over-map');
overMap
.append('div')
.attr('class', 'spinner')
.call(uiSpinner(context));
// Add attribution and footer
var about = content
.append('div')
.attr('class', 'map-footer');
about
overMap
.append('div')
.attr('class', 'attribution-wrap')
.attr('dir', 'ltr')
.call(uiAttribution(context));
about
.append('div')
.attr('class', 'api-status')
.call(uiStatus(context));
var footer = about
.append('div')
.attr('class', 'map-footer-bar fillD');
footer
.append('div')
.attr('class', 'flash-wrap footer-hide');
var footerWrap = footer
.append('div')
.attr('class', 'main-footer-wrap footer-show');
footerWrap
.append('div')
.attr('class', 'scale-block')
.call(uiScale(context));
var aboutList = footerWrap
.append('div')
.attr('class', 'info-block')
.append('ul')
.attr('class', 'map-footer-list');
if (!context.embed()) {
aboutList
.call(uiAccount(context));
}
aboutList
.append('li')
.attr('class', 'version')
.call(uiVersion(context));
var issueLinks = aboutList
.append('li');
issueLinks
.append('a')
.attr('target', '_blank')
.attr('href', 'https://github.com/openstreetmap/iD/issues')
.call(svgIcon('#iD-icon-bug', 'light'))
.call(uiTooltip().title(t('report_a_bug')).placement('top'));
issueLinks
.append('a')
.attr('target', '_blank')
.attr('href', 'https://github.com/openstreetmap/iD/blob/develop/CONTRIBUTING.md#translating')
.call(svgIcon('#iD-icon-translate', 'light'))
.call(uiTooltip().title(t('help_translate')).placement('top'));
aboutList
.append('li')
.attr('class', 'feature-warning')
.attr('tabindex', -1)
.call(uiFeatureInfo(context));
aboutList
.append('li')
.attr('class', 'issues-info')
.attr('tabindex', -1)
.call(uiIssuesInfo(context));
var apiConnections = context.apiConnections();
if (apiConnections && apiConnections.length > 1) {
aboutList
.append('li')
.attr('class', 'source-switch')
.attr('tabindex', -1)
.call(uiSourceSwitch(context)
.keys(apiConnections)
);
}
aboutList
.append('li')
.attr('class', 'user-list')
.attr('tabindex', -1)
.call(uiContributors(context));
// Setup map dimensions and move map to initial center/zoom.
// This should happen after .main-content and toolbars exist.
ui.onResize();
map.redrawEnable(true);
ui.hash = behaviorHash(context);
ui.hash();
if (!ui.hash.hadHash) {
map.centerZoom([0, 0], 2);
}
var overMap = content
.append('div')
.attr('class', 'over-map');
// Map controls
var controls = overMap
.append('div')
@@ -337,6 +237,104 @@ export function uiInit(context) {
.call(ui.photoviewer);
// Add footer
var about = content
.append('div')
.attr('class', 'map-footer');
about
.append('div')
.attr('class', 'api-status')
.call(uiStatus(context));
var footer = about
.append('div')
.attr('class', 'map-footer-bar fillD');
footer
.append('div')
.attr('class', 'flash-wrap footer-hide');
var footerWrap = footer
.append('div')
.attr('class', 'main-footer-wrap footer-show');
footerWrap
.append('div')
.attr('class', 'scale-block')
.call(uiScale(context));
var aboutList = footerWrap
.append('div')
.attr('class', 'info-block')
.append('ul')
.attr('class', 'map-footer-list');
aboutList
.append('li')
.attr('class', 'user-list')
.call(uiContributors(context));
var apiConnections = context.apiConnections();
if (apiConnections && apiConnections.length > 1) {
aboutList
.append('li')
.attr('class', 'source-switch')
.call(uiSourceSwitch(context)
.keys(apiConnections)
);
}
aboutList
.append('li')
.attr('class', 'issues-info')
.call(uiIssuesInfo(context));
aboutList
.append('li')
.attr('class', 'feature-warning')
.call(uiFeatureInfo(context));
var issueLinks = aboutList
.append('li');
issueLinks
.append('a')
.attr('target', '_blank')
.attr('href', 'https://github.com/openstreetmap/iD/issues')
.call(svgIcon('#iD-icon-bug', 'light'))
.call(uiTooltip().title(t.html('report_a_bug')).placement('top'));
issueLinks
.append('a')
.attr('target', '_blank')
.attr('href', 'https://github.com/openstreetmap/iD/blob/develop/CONTRIBUTING.md#translating')
.call(svgIcon('#iD-icon-translate', 'light'))
.call(uiTooltip().title(t.html('help_translate')).placement('top'));
aboutList
.append('li')
.attr('class', 'version')
.call(uiVersion(context));
if (!context.embed()) {
aboutList
.call(uiAccount(context));
}
// Setup map dimensions and move map to initial center/zoom.
// This should happen after .main-content and toolbars exist.
ui.onResize();
map.redrawEnable(true);
ui.hash = behaviorHash(context);
ui.hash();
if (!ui.hash.hadHash) {
map.centerZoom([0, 0], 2);
}
// Bind events
window.onbeforeunload = function() {
return context.save();
@@ -357,10 +355,10 @@ export function uiInit(context) {
.on('↑', pan([0, panPixels]))
.on('→', pan([-panPixels, 0]))
.on('↓', pan([0, -panPixels]))
.on(uiCmd('←'), pan([map.dimensions()[0], 0]))
.on(uiCmd('↑'), pan([0, map.dimensions()[1]]))
.on(uiCmd('→'), pan([-map.dimensions()[0], 0]))
.on(uiCmd('↓'), pan([0, -map.dimensions()[1]]))
.on(uiCmd('←'), pan([map.dimensions()[0], 0]))
.on(uiCmd('↑'), pan([0, map.dimensions()[1]]))
.on(uiCmd('→'), pan([-map.dimensions()[0], 0]))
.on(uiCmd('↓'), pan([0, -map.dimensions()[1]]))
.on(uiCmd('⌘' + t('background.key')), function quickSwitch() {
if (d3_event) {
d3_event.stopImmediatePropagation();
@@ -420,11 +418,11 @@ export function uiInit(context) {
}
context.container()
.call(uiShortcuts(context));
.call(ui.shortcuts);
}
var osm = context.connection();
var auth = uiLoading(context).message(t('loading_auth')).blocking(true);
var auth = uiLoading(context).message(t.html('loading_auth')).blocking(true);
if (osm && auth) {
osm
@@ -493,12 +491,16 @@ export function uiInit(context) {
return _lastPointerType;
};
ui.svgDefs = svgDefs(context);
ui.flash = uiFlash(context);
ui.sidebar = uiSidebar(context);
ui.photoviewer = uiPhotoviewer(context);
ui.shortcuts = uiShortcuts(context);
ui.onResize = function(withPan) {
var map = context.map();
@@ -553,19 +555,21 @@ export function uiInit(context) {
};
ui.togglePanes = function(showPane) {
var shownPanes = context.container().selectAll('.map-pane.shown');
var hidePanes = context.container().selectAll('.map-pane.shown');
var side = localizer.textDirection() === 'ltr' ? 'right' : 'left';
shownPanes
.classed('shown', false);
hidePanes
.classed('shown', false)
.classed('hide', true);
context.container().selectAll('.map-pane-control button')
.classed('active', false);
if (showPane) {
shownPanes
.style('display', 'none')
hidePanes
.classed('shown', false)
.classed('hide', true)
.style(side, '-500px');
context.container().selectAll('.' + showPane.attr('pane') + '-control button')
@@ -573,10 +577,9 @@ export function uiInit(context) {
showPane
.classed('shown', true)
.style('display', 'block');
if (shownPanes.empty()) {
.classed('hide', false);
if (hidePanes.empty()) {
showPane
.style('display', 'block')
.style(side, '-500px')
.transition()
.duration(200)
@@ -586,14 +589,17 @@ export function uiInit(context) {
.style(side, '0px');
}
} else {
shownPanes
.style('display', 'block')
hidePanes
.classed('shown', true)
.classed('hide', false)
.style(side, '0px')
.transition()
.duration(200)
.style(side, '-500px')
.on('end', function() {
d3_select(this).style('display', 'none');
d3_select(this)
.classed('shown', false)
.classed('hide', true);
});
}
};
@@ -647,7 +653,7 @@ export function uiInit(context) {
context.uploader()
.on('saveStarted.ui', function() {
_saveLoading = uiLoading(context)
.message(t('save.uploading'))
.message(t.html('save.uploading'))
.blocking(true);
context.container().call(_saveLoading); // block input during upload
})
+27 -9
View File
@@ -23,9 +23,7 @@ export function uiInspector(context) {
.autofocus(_newFeature)
.on('choose', inspector.setPreset)
.on('cancel', function() {
wrap.transition()
.styleTween('right', function() { return d3_interpolate('-100%', '0%'); });
editorPane.call(entityEditor);
inspector.setPreset();
});
entityEditor
@@ -87,10 +85,14 @@ export function uiInspector(context) {
if (shouldDefaultToPresetList()) {
wrap.style('right', '-100%');
presetPane.call(presetList);
editorPane.classed('hide', true);
presetPane.classed('hide', false)
.call(presetList);
} else {
wrap.style('right', '0%');
editorPane.call(entityEditor);
presetPane.classed('hide', true);
editorPane.classed('hide', false)
.call(entityEditor);
}
var footer = selection.selectAll('.footer')
@@ -109,8 +111,15 @@ export function uiInspector(context) {
inspector.showList = function(presets) {
presetPane.classed('hide', false);
wrap.transition()
.styleTween('right', function() { return d3_interpolate('0%', '-100%'); });
.styleTween('right', function() {
return d3_interpolate('0%', '-100%');
})
.on('end', function () {
editorPane.classed('hide', true);
});
if (presets) {
presetList.presets(presets);
@@ -123,16 +132,25 @@ export function uiInspector(context) {
inspector.setPreset = function(preset) {
// upon setting multipolygon, go to the area preset list instead of the editor
if (preset.id === 'type/multipolygon') {
if (preset && preset.id === 'type/multipolygon') {
presetPane
.call(presetList.autofocus(true));
} else {
editorPane.classed('hide', false);
wrap.transition()
.styleTween('right', function() { return d3_interpolate('-100%', '0%'); });
.styleTween('right', function() {
return d3_interpolate('-100%', '0%');
})
.on('end', function () {
presetPane.classed('hide', true);
});
if (preset) {
entityEditor.presets([preset]);
}
editorPane
.call(entityEditor.presets([preset]));
.call(entityEditor);
}
};
+17 -17
View File
@@ -13,7 +13,7 @@ import { t } from '../../core/localizer';
import { modeBrowse } from '../../modes/browse';
import { modeSelect } from '../../modes/select';
import { utilRebind } from '../../util/rebind';
import { helpString, icon, pad, transitionTime } from './helper';
import { helpHtml, icon, pad, transitionTime } from './helper';
export function uiIntroArea(context, reveal) {
@@ -60,7 +60,7 @@ export function uiIntroArea(context, reveal) {
timeout(function() {
var tooltip = reveal('button.add-area',
helpString('intro.areas.add_playground'));
helpHtml('intro.areas.add_playground'));
tooltip.selectAll('.popover-inner')
.insert('svg', 'span')
@@ -91,7 +91,7 @@ export function uiIntroArea(context, reveal) {
timeout(function() {
var textId = context.lastPointerType() === 'mouse' ? 'starting_node_click' : 'starting_node_tap';
var startDrawString = helpString('intro.areas.start_playground') + helpString('intro.areas.' + textId);
var startDrawString = helpHtml('intro.areas.start_playground') + helpHtml('intro.areas.' + textId);
revealPlayground(playground,
startDrawString, { duration: 250 }
);
@@ -125,14 +125,14 @@ export function uiIntroArea(context, reveal) {
_areaID = null;
revealPlayground(playground,
helpString('intro.areas.continue_playground'),
helpHtml('intro.areas.continue_playground'),
{ duration: 250 }
);
timeout(function() {
context.map().on('move.intro drawn.intro', function() {
revealPlayground(playground,
helpString('intro.areas.continue_playground'),
helpHtml('intro.areas.continue_playground'),
{ duration: 0 }
);
});
@@ -169,8 +169,8 @@ export function uiIntroArea(context, reveal) {
_areaID = null;
var finishString = helpString('intro.areas.finish_area_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap')) +
helpString('intro.areas.finish_playground');
var finishString = helpHtml('intro.areas.finish_area_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap')) +
helpHtml('intro.areas.finish_playground');
revealPlayground(playground,
finishString, { duration: 250 }
);
@@ -223,7 +223,7 @@ export function uiIntroArea(context, reveal) {
.on('keyup.intro', checkPresetSearch);
reveal('.preset-search-input',
helpString('intro.areas.search_playground', { preset: playgroundPreset.name() })
helpHtml('intro.areas.search_playground', { preset: playgroundPreset.name() })
);
}, 400); // after preset list pane visible..
@@ -247,7 +247,7 @@ export function uiIntroArea(context, reveal) {
.on('keyup.intro', checkPresetSearch);
reveal('.preset-search-input',
helpString('intro.areas.search_playground', { preset: playgroundPreset.name() })
helpHtml('intro.areas.search_playground', { preset: playgroundPreset.name() })
);
context.history().on('change.intro', null);
@@ -259,7 +259,7 @@ export function uiIntroArea(context, reveal) {
if (first.classed('preset-leisure-playground')) {
reveal(first.select('.preset-list-button').node(),
helpString('intro.areas.choose_playground', { preset: playgroundPreset.name() }),
helpHtml('intro.areas.choose_playground', { preset: playgroundPreset.name() }),
{ duration: 300 }
);
@@ -331,7 +331,7 @@ export function uiIntroArea(context, reveal) {
timeout(function() {
reveal('.more-fields .combobox-input',
helpString('intro.areas.add_field', {
helpHtml('intro.areas.add_field', {
name: nameField.label(),
description: descriptionField.label()
}),
@@ -399,7 +399,7 @@ export function uiIntroArea(context, reveal) {
}, 300);
reveal('div.combobox',
helpString('intro.areas.choose_field', { field: descriptionField.label() }),
helpHtml('intro.areas.choose_field', { field: descriptionField.label() }),
{ duration: 300 }
);
@@ -436,7 +436,7 @@ export function uiIntroArea(context, reveal) {
});
reveal('.entity-editor-pane',
helpString('intro.areas.describe_playground', { button: icon('#iD-icon-close', 'pre-text') }),
helpHtml('intro.areas.describe_playground', { button: icon('#iD-icon-close', 'inline') }),
{ duration: 300 }
);
@@ -460,8 +460,8 @@ export function uiIntroArea(context, reveal) {
context.container().select('.inspector-wrap .panewrap').style('right', '0%');
reveal('.entity-editor-pane',
helpString('intro.areas.retry_add_field', { field: descriptionField.label() }), {
buttonText: t('intro.ok'),
helpHtml('intro.areas.retry_add_field', { field: descriptionField.label() }), {
buttonText: t.html('intro.ok'),
buttonCallback: function() { continueTo(clickAddField); }
});
@@ -479,9 +479,9 @@ export function uiIntroArea(context, reveal) {
function play() {
dispatch.call('done');
reveal('.ideditor',
helpString('intro.areas.play', { next: t('intro.lines.title') }), {
helpHtml('intro.areas.play', { next: t('intro.lines.title') }), {
tooltipBox: '.intro-nav-wrap .chapter-line',
buttonText: t('intro.ok'),
buttonText: t.html('intro.ok'),
buttonCallback: function() { reveal('.ideditor'); }
}
);
+40 -40
View File
@@ -9,7 +9,7 @@ import { t } from '../../core/localizer';
import { modeBrowse } from '../../modes/browse';
import { modeSelect } from '../../modes/select';
import { utilArrayUniq, utilRebind } from '../../util';
import { helpString, icon, pad, isMostlySquare, selectMenuItem, transitionTime } from './helper';
import { helpHtml, icon, pad, isMostlySquare, selectMenuItem, transitionTime } from './helper';
export function uiIntroBuilding(context, reveal) {
@@ -65,7 +65,7 @@ export function uiIntroBuilding(context, reveal) {
timeout(function() {
var tooltip = reveal('button.add-area',
helpString('intro.buildings.add_building'));
helpHtml('intro.buildings.add_building'));
tooltip.selectAll('.popover-inner')
.insert('svg', 'span')
@@ -95,8 +95,8 @@ export function uiIntroBuilding(context, reveal) {
context.map().zoomEase(20, 500);
timeout(function() {
var startString = helpString('intro.buildings.start_building') +
helpString('intro.buildings.building_corner_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap'));
var startString = helpHtml('intro.buildings.start_building') +
helpHtml('intro.buildings.building_corner_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap'));
revealHouse(house, startString);
context.map().on('move.intro drawn.intro', function() {
@@ -125,9 +125,9 @@ export function uiIntroBuilding(context, reveal) {
_houseID = null;
var continueString = helpString('intro.buildings.continue_building') + '{br}' +
helpString('intro.areas.finish_area_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap')) +
helpString('intro.buildings.finish_building');
var continueString = helpHtml('intro.buildings.continue_building') + '{br}' +
helpHtml('intro.areas.finish_area_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap')) +
helpHtml('intro.buildings.finish_building');
revealHouse(house, continueString);
@@ -168,13 +168,13 @@ export function uiIntroBuilding(context, reveal) {
function retryHouse() {
var onClick = function() { continueTo(addHouse); };
revealHouse(house, helpString('intro.buildings.retry_building'),
{ buttonText: t('intro.ok'), buttonCallback: onClick }
revealHouse(house, helpHtml('intro.buildings.retry_building'),
{ buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
context.map().on('move.intro drawn.intro', function() {
revealHouse(house, helpString('intro.buildings.retry_building'),
{ duration: 0, buttonText: t('intro.ok'), buttonCallback: onClick }
revealHouse(house, helpHtml('intro.buildings.retry_building'),
{ duration: 0, buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
});
@@ -204,7 +204,7 @@ export function uiIntroBuilding(context, reveal) {
var button = context.container().select('.preset-category-building .preset-list-button');
reveal(button.node(),
helpString('intro.buildings.choose_category_building', { category: buildingCatetory.name() })
helpHtml('intro.buildings.choose_category_building', { category: buildingCatetory.name() })
);
button.on('click.intro', function() {
@@ -253,7 +253,7 @@ export function uiIntroBuilding(context, reveal) {
var button = context.container().select('.preset-building-house .preset-list-button');
reveal(button.node(),
helpString('intro.buildings.choose_preset_house', { preset: housePreset.name() }),
helpHtml('intro.buildings.choose_preset_house', { preset: housePreset.name() }),
{ duration: 300 }
);
@@ -300,7 +300,7 @@ export function uiIntroBuilding(context, reveal) {
timeout(function() {
reveal('.entity-editor-pane',
helpString('intro.buildings.close', { button: icon('#iD-icon-close', 'pre-text') })
helpHtml('intro.buildings.close', { button: icon('#iD-icon-close', 'inline') })
);
}, 500);
@@ -335,7 +335,7 @@ export function uiIntroBuilding(context, reveal) {
});
context.map().on('move.intro drawn.intro', function() {
var rightclickString = helpString('intro.buildings.' + (context.lastPointerType() === 'mouse' ? 'rightclick_building' : 'edit_menu_building_touch'));
var rightclickString = helpHtml('intro.buildings.' + (context.lastPointerType() === 'mouse' ? 'rightclick_building' : 'edit_menu_building_touch'));
revealHouse(house, rightclickString, { duration: 0 });
});
@@ -363,7 +363,7 @@ export function uiIntroBuilding(context, reveal) {
var wasChanged = false;
reveal('.edit-menu',
helpString('intro.buildings.square_building'),
helpHtml('intro.buildings.square_building'),
{ padding: 50 }
);
@@ -380,7 +380,7 @@ export function uiIntroBuilding(context, reveal) {
if (!wasChanged && !node) { return continueTo(rightClickHouse); }
reveal('.edit-menu',
helpString('intro.buildings.square_building'),
helpHtml('intro.buildings.square_building'),
{ duration: 0, padding: 50 }
);
});
@@ -391,7 +391,7 @@ export function uiIntroBuilding(context, reveal) {
// Something changed. Wait for transition to complete and check undo annotation.
timeout(function() {
if (context.history().undoAnnotation() === t('operations.orthogonalize.annotation.feature.single')) {
if (context.history().undoAnnotation() === t('operations.orthogonalize.annotation.feature', { n: 1 })) {
continueTo(doneSquare);
} else {
continueTo(retryClickSquare);
@@ -411,8 +411,8 @@ export function uiIntroBuilding(context, reveal) {
function retryClickSquare() {
context.enter(modeBrowse(context));
revealHouse(house, helpString('intro.buildings.retry_square'), {
buttonText: t('intro.ok'),
revealHouse(house, helpHtml('intro.buildings.retry_square'), {
buttonText: t.html('intro.ok'),
buttonCallback: function() { continueTo(rightClickHouse); }
});
@@ -425,8 +425,8 @@ export function uiIntroBuilding(context, reveal) {
function doneSquare() {
context.history().checkpoint('doneSquare');
revealHouse(house, helpString('intro.buildings.done_square'), {
buttonText: t('intro.ok'),
revealHouse(house, helpHtml('intro.buildings.done_square'), {
buttonText: t.html('intro.ok'),
buttonCallback: function() { continueTo(addTank); }
});
@@ -447,7 +447,7 @@ export function uiIntroBuilding(context, reveal) {
timeout(function() {
reveal('button.add-area',
helpString('intro.buildings.add_tank')
helpHtml('intro.buildings.add_tank')
);
context.on('enter.intro', function(mode) {
@@ -471,8 +471,8 @@ export function uiIntroBuilding(context, reveal) {
_tankID = null;
timeout(function() {
var startString = helpString('intro.buildings.start_tank') +
helpString('intro.buildings.tank_edge_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap'));
var startString = helpHtml('intro.buildings.start_tank') +
helpHtml('intro.buildings.tank_edge_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap'));
revealTank(tank, startString);
context.map().on('move.intro drawn.intro', function() {
@@ -501,9 +501,9 @@ export function uiIntroBuilding(context, reveal) {
_tankID = null;
var continueString = helpString('intro.buildings.continue_tank') + '{br}' +
helpString('intro.areas.finish_area_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap')) +
helpString('intro.buildings.finish_tank');
var continueString = helpHtml('intro.buildings.continue_tank') + '{br}' +
helpHtml('intro.areas.finish_area_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap')) +
helpHtml('intro.buildings.finish_tank');
revealTank(tank, continueString);
@@ -551,7 +551,7 @@ export function uiIntroBuilding(context, reveal) {
.on('keyup.intro', checkPresetSearch);
reveal('.preset-search-input',
helpString('intro.buildings.search_tank', { preset: tankPreset.name() })
helpHtml('intro.buildings.search_tank', { preset: tankPreset.name() })
);
}, 400); // after preset list pane visible..
@@ -575,7 +575,7 @@ export function uiIntroBuilding(context, reveal) {
.on('keyup.intro', checkPresetSearch);
reveal('.preset-search-input',
helpString('intro.buildings.search_tank', { preset: tankPreset.name() })
helpHtml('intro.buildings.search_tank', { preset: tankPreset.name() })
);
context.history().on('change.intro', null);
@@ -587,7 +587,7 @@ export function uiIntroBuilding(context, reveal) {
if (first.classed('preset-man_made-storage_tank')) {
reveal(first.select('.preset-list-button').node(),
helpString('intro.buildings.choose_tank', { preset: tankPreset.name() }),
helpHtml('intro.buildings.choose_tank', { preset: tankPreset.name() }),
{ duration: 300 }
);
@@ -628,7 +628,7 @@ export function uiIntroBuilding(context, reveal) {
timeout(function() {
reveal('.entity-editor-pane',
helpString('intro.buildings.close', { button: icon('#iD-icon-close', 'pre-text') })
helpHtml('intro.buildings.close', { button: icon('#iD-icon-close', 'inline') })
);
}, 500);
@@ -659,7 +659,7 @@ export function uiIntroBuilding(context, reveal) {
}, 50); // after menu visible
});
var rightclickString = helpString('intro.buildings.' + (context.lastPointerType() === 'mouse' ? 'rightclick_tank' : 'edit_menu_tank_touch'));
var rightclickString = helpHtml('intro.buildings.' + (context.lastPointerType() === 'mouse' ? 'rightclick_tank' : 'edit_menu_tank_touch'));
revealTank(tank, rightclickString);
@@ -693,7 +693,7 @@ export function uiIntroBuilding(context, reveal) {
var wasChanged = false;
reveal('.edit-menu',
helpString('intro.buildings.circle_tank'),
helpHtml('intro.buildings.circle_tank'),
{ padding: 50 }
);
@@ -710,7 +710,7 @@ export function uiIntroBuilding(context, reveal) {
if (!wasChanged && !node) { return continueTo(rightClickTank); }
reveal('.edit-menu',
helpString('intro.buildings.circle_tank'),
helpHtml('intro.buildings.circle_tank'),
{ duration: 0, padding: 50 }
);
});
@@ -721,7 +721,7 @@ export function uiIntroBuilding(context, reveal) {
// Something changed. Wait for transition to complete and check undo annotation.
timeout(function() {
if (context.history().undoAnnotation() === t('operations.circularize.annotation.single')) {
if (context.history().undoAnnotation() === t('operations.circularize.annotation.feature', { n: 1 })) {
continueTo(play);
} else {
continueTo(retryClickCircle);
@@ -741,8 +741,8 @@ export function uiIntroBuilding(context, reveal) {
function retryClickCircle() {
context.enter(modeBrowse(context));
revealTank(tank, helpString('intro.buildings.retry_circle'), {
buttonText: t('intro.ok'),
revealTank(tank, helpHtml('intro.buildings.retry_circle'), {
buttonText: t.html('intro.ok'),
buttonCallback: function() { continueTo(rightClickTank); }
});
@@ -755,9 +755,9 @@ export function uiIntroBuilding(context, reveal) {
function play() {
dispatch.call('done');
reveal('.ideditor',
helpString('intro.buildings.play', { next: t('intro.startediting.title') }), {
helpHtml('intro.buildings.play', { next: t('intro.startediting.title') }), {
tooltipBox: '.intro-nav-wrap .chapter-startEditing',
buttonText: t('intro.ok'),
buttonText: t.html('intro.ok'),
buttonCallback: function() { reveal('.ideditor'); }
}
);
+89 -63
View File
@@ -44,80 +44,106 @@ export function icon(name, svgklass, useklass) {
var helpStringReplacements;
// Returns the localized string for `id` with a standardized set of icon, key, and
// Returns the localized HTML element for `id` with a standardized set of icon, key, and
// label replacements suitable for tutorials and documentation. Optionally supplemented
// with custom `replacements`
export function helpString(id, replacements) {
export function helpHtml(id, replacements) {
// only load these the first time
if (!helpStringReplacements) helpStringReplacements = {
// insert icons corresponding to various UI elements
point_icon: icon('#iD-icon-point', 'pre-text'),
line_icon: icon('#iD-icon-line', 'pre-text'),
area_icon: icon('#iD-icon-area', 'pre-text'),
note_icon: icon('#iD-icon-note', 'pre-text add-note'),
plus: icon('#iD-icon-plus', 'pre-text'),
minus: icon('#iD-icon-minus', 'pre-text'),
move_icon: icon('#iD-operation-move', 'pre-text operation'),
merge_icon: icon('#iD-operation-merge', 'pre-text operation'),
delete_icon: icon('#iD-operation-delete', 'pre-text operation'),
circularize_icon: icon('#iD-operation-circularize', 'pre-text operation'),
split_icon: icon('#iD-operation-split', 'pre-text operation'),
orthogonalize_icon: icon('#iD-operation-orthogonalize', 'pre-text operation'),
disconnect_icon: icon('#iD-operation-disconnect', 'pre-text operation'),
layers_icon: icon('#iD-icon-layers', 'pre-text'),
data_icon: icon('#iD-icon-data', 'pre-text'),
inspect: icon('#iD-icon-inspect', 'pre-text'),
help_icon: icon('#iD-icon-help', 'pre-text'),
undo_icon: icon(localizer.textDirection() === 'rtl' ? '#iD-icon-redo' : '#iD-icon-undo', 'pre-text'),
redo_icon: icon(localizer.textDirection() === 'rtl' ? '#iD-icon-undo' : '#iD-icon-redo', 'pre-text'),
save_icon: icon('#iD-icon-save', 'pre-text'),
leftclick: icon('#iD-walkthrough-mouse-left', 'pre-text operation'),
rightclick: icon('#iD-walkthrough-mouse-right', 'pre-text operation'),
mousewheel_icon: icon('#iD-walkthrough-mousewheel', 'pre-text operation'),
tap_icon: icon('#iD-walkthrough-tap', 'pre-text operation'),
doubletap_icon: icon('#iD-walkthrough-doubletap', 'pre-text operation'),
longpress_icon: icon('#iD-walkthrough-longpress', 'pre-text operation'),
touchdrag_icon: icon('#iD-walkthrough-touchdrag', 'pre-text operation'),
pinch_icon: icon('#iD-walkthrough-pinch-apart', 'pre-text operation'),
point_icon: icon('#iD-icon-point', 'inline'),
line_icon: icon('#iD-icon-line', 'inline'),
area_icon: icon('#iD-icon-area', 'inline'),
note_icon: icon('#iD-icon-note', 'inline add-note'),
plus: icon('#iD-icon-plus', 'inline'),
minus: icon('#iD-icon-minus', 'inline'),
layers_icon: icon('#iD-icon-layers', 'inline'),
data_icon: icon('#iD-icon-data', 'inline'),
inspect: icon('#iD-icon-inspect', 'inline'),
help_icon: icon('#iD-icon-help', 'inline'),
undo_icon: icon(localizer.textDirection() === 'rtl' ? '#iD-icon-redo' : '#iD-icon-undo', 'inline'),
redo_icon: icon(localizer.textDirection() === 'rtl' ? '#iD-icon-undo' : '#iD-icon-redo', 'inline'),
save_icon: icon('#iD-icon-save', 'inline'),
// operation icons
circularize_icon: icon('#iD-operation-circularize', 'inline operation'),
continue_icon: icon('#iD-operation-continue', 'inline operation'),
copy_icon: icon('#iD-operation-copy', 'inline operation'),
delete_icon: icon('#iD-operation-delete', 'inline operation'),
disconnect_icon: icon('#iD-operation-disconnect', 'inline operation'),
downgrade_icon: icon('#iD-operation-downgrade', 'inline operation'),
extract_icon: icon('#iD-operation-extract', 'inline operation'),
merge_icon: icon('#iD-operation-merge', 'inline operation'),
move_icon: icon('#iD-operation-move', 'inline operation'),
orthogonalize_icon: icon('#iD-operation-orthogonalize', 'inline operation'),
paste_icon: icon('#iD-operation-paste', 'inline operation'),
reflect_long_icon: icon('#iD-operation-reflect-long', 'inline operation'),
reflect_short_icon: icon('#iD-operation-reflect-short', 'inline operation'),
reverse_icon: icon('#iD-operation-reverse', 'inline operation'),
rotate_icon: icon('#iD-operation-rotate', 'inline operation'),
split_icon: icon('#iD-operation-split', 'inline operation'),
straighten_icon: icon('#iD-operation-straighten', 'inline operation'),
// interaction icons
leftclick: icon('#iD-walkthrough-mouse-left', 'inline operation'),
rightclick: icon('#iD-walkthrough-mouse-right', 'inline operation'),
mousewheel_icon: icon('#iD-walkthrough-mousewheel', 'inline operation'),
tap_icon: icon('#iD-walkthrough-tap', 'inline operation'),
doubletap_icon: icon('#iD-walkthrough-doubletap', 'inline operation'),
longpress_icon: icon('#iD-walkthrough-longpress', 'inline operation'),
touchdrag_icon: icon('#iD-walkthrough-touchdrag', 'inline operation'),
pinch_icon: icon('#iD-walkthrough-pinch-apart', 'inline operation'),
// insert keys; may be localized and platform-dependent
shift: uiCmd.display('⇧'),
alt: uiCmd.display('⌥'),
return: uiCmd.display('↵'),
esc: t('shortcuts.key.esc'),
space: t('shortcuts.key.space'),
add_note_key: t('modes.add_note.key'),
help_key: t('help.key'),
shortcuts_key: t('shortcuts.toggle.key'),
esc: t.html('shortcuts.key.esc'),
space: t.html('shortcuts.key.space'),
add_note_key: t.html('modes.add_note.key'),
help_key: t.html('help.key'),
shortcuts_key: t.html('shortcuts.toggle.key'),
// reference localized UI labels directly so that they'll always match
save: t('save.title'),
undo: t('undo.title'),
redo: t('redo.title'),
upload: t('commit.save'),
point: t('modes.add_point.title'),
line: t('modes.add_line.title'),
area: t('modes.add_area.title'),
note: t('modes.add_note.title'),
delete: t('operations.delete.title'),
move: t('operations.move.title'),
orthogonalize: t('operations.orthogonalize.title'),
circularize: t('operations.circularize.title'),
merge: t('operations.merge.title'),
disconnect: t('operations.disconnect.title'),
split: t('operations.split.title'),
map_data: t('map_data.title'),
osm_notes: t('map_data.layers.notes.title'),
fields: t('inspector.fields'),
tags: t('inspector.tags'),
relations: t('inspector.relations'),
new_relation: t('inspector.new_relation'),
turn_restrictions: t('presets.fields.restrictions.label'),
background_settings: t('background.description'),
imagery_offset: t('background.fix_misalignment'),
start_the_walkthrough: t('splash.walkthrough'),
help: t('help.title'),
ok: t('intro.ok')
save: t.html('save.title'),
undo: t.html('undo.title'),
redo: t.html('redo.title'),
upload: t.html('commit.save'),
point: t.html('modes.add_point.title'),
line: t.html('modes.add_line.title'),
area: t.html('modes.add_area.title'),
note: t.html('modes.add_note.label'),
circularize: t.html('operations.circularize.title'),
continue: t.html('operations.continue.title'),
copy: t.html('operations.copy.title'),
delete: t.html('operations.delete.title'),
disconnect: t.html('operations.disconnect.title'),
downgrade: t.html('operations.downgrade.title'),
extract: t.html('operations.extract.title'),
merge: t.html('operations.merge.title'),
move: t.html('operations.move.title'),
orthogonalize: t.html('operations.orthogonalize.title'),
paste: t.html('operations.paste.title'),
reflect_long: t.html('operations.reflect.title.long'),
reflect_short: t.html('operations.reflect.title.short'),
reverse: t.html('operations.reverse.title'),
rotate: t.html('operations.rotate.title'),
split: t.html('operations.split.title'),
straighten: t.html('operations.straighten.title'),
map_data: t.html('map_data.title'),
osm_notes: t.html('map_data.layers.notes.title'),
fields: t.html('inspector.fields'),
tags: t.html('inspector.tags'),
relations: t.html('inspector.relations'),
new_relation: t.html('inspector.new_relation'),
turn_restrictions: t.html('presets.fields.restrictions.label'),
background_settings: t.html('background.description'),
imagery_offset: t.html('background.fix_misalignment'),
start_the_walkthrough: t.html('splash.walkthrough'),
help: t.html('help.title'),
ok: t.html('intro.ok')
};
var reps;
@@ -127,7 +153,7 @@ export function helpString(id, replacements) {
reps = helpStringReplacements;
}
return t(id, reps)
return t.html(id, reps)
// use keyboard key styling for shortcuts
.replace(/\`(.*?)\`/g, '<kbd>$1</kbd>');
}
+1 -1
View File
@@ -191,7 +191,7 @@ export function uiIntro(context) {
buttons
.append('span')
.text(d => t(d.title));
.html(d => t.html(d.title));
buttons
.append('span')
+58 -58
View File
@@ -11,7 +11,7 @@ import { geoSphericalDistance } from '../../geo';
import { modeBrowse } from '../../modes/browse';
import { modeSelect } from '../../modes/select';
import { utilRebind } from '../../util/rebind';
import { helpString, icon, pad, selectMenuItem, transitionTime } from './helper';
import { helpHtml, icon, pad, selectMenuItem, transitionTime } from './helper';
export function uiIntroLine(context, reveal) {
@@ -66,7 +66,7 @@ export function uiIntroLine(context, reveal) {
timeout(function() {
var tooltip = reveal('button.add-line',
helpString('intro.lines.add_line'));
helpHtml('intro.lines.add_line'));
tooltip.selectAll('.popover-inner')
.insert('svg', 'span')
@@ -97,9 +97,9 @@ export function uiIntroLine(context, reveal) {
box.height = box.height + 100;
var textId = context.lastPointerType() === 'mouse' ? 'start_line' : 'start_line_tap';
var startLineString = helpString('intro.lines.missing_road') + '{br}' +
helpString('intro.lines.line_draw_info') +
helpString('intro.lines.' + textId);
var startLineString = helpHtml('intro.lines.missing_road') + '{br}' +
helpHtml('intro.lines.line_draw_info') +
helpHtml('intro.lines.' + textId);
reveal(box, startLineString);
context.map().on('move.intro drawn.intro', function() {
@@ -133,7 +133,7 @@ export function uiIntroLine(context, reveal) {
var box = pad(tulipRoadMidpoint, padding, context);
box.height = box.height * 2;
reveal(box,
helpString('intro.lines.intersect', { name: t('intro.graph.name.flower-street') })
helpHtml('intro.lines.intersect', { name: t('intro.graph.name.flower-street') })
);
context.map().on('move.intro drawn.intro', function() {
@@ -141,7 +141,7 @@ export function uiIntroLine(context, reveal) {
box = pad(tulipRoadMidpoint, padding, context);
box.height = box.height * 2;
reveal(box,
helpString('intro.lines.intersect', { name: t('intro.graph.name.flower-street') }),
helpHtml('intro.lines.intersect', { name: t('intro.graph.name.flower-street') }),
{ duration: 0 }
);
});
@@ -191,7 +191,7 @@ export function uiIntroLine(context, reveal) {
var box = pad(tulipRoadIntersection, 80, context);
reveal(box,
helpString('intro.lines.retry_intersect', { name: t('intro.graph.name.flower-street') })
helpHtml('intro.lines.retry_intersect', { name: t('intro.graph.name.flower-street') })
);
timeout(chapter.restart, 3000);
@@ -205,9 +205,9 @@ export function uiIntroLine(context, reveal) {
context.map().centerEase(tulipRoadIntersection, 500);
var continueLineText = helpString('intro.lines.continue_line') + '{br}' +
helpString('intro.lines.finish_line_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap')) +
helpString('intro.lines.finish_road');
var continueLineText = helpHtml('intro.lines.continue_line') + '{br}' +
helpHtml('intro.lines.finish_line_' + (context.lastPointerType() === 'mouse' ? 'click' : 'tap')) +
helpHtml('intro.lines.finish_road');
reveal('.surface', continueLineText);
@@ -245,7 +245,7 @@ export function uiIntroLine(context, reveal) {
context.container().select('.inspector-wrap .panewrap').style('right', '-100%');
reveal(button.node(),
helpString('intro.lines.choose_category_road', { category: roadCategory.name() })
helpHtml('intro.lines.choose_category_road', { category: roadCategory.name() })
);
button.on('click.intro', function() {
@@ -285,7 +285,7 @@ export function uiIntroLine(context, reveal) {
timeout(function() {
reveal(subgrid.node(),
helpString('intro.lines.choose_preset_residential', { preset: residentialPreset.name() }),
helpHtml('intro.lines.choose_preset_residential', { preset: residentialPreset.name() }),
{ tooltipBox: '.preset-highway-residential .preset-list-button', duration: 300 }
);
}, 300);
@@ -313,7 +313,7 @@ export function uiIntroLine(context, reveal) {
var button = context.container().select('.entity-editor-pane .preset-list-button');
reveal(button.node(),
helpString('intro.lines.retry_preset_residential', { preset: residentialPreset.name() })
helpHtml('intro.lines.retry_preset_residential', { preset: residentialPreset.name() })
);
button.on('click.intro', function() {
@@ -338,7 +338,7 @@ export function uiIntroLine(context, reveal) {
timeout(function() {
reveal('.entity-editor-pane',
helpString('intro.lines.name_road', { button: icon('#iD-icon-close', 'pre-text') }),
helpHtml('intro.lines.name_road', { button: icon('#iD-icon-close', 'inline') }),
{ tooltipClass: 'intro-lines-name_road' }
);
}, 500);
@@ -354,8 +354,8 @@ export function uiIntroLine(context, reveal) {
context.history().checkpoint('doneAddLine');
timeout(function() {
reveal('.surface', helpString('intro.lines.did_name_road'), {
buttonText: t('intro.ok'),
reveal('.surface', helpHtml('intro.lines.did_name_road'), {
buttonText: t.html('intro.ok'),
buttonCallback: function() { continueTo(updateLine); }
});
}, 500);
@@ -381,15 +381,15 @@ export function uiIntroLine(context, reveal) {
var box = pad(woodRoadDragMidpoint, padding, context);
var advance = function() { continueTo(addNode); };
reveal(box, helpString('intro.lines.update_line'),
{ buttonText: t('intro.ok'), buttonCallback: advance }
reveal(box, helpHtml('intro.lines.update_line'),
{ buttonText: t.html('intro.ok'), buttonCallback: advance }
);
context.map().on('move.intro drawn.intro', function() {
var padding = 250 * Math.pow(2, context.map().zoom() - 19);
var box = pad(woodRoadDragMidpoint, padding, context);
reveal(box, helpString('intro.lines.update_line'),
{ duration: 0, buttonText: t('intro.ok'), buttonCallback: advance }
reveal(box, helpHtml('intro.lines.update_line'),
{ duration: 0, buttonText: t.html('intro.ok'), buttonCallback: advance }
);
});
}, msec + 100);
@@ -409,7 +409,7 @@ export function uiIntroLine(context, reveal) {
var padding = 40 * Math.pow(2, context.map().zoom() - 19);
var box = pad(woodRoadAddNode, padding, context);
var addNodeString = helpString('intro.lines.add_node' + (context.lastPointerType() === 'mouse' ? '' : '_touch'));
var addNodeString = helpHtml('intro.lines.add_node' + (context.lastPointerType() === 'mouse' ? '' : '_touch'));
reveal(box, addNodeString);
context.map().on('move.intro drawn.intro', function() {
@@ -448,8 +448,8 @@ export function uiIntroLine(context, reveal) {
}
var padding = 100 * Math.pow(2, context.map().zoom() - 19);
var box = pad(woodRoadDragEndpoint, padding, context);
var startDragString = helpString('intro.lines.start_drag_endpoint' + (context.lastPointerType() === 'mouse' ? '' : '_touch')) +
helpString('intro.lines.drag_to_intersection');
var startDragString = helpHtml('intro.lines.start_drag_endpoint' + (context.lastPointerType() === 'mouse' ? '' : '_touch')) +
helpHtml('intro.lines.drag_to_intersection');
reveal(box, startDragString);
context.map().on('move.intro drawn.intro', function() {
@@ -480,8 +480,8 @@ export function uiIntroLine(context, reveal) {
var padding = 100 * Math.pow(2, context.map().zoom() - 19);
var box = pad(woodRoadDragEndpoint, padding, context);
var finishDragString = helpString('intro.lines.spot_looks_good') +
helpString('intro.lines.finish_drag_endpoint' + (context.lastPointerType() === 'mouse' ? '' : '_touch'));
var finishDragString = helpHtml('intro.lines.spot_looks_good') +
helpHtml('intro.lines.finish_drag_endpoint' + (context.lastPointerType() === 'mouse' ? '' : '_touch'));
reveal(box, finishDragString);
context.map().on('move.intro drawn.intro', function() {
@@ -520,7 +520,7 @@ export function uiIntroLine(context, reveal) {
var padding = 80 * Math.pow(2, context.map().zoom() - 19);
var box = pad(woodRoadDragMidpoint, padding, context);
reveal(box, helpString('intro.lines.start_drag_midpoint'));
reveal(box, helpHtml('intro.lines.start_drag_midpoint'));
context.map().on('move.intro drawn.intro', function() {
if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
@@ -528,7 +528,7 @@ export function uiIntroLine(context, reveal) {
}
var padding = 80 * Math.pow(2, context.map().zoom() - 19);
var box = pad(woodRoadDragMidpoint, padding, context);
reveal(box, helpString('intro.lines.start_drag_midpoint'), { duration: 0 });
reveal(box, helpHtml('intro.lines.start_drag_midpoint'), { duration: 0 });
});
context.history().on('change.intro', function(changed) {
@@ -567,8 +567,8 @@ export function uiIntroLine(context, reveal) {
continueTo(deleteLines);
};
reveal(box, helpString('intro.lines.continue_drag_midpoint'),
{ buttonText: t('intro.ok'), buttonCallback: advance }
reveal(box, helpHtml('intro.lines.continue_drag_midpoint'),
{ buttonText: t.html('intro.ok'), buttonCallback: advance }
);
context.map().on('move.intro drawn.intro', function() {
@@ -578,8 +578,8 @@ export function uiIntroLine(context, reveal) {
var padding = 100 * Math.pow(2, context.map().zoom() - 19);
var box = pad(woodRoadDragEndpoint, padding, context);
box.height += 400;
reveal(box, helpString('intro.lines.continue_drag_midpoint'),
{ duration: 0, buttonText: t('intro.ok'), buttonCallback: advance }
reveal(box, helpHtml('intro.lines.continue_drag_midpoint'),
{ duration: 0, buttonText: t.html('intro.ok'), buttonCallback: advance }
);
});
@@ -611,8 +611,8 @@ export function uiIntroLine(context, reveal) {
box.height += 400;
var advance = function() { continueTo(rightClickIntersection); };
reveal(box, helpString('intro.lines.delete_lines', { street: t('intro.graph.name.12th-avenue') }),
{ buttonText: t('intro.ok'), buttonCallback: advance }
reveal(box, helpHtml('intro.lines.delete_lines', { street: t('intro.graph.name.12th-avenue') }),
{ buttonText: t.html('intro.ok'), buttonCallback: advance }
);
context.map().on('move.intro drawn.intro', function() {
@@ -620,8 +620,8 @@ export function uiIntroLine(context, reveal) {
var box = pad(deleteLinesLoc, padding, context);
box.top -= 200;
box.height += 400;
reveal(box, helpString('intro.lines.delete_lines', { street: t('intro.graph.name.12th-avenue') }),
{ duration: 0, buttonText: t('intro.ok'), buttonCallback: advance }
reveal(box, helpHtml('intro.lines.delete_lines', { street: t('intro.graph.name.12th-avenue') }),
{ duration: 0, buttonText: t.html('intro.ok'), buttonCallback: advance }
);
});
@@ -647,11 +647,11 @@ export function uiIntroLine(context, reveal) {
context.map().centerZoomEase(eleventhAvenueEnd, 18, 500);
var rightClickString = helpString('intro.lines.split_street', {
var rightClickString = helpHtml('intro.lines.split_street', {
street1: t('intro.graph.name.11th-avenue'),
street2: t('intro.graph.name.washington-street')
}) +
helpString('intro.lines.' + (context.lastPointerType() === 'mouse' ? 'rightclick_intersection' : 'edit_menu_intersection_touch'));
helpHtml('intro.lines.' + (context.lastPointerType() === 'mouse' ? 'rightclick_intersection' : 'edit_menu_intersection_touch'));
timeout(function() {
var padding = 60 * Math.pow(2, context.map().zoom() - 18);
@@ -708,7 +708,7 @@ export function uiIntroLine(context, reveal) {
var wasChanged = false;
_washingtonSegmentID = null;
reveal('.edit-menu', helpString('intro.lines.split_intersection',
reveal('.edit-menu', helpHtml('intro.lines.split_intersection',
{ street: t('intro.graph.name.washington-street') }),
{ padding: 50 }
);
@@ -717,7 +717,7 @@ export function uiIntroLine(context, reveal) {
var node = selectMenuItem(context, 'split').node();
if (!wasChanged && !node) { return continueTo(rightClickIntersection); }
reveal('.edit-menu', helpString('intro.lines.split_intersection',
reveal('.edit-menu', helpHtml('intro.lines.split_intersection',
{ street: t('intro.graph.name.washington-street') }),
{ duration: 0, padding: 50 }
);
@@ -751,15 +751,15 @@ export function uiIntroLine(context, reveal) {
var padding = 60 * Math.pow(2, context.map().zoom() - 18);
var box = pad(eleventhAvenueEnd, padding, context);
reveal(box, helpString('intro.lines.retry_split'),
{ buttonText: t('intro.ok'), buttonCallback: advance }
reveal(box, helpHtml('intro.lines.retry_split'),
{ buttonText: t.html('intro.ok'), buttonCallback: advance }
);
context.map().on('move.intro drawn.intro', function() {
var padding = 60 * Math.pow(2, context.map().zoom() - 18);
var box = pad(eleventhAvenueEnd, padding, context);
reveal(box, helpString('intro.lines.retry_split'),
{ duration: 0, buttonText: t('intro.ok'), buttonCallback: advance }
reveal(box, helpHtml('intro.lines.retry_split'),
{ duration: 0, buttonText: t.html('intro.ok'), buttonCallback: advance }
);
});
@@ -786,7 +786,7 @@ export function uiIntroLine(context, reveal) {
var padding = 200 * Math.pow(2, context.map().zoom() - 18);
var box = pad(twelfthAvenue, padding, context);
box.width = box.width / 2;
reveal(box, helpString(string, { street1: street, street2: street }),
reveal(box, helpHtml(string, { street1: street, street2: street }),
{ duration: 500 }
);
@@ -797,7 +797,7 @@ export function uiIntroLine(context, reveal) {
var padding = 200 * Math.pow(2, context.map().zoom() - 18);
var box = pad(twelfthAvenue, padding, context);
box.width = box.width / 2;
reveal(box, helpString(string, { street1: street, street2: street }),
reveal(box, helpHtml(string, { street1: street, street2: street }),
{ duration: 0 }
);
});
@@ -867,9 +867,9 @@ export function uiIntroLine(context, reveal) {
}
reveal(box,
helpString('intro.lines.multi_select',
helpHtml('intro.lines.multi_select',
{ selected: selected, other1: other }) + ' ' +
helpString('intro.lines.add_to_selection_' + (context.lastPointerType() === 'mouse' ? 'click' : 'touch'),
helpHtml('intro.lines.add_to_selection_' + (context.lastPointerType() === 'mouse' ? 'click' : 'touch'),
{ selected: selected, other2: other })
);
@@ -889,9 +889,9 @@ export function uiIntroLine(context, reveal) {
}
reveal(box,
helpString('intro.lines.multi_select',
helpHtml('intro.lines.multi_select',
{ selected: selected, other1: other }) + ' ' +
helpString('intro.lines.add_to_selection_' + (context.lastPointerType() === 'mouse' ? 'click' : 'touch'),
helpHtml('intro.lines.add_to_selection_' + (context.lastPointerType() === 'mouse' ? 'click' : 'touch'),
{ selected: selected, other2: other }),
{ duration: 0 }
);
@@ -933,8 +933,8 @@ export function uiIntroLine(context, reveal) {
var padding = 200 * Math.pow(2, context.map().zoom() - 18);
var box = pad(twelfthAvenue, padding, context);
var rightClickString = helpString('intro.lines.multi_select_success') +
helpString('intro.lines.multi_' + (context.lastPointerType() === 'mouse' ? 'rightclick' : 'edit_menu_touch'));
var rightClickString = helpHtml('intro.lines.multi_select_success') +
helpHtml('intro.lines.multi_' + (context.lastPointerType() === 'mouse' ? 'rightclick' : 'edit_menu_touch'));
reveal(box, rightClickString);
context.map().on('move.intro drawn.intro', function() {
@@ -995,13 +995,13 @@ export function uiIntroLine(context, reveal) {
if (!node) return continueTo(multiRightClick);
reveal('.edit-menu',
helpString('intro.lines.multi_delete'),
helpHtml('intro.lines.multi_delete'),
{ padding: 50 }
);
context.map().on('move.intro drawn.intro', function() {
reveal('.edit-menu',
helpString('intro.lines.multi_delete'),
helpHtml('intro.lines.multi_delete'),
{ duration: 0, padding: 50 }
);
});
@@ -1034,8 +1034,8 @@ export function uiIntroLine(context, reveal) {
var padding = 200 * Math.pow(2, context.map().zoom() - 18);
var box = pad(twelfthAvenue, padding, context);
reveal(box, helpString('intro.lines.retry_delete'), {
buttonText: t('intro.ok'),
reveal(box, helpHtml('intro.lines.retry_delete'), {
buttonText: t.html('intro.ok'),
buttonCallback: function() { continueTo(multiSelect); }
});
@@ -1048,9 +1048,9 @@ export function uiIntroLine(context, reveal) {
function play() {
dispatch.call('done');
reveal('.ideditor',
helpString('intro.lines.play', { next: t('intro.buildings.title') }), {
helpHtml('intro.lines.play', { next: t('intro.buildings.title') }), {
tooltipBox: '.intro-nav-wrap .chapter-building',
buttonText: t('intro.ok'),
buttonText: t.html('intro.ok'),
buttonCallback: function() { reveal('.ideditor'); }
}
);
+44 -44
View File
@@ -10,7 +10,7 @@ import { t } from '../../core/localizer';
import { modeBrowse } from '../../modes/browse';
import { modeSelect } from '../../modes/select';
import { utilRebind } from '../../util/rebind';
import { helpString, icon, pointBox, transitionTime } from './helper';
import { helpHtml, icon, pointBox, transitionTime } from './helper';
export function uiIntroNavigation(context, reveal) {
@@ -59,7 +59,7 @@ export function uiIntroNavigation(context, reveal) {
var centerStart = context.map().center();
var textId = context.lastPointerType() === 'mouse' ? 'drag' : 'drag_touch';
var dragString = helpString('intro.navigation.map_info') + '{br}' + helpString('intro.navigation.' + textId);
var dragString = helpHtml('intro.navigation.map_info') + '{br}' + helpHtml('intro.navigation.' + textId);
reveal('.surface', dragString);
context.map().on('drawn.intro', function() {
reveal('.surface', dragString, { duration: 0 });
@@ -86,7 +86,7 @@ export function uiIntroNavigation(context, reveal) {
var zoomStart = context.map().zoom();
var textId = context.lastPointerType() === 'mouse' ? 'zoom' : 'zoom_touch';
var zoomString = helpString('intro.navigation.' + textId);
var zoomString = helpHtml('intro.navigation.' + textId);
reveal('.surface', zoomString);
@@ -111,13 +111,13 @@ export function uiIntroNavigation(context, reveal) {
function features() {
var onClick = function() { continueTo(pointsLinesAreas); };
reveal('.surface', helpString('intro.navigation.features'),
{ buttonText: t('intro.ok'), buttonCallback: onClick }
reveal('.surface', helpHtml('intro.navigation.features'),
{ buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
context.map().on('drawn.intro', function() {
reveal('.surface', helpString('intro.navigation.features'),
{ duration: 0, buttonText: t('intro.ok'), buttonCallback: onClick }
reveal('.surface', helpHtml('intro.navigation.features'),
{ duration: 0, buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
});
@@ -130,13 +130,13 @@ export function uiIntroNavigation(context, reveal) {
function pointsLinesAreas() {
var onClick = function() { continueTo(nodesWays); };
reveal('.surface', helpString('intro.navigation.points_lines_areas'),
{ buttonText: t('intro.ok'), buttonCallback: onClick }
reveal('.surface', helpHtml('intro.navigation.points_lines_areas'),
{ buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
context.map().on('drawn.intro', function() {
reveal('.surface', helpString('intro.navigation.points_lines_areas'),
{ duration: 0, buttonText: t('intro.ok'), buttonCallback: onClick }
reveal('.surface', helpHtml('intro.navigation.points_lines_areas'),
{ duration: 0, buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
});
@@ -149,13 +149,13 @@ export function uiIntroNavigation(context, reveal) {
function nodesWays() {
var onClick = function() { continueTo(clickTownHall); };
reveal('.surface', helpString('intro.navigation.nodes_ways'),
{ buttonText: t('intro.ok'), buttonCallback: onClick }
reveal('.surface', helpHtml('intro.navigation.nodes_ways'),
{ buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
context.map().on('drawn.intro', function() {
reveal('.surface', helpString('intro.navigation.nodes_ways'),
{ duration: 0, buttonText: t('intro.ok'), buttonCallback: onClick }
reveal('.surface', helpHtml('intro.navigation.nodes_ways'),
{ duration: 0, buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
});
@@ -179,13 +179,13 @@ export function uiIntroNavigation(context, reveal) {
if (!entity) return;
var box = pointBox(entity.loc, context);
var textId = context.lastPointerType() === 'mouse' ? 'click_townhall' : 'tap_townhall';
reveal(box, helpString('intro.navigation.' + textId));
reveal(box, helpHtml('intro.navigation.' + textId));
context.map().on('move.intro drawn.intro', function() {
var entity = context.hasEntity(hallId);
if (!entity) return;
var box = pointBox(entity.loc, context);
reveal(box, helpString('intro.navigation.' + textId), { duration: 0 });
reveal(box, helpHtml('intro.navigation.' + textId), { duration: 0 });
});
context.on('enter.intro', function() {
@@ -218,16 +218,16 @@ export function uiIntroNavigation(context, reveal) {
var box = pointBox(entity.loc, context);
var onClick = function() { continueTo(editorTownHall); };
reveal(box, helpString('intro.navigation.selected_townhall'),
{ buttonText: t('intro.ok'), buttonCallback: onClick }
reveal(box, helpHtml('intro.navigation.selected_townhall'),
{ buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
context.map().on('move.intro drawn.intro', function() {
var entity = context.hasEntity(hallId);
if (!entity) return;
var box = pointBox(entity.loc, context);
reveal(box, helpString('intro.navigation.selected_townhall'),
{ duration: 0, buttonText: t('intro.ok'), buttonCallback: onClick }
reveal(box, helpHtml('intro.navigation.selected_townhall'),
{ duration: 0, buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
});
@@ -254,8 +254,8 @@ export function uiIntroNavigation(context, reveal) {
var onClick = function() { continueTo(presetTownHall); };
reveal('.entity-editor-pane',
helpString('intro.navigation.editor_townhall'),
{ buttonText: t('intro.ok'), buttonCallback: onClick }
helpHtml('intro.navigation.editor_townhall'),
{ buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
context.on('exit.intro', function() {
@@ -292,8 +292,8 @@ export function uiIntroNavigation(context, reveal) {
var onClick = function() { continueTo(fieldsTownHall); };
reveal('.entity-editor-pane .section-feature-type',
helpString('intro.navigation.preset_townhall', { preset: preset.name() }),
{ buttonText: t('intro.ok'), buttonCallback: onClick }
helpHtml('intro.navigation.preset_townhall', { preset: preset.name() }),
{ buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
context.on('exit.intro', function() {
@@ -326,8 +326,8 @@ export function uiIntroNavigation(context, reveal) {
var onClick = function() { continueTo(closeTownHall); };
reveal('.entity-editor-pane .section-preset-fields',
helpString('intro.navigation.fields_townhall'),
{ buttonText: t('intro.ok'), buttonCallback: onClick }
helpHtml('intro.navigation.fields_townhall'),
{ buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
context.on('exit.intro', function() {
@@ -356,7 +356,7 @@ export function uiIntroNavigation(context, reveal) {
var href = d3_select(selector).attr('href') || '#iD-icon-close';
reveal('.entity-editor-pane',
helpString('intro.navigation.close_townhall', { button: icon(href, 'pre-text') })
helpHtml('intro.navigation.close_townhall', { button: icon(href, 'inline') })
);
context.on('exit.intro', function() {
@@ -369,7 +369,7 @@ export function uiIntroNavigation(context, reveal) {
var href = d3_select(selector).attr('href') || '#iD-icon-close';
reveal('.entity-editor-pane',
helpString('intro.navigation.close_townhall', { button: icon(href, 'pre-text') }),
helpHtml('intro.navigation.close_townhall', { button: icon(href, 'inline') }),
{ duration: 0 }
);
});
@@ -392,7 +392,7 @@ export function uiIntroNavigation(context, reveal) {
timeout(function() {
reveal('.search-header input',
helpString('intro.navigation.search_street', { name: t('intro.graph.name.spring-street') })
helpHtml('intro.navigation.search_street', { name: t('intro.graph.name.spring-street') })
);
context.container().select('.search-header input')
@@ -406,9 +406,9 @@ export function uiIntroNavigation(context, reveal) {
var firstName = first.select('.entity-name');
var name = t('intro.graph.name.spring-street');
if (!firstName.empty() && firstName.text() === name) {
if (!firstName.empty() && firstName.html() === name) {
reveal(first.node(),
helpString('intro.navigation.choose_street', { name: name }),
helpHtml('intro.navigation.choose_street', { name: name }),
{ duration: 300 }
);
@@ -442,8 +442,8 @@ export function uiIntroNavigation(context, reveal) {
box.height = 500;
reveal(box,
helpString('intro.navigation.selected_street', { name: t('intro.graph.name.spring-street') }),
{ duration: 600, buttonText: t('intro.ok'), buttonCallback: onClick }
helpHtml('intro.navigation.selected_street', { name: t('intro.graph.name.spring-street') }),
{ duration: 600, buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
timeout(function() {
@@ -453,8 +453,8 @@ export function uiIntroNavigation(context, reveal) {
var box = pointBox(entity.loc, context);
box.height = 500;
reveal(box,
helpString('intro.navigation.selected_street', { name: t('intro.graph.name.spring-street') }),
{ duration: 0, buttonText: t('intro.ok'), buttonCallback: onClick }
helpHtml('intro.navigation.selected_street', { name: t('intro.graph.name.spring-street') }),
{ duration: 0, buttonText: t.html('intro.ok'), buttonCallback: onClick }
);
});
}, 600); // after reveal.
@@ -491,9 +491,9 @@ export function uiIntroNavigation(context, reveal) {
var selector = '.entity-editor-pane button.close svg use';
var href = d3_select(selector).attr('href') || '#iD-icon-close';
reveal('.entity-editor-pane', helpString('intro.navigation.street_different_fields') + '{br}' +
helpString('intro.navigation.editor_street', {
button: icon(href, 'pre-text'),
reveal('.entity-editor-pane', helpHtml('intro.navigation.street_different_fields') + '{br}' +
helpHtml('intro.navigation.editor_street', {
button: icon(href, 'inline'),
field1: onewayField.label(),
field2: maxspeedField.label()
}));
@@ -507,9 +507,9 @@ export function uiIntroNavigation(context, reveal) {
var selector = '.entity-editor-pane button.close svg use';
var href = d3_select(selector).attr('href') || '#iD-icon-close';
reveal('.entity-editor-pane', helpString('intro.navigation.street_different_fields') + '{br}' +
helpString('intro.navigation.editor_street', {
button: icon(href, 'pre-text'),
reveal('.entity-editor-pane', helpHtml('intro.navigation.street_different_fields') + '{br}' +
helpHtml('intro.navigation.editor_street', {
button: icon(href, 'inline'),
field1: onewayField.label(),
field2: maxspeedField.label()
}), { duration: 0 }
@@ -527,9 +527,9 @@ export function uiIntroNavigation(context, reveal) {
function play() {
dispatch.call('done');
reveal('.ideditor',
helpString('intro.navigation.play', { next: t('intro.points.title') }), {
helpHtml('intro.navigation.play', { next: t('intro.points.title') }), {
tooltipBox: '.intro-nav-wrap .chapter-point',
buttonText: t('intro.ok'),
buttonText: t.html('intro.ok'),
buttonCallback: function() { reveal('.ideditor'); }
}
);
+23 -23
View File
@@ -10,7 +10,7 @@ import { actionChangePreset } from '../../actions/change_preset';
import { modeBrowse } from '../../modes/browse';
import { modeSelect } from '../../modes/select';
import { utilRebind } from '../../util/rebind';
import { helpString, icon, pointBox, pad, selectMenuItem, transitionTime } from './helper';
import { helpHtml, icon, pointBox, pad, selectMenuItem, transitionTime } from './helper';
export function uiIntroPoint(context, reveal) {
@@ -48,7 +48,7 @@ export function uiIntroPoint(context, reveal) {
timeout(function() {
var tooltip = reveal('button.add-point',
helpString('intro.points.points_info') + '{br}' + helpString('intro.points.add_point'));
helpHtml('intro.points.points_info') + '{br}' + helpHtml('intro.points.add_point'));
_pointID = null;
@@ -78,11 +78,11 @@ export function uiIntroPoint(context, reveal) {
var pointBox = pad(building, 150, context);
var textId = context.lastPointerType() === 'mouse' ? 'place_point' : 'place_point_touch';
reveal(pointBox, helpString('intro.points.' + textId));
reveal(pointBox, helpHtml('intro.points.' + textId));
context.map().on('move.intro drawn.intro', function() {
pointBox = pad(building, 150, context);
reveal(pointBox, helpString('intro.points.' + textId), { duration: 0 });
reveal(pointBox, helpHtml('intro.points.' + textId), { duration: 0 });
});
context.on('enter.intro', function(mode) {
@@ -112,7 +112,7 @@ export function uiIntroPoint(context, reveal) {
.on('keyup.intro', checkPresetSearch);
reveal('.preset-search-input',
helpString('intro.points.search_cafe', { preset: cafePreset.name() })
helpHtml('intro.points.search_cafe', { preset: cafePreset.name() })
);
context.on('enter.intro', function(mode) {
@@ -133,7 +133,7 @@ export function uiIntroPoint(context, reveal) {
.on('keyup.intro', checkPresetSearch);
reveal('.preset-search-input',
helpString('intro.points.search_cafe', { preset: cafePreset.name() })
helpHtml('intro.points.search_cafe', { preset: cafePreset.name() })
);
context.history().on('change.intro', null);
@@ -150,7 +150,7 @@ export function uiIntroPoint(context, reveal) {
.on('keyup.intro', null);
reveal(first.select('.preset-list-button').node(),
helpString('intro.points.choose_cafe', { preset: cafePreset.name() }),
helpHtml('intro.points.choose_cafe', { preset: cafePreset.name() }),
{ duration: 300 }
);
@@ -176,9 +176,9 @@ export function uiIntroPoint(context, reveal) {
}
timeout(function() {
reveal('.entity-editor-pane', helpString('intro.points.feature_editor'), {
reveal('.entity-editor-pane', helpHtml('intro.points.feature_editor'), {
tooltipClass: 'intro-points-describe',
buttonText: t('intro.ok'),
buttonText: t.html('intro.ok'),
buttonCallback: function() { continueTo(addName); }
});
}, 400);
@@ -203,7 +203,7 @@ export function uiIntroPoint(context, reveal) {
// reset pane, in case user happened to change it..
context.container().select('.inspector-wrap .panewrap').style('right', '0%');
var addNameString = helpString('intro.points.fields_info') + '{br}' + helpString('intro.points.add_name');
var addNameString = helpHtml('intro.points.fields_info') + '{br}' + helpHtml('intro.points.add_name');
timeout(function() {
// It's possible for the user to add a name in a previous step..
@@ -213,7 +213,7 @@ export function uiIntroPoint(context, reveal) {
if (entity.tags.name) {
var tooltip = reveal('.entity-editor-pane', addNameString, {
tooltipClass: 'intro-points-describe',
buttonText: t('intro.ok'),
buttonText: t.html('intro.ok'),
buttonCallback: function() { continueTo(addCloseEditor); }
});
tooltip.select('.instruction').style('display', 'none');
@@ -254,7 +254,7 @@ export function uiIntroPoint(context, reveal) {
});
reveal('.entity-editor-pane',
helpString('intro.points.add_close', { button: icon(href, 'pre-text') })
helpHtml('intro.points.add_close', { button: icon(href, 'inline') })
);
function continueTo(nextStep) {
@@ -281,14 +281,14 @@ export function uiIntroPoint(context, reveal) {
timeout(function() {
var box = pointBox(entity.loc, context);
reveal(box, helpString('intro.points.reselect'), { duration: 600 });
reveal(box, helpHtml('intro.points.reselect'), { duration: 600 });
timeout(function() {
context.map().on('move.intro drawn.intro', function() {
var entity = context.hasEntity(_pointID);
if (!entity) return chapter.restart();
var box = pointBox(entity.loc, context);
reveal(box, helpString('intro.points.reselect'), { duration: 0 });
reveal(box, helpHtml('intro.points.reselect'), { duration: 0 });
});
}, 600); // after reveal..
@@ -324,7 +324,7 @@ export function uiIntroPoint(context, reveal) {
});
timeout(function() {
reveal('.entity-editor-pane', helpString('intro.points.update'),
reveal('.entity-editor-pane', helpHtml('intro.points.update'),
{ tooltipClass: 'intro-points-describe' }
);
}, 400);
@@ -351,7 +351,7 @@ export function uiIntroPoint(context, reveal) {
timeout(function() {
reveal('.entity-editor-pane',
helpString('intro.points.update_close', { button: icon('#iD-icon-close', 'pre-text') })
helpHtml('intro.points.update_close', { button: icon('#iD-icon-close', 'inline') })
);
}, 500);
@@ -371,14 +371,14 @@ export function uiIntroPoint(context, reveal) {
var box = pointBox(entity.loc, context);
var textId = context.lastPointerType() === 'mouse' ? 'rightclick' : 'edit_menu_touch';
reveal(box, helpString('intro.points.' + textId), { duration: 600 });
reveal(box, helpHtml('intro.points.' + textId), { duration: 600 });
timeout(function() {
context.map().on('move.intro', function() {
var entity = context.hasEntity(_pointID);
if (!entity) return chapter.restart();
var box = pointBox(entity.loc, context);
reveal(box, helpString('intro.points.' + textId), { duration: 0 });
reveal(box, helpHtml('intro.points.' + textId), { duration: 0 });
});
}, 600); // after reveal
@@ -411,14 +411,14 @@ export function uiIntroPoint(context, reveal) {
if (!node) { return continueTo(rightClickPoint); }
reveal('.edit-menu',
helpString('intro.points.delete'),
helpHtml('intro.points.delete'),
{ padding: 50 }
);
timeout(function() {
context.map().on('move.intro', function() {
reveal('.edit-menu',
helpString('intro.points.delete'),
helpHtml('intro.points.delete'),
{ duration: 0, padding: 50 }
);
});
@@ -451,7 +451,7 @@ export function uiIntroPoint(context, reveal) {
});
reveal('.top-toolbar button.undo-button',
helpString('intro.points.undo')
helpHtml('intro.points.undo')
);
function continueTo(nextStep) {
@@ -464,9 +464,9 @@ export function uiIntroPoint(context, reveal) {
function play() {
dispatch.call('done');
reveal('.ideditor',
helpString('intro.points.play', { next: t('intro.areas.title') }), {
helpHtml('intro.points.play', { next: t('intro.areas.title') }), {
tooltipBox: '.intro-nav-wrap .chapter-area',
buttonText: t('intro.ok'),
buttonText: t.html('intro.ok'),
buttonCallback: function() { reveal('.ideditor'); }
}
);
+8 -8
View File
@@ -4,7 +4,7 @@ import {
} from 'd3-selection';
import { t } from '../../core/localizer';
import { helpString } from './helper';
import { helpHtml } from './helper';
import { uiModal } from '../modal';
import { utilRebind } from '../../util/rebind';
@@ -20,8 +20,8 @@ export function uiIntroStartEditing(context, reveal) {
function showHelp() {
reveal('.map-control.help-control',
helpString('intro.startediting.help'), {
buttonText: t('intro.ok'),
helpHtml('intro.startediting.help'), {
buttonText: t.html('intro.ok'),
buttonCallback: function() { shortcuts(); }
}
);
@@ -29,8 +29,8 @@ export function uiIntroStartEditing(context, reveal) {
function shortcuts() {
reveal('.map-control.help-control',
helpString('intro.startediting.shortcuts'), {
buttonText: t('intro.ok'),
helpHtml('intro.startediting.shortcuts'), {
buttonText: t.html('intro.ok'),
buttonCallback: function() { showSave(); }
}
);
@@ -39,8 +39,8 @@ export function uiIntroStartEditing(context, reveal) {
function showSave() {
context.container().selectAll('.shaded').remove(); // in case user opened keyboard shortcuts
reveal('.top-toolbar button.save',
helpString('intro.startediting.save'), {
buttonText: t('intro.ok'),
helpHtml('intro.startediting.save'), {
buttonText: t.html('intro.ok'),
buttonCallback: function() { showStart(); }
}
);
@@ -72,7 +72,7 @@ export function uiIntroStartEditing(context, reveal) {
startbutton
.append('h2')
.text(t('intro.startediting.start'));
.html(t.html('intro.startediting.start'));
dispatch.call('startEditing');
}
+8 -8
View File
@@ -1,6 +1,6 @@
import { dispatch as d3_dispatch } from 'd3-dispatch';
import { helpString } from './helper';
import { helpHtml } from './helper';
import { t } from '../../core/localizer';
import { utilRebind } from '../../util/rebind';
@@ -16,22 +16,22 @@ export function uiIntroWelcome(context, reveal) {
function welcome() {
context.map().centerZoom([-85.63591, 41.94285], 19);
reveal('.intro-nav-wrap .chapter-welcome',
helpString('intro.welcome.welcome'),
{ buttonText: t('intro.ok'), buttonCallback: practice }
helpHtml('intro.welcome.welcome'),
{ buttonText: t.html('intro.ok'), buttonCallback: practice }
);
}
function practice() {
reveal('.intro-nav-wrap .chapter-welcome',
helpString('intro.welcome.practice'),
{ buttonText: t('intro.ok'), buttonCallback: words }
helpHtml('intro.welcome.practice'),
{ buttonText: t.html('intro.ok'), buttonCallback: words }
);
}
function words() {
reveal('.intro-nav-wrap .chapter-welcome',
helpString('intro.welcome.words'),
{ buttonText: t('intro.ok'), buttonCallback: chapters }
helpHtml('intro.welcome.words'),
{ buttonText: t.html('intro.ok'), buttonCallback: chapters }
);
}
@@ -39,7 +39,7 @@ export function uiIntroWelcome(context, reveal) {
function chapters() {
dispatch.call('done');
reveal('.intro-nav-wrap .chapter-navigation',
helpString('intro.welcome.chapters', { next: t('intro.navigation.title') })
helpHtml('intro.welcome.chapters', { next: t('intro.navigation.title') })
);
}
+2 -3
View File
@@ -56,14 +56,13 @@ export function uiIssuesInfo(context) {
return 'chip ' + d.id + '-count';
})
.attr('href', '#')
.attr('tabindex', -1)
.each(function(d) {
var chipSelection = d3_select(this);
var tooltipBehavior = uiTooltip()
.placement('top')
.title(t(d.descriptionID));
.title(t.html(d.descriptionID));
chipSelection
.call(tooltipBehavior)
@@ -84,7 +83,7 @@ export function uiIssuesInfo(context) {
enter.merge(chips)
.selectAll('span.count')
.text(function(d) {
.html(function(d) {
return d.count.toString();
});
}
+5 -4
View File
@@ -15,13 +15,13 @@ export function uiKeepRightDetails(context) {
function issueDetail(d) {
const { itemType, parentIssueType } = d;
const unknown = t('inspector.unknown');
const unknown = t.html('inspector.unknown');
let replacements = d.replacements || {};
replacements.default = unknown; // special key `default` works as a fallback string
let detail = t(`QA.keepRight.errorTypes.${itemType}.description`, replacements);
let detail = t.html(`QA.keepRight.errorTypes.${itemType}.description`, replacements);
if (detail === unknown) {
detail = t(`QA.keepRight.errorTypes.${parentIssueType}.description`, replacements);
detail = t.html(`QA.keepRight.errorTypes.${parentIssueType}.description`, replacements);
}
return detail;
}
@@ -48,7 +48,7 @@ export function uiKeepRightDetails(context) {
descriptionEnter
.append('h4')
.text(() => t('QA.keepRight.detail_description'));
.html(t.html('QA.keepRight.detail_description'));
descriptionEnter
.append('div')
@@ -58,6 +58,7 @@ export function uiKeepRightDetails(context) {
// If there are entity links in the error message..
let relatedEntities = [];
descriptionEnter.selectAll('.error_entity_link, .error_object_link')
.attr('href', '#')
.each(function() {
const link = d3_select(this);
const isObjectLink = link.classed('error_object_link');
+7 -7
View File
@@ -35,7 +35,7 @@ export function uiKeepRightEditor(context) {
headerEnter
.append('h3')
.text(t('QA.keepRight.title'));
.html(t.html('QA.keepRight.title'));
let body = selection.selectAll('.body')
@@ -90,7 +90,7 @@ export function uiKeepRightEditor(context) {
saveSectionEnter
.append('h4')
.attr('class', '.qa-save-header')
.text(t('QA.keepRight.comment'));
.html(t.html('QA.keepRight.comment'));
saveSectionEnter
.append('textarea')
@@ -146,7 +146,7 @@ export function uiKeepRightEditor(context) {
buttonEnter
.append('button')
.attr('class', 'button comment-button action')
.text(t('QA.keepRight.save_comment'));
.html(t.html('QA.keepRight.save_comment'));
buttonEnter
.append('button')
@@ -171,9 +171,9 @@ export function uiKeepRightEditor(context) {
});
buttonSection.select('.close-button') // select and propagate data
.text(d => {
.html(d => {
const andComment = (d.newComment ? '_comment' : '');
return t(`QA.keepRight.close${andComment}`);
return t.html(`QA.keepRight.close${andComment}`);
})
.on('click.close', function(d) {
this.blur(); // avoid keeping focus on the button - #4641
@@ -185,9 +185,9 @@ export function uiKeepRightEditor(context) {
});
buttonSection.select('.ignore-button') // select and propagate data
.text(d => {
.html(d => {
const andComment = (d.newComment ? '_comment' : '');
return t(`QA.keepRight.ignore${andComment}`);
return t.html(`QA.keepRight.ignore${andComment}`);
})
.on('click.ignore', function(d) {
this.blur(); // avoid keeping focus on the button - #4641
+4 -4
View File
@@ -8,13 +8,13 @@ export function uiKeepRightHeader() {
function issueTitle(d) {
const { itemType, parentIssueType } = d;
const unknown = t('inspector.unknown');
const unknown = t.html('inspector.unknown');
let replacements = d.replacements || {};
replacements.default = unknown; // special key `default` works as a fallback string
let title = t(`QA.keepRight.errorTypes.${itemType}.title`, replacements);
let title = t.html(`QA.keepRight.errorTypes.${itemType}.title`, replacements);
if (title === unknown) {
title = t(`QA.keepRight.errorTypes.${parentIssueType}.title`, replacements);
title = t.html(`QA.keepRight.errorTypes.${parentIssueType}.title`, replacements);
}
return title;
}
@@ -47,7 +47,7 @@ export function uiKeepRightHeader() {
headerEnter
.append('div')
.attr('class', 'qa-header-label')
.text(issueTitle);
.html(issueTitle);
}
+1 -1
View File
@@ -23,7 +23,7 @@ export function uiLoading(context) {
loadertext
.append('h3')
.text(_message);
.html(_message);
_modalSelection.select('button.close')
.attr('class', 'hide');
+36
View File
@@ -40,6 +40,11 @@ export function uiModal(selection, blocking) {
.append('div')
.attr('class', 'modal fillL');
modal
.append('input')
.attr('class', 'keytrap keytrap-first')
.on('focus.keytrap', moveFocusToLast);
if (!blocking) {
shaded.on('click.remove-modal', () => {
if (d3_event.target === this) {
@@ -65,6 +70,11 @@ export function uiModal(selection, blocking) {
.append('div')
.attr('class', 'content');
modal
.append('input')
.attr('class', 'keytrap keytrap-last')
.on('focus.keytrap', moveFocusToFirst);
if (animate) {
shaded.transition().style('opacity', 1);
} else {
@@ -72,4 +82,30 @@ export function uiModal(selection, blocking) {
}
return shaded;
function moveFocusToFirst() {
let node = modal
// there are additional rules about what's focusable, but this suits our purposes
.select('a, button, input:not(.keytrap), select, textarea')
.node();
if (node) {
node.focus();
} else {
d3_select(this).node().blur();
}
}
function moveFocusToLast() {
let nodes = modal
.selectAll('a, button, input:not(.keytrap), select, textarea')
.nodes();
if (nodes.length) {
nodes[nodes.length - 1].focus();
} else {
d3_select(this).node().blur();
}
}
}
+6 -4
View File
@@ -51,24 +51,26 @@ export function uiNoteComments() {
.append('a')
.attr('class', 'comment-author-link')
.attr('href', osm.userURL(d.user))
.attr('tabindex', -1)
.attr('target', '_blank');
}
selection
.text(function(d) { return d.user || t('note.anonymous'); });
.html(function(d) { return d.user || t.html('note.anonymous'); });
});
metadataEnter
.append('div')
.attr('class', 'comment-date')
.text(function(d) {
.html(function(d) {
return t('note.status.' + d.action, { when: localeDateString(d.date) });
});
mainEnter
.append('div')
.attr('class', 'comment-text')
.html(function(d) { return d.html; });
.html(function(d) { return d.html; })
.selectAll('a')
.attr('rel', 'noopener nofollow')
.attr('target', '_blank');
comments
.call(replaceAvatars);
+13 -13
View File
@@ -54,7 +54,7 @@ export function uiNoteEditor(context) {
headerEnter
.append('h3')
.text(t('note.title'));
.html(t.html('note.title'));
var body = selection.selectAll('.body')
@@ -148,7 +148,7 @@ export function uiNoteEditor(context) {
noteSaveEnter
.append('h4')
.attr('class', '.note-save-header')
.text(function() {
.html(function() {
return _note.isNew() ? t('note.newDescription') : t('note.newComment');
});
@@ -177,7 +177,8 @@ export function uiNoteEditor(context) {
// fast submit if user presses cmd+enter
function keydown() {
if (!(d3_event.keyCode === 13 && d3_event.metaKey)) return;
if (!(d3_event.keyCode === 13 && // ↩ Return
d3_event.metaKey)) return;
var osm = services.osm;
if (!osm) return;
@@ -256,14 +257,14 @@ export function uiNoteEditor(context) {
authEnter
.append('span')
.text(t('note.login'));
.html(t.html('note.login'));
authEnter
.append('a')
.attr('target', '_blank')
.call(svgIcon('#iD-icon-out-link', 'inline'))
.append('span')
.text(t('login'))
.html(t.html('login'))
.on('click.note-login', function() {
d3_event.preventDefault();
osm.authenticate();
@@ -284,7 +285,7 @@ export function uiNoteEditor(context) {
prose = prose.enter()
.append('p')
.attr('class', 'note-save-prose')
.text(t('note.upload_explanation'))
.html(t.html('note.upload_explanation'))
.merge(prose);
osm.userDetails(function(err, user) {
@@ -302,13 +303,12 @@ export function uiNoteEditor(context) {
userLink
.append('a')
.attr('class', 'user-info')
.text(user.display_name)
.html(user.display_name)
.attr('href', osm.userURL(user.display_name))
.attr('tabindex', -1)
.attr('target', '_blank');
prose
.html(t('note.upload_explanation_with_user', { user: userLink.html() }));
.html(t.html('note.upload_explanation_with_user', { user: userLink.html() }));
});
}
@@ -334,12 +334,12 @@ export function uiNoteEditor(context) {
buttonEnter
.append('button')
.attr('class', 'button cancel-button secondary-action')
.text(t('confirm.cancel'));
.html(t.html('confirm.cancel'));
buttonEnter
.append('button')
.attr('class', 'button save-button action')
.text(t('note.save'));
.html(t.html('note.save'));
} else {
buttonEnter
@@ -349,7 +349,7 @@ export function uiNoteEditor(context) {
buttonEnter
.append('button')
.attr('class', 'button comment-button action')
.text(t('note.comment'));
.html(t.html('note.comment'));
}
@@ -366,7 +366,7 @@ export function uiNoteEditor(context) {
buttonSection.select('.status-button') // select and propagate data
.attr('disabled', (hasAuth ? null : true))
.text(function(d) {
.html(function(d) {
var action = (d.status === 'open' ? 'close' : 'open');
var andComment = (d.newComment ? '_comment' : '');
return t('note.' + action + andComment);
+1 -1
View File
@@ -41,7 +41,7 @@ export function uiNoteHeader() {
headerEnter
.append('div')
.attr('class', 'note-header-label')
.text(function(d) {
.html(function(d) {
if (_note.isNew()) { return t('note.new'); }
return t('note.note') + ' ' + d.id + ' ' +
(d.status === 'closed' ? t('note.closed') : '');
+1 -1
View File
@@ -30,7 +30,7 @@ export function uiNoteReport() {
linkEnter
.append('span')
.text(t('note.report'));
.html(t.html('note.report'));
}
+1 -1
View File
@@ -28,7 +28,7 @@ export function uiNotice(context) {
.call(svgIcon('#iD-icon-plus', 'pre-text'))
.append('span')
.attr('class', 'label')
.text(t('zoom_in_edit'));
.html(t.html('zoom_in_edit'));
function disableTooHigh() {
+9 -8
View File
@@ -45,7 +45,7 @@ export function uiOsmoseDetails(context) {
div
.append('h4')
.text(() => t('QA.keepRight.detail_description'));
.html(t.html('QA.keepRight.detail_description'));
div
.append('p')
@@ -65,7 +65,7 @@ export function uiOsmoseDetails(context) {
.append('div')
.attr('class', 'qa-details-subsection');
// Suggested Fix (musn't exist for every issue type)
// Suggested Fix (mustn't exist for every issue type)
if (issueString(_qaItem, 'fix')) {
const div = detailsEnter
.append('div')
@@ -73,7 +73,7 @@ export function uiOsmoseDetails(context) {
div
.append('h4')
.text(() => t('QA.osmose.fix_title'));
.html(t.html('QA.osmose.fix_title'));
div
.append('p')
@@ -83,7 +83,7 @@ export function uiOsmoseDetails(context) {
.attr('target', '_blank');
}
// Common Pitfalls (musn't exist for every issue type)
// Common Pitfalls (mustn't exist for every issue type)
if (issueString(_qaItem, 'trap')) {
const div = detailsEnter
.append('div')
@@ -91,7 +91,7 @@ export function uiOsmoseDetails(context) {
div
.append('h4')
.text(() => t('QA.osmose.trap_title'));
.html(t.html('QA.osmose.trap_title'));
div
.append('p')
@@ -118,7 +118,7 @@ export function uiOsmoseDetails(context) {
if (d.detail) {
detailsDiv
.append('h4')
.text(() => t('QA.osmose.detail_title'));
.html(t.html('QA.osmose.detail_title'));
detailsDiv
.append('p')
@@ -131,7 +131,7 @@ export function uiOsmoseDetails(context) {
// Create list of linked issue elements
elemsDiv
.append('h4')
.text(() => t('QA.osmose.elems_title'));
.html(t.html('QA.osmose.elems_title'));
elemsDiv
.append('ul').selectAll('li')
@@ -139,8 +139,9 @@ export function uiOsmoseDetails(context) {
.enter()
.append('li')
.append('a')
.attr('href', '#')
.attr('class', 'error_entity_link')
.text(d => d)
.html(d => d)
.each(function() {
const link = d3_select(this);
const entityID = this.textContent;
+3 -3
View File
@@ -35,7 +35,7 @@ export function uiOsmoseEditor(context) {
headerEnter
.append('h3')
.text(t('QA.osmose.title'));
.html(t.html('QA.osmose.title'));
let body = selection.selectAll('.body')
.data([0]);
@@ -117,7 +117,7 @@ export function uiOsmoseEditor(context) {
.merge(buttonEnter);
buttonSection.select('.close-button')
.text(() => t('QA.keepRight.close'))
.html(t.html('QA.keepRight.close'))
.on('click.close', function(d) {
this.blur(); // avoid keeping focus on the button - #4641
const qaService = services.osmose;
@@ -128,7 +128,7 @@ export function uiOsmoseEditor(context) {
});
buttonSection.select('.ignore-button')
.text(() => t('QA.keepRight.ignore'))
.html(t.html('QA.keepRight.ignore'))
.on('click.ignore', function(d) {
this.blur(); // avoid keeping focus on the button - #4641
const qaService = services.osmose;
+1 -1
View File
@@ -65,7 +65,7 @@ export function uiOsmoseHeader() {
headerEnter
.append('div')
.attr('class', 'qa-header-label')
.text(issueTitle);
.html(issueTitle);
}
osmoseHeader.issue = function(val) {
+5 -5
View File
@@ -11,7 +11,7 @@ import { uiTooltip } from './tooltip';
export function uiPane(id, context) {
var _key;
var _title = '';
var _label = '';
var _description = '';
var _iconName = '';
var _sections; // array of uiSection objects
@@ -24,9 +24,9 @@ export function uiPane(id, context) {
id: id
};
pane.title = function(val) {
if (!arguments.length) return _title;
_title = val;
pane.label = function(val) {
if (!arguments.length) return _label;
_label = val;
return pane;
};
@@ -107,7 +107,7 @@ export function uiPane(id, context) {
heading
.append('h2')
.text(_title);
.html(_label);
heading
.append('button')
+25 -24
View File
@@ -9,9 +9,9 @@ import { t } from '../../core/localizer';
export function uiPanelBackground(context) {
var background = context.background();
var currSourceName = null;
var metadata = {};
var metadataKeys = [
var _currSourceName = null;
var _metadata = {};
var _metadataKeys = [
'zoom', 'vintage', 'source', 'description', 'resolution', 'accuracy'
];
@@ -23,9 +23,10 @@ export function uiPanelBackground(context) {
var isDG = (source.id.match(/^DigitalGlobe/i) !== null);
if (currSourceName !== source.name()) {
currSourceName = source.name();
metadata = {};
var sourceLabel = source.label();
if (_currSourceName !== sourceLabel) {
_currSourceName = sourceLabel;
_metadata = {};
}
selection.html('');
@@ -36,20 +37,20 @@ export function uiPanelBackground(context) {
list
.append('li')
.text(currSourceName);
.html(_currSourceName);
metadataKeys.forEach(function(k) {
_metadataKeys.forEach(function(k) {
// DigitalGlobe vintage is available in raster layers for now.
if (isDG && k === 'vintage') return;
list
.append('li')
.attr('class', 'background-info-list-' + k)
.classed('hide', !metadata[k])
.text(t('info_panels.background.' + k) + ':')
.classed('hide', !_metadata[k])
.html(t.html('info_panels.background.' + k) + ':')
.append('span')
.attr('class', 'background-info-span-' + k)
.text(metadata[k]);
.html(_metadata[k]);
});
debouncedGetMetadata(selection);
@@ -58,7 +59,7 @@ export function uiPanelBackground(context) {
selection
.append('a')
.text(t('info_panels.background.' + toggleTiles))
.html(t.html('info_panels.background.' + toggleTiles))
.attr('href', '#')
.attr('class', 'button button-toggle-tiles')
.on('click', function() {
@@ -74,7 +75,7 @@ export function uiPanelBackground(context) {
var toggleVintage = showsVintage ? 'hide_vintage' : 'show_vintage';
selection
.append('a')
.text(t('info_panels.background.' + toggleVintage))
.html(t.html('info_panels.background.' + toggleVintage))
.attr('href', '#')
.attr('class', 'button button-toggle-vintage')
.on('click', function() {
@@ -103,40 +104,40 @@ export function uiPanelBackground(context) {
var tile = context.container().select('.layer-background img.tile-center'); // tile near viewport center
if (tile.empty()) return;
var sourceName = currSourceName;
var sourceName = _currSourceName;
var d = tile.datum();
var zoom = (d && d.length >= 3 && d[2]) || Math.floor(context.map().zoom());
var center = context.map().center();
// update zoom
metadata.zoom = String(zoom);
_metadata.zoom = String(zoom);
selection.selectAll('.background-info-list-zoom')
.classed('hide', false)
.selectAll('.background-info-span-zoom')
.text(metadata.zoom);
.html(_metadata.zoom);
if (!d || !d.length >= 3) return;
background.baseLayerSource().getMetadata(center, d, function(err, result) {
if (err || currSourceName !== sourceName) return;
if (err || _currSourceName !== sourceName) return;
// update vintage
var vintage = result.vintage;
metadata.vintage = (vintage && vintage.range) || t('info_panels.background.unknown');
_metadata.vintage = (vintage && vintage.range) || t('info_panels.background.unknown');
selection.selectAll('.background-info-list-vintage')
.classed('hide', false)
.selectAll('.background-info-span-vintage')
.text(metadata.vintage);
.html(_metadata.vintage);
// update other metdata
metadataKeys.forEach(function(k) {
// update other _metadata
_metadataKeys.forEach(function(k) {
if (k === 'zoom' || k === 'vintage') return; // done already
var val = result[k];
metadata[k] = val;
_metadata[k] = val;
selection.selectAll('.background-info-list-' + k)
.classed('hide', !val)
.selectAll('.background-info-span-' + k)
.text(val);
.html(val);
});
});
}
@@ -162,7 +163,7 @@ export function uiPanelBackground(context) {
};
panel.id = 'background';
panel.title = t('info_panels.background.title');
panel.label = t.html('info_panels.background.title');
panel.key = t('info_panels.background.key');
+27 -33
View File
@@ -21,14 +21,14 @@ export function uiPanelHistory(context) {
if (!userName) {
selection
.append('span')
.text(t('info_panels.history.unknown'));
.html(t.html('info_panels.history.unknown'));
return;
}
selection
.append('span')
.attr('class', 'user-name')
.text(userName);
.html(userName);
var links = selection
.append('div')
@@ -40,8 +40,7 @@ export function uiPanelHistory(context) {
.attr('class', 'user-osm-link')
.attr('href', osm.userURL(userName))
.attr('target', '_blank')
.attr('tabindex', -1)
.text('OSM');
.html('OSM');
}
links
@@ -50,7 +49,7 @@ export function uiPanelHistory(context) {
.attr('href', 'https://hdyc.neis-one.org/?' + userName)
.attr('target', '_blank')
.attr('tabindex', -1)
.text('HDYC');
.html('HDYC');
}
@@ -58,14 +57,14 @@ export function uiPanelHistory(context) {
if (!changeset) {
selection
.append('span')
.text(t('info_panels.history.unknown'));
.html(t.html('info_panels.history.unknown'));
return;
}
selection
.append('span')
.attr('class', 'changeset-id')
.text(changeset);
.html(changeset);
var links = selection
.append('div')
@@ -77,8 +76,7 @@ export function uiPanelHistory(context) {
.attr('class', 'changeset-osm-link')
.attr('href', osm.changesetURL(changeset))
.attr('target', '_blank')
.attr('tabindex', -1)
.text('OSM');
.html('OSM');
}
links
@@ -86,16 +84,14 @@ export function uiPanelHistory(context) {
.attr('class', 'changeset-osmcha-link')
.attr('href', 'https://osmcha.org/changesets/' + changeset)
.attr('target', '_blank')
.attr('tabindex', -1)
.text('OSMCha');
.html('OSMCha');
links
.append('a')
.attr('class', 'changeset-achavi-link')
.attr('href', 'https://overpass-api.de/achavi/?changeset=' + changeset)
.attr('target', '_blank')
.attr('tabindex', -1)
.text('Achavi');
.html('Achavi');
}
@@ -122,7 +118,7 @@ export function uiPanelHistory(context) {
selection
.append('h4')
.attr('class', 'history-heading')
.text(singular || t('info_panels.history.selected', { n: selected.length }));
.html(singular || t.html('info_panels.selected', { n: selected.length }));
if (!singular) return;
@@ -138,7 +134,7 @@ export function uiPanelHistory(context) {
if (!note || note.isNew()) {
selection
.append('div')
.text(t('info_panels.history.note_no_history'));
.html(t.html('info_panels.history.note_no_history'));
return;
}
@@ -147,20 +143,20 @@ export function uiPanelHistory(context) {
list
.append('li')
.text(t('info_panels.history.note_comments') + ':')
.html(t.html('info_panels.history.note_comments') + ':')
.append('span')
.text(note.comments.length);
.html(note.comments.length);
if (note.comments.length) {
list
.append('li')
.text(t('info_panels.history.note_created_date') + ':')
.html(t.html('info_panels.history.note_created_date') + ':')
.append('span')
.text(displayTimestamp(note.comments[0].date));
.html(displayTimestamp(note.comments[0].date));
list
.append('li')
.text(t('info_panels.history.note_created_user') + ':')
.html(t.html('info_panels.history.note_created_user') + ':')
.call(displayUser, note.comments[0].user);
}
@@ -169,11 +165,10 @@ export function uiPanelHistory(context) {
.append('a')
.attr('class', 'view-history-on-osm')
.attr('target', '_blank')
.attr('tabindex', -1)
.attr('href', osm.noteURL(note))
.call(svgIcon('#iD-icon-out-link', 'inline'))
.append('span')
.text(t('info_panels.history.note_link_text'));
.html(t.html('info_panels.history.note_link_text'));
}
}
@@ -182,7 +177,7 @@ export function uiPanelHistory(context) {
if (!entity || entity.isNew()) {
selection
.append('div')
.text(t('info_panels.history.no_history'));
.html(t.html('info_panels.history.no_history'));
return;
}
@@ -196,9 +191,8 @@ export function uiPanelHistory(context) {
.attr('class', 'view-history-on-osm')
.attr('href', osm.historyURL(entity))
.attr('target', '_blank')
.attr('tabindex', -1)
.attr('title', t('info_panels.history.link_text'))
.text('OSM');
.html('OSM');
}
links
.append('a')
@@ -206,31 +200,31 @@ export function uiPanelHistory(context) {
.attr('href', 'https://pewu.github.io/osm-history/#/' + entity.type + '/' + entity.osmId())
.attr('target', '_blank')
.attr('tabindex', -1)
.text('PeWu');
.html('PeWu');
var list = selection
.append('ul');
list
.append('li')
.text(t('info_panels.history.version') + ':')
.html(t.html('info_panels.history.version') + ':')
.append('span')
.text(entity.version);
.html(entity.version);
list
.append('li')
.text(t('info_panels.history.last_edit') + ':')
.html(t.html('info_panels.history.last_edit') + ':')
.append('span')
.text(displayTimestamp(entity.timestamp));
.html(displayTimestamp(entity.timestamp));
list
.append('li')
.text(t('info_panels.history.edited_by') + ':')
.html(t.html('info_panels.history.edited_by') + ':')
.call(displayUser, entity.user);
list
.append('li')
.text(t('info_panels.history.changeset') + ':')
.html(t.html('info_panels.history.changeset') + ':')
.call(displayChangeset, entity.changeset);
}
@@ -255,7 +249,7 @@ export function uiPanelHistory(context) {
};
panel.id = 'history';
panel.title = t('info_panels.history.title');
panel.label = t.html('info_panels.history.title');
panel.key = t('info_panels.history.key');
+6 -6
View File
@@ -23,15 +23,15 @@ export function uiPanelLocation(context) {
list
.append('li')
.text(dmsCoordinatePair(coord))
.html(dmsCoordinatePair(coord))
.append('li')
.text(decimalCoordinatePair(coord));
.html(decimalCoordinatePair(coord));
// Location Info
selection
.append('div')
.attr('class', 'location-info')
.text(currLocation || ' ');
.html(currLocation || ' ');
debouncedGetLocation(selection, coord);
}
@@ -42,12 +42,12 @@ export function uiPanelLocation(context) {
if (!services.geocoder) {
currLocation = t('info_panels.location.unknown_location');
selection.selectAll('.location-info')
.text(currLocation);
.html(currLocation);
} else {
services.geocoder.reverse(coord, function(err, result) {
currLocation = result ? result.display_name : t('info_panels.location.unknown_location');
selection.selectAll('.location-info')
.text(currLocation);
.html(currLocation);
});
}
}
@@ -68,7 +68,7 @@ export function uiPanelLocation(context) {
};
panel.id = 'location';
panel.title = t('info_panels.location.title');
panel.label = t.html('info_panels.location.title');
panel.key = t('info_panels.location.key');
+40 -28
View File
@@ -7,14 +7,11 @@ import {
import { t, localizer } from '../../core/localizer';
import { displayArea, displayLength, decimalCoordinatePair, dmsCoordinatePair } from '../../util/units';
import { geoExtent } from '../../geo';
import { geoExtent, geoSphericalDistance } from '../../geo';
import { services } from '../../services';
import { utilGetAllNodes } from '../../util';
export function uiPanelMeasurement(context) {
var locale = localizer.localeCode();
var isImperial = !localizer.usesMetric();
function radiansToMeters(r) {
// using WGS84 authalic radius (6371007.1809 m)
@@ -45,11 +42,13 @@ export function uiPanelMeasurement(context) {
var graph = context.graph();
var selectedNoteID = context.selectedNoteID();
var osm = services.osm;
var isImperial = !localizer.usesMetric();
var localeCode = localizer.localeCode();
var heading;
var center, location, centroid;
var closed, geometry;
var totalNodeCount, length = 0, area = 0;
var totalNodeCount, length = 0, area = 0, distance;
if (selectedNoteID && osm) { // selected 1 note
@@ -67,7 +66,7 @@ export function uiPanelMeasurement(context) {
});
heading = selected.length === 1 ? selected[0].id :
t('info_panels.measurement.selected', { n: selected.length.toLocaleString(locale) });
t('info_panels.selected', { n: selected.length });
if (selected.length) {
var extent = geoExtent();
@@ -93,6 +92,12 @@ export function uiPanelMeasurement(context) {
centroid = null;
}
if (selected.length === 2 &&
selected[0].type === 'node' &&
selected[1].type === 'node') {
distance = geoSphericalDistance(selected[0].loc, selected[1].loc);
}
if (selected.length === 1 && selected[0].type === 'node') {
location = selected[0].loc;
} else {
@@ -111,7 +116,7 @@ export function uiPanelMeasurement(context) {
selection
.append('h4')
.attr('class', 'measurement-heading')
.text(heading);
.html(heading);
}
var list = selection
@@ -121,9 +126,9 @@ export function uiPanelMeasurement(context) {
if (geometry) {
list
.append('li')
.text(t('info_panels.measurement.geometry') + ':')
.html(t.html('info_panels.measurement.geometry') + ':')
.append('span')
.text(
.html(
closed ? t('info_panels.measurement.closed_' + geometry) : t('geometry.' + geometry)
);
}
@@ -131,63 +136,70 @@ export function uiPanelMeasurement(context) {
if (totalNodeCount) {
list
.append('li')
.text(t('info_panels.measurement.node_count') + ':')
.html(t.html('info_panels.measurement.node_count') + ':')
.append('span')
.text(totalNodeCount.toLocaleString(locale));
.html(totalNodeCount.toLocaleString(localeCode));
}
if (area) {
list
.append('li')
.text(t('info_panels.measurement.area') + ':')
.html(t.html('info_panels.measurement.area') + ':')
.append('span')
.text(displayArea(area, isImperial));
.html(displayArea(area, isImperial));
}
if (length) {
var lengthLabel = t('info_panels.measurement.' + (closed ? 'perimeter' : 'length'));
list
.append('li')
.text(lengthLabel + ':')
.html(t.html('info_panels.measurement.' + (closed ? 'perimeter' : 'length')) + ':')
.append('span')
.text(displayLength(length, isImperial));
.html(displayLength(length, isImperial));
}
if (typeof distance === 'number') {
list
.append('li')
.html(t.html('info_panels.measurement.distance') + ':')
.append('span')
.html(displayLength(distance, isImperial));
}
if (location) {
coordItem = list
.append('li')
.text(t('info_panels.measurement.location') + ':');
.html(t.html('info_panels.measurement.location') + ':');
coordItem.append('span')
.text(dmsCoordinatePair(location));
.html(dmsCoordinatePair(location));
coordItem.append('span')
.text(decimalCoordinatePair(location));
.html(decimalCoordinatePair(location));
}
if (centroid) {
coordItem = list
.append('li')
.text(t('info_panels.measurement.centroid') + ':');
.html(t.html('info_panels.measurement.centroid') + ':');
coordItem.append('span')
.text(dmsCoordinatePair(centroid));
.html(dmsCoordinatePair(centroid));
coordItem.append('span')
.text(decimalCoordinatePair(centroid));
.html(decimalCoordinatePair(centroid));
}
if (center) {
coordItem = list
.append('li')
.text(t('info_panels.measurement.center') + ':');
.html(t.html('info_panels.measurement.center') + ':');
coordItem.append('span')
.text(dmsCoordinatePair(center));
.html(dmsCoordinatePair(center));
coordItem.append('span')
.text(decimalCoordinatePair(center));
.html(decimalCoordinatePair(center));
}
if (length || area) {
if (length || area || typeof distance === 'number') {
var toggle = isImperial ? 'imperial' : 'metric';
selection
.append('a')
.text(t('info_panels.measurement.' + toggle))
.html(t.html('info_panels.measurement.' + toggle))
.attr('href', '#')
.attr('class', 'button button-toggle-units')
.on('click', function() {
@@ -219,7 +231,7 @@ export function uiPanelMeasurement(context) {
};
panel.id = 'measurement';
panel.title = t('info_panels.measurement.title');
panel.label = t.html('info_panels.measurement.title');
panel.key = t('info_panels.measurement.key');
+2 -2
View File
@@ -11,8 +11,8 @@ export function uiPaneBackground(context) {
var backgroundPane = uiPane('background', context)
.key(t('background.key'))
.title(t('background.title'))
.description(t('background.description'))
.label(t.html('background.title'))
.description(t.html('background.description'))
.iconName('iD-icon-layers')
.sections([
uiSectionBackgroundList(context),
+44 -14
View File
@@ -1,13 +1,14 @@
import { event as d3_event } from 'd3-selection';
import marked from 'marked';
import { svgIcon } from '../../svg/icon';
import { uiIntro } from '../intro/intro';
import { uiShortcuts } from '../shortcuts';
import { uiPane } from '../pane';
import { t, localizer } from '../../core/localizer';
import { uiTooltip } from '../tooltip';
import { helpString } from '../intro/helper';
import { helpHtml } from '../intro/helper';
export function uiPaneHelp(context) {
@@ -142,6 +143,25 @@ export function uiPaneHelp(context) {
'boundary',
'boundary_add'
]],
['operations', [
'intro',
'intro_2',
'straighten',
'orthogonalize',
'circularize',
'move',
'rotate',
'reflect',
'continue',
'reverse',
'disconnect',
'split',
'extract',
'merge',
'delete',
'downgrade',
'copy_paste'
]],
['notes', [
'intro',
'add_note_h',
@@ -242,12 +262,12 @@ export function uiPaneHelp(context) {
var subkey = helpkey + '.' + part;
var depth = headings[subkey]; // is this subkey a heading?
var hhh = depth ? Array(depth + 1).join('#') + ' ' : ''; // if so, prepend with some ##'s
return all + hhh + helpString(subkey, helpPaneReplacements) + '\n\n';
return all + hhh + helpHtml(subkey, helpPaneReplacements) + '\n\n';
}, '');
return {
title: t(helpkey + '.title'),
html: marked(text.trim())
title: t.html(helpkey + '.title'),
content: marked(text.trim())
// use keyboard key styling for shortcuts
.replace(/<code>/g, '<kbd>')
.replace(/<\/code>/g, '<\/kbd>')
@@ -256,18 +276,19 @@ export function uiPaneHelp(context) {
var helpPane = uiPane('help', context)
.key(t('help.key'))
.title(t('help.title'))
.description(t('help.title'))
.label(t.html('help.title'))
.description(t.html('help.title'))
.iconName('iD-icon-help');
helpPane.renderContent = function(content) {
function clickHelp(d, i) {
if (d3_event) d3_event.preventDefault();
var rtl = (localizer.textDirection() === 'rtl');
content.property('scrollTop', 0);
helpPane.selection().select('.pane-heading h2').html(d.title);
body.html(d.html);
body.html(d.content);
body.selectAll('a')
.attr('target', '_blank');
menuItems.classed('selected', function(m) {
@@ -286,14 +307,16 @@ export function uiPaneHelp(context) {
if (i < docs.length - 1) {
var nextLink = selection
.append('a')
.attr('href', '#')
.attr('class', 'next')
.on('click', function() {
d3_event.preventDefault();
clickHelp(docs[i + 1], i + 1);
});
nextLink
.append('span')
.text(docs[i + 1].title)
.html(docs[i + 1].title)
.call(svgIcon((rtl ? '#iD-icon-backward' : '#iD-icon-forward'), 'inline'));
}
}
@@ -303,21 +326,24 @@ export function uiPaneHelp(context) {
if (i > 0) {
var prevLink = selection
.append('a')
.attr('href', '#')
.attr('class', 'previous')
.on('click', function() {
d3_event.preventDefault();
clickHelp(docs[i - 1], i - 1);
});
prevLink
.call(svgIcon((rtl ? '#iD-icon-forward' : '#iD-icon-backward'), 'inline'))
.append('span')
.text(docs[i - 1].title);
.html(docs[i - 1].title);
}
}
}
function clickWalkthrough() {
d3_event.preventDefault();
if (context.inIntro()) return;
context.container().call(uiIntro(context));
context.ui().togglePanes();
@@ -325,7 +351,8 @@ export function uiPaneHelp(context) {
function clickShortcuts() {
context.container().call(uiShortcuts(context), true);
d3_event.preventDefault();
context.container().call(context.ui().shortcuts, true);
}
var toc = content
@@ -337,6 +364,7 @@ export function uiPaneHelp(context) {
.enter()
.append('li')
.append('a')
.attr('href', '#')
.html(function(d) { return d.title; })
.on('click', clickHelp);
@@ -344,21 +372,23 @@ export function uiPaneHelp(context) {
.append('li')
.attr('class', 'shortcuts')
.call(uiTooltip()
.title(t('shortcuts.tooltip'))
.title(t.html('shortcuts.tooltip'))
.keys(['?'])
.placement('top')
)
.append('a')
.attr('href', '#')
.on('click', clickShortcuts);
shortcuts
.append('div')
.text(t('shortcuts.title'));
.html(t.html('shortcuts.title'));
var walkthrough = toc
.append('li')
.attr('class', 'walkthrough')
.append('a')
.attr('href', '#')
.on('click', clickWalkthrough);
walkthrough
@@ -369,7 +399,7 @@ export function uiPaneHelp(context) {
walkthrough
.append('div')
.text(t('splash.walkthrough'));
.html(t.html('splash.walkthrough'));
var helpContent = content
+2 -2
View File
@@ -11,8 +11,8 @@ export function uiPaneIssues(context) {
var issuesPane = uiPane('issues', context)
.key(t('issues.key'))
.title(t('issues.title'))
.description(t('issues.title'))
.label(t.html('issues.title'))
.description(t.html('issues.title'))
.iconName('iD-icon-alert')
.sections([
uiSectionValidationOptions(context),
+2 -2
View File
@@ -11,8 +11,8 @@ export function uiPaneMapData(context) {
var mapDataPane = uiPane('map-data', context)
.key(t('map_data.key'))
.title(t('map_data.title'))
.description(t('map_data.description'))
.label(t.html('map_data.title'))
.description(t.html('map_data.description'))
.iconName('iD-icon-data')
.sections([
uiSectionDataLayers(context),
+2 -2
View File
@@ -7,8 +7,8 @@ export function uiPanePreferences(context) {
let preferencesPane = uiPane('preferences', context)
.key(t('preferences.key'))
.title(t('preferences.title'))
.description(t('preferences.description'))
.label(t.html('preferences.title'))
.description(t.html('preferences.description'))
.iconName('fas-user-cog')
.sections([
uiSectionPrivacy(context)
-4
View File
@@ -58,10 +58,6 @@ export function uiPhotoviewer(context) {
buildResizeListener(selection, 'resize', dispatch, { resizeOnY: true })
);
services.streetside.loadViewer(context);
services.mapillary.loadViewer(context);
services.openstreetcam.loadViewer(context);
function buildResizeListener(target, eventName, dispatch, options) {
var resizeOnX = !!options.resizeOnX;
+10 -2
View File
@@ -171,8 +171,15 @@ export function uiPopover(klass) {
if (d3_event.buttons !== 0) return;
show.apply(this, arguments);
});
anchor.on(_pointerPrefix + 'leave.popover', function() {
})
.on(_pointerPrefix + 'leave.popover', function() {
hide.apply(this, arguments);
})
// show on focus too for better keyboard navigation support
.on('focus.popover', function() {
show.apply(this, arguments);
})
.on('blur.popover', function() {
hide.apply(this, arguments);
});
@@ -189,6 +196,7 @@ export function uiPopover(klass) {
.on('click.popover', toggle);
popoverSelection
// This attribute lets the popover take focus
.attr('tabindex', 0)
.on('blur.popover', function() {
anchor.each(function() {
+1 -2
View File
@@ -242,8 +242,7 @@ export function uiPresetIcon() {
const isMaki = picon && /^maki-/.test(picon);
const isTemaki = picon && /^temaki-/.test(picon);
const isFa = picon && /^fa[srb]-/.test(picon);
const isTnp = picon && /^tnp-/.test(picon);
const isiDIcon = picon && !(isMaki || isTemaki || isFa || isTnp);
const isiDIcon = picon && !(isMaki || isTemaki || isFa);
const isCategory = !p.setTags;
const drawPoint = picon && geom === 'point' && isSmall() && !isFallback;
const drawVertex = picon !== null && geom === 'vertex' && (!isSmall() || !isFallback);
+25 -14
View File
@@ -38,7 +38,7 @@ export function uiPresetList(context) {
var message = messagewrap
.append('h3')
.text(t('inspector.choose'));
.html(t.html('inspector.choose'));
messagewrap
.append('button')
@@ -85,7 +85,8 @@ export function uiPresetList(context) {
function keypress() {
// enter
var value = search.property('value');
if (d3_event.keyCode === 13 && value.length) {
if (d3_event.keyCode === 13 && // ↩ Return
value.length) {
list.selectAll('.preset-list-item:first-child')
.each(function(d) { d.choose.call(this); });
}
@@ -110,13 +111,16 @@ export function uiPresetList(context) {
messageText = t('inspector.choose');
}
list.call(drawList, results);
message.text(messageText);
message.html(messageText);
}
var searchWrap = selection
.append('div')
.attr('class', 'search-header');
searchWrap
.call(svgIcon('#iD-icon-search', 'pre-text'));
var search = searchWrap
.append('input')
.attr('class', 'preset-search-input')
@@ -127,11 +131,14 @@ export function uiPresetList(context) {
.on('keypress', keypress)
.on('input', inputevent);
searchWrap
.call(svgIcon('#iD-icon-search', 'pre-text'));
if (_autofocus) {
search.node().focus();
// Safari 14 doesn't always like to focus immediately,
// so try again on the next pass
setTimeout(function() {
search.node().focus();
}, 0);
}
var listWrap = selection
@@ -323,7 +330,7 @@ export function uiPresetList(context) {
.attr('class', 'namepart')
.call(svgIcon((localizer.textDirection() === 'rtl' ? '#iD-icon-backward' : '#iD-icon-forward'), 'inline'))
.append('span')
.html(function() { return preset.name() + '&hellip;'; });
.html(function() { return preset.nameLabel() + '&hellip;'; });
box = selection.append('div')
.attr('class', 'subgrid')
@@ -386,13 +393,17 @@ export function uiPresetList(context) {
.append('div')
.attr('class', 'label-inner');
// NOTE: split/join on en-dash, not a hypen (to avoid conflict with fr - nl names in Brussels etc)
var nameparts = [
preset.nameLabel(),
preset.subtitleLabel()
].filter(Boolean);
label.selectAll('.namepart')
.data(preset.name().split(' '))
.data(nameparts)
.enter()
.append('div')
.attr('class', 'namepart')
.text(function(d) { return d; });
.html(function(d) { return d; });
wrap.call(item.reference.button);
selection.call(item.reference.body);
@@ -425,7 +436,7 @@ export function uiPresetList(context) {
};
item.preset = preset;
item.reference = uiTagReference(preset.reference(entityGeometries()[0]), context);
item.reference = uiTagReference(preset.reference(), context);
return item;
}
@@ -455,10 +466,10 @@ export function uiPresetList(context) {
if (isHiddenPreset) {
var isAutoHidden = context.features().autoHidden(hiddenPresetFeaturesId);
var tooltipIdSuffix = isAutoHidden ? 'zoom' : 'manual';
var tooltipObj = { features: t('feature.' + hiddenPresetFeaturesId + '.description') };
d3_select(this).call(uiTooltip()
.title(t('inspector.hidden_preset.' + tooltipIdSuffix, tooltipObj))
.title(t.html('inspector.hidden_preset.' + (isAutoHidden ? 'zoom' : 'manual'), {
features: t.html('feature.' + hiddenPresetFeaturesId + '.description')
}))
.placement(index < 2 ? 'bottom' : 'top')
);
}
+4 -4
View File
@@ -17,13 +17,13 @@ export function uiRestore(context) {
.append('div')
.attr('class', 'modal-section')
.append('h3')
.text(t('restore.heading'));
.html(t.html('restore.heading'));
introModal
.append('div')
.attr('class','modal-section')
.append('p')
.text(t('restore.description'));
.html(t.html('restore.description'));
let buttonWrap = introModal
.append('div')
@@ -45,7 +45,7 @@ export function uiRestore(context) {
restore
.append('div')
.text(t('restore.restore'));
.html(t.html('restore.restore'));
let reset = buttonWrap
.append('button')
@@ -63,7 +63,7 @@ export function uiRestore(context) {
reset
.append('div')
.text(t('restore.reset'));
.html(t.html('restore.reset'));
restore.node().focus();
};
+4 -8
View File
@@ -53,11 +53,9 @@ export function uiScale(context) {
selection.select('.scale-path')
.attr('d', 'M0.5,0.5v' + tickHeight + 'h' + scale.px + 'v-' + tickHeight);
selection.select('.scale-textgroup')
.attr('transform', 'translate(' + (scale.px + 8) + ',' + tickHeight + ')');
selection.select('.scale-text')
.text(scale.text);
.style(localizer.textDirection() === 'ltr' ? 'left' : 'right', (scale.px + 16) + 'px')
.html(scale.text);
}
@@ -77,10 +75,8 @@ export function uiScale(context) {
.append('path')
.attr('class', 'scale-path');
scalegroup
.append('g')
.attr('class', 'scale-textgroup')
.append('text')
selection
.append('div')
.attr('class', 'scale-text');
selection.call(update);
+5 -5
View File
@@ -14,7 +14,7 @@ export function uiSection(id, context) {
var _content;
var _disclosure;
var _title;
var _label;
var _expandedByDefault = utilFunctor(true);
var _disclosureContent;
var _disclosureExpanded;
@@ -31,9 +31,9 @@ export function uiSection(id, context) {
return section;
};
section.title = function(val) {
if (!arguments.length) return _title;
_title = utilFunctor(val);
section.label = function(val) {
if (!arguments.length) return _label;
_label = utilFunctor(val);
return section;
};
@@ -113,7 +113,7 @@ export function uiSection(id, context) {
if (_disclosureContent) {
if (!_disclosure) {
_disclosure = uiDisclosure(context, id.replace(/-/g, '_'), _expandedByDefault())
.title(_title || '')
.label(_label || '')
/*.on('toggled', function(expanded) {
if (expanded) { selection.node().parentNode.scrollTop += 200; }
})*/
@@ -13,13 +13,13 @@ import { utilDetect } from '../../util/detect';
export function uiSectionBackgroundDisplayOptions(context) {
var section = uiSection('background-display-options', context)
.title(t('background.display_options'))
.label(t.html('background.display_options'))
.disclosureContent(renderDisclosureContent);
var _detected = utilDetect();
var _storedOpacity = prefs('background-opacity');
var _minVal = 0.25;
var _maxVal = _detected.cssfilters ? 2 : 1;
var _minVal = 0;
var _maxVal = _detected.cssfilters ? 3 : 1;
var _sliders = _detected.cssfilters
? ['brightness', 'contrast', 'saturation', 'sharpness']
@@ -70,11 +70,15 @@ export function uiSectionBackgroundDisplayOptions(context) {
slidersEnter
.append('h5')
.text(function(d) { return t('background.' + d); })
.html(function(d) { return t.html('background.' + d); })
.append('span')
.attr('class', function(d) { return 'display-option-value display-option-value-' + d; });
slidersEnter
var sildersControlEnter = slidersEnter
.append('div')
.attr('class', 'control-wrap');
sildersControlEnter
.append('input')
.attr('class', function(d) { return 'display-option-input display-option-input-' + d; })
.attr('type', 'range')
@@ -86,7 +90,7 @@ export function uiSectionBackgroundDisplayOptions(context) {
updateValue(d, val);
});
slidersEnter
sildersControlEnter
.append('button')
.attr('title', t('background.reset'))
.attr('class', function(d) { return 'display-option-reset display-option-reset-' + d; })
@@ -101,7 +105,7 @@ export function uiSectionBackgroundDisplayOptions(context) {
.append('a')
.attr('class', 'display-option-resetlink')
.attr('href', '#')
.text(t('background.reset_all'))
.html(t.html('background.reset_all'))
.on('click', function() {
for (var i = 0; i < _sliders.length; i++) {
updateValue(_sliders[i],1);
@@ -116,7 +120,7 @@ export function uiSectionBackgroundDisplayOptions(context) {
.property('value', function(d) { return _options[d]; });
container.selectAll('.display-option-value')
.text(function(d) { return Math.floor(_options[d] * 100) + '%'; });
.html(function(d) { return Math.floor(_options[d] * 100) + '%'; });
container.selectAll('.display-option-reset')
.classed('disabled', function(d) { return _options[d] === 1; });
+27 -29
View File
@@ -24,7 +24,7 @@ export function uiSectionBackgroundList(context) {
.on('change', customChanged);
var section = uiSection('background-list', context)
.title(t('background.backgrounds'))
.label(t.html('background.backgrounds'))
.disclosureContent(renderDisclosureContent);
function previousBackgroundID() {
@@ -56,7 +56,7 @@ export function uiSectionBackgroundList(context) {
.attr('class', 'minimap-toggle-item')
.append('label')
.call(uiTooltip()
.title(t('background.minimap.tooltip'))
.title(t.html('background.minimap.tooltip'))
.keys([t('background.minimap.key')])
.placement('top')
);
@@ -71,7 +71,7 @@ export function uiSectionBackgroundList(context) {
minimapLabelEnter
.append('span')
.text(t('background.minimap.description'));
.html(t.html('background.minimap.description'));
var panelLabelEnter = bgExtrasListEnter
@@ -79,7 +79,7 @@ export function uiSectionBackgroundList(context) {
.attr('class', 'background-panel-toggle-item')
.append('label')
.call(uiTooltip()
.title(t('background.panel.tooltip'))
.title(t.html('background.panel.tooltip'))
.keys([uiCmd('⌘⇧' + t('info_panels.background.key'))])
.placement('top')
);
@@ -94,14 +94,14 @@ export function uiSectionBackgroundList(context) {
panelLabelEnter
.append('span')
.text(t('background.panel.description'));
.html(t.html('background.panel.description'));
var locPanelLabelEnter = bgExtrasListEnter
.append('li')
.attr('class', 'location-panel-toggle-item')
.append('label')
.call(uiTooltip()
.title(t('background.location_panel.tooltip'))
.title(t.html('background.location_panel.tooltip'))
.keys([uiCmd('⌘⇧' + t('info_panels.location.key'))])
.placement('top')
);
@@ -116,7 +116,7 @@ export function uiSectionBackgroundList(context) {
locPanelLabelEnter
.append('span')
.text(t('background.location_panel.description'));
.html(t.html('background.location_panel.description'));
// "Info / Report a Problem" link
@@ -130,7 +130,7 @@ export function uiSectionBackgroundList(context) {
.call(svgIcon('#iD-icon-out-link', 'inline'))
.attr('href', 'https://github.com/openstreetmap/iD/blob/develop/FAQ.md#how-can-i-report-an-issue-with-background-imagery')
.append('span')
.text(t('background.imagery_problem_faq'));
.html(t.html('background.imagery_problem_faq'));
_backgroundList
.call(drawListItems, 'radio', chooseBackground, function(d) { return !d.isHidden() && !d.overlay; });
@@ -149,13 +149,13 @@ export function uiSectionBackgroundList(context) {
if (d.id === previousBackgroundID()) {
item.call(uiTooltip()
.placement(placement)
.title('<div>' + t('background.switch') + '</div>')
.title('<div>' + t.html('background.switch') + '</div>')
.keys([uiCmd('⌘' + t('background.key'))])
);
} else if (description || isOverflowing) {
item.call(uiTooltip()
.placement(placement)
.title(description || d.name())
.title(description || d.label())
);
}
});
@@ -164,10 +164,18 @@ export function uiSectionBackgroundList(context) {
function drawListItems(layerList, type, change, filter) {
var sources = context.background()
.sources(context.map().extent(), context.map().zoom(), true)
.filter(filter);
.filter(filter)
.sort(function(a, b) {
return a.best() && !b.best() ? -1
: b.best() && !a.best() ? 1
: d3_descending(a.area(), b.area()) || d3_ascending(a.name(), b.name()) || 0;
});
var layerLinks = layerList.selectAll('li')
.data(sources, function(d) { return d.name(); });
// We have to be a bit inefficient about reordering the list since
// arrow key navigation of radio values likes to work in the order
// they were added, not the display document order.
.data(sources, function(d, i) { return d.id + '---' + i; });
layerLinks.exit()
.remove();
@@ -183,18 +191,21 @@ export function uiSectionBackgroundList(context) {
label
.append('input')
.attr('type', type)
.attr('name', 'layers')
.attr('name', 'background-layer')
.attr('value', function(d) {
return d.id;
})
.on('change', change);
label
.append('span')
.text(function(d) { return d.name(); });
.html(function(d) { return d.label(); });
enter.filter(function(d) { return d.id === 'custom'; })
.append('button')
.attr('class', 'layer-browse')
.call(uiTooltip()
.title(t('settings.custom_background.tooltip'))
.title(t.html('settings.custom_background.tooltip'))
.placement((localizer.textDirection() === 'rtl') ? 'right' : 'left')
)
.on('click', editCustom)
@@ -204,25 +215,14 @@ export function uiSectionBackgroundList(context) {
.append('div')
.attr('class', 'best')
.call(uiTooltip()
.title(t('background.best_imagery'))
.title(t.html('background.best_imagery'))
.placement((localizer.textDirection() === 'rtl') ? 'right' : 'left')
)
.append('span')
.html('&#9733;');
layerList.selectAll('li')
.sort(sortSources);
layerList
.call(updateLayerSelections);
function sortSources(a, b) {
return a.best() && !b.best() ? -1
: b.best() && !a.best() ? 1
: d3_descending(a.area(), b.area()) || d3_ascending(a.name(), b.name()) || 0;
}
}
function updateLayerSelections(selection) {
@@ -244,12 +244,10 @@ export function uiSectionBackgroundList(context) {
return editCustom();
}
d3_event.preventDefault();
var previousBackground = context.background().baseLayerSource();
prefs('background-last-used-toggle', previousBackground.id);
prefs('background-last-used', d.id);
context.background().baseLayerSource(d);
document.activeElement.blur();
}
+4 -3
View File
@@ -12,7 +12,7 @@ import { uiSection } from '../section';
export function uiSectionBackgroundOffset(context) {
var section = uiSection('background-offset', context)
.title(t('background.fix_misalignment'))
.label(t.html('background.fix_misalignment'))
.disclosureContent(renderDisclosureContent)
.expandedByDefault(false);
@@ -161,7 +161,7 @@ export function uiSectionBackgroundOffset(context) {
containerEnter
.append('div')
.attr('class', 'nudge-instructions')
.text(t('background.offset'));
.html(t.html('background.offset'));
var nudgeEnter = containerEnter
.append('div')
@@ -172,9 +172,10 @@ export function uiSectionBackgroundOffset(context) {
.append('div')
.attr('class', 'nudge-inner-rect')
.append('input')
.attr('type', 'text')
.on('change', inputOffset);
containerEnter
nudgeEnter
.append('div')
.selectAll('button')
.data(_directions).enter()
+16 -20
View File
@@ -26,10 +26,10 @@ export function uiSectionChanges(context) {
.catch(function() { /* ignore */ });
var section = uiSection('changes-list', context)
.title(function() {
.label(function() {
var history = context.history();
var summary = history.difference().summary();
return t('commit.changes', { count: summary.length });
return t('inspector.title_count', { title: t.html('commit.changes'), count: summary.length });
})
.disclosureContent(renderDisclosureContent);
@@ -59,29 +59,35 @@ export function uiSectionChanges(context) {
.append('li')
.attr('class', 'change-item');
itemsEnter
var buttons = itemsEnter
.append('button')
.on('mouseover', mouseover)
.on('mouseout', mouseout)
.on('click', click);
buttons
.each(function(d) {
d3_select(this)
.call(svgIcon('#iD-icon-' + d.entity.geometry(d.graph), 'pre-text ' + d.changeType));
});
itemsEnter
buttons
.append('span')
.attr('class', 'change-type')
.text(function(d) { return t('commit.' + d.changeType) + ' '; });
.html(function(d) { return t.html('commit.' + d.changeType) + ' '; });
itemsEnter
buttons
.append('strong')
.attr('class', 'entity-type')
.text(function(d) {
.html(function(d) {
var matched = presetManager.match(d.entity, d.graph);
return (matched && matched.name()) || utilDisplayType(d.entity.id);
});
itemsEnter
buttons
.append('span')
.attr('class', 'entity-name')
.text(function(d) {
.html(function(d) {
var name = utilDisplayName(d.entity) || '',
string = '';
if (name !== '') {
@@ -90,19 +96,9 @@ export function uiSectionChanges(context) {
return string += ' ' + name;
});
itemsEnter
.style('opacity', 0)
.transition()
.style('opacity', 1);
items = itemsEnter
.merge(items);
items
.on('mouseover', mouseover)
.on('mouseout', mouseout)
.on('click', click);
// Download changeset link
var changeset = new osmChangeset().update({ id: undefined });
@@ -136,7 +132,7 @@ export function uiSectionChanges(context) {
linkEnter
.call(svgIcon('#iD-icon-load', 'inline'))
.append('span')
.text(t('commit.download_changes'));
.html(t.html('commit.download_changes'));
function mouseover(d) {
+25 -19
View File
@@ -22,7 +22,7 @@ export function uiSectionDataLayers(context) {
var layers = context.layers();
var section = uiSection('data-layers', context)
.title(t('map_data.data_layers'))
.label(t.html('map_data.data_layers'))
.disclosureContent(renderDisclosureContent);
function renderDisclosureContent(selection) {
@@ -96,14 +96,14 @@ export function uiSectionDataLayers(context) {
if (d.id === 'osm') {
d3_select(this)
.call(uiTooltip()
.title(t('map_data.layers.' + d.id + '.tooltip'))
.title(t.html('map_data.layers.' + d.id + '.tooltip'))
.keys([uiCmd('⌥' + t('area_fill.wireframe.key'))])
.placement('bottom')
);
} else {
d3_select(this)
.call(uiTooltip()
.title(t('map_data.layers.' + d.id + '.tooltip'))
.title(t.html('map_data.layers.' + d.id + '.tooltip'))
.placement('bottom')
);
}
@@ -116,7 +116,7 @@ export function uiSectionDataLayers(context) {
labelEnter
.append('span')
.text(function(d) { return t('map_data.layers.' + d.id + '.title'); });
.html(function(d) { return t.html('map_data.layers.' + d.id + '.title'); });
// Update
@@ -155,7 +155,7 @@ export function uiSectionDataLayers(context) {
.each(function(d) {
d3_select(this)
.call(uiTooltip()
.title(t('map_data.layers.' + d.id + '.tooltip'))
.title(t.html('map_data.layers.' + d.id + '.tooltip'))
.placement('bottom')
);
});
@@ -167,7 +167,7 @@ export function uiSectionDataLayers(context) {
labelEnter
.append('span')
.text(function(d) { return t('map_data.layers.' + d.id + '.title'); });
.html(function(d) { return t.html('map_data.layers.' + d.id + '.title'); });
// Update
@@ -218,7 +218,7 @@ export function uiSectionDataLayers(context) {
containerEnter
.append('h4')
.attr('class', 'vectortile-header')
.text('Detroit Vector Tiles (Beta)');
.html('Detroit Vector Tiles (Beta)');
containerEnter
.append('ul')
@@ -229,11 +229,10 @@ export function uiSectionDataLayers(context) {
.attr('class', 'vectortile-footer')
.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.call(svgIcon('#iD-icon-out-link', 'inline'))
.attr('href', 'https://github.com/osmus/detroit-mapping-challenge')
.append('span')
.text('About these layers');
.html('About these layers');
container = container
.merge(containerEnter);
@@ -267,7 +266,7 @@ export function uiSectionDataLayers(context) {
labelEnter
.append('span')
.text(function(d) { return d.name; });
.html(function(d) { return d.name; });
// Update
li
@@ -315,7 +314,7 @@ export function uiSectionDataLayers(context) {
var labelEnter = liEnter
.append('label')
.call(uiTooltip()
.title(t('map_data.layers.custom.tooltip'))
.title(t.html('map_data.layers.custom.tooltip'))
.placement('top')
);
@@ -326,12 +325,13 @@ export function uiSectionDataLayers(context) {
labelEnter
.append('span')
.text(t('map_data.layers.custom.title'));
.html(t.html('map_data.layers.custom.title'));
liEnter
.append('button')
.attr('class', 'open-data-options')
.call(uiTooltip()
.title(t('settings.custom_data.tooltip'))
.title(t.html('settings.custom_data.tooltip'))
.placement((localizer.textDirection() === 'rtl') ? 'right' : 'left')
)
.on('click', editCustom)
@@ -339,16 +339,19 @@ export function uiSectionDataLayers(context) {
liEnter
.append('button')
.attr('class', 'zoom-to-data')
.call(uiTooltip()
.title(t('map_data.layers.custom.zoom'))
.title(t.html('map_data.layers.custom.zoom'))
.placement((localizer.textDirection() === 'rtl') ? 'right' : 'left')
)
.on('click', function() {
if (d3_select(this).classed('disabled')) return;
d3_event.preventDefault();
d3_event.stopPropagation();
dataLayer.fitZoom();
})
.call(svgIcon('#iD-icon-framed-dot'));
.call(svgIcon('#iD-icon-framed-dot', 'monochrome'));
// Update
ul = ul
@@ -361,6 +364,9 @@ export function uiSectionDataLayers(context) {
.selectAll('input')
.property('disabled', !hasData)
.property('checked', showsData);
ul.selectAll('button.zoom-to-data')
.classed('disabled', !hasData);
}
function editCustom() {
@@ -393,7 +399,7 @@ export function uiSectionDataLayers(context) {
.attr('class', 'history-panel-toggle-item')
.append('label')
.call(uiTooltip()
.title(t('map_data.history_panel.tooltip'))
.title(t.html('map_data.history_panel.tooltip'))
.keys([uiCmd('⌘⇧' + t('info_panels.history.key'))])
.placement('top')
);
@@ -408,14 +414,14 @@ export function uiSectionDataLayers(context) {
historyPanelLabelEnter
.append('span')
.text(t('map_data.history_panel.title'));
.html(t.html('map_data.history_panel.title'));
var measurementPanelLabelEnter = panelsListEnter
.append('li')
.attr('class', 'measurement-panel-toggle-item')
.append('label')
.call(uiTooltip()
.title(t('map_data.measurement_panel.tooltip'))
.title(t.html('map_data.measurement_panel.tooltip'))
.keys([uiCmd('⌘⇧' + t('info_panels.measurement.key'))])
.placement('top')
);
@@ -430,7 +436,7 @@ export function uiSectionDataLayers(context) {
measurementPanelLabelEnter
.append('span')
.text(t('map_data.measurement_panel.title'));
.html(t.html('map_data.measurement_panel.title'));
}
context.layers().on('change.uiSectionDataLayers', section.reRender);
+23 -21
View File
@@ -16,8 +16,8 @@ export function uiSectionEntityIssues(context) {
.shouldDisplay(function() {
return _issues.length > 0;
})
.title(function() {
return t('issues.list_title', { count: _issues.length });
.label(function() {
return t('inspector.title_count', { title: t.html('issues.list_title'), count: _issues.length });
})
.disclosureContent(renderDisclosureContent);
@@ -79,7 +79,11 @@ export function uiSectionEntityIssues(context) {
var labelsEnter = itemsEnter
.append('div')
.attr('class', 'issue-label')
.attr('class', 'issue-label');
var textEnter = labelsEnter
.append('button')
.attr('class', 'issue-text')
.on('click', function(d) {
makeActiveIssue(d.id); // expand only the clicked item
@@ -91,17 +95,11 @@ export function uiSectionEntityIssues(context) {
}
});
var textEnter = labelsEnter
.append('span')
.attr('class', 'issue-text');
textEnter
.append('span')
.attr('class', 'issue-icon')
.each(function(d) {
var iconName = '#iD-icon-' + (d.severity === 'warning' ? 'alert' : 'error');
d3_select(this)
.call(svgIcon(iconName));
.call(svgIcon(iconName, 'issue-icon'));
});
textEnter
@@ -113,7 +111,6 @@ export function uiSectionEntityIssues(context) {
.append('button')
.attr('class', 'issue-info-button')
.attr('title', t('icons.information'))
.attr('tabindex', -1)
.call(svgIcon('#iD-icon-inspect'));
infoButton
@@ -163,7 +160,7 @@ export function uiSectionEntityIssues(context) {
.call(d.reference);
} else {
d3_select(this)
.text(t('inspector.no_documentation_key'));
.html(t.html('inspector.no_documentation_key'));
}
});
@@ -174,7 +171,7 @@ export function uiSectionEntityIssues(context) {
.classed('active', function(d) { return d.id === _activeIssueID; });
containers.selectAll('.issue-message')
.text(function(d) {
.html(function(d) {
return d.message(context);
});
@@ -189,10 +186,13 @@ export function uiSectionEntityIssues(context) {
var fixesEnter = fixes.enter()
.append('li')
.attr('class', 'issue-fix-item')
.attr('class', 'issue-fix-item');
var buttons = fixesEnter
.append('button')
.on('click', function(d) {
// not all fixes are actionable
if (!d3_select(this).classed('actionable') || !d.onClick) return;
if (d3_select(this).attr('disabled') || !d.onClick) return;
// Don't run another fix for this issue within a second of running one
// (Necessary for "Select a feature type" fix. Most fixes should only ever run once)
@@ -221,26 +221,28 @@ export function uiSectionEntityIssues(context) {
utilHighlightEntities(d.entityIds, false, context);
});
fixesEnter
.append('span')
.attr('class', 'fix-icon')
buttons
.each(function(d) {
var iconName = d.icon || 'iD-icon-wrench';
if (iconName.startsWith('maki')) {
iconName += '-15';
}
d3_select(this).call(svgIcon('#' + iconName));
d3_select(this).call(svgIcon('#' + iconName, 'fix-icon'));
});
fixesEnter
buttons
.append('span')
.attr('class', 'fix-message')
.text(function(d) { return d.title; });
.html(function(d) { return d.title; });
fixesEnter.merge(fixes)
.selectAll('button')
.classed('actionable', function(d) {
return d.onClick;
})
.attr('disabled', function(d) {
return d.onClick ? null : 'true';
})
.attr('title', function(d) {
if (d.disabledReason) {
return d.disabledReason;
+9 -8
View File
@@ -23,7 +23,7 @@ export function uiSectionFeatureType(context) {
var _tagReference;
var section = uiSection('feature-type', context)
.title(t('inspector.feature_type'))
.label(t.html('inspector.feature_type'))
.disclosureContent(renderDisclosureContent);
function renderDisclosureContent(selection) {
@@ -42,7 +42,7 @@ export function uiSectionFeatureType(context) {
.append('button')
.attr('class', 'preset-list-button preset-reset')
.call(uiTooltip()
.title(t('inspector.back_tooltip'))
.title(t.html('inspector.back_tooltip'))
.placement('bottom')
);
@@ -95,8 +95,10 @@ export function uiSectionFeatureType(context) {
.preset(_presets.length === 1 ? _presets[0] : presetManager.item('point'))
);
// NOTE: split on en-dash, not a hypen (to avoid conflict with hyphenated names)
var names = _presets.length === 1 ? _presets[0].name().split(' ') : [t('inspector.multiple_types')];
var names = _presets.length === 1 ? [
_presets[0].nameLabel(),
_presets[0].subtitleLabel()
].filter(Boolean) : [t('inspector.multiple_types')];
var label = selection.select('.label-inner');
var nameparts = label.selectAll('.namepart')
@@ -109,7 +111,7 @@ export function uiSectionFeatureType(context) {
.enter()
.append('div')
.attr('class', 'namepart')
.text(function(d) { return d; });
.html(function(d) { return d; });
}
section.entityIDs = function(val) {
@@ -125,9 +127,8 @@ export function uiSectionFeatureType(context) {
if (!utilArrayIdentical(val, _presets)) {
_presets = val;
var geometries = entityGeometries();
if (_presets.length === 1 && geometries.length) {
_tagReference = uiTagReference(_presets[0].reference(geometries[0]), context)
if (_presets.length === 1) {
_tagReference = uiTagReference(_presets[0].reference(), context)
.showing(false);
}
}
+8 -8
View File
@@ -7,7 +7,7 @@ export function uiSectionMapFeatures(context) {
var _features = context.features().keys();
var section = uiSection('map-features', context)
.title(t('map_data.map_features'))
.label(t.html('map_data.map_features'))
.disclosureContent(renderDisclosureContent)
.expandedByDefault(false);
@@ -32,18 +32,18 @@ export function uiSectionMapFeatures(context) {
.append('a')
.attr('class', 'feature-list-link')
.attr('href', '#')
.text(t('issues.enable_all'))
.html(t.html('issues.disable_all'))
.on('click', function() {
context.features().enableAll();
context.features().disableAll();
});
footer
.append('a')
.attr('class', 'feature-list-link')
.attr('href', '#')
.text(t('issues.disable_all'))
.html(t.html('issues.enable_all'))
.on('click', function() {
context.features().disableAll();
context.features().enableAll();
});
// Update
@@ -67,9 +67,9 @@ export function uiSectionMapFeatures(context) {
.append('li')
.call(uiTooltip()
.title(function(d) {
var tip = t(name + '.' + d + '.tooltip');
var tip = t.html(name + '.' + d + '.tooltip');
if (autoHiddenFeature(d)) {
var msg = showsLayer('osm') ? t('map_data.autohidden') : t('map_data.osmhidden');
var msg = showsLayer('osm') ? t.html('map_data.autohidden') : t.html('map_data.osmhidden');
tip += '<div>' + msg + '</div>';
}
return tip;
@@ -88,7 +88,7 @@ export function uiSectionMapFeatures(context) {
label
.append('span')
.text(function(d) { return t(name + '.' + d + '.description'); });
.html(function(d) { return t.html(name + '.' + d + '.description'); });
// Update
items = items
+3 -3
View File
@@ -9,7 +9,7 @@ import { uiSection } from '../section';
export function uiSectionMapStyleOptions(context) {
var section = uiSection('fill-area', context)
.title(t('map_data.style_options'))
.label(t.html('map_data.style_options'))
.disclosureContent(renderDisclosureContent)
.expandedByDefault(false);
@@ -48,7 +48,7 @@ export function uiSectionMapStyleOptions(context) {
.append('li')
.call(uiTooltip()
.title(function(d) {
return t(name + '.' + d + '.tooltip');
return t.html(name + '.' + d + '.tooltip');
})
.keys(function(d) {
var key = (d === 'wireframe' ? t('area_fill.wireframe.key') : null);
@@ -69,7 +69,7 @@ export function uiSectionMapStyleOptions(context) {
label
.append('span')
.text(function(d) { return t(name + '.' + d + '.description'); });
.html(function(d) { return t.html(name + '.' + d + '.description'); });
// Update
items = items
+2 -2
View File
@@ -12,7 +12,7 @@ import { uiSection } from '../section';
export function uiSectionOverlayList(context) {
var section = uiSection('overlay-list', context)
.title(t('background.overlays'))
.label(t.html('background.overlays'))
.disclosureContent(renderDisclosureContent);
var _overlayList = d3_select(null);
@@ -81,7 +81,7 @@ export function uiSectionOverlayList(context) {
label
.append('span')
.text(function(d) { return d.name(); });
.html(function(d) { return d.label(); });
layerList.selectAll('li')
+6 -6
View File
@@ -11,7 +11,7 @@ export function uiSectionPhotoOverlays(context) {
var layers = context.layers();
var section = uiSection('photo-overlays', context)
.title(t('photo_overlays.title'))
.label(t.html('photo_overlays.title'))
.disclosureContent(renderDisclosureContent)
.expandedByDefault(false);
@@ -76,7 +76,7 @@ export function uiSectionPhotoOverlays(context) {
else titleID = d.id.replace(/-/g, '_') + '.tooltip';
d3_select(this)
.call(uiTooltip()
.title(t(titleID))
.title(t.html(titleID))
.placement('top')
);
});
@@ -88,10 +88,10 @@ export function uiSectionPhotoOverlays(context) {
labelEnter
.append('span')
.text(function(d) {
.html(function(d) {
var id = d.id;
if (id === 'mapillary-signs') id = 'photo_overlays.traffic_signs';
return t(id.replace(/-/g, '_') + '.title');
return t.html(id.replace(/-/g, '_') + '.title');
});
// Update
@@ -138,7 +138,7 @@ export function uiSectionPhotoOverlays(context) {
.each(function(d) {
d3_select(this)
.call(uiTooltip()
.title(t('photo_overlays.photo_type.' + d + '.tooltip'))
.title(t.html('photo_overlays.photo_type.' + d + '.tooltip'))
.placement('top')
);
});
@@ -152,7 +152,7 @@ export function uiSectionPhotoOverlays(context) {
labelEnter
.append('span')
.text(function(d) {
.html(function(d) {
return t('photo_overlays.photo_type.' + d + '.title');
});
+6 -5
View File
@@ -15,9 +15,7 @@ import { uiSection } from '../section';
export function uiSectionPresetFields(context) {
var section = uiSection('preset-fields', context)
.title(function() {
return t('inspector.fields');
})
.label(t.html('inspector.fields'))
.disclosureContent(renderDisclosureContent);
var dispatch = d3_dispatch('change', 'revert');
@@ -34,7 +32,8 @@ export function uiSectionPresetFields(context) {
var graph = context.graph();
var geometries = Object.keys(_entityIDs.reduce(function(geoms, entityID) {
return geoms[graph.entity(entityID).geometry(graph)] = true;
geoms[graph.entity(entityID).geometry(graph)] = true;
return geoms;
}, {}));
var presetsManager = presetManager;
@@ -126,7 +125,9 @@ export function uiSectionPresetFields(context) {
selection.selectAll('.wrap-form-field input')
.on('keydown', function() {
// if user presses enter, and combobox is not active, accept edits..
if (d3_event.keyCode === 13 && context.container().select('.combobox').empty()) {
if (d3_event.keyCode === 13 && // ↩ Return
context.container().select('.combobox').empty()) {
context.enter(modeBrowse(context));
}
});
+4 -4
View File
@@ -11,7 +11,7 @@ import { uiSection } from '../section';
export function uiSectionPrivacy(context) {
let section = uiSection('preferences-third-party', context)
.title(t('preferences.privacy.title'))
.label(t.html('preferences.privacy.title'))
.disclosureContent(renderDisclosureContent);
let _showThirdPartyIcons = prefs('preferences.privacy.thirdpartyicons') || 'true';
@@ -29,7 +29,7 @@ export function uiSectionPrivacy(context) {
.attr('class', 'privacy-third-party-icons-item')
.append('label')
.call(uiTooltip()
.title(t('preferences.privacy.third_party_icons.tooltip'))
.title(t.html('preferences.privacy.third_party_icons.tooltip'))
.placement('bottom')
);
@@ -45,7 +45,7 @@ export function uiSectionPrivacy(context) {
thirdPartyIconsEnter
.append('span')
.text(t('preferences.privacy.third_party_icons.description'));
.html(t.html('preferences.privacy.third_party_icons.description'));
// Privacy Policy link
@@ -59,7 +59,7 @@ export function uiSectionPrivacy(context) {
.call(svgIcon('#iD-icon-out-link', 'inline'))
.attr('href', 'https://github.com/openstreetmap/iD/blob/release/PRIVACY.md')
.append('span')
.text(t('preferences.privacy.privacy_link'));
.html(t.html('preferences.privacy.privacy_link'));
update();
+14 -8
View File
@@ -28,13 +28,13 @@ export function uiSectionRawMemberEditor(context) {
var entity = context.hasEntity(_entityIDs[0]);
return entity && entity.type === 'relation';
})
.title(function() {
.label(function() {
var entity = context.hasEntity(_entityIDs[0]);
if (!entity) return '';
var gt = entity.members.length > _maxMembers ? '>' : '';
var count = gt + entity.members.slice(0, _maxMembers).length;
return t('inspector.title_count', { title: t('inspector.members'), count: count });
return t('inspector.title_count', { title: t.html('inspector.members'), count: count });
})
.disclosureContent(renderDisclosureContent);
@@ -90,6 +90,7 @@ export function uiSectionRawMemberEditor(context) {
actionChangeMember(d.relation.id, member, d.index),
t('operations.change_role.annotation')
);
context.validator().validate();
}
}
@@ -105,7 +106,13 @@ export function uiSectionRawMemberEditor(context) {
);
if (!context.hasEntity(d.relation.id)) {
// Removing the last member will also delete the relation.
// If this happens we need to exit the selection mode
context.enter(modeBrowse(context));
} else {
// Changing the mode also runs `validate`, but otherwise we need to
// rerun it manually
context.validator().validate();
}
}
@@ -180,7 +187,7 @@ export function uiSectionRawMemberEditor(context) {
labelLink
.append('span')
.attr('class', 'member-entity-type')
.text(function(d) {
.html(function(d) {
var matched = presetManager.match(d.member, context.graph());
return (matched && matched.name()) || utilDisplayType(d.member.id);
});
@@ -188,11 +195,10 @@ export function uiSectionRawMemberEditor(context) {
labelLink
.append('span')
.attr('class', 'member-entity-name')
.text(function(d) { return utilDisplayName(d.member); });
.html(function(d) { return utilDisplayName(d.member); });
label
.append('button')
.attr('tabindex', -1)
.attr('title', t('icons.remove'))
.attr('class', 'remove member-delete')
.call(svgIcon('#iD-operation-delete'));
@@ -212,18 +218,17 @@ export function uiSectionRawMemberEditor(context) {
labelText
.append('span')
.attr('class', 'member-entity-type')
.text(t('inspector.' + d.type, { id: d.id }));
.html(t.html('inspector.' + d.type, { id: d.id }));
labelText
.append('span')
.attr('class', 'member-entity-name')
.text(t('inspector.incomplete', { id: d.id }));
.html(t.html('inspector.incomplete', { id: d.id }));
label
.append('button')
.attr('class', 'member-download')
.attr('title', t('icons.download'))
.attr('tabindex', -1)
.call(svgIcon('#iD-icon-load'))
.on('click', downloadMember);
}
@@ -320,6 +325,7 @@ export function uiSectionRawMemberEditor(context) {
actionMoveMember(d.relation.id, index, targetIndex),
t('operations.reorder_members.annotation')
);
context.validator().validate();
}
})
);
+16 -11
View File
@@ -27,14 +27,14 @@ export function uiSectionRawMembershipEditor(context) {
.shouldDisplay(function() {
return _entityIDs && _entityIDs.length === 1;
})
.title(function() {
.label(function() {
var entity = context.hasEntity(_entityIDs[0]);
if (!entity) return '';
var parents = context.graph().parentRelations(entity);
var gt = parents.length > _maxMemberships ? '>' : '';
var count = gt + parents.slice(0, _maxMemberships).length;
return t('inspector.title_count', { title: t('inspector.relations'), count: count });
return t('inspector.title_count', { title: t.html('inspector.relations'), count: count });
})
.disclosureContent(renderDisclosureContent);
@@ -74,7 +74,7 @@ export function uiSectionRawMembershipEditor(context) {
function changeRole(d) {
if (d === 0) return; // called on newrow (shoudn't happen)
if (d === 0) return; // called on newrow (shouldn't happen)
if (_inChange) return; // avoid accidental recursive call #5731
var oldRole = d.member.role;
@@ -86,6 +86,7 @@ export function uiSectionRawMembershipEditor(context) {
actionChangeMember(d.relation.id, Object.assign({}, d.member, { role: newRole }), d.index),
t('operations.change_role.annotation')
);
context.validator().validate();
}
_inChange = false;
}
@@ -102,6 +103,7 @@ export function uiSectionRawMembershipEditor(context) {
actionAddMember(d.relation.id, member),
t('operations.add_member.annotation')
);
context.validator().validate();
} else {
var relation = osmRelation();
@@ -110,7 +112,7 @@ export function uiSectionRawMembershipEditor(context) {
actionAddMember(relation.id, member),
t('operations.add.annotation.relation')
);
// changing the mode also runs `validate`
context.enter(modeSelect(context, [relation.id]).newFeature(true));
}
}
@@ -118,7 +120,7 @@ export function uiSectionRawMembershipEditor(context) {
function deleteMembership(d) {
this.blur(); // avoid keeping focus on the button
if (d === 0) return; // called on newrow (shoudn't happen)
if (d === 0) return; // called on newrow (shouldn't happen)
// remove the hover-highlight styling
utilHighlightEntities([d.relation.id], false, context);
@@ -127,11 +129,16 @@ export function uiSectionRawMembershipEditor(context) {
actionDeleteMember(d.relation.id, d.index),
t('operations.delete_member.annotation')
);
context.validator().validate();
}
function fetchNearbyRelations(q, callback) {
var newRelation = { relation: null, value: t('inspector.new_relation') };
var newRelation = {
relation: null,
value: t('inspector.new_relation'),
display: t.html('inspector.new_relation')
};
var entityID = _entityIDs[0];
@@ -259,7 +266,7 @@ export function uiSectionRawMembershipEditor(context) {
labelLink
.append('span')
.attr('class', 'member-entity-type')
.text(function(d) {
.html(function(d) {
var matched = presetManager.match(d.relation, context.graph());
return (matched && matched.name()) || t('inspector.relation');
});
@@ -267,11 +274,10 @@ export function uiSectionRawMembershipEditor(context) {
labelLink
.append('span')
.attr('class', 'member-entity-name')
.text(function(d) { return utilDisplayName(d.relation); });
.html(function(d) { return utilDisplayName(d.relation); });
labelEnter
.append('button')
.attr('tabindex', -1)
.attr('class', 'remove member-delete')
.call(svgIcon('#iD-operation-delete'))
.on('click', deleteMembership);
@@ -330,7 +336,6 @@ export function uiSectionRawMembershipEditor(context) {
newLabelEnter
.append('button')
.attr('tabindex', -1)
.attr('class', 'remove member-delete')
.call(svgIcon('#iD-operation-delete'))
.on('click', function() {
@@ -377,7 +382,7 @@ export function uiSectionRawMembershipEditor(context) {
addRelationButton
.call(svgIcon('#iD-icon-plus', 'light'));
addRelationButton
.call(uiTooltip().title(t('inspector.add_to_relation')).placement(localizer.textDirection() === 'ltr' ? 'right' : 'left'));
.call(uiTooltip().title(t.html('inspector.add_to_relation')).placement(localizer.textDirection() === 'ltr' ? 'right' : 'left'));
addRowEnter
.append('div')
+24 -21
View File
@@ -15,9 +15,9 @@ export function uiSectionRawTagEditor(id, context) {
var section = uiSection(id, context)
.classes('raw-tag-editor')
.title(function() {
.label(function() {
var count = Object.keys(_tags).filter(function(d) { return d; }).length;
return t('inspector.title_count', { title: t('inspector.tags'), count: count });
return t('inspector.title_count', { title: t.html('inspector.tags'), count: count });
})
.expandedByDefault(false)
.disclosureContent(renderDisclosureContent);
@@ -25,8 +25,8 @@ export function uiSectionRawTagEditor(id, context) {
var taginfo = services.taginfo;
var dispatch = d3_dispatch('change');
var availableViews = [
{ id: 'text', icon: '#fas-i-cursor' },
{ id: 'list', icon: '#fas-th-list' }
{ id: 'list', icon: '#fas-th-list' },
{ id: 'text', icon: '#fas-i-cursor' }
];
var _tagView = (prefs('raw-tag-editor-view') || 'list'); // 'list, 'text'
@@ -39,6 +39,11 @@ export function uiSectionRawTagEditor(id, context) {
var _presets;
var _tags;
var _entityIDs;
var _didInteract = false;
function interacted() {
_didInteract = true;
}
function renderDisclosureContent(wrap) {
@@ -127,6 +132,7 @@ export function uiSectionRawTagEditor(id, context) {
.call(utilGetSetValue, textData)
.each(setTextareaHeight)
.on('input', setTextareaHeight)
.on('focus', interacted)
.on('blur', textChanged)
.on('change', textChanged);
@@ -188,6 +194,7 @@ export function uiSectionRawTagEditor(id, context) {
.property('type', 'text')
.attr('class', 'key')
.call(utilNoAuto)
.on('focus', interacted)
.on('blur', keyChange)
.on('change', keyChange);
@@ -198,13 +205,13 @@ export function uiSectionRawTagEditor(id, context) {
.property('type', 'text')
.attr('class', 'value')
.call(utilNoAuto)
.on('focus', interacted)
.on('blur', valueChange)
.on('change', valueChange)
.on('keydown.push-more', pushMore);
innerWrap
.append('button')
.attr('tabindex', -1)
.attr('class', 'form-field-button remove')
.attr('title', t('icons.remove'))
.call(svgIcon('#iD-operation-delete'));
@@ -225,20 +232,11 @@ export function uiSectionRawTagEditor(id, context) {
bindTypeahead(key, value);
}
var reference;
if (typeof d.value !== 'string') {
reference = uiTagReference({ key: d.key }, context);
} else {
var isRelation = _entityIDs && _entityIDs.some(function(entityID) {
return context.entity(entityID).type === 'relation';
});
if (isRelation && d.key === 'type') {
reference = uiTagReference({ rtype: d.value }, context);
} else {
reference = uiTagReference({ key: d.key, value: d.value }, context);
}
var referenceOptions = { key: d.key };
if (typeof d.value === 'string') {
referenceOptions.value = d.value;
}
var reference = uiTagReference(referenceOptions, context);
if (_state === 'hover') {
reference.showing(false);
@@ -294,8 +292,11 @@ export function uiSectionRawTagEditor(id, context) {
if (_tagView !== 'text') return;
var selection = d3_select(this);
selection.style('height', null);
selection.style('height', selection.node().scrollHeight + 5 + 'px');
var matches = selection.node().value.match(/\n/g);
var lineCount = 2 + Number(matches && matches.length);
var lineHeight = 20;
selection.style('height', lineCount * lineHeight + 'px');
}
function stringify(s) {
@@ -582,7 +583,9 @@ export function uiSectionRawTagEditor(id, context) {
_presets = val;
if (_presets && _presets.length && _presets[0].isFallback()) {
section.disclosureExpanded(true);
} else {
// don't collapse the disclosure if the mapper used the raw tag editor - #1881
} else if (!_didInteract) {
section.disclosureExpanded(null);
}
return section;
+6 -6
View File
@@ -16,8 +16,8 @@ export function uiSectionSelectionList(context) {
.shouldDisplay(function() {
return _selectedIDs.length > 1;
})
.title(function() {
return t('inspector.title_count', { title: t('inspector.features'), count: _selectedIDs.length });
.label(function() {
return t('inspector.title_count', { title: t.html('inspector.features'), count: _selectedIDs.length });
})
.disclosureContent(renderDisclosureContent);
@@ -71,7 +71,7 @@ export function uiSectionSelectionList(context) {
// Enter
var enter = items.enter()
.append('div')
.append('button')
.attr('class', 'feature-list-item')
.on('click', selectEntity);
@@ -86,7 +86,7 @@ export function uiSectionSelectionList(context) {
});
var label = enter
.append('button')
.append('div')
.attr('class', 'label');
enter
@@ -119,10 +119,10 @@ export function uiSectionSelectionList(context) {
});
items.selectAll('.entity-type')
.text(function(entity) { return presetManager.match(entity, context.graph()).name(); });
.html(function(entity) { return presetManager.match(entity, context.graph()).name(); });
items.selectAll('.entity-name')
.text(function(d) {
.html(function(d) {
// fetch latest entity
var entity = context.entity(d.id);
return utilDisplayName(entity);
+4 -4
View File
@@ -16,10 +16,10 @@ export function uiSectionValidationIssues(id, severity, context) {
var _issues = [];
var section = uiSection(id, context)
.title(function() {
.label(function() {
if (!_issues) return '';
var issueCountText = _issues.length > 1000 ? '1000+' : String(_issues.length);
return t('issues.' + severity + 's.list_title', { count: issueCountText });
return t('inspector.title_count', { title: t.html('issues.' + severity + 's.list_title'), count: issueCountText });
})
.disclosureContent(renderDisclosureContent)
.shouldDisplay(function() {
@@ -147,7 +147,7 @@ export function uiSectionValidationIssues(id, severity, context) {
.order();
items.selectAll('.issue-message')
.text(function(d) {
.html(function(d) {
return d.message(context);
});
@@ -175,7 +175,7 @@ export function uiSectionValidationIssues(id, severity, context) {
linkEnter
.append('span')
.attr('class', 'autofix-all-link-text')
.text(t('issues.fix_all.title'));
.html(t.html('issues.fix_all.title'));
linkEnter
.append('span')
+2 -2
View File
@@ -36,7 +36,7 @@ export function uiSectionValidationOptions(context) {
optionsEnter
.append('div')
.attr('class', 'issues-option-title')
.text(function(d) { return t('issues.options.' + d.key + '.title'); });
.html(function(d) { return t.html('issues.options.' + d.key + '.title'); });
var valuesEnter = optionsEnter.selectAll('label')
.data(function(d) {
@@ -55,7 +55,7 @@ export function uiSectionValidationOptions(context) {
valuesEnter
.append('span')
.text(function(d) { return t('issues.options.' + d.key + '.' + d.value); });
.html(function(d) { return t.html('issues.options.' + d.key + '.' + d.value); });
}
function getOptions() {

Some files were not shown because too many files have changed in this diff Show More