| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::Widget::Element::Block; |
|
2
|
|
|
|
|
|
|
|
|
3
|
88
|
|
|
88
|
|
568
|
use warnings; |
|
|
88
|
|
|
|
|
255
|
|
|
|
88
|
|
|
|
|
2698
|
|
|
4
|
88
|
|
|
88
|
|
460
|
use strict; |
|
|
88
|
|
|
|
|
160
|
|
|
|
88
|
|
|
|
|
2692
|
|
|
5
|
88
|
|
|
88
|
|
495
|
use base 'HTML::Widget::Element::NullContainer'; |
|
|
88
|
|
|
|
|
168
|
|
|
|
88
|
|
|
|
|
15859
|
|
|
6
|
88
|
|
|
88
|
|
662
|
use NEXT; |
|
|
88
|
|
|
|
|
210
|
|
|
|
88
|
|
|
|
|
970
|
|
|
7
|
88
|
|
|
88
|
|
2509
|
use Carp qw/croak/; |
|
|
88
|
|
|
|
|
199
|
|
|
|
88
|
|
|
|
|
55917
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_classaccessor( |
|
10
|
|
|
|
|
|
|
block_container_class => 'HTML::Widget::BlockContainer' ); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/type wrap_sub/); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
HTML::Widget::Element::Block - Block Level Element |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $e = $widget->element( 'Block', 'div' ); |
|
21
|
|
|
|
|
|
|
$e->value('bar'); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Block Level Element. Base class for HTML::Widget::Element::Fieldset |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 new |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Returns a new Block element. Not usually required, use |
|
32
|
|
|
|
|
|
|
$widget->element() or $block->element() to create a new Block element |
|
33
|
|
|
|
|
|
|
within an existing widget or element. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
|
38
|
103
|
|
|
103
|
1
|
76697
|
return shift->NEXT::new(@_)->type('div'); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 type |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Default value is div, to create a container. Can be changed to |
|
44
|
|
|
|
|
|
|
create a tag of any type. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 element |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Add a new element, nested within this Block. See L |
|
49
|
|
|
|
|
|
|
for full documentation. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 push_content |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Add previously-created elements to the end of this block's elements. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 unshift_content |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Add previously-created elements to the start of this block's elements. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 block_container |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Creates a new block container object of type $self->block_container_class. |
|
62
|
|
|
|
|
|
|
Defaults to L. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub block_container { |
|
67
|
101
|
|
|
101
|
1
|
1671
|
my ( $self, $attributes ) = @_; |
|
68
|
101
|
|
50
|
|
|
544
|
my $class = $self->block_container_class |
|
69
|
|
|
|
|
|
|
|| 'HTML::Widget::BlockContainer'; |
|
70
|
101
|
|
|
|
|
1492
|
my $file = $class . ".pm"; |
|
71
|
101
|
|
|
|
|
397
|
$file =~ s{::}{/}g; |
|
72
|
101
|
|
|
|
|
185
|
eval { require $file }; |
|
|
101
|
|
|
|
|
30636
|
|
|
73
|
101
|
50
|
|
|
|
438
|
croak "Unable to load block container class $class: $@" if $@; |
|
74
|
|
|
|
|
|
|
|
|
75
|
101
|
|
|
|
|
787
|
return $class->new( { passive => $self->passive, %$attributes } ); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 block_container_class |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Sets the class to be used by $self->block_container. Can be called as a |
|
81
|
|
|
|
|
|
|
class or instance method. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub block_container_class { |
|
86
|
|
|
|
|
|
|
my ($self) = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
if ( not $_[0] and @_ >= 1 ) { |
|
89
|
|
|
|
|
|
|
delete $self->{block_container_class}; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
return $self->_block_container_class_accessor(@_); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 containerize |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Containerize the block and all its contained elements for later |
|
98
|
|
|
|
|
|
|
rendering. Uses HTML::Widget::BlockContainer by default, but this can |
|
99
|
|
|
|
|
|
|
be over-ridden on a class or instance basis via |
|
100
|
|
|
|
|
|
|
L. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub containerize { |
|
105
|
101
|
|
|
101
|
1
|
220
|
my ( $self, $w, $value, $error, $args ) = @_; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# NB: block-level HTML::Element generated here |
|
108
|
101
|
|
|
|
|
241
|
my %attrs; |
|
109
|
101
|
100
|
|
|
|
345
|
unless ( $self->{_anonymous} ) { |
|
110
|
31
|
|
|
|
|
155
|
$attrs{id} = $self->id($w); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
101
|
|
|
|
|
703
|
my $e = HTML::Element->new( $self->type, %attrs ); |
|
113
|
|
|
|
|
|
|
|
|
114
|
101
|
|
|
|
|
3330
|
my @pre_content = $self->_pre_content_elements($w); |
|
115
|
101
|
|
|
|
|
1097
|
my @post_content = $self->_post_content_elements($w); |
|
116
|
|
|
|
|
|
|
|
|
117
|
101
|
|
|
|
|
744
|
local $w->{attributes}->{id} = $self->id($w); |
|
118
|
|
|
|
|
|
|
|
|
119
|
101
|
|
|
|
|
394
|
my @content = $w->_containerize_elements( $self->content, $args ); |
|
120
|
|
|
|
|
|
|
|
|
121
|
101
|
|
|
|
|
729
|
$e->attr( $_ => ${ $self->attributes }{$_} ) |
|
|
94
|
|
|
|
|
330
|
|
|
122
|
101
|
|
|
|
|
226
|
for ( keys %{ $self->attributes } ); |
|
123
|
|
|
|
|
|
|
|
|
124
|
101
|
|
|
|
|
2077
|
return $self->block_container( { |
|
125
|
|
|
|
|
|
|
element => $e, |
|
126
|
|
|
|
|
|
|
content => \@content, |
|
127
|
|
|
|
|
|
|
pre_content => \@pre_content, |
|
128
|
|
|
|
|
|
|
post_content => \@post_content, |
|
129
|
|
|
|
|
|
|
wrap_sub => $self->wrap_sub, |
|
130
|
|
|
|
|
|
|
name => $self->name, |
|
131
|
|
|
|
|
|
|
} ); |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
7
|
|
|
7
|
|
16
|
sub _pre_content_elements { return (); } |
|
135
|
101
|
|
|
101
|
|
222
|
sub _post_content_elements { return (); } |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 get_elements |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my @elements = $self->get_elements; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my @elements = $self->get_elements( type => 'Textfield' ); |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
my @elements = $self->get_elements( name => 'username' ); |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Returns a list of all elements added to the widget. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
If a 'type' argument is given, only returns the elements of that type. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
If a 'name' argument is given, only returns the elements with that name. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 get_element |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
my $element = $self->get_element; |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my $element = $self->get_element( type => 'Textfield' ); |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
my $element = $self->get_element( name => 'username' ); |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Similar to get_elements(), but only returns the first element in the list. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Accepts the same arguments as get_elements(). |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 find_elements |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Similar to get_elements(), and has the same alternate forms, but performs a |
|
166
|
|
|
|
|
|
|
recursive search through itself and child elements. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
L |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 AUTHOR |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Michael Gray, C |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 LICENSE |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
|
179
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
1; |