summaryrefslogtreecommitdiffstats
path: root/templates/news/add.html
blob: 51f4d3040849a4fec88f7e8ca70697aed3e3e351 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{% extends "base.html" %}
{% block title %}Arch Linux - News: {% if form.instance.id %}Edit{% else %}Add{% endif %} Article{% endblock %}

{% block content %}
<div id="news-add-article" class="box">

    {% if form.instance.id %}
    <h2>News: Edit Article</h2>
    {% else %}
    <h2>News: Add Article</h2>
    {% endif %}
    <p>News articles are formatted using
    <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a>.
    Please use this syntax if at all possible over raw HTML, which can be used
    if Markdown doesn't support what you would like to do. Before posting, you
    are highly encouraged to use the <strong>Preview</strong> button to check
    your work.  Javascript must be enabled to use it, but it will render the
    news item exactly as it will appear on the news view page.</p>
    <form id="newsform" method="post">{% csrf_token %}
        <fieldset>
            {{ form.as_p }}
        </fieldset>
        <p>
        <label></label>
        <input title="Save changes" type="submit" value="Save" />
        <input id="previewbtn" title="Preview" type="button" value="Preview" />
        </p>
    </form>
</div>

<div class="news-article box" style="display:none;">
    <h2>News Preview: <span id="previewtitle"></span></h2>
    <div id="previewdata"></div>
</div>
{% load cdn %}{% jquery %}
<script type="text/javascript">
function enablePreview() {
    $('#previewbtn').click(function(event) {
        event.preventDefault();
        $.post('/news/preview/',
            { data: $('#id_content').val() },
            function(data) {
            $('#previewdata').html(data);
            $('.news-article').show();
        });
        $('#previewtitle').html($('#id_title').val());
    });
}
$(document).ready(enablePreview);
</script>
{% endblock %}