1 |
8 |
ahitrov@rambler.ru |
%# vim:syn=mason |
2 |
|
|
|
3 |
|
|
% if ($object->$name) { |
4 |
|
|
<table> |
5 |
|
|
<tr><th>Название</th><th>Удалить?</th></tr> |
6 |
|
|
% foreach my $geoid ($object->$name) { |
7 |
|
|
<tr><td><% $all_labels->{$geoid} || 'неизвестно' %></td><td><input type="checkbox" name="<% $name %>_delete" value="<% $geoid %>"/></td></tr> |
8 |
|
|
% } |
9 |
|
|
</table> |
10 |
|
|
% } |
11 |
|
|
|
12 |
|
|
Добавить: |
13 |
|
|
<input onkeyup="find_word_<% $name %>()" type="text" name="<% $name."_tmp" %>" size="10" onfocus="key_flag_<% $name %> = 0;" onblur="key_flag_<% $name %> = 1;"<% $prop->{readonly} ? 'readonly' : '' %>> |
14 |
|
|
<select name="<% $name %>_add"<% $prop->{readonly} ? ' disabled' : '' %>> |
15 |
|
|
<option value="" selected="selected"></option> |
16 |
|
|
% foreach my $value (sort { $all_labels->{$a} cmp $all_labels->{$b} } keys %$all_values) { |
17 |
|
|
<option value="<% $value %>"><% $all_labels->{$value} %></option> |
18 |
|
|
% } |
19 |
|
|
</select> |
20 |
|
|
|
21 |
|
|
<script type="text/javascript"> |
22 |
|
|
var key_flag_<% $name %> = 1; |
23 |
|
|
|
24 |
|
|
if (navigator.appName == "Netscape") { |
25 |
|
|
document.captureEvents(Event.KEYUP); |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
function find_word_<% $name %>() { |
29 |
|
|
var str1 = document.form.<% $name."_tmp" %>.value; |
30 |
|
|
if (str1 == "" || key_flag_<% $name %>) return; |
31 |
|
|
|
32 |
|
|
for (var i = 0; i < document.form.<% $name %>_add.options.length; i++) { |
33 |
|
|
var source = document.form.<% $name %>_add.options[i].text; |
34 |
|
|
source = source.toLowerCase(); |
35 |
|
|
str1 = str1.toLowerCase(); |
36 |
|
|
if ( source.indexOf(str1) == 0) { |
37 |
|
|
document.form.<% $name %>_add.options[i].selected=true; |
38 |
|
|
break; |
39 |
|
|
} |
40 |
|
|
} |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
</script> |
44 |
|
|
<%args> |
45 |
|
|
$object |
46 |
|
|
$name => undef |
47 |
|
|
$check => undef |
48 |
|
|
$prop => {} |
49 |
|
|
</%args> |
50 |
|
|
<%init> |
51 |
|
|
use locale; |
52 |
|
|
|
53 |
|
|
my ($all_values, $all_labels); |
54 |
|
|
|
55 |
|
|
my $geo_type = $prop->{'geo_type'} || [1, 3]; # По умолчанию выбираем регионы России и страны |
56 |
|
|
|
57 |
|
|
foreach my $i (@{$geo_type}) { |
58 |
|
|
my ($err, $msg) = $rpc_client->id->get_geo_tree($i); |
59 |
|
|
return unless $err->{success}; |
60 |
|
|
map { $all_values->{$_} = 1 } @{$msg->{values}}; |
61 |
|
|
$all_labels->{$_} = $msg->{labels}->{$_} foreach keys %{$msg->{labels}}; |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
</%init> |