| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Moonshine::Bootstrap::Component::ButtonGroup; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
292410
|
use Moonshine::Magic; |
|
|
6
|
|
|
|
|
152398
|
|
|
|
6
|
|
|
|
|
61
|
|
|
4
|
6
|
|
|
6
|
|
4340
|
use Moonshine::Util; |
|
|
6
|
|
|
|
|
16
|
|
|
|
6
|
|
|
|
|
114
|
|
|
5
|
6
|
|
|
6
|
|
5362
|
use Params::Validate qw/ARRAYREF/; |
|
|
6
|
|
|
|
|
19
|
|
|
|
6
|
|
|
|
|
738
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends( |
|
8
|
|
|
|
|
|
|
'Moonshine::Bootstrap::Component', |
|
9
|
|
|
|
|
|
|
'Moonshine::Bootstrap::Component::Button', |
|
10
|
|
|
|
|
|
|
'Moonshine::Bootstrap::Component::Dropdown', |
|
11
|
|
|
|
|
|
|
); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has( |
|
14
|
|
|
|
|
|
|
button_group_spec => sub { |
|
15
|
|
|
|
|
|
|
{ |
|
16
|
|
|
|
|
|
|
tag => { default => 'div' }, |
|
17
|
|
|
|
|
|
|
role => { default => 'group' }, |
|
18
|
|
|
|
|
|
|
class_base => { default => 'btn-group' }, |
|
19
|
|
|
|
|
|
|
sizing_base => { default => 'btn-group-' }, |
|
20
|
|
|
|
|
|
|
vertical => 0, |
|
21
|
|
|
|
|
|
|
justified_base => { default => 'btn-group-justified' }, |
|
22
|
|
|
|
|
|
|
nested => { |
|
23
|
|
|
|
|
|
|
type => ARRAYREF, |
|
24
|
|
|
|
|
|
|
optional => 1, |
|
25
|
|
|
|
|
|
|
}, |
|
26
|
|
|
|
|
|
|
group => { |
|
27
|
|
|
|
|
|
|
type => ARRAYREF, |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
}; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub button_group { |
|
34
|
27
|
|
|
27
|
|
177102
|
my ($self) = shift; |
|
35
|
|
|
|
|
|
|
|
|
36
|
27
|
|
50
|
|
|
260
|
my ( $base_args, $build_args ) = $self->validate_build( |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
|
|
|
|
|
|
params => $_[0] // {}, |
|
39
|
|
|
|
|
|
|
spec => $self->button_group_spec, |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
27
|
100
|
|
|
|
327
|
if ( $vertical = $build_args->{vertical} ) { |
|
44
|
|
|
|
|
|
|
$base_args->{class} = |
|
45
|
2
|
|
|
|
|
14
|
prepend_str( 'btn-group-vertical', $base_args->{class} ); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
27
|
|
|
|
|
217
|
my $button_group = Moonshine::Element->new($base_args); |
|
49
|
|
|
|
|
|
|
|
|
50
|
27
|
|
|
|
|
66280
|
my %drop_down_args = ( class => 'btn-group', role => 'group' ); |
|
51
|
27
|
|
|
|
|
70
|
for ( @{ $build_args->{group} } ) { |
|
|
27
|
|
|
|
|
142
|
|
|
52
|
50
|
100
|
|
|
|
57963
|
if ( exists $_->{group} ) { |
|
|
|
50
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
13
|
$button_group->add_child( $self->button_group($_) ); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
elsif ( delete $_->{dropdown} ) { |
|
56
|
|
|
|
|
|
|
$button_group->add_child( |
|
57
|
0
|
|
|
|
|
0
|
$self->dropdown( { %{$_}, %drop_down_args } ) ); |
|
|
0
|
|
|
|
|
0
|
|
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
else { |
|
60
|
48
|
|
|
|
|
312
|
$button_group->add_child( $self->button($_) ); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
27
|
|
|
|
|
58375
|
for ( @{ $build_args->{nested} } ) { |
|
|
27
|
|
|
|
|
129
|
|
|
65
|
4
|
|
|
|
|
16
|
my $index = delete $_->{index}; |
|
66
|
|
|
|
|
|
|
my $nested_button_group = |
|
67
|
|
|
|
|
|
|
delete $_->{dropdown} |
|
68
|
4
|
50
|
|
|
|
46
|
? $self->dropdown( { %{$_}, %drop_down_args } ) |
|
|
0
|
|
|
|
|
0
|
|
|
69
|
|
|
|
|
|
|
: $self->button_group($_); |
|
70
|
|
|
|
|
|
|
|
|
71
|
4
|
100
|
|
|
|
18
|
if ($index) { |
|
72
|
2
|
|
|
|
|
8
|
splice @{ $button_group->{children} }, $index - 1, 0, |
|
|
2
|
|
|
|
|
13
|
|
|
73
|
|
|
|
|
|
|
$nested_button_group; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
else { |
|
76
|
2
|
|
|
|
|
7
|
push @{ $button_group->{children} }, $nested_button_group; |
|
|
2
|
|
|
|
|
9
|
|
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
27
|
|
|
|
|
302
|
return $button_group; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |