annotate gpp/core/widgets.py @ 11:cc8eb028def1

Update jquery-ui and theme version that is hosted on google. In preparation for having jquery on every page (?), make it so that the autocomplete plug is using the 'global' jquery, and not the one that came with it. It seems to work okay with jquery 1.3.2.
author Brian Neal <bgneal@gmail.com>
date Tue, 14 Apr 2009 02:35:35 +0000
parents b6263ac72052
children f408971657b9
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
bgneal@6 8 from django.conf import settings
gremmie@1 9
gremmie@1 10
gremmie@1 11 class AutoCompleteUserInput(forms.TextInput):
gremmie@1 12 class Media:
gremmie@1 13 css = {
bgneal@6 14 'all': settings.GPP_THIRD_PARTY_CSS['jquery-autocomplete'],
gremmie@1 15 }
bgneal@11 16 js = settings.GPP_THIRD_PARTY_JS['jquery'] + \
bgneal@11 17 settings.GPP_THIRD_PARTY_JS['jquery-autocomplete']
gremmie@1 18
gremmie@1 19 def render(self, name, value, attrs=None):
gremmie@1 20 url = reverse('messages-ajax_users')
gremmie@1 21 output = super(AutoCompleteUserInput, self).render(name, value, attrs)
gremmie@1 22 return output + mark_safe(u'''\
gremmie@1 23 <script type="text/javascript">
gremmie@1 24 jQuery("#id_%s").autocomplete("%s", {
gremmie@1 25 width: 150,
gremmie@1 26 max: 10,
gremmie@1 27 highlight: false,
gremmie@1 28 multiple: false,
gremmie@1 29 scroll: true,
gremmie@1 30 scrollHeight: 300,
gremmie@1 31 matchContains: true,
gremmie@1 32 autoFill: true,
gremmie@1 33 });
gremmie@1 34 </script>''' % (name, url))
gremmie@1 35
gremmie@1 36
gremmie@1 37 # vim: ts=4 sw=4