提交 8a95648b 编写于 作者: J Jacob Schatz

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

上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册