line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Tooltip::Javascript; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
36619
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
813
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
12
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
13
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# This allows declaration use HTML::Tooltip::Javascript ':all'; |
16
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
17
|
|
|
|
|
|
|
# will save memory. |
18
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
) ] ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @EXPORT = qw( |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Preloaded methods go here. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
33
|
1
|
|
|
1
|
1
|
28
|
my ($class, %arg) = @_; |
34
|
1
|
|
|
|
|
3
|
my $self = {}; |
35
|
1
|
|
50
|
|
|
5
|
$self->{javascript_dir} = $arg{javascript_dir} || '/'; |
36
|
1
|
50
|
|
|
|
8
|
$self->{javascript_dir} .= "/" unless ($self->{javascript_dir} =~ m:/$:); |
37
|
1
|
|
50
|
|
|
4
|
$self->{options} = $arg{options} || {}; |
38
|
1
|
|
|
|
|
4
|
bless($self, $class); |
39
|
1
|
|
|
|
|
5
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub tooltip { |
43
|
2
|
|
|
2
|
1
|
5852
|
my ($self, $tip, $options) = @_; |
44
|
|
|
|
|
|
|
|
45
|
2
|
50
|
66
|
|
|
19
|
return '' if (!$tip && !$self->{options}->{default_tip}); |
46
|
|
|
|
|
|
|
|
47
|
2
|
100
|
|
|
|
8
|
$tip = $self->{options}->{default_tip} if (!$tip); |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
6
|
$tip =~ s/\\/\\\\/g; |
50
|
2
|
|
|
|
|
5
|
$tip =~ s/['"]/\\'/g; |
51
|
2
|
|
|
|
|
5
|
$tip =~ s/[\n\r]//g; |
52
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
3
|
my %opts = %{$self->{options}}; |
|
2
|
|
|
|
|
22
|
|
54
|
2
|
|
|
|
|
11
|
foreach my $o (keys %$options) { |
55
|
8
|
|
|
|
|
14
|
$opts{$o} = $options->{$o}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
15
|
my $text = ' onmouseover="'; |
59
|
2
|
|
|
|
|
8
|
my %can_be_zero = ( |
60
|
|
|
|
|
|
|
borderwidth => 1, |
61
|
|
|
|
|
|
|
delay => 1, |
62
|
|
|
|
|
|
|
); |
63
|
2
|
|
|
|
|
10
|
foreach my $o (keys %opts) { |
64
|
18
|
100
|
|
|
|
34
|
next if ($o eq 'default_tip'); |
65
|
16
|
50
|
|
|
|
27
|
next if ($o eq 'function'); |
66
|
16
|
100
|
|
|
|
25
|
if ($can_be_zero{$o}) { |
67
|
2
|
100
|
|
|
|
8
|
next if (!defined $opts{$o}); |
68
|
|
|
|
|
|
|
} else { |
69
|
14
|
100
|
|
|
|
29
|
next if (!$opts{$o}); |
70
|
|
|
|
|
|
|
} |
71
|
8
|
|
|
|
|
13
|
my $param = uc($o); |
72
|
8
|
|
|
|
|
10
|
my $val = $opts{$o}; |
73
|
|
|
|
|
|
|
|
74
|
8
|
50
|
|
|
|
20
|
if ($o !~ m/fix/i) { |
75
|
8
|
50
|
66
|
|
|
74
|
$val = "'$val'" unless |
|
|
|
66
|
|
|
|
|
76
|
|
|
|
|
|
|
($val =~ m/^\d+$/ || $val =~ m/^true$/i || $val =~ m/^false$/); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
8
|
|
|
|
|
21
|
$text .= "this.T_$param=$val; "; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
2
|
50
|
|
|
|
6
|
if ($opts{'function'}) { |
83
|
0
|
|
|
|
|
0
|
$text .= "return escape($tip);"; |
84
|
|
|
|
|
|
|
} else { |
85
|
2
|
|
|
|
|
6
|
$text .= "return escape('$tip');"; |
86
|
|
|
|
|
|
|
} |
87
|
2
|
|
|
|
|
3
|
$text .= '" '; |
88
|
2
|
|
|
|
|
10
|
return $text; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub at_end($) { |
92
|
1
|
|
|
1
|
1
|
518
|
my ($self) = @_; |
93
|
1
|
|
|
|
|
4
|
my $js = $self->{javascript_dir} . 'wz_tooltip.js'; |
94
|
1
|
|
|
|
|
5
|
return qq(); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |