mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-19 23:14:47 +02:00
Use accessors
Not a mix of constructor arguments and bound datum.
This commit is contained in:
@@ -47,9 +47,7 @@ iD.ui.EntityEditor = function(context, entity) {
|
||||
preset = newpreset;
|
||||
}
|
||||
|
||||
selection
|
||||
.datum(preset)
|
||||
.html('');
|
||||
selection.html('');
|
||||
|
||||
var messagewrap = selection.append('div')
|
||||
.attr('class', 'header fillL cf');
|
||||
@@ -79,7 +77,9 @@ iD.ui.EntityEditor = function(context, entity) {
|
||||
.attr('class', 'col12 inspector-inner preset-icon-wrap')
|
||||
.append('div')
|
||||
.attr('class','fillL')
|
||||
.call(iD.ui.PresetIcon(context.geometry(entity.id)));
|
||||
.call(iD.ui.PresetIcon()
|
||||
.geometry(context.geometry(entity.id))
|
||||
.preset(preset));
|
||||
|
||||
presetUI = iD.ui.preset(context, entity, preset)
|
||||
.on('change', changeTags);
|
||||
|
||||
+20
-4
@@ -1,7 +1,9 @@
|
||||
iD.ui.PresetIcon = function(geometry) {
|
||||
return function(selection) {
|
||||
iD.ui.PresetIcon = function() {
|
||||
var preset, geometry;
|
||||
|
||||
function presetIcon(selection) {
|
||||
selection.append('div')
|
||||
.attr('class', function(preset) {
|
||||
.attr('class', function() {
|
||||
var s = 'preset-icon-fill icon-' + geometry;
|
||||
for (var i in preset.tags) {
|
||||
s += ' tag-' + i + ' tag-' + i + '-' + preset.tags[i];
|
||||
@@ -12,7 +14,7 @@ iD.ui.PresetIcon = function(geometry) {
|
||||
var fallbackIcon = geometry === 'line' ? 'other-line' : 'marker-stroked';
|
||||
|
||||
selection.append('div')
|
||||
.attr('class', function(preset) {
|
||||
.attr('class', function() {
|
||||
var icon = preset.icon || fallbackIcon,
|
||||
klass = 'feature-' + icon + ' preset-icon';
|
||||
|
||||
@@ -26,5 +28,19 @@ iD.ui.PresetIcon = function(geometry) {
|
||||
|
||||
return klass;
|
||||
});
|
||||
}
|
||||
|
||||
presetIcon.preset = function(_) {
|
||||
if (!arguments.length) return preset;
|
||||
preset = _;
|
||||
return presetIcon;
|
||||
};
|
||||
|
||||
presetIcon.geometry = function(_) {
|
||||
if (!arguments.length) return geometry;
|
||||
geometry = _;
|
||||
return presetIcon;
|
||||
};
|
||||
|
||||
return presetIcon;
|
||||
};
|
||||
|
||||
@@ -130,9 +130,10 @@ iD.ui.PresetList = function(context, entity) {
|
||||
.attr('class', 'preset-list-button-wrap category col12');
|
||||
|
||||
wrap.append('button')
|
||||
.datum(preset)
|
||||
.attr('class', 'preset-list-button')
|
||||
.call(iD.ui.PresetIcon(context.geometry(entity.id)))
|
||||
.call(iD.ui.PresetIcon()
|
||||
.geometry(context.geometry(entity.id))
|
||||
.preset(preset))
|
||||
.on('click', item.choose)
|
||||
.append('div')
|
||||
.attr('class', 'label')
|
||||
@@ -179,9 +180,10 @@ iD.ui.PresetList = function(context, entity) {
|
||||
.attr('class', 'preset-list-button-wrap col12');
|
||||
|
||||
wrap.append('button')
|
||||
.datum(preset)
|
||||
.attr('class', 'preset-list-button')
|
||||
.call(iD.ui.PresetIcon(context.geometry(entity.id)))
|
||||
.call(iD.ui.PresetIcon()
|
||||
.geometry(context.geometry(entity.id))
|
||||
.preset(preset))
|
||||
.on('click', item.choose)
|
||||
.append('div')
|
||||
.attr('class', 'label')
|
||||
|
||||
Reference in New Issue
Block a user