1 |
3 |
ahitrov@rambler.ru |
% unless ($error) { |
2 |
|
|
<table width="100%" cellspacing="0" cellpadding="0" border="0"> |
3 |
|
|
<tr> |
4 |
|
|
<td width="15%" style="padding-right: 3px;"> |
5 |
|
|
<input onkeyup="find_word_<% $name %>()" type="text" name="<% $name."_tmp" %>" size="10" onfocus="key_flag_<% $name %> = 0;" onblur="key_flag_<% $name %> = 1;" style="width: 100%;" <% $prop->{readonly} ? 'readonly' : '' %>> |
6 |
|
|
</td> |
7 |
|
|
<td width="80%"> |
8 |
|
|
<input type="hidden" name="<% $name %>" id="<% $name %>_hidden" value="<% $check ? $check : ($prop->{allow_null} ? '' : (@list ? $list[0]->id : '')) %>"> |
9 |
|
|
<select id="<% $name %>_select" class="selects" <% $prop->{readonly} ? 'readonly' : '' %> style="width: 100%;" onchange="<% $name %>_changed();"> |
10 |
|
|
|
11 |
|
|
% if ($prop->{allow_null}) { |
12 |
|
|
<option value="" <% defined($check) ? '' : 'selected' %>>--- �� ������� ---</option> |
13 |
|
|
% } |
14 |
|
|
|
15 |
|
|
% for (@list) { |
16 |
|
|
<option value="<% $_->id %> <% $_->class %>" <% defined($check) && $check eq $_->id ? "selected" : "" %>><% $prop->{'list_field'} ? $_->{$prop->{'list_field'}} : $_->name %></option> |
17 |
|
|
% } |
18 |
|
|
</select> |
19 |
|
|
</td> |
20 |
|
|
<td style="padding-left: 10px;"><a href="#" onclick="return <% $name %>_popup();" title="����� ��������"><img src="/contenido/i/lookup-19x19.gif" width="19" height="19" class="bb gb"></a></td> |
21 |
|
|
</tr> |
22 |
|
|
|
23 |
|
|
<tr id="<% $name %>_prev_table" style="display: none;"> |
24 |
|
|
<td> </td> |
25 |
|
|
<td> |
26 |
|
|
<table width="100%" cellspacing="0" cellpadding="0" border="0"> |
27 |
|
|
<tr> |
28 |
|
|
<td width="100%" id="<% $name %>_prev_text" class="bb undo" style="padding: 3px;"></td> |
29 |
|
|
<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> |
30 |
|
|
</tr> |
31 |
|
|
</table> |
32 |
|
|
</td> |
33 |
|
|
<td> </td> |
34 |
|
|
</tr> |
35 |
|
|
</table> |
36 |
|
|
|
37 |
|
|
<script type="text/javascript"> |
38 |
|
|
var key_flag_<% $name %> = 1; |
39 |
|
|
var <% $name %>_prev_value = document.getElementById('<% $name %>_select').selectedIndex; |
40 |
|
|
|
41 |
|
|
if (navigator.appName == "Netscape") { |
42 |
|
|
document.captureEvents(Event.KEYUP); |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
function find_word_<% $name %>() { |
46 |
|
|
var str1 = document.form.<% $name."_tmp" %>.value; |
47 |
|
|
if (str1 == "" || key_flag_<% $name %>) return; |
48 |
|
|
|
49 |
|
|
for (var i = 0; i < document.form.<% $name %>_select.options.length; i++) { |
50 |
|
|
var source = document.form.<% $name %>_select.options[i].text; |
51 |
|
|
source = source.toLowerCase(); |
52 |
|
|
str1 = str1.toLowerCase(); |
53 |
|
|
if ( source.indexOf(str1) > -1) { |
54 |
|
|
document.form.<% $name %>_select.options[i].selected=true; |
55 |
|
|
<% $name %>_changed(); |
56 |
|
|
break; |
57 |
|
|
} |
58 |
|
|
} |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
function <% $name %>_popup() { |
62 |
|
|
var s = document.getElementById('<% $name %>_select'); |
63 |
|
|
if (!s.value) { |
64 |
|
|
alert('��� ���������� ��������'); |
65 |
|
|
return false; |
66 |
|
|
} |
67 |
|
|
var re = /^(\d+)\s+(.+)$/; |
68 |
|
|
var matches = re.exec(s.value); |
69 |
|
|
window.open('/contenido/document.html?class=' + matches[2] + '&id=' + matches[1]); |
70 |
|
|
return false; |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
function <% $name %>_changed() { |
74 |
|
|
var t = document.getElementById('<% $name %>_prev_table'); |
75 |
|
|
var h = document.getElementById('<% $name %>_hidden'); |
76 |
|
|
var s = document.getElementById('<% $name %>_select'); |
77 |
|
|
if (s.selectedIndex==<% $name %>_prev_value) { |
78 |
|
|
if (t.style.display!='none') { |
79 |
|
|
t.style.display = 'none'; |
80 |
|
|
} |
81 |
|
|
return; |
82 |
|
|
} |
83 |
|
|
if (t.style.display=='none') { |
84 |
|
|
t.style.display = ''; |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
if (s.value) { |
88 |
|
|
var re = /^(\d+)\s+(.+)$/; |
89 |
|
|
var matches = re.exec(s.value); |
90 |
|
|
h.value = matches[1]; |
91 |
|
|
} else { |
92 |
|
|
h.value = ''; |
93 |
|
|
} |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
function <% $name %>_undo() { |
97 |
|
|
document.getElementById('<% $name %>_select').selectedIndex = <% $name %>_prev_value; |
98 |
|
|
<% $name %>_changed(); |
99 |
|
|
return false; |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
var s = document.getElementById('<% $name %>_select'); |
103 |
|
|
document.getElementById('<% $name %>_prev_text').innerHTML = s.options.item(s.selectedIndex).innerHTML || ' '; |
104 |
|
|
</script> |
105 |
|
|
|
106 |
|
|
% } else { |
107 |
|
|
<font color="red"><% $error %></font> |
108 |
|
|
% $m->comp('/contenido/components/inputs/integer.msn', %ARGS); |
109 |
|
|
% } |
110 |
|
|
|
111 |
|
|
<%args> |
112 |
|
|
$name => undef |
113 |
|
|
$check => undef |
114 |
|
|
$prop => undef |
115 |
|
|
</%args> |
116 |
|
|
|
117 |
|
|
<%init> |
118 |
|
|
my (@list, $error); |
119 |
|
|
|
120 |
|
|
if ($prop && ref($prop) && ref($prop->{lookup_opts}) eq 'HASH') { |
121 |
|
|
@list = $keeper->get_documents(order => ['name','reverse'], %{$prop->{lookup_opts}}); |
122 |
|
|
} else { |
123 |
|
|
$error = '������ �������� �������� lookup_opts � ���������'; |
124 |
|
|
} |
125 |
|
|
</%init> |