line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
6669
|
use strict; |
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
486
|
|
2
|
15
|
|
|
15
|
|
61
|
use warnings; |
|
15
|
|
|
|
|
20
|
|
|
15
|
|
|
|
|
621
|
|
3
|
|
|
|
|
|
|
package HTML::Widget::Plugin::Checkbox; |
4
|
|
|
|
|
|
|
# ABSTRACT: it's either [ ] or [x] |
5
|
|
|
|
|
|
|
$HTML::Widget::Plugin::Checkbox::VERSION = '0.203'; |
6
|
15
|
|
|
15
|
|
58
|
use parent 'HTML::Widget::Plugin'; |
|
15
|
|
|
|
|
16
|
|
|
15
|
|
|
|
|
60
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod $widget_factory->checkbox({ |
11
|
|
|
|
|
|
|
#pod id => 'checkbox-id', # also used as default for control name |
12
|
|
|
|
|
|
|
#pod value => 'checkbox-value', # -not- the "am I checked?" setting |
13
|
|
|
|
|
|
|
#pod checked => $true_or_false, |
14
|
|
|
|
|
|
|
#pod }); |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod This plugin provides a widget for boolean checkbox widgets. |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod =cut |
21
|
|
|
|
|
|
|
|
22
|
15
|
|
|
15
|
|
787
|
use HTML::Element; |
|
15
|
|
|
|
|
20
|
|
|
15
|
|
|
|
|
66
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#pod =head1 METHODS |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod =head2 C< provided_widgets > |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod This plugin provides the following widgets: checkbox |
29
|
|
|
|
|
|
|
#pod |
30
|
|
|
|
|
|
|
#pod =cut |
31
|
|
|
|
|
|
|
|
32
|
16
|
|
|
16
|
1
|
34
|
sub provided_widgets { qw(checkbox) } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#pod =head2 C< checkbox > |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod This method returns a checkbox widget. |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod In addition to the generic L attributes, the following |
39
|
|
|
|
|
|
|
#pod are valid arguments: |
40
|
|
|
|
|
|
|
#pod |
41
|
|
|
|
|
|
|
#pod =over |
42
|
|
|
|
|
|
|
#pod |
43
|
|
|
|
|
|
|
#pod =item checked |
44
|
|
|
|
|
|
|
#pod |
45
|
|
|
|
|
|
|
#pod This is the widget's initial state. If true, the checkbox is checked. |
46
|
|
|
|
|
|
|
#pod Otherwise, it is not. |
47
|
|
|
|
|
|
|
#pod |
48
|
|
|
|
|
|
|
#pod =item value |
49
|
|
|
|
|
|
|
#pod |
50
|
|
|
|
|
|
|
#pod This is the value for the checkbox, not to be confused with whether or not it |
51
|
|
|
|
|
|
|
#pod is checked. |
52
|
|
|
|
|
|
|
#pod |
53
|
|
|
|
|
|
|
#pod =back |
54
|
|
|
|
|
|
|
#pod |
55
|
|
|
|
|
|
|
#pod =cut |
56
|
|
|
|
|
|
|
|
57
|
16
|
|
|
16
|
|
49
|
sub _attribute_args { qw(checked disabled value) } |
58
|
32
|
|
|
32
|
|
76
|
sub _boolean_args { qw(checked disabled) } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub checkbox { |
61
|
2
|
|
|
2
|
1
|
3
|
my ($self, $factory, $arg) = @_; |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
3
|
$arg->{attr}{type} = 'checkbox'; |
64
|
|
|
|
|
|
|
|
65
|
2
|
100
|
|
|
|
7
|
$arg->{attr}{name} = $arg->{attr}{id} if not defined $arg->{attr}{name}; |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
7
|
my $widget = HTML::Element->new('input'); |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
43
|
$widget->attr($_ => $arg->{attr}{$_}) for keys %{ $arg->{attr} }; |
|
2
|
|
|
|
|
9
|
|
70
|
2
|
|
|
|
|
64
|
return $widget->as_XML; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |