roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adityasha...@apache.org
Subject [roller] branch roller-5.2.x updated: Fixed: confirmation dialog should not appear in case of submit button (ROL-2136)
Date Thu, 24 Oct 2019 08:51:51 GMT
This is an automated email from the ASF dual-hosted git repository.

adityasharma pushed a commit to branch roller-5.2.x
in repository https://gitbox.apache.org/repos/asf/roller.git


The following commit(s) were added to refs/heads/roller-5.2.x by this push:
     new 8de22a6  Fixed: confirmation dialog should not appear in case of submit button (ROL-2136)
     new 8657254  Merge pull request #45 from adityasharma7/ROL-2136-5.2.x
8de22a6 is described below

commit 8de22a61710f937b2bb8be2e9ae826eef416b7ba
Author: Aditya Sharma <iamadityasharma7@gmail.com>
AuthorDate: Thu Oct 24 14:20:06 2019 +0530

    Fixed: confirmation dialog should not appear in case of submit button (ROL-2136)
---
 app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp b/app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp
index 95fd034..241c924 100644
--- a/app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp
@@ -126,13 +126,18 @@
             }
         }
         // Added event listener to confirm once the editor content is changed
-        jQuery("#edit_content").one("change", function() {
-            jQuery(window).on("beforeunload", function(event) {
+        $("#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);
             });
         });
     </script>


Mime
View raw message