mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-06 11:21:33 +00:00
Condense modal hiding logic, fixes #1159
This commit is contained in:
@@ -3,12 +3,6 @@ iD.ui.modal = function(selection, blocking) {
|
||||
var previous = selection.select('div.modal');
|
||||
var animate = previous.empty();
|
||||
|
||||
var keybinding = d3.keybinding('modal')
|
||||
.on('⌫', close)
|
||||
.on('⎋', close);
|
||||
|
||||
d3.select(document).call(keybinding);
|
||||
|
||||
previous.transition()
|
||||
.duration(200)
|
||||
.style('opacity', 0)
|
||||
@@ -19,37 +13,36 @@ iD.ui.modal = function(selection, blocking) {
|
||||
.attr('class', 'shaded')
|
||||
.style('opacity', 0);
|
||||
|
||||
shaded.close = function() {
|
||||
shaded
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('opacity',0)
|
||||
.remove();
|
||||
modal
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('top','0px');
|
||||
keybinding.off();
|
||||
};
|
||||
|
||||
var keybinding = d3.keybinding('modal')
|
||||
.on('⌫', shaded.close)
|
||||
.on('⎋', shaded.close);
|
||||
|
||||
d3.select(document).call(keybinding);
|
||||
|
||||
var modal = shaded.append('div')
|
||||
.attr('class', 'modal fillL col6');
|
||||
|
||||
shaded.on('click.remove-modal', function() {
|
||||
if (d3.event.target == this && !blocking) {
|
||||
shaded
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('opacity',0)
|
||||
.remove();
|
||||
modal
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('top','0px');
|
||||
}
|
||||
if (d3.event.target == this && !blocking) shaded.close();
|
||||
});
|
||||
|
||||
modal.append('button')
|
||||
.attr('class', 'close')
|
||||
.on('click', function() {
|
||||
if (!blocking) {
|
||||
shaded
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('opacity',0)
|
||||
.remove();
|
||||
modal
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('top','0px');
|
||||
}
|
||||
if (!blocking) shaded.close();
|
||||
})
|
||||
.append('div')
|
||||
.attr('class','icon close');
|
||||
@@ -68,18 +61,6 @@ iD.ui.modal = function(selection, blocking) {
|
||||
shaded.style('opacity', 1);
|
||||
}
|
||||
|
||||
function close() {
|
||||
shaded
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('opacity',0)
|
||||
.remove();
|
||||
modal
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('top','0px');
|
||||
keybinding.off();
|
||||
}
|
||||
|
||||
return shaded;
|
||||
};
|
||||
|
||||
@@ -34,35 +34,13 @@ iD.ui.Splash = function(context) {
|
||||
.text(t('splash.walkthrough'))
|
||||
.on('click', function() {
|
||||
d3.select(document.body).call(iD.ui.intro(context));
|
||||
modal
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('opacity','0')
|
||||
.remove();
|
||||
|
||||
modal.select('.modal')
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('top','0px')
|
||||
.remove();
|
||||
modal.close();
|
||||
});
|
||||
|
||||
buttons.append('button')
|
||||
.attr('class', 'col6 start')
|
||||
.text(t('splash.start'))
|
||||
.on('click', function() {
|
||||
modal
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('opacity','0')
|
||||
.remove();
|
||||
|
||||
modal.select('.modal')
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style('top','0px')
|
||||
.remove();
|
||||
});
|
||||
.on('click', modal.close);
|
||||
|
||||
modal.select('button.close').attr('class','hide');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user