You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ad...@apache.org on 2019/06/03 16:57:23 UTC

[roller] branch ROL-2136 created (now 681cf9c)

This is an automated email from the ASF dual-hosted git repository.

adityasharma pushed a change to branch ROL-2136
in repository https://gitbox.apache.org/repos/asf/roller.git.


      at 681cf9c  Improved: Editor should confirm user before leaving the page (ROL-2136) On the pages where editors are used, if the user has done some unsaved changes. Before closing window/tab it should confirm user. Done following changes: 1. Included UnsavedChanges plugin for Xinha editor that implicitly handles it 2. Added custom code to add confimation box for text area which adds an event handler to beforeunload event if the text area is changed.

This branch includes the following new commits:

     new 681cf9c  Improved: Editor should confirm user before leaving the page (ROL-2136) On the pages where editors are used, if the user has done some unsaved changes. Before closing window/tab it should confirm user. Done following changes: 1. Included UnsavedChanges plugin for Xinha editor that implicitly handles it 2. Added custom code to add confimation box for text area which adds an event handler to beforeunload event if the text area is changed.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[roller] 01/01: Improved: Editor should confirm user before leaving the page (ROL-2136) On the pages where editors are used, if the user has done some unsaved changes. Before closing window/tab it should confirm user. Done following changes: 1. Included UnsavedChanges plugin for Xinha editor that implicitly handles it 2. Added custom code to add confimation box for text area which adds an event handler to beforeunload event if the text area is changed.

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 681cf9c19aba86e0cb4cddd5745761c4d9cd2b3c
Author: Aditya Sharma <ia...@gmail.com>
AuthorDate: Mon Jun 3 22:18:19 2019 +0530

    Improved: Editor should confirm user before leaving the page
    (ROL-2136)
    On the pages where editors are used, if the user has done some unsaved changes. Before closing window/tab it should confirm user.
    Done following changes:
    1. Included UnsavedChanges plugin for Xinha editor that implicitly handles it
    2. Added custom code to add confimation box for text area which adds an event handler to beforeunload event if the text area is changed.
---
 app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

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 08f2051..dc4a59f 100644
--- a/app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/editor/EntryEditor.jsp
@@ -125,6 +125,17 @@
                 textAreaElement.focus();
             }
         }
+        // Added event listener to confirm once the editor content is changed
+        jQuery("#edit_content").one("change", function() {
+            console.log("this");
+            jQuery(window).on("beforeunload", 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?";
+            });
+        });
     </script>
 </s:if>
 <s:else>
@@ -169,7 +180,7 @@
                 'edit_content', 'edit_summary'
             ];
 
-            xinha_plugins = xinha_plugins ? xinha_plugins :[];
+            xinha_plugins = xinha_plugins ? xinha_plugins :[ 'UnsavedChanges'];
             if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;
 
             xinha_config = xinha_config ? xinha_config() : new Xinha.Config();