resolved conflict

This commit is contained in:
saman bb
2013-03-12 20:51:13 -04:00
156 changed files with 423 additions and 220 deletions
+4 -2
View File
@@ -17,10 +17,12 @@ iD.actions.Connect = function(nodeIds) {
var survivor = graph.entity(_.last(nodeIds));
for (var i = 0; i < nodeIds.length - 1; i++) {
var node = graph.entity(nodeIds[i]), index;
var node = graph.entity(nodeIds[i]);
graph.parentWays(node).forEach(function(parent) {
graph = graph.replace(parent.replaceNode(node.id, survivor.id));
if (!parent.areAdjacent(node.id, survivor.id)) {
graph = graph.replace(parent.replaceNode(node.id, survivor.id));
}
});
graph.parentRelations(node).forEach(function(parent) {
+7 -5
View File
@@ -68,17 +68,19 @@ iD.Entity.prototype = {
},
mergeTags: function(tags) {
var merged = _.clone(this.tags);
var merged = _.clone(this.tags), changed = false;
for (var k in tags) {
var t1 = merged[k],
t2 = tags[k];
if (t1 && t1 !== t2) {
merged[k] = _.union(t1.split(/;\s*/), t2.split(/;\s*/)).join(';');
} else {
if (!t1) {
changed = true;
merged[k] = t2;
} else if (t1 !== t2) {
changed = true;
merged[k] = _.union(t1.split(/;\s*/), t2.split(/;\s*/)).join(';');
}
}
return this.update({tags: merged});
return changed ? this.update({tags: merged}) : this;
},
intersects: function(extent, resolver) {
+1 -1
View File
@@ -59,7 +59,7 @@ _.extend(iD.Way.prototype, {
areAdjacent: function(n1, n2) {
for (var i = 0; i < this.nodes.length; i++) {
if (this.nodes[i] === n1) {
if (this.nodes[i] === n1) {
if (this.nodes[i - 1] === n2) return true;
if (this.nodes[i + 1] === n2) return true;
}
-15
View File
@@ -102,12 +102,6 @@ iD.modes.DragNode = function(context) {
function end(entity) {
if (cancelled) return;
function adjacent(d) {
return _.any(context.graph().parentWays(entity).map(function(w) {
return w.areAdjacent(d.id, entity.id);
}));
}
var d = datum();
if (d.type === 'way') {
@@ -117,15 +111,6 @@ iD.modes.DragNode = function(context) {
iD.actions.AddVertex(d.id, entity.id, choice.index),
connectAnnotation(d));
} else if (d.type === 'node' && adjacent(d)) {
if (wasMidpoint) {
context.history().pop();
} else {
context.replace(
iD.actions.DeleteNode(entity.id),
t('operations.delete.annotation.vertex'));
}
} else if (d.type === 'node' && d.id !== entity.id) {
context.replace(
iD.actions.Connect([entity.id, d.id]),
+9 -2
View File
@@ -8,13 +8,14 @@ iD.presets = function(context) {
icon: 'marker-stroked',
match: {
tags: {},
type: ['point', 'vertex', 'line', 'area']
geometry: ['point', 'vertex', 'line', 'area']
},
form: []
}),
all = iD.presets.Collection([iD.presets.Preset(other)]),
defaults = { area: all, line: all, point: all, vertex: all },
forms = {},
universal = [],
recent = iD.presets.Collection([]);
all.load = function(d) {
@@ -22,6 +23,7 @@ iD.presets = function(context) {
if (d.forms) {
_.forEach(d.forms, function(d, id) {
forms[id] = iD.presets.Form(d, id);
if (d.universal) universal.push(forms[id]);
});
}
@@ -31,6 +33,7 @@ iD.presets = function(context) {
});
}
if (d.categories) {
d.categories.forEach(function(d) {
all.collection.push(iD.presets.Category(d, all));
@@ -50,8 +53,12 @@ iD.presets = function(context) {
return all;
};
all.universal = function() {
return universal;
};
all.defaults = function(entity, n) {
var rec = recent.matchType(entity, context.graph()).collection.slice(0, 4),
var rec = recent.matchGeometry(entity, context.graph()).collection.slice(0, 4),
def = _.uniq(rec.concat(defaults[entity.geometry(context.graph())].collection)).slice(0, n - 1);
return iD.presets.Collection(_.unique(rec.concat(def).concat(other)));
};
+2 -2
View File
@@ -5,8 +5,8 @@ iD.presets.Category = function(category, all) {
return all.item(name);
}));
category.matchType = function(entity, resolver) {
return category.match.type.indexOf(entity.geometry(resolver)) >= 0;
category.matchGeometry = function(entity, resolver) {
return category.match.geometry.indexOf(entity.geometry(resolver)) >= 0;
};
category.matchTags = function() { return false; };
+3 -3
View File
@@ -11,12 +11,12 @@ iD.presets.Collection = function(collection) {
},
match: function(entity, resolver) {
return presets.matchType(entity, resolver).matchTags(entity);
return presets.matchGeometry(entity, resolver).matchTags(entity);
},
matchType: function(entity, resolver) {
matchGeometry: function(entity, resolver) {
return iD.presets.Collection(collection.filter(function(d) {
return d.matchType(entity, resolver);
return d.matchGeometry(entity, resolver);
}));
},
+7 -4
View File
@@ -3,16 +3,19 @@ iD.presets.Preset = function(preset, forms) {
preset.icon = preset.icon || 'marker-stroked';
preset.form = preset.form ? preset.form.map(function(f) {
preset.form = preset.form ? preset.form.map(getForms) : [];
preset.additional = preset.additional ? preset.additional.map(getForms) : [];
function getForms(f) {
if (typeof f === 'string') {
return forms[f];
} else {
return iD.presets.Form(f, f.key);
}
}) : [];
}
preset.matchType = function(entity, resolver) {
return preset.match.type.indexOf(entity.geometry(resolver)) >= 0;
preset.matchGeometry = function(entity, resolver) {
return preset.match.geometry.indexOf(entity.geometry(resolver)) >= 0;
};
preset.matchTags = function(entity) {
+2 -1
View File
@@ -34,7 +34,8 @@ iD.svg.Areas = function(projection) {
cemetery: 'cemetery',
grave_yard: 'cemetery',
meadow: 'meadow',
famrland: 'farmland',
farm: 'farmland',
farmland: 'farmland',
orchard: 'orchard'
};
+2 -2
View File
@@ -187,9 +187,9 @@ iD.ui.Background = function(context) {
.attr('class', 'adjustments pad1');
var directions = [
['left', [-1, 0]],
['left', [1, 0]],
['top', [0, -1]],
['right', [1, 0]],
['right', [-1, 0]],
['bottom', [0, 1]]];
adjustments.append('a')
+64 -15
View File
@@ -3,7 +3,9 @@ iD.ui.preset = function(context) {
entity,
tags,
keys,
preset;
preset,
formwrap,
formbuttonwrap;
function input(d) {
var i = iD.ui.preset[d.type](d, context)
@@ -18,7 +20,7 @@ iD.ui.preset = function(context) {
keys = keys.concat(d.key ? [d.key] : d.keys);
this.call(i);
d3.select(this).call(i);
}
function presets(selection) {
@@ -26,22 +28,53 @@ iD.ui.preset = function(context) {
selection.html('');
keys = [];
formwrap = selection.append('div');
draw(formwrap, preset.form);
var wrap = selection.append('div')
.attr('class', 'col12 inspector-inner');
wrap.append('div')
.attr('class', 'col3 preset-label')
.text('Add field');
formbuttonwrap = wrap.append('div')
.attr('class', 'col9 preset-input');
formbuttonwrap.selectAll('button')
.data(preset.additional)
.enter()
.append('button')
.attr('class', 'preset-add-form')
.attr('title', function(d) { return d.label(); })
.on('click', addForm)
.append('span')
.attr('class', function(d) { return 'icon ' + d.icon; });
function addForm(d) {
draw(formwrap, [d]);
d3.select(this).remove();
if (!wrap.selectAll('button').node()) wrap.remove();
}
}
function formKey(d) {
return d.key || String(d.keys);
}
function draw(selection, form) {
var sections = selection.selectAll('div.preset-section')
.data(preset.form)
.data(form, formKey)
.enter()
.append('div')
.attr('class', 'preset-section fillL inspector-inner col12');
.attr('class', 'preset-section fillL inspector-inner col12')
sections.each(function(d) {
var s = d3.select(this);
s.append('h4')
.attr('for', 'input-' + d.key)
sections.append('h4')
.attr('for', function(d) { return 'input-' + d.key; })
.text(function(d) { return d.label(); });
input.call(s, d);
});
if (tags) event.setTags(tags);
sections.each(input);
}
presets.rendered = function() {
@@ -54,9 +87,25 @@ iD.ui.preset = function(context) {
return presets;
};
presets.change = function(_) {
tags = _;
event.setTags(_);
presets.change = function(t) {
tags = t;
function haveKey(k) { return k && !!tags[k]; }
formbuttonwrap.selectAll('button').each(function(p) {
if (haveKey(p.key) || _.any(p.keys, haveKey)) {
draw(formwrap, [p]);
d3.select(this).remove();
}
});
context.presets().universal().forEach(function(p) {
if (haveKey(p.key) || _.any(p.keys, haveKey)) {
draw(formwrap, [p]);
}
});
event.setTags(tags);
return presets;
};
+3 -1
View File
@@ -2,7 +2,7 @@ iD.ui.preset.check = function(form) {
var event = d3.dispatch('change', 'close'),
values = ['', 'yes', 'no'],
value,
value = '',
box,
text,
label;
@@ -14,9 +14,11 @@ iD.ui.preset.check = function(form) {
label = selection.append('label');
box = label.append('input')
.property('indeterminate', true)
.attr('type', 'checkbox');
text = label.append('span')
.text('unknown')
.attr('class', 'value');
box.on('click', function() {
+1 -1
View File
@@ -8,7 +8,7 @@ iD.ui.PresetGrid = function(context) {
selection.html('');
presets = presets.matchType(entity, context.graph());
presets = presets.matchGeometry(entity, context.graph());
var messagewrap = selection.append('div')
.attr('class', 'message inspector-inner fillL');
+7 -2
View File
@@ -1,6 +1,7 @@
iD.ui.RadialMenu = function(operations) {
var menu,
center = [0, 0];
center = [0, 0],
tooltip;
var radialMenu = function(selection) {
if (!operations.length)
@@ -57,7 +58,7 @@ iD.ui.RadialMenu = function(operations) {
.attr('clip-path', 'url(#clip-square-20)')
.attr('xlink:href', function(d) { return '#icon-operation-' + d.id; });
var tooltip = d3.select(document.body)
tooltip = d3.select(document.body)
.append('div')
.attr('class', 'tooltip-inner radial-menu-tooltip');
@@ -84,6 +85,10 @@ iD.ui.RadialMenu = function(operations) {
.attr('opacity', 0)
.remove();
}
if (tooltip) {
tooltip.remove();
}
};
radialMenu.center = function(_) {
+1 -1
View File
@@ -149,7 +149,7 @@ iD.ui.TagEditor = function(context) {
// change preset if necessary (undos/redos)
var newmatch = presets
.matchType(entity, context.graph())
.matchGeometry(entity, context.graph())
.matchTags(entity.update({ tags: tags }));
if (newmatch !== preset) {
return tageditor(selection_, newmatch);
+1 -1
View File
@@ -18,7 +18,7 @@ function t(s, o, loc) {
if (rep !== undefined) {
if (o) for (var k in o) rep = rep.replace('{' + k + '}', o[k]);
return rep;
} else if (o.default) {
} else if (o && o.default) {
return o.default;
} else {
var missing = 'Missing translation: ' + s;