Skip to content
Snippets Groups Projects
Commit f4917a35 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Elmar Ludwig
Browse files

disable security handler when regularly saving a wiki page, fixes #4543

Closes #4543

Merge request studip/studip!3338
parent 9dd7c016
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,10 @@
</div>
<div data-dialog-button="">
<button class="button" :title="isChanged ? '<?= _('Den aktuellen Stand speichern.') ?>' : '<?= _('Der aktuelle Stand wurde bereits gespeichert.') ?>'">
<button class="button"
:title="isChanged ? '<?= _('Den aktuellen Stand speichern.') ?>' : '<?= _('Der aktuelle Stand wurde bereits gespeichert.') ?>'"
@click="toggleSecurityHandler(false)"
>
<?= _('Speichern') ?>
</button>
<?= \Studip\LinkButton::create(_('Verlassen'), $controller->leave_editing($page))?>
......
......@@ -77,6 +77,13 @@ const Wiki = {
this.editor.editing.view.focus();
});
},
toggleSecurityHandler(state = true) {
if (state) {
window.addEventListener('beforeunload', this.securityHandler);
} else {
window.removeEventListener('beforeunload', this.securityHandler);
}
},
securityHandler(event) {
event.preventDefault();
event.returnValue = true;
......@@ -105,11 +112,7 @@ const Wiki = {
},
watch: {
isChanged(current) {
if (current) {
window.addEventListener('beforeunload', this.securityHandler);
} else {
window.removeEventListener('beforeunload', this.securityHandler);
}
this.toggleSecurityHandler(current);
}
},
components: { WikiEditorOnlineUsers }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment