mirror of
https://github.com/Hopiu/django-select2.git
synced 2026-03-28 02:40:23 +00:00
v3.3.1 commit
This commit is contained in:
parent
973116778c
commit
f58f608b23
12 changed files with 53 additions and 18 deletions
6
README
6
README
|
|
@ -49,6 +49,12 @@ Special Thanks
|
|||
Changelog Summary
|
||||
=================
|
||||
|
||||
### v3.3.1
|
||||
|
||||
* Addressed issue[#30](https://github.com/applegrew/django-select2/issues/30).
|
||||
* Merged pull request[#31](https://github.com/applegrew/django-select2/issues/31).
|
||||
* Added `light` parameter to `import_django_select2_js`, `import_django_select2_css` and `import_django_select2_js_css` template tags. Please see doc's "Getting Started", for more details.
|
||||
|
||||
### v3.3.0
|
||||
|
||||
* Updated Select2 to version 3.3.1.
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ Special Thanks
|
|||
Changelog Summary
|
||||
=================
|
||||
|
||||
### v3.3.1
|
||||
|
||||
* Addressed issue[#30](https://github.com/applegrew/django-select2/issues/30).
|
||||
* Merged pull request[#31](https://github.com/applegrew/django-select2/issues/31).
|
||||
* Added `light` parameter to `import_django_select2_js`, `import_django_select2_css` and `import_django_select2_js_css` template tags. Please see doc's "Getting Started", for more details.
|
||||
|
||||
### v3.3.0
|
||||
|
||||
* Updated Select2 to version 3.3.1.
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ The view - `Select2View`, exposed here is meant to be used with 'Heavy' fields a
|
|||
|
||||
"""
|
||||
|
||||
__version__ = "3.3.0"
|
||||
__version__ = "3.3.1"
|
||||
|
||||
__RENDER_SELECT2_STATICS = False
|
||||
__ENABLE_MULTI_PROCESS_SUPPORT = False
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@
|
|||
}
|
||||
.select2-container.select2-container-multi {
|
||||
width: 300px;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1
django_select2/static/css/select2.min.css
vendored
Normal file
1
django_select2/static/css/select2.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
2
django_select2/static/js/select2.min.js
vendored
2
django_select2/static/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -2,21 +2,31 @@ from django import template
|
|||
|
||||
register = template.Library()
|
||||
|
||||
from ..widgets import HeavySelect2Widget
|
||||
from ..widgets import HeavySelect2Widget, Select2Widget
|
||||
|
||||
__proxy_widget = HeavySelect2Widget(data_view="xyz")
|
||||
__proxy_light_widget = Select2Widget()
|
||||
|
||||
|
||||
@register.simple_tag(name='import_django_select2_js')
|
||||
def import_js():
|
||||
return u'\n'.join(__proxy_widget.media.render_js())
|
||||
def import_js(light=0):
|
||||
if light:
|
||||
return u'\n'.join(__proxy_light_widget.media.render_js())
|
||||
else:
|
||||
return u'\n'.join(__proxy_widget.media.render_js())
|
||||
|
||||
|
||||
@register.simple_tag(name='import_django_select2_css')
|
||||
def import_css():
|
||||
return u'\n'.join(__proxy_widget.media.render_css())
|
||||
def import_css(light=0):
|
||||
if light:
|
||||
return u'\n'.join(__proxy_light_widget.media.render_css())
|
||||
else:
|
||||
return u'\n'.join(__proxy_widget.media.render_css())
|
||||
|
||||
|
||||
@register.simple_tag(name='import_django_select2_js_css')
|
||||
def import_all():
|
||||
return __proxy_widget.media.render()
|
||||
def import_all(light=0):
|
||||
if light:
|
||||
return __proxy_light_widget.media.render()
|
||||
else:
|
||||
return __proxy_widget.media.render()
|
||||
|
|
|
|||
|
|
@ -35,12 +35,18 @@ def get_select2_heavy_js_libs():
|
|||
else:
|
||||
return libs + ('js/heavy_data.min.js', )
|
||||
|
||||
def get_select2_css_libs():
|
||||
def get_select2_css_libs(light=False):
|
||||
from django.conf import settings
|
||||
if settings.configured and settings.DEBUG:
|
||||
return ('css/select2.css', 'css/extra.css', )
|
||||
if light:
|
||||
return ('css/select2.css',)
|
||||
else:
|
||||
return ('css/select2.css', 'css/extra.css', )
|
||||
else:
|
||||
return ('css/all.min.css', )
|
||||
if light:
|
||||
return ('css/select2.min.css',)
|
||||
else:
|
||||
return ('css/all.min.css', )
|
||||
|
||||
### Light mixin and widgets ###
|
||||
|
||||
|
|
@ -214,7 +220,7 @@ class Select2Mixin(object):
|
|||
|
||||
class Media:
|
||||
js = get_select2_js_libs()
|
||||
css = {'screen': get_select2_css_libs()}
|
||||
css = {'screen': get_select2_css_libs(light=True)}
|
||||
|
||||
|
||||
class Select2Widget(Select2Mixin, forms.Select):
|
||||
|
|
@ -458,7 +464,7 @@ class HeavySelect2Mixin(Select2Mixin):
|
|||
|
||||
class Media:
|
||||
js = get_select2_heavy_js_libs()
|
||||
css = {'screen': ('css/select2.css', 'css/extra.css', )}
|
||||
css = {'screen': get_select2_css_libs()}
|
||||
|
||||
|
||||
class HeavySelect2Widget(HeavySelect2Mixin, forms.TextInput):
|
||||
|
|
|
|||
|
|
@ -39,7 +39,11 @@ When this settings is ``False`` then you are responsible for including the JS an
|
|||
* ``import_django_select2_css`` - Outputs ``<link>`` tags to include all the CSS files, required by Light and Heavy widgets.
|
||||
* ``import_django_select2_js_css`` - Outputs both ``<script>`` and ``<link>`` tags to include all the JS and CSS files, required by Light and Heavy widgets.
|
||||
|
||||
Make sure to include them at the top of the page, prefereably in ``<head>...</head>``.
|
||||
.. tip:: Make sure to include them at the top of the page, prefereably in ``<head>...</head>``.
|
||||
|
||||
.. note:: (Since version 3.3.1) The above temaple tags accept one argument ``light``. Default value for that is ``0``.
|
||||
If that is set to ``1`` then only the JS and CSS libraries needed by Select2Widget (Light field) is rendered.
|
||||
That effectively leaves out ``heavy.js`` and ``extra.css``.
|
||||
|
||||
|
||||
``ENABLE_SELECT2_MULTI_PROCESS_SUPPORT`` [Default ``False``]
|
||||
|
|
|
|||
3
setup.py
3
setup.py
|
|
@ -142,7 +142,7 @@ def minify(files, outfile, ftype):
|
|||
for key in data:
|
||||
value = data[key]
|
||||
if isinstance(value, str) or isinstance(value, unicode):
|
||||
data[key] = unicode(value).decode("string-escape").replace(r'\/', '/')
|
||||
data[key] = unicode(value).replace(r'\/', '/') #.decode("unicode_escape").replace(r'\/', '/')
|
||||
|
||||
if data['success']:
|
||||
with open(getPkgPath() + outfile, 'w') as f:
|
||||
|
|
@ -156,6 +156,7 @@ def minify(files, outfile, ftype):
|
|||
if len(sys.argv) > 1 and 'sdist' == sys.argv[1]:
|
||||
minify(['static/js/select2.js'], 'static/js/select2.min.js', 'js')
|
||||
minify(['static/js/heavy_data.js'], 'static/js/heavy_data.min.js', 'js')
|
||||
minify(['static/css/select2.css'], 'static/css/select2.min.css', 'css')
|
||||
minify(['static/css/select2.css', 'static/css/extra.css'], 'static/css/all.min.css', 'css')
|
||||
|
||||
setup(
|
||||
|
|
|
|||
BIN
testapp/test.db
BIN
testapp/test.db
Binary file not shown.
|
|
@ -6,7 +6,8 @@
|
|||
<script src="{{ STATIC_URL }}jquery-1.7.2.min.js"></script>
|
||||
{% import_django_select2_js %}
|
||||
{% import_django_select2_css %}
|
||||
{% import_django_select2_js_css %} <!-- For testing importing it again, but with another tag -->
|
||||
<!-- For testing importing it again, but with another tag and light=1 -->
|
||||
{% import_django_select2_js_css light=1 %}
|
||||
</head>
|
||||
<body>
|
||||
<form method="post" action="">
|
||||
|
|
|
|||
Loading…
Reference in a new issue