diff --git a/index.html b/index.html
index 7c7e3e703..afa192755 100644
--- a/index.html
+++ b/index.html
@@ -45,6 +45,7 @@
+
diff --git a/js/id/ui/inspector.js b/js/id/ui/inspector.js
index 885fd0d90..42d9ce0e7 100644
--- a/js/id/ui/inspector.js
+++ b/js/id/ui/inspector.js
@@ -109,32 +109,15 @@ iD.Inspector = function() {
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');
+ en.types = types;
+ var mod = iD.modal();
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('a')
- .attr('href', 'http://wiki.openstreetmap.org/wiki/' + en.title)
- .text('→ ' + en.title + ' on wiki.osm.org');
- mod.select('.content')
- .append('p')
- .text(en.description);
+ .datum(en)
+ .call(iD.tagReference);
}
});
d3.event.preventDefault();
diff --git a/js/id/ui/tag_reference.js b/js/id/ui/tag_reference.js
new file mode 100644
index 000000000..c47d398a5
--- /dev/null
+++ b/js/id/ui/tag_reference.js
@@ -0,0 +1,31 @@
+iD.tagReference = function(selection) {
+ selection.each(function() {
+ function g(x) { return function(d) { return d[x]; }; }
+ var selection = d3.select(this);
+ selection
+ .append('h3')
+ .text(g('title'));
+ var icon_row = selection.append('div');
+ var icons = icon_row.selectAll('span.icon')
+ .data(g('types'))
+ .enter()
+ .append('span')
+ .attr('title', function(d) {
+ return 'used with ' + d;
+ })
+ .attr('class', function(d) {
+ return 'icon add-' + d;
+ });
+ selection
+ .append('a')
+ .attr('href', function(d) {
+ return 'http://wiki.openstreetmap.org/wiki/' + d.title;
+ })
+ .text(function(d) {
+ return '→ ' + d.title + ' on wiki.osm.org';
+ });
+ selection
+ .append('p')
+ .text(g('description'));
+ });
+};