line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## HTML Object - ~/lib/HTML/Object/DOM/Element/Progress.pm |
3
|
|
|
|
|
|
|
## Version v0.2.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2021 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2021/12/23 |
7
|
|
|
|
|
|
|
## Modified 2022/09/18 |
8
|
|
|
|
|
|
|
## All rights reserved |
9
|
|
|
|
|
|
|
## |
10
|
|
|
|
|
|
|
## |
11
|
|
|
|
|
|
|
## This program is free software; you can redistribute it and/or modify it |
12
|
|
|
|
|
|
|
## under the same terms as Perl itself. |
13
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
package HTML::Object::DOM::Element::Progress; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
1
|
|
|
1
|
|
957
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
18
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
19
|
1
|
|
|
1
|
|
7
|
use parent qw( HTML::Object::DOM::Element ); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
5
|
|
20
|
1
|
|
|
1
|
|
63
|
use vars qw( $VERSION ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
42
|
|
21
|
1
|
|
|
1
|
|
6
|
use HTML::Object::DOM::Element::Shared qw( :progress ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
124
|
|
22
|
1
|
|
|
1
|
|
18
|
our $VERSION = 'v0.2.0'; |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
20
|
|
26
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
261
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub init |
29
|
|
|
|
|
|
|
{ |
30
|
0
|
|
|
0
|
1
|
|
my $self = shift( @_ ); |
31
|
0
|
|
|
|
|
|
$self->{max} = '1.0'; |
32
|
0
|
|
|
|
|
|
$self->{value} = 0; |
33
|
0
|
|
|
|
|
|
$self->{_init_strict_use_sub} = 1; |
34
|
0
|
0
|
|
|
|
|
$self->SUPER::init( @_ ) || return( $self->pass_error ); |
35
|
0
|
0
|
|
|
|
|
$self->{tag} = 'progress' if( !CORE::length( "$self->{tag}" ) ); |
36
|
0
|
|
|
|
|
|
return( $self ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Note: property labels read-only inherited |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Note: property max |
42
|
0
|
|
|
0
|
1
|
|
sub max : lvalue { return( shift->_set_get_property( 'max', @_ ) ); } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Note: property position read-only |
45
|
|
|
|
|
|
|
sub position |
46
|
|
|
|
|
|
|
{ |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift( @_ ); |
48
|
0
|
|
|
|
|
|
my $val = $self->value; |
49
|
0
|
|
|
|
|
|
my $max = $self->max; |
50
|
0
|
0
|
0
|
|
|
|
return(-1) if( !defined( $max ) || !CORE::length( "$max" ) || int( $max ) == 0 ); |
|
|
|
0
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return( $self->new_number( int( $val ) / int( $max ) ) ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Note: property value inherited |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
# NOTE: POD |
58
|
|
|
|
|
|
|
__END__ |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=encoding utf-8 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
HTML::Object::DOM::Element::Progress - HTML Object DOM Progress Class |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
use HTML::Object::DOM::Element::Progress; |
69
|
|
|
|
|
|
|
my $progress = HTML::Object::DOM::Element::Progress->new || |
70
|
|
|
|
|
|
|
die( HTML::Object::DOM::Element::Progress->error, "\n" ); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
v0.2.0 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This interface provides special properties and methods (beyond the regular L<HTML::Object::Element> interface it also has available to it by inheritance) for manipulating the layout and presentation of C<<progress>> elements. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 INHERITANCE |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +--------------------------------------+ |
83
|
|
|
|
|
|
|
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Progress | |
84
|
|
|
|
|
|
|
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +--------------------------------------+ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 PROPERTIES |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Inherits properties from its parent L<HTML::Object::DOM::Element> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 labels |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Read-only. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Returns L<NodeList|HTML::Object::DOM::NodeList> containing the list of L<<label>|HTML::Object::DOM::Label> elements that are labels for this element. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Example: |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
<label id="label1" for="test">Label 1</label> |
99
|
|
|
|
|
|
|
<progress id="test" value="70" max="100">70%</progress> |
100
|
|
|
|
|
|
|
<label id="label2" for="test">Label 2</label> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
use HTML::Object::DOM qw( window ); |
103
|
|
|
|
|
|
|
window->addEventListener( DOMContentLoaded => sub |
104
|
|
|
|
|
|
|
{ |
105
|
|
|
|
|
|
|
my $progress = $doc->getElementById( 'test' ); |
106
|
|
|
|
|
|
|
for( my $i = 0; $i < $progress->labels->length; $i++ ) |
107
|
|
|
|
|
|
|
{ |
108
|
|
|
|
|
|
|
say( $progress->labels->[$i]->textContent ); # "Label 1" and "Label 2" |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
}); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLProgressElement/labels> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 max |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Is a double value reflecting HTML attribute that describes the content attribute of the same name, limited to numbers greater than zero. Its default value is 1.0. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLProgressElement/max> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 position |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Read-only. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Returns a double value returning the result of dividing the current value (value) by the maximum value (max); if the progress bar is an indeterminate progress bar, it returns C<-1>. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLProgressElement/position> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 value |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Is a double value reflecting the HTML attribute that describes the current value; if the progress bar is an indeterminate progress bar, it returns C<0>. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my $progress = $doc->createElement( 'progress' ); |
133
|
|
|
|
|
|
|
$progress->value = 2; # <progress value="2"></progress> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLProgressElement/value> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 METHODS |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Inherits methods from its parent L<HTML::Object::DOM::Element> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 SEE ALSO |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLProgressElement>, L<Mozilla documentation on progress element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Copyright(c) 2021 DEGUEST Pte. Ltd. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
All rights reserved |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |