mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-06 11:21:33 +00:00
Refactor source menu into proper control and fill it in intially.
Fixes #1084
This commit is contained in:
@@ -182,3 +182,5 @@ en:
|
||||
zoom:
|
||||
in: Zoom In
|
||||
out: Zoom Out
|
||||
imagery:
|
||||
provided_by: "Imagery provided by {source}"
|
||||
|
||||
@@ -156,7 +156,7 @@ iD.Background = function() {
|
||||
return background;
|
||||
};
|
||||
|
||||
function setPermalink(source) {
|
||||
function setHash(source) {
|
||||
var tag = source.data.sourcetag;
|
||||
var q = iD.util.stringQs(location.hash.substring(1));
|
||||
if (tag) {
|
||||
@@ -173,7 +173,7 @@ iD.Background = function() {
|
||||
source = _;
|
||||
cache = {};
|
||||
tile.scaleExtent((source.data && source.data.scaleExtent) || [1, 20]);
|
||||
setPermalink(source);
|
||||
setHash(source);
|
||||
return background;
|
||||
};
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ iD.ui = function(context) {
|
||||
linkList.append('li')
|
||||
.attr('class', 'attribution')
|
||||
.attr('tabindex', -1)
|
||||
.data([context.background().source()])
|
||||
.call(iD.ui.Attribution(context));
|
||||
|
||||
linkList.append('li')
|
||||
|
||||
@@ -1,10 +1,26 @@
|
||||
iD.ui.Attribution = function(context) {
|
||||
return function(selection) {
|
||||
selection.append('span')
|
||||
.text('imagery');
|
||||
return function attribution(selection) {
|
||||
var d = selection.data()[0];
|
||||
|
||||
selection
|
||||
var provided_by = selection
|
||||
.html('')
|
||||
.append('span')
|
||||
.attr('class', 'provided-by');
|
||||
|
||||
if (!d) return;
|
||||
|
||||
var desc = t('imagery.provided_by', {
|
||||
source: (d.data.sourcetag || d.data.name)
|
||||
});
|
||||
|
||||
if (d.data.terms_url) {
|
||||
provided_by.append('a')
|
||||
.attr('href', (d.data.terms_url || ''))
|
||||
.attr('target', '_blank')
|
||||
.classed('disabled', !d.data.terms_url)
|
||||
.text(desc);
|
||||
} else {
|
||||
provided_by.text(desc);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -110,21 +110,10 @@ iD.ui.Background = function(context) {
|
||||
return d.data.name === context.background().source().data.name;
|
||||
});
|
||||
|
||||
var provided_by = context.container()
|
||||
.select('.attribution .provided-by')
|
||||
.html('');
|
||||
|
||||
if (d.data.terms_url) {
|
||||
provided_by.append('a')
|
||||
.attr('href', (d.data.terms_url || ''))
|
||||
.attr('target', '_blank')
|
||||
.classed('disabled', !d.data.terms_url)
|
||||
.text(' provided by ' + (d.data.sourcetag || d.data.name));
|
||||
} else {
|
||||
provided_by
|
||||
.text(' provided by ' + (d.data.sourcetag || d.data.name));
|
||||
}
|
||||
|
||||
context.container()
|
||||
.select('.attribution')
|
||||
.data([d])
|
||||
.call(iD.ui.Attribution(context));
|
||||
}
|
||||
|
||||
function clickSetSource(d) {
|
||||
|
||||
Reference in New Issue
Block a user