From 6b3990386bf9d237bf90911802743017cd287bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Tue, 16 May 2017 16:22:33 +0200 Subject: [PATCH] enable using the editor with noscript (without the map, of course) --- src/c3nav/editor/static/editor/css/editor.css | 9 +++++++++ src/c3nav/editor/static/editor/js/editor.js | 15 ++++++++++----- src/c3nav/editor/templates/editor/map.html | 9 +++++++-- src/c3nav/editor/views.py | 7 ++++--- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/c3nav/editor/static/editor/css/editor.css b/src/c3nav/editor/static/editor/css/editor.css index 44010d8d..cf1b05ac 100644 --- a/src/c3nav/editor/static/editor/css/editor.css +++ b/src/c3nav/editor/static/editor/css/editor.css @@ -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 { diff --git a/src/c3nav/editor/static/editor/js/editor.js b/src/c3nav/editor/static/editor/js/editor.js index 93511213..d7f87c1a 100644 --- a/src/c3nav/editor/static/editor/js/editor.js +++ b/src/c3nav/editor/static/editor/js/editor.js @@ -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'); diff --git a/src/c3nav/editor/templates/editor/map.html b/src/c3nav/editor/templates/editor/map.html index 3b57ee70..e5705c08 100644 --- a/src/c3nav/editor/templates/editor/map.html +++ b/src/c3nav/editor/templates/editor/map.html @@ -1,6 +1,11 @@ {% extends 'editor/base.html' %} {% load static %} +{% load i18n %} + {% block addnav %} +