[%# Autocompleting editbox for selecting users
  # License: Dual-license GPL 3.0+ or MPL 1.1+
  # Author: Vitaliy Filippov <vitalif@mail.ru>
  #%]

[%# INTERFACE:
  # name: mandatory; field name
  # id: optional; field id
  # value: optional; default field value/selection
  # onchange: optional; onchange attribute value (FIXME may not work)
  # disabled: optional; if true, the field is disabled
  # accesskey: optional; accesskey attribute value
  # size: optional; size attribute value
  # multiple: optional; select several users at once (delimiter is ',')
  # custom_userlist: optional, specify a limited list of users to use
  # tabindex: optional, HTML tabindex
  #%]

[% id = id || name %]
<input
  name="[% name | html %]"
  id="[% id | html %]"
  value="[% value | html %]"
  [% IF tabindex %] tabindex="[% tabindex | html %]" [% END %]
  [% IF onchange %] onchange="[% onchange | html %]" [% END %]
  [% IF disabled %] disabled="[% disabled | html %]" [% END %]
  [% IF accesskey %] accesskey="[% accesskey | html %]" [% END %]
  [% IF size %] size="[% size | html %]" [% END %]
  [% IF style %] style="[% style | html %]" [% END %]
/>
<script language="JavaScript">
[%-# FIXME: remove hardcoded i18n message, also from js/field.js::userAutocomplete() %]
new SimpleAutocomplete("[% id | js %]",
  function(h) { userAutocomplete(h, [% custom_userlist ? json(custom_userlist) : "null" %], [% Param('usemenuforusers') ? 1 : 0 %]); },
  { emptyText: 'No users found'[% ', multipleDelimiter: ","' IF multiple %] });
</script>
