]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/templates/question_edit.html
warning users that edits will be lost if they navigate away from the page.
[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("/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].split(".")[0] + " (" + row[1].split(".")[1] + ")";
45                 },
46
47                 formatResult: function(row, i, max, value){
48                     return row[0];
49                 }
50                 
51             });         
52
53             $('#id_revision').unbind().change(function(){
54                 $("#select_revision").click();
55             });
56
57             init = $("textarea#editor")[0].value;
58         });
59
60          function beforeUnload(e) {
61              if($("input#id_title")[0].value != "" || $("textarea#editor")[0].value != "" || $("input#id_tags")[0].value != "") {
62                  yourWorkWillBeLost(e);
63              }
64              return false;
65          }
66          window.addEventListener('beforeunload', beforeUnload, true);
67
68         var init = "";
69         </script>
70 {% endblock %}
71         
72 {% block content %}
73 <div id="main-bar" class="headNormal">
74     {% trans "Edit question" %} [<a href="{{ question.get_absolute_url }}">{% trans "back" %}</a>]
75 </div>
76 <div id="main-body" class="ask-body">
77     <div id="askform">
78         <form id="fmedit" action="{% url edit_question question.id %}" method="post" >
79             <label for="id_revision" ><strong>{% trans "revision" %}:</strong></label> <br/> 
80             {% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul }}{% endif %}
81             <div style="vertical-align:middle">
82             {{ revision_form.revision }} <input type="submit" style="display:none" id="select_revision" name="select_revision" 
83                                                                                         value="{% trans "select revision"%}">
84             </div> 
85             <div class="form-item">
86                 <label for="id_title" ><strong>{{ form.title.label_tag }}:</strong></label> <span class="form-error"></span><br/> 
87                 {{ form.title }} {{ form.title.errors }}  
88                 <div class="title-desc">
89                     {{ form.title.help_text }}
90                 </div>     
91             </div>
92             <div class="form-item">
93                 <div id="wmd-button-bar" class="wmd-panel"></div>
94                 {{ form.text }}
95                 <span class="form-error"></span>
96                 <div class="preview-toggle">
97                     <table width="100%">
98                         <tr>
99                             <td>
100                                 <span id="pre-collapse" title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
101                             </td>
102                             {% if settings.WIKI_ON %}
103                             <td style="text-align:right;">
104                                 {{ form.wiki }} <span style="color:#000;cursor:help" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag }} </span>
105                             </td>
106                             {% endif %}
107                         </tr>
108                     
109                     </table>   
110                 </div>
111                 <div id="previewer" class="wmd-preview"></div>
112             </div>
113             <div class="form-item">
114                 <strong>{{ form.tags.label_tag }}:</strong> <span class="form-error"></span><br/>
115                 {{ form.tags }}  {{ form.tags.errors }}
116                 <div class="title-desc">
117                     {{ form.tags.help_text }}
118                 </div>
119             </div>
120             <strong>{{ form.summary.label_tag }}</strong> <br/>
121             {{ form.summary }}  {{ form.summary.errors }}
122             <div class="title-desc">
123                 {{ form.summary.help_text }}
124             </div>
125             <div class="error" ></div>
126             <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="window.removeEventListener('beforeunload', beforeUnload, true)" />
127
128         </form>
129     </div>
130 </div>
131 {% endblock %}
132
133 {% block sidebar %}
134 {% include "question_edit_tips.html" %}
135 {% endblock %}
136
137 {% block endjs %}
138 {% endblock %}
139 <!-- end question_edit.html -->