mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-03 13:38:04 +02:00
Warn before leaving when you have changes. Fixes #341
This commit is contained in:
+12
@@ -173,6 +173,18 @@ window.iD = function(container) {
|
||||
.text(num_changes);
|
||||
});
|
||||
|
||||
history.on('change.warn-unload', function() {
|
||||
var changes = history.changes(),
|
||||
|
||||
has_changes = !!d3.sum(d3.values(changes).map(function(c) {
|
||||
return c.length;
|
||||
}));
|
||||
|
||||
window.onbeforeunload = has_changes ? function() {
|
||||
return 'You have unsaved changes.';
|
||||
} : null;
|
||||
});
|
||||
|
||||
bar.append('div')
|
||||
.attr('class', 'messages');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user