| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package JQuery::Accordion ; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4647
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
850
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
|
9
|
0
|
|
|
0
|
1
|
|
my $this = shift; |
|
10
|
0
|
|
0
|
|
|
|
my $class = ref($this) || $this; |
|
11
|
0
|
|
|
|
|
|
my $my ; |
|
12
|
0
|
|
|
|
|
|
$my->{param}{headers} = [] ; |
|
13
|
0
|
|
|
|
|
|
$my->{param}{texts} = [] ; |
|
14
|
0
|
|
|
|
|
|
%{$my->{param}} = @_ ; |
|
|
0
|
|
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
die "No id defined for Accordion" unless $my->{param}{id} =~ /\S/ ; |
|
16
|
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
bless $my, $class; |
|
18
|
0
|
0
|
|
|
|
|
if ($my->{param}{css}) { |
|
19
|
0
|
|
|
|
|
|
push @{$my->{css}},$my->{param}{css} ; |
|
|
0
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
} |
|
21
|
0
|
|
|
|
|
|
$my->add_to_jquery ; |
|
22
|
0
|
|
|
|
|
|
return $my ; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub add_to_jquery { |
|
26
|
0
|
|
|
0
|
0
|
|
my $my = shift ; |
|
27
|
0
|
|
|
|
|
|
my $jquery = $my->{param}{addToJQuery} ; |
|
28
|
0
|
0
|
|
|
|
|
if (defined $jquery) { |
|
29
|
0
|
|
|
|
|
|
$jquery->add($my) ; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub id { |
|
34
|
0
|
|
|
0
|
0
|
|
my $my = shift ; |
|
35
|
0
|
|
|
|
|
|
return $my->{param}{id} ; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub packages_needed { |
|
40
|
0
|
|
|
0
|
0
|
|
my $my = shift ; |
|
41
|
0
|
|
|
|
|
|
return ('interface/interface.js') ; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub get_css { |
|
45
|
0
|
|
|
0
|
0
|
|
my $my = shift ; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $id = $my->id ; |
|
48
|
0
|
|
0
|
|
|
|
my $panelWidth = $my->{param}{panelWidth} || '400px' ; |
|
49
|
0
|
|
0
|
|
|
|
my $panelHeight = $my->{param}{panelHeight} || '200px' ; |
|
50
|
|
|
|
|
|
|
# The position was absolute |
|
51
|
0
|
|
|
|
|
|
my $css=<
|
|
52
|
|
|
|
|
|
|
#$id { |
|
53
|
|
|
|
|
|
|
width: $panelWidth ; |
|
54
|
|
|
|
|
|
|
border: 1px solid #6CAF00; |
|
55
|
|
|
|
|
|
|
position: relative; |
|
56
|
|
|
|
|
|
|
left: 10px; |
|
57
|
|
|
|
|
|
|
top: 10px; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
#$id dt{ |
|
60
|
|
|
|
|
|
|
line-height: 20px; |
|
61
|
|
|
|
|
|
|
background-color: #80df20; |
|
62
|
|
|
|
|
|
|
border-top: 2px solid #DAFF9F; |
|
63
|
|
|
|
|
|
|
border-bottom: 2px solid #6CAF00; |
|
64
|
|
|
|
|
|
|
padding: 0 10px; |
|
65
|
|
|
|
|
|
|
font-weight: bold; |
|
66
|
|
|
|
|
|
|
color: #fff; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
#$id dd{ |
|
69
|
|
|
|
|
|
|
overflow: auto; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#$id dt.${id}Hover |
|
73
|
|
|
|
|
|
|
{ |
|
74
|
|
|
|
|
|
|
background-color: #90ef30; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
#$id dt.${id}Active |
|
77
|
|
|
|
|
|
|
{ |
|
78
|
|
|
|
|
|
|
background-color: #6CAF00; |
|
79
|
|
|
|
|
|
|
border-top: 2px solid #80df20; |
|
80
|
|
|
|
|
|
|
border-bottom: 2px solid #000; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
EOD |
|
83
|
0
|
|
|
|
|
|
return $css ; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub HTML { |
|
89
|
0
|
|
|
0
|
1
|
|
my $my = shift ; |
|
90
|
0
|
|
|
|
|
|
my $id = $my->id ; |
|
91
|
0
|
|
|
|
|
|
my $html = qq[\n] ; |
|
92
|
0
|
|
|
|
|
|
my @headers = @{$my->{param}{headers}} ; |
|
|
0
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my @texts = @{$my->{param}{texts}} ; |
|
|
0
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my $n = -1 ; |
|
95
|
0
|
|
|
|
|
|
for my $h (@headers) { |
|
96
|
0
|
|
|
|
|
|
$n ++ ; |
|
97
|
0
|
|
|
|
|
|
my $t = $texts[$n] ; |
|
98
|
0
|
|
|
|
|
|
$html .= qq[ $h\n] ; |
|
99
|
0
|
|
|
|
|
|
$html .= qq[ $t\n] ; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
0
|
|
|
|
|
|
$html .= qq[] ; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub get_jquery_code { |
|
106
|
0
|
|
|
0
|
0
|
|
my $my = shift ; |
|
107
|
0
|
|
|
|
|
|
my $id = $my->id ; |
|
108
|
0
|
|
|
|
|
|
my $remoteProgram = $my->{param}{remoteProgram} ; |
|
109
|
0
|
0
|
|
|
|
|
return '' unless $id =~ /\S/ ; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $function =<<'EOD'; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
$('#ID').Accordion({headerSelector : 'dt', |
|
114
|
|
|
|
|
|
|
panelSelector : 'dd', |
|
115
|
|
|
|
|
|
|
activeClass : 'IDActive', |
|
116
|
|
|
|
|
|
|
hoverClass : 'IDHover', |
|
117
|
|
|
|
|
|
|
panelHeight : PANEL_HEIGHT, |
|
118
|
|
|
|
|
|
|
speed : 300 |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
); |
|
121
|
|
|
|
|
|
|
EOD |
|
122
|
0
|
|
0
|
|
|
|
my $panelHeight = $my->{param}{panelHeight} || 200 ; |
|
123
|
0
|
|
|
|
|
|
$function =~ s/PANEL_HEIGHT/$panelHeight/ ; |
|
124
|
0
|
|
|
|
|
|
$function =~ s/ID/$id/g ; |
|
125
|
0
|
|
|
|
|
|
return $function ; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 NAME |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
JQuery::Accordion - produce an accordion effect |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my @headers = ("header 1","header 2","header 3","header4") ; |
|
136
|
|
|
|
|
|
|
my @texts = ("line 1","line 2","line 3","line4") ; |
|
137
|
|
|
|
|
|
|
my $accordion = JQuery::Accordion->new(id => 'myAccordion', |
|
138
|
|
|
|
|
|
|
headers => \@headers, |
|
139
|
|
|
|
|
|
|
texts => \@texts, |
|
140
|
|
|
|
|
|
|
panelHeight => 200, |
|
141
|
|
|
|
|
|
|
panelWidth => '400px' |
|
142
|
|
|
|
|
|
|
addToJQuery => $jquery, |
|
143
|
|
|
|
|
|
|
) ; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Change css defaults - add at the bottom |
|
146
|
|
|
|
|
|
|
$jquery->add_css_last(new JQuery::CSS( hash => {'#myAccordion' => {width => '600px'}})) ; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
my $html = $accordion->HTML ; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Add an accordion effect. For an example of how it looks, see L. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
You will also be wondering how to change colours etc. There are a |
|
155
|
|
|
|
|
|
|
number of CSS items that are defined, and taht can be changed. Each |
|
156
|
|
|
|
|
|
|
accordion needs an id. So the CSS paragraphs that are created are: |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
#id |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
#id dt |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
#id dd |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
#id dt.idHover |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
and |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
#id dt.idActive |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=over |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item HTML |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Get the HTML for the object |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item new |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Instantiate the object |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=back |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 AUTHOR |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Peter Gordon, C<< >> |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 BUGS |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
191
|
|
|
|
|
|
|
C, or through the web interface at |
|
192
|
|
|
|
|
|
|
L. |
|
193
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
194
|
|
|
|
|
|
|
your bug as I make changes. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 SUPPORT |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
perldoc JQuery |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
You can also look for information at: |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=over 4 |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
L |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
L |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
L |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item * Search CPAN |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
L |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=back |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Copyright 2007 Peter Gordon, all rights reserved. |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
231
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=cut |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
1; # End of JQuery::Accordion |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
|