War on TODOs

Improved mermaid and photoswipe extensions, handled control-s on the edit page.
This commit is contained in:
Simon Brooke 2020-02-20 12:35:00 +00:00
parent ac433c3afa
commit c19580a23e
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
10 changed files with 142 additions and 61 deletions

View file

@ -11,7 +11,7 @@
{% block content %}
<div id="content" class="edit">
<form action="{{servlet-context}}/edit" method="POST">
<form id="edit-form" action="{{servlet-context}}/edit" method="POST">
{% csrf-field %}
<input type="hidden" name="page" value="{{page}}"/>
<textarea name="src" id="src" rows="25" cols="80">{{content}}</textarea>
@ -21,12 +21,20 @@
value="{%if exists%}{%else%}New file {{page}}{%endif%}" required/>
</p>
<p class="widget">
<label for="submit">{% i18n save-prompt %}</label>
<input name="submit" id="submit" type="submit" class="action" value="{% i18n save-label %}"/>
<label for="submit-button">{% i18n save-prompt %}</label>
<input name="submit-button" id="submit-button" type="submit" class="action" value="{% i18n save-label %}"/>
</p>
</form>
</div>
<script>
// intercept control-S (or on Mac meta-S) and submit the form. Saves much annoyance.
document.addEventListener("keydown", function(e) {
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
e.preventDefault();
document.getElementById('edit-form').submit();
}
}, false);
// initialise the editor
var simplemde = new SimpleMDE({
autosave: {
enabled: true,

View file

@ -17,14 +17,4 @@
{% endif %}
{{content|safe}}
</div>
<script>
//<![CDATA[
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", function(event) {
mermaid.initialize({startOnLoad:true});
});
}
//]]
</script>
{% endblock %}