Fix hover help for matrix

This commit is contained in:
Graham Knop 2007-10-04 19:23:08 +00:00
parent 183242a6ce
commit 3f5ca61c12
11 changed files with 318 additions and 61 deletions

View file

@ -257,9 +257,9 @@ sub displayFormWithWrapper {
my $self = shift;
if ($self->passUiLevelCheck) {
my ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext) = $self->prepareWrapper;
my $hoverCode = $self->getHoverCode($hoverHelp, $self->get('id') . '_wrapper');
$hoverHelp &&= '<div class="wg-hoverhelp">' . $hoverHelp . '</div>';
return '<tr'.$rowClass.'>
<td'.$labelClass.' valign="top" style="width: 25%;">'.$self->get("label") . $hoverCode . '</td>
<td'.$labelClass.' valign="top" style="width: 25%;">'.$self->get("label") . $hoverHelp . '</td>
<td valign="top"'.$fieldClass.' style="width: 75%;">'.$self->displayForm().$subtext."</td>
</tr>\n";
} else {
@ -542,8 +542,9 @@ sub prepareWrapper {
$labelClass = qq| class="$labelClass" | if($self->get("labelClass"));
my $fieldClass = $self->get("fieldClass");
$fieldClass = qq| class="$fieldClass" | if($self->get("fieldClass"));
my $hoverHelp = $self->get("hoverHelp");
my $subtext = $self->get("subtext");
my $hoverHelp = $self->get("hoverHelp") || '';
$hoverHelp =~ s/^\s+//;
my $subtext = $self->get("subtext");
$subtext = qq| <span class="formSubtext">$subtext</span>| if ($subtext);
return ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext);
}
@ -625,9 +626,9 @@ sub toHtmlWithWrapper {
if ($self->passUiLevelCheck) {
my $rawField = $self->toHtml(); # has to be called before prepareWrapper for some controls, namely captcha.
my ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext) = $self->prepareWrapper;
my $hoverCode = $self->getHoverCode($hoverHelp, $self->get('id') . '_description');
$hoverHelp &&= '<div class="wg-hoverhelp">' . $hoverHelp . '</div>';
return '<tr'.$rowClass.' id="'.$self->get("id").'_row">
<td'.$labelClass.' id="' . $self->get('id') . '_description" valign="top" style="width: 180px;"><label for="'.$self->get("id").'">'.$self->get("label").'</label>' . $hoverCode . '</td>
<td'.$labelClass.' valign="top" style="width: 180px;"><label for="'.$self->get("id").'">'.$self->get("label").'</label>' . $hoverHelp . '</td>
<td valign="top"'.$fieldClass.'>'.$rawField . $subtext . "</td>
</tr>\n";
} else {
@ -637,42 +638,6 @@ sub toHtmlWithWrapper {
#-------------------------------------------------------------------
=head2 getHoverCode ( hoverHelp, attachId )
Generated the code to add hover help to html elements.
=head3 hoverHelp
The text in include in the hover help.
=head3 attachId
The id of the HTML element to attach the hover help to.
=cut
sub getHoverCode {
my $self = shift;
my $style = $self->session->style;
my $url = $self->session->url;
my $hoverHelp = shift;
my $attachId = shift;
$hoverHelp =~ s/^\s+//;
return ''
unless $hoverHelp;
my $hover = '<div class="wg-hoverhelp">' . $hoverHelp . '</div>';
$style->setLink($url->extras('/yui/build/container/assets/container.css'),{ type=>'text/css', rel=>"stylesheet" });
$style->setLink($url->extras('/hoverhelp.css'),{ type=>'text/css', rel=>"stylesheet" });
$style->setScript($url->extras('/yui/build/yahoo/yahoo-min.js'),{ type=>'text/javascript' });
$style->setScript($url->extras('/yui/build/dom/dom-min.js'),{ type=>'text/javascript' });
$style->setScript($url->extras('/yui/build/event/event-min.js'),{ type=>'text/javascript' });
$style->setScript($url->extras('/yui/build/container/container-min.js'),{ type=>'text/javascript' });
$style->setScript($url->extras('/hoverhelp.js'),{ type=>'text/javascript' });
return $hover;
}
#-------------------------------------------------------------------
=head2 passUiLevelCheck ( )
Renders the form field to HTML as a table row complete with labels, subtext, hoverhelp, etc.