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 f735db1..8464d47 100644 --- a/chimere/widgets.py +++ b/chimere/widgets.py @@ -37,6 +37,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 ''' @@ -361,12 +377,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): ''' @@ -452,12 +464,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): @@ -505,13 +513,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): ''' @@ -602,12 +605,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 = '' @@ -658,13 +657,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): """ |