diff options
Diffstat (limited to 'ishtar_common/widgets.py')
-rw-r--r-- | ishtar_common/widgets.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 12db821c5..42a93ddaa 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -58,7 +58,7 @@ class Select2Multiple(forms.SelectMultiple): css = { 'all': ('select2/css/select2.css',) } - js = ['select2/js/select2.min.js'] + js = ['select2/js/select2.full.min.js'] for lang_code, lang in settings.LANGUAGES: js.append('select2/js/i18n/{}.js'.format(lang_code)) media.add_css(css) @@ -91,7 +91,11 @@ class Select2Multiple(forms.SelectMultiple): attrs = {} attrs['class'] = klass if 'style' not in attrs: - attrs['style'] = "width: 370px" + if attrs.get('full-width', None): + attrs['style'] = "width: 100%" + else: + attrs['style'] = "width: 370px" + options = "" if self.remote: options = """{ @@ -124,6 +128,12 @@ class Select2Multiple(forms.SelectMultiple): except (self.model.DoesNotExist, ValueError): # an old reference? it should not happen pass + if attrs.get('full-width', None): + if options: + options = options[:-1] + ", " + else: + options = "{" + options += " containerCssClass: 'full-width'}" html = super(Select2Multiple, self).render(name, value, attrs, choices) html += """<script type="text/javascript"> |