Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@
textAreaElement.focus();
}
}
// Added event listener to confirm once the editor content is changed
$("#edit_content").one("change", function() {
var confirmFunction = function(event) {
// Chrome requires returnValue to be set and original event is found as originalEvent
// see https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#Example
if (event.originalEvent)
event.originalEvent.returnValue = "Are you sure you want to leave?";
return "Are you sure you want to leave?";
}
$(window).on("beforeunload", confirmFunction);

// Remove it if it is form submit
$(this.form).on('submit', function() {
$(window).off("beforeunload", confirmFunction);
});
});

</s:if>
<s:else>
Expand All @@ -146,6 +162,22 @@
height: 400
}
);
// Added event listener to confirm once the editor content is changed
$('#edit_content').on('summernote.change', function(we, contents, $editable) {
var confirmFunction = function(event) {
// Chrome requires returnValue to be set and original event is found as originalEvent
// see https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#Example
if (event.originalEvent)
event.originalEvent.returnValue = "Are you sure you want to leave?";
return "Are you sure you want to leave?";
}
$(window).on("beforeunload", confirmFunction);

// Remove it if it is form submit
$(this.form).on('submit', function() {
$(window).off("beforeunload", confirmFunction);
});
});
});

function insertMediaFile(toInsert) {
Expand Down