mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-29 15:16:07 +02:00
Cleanup
This commit is contained in:
+33
-36
@@ -6,27 +6,10 @@ iD.ui.preset = function(context, entity) {
|
||||
formwrap,
|
||||
formbuttonwrap;
|
||||
|
||||
function input(d) {
|
||||
var i = iD.ui.preset[d.type](d, context)
|
||||
.on('close', event.close)
|
||||
.on('change', event.change);
|
||||
|
||||
event.on('setTags.' + d.key || d.type, function(tags) {
|
||||
i.tags(_.clone(tags));
|
||||
});
|
||||
|
||||
if (d.type === 'address') i.entity(entity);
|
||||
|
||||
keys = keys.concat(d.key ? [d.key] : d.keys);
|
||||
|
||||
d3.select(this).call(i);
|
||||
}
|
||||
|
||||
function presets(selection) {
|
||||
|
||||
selection.html('');
|
||||
keys = [];
|
||||
|
||||
keys = [];
|
||||
formwrap = selection.append('div');
|
||||
|
||||
var geometry = entity.geometry(context.graph());
|
||||
@@ -44,32 +27,31 @@ iD.ui.preset = function(context, entity) {
|
||||
.data(context.presets().universal().filter(notInForm))
|
||||
.enter()
|
||||
.append('button')
|
||||
.attr('class', 'preset-add-field')
|
||||
.on('click', addForm)
|
||||
.each(tooltip)
|
||||
.append('span')
|
||||
.attr('class', function(d) { return 'icon ' + d.icon; });
|
||||
.attr('class', 'preset-add-field')
|
||||
.on('click', addForm)
|
||||
.call(bootstrap.tooltip()
|
||||
.placement('top')
|
||||
.title(function(d) { return d.label(); }))
|
||||
.append('span')
|
||||
.attr('class', function(d) { return 'icon ' + d.icon; });
|
||||
|
||||
function notInForm(p) {
|
||||
return preset.fields.indexOf(p) < 0;
|
||||
}
|
||||
|
||||
function tooltip(d) {
|
||||
d3.select(this).call(bootstrap.tooltip()
|
||||
.placement('top')
|
||||
.title(d.label()));
|
||||
}
|
||||
|
||||
function addForm(d) {
|
||||
draw(formwrap, [d]);
|
||||
|
||||
d3.select(this)
|
||||
.style('opacity', 1)
|
||||
.transition().style('opacity', 0).each('end', function() {
|
||||
d3.select(this).remove();
|
||||
});
|
||||
if (!wrap.selectAll('button').node()) wrap.remove();
|
||||
}
|
||||
.transition()
|
||||
.style('opacity', 0)
|
||||
.remove();
|
||||
|
||||
if (!wrap.selectAll('button').node()) {
|
||||
wrap.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function draw(selection, fields) {
|
||||
@@ -86,9 +68,24 @@ iD.ui.preset = function(context, entity) {
|
||||
.attr('for', function(d) { return 'input-' + d.key; })
|
||||
.text(function(d) { return d.label(); });
|
||||
|
||||
sections.transition().style('opacity', 1);
|
||||
sections.transition()
|
||||
.style('opacity', 1);
|
||||
|
||||
sections.each(input);
|
||||
sections.each(function(field) {
|
||||
var i = iD.ui.preset[field.type](field, context)
|
||||
.on('close', event.close)
|
||||
.on('change', event.change);
|
||||
|
||||
event.on('setTags.' + field.key || field.type, function (tags) {
|
||||
i.tags(_.clone(tags));
|
||||
});
|
||||
|
||||
if (field.type === 'address') i.entity(entity);
|
||||
|
||||
keys = keys.concat(field.key ? [field.key] : field.keys);
|
||||
|
||||
d3.select(this).call(i);
|
||||
});
|
||||
}
|
||||
|
||||
presets.rendered = function() {
|
||||
|
||||
Reference in New Issue
Block a user