Add ref ui, refs #256

This commit is contained in:
Tom MacWright
2012-12-17 12:55:25 -05:00
parent d8d65c4784
commit 5104c2a0aa
2 changed files with 40 additions and 0 deletions
+8
View File
@@ -13,6 +13,14 @@ iD.taginfo = function() {
}), callback);
};
taginfo.docs = function(keyvalue, callback) {
d3.json(endpoint + 'wiki/tags?' +
iD.util.qsString({
key: keyvalue.key,
value: keyvalue.value
}), callback);
};
taginfo.endpoint = function(_) {
if (!arguments.length) return endpoint;
endpoint = _;
+32
View File
@@ -94,6 +94,38 @@ iD.Inspector = function() {
.append('a')
.attr('tabindex', -1)
.attr('target', '_blank')
.on('click', function(d) {
taginfo.docs(d, function(err, docs) {
var en = _.find(docs, function(d) {
return d.lang == 'en';
});
if (en) {
var mod = iD.modal();
var types = [];
if (en.on_area) types.push('area');
if (en.on_node) types.push('point');
if (en.on_way) types.push('line');
mod.select('.content')
.append('h3')
.text(en.title);
mod.select('.content')
.append('div')
.selectAll('span.icon')
.data(types).enter()
.append('span')
.attr('title', function(d) {
return 'used with ' + d;
})
.attr('class', function(d) {
return 'icon add-' + d;
});
mod.select('.content')
.append('p')
.text(en.description);
}
});
d3.event.preventDefault();
})
.attr('href', function(d) {
return 'http://taginfo.openstreetmap.org/keys/' + d.key;
});