blob: 8d5b61db45fe20d134885049c55d39f7a34617bb (
plain) (
blame)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
{% extends "wiki/article.html" %}
{% load wiki_tags i18n sekizai_tags %}
{% block wiki_pagetitle %}
Edit: {{ article.current_revision.title }}
{% endblock %}
{% block head %}
{{ block.super }}
<script language="javascript">
{# I'm sorry this JS sucks, it came with the wiki, just stuck right in here. #}
$(document).ready(function() {
$("#article_edit_form :input").change(function() {
$("#article_edit_form").data("changed",true);
});
if ($("#article_edit_form").find(".alert-danger").length > 0 || $("#article_edit_form").find(".has-error").length > 0 ) {
// Set the forms status as "changed" if there was a submission error
$("#article_edit_form").data("changed",true);
}
window.onbeforeunload = confirmOnPageExit;
var click_time = 0;
$("#article_edit_form").on("submit", function (ev) {
now = Date.now();
elapsed = now-click_time;
click_time = now;
if (elapsed < 3000)
ev.preventDefault();
window.onbeforeunload = null;
return true;
});
$("#id_preview").on("click", function () {
$("#previewModal").modal("show");
return true;
});
$("#id_preview_save_changes").on("click", function (ev) {
ev.preventDefault();
$("#id_save").trigger("click");
});
});
var confirmOnPageExit = function (e) {
if ($("#article_edit_form").data("changed")) {
e = e || window.event;
var message = "You have unsaved changes!";
// For IE6-8 and Firefox prior to version 4
if (e) {
e.returnValue = message;
}
// For Chrome, Safari, IE8+ and Opera 12+
return message;
} else {
// If the form hasn't been changed, don't display the pop-up
return;
}
};
</script>
<script type="text/javascript">
$(document).ready( function() {
$('.sidebar-form').each(function () {
$(this).submit( function() {
this.unsaved_article_title.value = $('#id_title').val();
this.unsaved_article_content.value = $('#id_content').val();
});
});
});
</script>
<script language="javascript">
$(document).ready(function() {
$("#id_revision").val('{{ article.current_revision.id }}');
});
</script>
{% endblock %}
{% block wiki_contents_tab %}
{% if not user.is_authenticated %}
<p class="alert alert-warning">
{% trans "<strong>Warning:</strong> You are not logged in. Your IP address will be logged." %}
<a href="{% url 'wiki:login' %}?next={% url 'wiki:edit' article_id=article.id path=urlpath.path %}">{% trans "Click here to log in" %} »</a>
</p>
{% endif %}
<div class="row">
<div class="col-lg-8">
<form method="POST" class="form-horizontal" id="article_edit_form">
{% with edit_form as form %}
{% include "wiki/includes/editor.html" %}
{% endwith %}
<button class="button is-primary" type="submit" name="preview" value="1" id="id_preview"
formaction="{% url 'wiki:preview' path=urlpath.path article_id=article.id %}"
formtarget="previewWindow"
>
<span class="icon">
<i class="fas fa-eye"></i>
</span>
<span>Preview</span>
</button>
<button class="button is-primary" type="submit" name="save" value="1" id="id_save">
<span class="icon">
<i class="fas fa-save"></i>
</span>
<span>Save Changes</span>
</button>
<div class="is-pulled-right">
{% if user.is_authenticated and urlpath.path %}
<a href="{% url 'wiki:move' path=urlpath.path article_id=article.id %}" class="button is-warning ">
<span class="icon">
<i class="fas fa-random"></i>
</span>
<span>Move Article</span>
</a>
{% endif %}
{% if article|can_delete:user %}
<a href="{% url 'wiki:delete' path=urlpath.path article_id=article.id %}" class="button is-danger">
<span class="icon">
<i class="fas fa-trash"></i>
</span>
<span>Delete Article</span>
</a>
{% endif %}
</div>
<br />
<br />
</form>
</div>
<div class="col-lg-4" id="wiki-edit-sidebar">
{% include "wiki/includes/editor_sidebar.html" %}
</div>
</div>
<div style="clear: both"></div>
{% include "wiki/includes/modals.html" %}
<div class="modal fade wiki-modal" id="previewModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<iframe name="previewWindow" frameborder="0"></iframe>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-default btn-lg" data-dismiss="modal">
<span class="fa fa-arrow-circle-left"></span>
{% trans "Back to editor" %}
</a>
<a class="btn btn-lg btn-primary" id="id_preview_save_changes" href="#">
<span class="fa fa-check"></span>
{% trans "Save changes" %}
</a>
</div>
</div>
</div>
</div>
{% endblock %}
|