Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 22ae0bf0

Von Sven Schöling vor fast 14 Jahren hinzugefügt

date_tag

Beispiel ist hier nicht mit enthalten, weil der date_tag gleichzeitig einen
graphischen datepicker rendert, deshalb hier im Commit:

[% USE L ]
[
L.date_tag('orddate', orddate, cal_align => 'BL') %]

Das erste ist der name in html, das zweite der Wert zum befüllen, das dritte
die Orientierung des Popups.

Unterschiede anzeigen:

SL/Template/Plugin/L.pm
5 5

  
6 6
use strict;
7 7

  
8
{ # This will give you an id for identifying html tags and such.
9
  # It's guaranteed to be unique unless you exceed 10 mio calls per request.
10
  # Do not use these id's to store information across requests.
11
my $_id_sequence = int rand 1e7;
12
sub _tag_id {
13
  return $_id_sequence = ($_id_sequence + 1) % 1e7;
14
}
15
}
16

  
8 17
sub _H {
9 18
  my $string = shift;
10 19
  return $::locale->quote_special_chars('HTML', $string);
......
132 141
  return $code;
133 142
}
134 143

  
144
sub javascript {
145
  my ($self, $data) = @_;
146
  return $self->html_tag('script', $data, type => 'text/javascript');
147
}
148

  
149
sub date_tag {
150
  my ($self, $name, $value, @slurp) = @_;
151
  my %params   = _hashify(@slurp);
152
  my $name_e   = _H($name);
153
  my $seq      = _tag_id();
154

  
155
  $params{cal_align} ||= 'BR';
156

  
157
  $self->input_tag($name, $value,
158
    size   => 11,
159
    title  => _H($::myconfig{dateformat}),
160
    onBlur => 'check_right_date_format(this)',
161
    %params,
162
  ) . ((!$params{no_cal}) ?
163
  $self->html_tag('img', undef,
164
    src    => 'image/calendar.png',
165
    id     => "trigger$seq",
166
    title  => _H($::myconfig{dateformat}),
167
    %params,
168
  ) .
169
  $self->javascript(
170
    "Calendar.setup({ inputField: '$name_e', ifFormat: '$::myconfig{jsc_dateformat}', align: '$params{cal_align}', button: 'trigger$seq'  });"
171
  ) : '');
172
}
173

  
135 174
1;
136 175

  
137 176
__END__
......
213 252
created with said C<label>. No attribute named C<label> is created in
214 253
that case.
215 254

  
255
=item C<date_tag $name, $value, %attributes>
256

  
257
=item C<date_tag $name, $value, cal_align =E<gt> $align_code, %attributes>
258

  
259
Creates a date input field, with an attached javascript that will open a
260
calendar on click. The javascript ist by default anchoered at the bottom right
261
sight. This can be overridden with C<cal_align>, see Calendar documentation for
262
the details, usually you'll want a two letter abbreviation of the alignment.
263
Right + Bottom becomes C<BL>.
264

  
216 265
=back
217 266

  
218 267
=head2 CONVERSION FUNCTIONS

Auch abrufbar als: Unified diff