summaryrefslogtreecommitdiff
path: root/chimere/widgets.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2012-04-08 23:38:39 +0200
committerÉtienne Loks <etienne.loks@peacefrogs.net>2012-04-08 23:38:39 +0200
commit3419f706ecf16b0252975084ebe2806467a40206 (patch)
tree2031e8b19abdaf2dcce67136d4432044f4d35c73 /chimere/widgets.py
parent177517832e1e67a97c44cc0a7d79cb79f5e77e03 (diff)
downloadChimère-3419f706ecf16b0252975084ebe2806467a40206.tar.bz2
Chimère-3419f706ecf16b0252975084ebe2806467a40206.zip
Move route edition to jquery.chimere plugin (currently broken)
Diffstat (limited to 'chimere/widgets.py')
-rw-r--r--chimere/widgets.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/chimere/widgets.py b/chimere/widgets.py
index b0ea71d..04a8e65 100644
--- a/chimere/widgets.py
+++ b/chimere/widgets.py
@@ -168,8 +168,9 @@ class RouteChooserWidget(forms.TextInput):
css = {"all": settings.OSM_CSS_URLS + \
["%schimere/css/forms.css" % settings.STATIC_URL,]
}
- js = settings.OSM_JS_URLS + \
- ["%schimere/js/edit_route_map.js" % settings.STATIC_URL,
+ js = settings.OSM_JS_URLS + list(settings.JQUERY_JS_URLS) + \
+ ["%schimere/js/jquery.chimere.js" % settings.STATIC_URL,
+ "%schimere/js/edit_route_map.js" % settings.STATIC_URL,
"%schimere/js/base.js" % settings.STATIC_URL,]
def render(self, name, value, attrs=None, area_name='', routefile_id=None):
@@ -177,6 +178,20 @@ class RouteChooserWidget(forms.TextInput):
Render a map and latitude, longitude information field
'''
tpl = getMapJS(area_name)
+ js = """
+ var EPSG_DISPLAY_PROJECTION = epsg_display_projection = new OpenLayers.Projection('EPSG:%s');
+ var EPSG_PROJECTION = epsg_projection = new OpenLayers.Projection('EPSG:%s');
+ var chimere_init_options = {};
+ chimere_init_options["map_layers"] = [new OpenLayers.Layer.OSM.Mapnik('Mapnik')];
+ chimere_init_options['dynamic_categories'] = false;
+ chimere_init_options['edition'] = true;
+ chimere_init_options['edition_type_is_route'] = true;
+ chimere_init_options["checked_categories"] = [];
+ """ % (settings.CHIMERE_EPSG_DISPLAY_PROJECTION,
+ settings.CHIMERE_EPSG_PROJECTION)
+ tpl = u"<script type='text/javascript'><!--\n"\
+ u"%s// !--></script>\n" % js
+ #TODO: manage area
help_create = ''
if not value:
help_create = u"<h3>%s</h3>\n"\
@@ -202,8 +217,8 @@ class RouteChooserWidget(forms.TextInput):
u"\"d\" or \"Del\" key."),
_(u"To add a point click in the middle of a segment and drag the new "\
u"point to the desired position"))
- tpl += u'<script src="%sedit_route_map.js"></script>\n' % \
- settings.STATIC_URL
+ #tpl += u'<script src="%sedit_route_map.js"></script>\n' % \
+ # settings.STATIC_URL
if not value:
# upload a file
tpl += u"<script type='text/javascript'><!--\n"\
@@ -244,9 +259,9 @@ class RouteChooserWidget(forms.TextInput):
style, help_modify, name, name, value, routefile_id)
tpl += u"<script type='text/javascript'><!--\n"
if not value:
- tpl += u"document.getElementById('map_edit').style.display = 'None';"
+ tpl += u"jQuery('#map_edit').hide();"
if value:
- tpl += u"init();\n"
+ tpl += u"jQuery('#map_edit').chimere(chimere_init_options);\n"
val = value
if type(value) == unicode:
try:
@@ -255,7 +270,8 @@ class RouteChooserWidget(forms.TextInput):
pass
if hasattr(val, 'json'):
tpl += u"\nvar geometry='%s';\n"\
- u"initFeature(geometry);" % val.json
+ u"jQuery('#map_edit').chimere('initFeature', geometry);"\
+ % val.json
tpl += u"\n// --></script>\n"
return mark_safe(tpl)