]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/templates/question_edit.html
enabling the CSRF protection middleware and adding the {% csrf_token %} tag to the...
[osqa.git] / forum / skins / default / templates / question_edit.html
1 {% extends "base.html" %}
2 <!-- question_edit.html -->
3 {% load i18n %}
4 {% load extra_tags %}
5 {% block title %}{% spaceless %}{% trans "Edit question" %}{% endspaceless %}{% endblock %}
6 {% block forejs %}
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        
12         $().ready(function(){
13             $("#nav_questions").attr('className',"on");
14             $('#editor').TextAreaResizer();
15             
16
17             //toggle preview of editor
18             var display = true;
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" %}]";
23                 display = !display;
24                 $('#previewer').toggle();
25                 $('#pre-collapse').text(txt);
26             });
27             
28             //Tags autocomplete action
29                 $("#id_tags").autocomplete("{% url matching_tags %}", {
30                         matchContains: true,
31                 max: 20,
32                 multiple: true,
33                 multipleSeparator: " ",
34                 highlightItem: true,
35                 scroll: true,
36                 scrollHeight: 300,
37                         /*formatItem: function(row, i, max) {
38                                 return row.n + " ("+ row.c +")";
39                         },
40                 formatResult: function(row, i, max){
41                     return row.n;
42                 }*/
43                 formatItem: function(row, i, max, value) {
44                     return row[1] + " (" + row[2] + ")";
45                 },
46
47                 formatResult: function(row, i, max, value){
48                     return row[1];
49                 }
50                 
51             });         
52
53             $('#id_revision').unbind().change(function(){
54                 $("#select_revision").click();
55             });
56
57             init = $("textarea#editor")[0].value;
58
59             title = $("input#id_title")[0].value;
60             body = $("textarea#editor")[0].value;
61             tag = $("input#id_tags")[0].value;
62         });
63
64         function submitClicked(e, f) {
65             if(!(browserTester('chrome') || browserTester('safari'))) {
66                 $("input.submit")[0].disabled=true;
67                 $("input.submit")[1].disabled=true;
68             }
69             window.removeEventListener('beforeunload', beforeUnload, true);
70             if (f) {
71                 f.submit();
72             }
73         }
74
75         function beforeUnload(e) {
76             if($("input#id_title")[0].value != title || $("textarea#editor")[0].value != body || $("input#id_tags")[0].value != tag) {
77                  return yourWorkWillBeLost(e);
78             }
79         }
80         window.addEventListener('beforeunload', beforeUnload, true);
81
82         var init = "";
83         var title = "";
84         var body = "";
85         var tag = "";
86         </script>
87 {% endblock %}
88         
89 {% block content %}
90 <div id="main-bar" class="headNormal">
91     {% block edittype %}{% trans "Edit question" %}{% endblock %} [<a href="{{ question.get_absolute_url }}">{% trans "back" %}</a>]
92 </div>
93 <div id="main-body" class="ask-body">
94     <div id="askform">
95         <form id="fmedit" action="" method="post">
96             {% csrf_token %}
97             <label for="id_revision" ><strong>{% trans "revision" %}:</strong></label> <br/> 
98             {% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul }}{% endif %}
99             <div style="vertical-align:middle">
100             {{ revision_form.revision }} <input type="submit" style="display:none" id="select_revision" name="select_revision" 
101                                                                                         value="{% trans "select revision"%}">
102             </div> 
103             <div class="form-item">
104                 <label for="id_title" ><strong>{{ form.title.label_tag }}:</strong></label> <span class="form-error"></span><br/> 
105                 {{ form.title }} {{ form.title.errors }}  
106                 <div class="title-desc">
107                     {{ form.title.help_text }}
108                 </div>     
109             </div>
110             <div class="form-item">
111                 <div id="wmd-button-bar" class="wmd-panel"></div>
112                 {{ form.text }}
113                 <span class="form-error"></span>
114                 <div class="preview-toggle">
115                     <table width="100%">
116                         <tr>
117                             <td>
118                                 <span id="pre-collapse" title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
119                             </td>
120                             <td style="text-align: right;" id="editor-metrics"></td>
121                             {% if settings.WIKI_ON %}
122                             <td style="text-align:right;">
123                                 {{ form.wiki }} <span style="color:#000;cursor:help" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag }} </span>
124                             </td>
125                             {% endif %}
126                         </tr>
127                     
128                     </table>   
129                 </div>
130                 <div id="previewer" class="wmd-preview"></div>
131             </div>
132             <div class="form-item">
133                 <strong>{{ form.tags.label_tag }}:</strong> <span class="form-error"></span><br/>
134                 {{ form.tags }}  {{ form.tags.errors }}
135                 <div class="title-desc">
136                     {{ form.tags.help_text }}
137                 </div>
138             </div>
139             <strong>{{ form.summary.label_tag }}</strong> <br/>
140             {{ form.summary }}  {{ form.summary.errors }}
141             <div class="title-desc">
142                 {{ form.summary.help_text }}
143             </div>
144             
145             {% if form.recaptcha %}
146             <div class="question-captcha" style="float: left">
147                 {{ form.recaptcha.errors }}
148                 {{ form.recaptcha }}
149             </div>
150             <div class="clear"></div>
151             {% endif %}
152             
153             <div class="error" ></div>
154             <input type="button" value="{% trans "Save edit" %}" class="submit" onclick="submitClicked(event, this.form)" />
155             <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="submitClicked(event, null); history.back(-1);" />
156         </form>
157     </div>
158 </div>
159 {% endblock %}
160
161 {% block sidebar %}
162 {% include "question_edit_tips.html" %}
163 {% endblock %}
164
165 {% block endjs %}
166 {% endblock %}
167 <!-- end question_edit.html -->