From 775fc1572af5a38a4da3861e3957f28487f1a737 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Mon, 17 Aug 2009 21:46:44 +0000 Subject: [PATCH] Plone CSS classes added to buttons. svn path=/plone.app.discussion/trunk/; revision=29108 --- plone/app/discussion/browser/comments.py | 37 +++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index baa913d..bb6f541 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -54,12 +54,44 @@ class View(BrowserView): '#' + str(comment_id)) class AutoResizeTextArea(TextAreaWidget): + """Textarea with autoresize CSS class. + """ klass = u'autoresize' def AutoResizeTextAreaFieldWidget(field, request): - """IFieldWidget factory for AutoResizeTextAreaWidget.""" + """IFieldWidget factory for AutoResizeTextAreaWidget. + """ return widget.FieldWidget(field, AutoResizeTextArea(request)) +class CommentButtonAction(button.ButtonAction): + """Comment button with Plone CSS style. + """ + +def commentButtonActionFactory(request, field): + """Comment button action factory. + """ + button = CommentButtonAction(request, field) + button.klass += " context" + return button + +class ReplyButtonAction(button.ButtonAction): + """Reply button with Plone CSS style. + """ + +def replyButtonActionFactory(request, field): + button = ReplyButtonAction(request, field) + button.klass += " context" + return button + +class CancelButtonAction(button.ButtonAction): + """Cancel button with Plone CSS style. + """ + +def cancelButtonActionFactory(request, field): + button = ReplyButtonAction(request, field) + button.klass += " standalone" + return button + class CommentForm(extensible.ExtensibleForm, form.Form): ignoreContext = True # don't use context to get widget data @@ -83,6 +115,9 @@ class CommentForm(extensible.ExtensibleForm, form.Form): # XXX: This is ugly. The fields should be omitted, not hidden. self.widgets['author_name'].mode = interfaces.HIDDEN_MODE self.widgets['author_email'].mode = interfaces.HIDDEN_MODE + self.buttons['comment'].actionFactory = commentButtonActionFactory + self.buttons['reply'].actionFactory = replyButtonActionFactory + self.buttons['cancel'].actionFactory = cancelButtonActionFactory @button.buttonAndHandler(_(u"Comment")) def handleComment(self, action):