Commit 38891274 authored by Andreas Jung's avatar Andreas Jung

- Collector #628: Applied patch to fix several textarea resize

       problems.
parent 27d54537
......@@ -71,6 +71,9 @@ Zope Changes
Bugs Fixed
- Collector #628: Applied patch to fix several textarea resize
problems.
- Collector #954: clear() method of TopicIndex removed all filter sets
instead of clearing them.
......
......@@ -91,7 +91,7 @@ button in order for some changes to take effect.
</div>
</td>
<td align="left" valign="top">
<input type="text" name="dtpref_rows" value="&dtml-rows;" size="6" />
<input type="text" name="dtpref_rows:int" value="&dtml-rows;" size="6" />
</td>
</tr>
</table>
......@@ -102,14 +102,12 @@ button in order for some changes to take effect.
<div class="form-help">
<dtml-if expr="cols[-1]=='%'">
<textarea name="data:text" wrap="off" style="width:&dtml-cols;"
rows="&dtml-rows;"
>This is a sample edit textarea.</textarea>
<textarea name="data:text" rows="&dtml-rows;" style="width: &dtml-cols;;">
<dtml-else>
<textarea name="data:text" wrap="off" cols="&dtml-cols;"
rows="&dtml-rows;"
>This is a sample edit textarea.</textarea>
<textarea name="data:text" cols="&dtml-cols;" rows="&dtml-rows;">
</dtml-if>
This is a sample edit textarea.
</textarea>
</div>
</dtml-let>
......
......@@ -12,8 +12,8 @@
##############################################################################
__doc__='''Machinery to support through-the-web editing
$Id: DT_UI.py,v 1.13 2002/08/26 13:30:18 Brian Exp $'''
__version__='$Revision: 1.13 $'[11:-2]
$Id: DT_UI.py,v 1.14 2003/07/06 10:43:46 andreasjung Exp $'''
__version__='$Revision: 1.14 $'[11:-2]
from DT_HTML import HTML
......@@ -25,9 +25,6 @@ HTML.document_template_edit_footer=(
"""<FONT SIZE="-1">
<I><A HREF="http://www.zope.com">
&copy; 2002 Zope Corporation</A></I></FONT>""")
HTML.document_template_edit_width=58
HTML._manage_editForm = HTML(
"""<HTML>
<HEAD>
......@@ -41,9 +38,15 @@ HTML._manage_editForm = HTML(
Document template source:
<center>
<br>
<TEXTAREA NAME="data:text" cols="<!--#var document_template_edit_width-->"
rows="20"><!--#var __str__--></TEXTAREA>
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if expr="cols[-1]=='%'">
<textarea name="data:text" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="data:text" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-var __str__></textarea>
</dtml-let>
<br>
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change">
<INPUT NAME=SUBMIT TYPE="RESET" VALUE="Reset">
......
......@@ -12,7 +12,7 @@
##############################################################################
"""DTML Document objects."""
__version__='$Revision: 1.48 $'[11:-2]
__version__='$Revision: 1.49 $'[11:-2]
from ZPublisher.Converters import type_converters
from Globals import HTML, DTMLFile, MessageDialog
......@@ -55,7 +55,7 @@ class DTMLDocument(PropertyManager, DTMLMethod):
),
)
def manage_edit(self,data,title,SUBMIT='Change',dtpref_cols='50',
def manage_edit(self,data,title,SUBMIT='Change',dtpref_cols='100%',
dtpref_rows='20',REQUEST=None):
"""
Replaces a Documents contents with Data, Title with Title.
......
......@@ -12,7 +12,7 @@
##############################################################################
"""DTML Method objects."""
__version__='$Revision: 1.80 $'[11:-2]
__version__='$Revision: 1.81 $'[11:-2]
import History
from Globals import HTML, DTMLFile, MessageDialog
......@@ -220,21 +220,19 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
def _er(self,data,title,SUBMIT,dtpref_cols,dtpref_rows,REQUEST):
dr,dc = self._size_changes[SUBMIT]
rows=str(max(1,int(dtpref_rows)+dr))
if dtpref_cols[-1]=='%':
cols= str(min(100, max(25,int(dtpref_cols[:-1])+dc)))+'%'
rows = str(max(1, int(dtpref_rows) + dr))
cols = str(dtpref_cols)
if cols.endswith('%'):
cols = str(min(100, max(25, int(cols[:-1]) + dc))) + '%'
else:
cols=str(max(35,int(dtpref_cols)+dc))
e=(DateTime('GMT') + 365).rfc822()
resp=REQUEST['RESPONSE']
resp.setCookie('dtpref_rows',str(rows),path='/',expires=e)
resp.setCookie('dtpref_cols',str(cols),path='/',expires=e)
return self.manage_main(
self,REQUEST,title=title,__str__=self.quotedHTML(data),
dtpref_cols=cols,dtpref_rows=rows)
cols = str(max(35, int(cols) + dc))
e = (DateTime("GMT") + 365).rfc822()
setCookie = REQUEST["RESPONSE"].setCookie
setCookie("dtpref_rows", rows, path='/', expires=e)
setCookie("dtpref_cols", cols, path='/', expires=e)
REQUEST.other.update({"dtpref_cols":cols, "dtpref_rows":rows})
return self.manage_main(self, REQUEST, title=title,
__str__=self.quotedHTML(data))
def manage_edit(self,data,title,SUBMIT='Change',dtpref_cols='100%',
dtpref_rows='20',REQUEST=None):
......
......@@ -25,16 +25,14 @@ the <em>browse</em> button to select a local file to upload.
<tr>
<td align="left" valign="top" colspan="2">
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')">
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if expr="cols[-1]=='%'">
<textarea name="data:text" wrap="off" style="width:&dtml-cols;"
rows="<dtml-var dtpref_rows missing="20" html_quote>"
><dtml-var __str__></textarea>
<textarea name="data:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="data:text" wrap="off" cols="&dtml-cols;"
rows="<dtml-var dtpref_rows missing="20" html_quote>"
><dtml-var __str__></textarea>
</dtml-if>
rows="&dtml-rows;"><dtml-var __str__></textarea>
</dtml-let>
</td>
</tr>
......
......@@ -52,9 +52,15 @@ text type and small enough to be edited in a text area.
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<textarea name="filedata:text" wrap="off" style="width: 100%;"<dtml-if
dtpref_cols> cols="&dtml-dtpref_cols;"<dtml-else
> cols="50"</dtml-if><dtml-if dtpref_rows> rows="&dtml-dtpref_rows;"<dtml-else> rows="20"</dtml-if>><dtml-var __str__ html_quote></textarea>
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="filedata:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="filedata:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-var __str__ html_quote></textarea>
</dtml-let>
</div>
</td>
</tr>
......
......@@ -15,7 +15,7 @@
Zope object encapsulating a Page Template.
"""
__version__='$Revision: 1.44 $'[11:-2]
__version__='$Revision: 1.45 $'[11:-2]
import os, AccessControl, Acquisition, sys
from types import StringType
......@@ -138,33 +138,25 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
return self.pt_editForm(manage_tabs_message=message)
def pt_changePrefs(self, REQUEST, height=None, width=None,
dtpref_cols='100%', dtpref_rows='20'):
dtpref_cols="100%", dtpref_rows="20"):
"""Change editing preferences."""
szchh = {'Taller': 1, 'Shorter': -1, None: 0}
szchw = {'Wider': 5, 'Narrower': -5, None: 0}
# The <textarea> can have dimensions expressed in percentages
if type(width) is StringType and width.endswith('%'):
cols = int(width[:-1])
cols = max(cols, 25) # Min width 25%
cols = max(cols, 100) # Max width 100%
cols = "%d%%" % cols # Add percent sign back on
elif type(width) is StringType and dtpref_cols.endswith('%'):
cols = int(dtpref_cols[:-1])
cols = max(cols + szchw.get(width, 0), 25) # Min width 25%
cols = min(cols, 100) # Max width 100%
cols = "%d%%" % cols # Add percent sign back on
else: # Absolute width
try: cols = int(width)
except: cols = max(40, int(dtpref_cols) + szchw.get(width, 0))
try: rows = int(height)
except: rows = max(1, int(dtpref_rows) + szchh.get(height, 0))
e = (DateTime('GMT') + 365).rfc822()
setc = REQUEST['RESPONSE'].setCookie
setc('dtpref_rows', str(rows), path='/', expires=e)
setc('dtpref_cols', str(cols), path='/', expires=e)
REQUEST.form.update({'dtpref_cols': cols, 'dtpref_rows': rows})
dr = {"Taller":5, "Shorter":-5}.get(height, 0)
dc = {"Wider":5, "Narrower":-5}.get(width, 0)
if isinstance(height, int): dtpref_rows = height
if isinstance(width, int) or \
isinstance(width, str) and width.endswith('%'):
dtpref_cols = width
rows = str(max(1, int(dtpref_rows) + dr))
cols = str(dtpref_cols)
if cols.endswith('%'):
cols = str(min(100, max(25, int(cols[:-1]) + dc))) + '%'
else:
cols = str(max(35, int(cols) + dc))
e = (DateTime("GMT") + 365).rfc822()
setCookie = REQUEST["RESPONSE"].setCookie
setCookie("dtpref_rows", rows, path='/', expires=e)
setCookie("dtpref_cols", cols, path='/', expires=e)
REQUEST.other.update({"dtpref_cols":cols, "dtpref_rows":rows})
return self.manage_main()
def ZScriptHTML_tryParams(self):
......
......@@ -68,17 +68,16 @@
<tr>
<td align="left" valign="top" colspan="4"
tal:define="width request/form/dtpref_cols | request/dtpref_cols | string:100%;
tal:define="width request/dtpref_cols | string:100%;
relative_width python:str(width).endswith('%')">
<textarea name="text:text" wrap="off" style="width:100%;" rows="20"
<textarea name="text:text" wrap="off" style="width: 100%;" rows="20"
tal:condition="relative_width"
tal:attributes="style string:width:$width;
rows request/form/dtpref_rows | request/dtpref_rows | default"
tal:attributes="style string:width: $width;;;
rows request/dtpref_rows | default"
tal:content="body">Template Body</textarea>
<textarea name="text:text" wrap="off" rows="20" cols="50"
tal:condition="not:relative_width"
tal:attributes="cols width;
rows request/form/dtpref_rows | request/dtpref_rows | default"
tal:attributes="cols width; rows request/dtpref_rows | default"
tal:content="body">Template Body</textarea>
</td>
</tr>
......
......@@ -17,7 +17,7 @@ This product provides support for Script objects containing restricted
Python code.
"""
__version__='$Revision: 1.46 $'[11:-2]
__version__='$Revision: 1.47 $'[11:-2]
import sys, os, traceback, re, marshal, new
from Globals import DTMLFile, MessageDialog, package_home
......@@ -164,20 +164,26 @@ class PythonScript(Script, Historical, Cacheable):
manage_tabs_message=message)
def ZPythonScriptHTML_changePrefs(self, REQUEST, height=None, width=None,
dtpref_cols='50', dtpref_rows='20'):
dtpref_cols="100%", dtpref_rows="20"):
"""Change editing preferences."""
szchh = {'Taller': 1, 'Shorter': -1, None: 0}
szchw = {'Wider': 5, 'Narrower': -5, None: 0}
try: rows = int(height)
except: rows = max(1, int(dtpref_rows) + szchh.get(height, 0))
try: cols = int(width)
except: cols = max(40, int(dtpref_cols) + szchw.get(width, 0))
e = (DateTime('GMT') + 365).rfc822()
setc = REQUEST['RESPONSE'].setCookie
setc('dtpref_rows', str(rows), path='/', expires=e)
setc('dtpref_cols', str(cols), path='/', expires=e)
REQUEST.form.update({'dtpref_cols': cols, 'dtpref_rows': rows})
return apply(self.manage_main, (self, REQUEST), REQUEST.form)
dr = {"Taller":5, "Shorter":-5}.get(height, 0)
dc = {"Wider":5, "Narrower":-5}.get(width, 0)
if isinstance(height, int): dtpref_rows = height
if isinstance(width, int) or \
isinstance(width, str) and width.endswith('%'):
dtpref_cols = width
rows = str(max(1, int(dtpref_rows) + dr))
cols = str(dtpref_cols)
if cols.endswith('%'):
cols = str(min(100, max(25, int(cols[:-1]) + dc))) + '%'
else:
cols = str(max(35, int(cols) + dc))
e = (DateTime("GMT") + 365).rfc822()
setCookie = REQUEST["RESPONSE"].setCookie
setCookie("dtpref_rows", rows, path='/', expires=e)
setCookie("dtpref_cols", cols, path='/', expires=e)
REQUEST.other.update({"dtpref_cols":cols, "dtpref_rows":rows})
return self.manage_main(self, REQUEST)
def ZScriptHTML_tryParams(self):
"""Parameters to test the script with."""
......
......@@ -82,9 +82,15 @@
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<textarea name="body:text" wrap="off" style="width: 100%;"
cols=<dtml-var dtpref_cols html_quote missing="50">
rows=<dtml-var dtpref_rows html_quote missing="20">>&dtml-body;</textarea>
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="body:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="body:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;">&dtml-body;</textarea>
</dtml-let>
</div>
</td>
</tr>
......
......@@ -28,10 +28,14 @@ probably need to manage Zope using its raw IP address to fix things.
(<strong>host/path</strong>),
or a set of hosts (<strong>*.host/path</strong>).
<div style="width: 100%;">
<textarea name="map_text:text" wrap="off" style="width: 100%;"<dtml-if
dtpref_cols> cols="&dtml-dtpref_cols;"<dtml-else
> cols="50"</dtml-if><dtml-if dtpref_rows> rows="&dtml-dtpref_rows;"<dtml-else> rows="20"</dtml-if>><dtml-in
lines>&dtml-sequence-item;
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="map_text:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="map_text:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-in lines>&dtml-sequence-item;
</dtml-in></textarea>
</div>
</td>
......
#
# $Id: ZReST.py,v 1.6 2003/02/22 07:08:12 andreasjung Exp $
# $Id: ZReST.py,v 1.7 2003/07/06 10:44:11 andreasjung Exp $
#
''' ReStructuredText Product for Zope
......@@ -121,14 +121,18 @@ class ZReST(Item, PropertyManager, Historical, Implicit, Persistent):
}
def _er(self, data, SUBMIT, dtpref_cols, dtpref_rows, REQUEST):
dr,dc = self._size_changes[SUBMIT]
rows=max(1,int(dtpref_rows)+dr)
cols=max(40,int(dtpref_cols)+dc)
e=(DateTime('GMT') + 365).rfc822()
resp=REQUEST['RESPONSE']
resp.setCookie('dtpref_rows',str(rows),path='/',expires=e)
resp.setCookie('dtpref_cols',str(cols),path='/',expires=e)
return self.manage_main(self, REQUEST, __str__=self.quotedHTML(data),
dtpref_cols=cols, dtpref_rows=rows)
rows = str(max(1, int(dtpref_rows) + dr))
cols = str(dtpref_cols)
if cols.endswith('%'):
cols = str(min(100, max(25, int(cols[:-1]) + dc))) + '%'
else:
cols = str(max(35, int(cols) + dc))
e = (DateTime("GMT") + 365).rfc822()
setCookie = REQUEST["RESPONSE"].setCookie
setCookie("dtpref_rows", rows, path='/', expires=e)
setCookie("dtpref_cols", cols, path='/', expires=e)
REQUEST.other.update({"dtpref_cols":cols, "dtpref_rows":rows})
return self.manage_main(self, REQUEST, __str__=self.quotedHTML(data))
security.declarePrivate('quotedHTML')
def quotedHTML(self,
text=None,
......
......@@ -29,11 +29,15 @@ the <em>browse</em> button to select a local file to upload.
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<textarea name="data:text" wrap="off" style="width: 100%;"<dtml-if
dtpref_cols> cols="<dtml-var dtpref_cols>"<dtml-else
> cols="50"</dtml-if><dtml-if dtpref_rows> rows="<dtml-var
dtpref_rows>"<dtml-else> rows="20"</dtml-if>><dtml-var
__str__></textarea>
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="data:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="data:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-var __str__></textarea>
</dtml-let>
</div>
</td>
</tr>
......
......@@ -57,11 +57,15 @@
</tr>
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<textarea name="template:text" wrap="off" style="width: 100%;"
cols=<dtml-var sql_pref__cols html_quote missing="60">
rows=<dtml-var sql_pref__rows html_quote missing="20">>&dtml-src;</textarea>
</div>
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if expr="cols[-1]=='%'">
<textarea name="template:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="template:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;">&dtml-src;</textarea>
</dtml-let>
</td>
</tr>
......
......@@ -13,7 +13,7 @@
__doc__='''Generic Database adapter'''
__version__='$Revision: 1.110 $'[11:-2]
__version__='$Revision: 1.111 $'[11:-2]
import OFS.SimpleItem, Aqueduct, RDB, re
import DocumentTemplate, marshal, md5, base64, Acquisition, os
......@@ -124,25 +124,25 @@ class DA(
}
def _er(self,title,connection_id,arguments,template,
SUBMIT,sql_pref__cols,sql_pref__rows,REQUEST):
SUBMIT,dtpref_cols,dtpref_rows,REQUEST):
dr,dc = self._size_changes[SUBMIT]
rows=max(1,atoi(sql_pref__rows)+dr)
cols=max(40,atoi(sql_pref__cols)+dc)
e=(DateTime('GMT') + 365).rfc822()
resp=REQUEST['RESPONSE']
resp.setCookie('sql_pref__rows',str(rows),path='/',expires=e)
resp.setCookie('sql_pref__cols',str(cols),path='/',expires=e)
return self.manage_main(
self,REQUEST,
title=title,
arguments_src=arguments,
connection_id=connection_id,
src=template,
sql_pref__cols=cols,sql_pref__rows=rows)
rows = str(max(1, int(dtpref_rows) + dr))
cols = str(dtpref_cols)
if cols.endswith('%'):
cols = str(min(100, max(25, int(cols[:-1]) + dc))) + '%'
else:
cols = str(max(35, int(cols) + dc))
e = (DateTime("GMT") + 365).rfc822()
setCookie = REQUEST["RESPONSE"].setCookie
setCookie("dtpref_rows", rows, path='/', expires=e)
setCookie("dtpref_cols", cols, path='/', expires=e)
REQUEST.other.update({"dtpref_cols":cols, "dtpref_rows":rows})
return self.manage_main(self, REQUEST, title=title,
arguments_src=arguments,
connection_id=connection_id, src=template)
def manage_edit(self,title,connection_id,arguments,template,
SUBMIT='Change',sql_pref__cols='50', sql_pref__rows='20',
SUBMIT='Change', dtpref_cols='100%', dtpref_rows='20',
REQUEST=None):
"""Change database method properties
......@@ -159,7 +159,7 @@ class DA(
if self._size_changes.has_key(SUBMIT):
return self._er(title,connection_id,arguments,template,
SUBMIT,sql_pref__cols,sql_pref__rows,REQUEST)
SUBMIT,dtpref_cols,dtpref_rows,REQUEST)
if self.wl_isLocked():
raise ResourceLockedError, 'SQL Method is locked via WebDAV'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment