enable using the editor with noscript (without the map, of course)

This commit is contained in:
Laura Klünder 2017-05-16 16:22:33 +02:00
parent dded1de9e3
commit 6b3990386b
4 changed files with 30 additions and 10 deletions

View file

@ -49,6 +49,15 @@ body:not(.map-enabled) #sidebar {
padding:10px 15px;
margin:auto;
}
#noscript {
font-weight:bold;
color:red;
padding-top:2px;
text-align:right;
font-size:14px;
line-height:15px;
height:50px;
}
/* sidebar contents */
#sidebar form.creation-lock .btn.btn-primary {

View file

@ -72,7 +72,7 @@ editor = {
.on('click', 'button[type=submit]', editor._sidebar_submit_btn_click)
.on('submit', 'form', editor._sidebar_submit);
var location_path = editor.get_location_path();
editor.sidebar_get(location_path);
editor._sidebar_loaded();
history.replaceState({}, '', location_path);
window.onpopstate = function() {
editor.sidebar_get(editor.get_location_path());
@ -95,16 +95,21 @@ editor = {
},
_sidebar_loaded: function(data) {
// sidebar was loaded. load the content. check if there are any redirects. call _check_start_editing.
var content = $(data);
$('#sidebar').removeClass('loading').find('.content').html(content);
var content;
if (data !== undefined) {
content = $(data);
$('#sidebar').removeClass('loading').find('.content').html(content);
} else {
content = $('#sidebar').find('.content')
}
var redirect = $('span[data-redirect]');
var redirect = content.find('span[data-redirect]');
if (redirect.length) {
editor.sidebar_get(redirect.attr('data-redirect'));
return;
}
sections = $('[data-sections]');
sections = content.find('[data-sections]');
if (sections.length) {
$('body').addClass('map-enabled');
var sections = sections.find('a');

View file

@ -1,6 +1,11 @@
{% extends 'editor/base.html' %}
{% load static %}
{% load i18n %}
{% block addnav %}
<noscript>
<div id="noscript">{% trans 'Editing geometries using the map requires JavaScript.' %}</div>
</noscript>
<div id="responsive_switch" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>
@ -12,7 +17,7 @@
{% endblock %}
{% block content %}
<div id="map"></div>
<div id="sidebar" class="loading">
<div class="content"></div>
<div id="sidebar">
<div class="content">{{ content | safe }}</div>
</div>
{% endblock %}

View file

@ -13,9 +13,10 @@ from c3nav.mapdata.models.base import EDITOR_FORM_MODELS
def sidebar_view(func):
@wraps(func)
def with_ajax_check(request, *args, **kwargs):
if not request.is_ajax():
return render(request, 'editor/map.html', {})
return func(request, *args, **kwargs)
response = func(request, *args, **kwargs)
if request.is_ajax():
return response
return render(request, 'editor/map.html', {'content': response.content})
return never_cache(with_ajax_check)