Mercurial > libervia-web
comparison browser_side/panels.py @ 315:09205b410a53
browser_side: handle successive click on blog post "edit" and "comment" icons
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 02 Jan 2014 16:10:27 +0100 |
parents | 70ac3067d641 |
children | 462a0a8894e3 |
comparison
equal
deleted
inserted
replaced
314:70ac3067d641 | 315:09205b410a53 |
---|---|
420 return getattr(self._base_item, name) | 420 return getattr(self._base_item, name) |
421 | 421 |
422 def _setContent(self): | 422 def _setContent(self): |
423 """Actually set the entry content (header, icons, bubble...)""" | 423 """Actually set the entry content (header, icons, bubble...)""" |
424 self.delete_label = self.update_label = self.comment_label = None | 424 self.delete_label = self.update_label = self.comment_label = None |
425 self.bubble = self.editbox = None | 425 self.bubble = self.editbox = self._current_comment = None |
426 self._setHeader() | 426 self._setHeader() |
427 if self.empty: | 427 if self.empty: |
428 self.editable_content = ['', const.SYNTAX_XHTML] | 428 self.editable_content = ['', const.SYNTAX_XHTML] |
429 else: | 429 else: |
430 self.editable_content = [self.xhtml, const.SYNTAX_XHTML] if self.xhtml else [self.content, None] | 430 self.editable_content = [self.xhtml, const.SYNTAX_XHTML] if self.xhtml else [self.content, None] |
503 self.edit_panel = self.editbox = None | 503 self.edit_panel = self.editbox = None |
504 | 504 |
505 def removeNewEntry(): | 505 def removeNewEntry(): |
506 if self.empty: | 506 if self.empty: |
507 self._blog_panel.removeEntry(self.type, self.id) | 507 self._blog_panel.removeEntry(self.type, self.id) |
508 if self.type == 'main_item': | 508 if self.type == 'main_item': # restore the "New message" button |
509 self._blog_panel.setUniBox(enable=False) | 509 self._blog_panel.setUniBox(enable=False) |
510 else: # allow to create a new comment | |
511 self._parent_entry._current_comment = None | |
510 | 512 |
511 if cancel or new_text == self.editable_content[0] or new_text == "": | 513 if cancel or new_text == self.editable_content[0] or new_text == "": |
512 removeNewEntry() | 514 removeNewEntry() |
513 return | 515 return |
514 self.editable_content[0] = new_text | 516 self.editable_content[0] = new_text |
526 | 528 |
527 def setEntryDialog(self, edit=False): | 529 def setEntryDialog(self, edit=False): |
528 """Set the bubble or the editor | 530 """Set the bubble or the editor |
529 @param edit: set to True to display the editor""" | 531 @param edit: set to True to display the editor""" |
530 if edit: | 532 if edit: |
533 if self.editbox and self.editbox.getVisible(): | |
534 self.editbox.setFocus(True) | |
535 return | |
531 if self.empty or self.xhtml: | 536 if self.empty or self.xhtml: |
532 if not self.editbox: | 537 def cb(result): |
533 | 538 self._updateContent(result == richtext.CANCEL) |
534 def cb(result): | 539 |
535 self._updateContent(result == richtext.CANCEL) | 540 options = ('no_recipient', 'no_sync_unibox', 'no_style', 'update_msg', 'no_close') |
536 | 541 editor = richtext.RichTextEditor(self._blog_panel.host, self.panel, cb, options=options) |
537 options = ('no_recipient', 'no_sync_unibox', 'no_style', 'update_msg', 'no_close') | 542 editor.setWidth('100%') |
538 editor = richtext.RichTextEditor(self._blog_panel.host, self.panel, cb, options=options) | 543 self.editbox = editor.textarea |
539 editor.setWidth('100%') | |
540 self.editbox = editor.textarea | |
541 | |
542 editor.setVisible(True) # needed to build the toolbar | 544 editor.setVisible(True) # needed to build the toolbar |
543 if self.editable_content[0]: | 545 if self.editable_content[0]: |
544 self._blog_panel.host.bridge.call('syntaxConvert', lambda d: self._setOriginalText(d, editor), | 546 self._blog_panel.host.bridge.call('syntaxConvert', lambda d: self._setOriginalText(d, editor), |
545 self.editable_content[0], self.editable_content[1]) | 547 self.editable_content[0], self.editable_content[1]) |
546 else: | 548 else: |
588 _dialog = ConfirmDialog(confirm_cb, text="Do you really want to delete this %s?" % target) | 590 _dialog = ConfirmDialog(confirm_cb, text="Do you really want to delete this %s?" % target) |
589 _dialog.show() | 591 _dialog.show() |
590 | 592 |
591 def _comment(self): | 593 def _comment(self): |
592 """Add an empty entry for a new comment""" | 594 """Add an empty entry for a new comment""" |
595 if self._current_comment: | |
596 self._current_comment.editbox.setFocus(True) | |
597 return | |
593 data = {'id': str(time()), | 598 data = {'id': str(time()), |
594 'new': True, | 599 'new': True, |
595 'type': 'comment', | 600 'type': 'comment', |
596 'author': self._blog_panel.host.whoami.bare, | 601 'author': self._blog_panel.host.whoami.bare, |
597 'service': self.service, | 602 'service': self.service, |
598 'node': self.node | 603 'node': self.node |
599 } | 604 } |
600 entry = self._blog_panel.addEntry(data) | 605 entry = self._blog_panel.addEntry(data) |
601 entry._parent_entry = self | 606 entry._parent_entry = self |
607 self._current_comment = entry | |
602 entry.setEntryDialog(edit=True) | 608 entry.setEntryDialog(edit=True) |
603 | 609 |
604 | 610 |
605 class MicroblogPanel(base_widget.LiberviaWidget): | 611 class MicroblogPanel(base_widget.LiberviaWidget): |
606 warning_msg_public = "This message will be PUBLIC and everybody will be able to see it, even people you don't know" | 612 warning_msg_public = "This message will be PUBLIC and everybody will be able to see it, even people you don't know" |