Revision 3 (by ahitrov@rambler.ru, 2010/03/24 15:19:32) The CORE
%# vim:syn=mason

% if ($object->$name) {
	<table>
	<tr><th>��������</th><th>�������?</th></tr>
%	foreach my $geoid ($object->$name) {
		<tr><td><% $all_labels->{$geoid} || '����������' %></td><td><input type="checkbox" name="<% $name %>_delete" value="<% $geoid %>"/></td></tr>
%	}
	</table>
% }

��������: 
<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' : '' %>>
<select name="<% $name %>_add"<% $prop->{readonly} ? ' disabled' : '' %>>
	<option value="" selected="selected"></option>
% foreach my $value (sort { $all_labels->{$a} cmp $all_labels->{$b} } keys %$all_values) {
	<option value="<% $value %>"><% $all_labels->{$value} %></option>
% }
</select>

<script type="text/javascript">
	var key_flag_<% $name %> = 1;

	if (navigator.appName == "Netscape") {
		document.captureEvents(Event.KEYUP);
	}

	function find_word_<% $name %>() {
		var str1 = document.form.<% $name."_tmp" %>.value;
		if (str1 == "" || key_flag_<% $name %>) return;

		for (var i = 0; i < document.form.<% $name %>_add.options.length; i++) {
			var source = document.form.<% $name %>_add.options[i].text;
			source = source.toLowerCase();
			str1 = str1.toLowerCase();
			if ( source.indexOf(str1) == 0) {
				document.form.<% $name %>_add.options[i].selected=true;
				break;
			}
		}
	}

</script>
<%args>
	$object
	$name => undef
	$check => undef
	$prop => {}
</%args>
<%init>
	use locale;

	my ($all_values, $all_labels);

    my $geo_type = $prop->{'geo_type'} || [1, 3]; # �� ��������� �������� ������� ������ � ������

	foreach my $i (@{$geo_type}) {
		my ($err, $msg) = $rpc_client->id->get_geo_tree($i);
		return unless $err->{success};
		map { $all_values->{$_} = 1 } @{$msg->{values}};
		$all_labels->{$_} = $msg->{labels}->{$_} foreach keys %{$msg->{labels}};
	}
    
</%init>