mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 17:23:02 +00:00
Add 'I' shortcut for switching between the last two backgrounds.
This commit is contained in:
@@ -1808,6 +1808,10 @@ div.full-screen > button:hover {
|
||||
background: #E8EBFF;
|
||||
}
|
||||
|
||||
.layer-list li.switch {
|
||||
background: #fffce8;
|
||||
}
|
||||
|
||||
.layer-list label {
|
||||
display: block;
|
||||
padding: 5px 10px;
|
||||
|
||||
@@ -8,7 +8,8 @@ iD.ui.Background = function(context) {
|
||||
['bottom', [0, 1]]],
|
||||
opacityDefault = (context.storage('background-opacity') !== null) ?
|
||||
(+context.storage('background-opacity')) : 1.0,
|
||||
customTemplate = context.storage('background-custom-template') || '';
|
||||
customTemplate = context.storage('background-custom-template') || '',
|
||||
latestBg = [context.background().baseLayerSource(), null];
|
||||
|
||||
// Can be 0 from <1.3.0 use or due to issue #1923.
|
||||
if (opacityDefault === 0) opacityDefault = 1.0;
|
||||
@@ -44,13 +45,21 @@ iD.ui.Background = function(context) {
|
||||
return context.background().showsLayer(d);
|
||||
}
|
||||
|
||||
function bgswitch(d) {
|
||||
return latestBg[1] === d;
|
||||
}
|
||||
|
||||
content.selectAll('.layer, .custom_layer')
|
||||
.classed('active', active)
|
||||
.classed('switch', bgswitch)
|
||||
.selectAll('input')
|
||||
.property('checked', active);
|
||||
}
|
||||
|
||||
function clickSetSource(d) {
|
||||
latestBg[1] = latestBg[0];
|
||||
latestBg[0] = d;
|
||||
|
||||
d3.event.preventDefault();
|
||||
context.background().baseLayerSource(d);
|
||||
selectLayer();
|
||||
@@ -156,6 +165,20 @@ iD.ui.Background = function(context) {
|
||||
setVisible(!button.classed('active'));
|
||||
}
|
||||
|
||||
function interchangeBg() {
|
||||
var d = latestBg[1];
|
||||
if (d == null) {
|
||||
toggle();
|
||||
return;
|
||||
}
|
||||
|
||||
latestBg[1] = latestBg[0];
|
||||
latestBg[0] = d;
|
||||
|
||||
context.background().baseLayerSource(d);
|
||||
selectLayer();
|
||||
}
|
||||
|
||||
function setVisible(show) {
|
||||
if (show !== shown) {
|
||||
button.classed('active', show);
|
||||
@@ -323,6 +346,7 @@ iD.ui.Background = function(context) {
|
||||
|
||||
var keybinding = d3.keybinding('background')
|
||||
.on(key, toggle)
|
||||
.on('I', interchangeBg)
|
||||
.on('F', hide)
|
||||
.on('H', hide);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user