1 {% extends "base.html" %}
2 <!-- question_edit.html -->
5 {% block title %}{% spaceless %}{% trans "Edit question" %}{% endspaceless %}{% endblock %}
7 <script type='text/javascript' src='{% media "/media/js/wmd/showdown.js" %}'></script>
8 <script type='text/javascript' src='{% media "/media/js/wmd/wmd.js" %}'></script>
9 <link rel="stylesheet" type="text/css" href="{% media "/media/js/wmd/wmd.css" %}" />
10 <script type="text/javascript">
11 //todo move javascript out
13 $("#nav_questions").attr('className',"on");
14 $('#editor').TextAreaResizer();
17 //toggle preview of editor
19 var txt = "[{% trans "hide preview" %}]";
20 $('#pre-collapse').text(txt);
21 $('#pre-collapse').bind('click', function(){
22 txt = display ? "[{% trans "show preview" %}]" : "[{% trans "hide preview" %}]";
24 $('#previewer').toggle();
25 $('#pre-collapse').text(txt);
28 //Tags autocomplete action
29 $("#id_tags").autocomplete("/matching_tags/", {
33 multipleSeparator: " ",
37 /*formatItem: function(row, i, max) {
38 return row.n + " ("+ row.c +")";
40 formatResult: function(row, i, max){
43 formatItem: function(row, i, max, value) {
44 return row[1].split(".")[0] + " (" + row[1].split(".")[1] + ")";
47 formatResult: function(row, i, max, value){
53 $('#id_revision').unbind().change(function(){
54 $("#select_revision").click();
57 init = $("textarea#editor")[0].value;
59 title = $("input#id_title")[0].value;
60 body = $("textarea#editor")[0].value;
61 tag = $("input#id_tags")[0].value;
64 function submitClicked(e) {
66 $("input.submit")[0].disabled=true;
67 $("input.submit")[1].disabled=true;
69 window.removeEventListener('beforeunload', beforeUnload, true);
72 function beforeUnload(e) {
73 var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
75 if($("input#id_title")[0].value != title || $("textarea#editor")[0].value != body || $("input#id_tags")[0].value != tag) {
77 return "You sure you want to leave? Your work will be lost.";
79 yourWorkWillBeLost(e);
83 window.addEventListener('beforeunload', beforeUnload, true);
93 <div id="main-bar" class="headNormal">
94 {% trans "Edit question" %} [<a href="{{ question.get_absolute_url }}">{% trans "back" %}</a>]
96 <div id="main-body" class="ask-body">
98 <form id="fmedit" action="{% url edit_question question.id %}" method="post" >
99 <label for="id_revision" ><strong>{% trans "revision" %}:</strong></label> <br/>
100 {% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul }}{% endif %}
101 <div style="vertical-align:middle">
102 {{ revision_form.revision }} <input type="submit" style="display:none" id="select_revision" name="select_revision"
103 value="{% trans "select revision"%}">
105 <div class="form-item">
106 <label for="id_title" ><strong>{{ form.title.label_tag }}:</strong></label> <span class="form-error"></span><br/>
107 {{ form.title }} {{ form.title.errors }}
108 <div class="title-desc">
109 {{ form.title.help_text }}
112 <div class="form-item">
113 <div id="wmd-button-bar" class="wmd-panel"></div>
115 <span class="form-error"></span>
116 <div class="preview-toggle">
120 <span id="pre-collapse" title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
122 {% if settings.WIKI_ON %}
123 <td style="text-align:right;">
124 {{ form.wiki }} <span style="color:#000;cursor:help" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag }} </span>
131 <div id="previewer" class="wmd-preview"></div>
133 <div class="form-item">
134 <strong>{{ form.tags.label_tag }}:</strong> <span class="form-error"></span><br/>
135 {{ form.tags }} {{ form.tags.errors }}
136 <div class="title-desc">
137 {{ form.tags.help_text }}
140 <strong>{{ form.summary.label_tag }}</strong> <br/>
141 {{ form.summary }} {{ form.summary.errors }}
142 <div class="title-desc">
143 {{ form.summary.help_text }}
145 <div class="error" ></div>
146 <input type="submit" value="{% trans "Save edit" %}" class="submit" onclick="submitClicked(event)" />
147 <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);submitClicked(event)" />
154 {% include "question_edit_tips.html" %}
159 <!-- end question_edit.html -->