[Zope3-checkins] SVN: zope.formlib/trunk/src/zope/formlib/ fix
broken help handling,
and avoid broken JavaScript error messages in the
Fred L. Drake, Jr.
fdrake at gmail.com
Tue Aug 16 16:22:14 EDT 2005
Log message for revision 37970:
fix broken help handling, and avoid broken JavaScript error messages in the
JavaScript console of some browsers
Changed:
U zope.formlib/trunk/src/zope/formlib/pageform.pt
U zope.formlib/trunk/src/zope/formlib/subpageform.pt
-=-
Modified: zope.formlib/trunk/src/zope/formlib/pageform.pt
===================================================================
--- zope.formlib/trunk/src/zope/formlib/pageform.pt 2005-08-16 20:19:02 UTC (rev 37969)
+++ zope.formlib/trunk/src/zope/formlib/pageform.pt 2005-08-16 20:22:14 UTC (rev 37970)
@@ -16,26 +16,15 @@
<script type="text/javascript"><!--
function toggleFormFieldHelp(ob,state) {
- ob = ob.nextSibling;
- while (ob && ob.className != 'field') {
- ob = ob.nextSibling;
+ // ob is the label element
+ var field = ob.form[ob.htmlFor];
+ if (field) {
+ field.style.visibility = state && 'hidden' || 'visible';
+ var help = document.getElementById("field-help-for-" + field.name);
+ if (help) {
+ help.style.visibility = state && 'visible' || 'hidden';
+ }
}
- var td = ob;
-
- ob = ob.firstChild;
- while (ob && ob.className != 'form-fields-help')
- ob = ob.nextSibling;
- if (ob) {
- ob.style.visibility = state && 'visible' || 'hidden';
- }
-
- ob = td.firstChild;
- while (ob && ob.className != 'widget') {
- ob = ob.nextSibling;
- }
- if (ob) {
- ob.style.visibility = state && 'hidden' || 'visible';
- }
}
//-->
@@ -105,6 +94,7 @@
i18n:translate=""
tal:content="hint"
tal:condition="hint"
+ tal:attributes="id string:field-help-for-${widget/name}"
onclick="this.style.visibility='hidden';"
>Title of this content object.</div>
<div class="widget" tal:content="structure widget">
Modified: zope.formlib/trunk/src/zope/formlib/subpageform.pt
===================================================================
--- zope.formlib/trunk/src/zope/formlib/subpageform.pt 2005-08-16 20:19:02 UTC (rev 37969)
+++ zope.formlib/trunk/src/zope/formlib/subpageform.pt 2005-08-16 20:22:14 UTC (rev 37970)
@@ -4,26 +4,15 @@
<script type="text/javascript"><!--
function toggleFormFieldHelp(ob,state) {
- ob = ob.nextSibling;
- while (ob && ob.className != 'field') {
- ob = ob.nextSibling;
+ // ob is the label element
+ var field = ob.form[ob.htmlFor];
+ if (field) {
+ field.style.visibility = state && 'hidden' || 'visible';
+ var help = document.getElementById("field-help-for-" + field.name);
+ if (help) {
+ help.style.visibility = state && 'visible' || 'hidden';
+ }
}
- var td = ob;
-
- ob = ob.firstChild;
- while (ob && ob.className != 'form-fields-help')
- ob = ob.nextSibling;
- if (ob) {
- ob.style.visibility = state && 'visible' || 'hidden';
- }
-
- ob = td.firstChild;
- while (ob && ob.className != 'widget') {
- ob = ob.nextSibling;
- }
- if (ob) {
- ob.style.visibility = state && 'hidden' || 'visible';
- }
}
//-->
@@ -94,6 +83,7 @@
<div class="form-fields-help"
tal:content="hint"
tal:condition="hint"
+ tal:attributes="id string:field-help-for-${widget/name}"
onclick="this.style.visibility='hidden';"
i18n:translate=""
>Title of this content object.</div>
More information about the Zope3-Checkins
mailing list