Ticket #11810: 11810_v2.diff

File 11810_v2.diff, 2.0 KB (added by jbronn, 15 years ago)
  • django/contrib/gis/templates/gis/admin/openlayers.js

     
    11{# Author: Justin Bronn, Travis Pinney & Dane Springmeyer #}
    22{% block vars %}var {{ module }} = {};
    33{{ module }}.map = null; {{ module }}.controls = null; {{ module }}.panel = null; {{ module }}.re = new RegExp("^SRID=\d+;(.+)", "i"); {{ module }}.layers = {};
     4{{ module }}.modifiable = {{ modifiable|yesno:"true,false" }};
    45{{ module }}.wkt_f = new OpenLayers.Format.WKT();
    56{{ module }}.is_collection = {{ is_collection|yesno:"true,false" }};
    67{{ module }}.collection_type = '{{ collection_type }}';
     
    8889  } else if ({{ module }}.is_point){
    8990    draw_ctl = new OpenLayers.Control.DrawFeature(lyr, OpenLayers.Handler.Point, {'displayClass': 'olControlDrawFeaturePoint'});
    9091  }
    91   {% if modifiable %}
    92   var mod = new OpenLayers.Control.ModifyFeature(lyr, {'displayClass': 'olControlModifyFeature'});
    93   {{ module }}.controls = [nav, draw_ctl, mod];
    94   {% else %}
    95   {{ module }}.controls = [nav, darw_ctl];
    96   {% endif %} 
     92  if ({{ module }}.modifiable){
     93      var mod = new OpenLayers.Control.ModifyFeature(lyr, {'displayClass': 'olControlModifyFeature'});
     94      {{ module }}.controls = [nav, draw_ctl, mod];
     95  } else {
     96      if(!lyr.features.length){
     97          {{ module }}.controls = [nav, draw_ctl];
     98      } else {
     99          {{ module }}.controls = [nav];
     100      }
     101  }
    97102}
    98103{{ module }}.init = function(){
    99104    {% block map_options %}// The options hash, w/ zoom, resolution, and projection settings.
     
    153158    {% if not scrollable %}{{ module }}.map.getControlsByClass('OpenLayers.Control.Navigation')[0].disableZoomWheel();{% endif %}
    154159    {% endblock %}
    155160    if (wkt){
    156       {{ module }}.enableEditing();
     161        if ({{ module }}.modifiable){
     162            {{ module }}.enableEditing();
     163        }
    157164    } else {
    158165      {{ module }}.enableDrawing();
    159166    }
Back to Top