annotate gpp/core/widgets.py @ 2:f3ad863505bf

Got rid of the core.SiteConfig model and all usage.
author Brian Neal <bgneal@gmail.com>
date Sat, 11 Apr 2009 17:57:22 +0000
parents dbd703f7d63a
children b6263ac72052
rev   line source
gremmie@1 1 """
gremmie@1 2 Various useful widgets for the GPP application.
gremmie@1 3 """
gremmie@1 4
gremmie@1 5 from django import forms
gremmie@1 6 from django.utils.safestring import mark_safe
gremmie@1 7 from django.core.urlresolvers import reverse
gremmie@1 8
gremmie@1 9
gremmie@1 10 class AutoCompleteUserInput(forms.TextInput):
gremmie@1 11 class Media:
gremmie@1 12 css = {
gremmie@1 13 'all': ('js/jquery-autocomplete/jquery.autocomplete.css',)
gremmie@1 14 }
gremmie@1 15 js = (
gremmie@1 16 'js/jquery-autocomplete/lib/jquery.js',
gremmie@1 17 'js/jquery-autocomplete/lib/jquery.bgiframe.min.js',
gremmie@1 18 'js/jquery-autocomplete/lib/jquery.ajaxQueue.js',
gremmie@1 19 'js/jquery-autocomplete/jquery.autocomplete.js'
gremmie@1 20 )
gremmie@1 21
gremmie@1 22 def render(self, name, value, attrs=None):
gremmie@1 23 url = reverse('messages-ajax_users')
gremmie@1 24 output = super(AutoCompleteUserInput, self).render(name, value, attrs)
gremmie@1 25 return output + mark_safe(u'''\
gremmie@1 26 <script type="text/javascript">
gremmie@1 27 jQuery("#id_%s").autocomplete("%s", {
gremmie@1 28 width: 150,
gremmie@1 29 max: 10,
gremmie@1 30 highlight: false,
gremmie@1 31 multiple: false,
gremmie@1 32 scroll: true,
gremmie@1 33 scrollHeight: 300,
gremmie@1 34 matchContains: true,
gremmie@1 35 autoFill: true,
gremmie@1 36 });
gremmie@1 37 </script>''' % (name, url))
gremmie@1 38
gremmie@1 39
gremmie@1 40 # vim: ts=4 sw=4