Revision 59

Date:
2010/09/13 12:07:22
Author:
ahitrov@rambler.ru
Revision Log:
Расширение возможностей и настроек контролек date и datetime
Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/core/comps/contenido/components/inputs/date.msn

     
    27 27 } elsif(!$prop->{allow_null}) {
    28 28 ($day,$month,$year) = @localtime[3 .. 5];
    29 29 }
    30 my $now = Contenido::DateTime->new;
    31
    30 32 </%init>
    31 33
    32 34 <& "/contenido/components/select.msn", name => $name.'_day', values => \@days, check => $day &><&
    33 35 '/contenido/components/select.msn', name => $name.'_month', values => $months, check => $month &><&
    34 36 '/contenido/components/select.msn', name => $name.'_year', values => \@years, check => $year &>
    37 <span style="padding-left:20px;"><a href="javascript:void(0)" onclick="set_<% $prop->{attr} %>_now()" style="color:red;">Сейчас!</a></span>
    38 <script type="text/javascript">
    39 <!--
    40 function set_<% $prop->{attr} %>_now () {
    41 document.forms['form'].elements['<% $prop->{attr} %>_day'].value = '<% $now->day %>';
    42 document.forms['form'].elements['<% $prop->{attr} %>_month'].value = '<% $now->mon %>';
    43 document.forms['form'].elements['<% $prop->{attr} %>_year'].value = '<% $now->year %>';
    44 }
    45 //-->
    46 </script>
  • utf8/core/comps/contenido/components/inputs/datetime.msn

     
    4 4 &nbsp;&nbsp;
    5 5 <& '/contenido/components/select.msn', name => $name.'_hour', values => \@hours, check => $hour &>
    6 6 <& '/contenido/components/select.msn', name => $name.'_minute', values => \@minutes, check => $minute &>
    7 % if ( $prop->{noseconds} ) {
    8 <input type="hidden" name="<% $prop->{attr} %>_second" value="0">
    9 % } else {
    7 10 <& '/contenido/components/select.msn', name => $name.'_second', values => \@seconds, check => $second &>
    8
    11 % }
    12 <span style="padding-left:20px;"><a href="javascript:void(0)" onclick="set_<% $prop->{attr} %>_now()" style="color:red;">Сейчас!</a></span>
    13 <script type="text/javascript">
    14 <!--
    15 function set_<% $prop->{attr} %>_now () {
    16 document.forms['form'].elements['<% $prop->{attr} %>_day'].value = '<% $now->day %>';
    17 document.forms['form'].elements['<% $prop->{attr} %>_month'].value = '<% $now->mon %>';
    18 document.forms['form'].elements['<% $prop->{attr} %>_year'].value = '<% $now->year %>';
    19 document.forms['form'].elements['<% $prop->{attr} %>_hour'].value = '<% $now->hour %>';
    20 document.forms['form'].elements['<% $prop->{attr} %>_minute'].value = '<% $now->minute %>';
    21 % unless ( $prop->{noseconds} ) {
    22 document.forms['form'].elements['<% $prop->{attr} %>_second'].value = '<% $now->second %>';
    23 % }
    24 }
    25 //-->
    26 </script>
    9 27 <%args>
    10 28 $prop
    11 29 $name => undef
     
    21 39 my @months = @{ $m->comp('/contenido/components/get_months.msn') };
    22 40 my @years = map { $_ => $_ } ( $localtime[5] - 5 .. $localtime[5] + 5);
    23 41 my @hours = map { $_ => sprintf('%02d', $_) } (0 .. 23);
    24 my @minutes = map { $_ => sprintf('%02d', $_) } (0 ..59);
    25 my @seconds = map { $_ => sprintf('%02d', $_) } (0 ..59);
    42 my @minutes = map { $_ => sprintf('%02d', $_) } (0 .. 59);
    43 my @seconds;
    44 if ( exists $prop->{seconds_step} && $prop->{seconds_step} > 1 ) {
    45 @seconds = grep { ($_ % $prop->{seconds_step}) == 0 } map { $_ => sprintf('%02d', $_) } (0 .. 59);
    46 } else {
    47 @seconds = map { $_ => sprintf('%02d', $_) } (0 .. 59);
    48 }
    26 49
    27 50 if ($prop->{allow_null}) {
    28 51 unshift @days, '', '';
     
    40 63 } elsif(!$prop->{allow_null}) {
    41 64 ($second,$minute,$hour,$day,$month,$year) = @localtime[0 .. 5];
    42 65 }
    66 my $now = Contenido::DateTime->new;
    67
    43 68 </%init>