diff --git a/js/id/taginfo.js b/js/id/taginfo.js index 298c48e1e..b06f1e8d5 100644 --- a/js/id/taginfo.js +++ b/js/id/taginfo.js @@ -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 = _; diff --git a/js/id/ui/inspector.js b/js/id/ui/inspector.js index eb1322f6c..4da5021cb 100644 --- a/js/id/ui/inspector.js +++ b/js/id/ui/inspector.js @@ -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; });