line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Widgets::NavMenu::Iterator::NavMenu; |
2
|
|
|
|
|
|
|
$HTML::Widgets::NavMenu::Iterator::NavMenu::VERSION = '1.0901'; |
3
|
11
|
|
|
11
|
|
1274
|
use strict; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
292
|
|
4
|
11
|
|
|
11
|
|
48
|
use warnings; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
295
|
|
5
|
|
|
|
|
|
|
|
6
|
11
|
|
|
11
|
|
47
|
use parent qw(HTML::Widgets::NavMenu::Iterator::Html); |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
48
|
|
7
|
|
|
|
|
|
|
|
8
|
11
|
|
|
11
|
|
450
|
use HTML::Widgets::NavMenu::EscapeHtml qw/ escape_html /; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
9105
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->mk_acc_ref( |
11
|
|
|
|
|
|
|
[ |
12
|
|
|
|
|
|
|
qw( |
13
|
|
|
|
|
|
|
_ul_classes |
14
|
|
|
|
|
|
|
) |
15
|
|
|
|
|
|
|
] |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _init |
20
|
|
|
|
|
|
|
{ |
21
|
276
|
|
|
276
|
|
377
|
my $self = shift; |
22
|
276
|
|
|
|
|
333
|
my $args = shift; |
23
|
|
|
|
|
|
|
|
24
|
276
|
|
|
|
|
746
|
$self->SUPER::_init($args); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Make a fresh copy just to be on the safe side. |
27
|
276
|
|
|
|
|
350
|
$self->_ul_classes( [ @{ $args->{'ul_classes'} } ] ); |
|
276
|
|
|
|
|
690
|
|
28
|
|
|
|
|
|
|
|
29
|
276
|
|
|
|
|
448
|
return 0; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _calc_li_id_attr |
33
|
|
|
|
|
|
|
{ |
34
|
212
|
|
|
212
|
|
276
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
212
|
|
|
|
|
363
|
my $li_id = $self->top()->_li_id; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return ( |
39
|
212
|
100
|
|
|
|
606
|
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
|
162
|
my ( $self, $args ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
94
|
|
|
|
|
142
|
my $depth = $args->{'depth'}; |
52
|
|
|
|
|
|
|
|
53
|
94
|
|
|
|
|
210
|
my $class = $self->_get_ul_class( { 'depth' => $depth } ); |
54
|
|
|
|
|
|
|
|
55
|
94
|
100
|
|
|
|
335
|
return " |
56
|
|
|
|
|
|
|
. ( |
57
|
|
|
|
|
|
|
defined($class) |
58
|
|
|
|
|
|
|
? ( " class=\"" . escape_html($class) . "\"" ) |
59
|
|
|
|
|
|
|
: "" |
60
|
|
|
|
|
|
|
) . ">"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _get_ul_class |
64
|
|
|
|
|
|
|
{ |
65
|
94
|
|
|
94
|
|
154
|
my ( $self, $args ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
94
|
|
|
|
|
147
|
my $depth = $args->{'depth'}; |
68
|
|
|
|
|
|
|
|
69
|
94
|
|
|
|
|
232
|
return $self->_ul_classes->[ $depth - 1 ]; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub get_currently_active_text |
74
|
|
|
|
|
|
|
{ |
75
|
24
|
|
|
24
|
1
|
41
|
my $self = shift; |
76
|
24
|
|
|
|
|
33
|
my $node = shift; |
77
|
24
|
|
|
|
|
84
|
return "" . $node->text() . ""; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub get_link_tag |
82
|
|
|
|
|
|
|
{ |
83
|
216
|
|
|
216
|
1
|
291
|
my $self = shift; |
84
|
216
|
|
|
|
|
397
|
my $node = $self->top->_node(); |
85
|
216
|
100
|
|
|
|
437
|
if ( $node->CurrentlyActive() ) |
86
|
|
|
|
|
|
|
{ |
87
|
25
|
|
|
|
|
73
|
return $self->get_currently_active_text($node); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else |
90
|
|
|
|
|
|
|
{ |
91
|
191
|
|
|
|
|
377
|
return $self->get_a_tag(); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _start_root |
96
|
|
|
|
|
|
|
{ |
97
|
44
|
|
|
44
|
|
65
|
my $self = shift; |
98
|
|
|
|
|
|
|
|
99
|
44
|
|
|
|
|
133
|
$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
|
|
5
|
my $self = shift; |
111
|
|
|
|
|
|
|
|
112
|
2
|
|
|
|
|
4
|
$self->_add_tags(""); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _start_handle_role |
116
|
|
|
|
|
|
|
{ |
117
|
3
|
|
|
3
|
|
10
|
my $self = shift; |
118
|
3
|
|
|
|
|
18
|
return $self->_start_handle_non_role(); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub get_open_sub_menu_tags |
123
|
|
|
|
|
|
|
{ |
124
|
42
|
|
|
42
|
1
|
70
|
my $self = shift; |
125
|
42
|
|
|
|
|
126
|
return ( " ", |
126
|
|
|
|
|
|
|
$self->gen_ul_tag( { 'depth' => $self->stack->len() } ) ); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub _start_handle_non_role |
130
|
|
|
|
|
|
|
{ |
131
|
195
|
|
|
195
|
|
259
|
my $self = shift; |
132
|
195
|
|
|
|
|
350
|
my $top_item = $self->top; |
133
|
195
|
|
|
|
|
362
|
my @tags_to_add = |
134
|
|
|
|
|
|
|
( ( "_calc_li_id_attr() . ">" ), $self->get_link_tag() ); |
135
|
195
|
100
|
100
|
|
|
442
|
if ( $top_item->_num_subs_to_go() && $self->_is_expanded() ) |
136
|
|
|
|
|
|
|
{ |
137
|
41
|
|
|
|
|
113
|
push @tags_to_add, ( $self->get_open_sub_menu_tags() ); |
138
|
|
|
|
|
|
|
} |
139
|
195
|
|
|
|
|
479
|
$self->_add_tags(@tags_to_add); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub _start_regular |
143
|
|
|
|
|
|
|
{ |
144
|
220
|
|
|
220
|
|
291
|
my $self = shift; |
145
|
|
|
|
|
|
|
|
146
|
220
|
|
|
|
|
389
|
my $top_item = $self->top; |
147
|
220
|
|
|
|
|
382
|
my $node = $self->top->_node(); |
148
|
|
|
|
|
|
|
|
149
|
220
|
100
|
|
|
|
400
|
if ( $self->_is_hidden() ) |
150
|
|
|
|
|
|
|
{ |
151
|
|
|
|
|
|
|
# Do nothing |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
else |
154
|
|
|
|
|
|
|
{ |
155
|
216
|
100
|
|
|
|
389
|
if ( $self->_is_role_specified() ) |
156
|
|
|
|
|
|
|
{ |
157
|
7
|
|
|
|
|
22
|
$self->_start_handle_role(); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
else |
160
|
|
|
|
|
|
|
{ |
161
|
209
|
|
|
|
|
404
|
$self->_start_handle_non_role(); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub _end_sep |
167
|
|
|
|
|
|
|
{ |
168
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
169
|
|
|
|
|
|
|
|
170
|
2
|
|
|
|
|
9
|
$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
|
|
7
|
my $self = shift; |
182
|
3
|
|
|
|
|
6
|
return $self->_end_handle_non_role(); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub _end_handle_non_role |
186
|
|
|
|
|
|
|
{ |
187
|
212
|
|
|
212
|
|
268
|
my $self = shift; |
188
|
212
|
|
|
|
|
397
|
return $self->SUPER::_end_regular(); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub _end_regular |
192
|
|
|
|
|
|
|
{ |
193
|
220
|
|
|
220
|
|
292
|
my $self = shift; |
194
|
220
|
100
|
|
|
|
359
|
if ( $self->_is_hidden() ) |
|
|
100
|
|
|
|
|
|
195
|
|
|
|
|
|
|
{ |
196
|
|
|
|
|
|
|
# Do nothing |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
elsif ( $self->_is_role_specified() ) |
199
|
|
|
|
|
|
|
{ |
200
|
7
|
|
|
|
|
31
|
$self->_end_handle_role(); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
else |
203
|
|
|
|
|
|
|
{ |
204
|
209
|
|
|
|
|
348
|
$self->_end_handle_non_role(); |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub _is_hidden |
209
|
|
|
|
|
|
|
{ |
210
|
440
|
|
|
440
|
|
535
|
my $self = shift; |
211
|
440
|
|
|
|
|
752
|
return $self->top->_node()->hide(); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub _is_expanded |
215
|
|
|
|
|
|
|
{ |
216
|
559
|
|
|
559
|
|
704
|
my $self = shift; |
217
|
559
|
|
|
|
|
960
|
my $node = $self->top->_node(); |
218
|
559
|
|
66
|
|
|
1823
|
return ( $node->expanded() || $self->top->_accum_state->{'show_always'} ); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub get_role |
223
|
|
|
|
|
|
|
{ |
224
|
446
|
|
|
446
|
1
|
579
|
my $self = shift; |
225
|
446
|
|
|
|
|
779
|
return $self->top->_node->role(); |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub _is_role_specified |
229
|
|
|
|
|
|
|
{ |
230
|
432
|
|
|
432
|
|
573
|
my $self = shift; |
231
|
432
|
|
|
|
|
619
|
return defined( $self->get_role() ); |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
1; |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
__END__ |