Skip to content

Commit

Permalink
Backported
Browse files Browse the repository at this point in the history
r26488 | srichter | 2004-07-13 13:13:19 -0400 (Tue, 13 Jul 2004) | 2 lines
r26489 | srichter | 2004-07-13 13:14:44 -0400 (Tue, 13 Jul 2004) | 3 lines
r26490 | srichter | 2004-07-13 13:15:34 -0400 (Tue, 13 Jul 2004) | 2 lines
r26491 | srichter | 2004-07-13 13:16:12 -0400 (Tue, 13 Jul 2004) | 2 lines
r26492 | srichter | 2004-07-13 13:18:09 -0400 (Tue, 13 Jul 2004) | 2 lines
r26493 | srichter | 2004-07-13 13:19:25 -0400 (Tue, 13 Jul 2004) | 2 lines
r26494 | srichter | 2004-07-13 13:21:02 -0400 (Tue, 13 Jul 2004) | 4 lines
r26495 | srichter | 2004-07-13 13:23:17 -0400 (Tue, 13 Jul 2004) | 2 lines
r26496 | srichter | 2004-07-13 13:24:35 -0400 (Tue, 13 Jul 2004) | 2 lines
r26497 | srichter | 2004-07-13 13:25:02 -0400 (Tue, 13 Jul 2004) | 2 lines
r26498 | srichter | 2004-07-13 13:26:37 -0400 (Tue, 13 Jul 2004) | 5 lines
r26499 | srichter | 2004-07-13 13:31:56 -0400 (Tue, 13 Jul 2004) | 2 lines
  • Loading branch information
strichter committed Aug 12, 2004
1 parent ffdeffd commit 5f5abc9
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions editingwidgets.py
@@ -0,0 +1,57 @@
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id$
"""
__metaclass__ = type

from zope.interface import implements
from zope.app.form.interfaces import IInputWidget
from zope.app.form.browser import TextAreaWidget
from zope.app.form.browser.widget import renderElement
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile

class SimpleEditingWidget(TextAreaWidget):
"""Improved textarea editing, with async saving using JavaScript."""

implements(IInputWidget)

default = ""
width = 60
height = 15
extra=""
style="width: 98%; font-family: monospace;"
rowTemplate = ViewPageTemplateFile("simpleeditingrow.pt")
rowFragment = ViewPageTemplateFile("simpleeditingrowfragment.pt")

def _toFieldValue(self, value):
if self.context.min_length and not value:
return None
return value

def __call__(self):
return renderElement("textarea",
name=self.name,
id=self.name,
cssClass=self.cssClass,
rows=self.height,
cols=self.width,
style=self.style,
contents=self._getFormValue(),
extra=self.extra)

def contents(self):
"""Make the contents available to the template"""
return self._getFormData()

0 comments on commit 5f5abc9

Please sign in to comment.