line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
9641
|
use strict; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
383
|
|
2
|
15
|
|
|
15
|
|
73
|
use warnings; |
|
15
|
|
|
|
|
25
|
|
|
15
|
|
|
|
|
696
|
|
3
|
|
|
|
|
|
|
package HTML::Widget::Plugin::Checkbox; |
4
|
|
|
|
|
|
|
# ABSTRACT: it's either [ ] or [x] |
5
|
|
|
|
|
|
|
$HTML::Widget::Plugin::Checkbox::VERSION = '0.204'; |
6
|
15
|
|
|
15
|
|
72
|
use parent 'HTML::Widget::Plugin'; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
79
|
|
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
|
|
770
|
use HTML::Element; |
|
15
|
|
|
|
|
24
|
|
|
15
|
|
|
|
|
81
|
|
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
|
51
|
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
|
|
80
|
sub _attribute_args { qw(checked disabled value) } |
58
|
32
|
|
|
32
|
|
107
|
sub _boolean_args { qw(checked disabled) } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub checkbox { |
61
|
2
|
|
|
2
|
1
|
5
|
my ($self, $factory, $arg) = @_; |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
4
|
$arg->{attr}{type} = 'checkbox'; |
64
|
|
|
|
|
|
|
|
65
|
2
|
100
|
|
|
|
7
|
$arg->{attr}{name} = $arg->{attr}{id} if not defined $arg->{attr}{name}; |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
8
|
my $widget = HTML::Element->new('input'); |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
51
|
$widget->attr($_ => $arg->{attr}{$_}) for keys %{ $arg->{attr} }; |
|
2
|
|
|
|
|
14
|
|
70
|
2
|
|
|
|
|
96
|
return $widget->as_XML; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |