diff options
Diffstat (limited to 'chimere/widgets.py')
-rw-r--r-- | chimere/widgets.py | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/chimere/widgets.py b/chimere/widgets.py index b4bbee6..465ec7f 100644 --- a/chimere/widgets.py +++ b/chimere/widgets.py @@ -38,6 +38,22 @@ from django.template.loader import render_to_string import re +BASE_CSS = { + "all": ("{}ol3/ol.css".format(settings.STATIC_URL), + "{}chimere/css/forms.css".format(settings.STATIC_URL)) +} + +BASE_JS = tuple( + ["{}ol3/ol.js".format(settings.STATIC_URL)] + + list(settings.JQUERY_JS_URLS) + + ["{}chimere/js/jquery.chimere.js".format(settings.STATIC_URL)]) + +AREA_JS = tuple( + ["{}ol3/ol.js".format(settings.STATIC_URL)] + + ["{}chimere/js/edit_area.js".format(settings.STATIC_URL) + + "{}chimere/js/base.js".format(settings.STATIC_URL)]) + + def getMapJS(area_name=''): '''Variable initialization for drawing the map ''' @@ -355,12 +371,8 @@ class PointChooserWidget(forms.TextInput): Manage the edition of point on a map """ class Media: - css = { - "all": settings.MAP_CSS_URLS + - ["%schimere/css/forms.css" % settings.STATIC_URL] - } - js = settings.MAP_JS_URLS + list(settings.JQUERY_JS_URLS) + \ - ["%schimere/js/jquery.chimere.js" % settings.STATIC_URL] + css = BASE_CSS + js = BASE_JS def render(self, name, value, attrs=None, area_name='', initialized=True): ''' @@ -446,12 +458,8 @@ class RouteChooserWidget(forms.TextInput): Manage the edition of route on a map """ class Media: - css = { - "all": settings.MAP_CSS_URLS + - ["%schimere/css/forms.css" % settings.STATIC_URL] - } - js = settings.MAP_JS_URLS + list(settings.JQUERY_JS_URLS) + \ - ["%schimere/js/jquery.chimere.js" % settings.STATIC_URL] + css = BASE_CSS + js = BASE_JS def render(self, name, value, attrs=None, area_name='', routefile_id=None, initialized=True): @@ -499,13 +507,8 @@ class AreaWidget(forms.TextInput): Manage the edition of an area on the map """ class Media: - css = { - "all": settings.MAP_CSS_URLS + - ["%schimere/css/forms.css" % settings.STATIC_URL] - } - js = settings.MAP_JS_URLS + [ - "%schimere/js/edit_area.js" % settings.STATIC_URL, - "%schimere/js/base.js" % settings.STATIC_URL] + css = BASE_CSS + js = AREA_JS def get_bounding_box_from_value(self, value): ''' @@ -596,12 +599,8 @@ class PolygonChooserWidget(forms.TextInput): Manage the edition of polygon on a map """ class Media: - css = { - "all": settings.MAP_CSS_URLS + - ["%schimere/css/forms.css" % settings.STATIC_URL] - } - js = settings.MAP_JS_URLS + list(settings.JQUERY_JS_URLS) + \ - ["%schimere/js/jquery.chimere.js" % settings.STATIC_URL] + css = BASE_CSS + js = BASE_JS def render(self, name, value, attrs=None, area_name='', initialized=True): val = '' @@ -652,13 +651,8 @@ class ImportFiltrWidget(AreaWidget): Manage the edition of the import source field """ class Media: - css = { - "all": settings.MAP_CSS_URLS + - ["%schimere/css/forms.css" % settings.STATIC_URL] - } - js = settings.MAP_JS_URLS + [ - "%schimere/js/edit_area.js" % settings.STATIC_URL, - "%schimere/js/base.js" % settings.STATIC_URL] + css = BASE_CSS + js = AREA_JS def render(self, name, value, attrs=None): """ |