yui tooltips for hoverhelp
This commit is contained in:
parent
f2d27f96e3
commit
1eabe1ea37
6 changed files with 58 additions and 483 deletions
|
|
@ -257,9 +257,10 @@ sub displayFormWithWrapper {
|
|||
my $self = shift;
|
||||
if ($self->passUiLevelCheck) {
|
||||
my ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext) = $self->prepareWrapper;
|
||||
return '<tr'.$rowClass.'>
|
||||
<td'.$labelClass.$hoverHelp.' valign="top" style="width: 25%;">'.$self->get("label").'</td>
|
||||
<td valign="top"'.$fieldClass.' style="width: 75%;">'.$self->displayForm().$subtext."</td>
|
||||
my $hoverCode = $self->getHoverCode($hoverHelp, $self->get('id') . '_wrapper');
|
||||
return '<tr'.$rowClass.'>
|
||||
<td'.$labelClass.' valign="top" style="width: 25%;">'.$self->get("label").'</td>
|
||||
<td valign="top"'.$fieldClass.' style="width: 75%;">'.$self->displayForm().$subtext.$hoverCode."</td>
|
||||
</tr>\n";
|
||||
} else {
|
||||
return $self->toHtmlAsHidden;
|
||||
|
|
@ -542,18 +543,6 @@ sub prepareWrapper {
|
|||
my $fieldClass = $self->get("fieldClass");
|
||||
$fieldClass = qq| class="$fieldClass" | if($self->get("fieldClass"));
|
||||
my $hoverHelp = $self->get("hoverHelp");
|
||||
$hoverHelp =~ s/\r/ /g;
|
||||
$hoverHelp =~ s/\n/ /g;
|
||||
$hoverHelp =~ s/&/& amp;/g;
|
||||
$hoverHelp =~ s/>/& gt;/g;
|
||||
$hoverHelp =~ s/</& lt;/g;
|
||||
$hoverHelp =~ s/&/&/g;
|
||||
$hoverHelp =~ s/>/>/g;
|
||||
$hoverHelp =~ s/</</g;
|
||||
$hoverHelp =~ s/"/"/g;
|
||||
$hoverHelp =~ s/'/\\'/g;
|
||||
$hoverHelp =~ s/^\s+//;
|
||||
$hoverHelp = qq| onmouseover="return escape('$hoverHelp')"| if ($hoverHelp);
|
||||
my $subtext = $self->get("subtext");
|
||||
$subtext = qq| <span class="formSubtext">$subtext</span>| if ($subtext);
|
||||
return ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext);
|
||||
|
|
@ -636,9 +625,10 @@ 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;
|
||||
return '<tr'.$rowClass.' id="'.$self->get("id").'_row">
|
||||
<td'.$labelClass.$hoverHelp.' valign="top" style="width: 180px;"><label for="'.$self->get("id").'">'.$self->get("label").'</label></td>
|
||||
<td valign="top"'.$fieldClass.'>'.$rawField.$subtext."</td>
|
||||
my $hoverCode = $self->getHoverCode($hoverHelp, $self->get('id') . '_description');
|
||||
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></td>
|
||||
<td valign="top"'.$fieldClass.'>'.$rawField . $subtext . $hoverCode . "</td>
|
||||
</tr>\n";
|
||||
} else {
|
||||
return $self->toHtmlAsHidden;
|
||||
|
|
@ -647,6 +637,41 @@ 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/\r/ /g;
|
||||
$hoverHelp =~ s/\n/ /g;
|
||||
$hoverHelp =~ s/'/\\'/g;
|
||||
$hoverHelp =~ s/^\s+//;
|
||||
my $hover = '<script type="text/javascript">var tooltip = new YAHOO.widget.Tooltip("' . $attachId . '_tooltip", { context: "' . $attachId . '", text: \'' . $hoverHelp . '\', autodismissdelay: 100000, width: "300px"});</script>';
|
||||
$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' });
|
||||
return $hover;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 passUiLevelCheck ( )
|
||||
|
||||
Renders the form field to HTML as a table row complete with labels, subtext, hoverhelp, etc.
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ Returns the HTML for this form object.
|
|||
|
||||
sub print {
|
||||
my $self = shift;
|
||||
return $self->{_header}.$self->{_data}.$self->{_footer}.'<script type="text/javascript" src="'.$self->session->url->extras('wz_tooltip.js').'"></script>';
|
||||
return $self->{_header}.$self->{_data}.$self->{_footer};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -248,7 +248,6 @@ sub print {
|
|||
$output .= $form;
|
||||
$output .= WebGUI::Form::formFooter($self->session,);
|
||||
$output .= '<script type="text/javascript">var numberOfTabs = '.($i-1).'; initTabs();</script>';
|
||||
$output .= '<script type="text/javascript" src="'.$self->session->url->extras('wz_tooltip.js').'"></script>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue