Quiq/Html/Widget/Button.pm

filter: Statementstmt 93.1% 27 / 29 Branchbran 66.6% 4 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 91.8% 45 / 49 CC 5 SCAR 10.8
CC
5
Cov
89%
html
5.3
BEGIN
1.0
BEGIN
1.0
CRAP 2.9
« Quiq/Html/Table/Base.pm ↑ Summary Quiq/SoapWsdlServiceCgi.pm »
1 # -----------------------------------------------------------------------------
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 Quiq::Html::Widget::Button - Schaltfläche
8  
9 =head1 BASE CLASS
10  
11 L<Quiq::Html::Widget>
12  
13 =head1 ATTRIBUTES
14  
15 =over 4
16  
17 =item class => $class (Default: undef)
18  
19 CSS Klasse.
20  
21 =item content => $html (Default: undef)
22  
23 Button-Label (allgemeiner HTML-Content).
24  
25 =item disabled => $bool (Default: 0)
26  
27 Keine Eingabe möglich.
28  
29 =item hidden => $bool (Default: 0)
30  
31 Nicht sichtbar.
32  
33 =item id => $id (Default: undef)
34  
35 CSS-Id.
36  
37 =item name => $name (Default: undef)
38  
39 Name, unter dem der Button kommuniziert wird.
40  
41 =item onClick => $js (Default: undef)
42  
43 OnClick-Handler.
44  
45 =item style => $style (Default: undef)
46  
47 CSS Definition (inline).
48  
49 =item title => $str (Default: undef)
50  
51 Tooltip-Text.
52  
53 =item type => $type (Default: 'button')
54  
55 Button-Typ: 'button', 'submit' oder 'reset'.
56  
57 =item undefIf => $bool (Default: 0)
58  
59 Wenn wahr, liefere C<undef> als Widget-Code.
60  
61 =item value => $value (Default: undef)
62  
63 Wert, der gesendet wird.
64  
65 =back
66  
67 =cut
68  
69 # -----------------------------------------------------------------------------
70  
71 package Quiq::Html::Widget::Button;
72 3 ▶use base qw/Quiq::Html::Widget/;
Subroutine BEGIN: called CC=1 SCAR=0.0
73  
74 3 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
77  
78 3 our $VERSION = '1.240';
79  
80 3 ▶use Quiq::JavaScript;
Subroutine BEGIN: called CC=1 SCAR=0.0
81  
82 # -----------------------------------------------------------------------------
83  
84 =head1 METHODS
85  
86 =head2 Konstruktor
87  
88 =head3 new() - Konstruktor
89  
90 =head4 Synopsis
91  
92 $e = $class->new(@keyVal);
93  
94 =cut
95  
96 # -----------------------------------------------------------------------------
97  
98 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
99 4 my $class = shift;
100 # @_: @keyVal
101  
102 # Defaultwerte
103  
104 4 my $self = $class->SUPER::new(
105 class => undef,
106 content => undef,
107 disabled => 0,
108 hidden => 0,
109 id => undef,
110 name => undef,
111 onClick => undef,
112 style => undef,
113 title => undef,
114 type => 'button',
115 undefIf => 0,
116 value => undef,
117 );
118 4 $self->set(@_);
119  
120 4 return $self;
121 }
122  
123 # -----------------------------------------------------------------------------
124  
125 =head2 Objektmethoden
126  
127 =head3 html() - Generiere HTML-Code
128  
129 =head4 Synopsis
130  
131 $html = $e->html($h);
132 $html = $class->html($h,@keyVal);
133  
134 =cut
135  
136 # -----------------------------------------------------------------------------
137  
138 4 ▶sub html {
Subroutine html: called CC=5 SCAR=16.6
Pod documented
139 4 my $this = shift;
140 4 my $h = shift;
141  
142 4 ▶ my $self = ref $this? $this: $this->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $this ? : 2 2 4
143  
144 # Attribute
145  
146 4 my ($class,$content,$disabled,$hidden,$id,$name,$onClick,$style,
147 $title,$type,$undefIf,$value) = $self->get(qw/class content disabled
148 hidden id name onClick style title type undefIf value/);
149  
150 # Generierung
151  
152 4 ▶ if ($undefIf) {
Branch: 1 branch
BranchTrueFalseTotal
if ($undefIf) 0 4 4
153 0 return undef;
154 }
155  
156 4 ▶ if ($hidden) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hidden) 0 4 4
157 0 return '';
158 }
159  
160 4 ▶ return $h->tag('button',
Condition100%3/3
$content || $value
l!l&&r!l&&!r
211
MC/DC100%2/2
$content || $value
$content $value
Truth table100%3/3
A || B
A= $contentB= $value
ABresult
1X1
011
000
161 id => $id,
162 name => $name,
163 type => $type,
164 class => $class,
165 style => $style,
166 value => $value,
167 disabled => $disabled,
168 onclick => Quiq::JavaScript->line($onClick),
169 title => $title,
170 $content || $value
171 );
172 }
173  
174 # -----------------------------------------------------------------------------
175  
176 =head1 VERSION
177  
178 1.240
179  
180 =head1 AUTHOR
181  
182 Frank Seitz, L<http://fseitz.de/>
183  
184 =head1 COPYRIGHT
185  
186 Copyright (C) 2026 Frank Seitz
187  
188 =head1 LICENSE
189  
190 This code is free software; you can redistribute it and/or modify
191 it under the same terms as Perl itself.
192  
193 =cut
194  
195 # -----------------------------------------------------------------------------
196  
197 3 1;
198  
199 # eof
« Quiq/Html/Table/Base.pm ↑ Summary Quiq/SoapWsdlServiceCgi.pm »