2020-01-21 06:35:58 +00:00
|
|
|
{% compress js %}
|
2023-01-27 23:11:10 +00:00
|
|
|
<script src="{{ static('libs/featherlight/featherlight.min.js') }}" type="text/javascript"></script>
|
|
|
|
<script type="text/javascript" src="{{ static('libs/timezone-map/timezone-picker.js') }}"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(function () {
|
|
|
|
$('#open-map').featherlight({
|
|
|
|
afterOpen: function () {
|
|
|
|
timezone_picker($('.featherlight-inner .map-inset'), $('#id_timezone'),
|
|
|
|
'{{ static('libs/timezone-map/timezone-picker.json') }}');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2020-01-21 06:35:58 +00:00
|
|
|
|
2023-01-27 23:11:10 +00:00
|
|
|
if ('geolocation' in navigator) {
|
|
|
|
$(function () {
|
|
|
|
$('<span>, <a href="#" id="detect-tz">detect</a></span>').insertAfter('#open-map');
|
|
|
|
$('#detect-tz').click(function (event) {
|
|
|
|
var button = $(this).html('detecting...');
|
|
|
|
navigator.geolocation.getCurrentPosition(function (position) {
|
|
|
|
$.ajax({
|
|
|
|
url: 'https://maps.googleapis.com/maps/api/timezone/json',
|
|
|
|
data: {
|
|
|
|
location: position.coords.latitude + ',' + position.coords.longitude,
|
|
|
|
timestamp: Math.floor(Date.now() / 1000)
|
|
|
|
}
|
|
|
|
}).done(function (data) {
|
|
|
|
if (data['timeZoneId'])
|
|
|
|
$('#id_timezone').val(data.timeZoneId).change();
|
|
|
|
else
|
|
|
|
alert('Invalid response from Google: ' + data);
|
|
|
|
}).fail(function (jqXHR, status) {
|
|
|
|
alert(status);
|
|
|
|
}).always(function () {
|
|
|
|
button.html('detect');
|
2020-01-21 06:35:58 +00:00
|
|
|
});
|
2023-01-27 23:11:10 +00:00
|
|
|
}, function () {
|
|
|
|
button.html('detect');
|
|
|
|
alert('Unable to detect');
|
|
|
|
});
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
2020-01-21 06:35:58 +00:00
|
|
|
{% endcompress %}
|