mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-11 13:46:10 +00:00
(closes #3036) 1. Fix the modal close button icon - was not visible 2. Use a blocking modal for the Save/Restore dialog 3. Don't allow `context.save()` while modal is visible (especially for `onbeforeunload` event - this would wipe user's saved history if browser is closed while the Save/Restore modal was visible) 4. Don't allow blocking modals to be dismissed by pressing escape 5. Don't show the close button icon for blocking modals
64 lines
1.4 KiB
JavaScript
64 lines
1.4 KiB
JavaScript
iD.ui.modal = function(selection, blocking) {
|
|
var keybinding = d3.keybinding('modal');
|
|
var previous = selection.select('div.modal');
|
|
var animate = previous.empty();
|
|
|
|
previous.transition()
|
|
.duration(200)
|
|
.style('opacity', 0)
|
|
.remove();
|
|
|
|
var shaded = selection
|
|
.append('div')
|
|
.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 modal = shaded.append('div')
|
|
.attr('class', 'modal fillL col6');
|
|
|
|
if (!blocking) {
|
|
shaded.on('click.remove-modal', function() {
|
|
if (d3.event.target === this) {
|
|
shaded.close();
|
|
}
|
|
});
|
|
|
|
modal.append('button')
|
|
.attr('class', 'close')
|
|
.on('click', shaded.close)
|
|
.call(iD.svg.Icon('#icon-close'));
|
|
|
|
keybinding
|
|
.on('⌫', shaded.close)
|
|
.on('⎋', shaded.close);
|
|
|
|
d3.select(document).call(keybinding);
|
|
}
|
|
|
|
modal.append('div')
|
|
.attr('class', 'content');
|
|
|
|
if (animate) {
|
|
shaded.transition().style('opacity', 1);
|
|
} else {
|
|
shaded.style('opacity', 1);
|
|
}
|
|
|
|
return shaded;
|
|
};
|