Added WYSIWYG editor. Works for notes & description, fails miserably for items :(

This commit is contained in:
David Taylor
2016-03-31 01:23:58 +01:00
parent e2e7f5845a
commit 1b4cc91ec8
2 changed files with 15 additions and 7 deletions

View File

@@ -8,11 +8,13 @@
{% block css %} {% block css %}
<link rel="stylesheet" href="{% static "css/bootstrap-select.min.css" %}"/> <link rel="stylesheet" href="{% static "css/bootstrap-select.min.css" %}"/>
<link rel="stylesheet" href="{% static "css/ajax-bootstrap-select.css" %}"/> <link rel="stylesheet" href="{% static "css/ajax-bootstrap-select.css" %}"/>
<link rel="stylesheet" href="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
{% endblock %} {% endblock %}
{% block preload_js %} {% block preload_js %}
<script src="{% static "js/bootstrap-select.js" %}"></script> <script src="{% static "js/bootstrap-select.js" %}"></script>
<script src="{% static "js/ajax-bootstrap-select.js" %}"></script> <script src="{% static "js/ajax-bootstrap-select.js" %}"></script>
<script src="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
{% endblock %} {% endblock %}
{% block js %} {% block js %}
@@ -40,6 +42,15 @@
} }
$(document).ready(function () { $(document).ready(function () {
$(".md-enabled").each(function(index){
editor = new SimpleMDE({
element: $(".md-enabled")[index],
toolbar: ["bold", "italic", "strikethrough", "|", "unordered-list", "ordered-list", "|", "link", "|", "preview", "guide"],
status: false,
});
});
{% if not object.pk and not form.errors %} {% if not object.pk and not form.errors %}
$('.form-hws').slideUp(function () { $('.form-hws').slideUp(function () {
@@ -225,11 +236,8 @@
<div class="panel-heading">Event Description</div> <div class="panel-heading">Event Description</div>
<div class="panel-body"> <div class="panel-body">
<div class="form-group" data-toggle="tooltip" title="A short description of the event, shown on rigboard and on paperwork. MD enabled."> <div class="form-group" data-toggle="tooltip" title="A short description of the event, shown on rigboard and on paperwork. MD enabled.">
<label for="{{ form.description.id_for_label }}" <div class="col-sm-12">
class="col-sm-4 control-label">{{ form.description.label }}</label> {% render_field form.description class+="form-control md-enabled" %}
<div class="col-sm-8">
{% render_field form.description class+="form-control" %}
</div> </div>
</div> </div>
</div> </div>
@@ -424,7 +432,7 @@
<div class="col-sm-12"> <div class="col-sm-12">
<div class="form-group" data-toggle="tooltip" title="Notes on the event. This is only visible to keyholders, and is not displayed on the paperwork. MD enabled."> <div class="form-group" data-toggle="tooltip" title="Notes on the event. This is only visible to keyholders, and is not displayed on the paperwork. MD enabled.">
<label for="{{ form.notes.id_for_label }}">{{ form.notes.label }}</label> <label for="{{ form.notes.id_for_label }}">{{ form.notes.label }}</label>
{% render_field form.notes class+="form-control" %} {% render_field form.notes class+="form-control md-enabled" %}
</div> </div>
</div> </div>
{% include "RIGS/item_table.html" %} {% include "RIGS/item_table.html" %}

View File

@@ -27,7 +27,7 @@
<label for="item_description" class="col-sm-2 control-label">Description</label> <label for="item_description" class="col-sm-2 control-label">Description</label>
<div class="col-sm-10"> <div class="col-sm-10">
<textarea type="text" placeholder="Description" class="form-control" <textarea type="text" placeholder="Description" class="form-control md-enabled"
id="item_description" rows="8"></textarea> id="item_description" rows="8"></textarea>
</div> </div>
</div> </div>