line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Form::Input; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
4614
|
use strict; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
10988
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '6.11'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: A generic HTML form input element for use with HTML::Form |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
154
|
|
|
154
|
0
|
250
|
my $class = shift; |
11
|
154
|
|
|
|
|
611
|
my $self = bless {@_}, $class; |
12
|
154
|
|
|
|
|
359
|
$self; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub add_to_form { |
16
|
116
|
|
|
116
|
0
|
247
|
my ( $self, $form ) = @_; |
17
|
116
|
|
|
|
|
156
|
push( @{ $form->{'inputs'} }, $self ); |
|
116
|
|
|
|
|
251
|
|
18
|
116
|
|
|
|
|
595
|
$self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub strict { |
22
|
10
|
|
|
10
|
0
|
1173
|
my $self = shift; |
23
|
10
|
|
|
|
|
17
|
my $old = $self->{strict}; |
24
|
10
|
100
|
|
|
|
23
|
if (@_) { |
25
|
8
|
|
|
|
|
17
|
$self->{strict} = shift; |
26
|
|
|
|
|
|
|
} |
27
|
10
|
|
|
|
|
26
|
$old; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
50
|
0
|
|
sub fixup { } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub type { |
33
|
145
|
|
|
145
|
0
|
410
|
shift->{type}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub name { |
37
|
234
|
|
|
234
|
0
|
304
|
my $self = shift; |
38
|
234
|
|
|
|
|
325
|
my $old = $self->{name}; |
39
|
234
|
100
|
|
|
|
415
|
$self->{name} = shift if @_; |
40
|
234
|
|
|
|
|
421
|
$old; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub id { |
44
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
45
|
1
|
|
|
|
|
4
|
my $old = $self->{id}; |
46
|
1
|
50
|
|
|
|
5
|
$self->{id} = shift if @_; |
47
|
1
|
|
|
|
|
4
|
$old; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub class { |
51
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
52
|
1
|
|
|
|
|
3
|
my $old = $self->{class}; |
53
|
1
|
50
|
|
|
|
4
|
$self->{class} = shift if @_; |
54
|
1
|
|
|
|
|
5
|
$old; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub selected { |
58
|
580
|
|
|
580
|
0
|
914
|
my ( $self, $sel ) = @_; |
59
|
580
|
50
|
|
|
|
1008
|
return undef unless defined $sel; |
60
|
580
|
100
|
|
|
|
1606
|
my $attr |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
61
|
|
|
|
|
|
|
= $sel =~ s/^\^// ? "name" |
62
|
|
|
|
|
|
|
: $sel =~ s/^#// ? "id" |
63
|
|
|
|
|
|
|
: $sel =~ s/^\.// ? "class" |
64
|
|
|
|
|
|
|
: "name"; |
65
|
580
|
100
|
|
|
|
1122
|
return 0 unless defined $self->{$attr}; |
66
|
575
|
|
|
|
|
1731
|
return $self->{$attr} eq $sel; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub value { |
70
|
11
|
|
|
11
|
0
|
19
|
my $self = shift; |
71
|
11
|
|
|
|
|
20
|
my $old = $self->{value}; |
72
|
11
|
100
|
|
|
|
27
|
$self->{value} = shift if @_; |
73
|
11
|
|
|
|
|
32
|
$old; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub autocomplete { |
77
|
6
|
|
|
6
|
0
|
18
|
my $self = shift; |
78
|
6
|
|
|
|
|
9
|
my $old = $self->{autocomplete}; |
79
|
6
|
100
|
|
|
|
23
|
$self->{autocomplete} = shift if @_; |
80
|
6
|
|
|
|
|
32
|
$old; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub possible_values { |
84
|
0
|
|
|
0
|
0
|
0
|
return; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub other_possible_values { |
88
|
0
|
|
|
0
|
0
|
0
|
return; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub value_names { |
92
|
0
|
|
|
0
|
0
|
0
|
return; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub readonly { |
96
|
6
|
|
|
6
|
0
|
721
|
my $self = shift; |
97
|
6
|
|
|
|
|
11
|
my $old = $self->{readonly}; |
98
|
6
|
100
|
|
|
|
18
|
$self->{readonly} = shift if @_; |
99
|
6
|
|
|
|
|
30
|
$old; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub disabled { |
103
|
60
|
|
|
60
|
0
|
81
|
my $self = shift; |
104
|
60
|
|
|
|
|
87
|
my $old = $self->{disabled}; |
105
|
60
|
100
|
|
|
|
135
|
$self->{disabled} = shift if @_; |
106
|
60
|
|
|
|
|
151
|
$old; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub form_name_value { |
110
|
76
|
|
|
76
|
0
|
104
|
my $self = shift; |
111
|
76
|
|
|
|
|
126
|
my $name = $self->{'name'}; |
112
|
76
|
100
|
|
|
|
149
|
return unless defined $name; |
113
|
68
|
100
|
|
|
|
128
|
return if $self->disabled; |
114
|
65
|
|
|
|
|
166
|
my $value = $self->value; |
115
|
65
|
100
|
|
|
|
143
|
return unless defined $value; |
116
|
60
|
|
|
|
|
221
|
return ( $name => $value ); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub dump { |
120
|
1
|
|
|
1
|
0
|
5
|
my $self = shift; |
121
|
1
|
|
|
|
|
5
|
my $name = $self->name; |
122
|
1
|
50
|
|
|
|
4
|
$name = "" unless defined $name; |
123
|
1
|
|
|
|
|
3
|
my $value = $self->value; |
124
|
1
|
50
|
|
|
|
5
|
$value = "" unless defined $value; |
125
|
1
|
|
|
|
|
3
|
my $dump = "$name=$value"; |
126
|
|
|
|
|
|
|
|
127
|
1
|
|
|
|
|
23
|
my $type = $self->type; |
128
|
|
|
|
|
|
|
|
129
|
1
|
50
|
|
|
|
8
|
$type .= " disabled" if $self->disabled; |
130
|
1
|
50
|
|
|
|
7
|
$type .= " readonly" if $self->readonly; |
131
|
1
|
50
|
|
|
|
13
|
return sprintf "%-30s %s", $dump, "($type)" unless $self->{menu}; |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
my @menu; |
134
|
0
|
|
|
|
|
|
my $i = 0; |
135
|
0
|
|
|
|
|
|
for ( @{ $self->{menu} } ) { |
|
0
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my $opt = $_->{value}; |
137
|
0
|
0
|
|
|
|
|
$opt = "" unless defined $opt; |
138
|
|
|
|
|
|
|
$opt .= "/$_->{name}" |
139
|
0
|
0
|
0
|
|
|
|
if defined $_->{name} && length $_->{name} && $_->{name} ne $opt; |
|
|
|
0
|
|
|
|
|
140
|
0
|
0
|
|
|
|
|
substr( $opt, 0, 0 ) = "-" if $_->{disabled}; |
141
|
0
|
0
|
0
|
|
|
|
if ( exists $self->{current} && $self->{current} == $i ) { |
142
|
0
|
0
|
|
|
|
|
substr( $opt, 0, 0 ) = "!" unless $_->{seen}; |
143
|
0
|
|
|
|
|
|
substr( $opt, 0, 0 ) = "*"; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
else { |
146
|
0
|
0
|
|
|
|
|
substr( $opt, 0, 0 ) = ":" if $_->{seen}; |
147
|
|
|
|
|
|
|
} |
148
|
0
|
|
|
|
|
|
push( @menu, $opt ); |
149
|
0
|
|
|
|
|
|
$i++; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
return sprintf "%-30s %-10s %s", $dump, "($type)", |
153
|
|
|
|
|
|
|
"[" . join( "|", @menu ) . "]"; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
__END__ |