Mercurial > public > sg101
comparison gpp/core/widgets.py @ 1:dbd703f7d63a
Initial import of sg101 stuff from private repository.
author | gremmie |
---|---|
date | Mon, 06 Apr 2009 02:43:12 +0000 |
parents | |
children | b6263ac72052 |
comparison
equal
deleted
inserted
replaced
0:900ba3c7b765 | 1:dbd703f7d63a |
---|---|
1 """ | |
2 Various useful widgets for the GPP application. | |
3 """ | |
4 | |
5 from django import forms | |
6 from django.utils.safestring import mark_safe | |
7 from django.core.urlresolvers import reverse | |
8 | |
9 | |
10 class AutoCompleteUserInput(forms.TextInput): | |
11 class Media: | |
12 css = { | |
13 'all': ('js/jquery-autocomplete/jquery.autocomplete.css',) | |
14 } | |
15 js = ( | |
16 'js/jquery-autocomplete/lib/jquery.js', | |
17 'js/jquery-autocomplete/lib/jquery.bgiframe.min.js', | |
18 'js/jquery-autocomplete/lib/jquery.ajaxQueue.js', | |
19 'js/jquery-autocomplete/jquery.autocomplete.js' | |
20 ) | |
21 | |
22 def render(self, name, value, attrs=None): | |
23 url = reverse('messages-ajax_users') | |
24 output = super(AutoCompleteUserInput, self).render(name, value, attrs) | |
25 return output + mark_safe(u'''\ | |
26 <script type="text/javascript"> | |
27 jQuery("#id_%s").autocomplete("%s", { | |
28 width: 150, | |
29 max: 10, | |
30 highlight: false, | |
31 multiple: false, | |
32 scroll: true, | |
33 scrollHeight: 300, | |
34 matchContains: true, | |
35 autoFill: true, | |
36 }); | |
37 </script>''' % (name, url)) | |
38 | |
39 | |
40 # vim: ts=4 sw=4 |