Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6be0a1ce

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

  • ID 6be0a1ce013f6355b88f869efbfc557e0f7dc394
  • Vorgänger 13fddaf3
  • Nachfolger 083f2ba7

MaterialComponents: date_tag Komponente

Unterschiede anzeigen:

SL/Presenter/MaterialComponents.pm
27 27
use constant SMALL           => 'small';
28 28
use constant TINY            => 'tiny';
29 29
use constant INPUT_FIELD     => 'input-field';
30
use constant DATEPICKER      => 'datepicker';
30 31

  
31 32
use constant WAVES_EFFECT    => 'waves-effect';
32 33
use constant WAVES_LIGHT     => 'waves-light';
......
204 205
  );
205 206
}
206 207

  
208
sub date_tag {
209
  my ($name, $value, %attributes) = @_;
210

  
211
  _set_id_attribute(\%attributes, $name);
212

  
213
  my $icon  = $attributes{icon}
214
    ? icon(delete $attributes{icon}, class => 'prefix')
215
    : '';
216

  
217
  my $label = $attributes{label}
218
    ? html_tag('label', delete $attributes{label}, for => $attributes{id})
219
    : '';
220

  
221
  $attributes{type} = 'text'; # required for materialize
222

  
223
  my @onchange = $attributes{onchange} ? (onChange => delete $attributes{onchange}) : ();
224
  my @classes  = (delete $attributes{class});
225

  
226
  $::request->layout->add_javascripts('kivi.Validator.js');
227
  $::request->presenter->need_reinit_widgets($attributes{id});
228

  
229
  $attributes{'data-validate'} = join(' ', "date", grep { $_ } (delete $attributes{'data-validate'}));
230

  
231
  html_tag('div',
232
    $icon .
233
    html_tag('input',
234
      blessed($value) ? $value->to_lxoffice : $value,
235
      size   => 11, type => 'text', name => $name,
236
      %attributes,
237
      class => DATEPICKER, @onchange,
238
    ) .
239
    $label,
240
    class => [ grep $_, @classes, INPUT_FIELD ],
241
  );
242

  
207 243

  
208 244
}
209 245

  
templates/mobile_webpages/test/components.html
39 39
[% P.M.input_tag("i1", "", placeholder="2 cols placeholder", icon="phone", class="col s6") %]
40 40
[% P.M.input_tag("i2", "", label="2 cols label", icon="account_circle", class="col s6") %]
41 41
</div>
42

  
43
<h2>Date Picker</h2>
44

  
45
<div class="row">
46
[% P.M.date_tag("d1", "", label="date of birth", class="col s6", icon="date_range") %]
47
[% P.M.date_tag("d1", "", class="col s6", placeholder="date of birth?", icon="access_time") %]
48
</div>

Auch abrufbar als: Unified diff