Commit 8a95648b authored by Jacob Schatz's avatar Jacob Schatz

Show an alert when trying to close the window with unsaved changes

parent 9e806fd4
......@@ -17,6 +17,19 @@ function addEventsForNonVueEls() {
$(document).on('change', '.dropdown', () => {
Store.targetBranch = $('.project-refs-target-form input[name="ref"]').val();
});
window.onbeforeunload = function (e) {
const hasChanged = Store.openedFiles
.some(file => file.changed);
console.log('hasChanged',hasChanged)
if(!hasChanged) return;
e = e || window.event;
if (e) {
e.returnValue = 'Are you sure you want to lose unsaved changes?';
}
// For Safari
return 'Are you sure you want to lose unsaved changes?';
};
}
function initRepo() {
......
......@@ -158,6 +158,7 @@
span.help-block {
padding-top: 7px;
margin-top: 0;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment