diff options
| author | Claude Paroz <claude@2xlibre.net> | 2021-11-30 06:35:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-30 06:35:15 +0100 |
| commit | 322a1a037d4d2f18744c5d1a1efc2e84d4c5e94b (patch) | |
| tree | 36c0ccd7601e0d2d2b30146cfb6782a367bef99c | |
| parent | 3ff7f6cf07a722635d690785c31ac89484134bee (diff) | |
Refs #25706 - Removed inline JavaScript from OpenLayers template.
This allows setting a Content-Security-Policy HTTP header.
| -rw-r--r-- | django/contrib/gis/static/gis/js/OLMapWidget.js | 7 | ||||
| -rw-r--r-- | django/contrib/gis/templates/gis/openlayers.html | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/django/contrib/gis/static/gis/js/OLMapWidget.js b/django/contrib/gis/static/gis/js/OLMapWidget.js index 29725636a3..2395e4d7dd 100644 --- a/django/contrib/gis/static/gis/js/OLMapWidget.js +++ b/django/contrib/gis/static/gis/js/OLMapWidget.js @@ -107,6 +107,13 @@ ol.inherits(GeometryTypeControl, ol.control.Control); if (initial_value && !this.options.is_collection) { this.disableDrawing(); } + const clearNode = document.getElementById(this.map.getTarget()).nextElementSibling; + if (clearNode.classList.contains('clear_features')) { + clearNode.querySelector('a').addEventListener('click', (ev) => { + ev.preventDefault(); + self.clearFeatures(); + }); + } this.ready = true; } diff --git a/django/contrib/gis/templates/gis/openlayers.html b/django/contrib/gis/templates/gis/openlayers.html index 90ecf1b44b..128654d5aa 100644 --- a/django/contrib/gis/templates/gis/openlayers.html +++ b/django/contrib/gis/templates/gis/openlayers.html @@ -9,7 +9,7 @@ <div id="{{ id }}_div_map"> <div id="{{ id }}_map"></div> - {% if not disabled %}<span class="clear_features"><a href="javascript:{{ module }}.clearFeatures()">{% translate "Delete all Features" %}</a></span>{% endif %} + {% if not disabled %}<span class="clear_features"><a href="">{% translate "Delete all Features" %}</a></span>{% endif %} {% if display_raw %}<p>{% translate "Debugging window (serialized value)" %}</p>{% endif %} <textarea id="{{ id }}" class="vSerializedField required" cols="150" rows="10" name="{{ name }}">{{ serialized }}</textarea> <script> |
