File Coverage

lib/HTML/FormWidgets/Date.pm
Criterion Covered Total %
statement 29 29 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 37 38 97.3


line stmt bran cond sub pod time code
1             package HTML::FormWidgets::Date;
2              
3 1     1   751 use strict;
  1         3  
  1         23  
4 1     1   5 use warnings;
  1         1  
  1         27  
5 1     1   4 use parent 'HTML::FormWidgets';
  1         1  
  1         6  
6              
7             __PACKAGE__->mk_accessors( qw( config width ) );
8              
9             my $SPC = q( );
10             my $TTS = q( ~ );
11              
12             sub init {
13 1     1 1 3    my ($self, $args) = @_;
14              
15 1         7    $self->config ( { align => '"bR"',
16                                   ifFormat => '"%d/%m/%Y"',
17                                   singleClick => 'true' } );
18 1         10    $self->readonly( 1 );
19 1         6    $self->width ( 10 );
20 1         5    return;
21             }
22              
23             sub render_field {
24 1     1 1 3    my ($self, $args) = @_; my $hacc = $self->hacc;
  1         4  
25              
26 1         11    $self->add_optional_js( 'calendar.js', 'calendar-setup.js' );
27 1         4    $self->add_literal_js ( 'calendars', $self->id, $self->config );
28              
29 1 50       6    $args->{class} .= ($args->{class} ? $SPC : q()).'ifield calendars';
30 1         5    $args->{size } = $self->width;
31              
32 1         9    my $html = $hacc->textfield( $args );
33 1         66    my $hint = $self->hint_title.$TTS.$self->loc( 'dateWidgetTip' );
34 1         9    my $icon = $hacc->span( { class => 'calendar_icon' }, $SPC );
35 1         47    my $text = $hacc->span( { class => 'icon_button tips',
36                                          id => $self->id.'_trigger',
37                                          title => $hint }, $icon );
38              
39 1         42    $hint = $self->hint_title.$TTS.$self->loc( 'clearFieldTip' );
40 1         8    $icon = $hacc->span( { class => 'clear_field_icon' }, $SPC );
41 1         31    $text .= $hacc->span( { class => 'icon_button tips',
42                                          id => $self->id.'_clear',
43                                          title => $hint }, $icon );
44 1         40    $html .= $text;
45              
46 1         4    return $html;
47             }
48              
49             1;
50              
51             # Local Variables:
52             # mode: perl
53             # tab-width: 3
54             # End:
55              
56