changeset 357:2b5503392fbd

browser_side: small fixes for RichTextEditor
author souliane <souliane@mailoo.org>
date Thu, 13 Feb 2014 15:32:59 +0100
parents b95099a1d11b
children df743589bb8c
files browser_side/dialog.py browser_side/richtext.py
diffstat 2 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/dialog.py	Thu Feb 13 12:53:07 2014 +0100
+++ b/browser_side/dialog.py	Thu Feb 13 15:32:59 2014 +0100
@@ -255,7 +255,8 @@
         button_panel.addStyleName("marginAuto")
         self.confirm_button = Button("OK", self.onConfirm)
         button_panel.add(self.confirm_button)
-        button_panel.add(Button("Cancel", self.onCancel))
+        self.cancel_button = Button("Cancel", self.onCancel)
+        button_panel.add(self.cancel_button)
         content.add(button_panel)
         self.setHTML(title)
         self.setWidget(content)
--- a/browser_side/richtext.py	Thu Feb 13 12:53:07 2014 +0100
+++ b/browser_side/richtext.py	Thu Feb 13 15:32:59 2014 +0100
@@ -256,11 +256,12 @@
         confirmation. When edit is False and abort is True, abortion is actually done.
         @param sync: set to True to cancel the edition after the content has been saved somewhere else
         """
-        self.refresh(edit)
-        BaseTextEditor.edit(self, edit, abort, sync)
+        if not (edit and abort):
+            self.refresh(edit)  # not when we are asking for a confirmation
+        BaseTextEditor.edit(self, edit, abort, sync)  # after the UI has been refreshed
         if (edit and abort):
-            return
-        self.setWysiwyg(False, init=True)  # /!\ it affects self.getContent
+            return  # self.avortEdition is called by BaseTextEditor.edit
+        self.setWysiwyg(False, init=True)  # after BaseTextEditor (it affects self.getContent)
         if sync:
             return
         # the following must NOT be done at each UI refresh!
@@ -290,7 +291,7 @@
                 if 'title' in content and content['title']:
                     text = '<h1>%s</h1>%s' % (content['title'], content['text'])
                 self.display.setContent({'text': text})
-                self.display.edit(False)
+            self.display.edit(False)
 
     def setFocus(self, focus):
         self.textarea.setFocus(focus)
@@ -301,6 +302,7 @@
             if answer:
                 self.edit(False, True)
         _dialog = ConfirmDialog(confirm_cb, text="Do you really want to %s?" % ("cancel your changes" if self.update_msg else "cancel this message"))
+        _dialog.cancel_button.setText(_("No"))
         _dialog.show()