Files
iD/js/id/ui/restore.js
Bryan Housel 7930a0bb36 Modal Dialog and Save/Restore improvements
(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
2016-04-15 23:01:28 -04:00

47 lines
1.3 KiB
JavaScript

iD.ui.Restore = function(context) {
return function(selection) {
if (!context.history().lock() || !context.history().restorableChanges())
return;
var modal = iD.ui.modal(selection, true);
modal.select('.modal')
.attr('class', 'modal fillL col6');
var introModal = modal.select('.content');
introModal.attr('class','cf');
introModal.append('div')
.attr('class', 'modal-section')
.append('h3')
.text(t('restore.heading'));
introModal.append('div')
.attr('class','modal-section')
.append('p')
.text(t('restore.description'));
var buttonWrap = introModal.append('div')
.attr('class', 'modal-actions cf');
var restore = buttonWrap.append('button')
.attr('class', 'restore col6')
.text(t('restore.restore'))
.on('click', function() {
context.history().restore();
modal.remove();
});
buttonWrap.append('button')
.attr('class', 'reset col6')
.text(t('restore.reset'))
.on('click', function() {
context.history().clearSaved();
modal.remove();
});
restore.node().focus();
};
};