mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 05:30:35 +02:00
refactor further modules to not rely on html injection
This commit is contained in:
@@ -376,7 +376,7 @@ export function coreLocalizer() {
|
||||
|
||||
// Adds localized text wrapped as an HTML span element with locale info to the DOM
|
||||
localizer.t.append = function(stringId, replacements, locale) {
|
||||
return function(selection) {
|
||||
const ret = function(selection) {
|
||||
const info = localizer.tInfo(stringId, replacements, locale);
|
||||
return selection.append('span')
|
||||
.attr('class', 'localized-text')
|
||||
@@ -385,6 +385,8 @@ export function coreLocalizer() {
|
||||
+ info.text
|
||||
+ (replacements &&replacements.suffix || ''));
|
||||
};
|
||||
ret.stringId = stringId;
|
||||
return ret;
|
||||
};
|
||||
|
||||
localizer.languageName = (code, options) => {
|
||||
|
||||
@@ -250,7 +250,9 @@ export function rendererTileLayer(context) {
|
||||
if (result && result.vintage && result.vintage.range) {
|
||||
span.text(result.vintage.range);
|
||||
} else {
|
||||
span.html(t.html('info_panels.background.vintage') + ': ' + t.html('info_panels.background.unknown'));
|
||||
span.call(t.append('info_panels.background.vintage'));
|
||||
span.append('span').text(': ');
|
||||
span.call(t.append('info_panels.background.unknown'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ export function uiCommitWarnings(context) {
|
||||
|
||||
containerEnter
|
||||
.append('h3')
|
||||
.html(severity === 'warning' ? t.html('commit.warnings') : t.html('commit.errors'));
|
||||
.call(severity === 'warning' ? t.append('commit.warnings') : t.append('commit.errors'));
|
||||
|
||||
containerEnter
|
||||
.append('ul')
|
||||
|
||||
@@ -65,7 +65,8 @@ export function uiEntityEditor(context) {
|
||||
.merge(headerEnter);
|
||||
|
||||
header.selectAll('h2')
|
||||
.html(_entityIDs.length === 1 ? t.html('inspector.edit') : t.html('inspector.edit_features'));
|
||||
.text('')
|
||||
.call(_entityIDs.length === 1 ? t.append('inspector.edit') : t.append('inspector.edit_features'));
|
||||
|
||||
header.selectAll('.preset-reset')
|
||||
.on('click', function() {
|
||||
|
||||
@@ -399,10 +399,11 @@ export function uiPresetList(context) {
|
||||
].filter(Boolean);
|
||||
|
||||
label.selectAll('.namepart')
|
||||
.data(nameparts)
|
||||
.data(nameparts, d => d.stringId)
|
||||
.enter()
|
||||
.append('div')
|
||||
.attr('class', 'namepart')
|
||||
.text('')
|
||||
.each(function(d) { d(d3_select(this)); });
|
||||
|
||||
wrap.call(item.reference.button);
|
||||
|
||||
@@ -96,11 +96,11 @@ export function uiSectionFeatureType(context) {
|
||||
var names = _presets.length === 1 ? [
|
||||
_presets[0].nameLabel(),
|
||||
_presets[0].subtitleLabel()
|
||||
].filter(Boolean) : [t('inspector.multiple_types')];
|
||||
].filter(Boolean) : [ t.append('inspector.multiple_types') ];
|
||||
|
||||
var label = selection.select('.label-inner');
|
||||
var nameparts = label.selectAll('.namepart')
|
||||
.data(names, function(d) { return d; });
|
||||
.data(names, d => d.stringId);
|
||||
|
||||
nameparts.exit()
|
||||
.remove();
|
||||
@@ -109,7 +109,8 @@ export function uiSectionFeatureType(context) {
|
||||
.enter()
|
||||
.append('div')
|
||||
.attr('class', 'namepart')
|
||||
.each(function(d) { return d(d3_select(this)); });
|
||||
.text('')
|
||||
.each(function(d) { d(d3_select(this)); });
|
||||
}
|
||||
|
||||
section.entityIDs = function(val) {
|
||||
|
||||
Reference in New Issue
Block a user