]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/templates/answer_edit.html
warning users that edits will be lost if they navigate away from the page.
[osqa.git] / forum / skins / default / templates / answer_edit.html
1 {% extends "base.html" %}
2 <!-- template answer_edit.html -->
3 {% load i18n %}
4 {% load extra_tags %}
5 {% block title %}{% spaceless %}{% trans "Edit answer" %}{% 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         
12         $().ready(function(){
13             $("#nav_questions").attr('className',"on");
14             $('#editor').TextAreaResizer();
15                              
16             //toggle preview of editor
17             var display = true;
18             var txt = "{% trans "hide preview" %}";
19             $('#pre-collapse').text(txt);
20             $('#pre-collapse').bind('click', function(){
21                 txt = display ? "{% trans "show preview" %}" : "{% trans "hide preview" %}";
22                 display = !display;
23                 $('#previewer').toggle();
24                 $('#pre-collapse').text(txt);
25             });
26
27             
28             $('#id_revision').unbind().change(function(){
29                 $("#select_revision").click();
30             });
31         });
32
33         function beforeUnload(e) {
34             if($("textarea#editor")[0].value != "") {
35                yourWorkWillBeLost(e);
36             }
37
38             return false;
39         }
40         window.addEventListener('beforeunload', beforeUnload, true);
41         </script>
42 {% endblock %}
43         
44 {% block content %}
45 <div id="main-bar" class="headNormal">
46     {% trans "Edit answer" %} [<a href="{{ answer.question.get_absolute_url }}#{{ answer.id }}">{% trans "back" %}</a>]
47 </div>
48 <div id="main-body" class="ask-body">
49     <div id="askform">
50         <form id="fmedit" action="{% url edit_answer answer.id %}" method="post" >
51             <label for="id_revision" ><strong>{% trans "revision" %}:</strong></label> <br/> 
52             {% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul }}{% endif %}
53             <div>
54             {{ revision_form.revision }} <input type="submit" style="display:none" id="select_revision" name="select_revision" value="{% trans "select revision" %}">
55             </div>
56             <div class="form-item">
57                 <div id="wmd-button-bar" class="wmd-panel"></div>
58                 {{ form.text }}
59                 <span class="form-error"></span>
60                 <div class="preview-toggle"><span id="pre-collapse" 
61                                         title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
62                                 {% if settings.WIKI_ON %}
63                     <div style="float:right;">
64                         {{ form.wiki }} <span style="color:#000;cursor:help" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag }} </span>
65                     </div>
66                     {% endif %}
67                 </div>
68                 <div id="previewer" class="wmd-preview"></div>
69             </div>
70             
71             <strong>{{ form.summary.label_tag }}</strong> <br/>
72             {{ form.summary }}  {{ form.summary.errors }}
73             <div class="title-desc">
74                 {{ form.summary.help_text }}
75             </div>
76             <input type="submit" value="{% trans "Save edit" %}" class="submit" onclick="window.removeEventListener('beforeunload', beforeUnload, true)" />
77             <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);" />
78         </form>
79     </div>
80 </div>
81 {% endblock %}
82
83 {% block sidebar %}
84 {% include "answer_edit_tips.html" %}
85 {% endblock %}
86
87 {% block endjs %}
88 {% endblock %}
89 <!-- end template answer_edit.html -->