Show an alert when trying to close the window with unsaved changes
This commit is contained in:
parent
9e806fd437
commit
8a95648b89
2 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue