Mercurial > public > sg101
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/core/widgets.py Mon Apr 06 02:43:12 2009 +0000 @@ -0,0 +1,40 @@ +""" +Various useful widgets for the GPP application. +""" + +from django import forms +from django.utils.safestring import mark_safe +from django.core.urlresolvers import reverse + + +class AutoCompleteUserInput(forms.TextInput): + class Media: + css = { + 'all': ('js/jquery-autocomplete/jquery.autocomplete.css',) + } + js = ( + 'js/jquery-autocomplete/lib/jquery.js', + 'js/jquery-autocomplete/lib/jquery.bgiframe.min.js', + 'js/jquery-autocomplete/lib/jquery.ajaxQueue.js', + 'js/jquery-autocomplete/jquery.autocomplete.js' + ) + + def render(self, name, value, attrs=None): + url = reverse('messages-ajax_users') + output = super(AutoCompleteUserInput, self).render(name, value, attrs) + return output + mark_safe(u'''\ +<script type="text/javascript"> +jQuery("#id_%s").autocomplete("%s", { + width: 150, + max: 10, + highlight: false, + multiple: false, + scroll: true, + scrollHeight: 300, + matchContains: true, + autoFill: true, +}); +</script>''' % (name, url)) + + +# vim: ts=4 sw=4