Line # | Revision | Author | |
---|---|---|---|
1 | 8 | ahitrov@rambler.ru | <select name="<% $name %>" id="<% $name %>_select" style="width: 37%;" onchange="<% $name %>_changed();"> |
2 | % if ($prop->{allow_null}) { | ||
3 | <option value="" <% defined $check ? '' : 'selected' %>>--- не указано ---</option> | ||
4 | % } | ||
5 | % for my $sm (@{ $status_map }) { | ||
6 | <option value="<% $sm->[0] %>" <% (defined($check) && ($check eq $sm->[0])) ? 'selected' : '' %>><% defined $sm->[1] ? $sm->[1] : "$sm->[0] [unknown value]" %></option> | ||
7 | % } | ||
8 | </select> | ||
9 | |||
10 | <table id="<% $name %>_prev_table" style="width: 37%; display: none;" cellspacing="0" cellpadding="0" border="0"> | ||
11 | <tr> | ||
12 | <td width="100%" id="<% $name %>_prev_text" class="bb undo" style="padding: 3px;"></td> | ||
13 | <td style="padding-left: 3px; vertical-align: top;"><a href="#" onclick="return <% $name %>_undo();" title="Отменить изменения"><img src="/contenido/i/undo-19x19.gif" width="19" height="19" class="bb gb"></a></td> | ||
14 | </tr> | ||
15 | </table> | ||
16 | |||
17 | <script type="text/javascript"> | ||
18 | var <% $name %>_prev_value = document.getElementById('<% $name %>_select').selectedIndex; | ||
19 | |||
20 | function <% $name %>_changed() { | ||
21 | var t = document.getElementById('<% $name %>_prev_table'); | ||
22 | if (document.getElementById('<% $name %>_select').selectedIndex==<% $name %>_prev_value) { | ||
23 | if (t.style.display!='none') { | ||
24 | t.style.display = 'none'; | ||
25 | } | ||
26 | return; | ||
27 | } | ||
28 | if (t.style.display=='none') { | ||
29 | t.style.display = ''; | ||
30 | } | ||
31 | } | ||
32 | |||
33 | function <% $name %>_undo() { | ||
34 | document.getElementById('<% $name %>_select').selectedIndex = <% $name %>_prev_value; | ||
35 | <% $name %>_changed(); | ||
36 | return false; | ||
37 | } | ||
38 | |||
39 | var s = document.getElementById('<% $name %>_select'); | ||
40 | document.getElementById('<% $name %>_prev_text').innerHTML = s.options.item(s.selectedIndex).innerHTML || ' '; | ||
41 | </script> | ||
42 | |||
43 | <%ARGS> | ||
44 | $name => undef | ||
45 | $check => undef | ||
46 | $mode => 'view' | ||
47 | $prop => {} | ||
48 | </%ARGS> | ||
49 | <%INIT> | ||
50 | # тут надо копию массива... иначе push @{$status_map} ломает default значения в $prop->{cases} или в $keeper->default_status() | ||
51 | my $status_map = [ @{ref $prop->{cases} eq 'ARRAY' ? $prop->{cases} : $keeper->default_status()} ]; | ||
52 | if ($mode eq 'get') { | ||
53 | return $status_map; | ||
54 | } | ||
55 | if (defined $check) { | ||
56 | unless (grep {$_->[0] eq $check} @{$status_map}) { | ||
57 | push @{$status_map}, [$check, "$check [unknown value]"]; | ||
58 | } | ||
59 | } | ||
60 | </%INIT> |