changeset 542:2f495a1be4c7

confirm leaving JS added to gui editor, TODO: add flgChange update JS code imported from: moin--main--1.5--patch-546
author Thomas Waldmann <tw@waldmann-edv.de>
date Sun, 09 Apr 2006 12:31:35 +0000
parents d141b2a723cf
children 2d4d8f7edf1b
files ChangeLog MoinMoin/PageEditor.py MoinMoin/PageGraphicalEditor.py
diffstat 3 files changed, 31 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Apr 09 12:05:08 2006 +0000
+++ b/ChangeLog	Sun Apr 09 12:31:35 2006 +0000
@@ -2,6 +2,21 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-04-09 13:31:35 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-546
+
+    Summary:
+      confirm leaving JS added to gui editor, TODO: add flgChange update JS code
+    Revision:
+      moin--main--1.5--patch-546
+
+    confirm leaving JS added to gui editor, TODO: add flgChange update JS code
+    
+
+    modified files:
+     ChangeLog MoinMoin/PageEditor.py
+     MoinMoin/PageGraphicalEditor.py
+
+
 2006-04-09 13:05:08 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-545
 
     Summary:
--- a/MoinMoin/PageEditor.py	Sun Apr 09 12:05:08 2006 +0000
+++ b/MoinMoin/PageEditor.py	Sun Apr 09 12:31:35 2006 +0000
@@ -111,6 +111,19 @@
 
         return False
 
+    def sendconfirmleaving(self):
+        """ to prevent moving away from the page without saving it """
+        _ = self._
+        self.request.write(u'''\
+<script type="text/javascript">
+    var flgChange = false;
+    function confirmleaving() {
+        if ( flgChange )
+            return "%s";
+    }
+</script>
+''' % _("Your changes are not saved!"))
+        
     def sendEditor(self, **kw):
         """
         Send the editor form page.
@@ -337,16 +350,7 @@
         # language into meta file.
         lang = self.language or self.request.cfg.language_default
 
-        # to prevent moving away from the page without saving it
-        self.request.write(u'''\
-<script type="text/javascript">
-    var flgChange = false;
-    function confirmleaving() {
-        if ( flgChange )
-            return "%s";
-    }
-</script>
-''' % _("Your changes are not saved!"))
+        self.sendconfirmleaving()
 
         self.request.write(
             u'''\
--- a/MoinMoin/PageGraphicalEditor.py	Sun Apr 09 12:05:08 2006 +0000
+++ b/MoinMoin/PageGraphicalEditor.py	Sun Apr 09 12:31:35 2006 +0000
@@ -242,6 +242,8 @@
 <input type="hidden" name="editor" value="gui">
 ''' % (save_button_text, _('Preview'), _('Text mode'), button_spellcheck, cancel_button_text,))
 
+        self.sendconfirmleaving() # TODO update state of flgChange to make this work, see PageEditor
+
         # Add textarea with page text
 
         # TODO: currently self.language is None at this point. We have