Element/Textarea.pm

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Element/Select.pm ↑ Summary Element/Utils.pm »
1 package Tags::HTML::Element::Textarea;
2  
3 3 ▶use base qw(Tags::HTML);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 0 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=2.6
8 use Scalar::Util qw(blessed);
9 use Tags::HTML::Element::Utils qw(tags_boolean tags_label tags_value);
10  
11 our $VERSION = 0.15;
12  
13 sub _cleanup {
14 my $self = shift;
15  
16 delete $self->{'_textarea'};
17  
18 return;
19 }
20  
21 sub _init {
22 my ($self, $textarea) = @_;
23  
24 # Check textarea.
25 if (! defined $textarea
26 || ! blessed($textarea)
27 || ! $textarea->isa('Data::HTML::Element::Textarea')) {
28  
29 err "Textarea object must be a 'Data::HTML::Element::Textarea' instance.";
30 }
31  
32 $self->{'_textarea'} = $textarea;
33  
34 return;
35 }
36  
37 # Process 'Tags'.
38 sub _process {
39 my $self = shift;
40  
41 if (! exists $self->{'_textarea'}) {
42 return;
43 }
44  
45 $self->{'tags'}->put(
46 tags_label($self, $self->{'_textarea'}),
47 ['b', 'textarea'],
48 tags_boolean($self, $self->{'_textarea'}, 'autofocus'),
49 tags_value($self, $self->{'_textarea'}, 'css_class', 'class'),
50 tags_value($self, $self->{'_textarea'}, 'id'),
51 tags_value($self, $self->{'_textarea'}, 'name'),
52 tags_value($self, $self->{'_textarea'}, 'placeholder'),
53 tags_boolean($self, $self->{'_textarea'}, 'readonly'),
54 tags_boolean($self, $self->{'_textarea'}, 'disabled'),
55 tags_boolean($self, $self->{'_textarea'}, 'required'),
56 tags_value($self, $self->{'_textarea'}, 'cols'),
57 tags_value($self, $self->{'_textarea'}, 'rows'),
58 tags_value($self, $self->{'_textarea'}, 'form'),
59 defined $self->{'_textarea'}->value ? (
60 ['d', $self->{'_textarea'}->value],
61 ) : (),
62 ['e', 'textarea'],
63 );
64  
65 return;
66 }
67  
68 sub _process_css {
69 my $self = shift;
70  
71 if (! exists $self->{'_textarea'}) {
72 return;
73 }
74  
75 my $css_class = '';
76 if (defined $self->{'_textarea'}->css_class) {
77 $css_class = '.'.$self->{'_textarea'}->css_class;
78 }
79  
80 $self->{'css'}->put(
81 ['s', 'textarea'.$css_class],
82 ['d', 'width', '100%'],
83 ['d', 'padding', '12px 20px'],
84 ['d', 'margin', '8px 0'],
85 ['d', 'display', 'inline-block'],
86 ['d', 'border', '1px solid #ccc'],
87 ['d', 'border-radius', '4px'],
88 ['d', 'box-sizing', 'border-box'],
89 ['e'],
90 );
91  
92 return;
93 }
94  
95 1;
96  
97 __END__
« Element/Select.pm ↑ Summary Element/Utils.pm »