front-end ui to launch location randomizer

This commit is contained in:
Laura Klünder 2019-12-25 12:37:20 +01:00
parent 0adf48147f
commit c9df2828b0
5 changed files with 24 additions and 2 deletions

View file

@ -66,6 +66,10 @@ PUBLIC_EDITOR = config.getboolean('c3nav', 'editor', fallback=True)
PUBLIC_BASE_MAPDATA = config.getboolean('c3nav', 'public_base_mapdata', fallback=False)
AUTO_PROCESS_UPDATES = config.getboolean('c3nav', 'auto_process_updates', fallback=True)
RANDOM_LOCATION_GROUPS = config.get('c3nav', 'random_location_groups', fallback=None)
if RANDOM_LOCATION_GROUPS:
RANDOM_LOCATION_GROUPS = tuple(int(i) for i in RANDOM_LOCATION_GROUPS.split(','))
if config.has_option('django', 'secret'):
SECRET_KEY = config.get('django', 'secret')
else:

View file

@ -671,7 +671,18 @@ main.show-options #resultswrapper #route-options {
font-size: 35px;
top: 5px;
}
.locationinput:not(.empty) button.locate, .locationinput.empty button.clear {
main:not([data-random-location-groups]) button.random {
display: none;
}
#search button.random {
right: 45px;
color: lighten($color-icon-light, 18%);
&:hover {
color: lighten($color-icon-light, 8%);
}
}
.locationinput:not(.empty) button.locate, .locationinput.empty button.clear,
main[data-view^=route] button.random, .locationinput:not(.empty) button.random {
-webkit-transform: scale(0.7);
-ms-transform: scale(0.7);
transform: scale(0.7);

View file

@ -155,6 +155,8 @@ c3nav = {
c3nav.ssids = $main.is('[data-ssids]') ? JSON.parse($main.attr('data-ssids')) : null;
c3nav.random_location_groups = $main.is('[data-random-location-groups]') ? $main.attr('data-random-location-groups').split(',') : null;
history.replaceState(state, window.location.path);
c3nav.load_state(state, true);
c3nav.update_map_locations();
@ -865,6 +867,7 @@ c3nav = {
.on('keydown', c3nav._locationinput_keydown);
$('.locationinput .clear').on('click', c3nav._locationinput_clear);
$('.locationinput .locate').on('click', c3nav._locationinput_locate);
$('.locationinput .random').on('click', c3nav._modal_link_click);
$('.leaflet-control-user-location a').on('click', c3nav._goto_user_location_click).dblclick(function(e) { e.stopPropagation(); });
$('#autocomplete').on('mouseover', '.location', c3nav._locationinput_hover_suggestion)
.on('click', '.location', c3nav._locationinput_click_suggestion);

View file

@ -4,7 +4,7 @@
{% load i18n %}
{% block content %}
<main class="map" data-state="{{ state }}"{% if embed %} data-embed{% endif %} data-last-site-update="{{ last_site_update }}"{% if ssids %} data-ssids="{{ ssids }}"{% endif %} data-primary-color="{{ primary_color }}">
<main class="map" data-state="{{ state }}"{% if embed %} data-embed{% endif %} data-last-site-update="{{ last_site_update }}"{% if ssids %} data-ssids="{{ ssids }}"{% endif %} data-primary-color="{{ primary_color }}"{% if random_location_groups %} data-random-location-groups="{{ random_location_groups }}"{% endif %}>
{% if not request.mobileclient %}
<section id="attributions">
{% if not embed %}
@ -108,6 +108,7 @@
<i class="icon material-icons">place</i>
<input type="text" autocomplete="off" spellcheck="false" placeholder="{% trans 'Search any location…' %}">
<small></small>
<button class="button-clear random material-icons" href="/random/">casino</button>
<button class="button-clear locate material-icons">location_disabled</button>
<button class="button-clear clear material-icons">clear</button>
</div>

View file

@ -136,6 +136,9 @@ def map_index(request, mode=None, slug=None, slug2=None, details=None, options=N
'initial_bounds': json.dumps(initial_bounds, separators=(',', ':')) if initial_bounds else None,
'last_site_update': json.dumps(SiteUpdate.last_update()),
'ssids': json.dumps(settings.WIFI_SSIDS, separators=(',', ':')) if settings.WIFI_SSIDS else None,
'random_location_groups': (
','.join(str(i) for i in settings.RANDOM_LOCATION_GROUPS) if settings.RANDOM_LOCATION_GROUPS else None
),
'editor': can_access_editor(request),
'embed': bool(embed),
}