Merge branch 'random'
This commit is contained in:
commit
019aacd834
5 changed files with 84 additions and 2 deletions
|
@ -66,6 +66,10 @@ PUBLIC_EDITOR = config.getboolean('c3nav', 'editor', fallback=True)
|
||||||
PUBLIC_BASE_MAPDATA = config.getboolean('c3nav', 'public_base_mapdata', fallback=False)
|
PUBLIC_BASE_MAPDATA = config.getboolean('c3nav', 'public_base_mapdata', fallback=False)
|
||||||
AUTO_PROCESS_UPDATES = config.getboolean('c3nav', 'auto_process_updates', fallback=True)
|
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'):
|
if config.has_option('django', 'secret'):
|
||||||
SECRET_KEY = config.get('django', 'secret')
|
SECRET_KEY = config.get('django', 'secret')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -671,7 +671,18 @@ main.show-options #resultswrapper #route-options {
|
||||||
font-size: 35px;
|
font-size: 35px;
|
||||||
top: 5px;
|
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);
|
-webkit-transform: scale(0.7);
|
||||||
-ms-transform: scale(0.7);
|
-ms-transform: scale(0.7);
|
||||||
transform: scale(0.7);
|
transform: scale(0.7);
|
||||||
|
|
|
@ -155,6 +155,8 @@ c3nav = {
|
||||||
|
|
||||||
c3nav.ssids = $main.is('[data-ssids]') ? JSON.parse($main.attr('data-ssids')) : null;
|
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(',').map(id => parseInt(id)) : null;
|
||||||
|
|
||||||
history.replaceState(state, window.location.path);
|
history.replaceState(state, window.location.path);
|
||||||
c3nav.load_state(state, true);
|
c3nav.load_state(state, true);
|
||||||
c3nav.update_map_locations();
|
c3nav.update_map_locations();
|
||||||
|
@ -864,6 +866,7 @@ c3nav = {
|
||||||
.on('keydown', c3nav._locationinput_keydown);
|
.on('keydown', c3nav._locationinput_keydown);
|
||||||
$('.locationinput .clear').on('click', c3nav._locationinput_clear);
|
$('.locationinput .clear').on('click', c3nav._locationinput_clear);
|
||||||
$('.locationinput .locate').on('click', c3nav._locationinput_locate);
|
$('.locationinput .locate').on('click', c3nav._locationinput_locate);
|
||||||
|
$('.locationinput .random').on('click', c3nav._random_location_click);
|
||||||
$('.leaflet-control-user-location a').on('click', c3nav._goto_user_location_click).dblclick(function(e) { e.stopPropagation(); });
|
$('.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)
|
$('#autocomplete').on('mouseover', '.location', c3nav._locationinput_hover_suggestion)
|
||||||
.on('click', '.location', c3nav._locationinput_click_suggestion);
|
.on('click', '.location', c3nav._locationinput_click_suggestion);
|
||||||
|
@ -1132,6 +1135,66 @@ c3nav = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_random_location_click: function() {
|
||||||
|
var $button = $('button.random'),
|
||||||
|
parent = $button.parent(),
|
||||||
|
width = parent.width(),
|
||||||
|
height = parent.height();
|
||||||
|
|
||||||
|
$cover = $('<div>').css({
|
||||||
|
'width': width+'px',
|
||||||
|
'height': height+'px',
|
||||||
|
'background-color': '#ffffff',
|
||||||
|
'position': 'absolute',
|
||||||
|
'top': 0,
|
||||||
|
'left': $button.position().left+$button.width()/2+'px',
|
||||||
|
'z-index': 200,
|
||||||
|
}).appendTo(parent);
|
||||||
|
|
||||||
|
$cover.animate({
|
||||||
|
left: 5+$button.width()/2+'px'
|
||||||
|
}, 300, 'swing');
|
||||||
|
$button.css({
|
||||||
|
'left': $button.position().left,
|
||||||
|
'background-color': '#ffffff',
|
||||||
|
'right': null,
|
||||||
|
'z-index': 201,
|
||||||
|
'opacity': 1,
|
||||||
|
'transform': 'scale(1)',
|
||||||
|
'color': c3nav._primary_color,
|
||||||
|
'pointer-events': 'none'
|
||||||
|
}).animate({
|
||||||
|
left: 5,
|
||||||
|
}, 300, 'swing').queue(function(d) {
|
||||||
|
d();
|
||||||
|
var possible_locations = [];
|
||||||
|
for (var id of c3nav.random_location_groups) {
|
||||||
|
var group = c3nav.locations_by_id[id];
|
||||||
|
if (!group) continue;
|
||||||
|
// todo set und so
|
||||||
|
for (var subid of group.locations) {
|
||||||
|
if (!(subid in possible_locations) && subid in c3nav.locations_by_id) {
|
||||||
|
possible_locations.push(subid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var location = c3nav.locations_by_id[possible_locations[Math.floor(Math.random()*possible_locations.length)]];
|
||||||
|
c3nav._locationinput_set($('#destination-input'), location);
|
||||||
|
c3nav.update_state(false);
|
||||||
|
c3nav.fly_to_bounds(true);
|
||||||
|
$cover.animate({
|
||||||
|
left: width+$button.width()/2+'px'
|
||||||
|
}, 300, 'swing');
|
||||||
|
$button.animate({
|
||||||
|
left: width,
|
||||||
|
}, 300, 'swing').queue(function(d) {
|
||||||
|
d();
|
||||||
|
$button.attr('style', '');
|
||||||
|
$cover.remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
modal_noclose: false,
|
modal_noclose: false,
|
||||||
open_modal: function (content, no_close) {
|
open_modal: function (content, no_close) {
|
||||||
c3nav.modal_noclose = no_close;
|
c3nav.modal_noclose = no_close;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% 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 %}
|
{% if not request.mobileclient %}
|
||||||
<section id="attributions">
|
<section id="attributions">
|
||||||
{% if not embed %}
|
{% if not embed %}
|
||||||
|
@ -108,6 +108,7 @@
|
||||||
<i class="icon material-icons">place</i>
|
<i class="icon material-icons">place</i>
|
||||||
<input type="text" autocomplete="off" spellcheck="false" placeholder="{% trans 'Search any location…' %}">
|
<input type="text" autocomplete="off" spellcheck="false" placeholder="{% trans 'Search any location…' %}">
|
||||||
<small></small>
|
<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 locate material-icons">location_disabled</button>
|
||||||
<button class="button-clear clear material-icons">clear</button>
|
<button class="button-clear clear material-icons">clear</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -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,
|
'initial_bounds': json.dumps(initial_bounds, separators=(',', ':')) if initial_bounds else None,
|
||||||
'last_site_update': json.dumps(SiteUpdate.last_update()),
|
'last_site_update': json.dumps(SiteUpdate.last_update()),
|
||||||
'ssids': json.dumps(settings.WIFI_SSIDS, separators=(',', ':')) if settings.WIFI_SSIDS else None,
|
'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),
|
'editor': can_access_editor(request),
|
||||||
'embed': bool(embed),
|
'embed': bool(embed),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue