line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormWidgets::Slider; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
645
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
5
|
use parent 'HTML::FormWidgets'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw(config display) ); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub init { |
10
|
1
|
|
|
1
|
1
|
3
|
my ($self, $args) = @_; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
7
|
$self->config ( { knob_class => q(".knob"), |
13
|
|
|
|
|
|
|
mode => q("horizontal"), |
14
|
|
|
|
|
|
|
offset => 0, |
15
|
|
|
|
|
|
|
range => 'false', |
16
|
|
|
|
|
|
|
snap => 'true', |
17
|
|
|
|
|
|
|
steps => 100, |
18
|
|
|
|
|
|
|
wheel => 'true', } ); |
19
|
1
|
|
|
|
|
9
|
$self->default( 50 ); |
20
|
1
|
|
|
|
|
6
|
$self->display( 1 ); |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
5
|
return; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub render_field { |
26
|
1
|
|
|
1
|
1
|
2
|
my ($self, $args) = @_; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
3
|
my $hacc = $self->hacc; |
29
|
1
|
|
|
|
|
5
|
my $id = $args->{name}.'_slider'; |
30
|
1
|
|
|
|
|
3
|
my $size = int ((log $self->config->{steps}) / (log 10)); |
31
|
1
|
|
|
|
|
6
|
my $html = q(); |
32
|
1
|
|
|
|
|
2
|
my $text; |
33
|
|
|
|
|
|
|
|
34
|
1
|
50
|
|
|
|
3
|
if ($self->display) { |
35
|
|
|
|
|
|
|
$html .= $hacc->textfield( { class => 'ifield numeric', |
36
|
|
|
|
|
|
|
name => $args->{name}, |
37
|
|
|
|
|
|
|
readonly => 'readonly', |
38
|
|
|
|
|
|
|
size => $size, |
39
|
1
|
|
|
|
|
11
|
value => $args->{default} } ); |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
0
|
else { $self->add_hidden( $args->{name}, $args->{default} ) } |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
52
|
$text = $hacc->span( { class => 'knob' } ); |
44
|
1
|
|
|
|
|
28
|
$text = $hacc->span( { class => 'slider', id => $id }, $text ); |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
25
|
for (0 .. 10) { |
47
|
11
|
|
|
|
|
280
|
my $style = 'left: '.(-1 + $_ * 20).'px;'; |
48
|
|
|
|
|
|
|
|
49
|
11
|
|
|
|
|
57
|
$text .= $hacc->span( { class => 'tick', style => $style } ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
29
|
$html .= $hacc->span( { class => 'slider_group' }, $text ); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
25
|
$self->config->{default_v} = $args->{default}; |
55
|
1
|
|
|
|
|
8
|
$self->config->{name } = '"'.$args->{name}.'"'; |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
6
|
$self->add_literal_js( 'sliders', $id, $self->config ); |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
3
|
return $html; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Local Variables: |
67
|
|
|
|
|
|
|
# mode: perl |
68
|
|
|
|
|
|
|
# tab-width: 3 |
69
|
|
|
|
|
|
|
# End: |
70
|
|
|
|
|
|
|
|