Move tag reference to its own file

This commit is contained in:
Tom MacWright
2012-12-17 17:06:39 -05:00
parent 853d7322c8
commit c0921ac44a
3 changed files with 36 additions and 21 deletions
+1
View File
@@ -45,6 +45,7 @@
<script src='js/id/ui/layerswitcher.js'></script>
<script src='js/id/ui/geocoder.js'></script>
<script src='js/id/ui/notice.js'></script>
<script src='js/id/ui/tag_reference.js'></script>
<script src='js/id/actions.js'></script>
<script src='js/id/actions/add_node.js'></script>
+4 -21
View File
@@ -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();
+31
View File
@@ -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'));
});
};