line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Widgets::NavMenu::Iterator::NavMenu; |
2
|
|
|
|
|
|
|
$HTML::Widgets::NavMenu::Iterator::NavMenu::VERSION = '1.1000'; |
3
|
11
|
|
|
11
|
|
1135
|
use strict; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
286
|
|
4
|
11
|
|
|
11
|
|
47
|
use warnings; |
|
11
|
|
|
|
|
27
|
|
|
11
|
|
|
|
|
273
|
|
5
|
|
|
|
|
|
|
|
6
|
11
|
|
|
11
|
|
48
|
use parent qw(HTML::Widgets::NavMenu::Iterator::Html); |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
49
|
|
7
|
|
|
|
|
|
|
|
8
|
11
|
|
|
11
|
|
465
|
use HTML::Widgets::NavMenu::EscapeHtml qw/ escape_html /; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
8361
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->mk_acc_ref( |
11
|
|
|
|
|
|
|
[ |
12
|
|
|
|
|
|
|
qw( |
13
|
|
|
|
|
|
|
_ul_classes |
14
|
|
|
|
|
|
|
) |
15
|
|
|
|
|
|
|
] |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _init |
20
|
|
|
|
|
|
|
{ |
21
|
295
|
|
|
295
|
|
414
|
my $self = shift; |
22
|
295
|
|
|
|
|
370
|
my $args = shift; |
23
|
|
|
|
|
|
|
|
24
|
295
|
|
|
|
|
823
|
$self->SUPER::_init($args); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Make a fresh copy just to be on the safe side. |
27
|
295
|
|
|
|
|
439
|
$self->_ul_classes( [ @{ $args->{'ul_classes'} } ] ); |
|
295
|
|
|
|
|
651
|
|
28
|
|
|
|
|
|
|
|
29
|
295
|
|
|
|
|
491
|
return 0; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _calc_li_id_attr |
33
|
|
|
|
|
|
|
{ |
34
|
212
|
|
|
212
|
|
282
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
212
|
|
|
|
|
391
|
my $li_id = $self->top()->_li_id; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return ( |
39
|
212
|
100
|
|
|
|
641
|
defined($li_id) |
40
|
|
|
|
|
|
|
? qq/ id="/ . escape_html($li_id) . qq/"/ |
41
|
|
|
|
|
|
|
: q// |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Depth is 1 for the uppermost depth. |
47
|
|
|
|
|
|
|
sub gen_ul_tag |
48
|
|
|
|
|
|
|
{ |
49
|
94
|
|
|
94
|
1
|
176
|
my ( $self, $args ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
94
|
|
|
|
|
135
|
my $depth = $args->{'depth'}; |
52
|
|
|
|
|
|
|
|
53
|
94
|
|
|
|
|
201
|
my $class = $self->_get_ul_class( { 'depth' => $depth } ); |
54
|
|
|
|
|
|
|
|
55
|
94
|
100
|
|
|
|
362
|
return " |
56
|
|
|
|
|
|
|
. ( |
57
|
|
|
|
|
|
|
defined($class) |
58
|
|
|
|
|
|
|
? ( " class=\"" . escape_html($class) . "\"" ) |
59
|
|
|
|
|
|
|
: "" |
60
|
|
|
|
|
|
|
) . ">"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _get_ul_class |
64
|
|
|
|
|
|
|
{ |
65
|
94
|
|
|
94
|
|
163
|
my ( $self, $args ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
94
|
|
|
|
|
121
|
my $depth = $args->{'depth'}; |
68
|
|
|
|
|
|
|
|
69
|
94
|
|
|
|
|
249
|
return $self->_ul_classes->[ $depth - 1 ]; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub get_currently_active_text |
74
|
|
|
|
|
|
|
{ |
75
|
24
|
|
|
24
|
1
|
36
|
my $self = shift; |
76
|
24
|
|
|
|
|
43
|
my $node = shift; |
77
|
24
|
|
|
|
|
83
|
return "" . $node->text() . ""; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub get_link_tag |
82
|
|
|
|
|
|
|
{ |
83
|
216
|
|
|
216
|
1
|
313
|
my $self = shift; |
84
|
216
|
|
|
|
|
344
|
my $node = $self->top->_node(); |
85
|
216
|
100
|
|
|
|
410
|
if ( $node->CurrentlyActive() ) |
86
|
|
|
|
|
|
|
{ |
87
|
25
|
|
|
|
|
79
|
return $self->get_currently_active_text($node); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else |
90
|
|
|
|
|
|
|
{ |
91
|
191
|
|
|
|
|
348
|
return $self->get_a_tag(); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _start_root |
96
|
|
|
|
|
|
|
{ |
97
|
44
|
|
|
44
|
|
62
|
my $self = shift; |
98
|
|
|
|
|
|
|
|
99
|
44
|
|
|
|
|
131
|
$self->_add_tags( |
100
|
|
|
|
|
|
|
$self->gen_ul_tag( |
101
|
|
|
|
|
|
|
{ |
102
|
|
|
|
|
|
|
'depth' => $self->stack->len() |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
) |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _start_sep |
109
|
|
|
|
|
|
|
{ |
110
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
111
|
|
|
|
|
|
|
|
112
|
2
|
|
|
|
|
4
|
$self->_add_tags(""); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _start_handle_role |
116
|
|
|
|
|
|
|
{ |
117
|
3
|
|
|
3
|
|
7
|
my $self = shift; |
118
|
3
|
|
|
|
|
5
|
return $self->_start_handle_non_role(); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub get_open_sub_menu_tags |
123
|
|
|
|
|
|
|
{ |
124
|
42
|
|
|
42
|
1
|
69
|
my $self = shift; |
125
|
42
|
|
|
|
|
128
|
return ( " ", |
126
|
|
|
|
|
|
|
$self->gen_ul_tag( { 'depth' => $self->stack->len() } ) ); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub _start_handle_non_role |
130
|
|
|
|
|
|
|
{ |
131
|
195
|
|
|
195
|
|
256
|
my $self = shift; |
132
|
195
|
|
|
|
|
357
|
my $top_item = $self->top; |
133
|
195
|
|
|
|
|
336
|
my @tags_to_add = |
134
|
|
|
|
|
|
|
( ( "_calc_li_id_attr() . ">" ), $self->get_link_tag() ); |
135
|
195
|
100
|
100
|
|
|
493
|
if ( $top_item->_num_subs_to_go() && $self->_is_expanded() ) |
136
|
|
|
|
|
|
|
{ |
137
|
41
|
|
|
|
|
95
|
push @tags_to_add, ( $self->get_open_sub_menu_tags() ); |
138
|
|
|
|
|
|
|
} |
139
|
195
|
|
|
|
|
519
|
$self->_add_tags(@tags_to_add); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub _start_regular |
143
|
|
|
|
|
|
|
{ |
144
|
220
|
|
|
220
|
|
300
|
my $self = shift; |
145
|
|
|
|
|
|
|
|
146
|
220
|
|
|
|
|
377
|
my $top_item = $self->top; |
147
|
220
|
|
|
|
|
407
|
my $node = $self->top->_node(); |
148
|
|
|
|
|
|
|
|
149
|
220
|
100
|
|
|
|
367
|
if ( $self->_is_hidden() ) |
150
|
|
|
|
|
|
|
{ |
151
|
|
|
|
|
|
|
# Do nothing |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
else |
154
|
|
|
|
|
|
|
{ |
155
|
216
|
100
|
|
|
|
362
|
if ( $self->_is_role_specified() ) |
156
|
|
|
|
|
|
|
{ |
157
|
7
|
|
|
|
|
24
|
$self->_start_handle_role(); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
else |
160
|
|
|
|
|
|
|
{ |
161
|
209
|
|
|
|
|
425
|
$self->_start_handle_non_role(); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub _end_sep |
167
|
|
|
|
|
|
|
{ |
168
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
169
|
|
|
|
|
|
|
|
170
|
2
|
|
|
|
|
6
|
$self->_add_tags( |
171
|
|
|
|
|
|
|
$self->gen_ul_tag( |
172
|
|
|
|
|
|
|
{ |
173
|
|
|
|
|
|
|
'depth' => $self->stack->len() - 1 |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
) |
176
|
|
|
|
|
|
|
); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub _end_handle_role |
180
|
|
|
|
|
|
|
{ |
181
|
3
|
|
|
3
|
|
6
|
my $self = shift; |
182
|
3
|
|
|
|
|
6
|
return $self->_end_handle_non_role(); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub _end_handle_non_role |
186
|
|
|
|
|
|
|
{ |
187
|
212
|
|
|
212
|
|
315
|
my $self = shift; |
188
|
212
|
|
|
|
|
417
|
return $self->SUPER::_end_regular(); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub _end_regular |
192
|
|
|
|
|
|
|
{ |
193
|
220
|
|
|
220
|
|
325
|
my $self = shift; |
194
|
220
|
100
|
|
|
|
333
|
if ( $self->_is_hidden() ) |
|
|
100
|
|
|
|
|
|
195
|
|
|
|
|
|
|
{ |
196
|
|
|
|
|
|
|
# Do nothing |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
elsif ( $self->_is_role_specified() ) |
199
|
|
|
|
|
|
|
{ |
200
|
7
|
|
|
|
|
19
|
$self->_end_handle_role(); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
else |
203
|
|
|
|
|
|
|
{ |
204
|
209
|
|
|
|
|
346
|
$self->_end_handle_non_role(); |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub _is_hidden |
209
|
|
|
|
|
|
|
{ |
210
|
440
|
|
|
440
|
|
566
|
my $self = shift; |
211
|
440
|
|
|
|
|
719
|
return $self->top->_node()->hide(); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub _is_expanded |
215
|
|
|
|
|
|
|
{ |
216
|
559
|
|
|
559
|
|
706
|
my $self = shift; |
217
|
559
|
|
|
|
|
959
|
my $node = $self->top->_node(); |
218
|
559
|
|
66
|
|
|
1764
|
return ( $node->expanded() || $self->top->_accum_state->{'show_always'} ); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub get_role |
223
|
|
|
|
|
|
|
{ |
224
|
446
|
|
|
446
|
1
|
529
|
my $self = shift; |
225
|
446
|
|
|
|
|
708
|
return $self->top->_node->role(); |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub _is_role_specified |
229
|
|
|
|
|
|
|
{ |
230
|
432
|
|
|
432
|
|
559
|
my $self = shift; |
231
|
432
|
|
|
|
|
687
|
return defined( $self->get_role() ); |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
1; |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
__END__ |