comparison browser_side/richtext.py @ 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 151bf1afd97e
comparison
equal deleted inserted replaced
356:b95099a1d11b 357:2b5503392fbd
254 @param abort: set to True to cancel the edition and loose the changes. 254 @param abort: set to True to cancel the edition and loose the changes.
255 If edit and abort are both True, self.abortEdition can be used to ask for a 255 If edit and abort are both True, self.abortEdition can be used to ask for a
256 confirmation. When edit is False and abort is True, abortion is actually done. 256 confirmation. When edit is False and abort is True, abortion is actually done.
257 @param sync: set to True to cancel the edition after the content has been saved somewhere else 257 @param sync: set to True to cancel the edition after the content has been saved somewhere else
258 """ 258 """
259 self.refresh(edit) 259 if not (edit and abort):
260 BaseTextEditor.edit(self, edit, abort, sync) 260 self.refresh(edit) # not when we are asking for a confirmation
261 BaseTextEditor.edit(self, edit, abort, sync) # after the UI has been refreshed
261 if (edit and abort): 262 if (edit and abort):
262 return 263 return # self.avortEdition is called by BaseTextEditor.edit
263 self.setWysiwyg(False, init=True) # /!\ it affects self.getContent 264 self.setWysiwyg(False, init=True) # after BaseTextEditor (it affects self.getContent)
264 if sync: 265 if sync:
265 return 266 return
266 # the following must NOT be done at each UI refresh! 267 # the following must NOT be done at each UI refresh!
267 content = self._original_content 268 content = self._original_content
268 if edit: 269 if edit:
288 # set the display text in XHTML only during init because a new MicroblogEntry instance is created after each modification 289 # set the display text in XHTML only during init because a new MicroblogEntry instance is created after each modification
289 text = content['text'] 290 text = content['text']
290 if 'title' in content and content['title']: 291 if 'title' in content and content['title']:
291 text = '<h1>%s</h1>%s' % (content['title'], content['text']) 292 text = '<h1>%s</h1>%s' % (content['title'], content['text'])
292 self.display.setContent({'text': text}) 293 self.display.setContent({'text': text})
293 self.display.edit(False) 294 self.display.edit(False)
294 295
295 def setFocus(self, focus): 296 def setFocus(self, focus):
296 self.textarea.setFocus(focus) 297 self.textarea.setFocus(focus)
297 298
298 def abortEdition(self, content): 299 def abortEdition(self, content):
299 """Ask for confirmation before closing the dialog.""" 300 """Ask for confirmation before closing the dialog."""
300 def confirm_cb(answer): 301 def confirm_cb(answer):
301 if answer: 302 if answer:
302 self.edit(False, True) 303 self.edit(False, True)
303 _dialog = ConfirmDialog(confirm_cb, text="Do you really want to %s?" % ("cancel your changes" if self.update_msg else "cancel this message")) 304 _dialog = ConfirmDialog(confirm_cb, text="Do you really want to %s?" % ("cancel your changes" if self.update_msg else "cancel this message"))
305 _dialog.cancel_button.setText(_("No"))
304 _dialog.show() 306 _dialog.show()
305 307
306 308
307 class RichMessageEditor(RichTextEditor): 309 class RichMessageEditor(RichTextEditor):
308 """Use the rich text editor for sending messages with extended addressing. 310 """Use the rich text editor for sending messages with extended addressing.