").addClass("col-md-9 col-md-offset-3").append($map));
- var map = L.map($map.get(0));
- L.tileLayer(tiles, {
- attribution: attrib,
- maxZoom: 18,
- }).addTo(map);
- var $lat = $sec.find("input[name$=geo_lat]");
- var $lon = $sec.find("input[name$=geo_lon]");
+ $updateButton.click(function() {
+ $lat.val(lat);
+ $lon.val(lon).trigger("change");// change-event is needed by bulk-edit
+ touched = false;
+ center(13);
+ $notifications.attr("data-notify", "updated");
+ delayUpdateDismissal = window.setTimeout(function() {
+ if ($notifications.attr("data-notify") == "updated") $notifications.attr("data-notify", "");
+ }, 2500);
+ });
- function getpoint() {
- if ($lat.val() !== "" && $lon.val() !== "") {
- var p = [parseFloat($lat.val().replace(",", ".")), parseFloat($lon.val().replace(",", "."))];
- // Clip to valid ranges. Very invalid lon/lat values can even lead to browser crashes in leaflet apparently
- if (p[0] < -90) p[0] = -90
- if (p[0] > 90) p[0] = 90
- if (p[1] < -180) p[1] = -180
- if (p[1] > 180) p[1] = 180
- return p
+ // Map
+ var $grp = $(".geodata-group", this);
+ var tiles = $grp.attr("data-tiles");
+ var attrib = $grp.attr("data-attrib");
+ if (tiles) {
+ var $map = $("
");
+ $grp.append($("
").addClass("col-md-9 col-md-offset-3").append($map));
+ var map = L.map($map.get(0));
+ L.tileLayer(tiles, {
+ attribution: attrib,
+ maxZoom: 18,
+ }).addTo(map);
+
+ function getpoint() {
+ if ($lat.val() !== "" && $lon.val() !== "") {
+ var p = [parseFloat($lat.val().replace(",", ".")), parseFloat($lon.val().replace(",", "."))];
+ // Clip to valid ranges. Very invalid lon/lat values can even lead to browser crashes in leaflet apparently
+ if (p[0] < -90) p[0] = -90
+ if (p[0] > 90) p[0] = 90
+ if (p[1] < -180) p[1] = -180
+ if (p[1] > 180) p[1] = 180
+ return p
+ } else {
+ return [0.0, 0.0];
+ }
+ }
+
+ var marker = L.marker(getpoint(), {
+ draggable: 'true',
+ icon: L.icon({
+ iconUrl: $grp.attr("data-icon"),
+ shadowUrl: $grp.attr("data-shadow"),
+ iconSize: [25, 41],
+ iconAnchor: [12, 41],
+ popupAnchor: [1, -34],
+ tooltipAnchor: [16, -28],
+ shadowSize: [41, 41]
+ })
+ });
+ marker.addTo(map);
+ marker.on("dragend", function (event) {
+ var position = marker.getLatLng();
+ marker.setLatLng(position, {
+ draggable: 'true'
+ }).bindPopup(position).update();
+ $lat.val(position.lat.toFixed(7));
+ $lon.val(position.lng.toFixed(7));
+ touched = true;
+ center(null);
+ });
+
+ function center(zoom) {
+ if ($lat.val() !== "" && $lon.val() !== "") {
+ if (zoom) {
+ map.setView(getpoint(), zoom);
+ } else {
+ map.panTo(getpoint());
+ }
+ marker.setLatLng(getpoint(), {
+ draggable: 'true'
+ }).bindPopup(getpoint()).update();
+ } else {
+ map.fitWorld();
+ }
+ }
+
+ center(13);
} else {
- return [0.0, 0.0];
+ function center(zoom) {
+ }
}
- }
- var marker = L.marker(getpoint(), {
- draggable: 'true',
- icon: L.icon({
- iconUrl: $grp.attr("data-icon"),
- shadowUrl: $grp.attr("data-shadow"),
- iconSize: [25, 41],
- iconAnchor: [12, 41],
- popupAnchor: [1, -34],
- tooltipAnchor: [16, -28],
- shadowSize: [41, 41]
- })
- });
- marker.addTo(map);
- marker.on("dragend", function (event) {
- var position = marker.getLatLng();
- marker.setLatLng(position, {
- draggable: 'true'
- }).bindPopup(position).update();
- $lat.val(position.lat.toFixed(7));
- $lon.val(position.lng.toFixed(7));
- center(null);
- });
-
- function center(zoom) {
- if ($lat.val() !== "" && $lon.val() !== "") {
- if (zoom) {
- map.setView(getpoint(), zoom);
- } else {
- map.panTo(getpoint());
- }
- marker.setLatLng(getpoint(), {
- draggable: 'true'
- }).bindPopup(getpoint()).update();
- } else {
- map.fitWorld();
- }
- }
-
- center(13);
- } else {
- function center(zoom) {
- }
- }
-
- });
+ });
});
diff --git a/src/pretix/static/pretixcontrol/scss/_forms.scss b/src/pretix/static/pretixcontrol/scss/_forms.scss
index d79fe15a7..763fc7a8c 100644
--- a/src/pretix/static/pretixcontrol/scss/_forms.scss
+++ b/src/pretix/static/pretixcontrol/scss/_forms.scss
@@ -241,6 +241,23 @@ div.mail-preview {
input[type=number].short {
width: 80px !important;
}
+
+.geodata-autoupdate {
+ display: block;
+}
+.geodata-autoupdate .btn-link {
+ padding: 0;
+}
+.geodata-autoupdate [data-notification] {
+ display: none;
+}
+[data-notify=error] [data-notification=error],
+[data-notify=loading] [data-notification=loading],
+[data-notify=updated] [data-notification=updated],
+[data-notify=confirm] [data-notification=confirm] {
+ display: block;
+}
+
.geodata-group {
.form-group {
margin: 0 0 10px 0;