]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/templates/ask.html
make sure that we pre-wrap the lines of code in the markdown code blocks
[osqa.git] / forum / skins / default / templates / ask.html
1 {% extends "base.html" %}
2 <!-- template ask.html -->
3 {% load i18n extra_tags extra_filters %}
4 {% block title %}{% spaceless %}{% trans "Ask a question" %}{% endspaceless %}{% endblock %}
5 {% block forejs %}
6         <script type='text/javascript' src='{% media  "/media/js/wmd/showdown.js" %}'></script>
7         <script type='text/javascript' src='{% media  "/media/js/wmd/wmd.js" %}'></script>
8         <link rel="stylesheet" type="text/css" href="{% media  "/media/js/wmd/wmd.css" %}" />
9         <script type="text/html" id="question-summary-template">
10             <div class="answer-summary">
11                 <a href="%URL%"><div class="answer-votes">%SCORE%</div></a>
12                 <div class="answer-link">
13                     <a class="question-hyperlink" href="%URL%" title="%SUMMARY%">%TITLE%</a>
14                 </div>
15             </div>
16         </script>
17         <script type="text/javascript">
18         $(function(){
19             //set current module button style
20             $("#nav_ask").attr('className',"on");
21             $('#editor').TextAreaResizer();
22
23             //toggle preview of editor
24                         //todo remove copy-paste
25             var display = true;
26             var txt = "[{% trans "hide preview" %}]";
27             $('#pre-collapse').text(txt);
28             $('#pre-collapse').bind('click', function(){
29                 txt = display ? "[{% trans "show preview" %}]" : "[{% trans "hide preview" %}]";
30                 display = !display;
31                 $('#previewer').toggle();
32                 $('#pre-collapse').text(txt);
33             });
34
35             //Tags autocomplete action
36                 $("#id_tags").autocomplete("{% url matching_tags %}", {
37                 minChars: 1,
38                         matchContains: true,
39                 max: 10,
40                 multiple: true,
41                 multipleSeparator: " ",
42                 highlightItem: true,
43                 scroll: true,
44                 scrollHeight: 300,
45
46
47                         /*
48                         formatItem: function(row, i, max) {
49                                 return row.n + " ("+ row.c +")";
50                         },
51                 formatResult: function(row, i, max){
52                     return row.n;
53                 }
54                 */
55
56                 formatItem: function(row, i, max, value) {
57                     return row[1] + " (" + row[2] + ")";
58                 },
59
60                 formatResult: function(row, i, max, value){
61                     return row[1];
62                 }
63
64             });
65
66         });
67
68         function submitClicked(e, f) {
69             if(!(browserTester('chrome') || browserTester('safari'))) {
70                 $("input.submit")[0].disabled=true;
71             }
72             window.removeEventListener('beforeunload', beforeUnload, true);
73             if (f) {
74                 f.submit();
75             }
76         }
77
78         function beforeUnload(e) {
79             if($("input#id_title")[0].value != "" || $("textarea#editor")[0].value != "" || $("input#id_tags")[0].value != "") {
80                 return yourWorkWillBeLost(e);
81             }
82         }
83         window.addEventListener('beforeunload', beforeUnload, true);
84
85         var related_questions_url = "{% url related_questions %}";
86         </script>
87         <script src="{% media "/media/js/osqa.ask.js" %}" type="text/javascript"></script>
88 {% endblock %}
89
90 {% block content %}
91 <div id="main-bar" class="headNormal">
92         {% trans "Ask a question" %}
93 </div>
94 <div id="main-body" class="ask-body">
95     <div id="askform">
96         <form id="fmask" action="" method="post" accept-charset="utf-8">
97             {% csrf_token %}
98                         {% if not request.user.is_authenticated %}
99             <div class="message">
100                 <span class="strong big">{% trans "You are welcome to start submitting your question anonymously." %}</span>
101                 <p>{% blocktrans %}
102                     After submiting your question, you will be redirected to the login/signup page.
103                     Your question will be saved in the current session and will be published after you login with your existing account,
104                     or signup for a new account{% endblocktrans %}{% if "ask"|contained_in:settings.REQUIRE_EMAIL_VALIDATION_TO %}
105                     {% trans "and validate your email." %}{% else %}.{% endif %}</p>
106             </div>
107             {% else %}
108                 {% if not request.user.email_valid_and_can_ask %}
109                     <div class="message">
110                         {% blocktrans %}Remember, your question will not be published until you validate your email.{% endblocktrans %}
111                         <a href="{% url send_validation_email %}">{% trans "Send me a validation link." %}</a>
112                     </div>
113                 {% endif %}
114                         {% endif %}
115             <div class="form-item">
116                 <label for="id_title" ><strong>{{ form.title.label_tag }}:</strong></label> <span class="form-error"></span><br/>
117                 {{ form.title }} {{ form.title.errors }}
118                 <div class="title-desc">
119                     {{ form.title.help_text }}
120                 </div>
121             </div>
122             <div id="ask-related-questions"></div>
123             <div class="form-item">
124                 <div id="wmd-button-bar" class="wmd-panel"></div>
125                 {{ form.text }} {{ form.text.errors }}
126                 <div class="preview-toggle">
127                     <table width="100%">
128                         <tr>
129                             <td>
130                                 <span id="pre-collapse" title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
131                             </td>
132                             <td style="text-align: right;" id="editor-metrics"></td>
133                             {% if settings.WIKI_ON %}
134                             <td class="tright">
135                                 {{ form.wiki }} <span class="help_text" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag }} </span>
136                             </td>
137                             {% endif %}
138                         </tr>
139
140                     </table>
141                 </div>
142                 <div id="previewer" class="wmd-preview"></div>
143                 <span class="form-error"></span>
144             </div>
145             <div class="form-item">
146                 <strong>{{ form.tags.label_tag }}:</strong> {% trans "(required)" %} <span class="form-error"></span><br/>
147                 {{ form.tags }}  {{ form.tags.errors }}
148             </div>
149                         <p class="title-desc">
150                                 {{ form.tags.help_text }}
151                         </p>
152                         
153             {% if form.recaptcha %}
154             <div class="question-captcha" style="float: left">
155                 {{ form.recaptcha.errors }}
156                 {{ form.recaptcha }}
157             </div>
158             <div class="clear"></div>
159             {% endif %}
160                         
161             {% if not request.user.is_authenticated %}                                                                        
162             <input name="ask" type="button" value="{% trans "Login/signup to post your question" %}" class="submit" onclick="submitClicked(event, this.form)"/>
163                         {% else %}
164             <input name="ask" type="button" value="{% trans "Ask your question" %}" class="submit" onclick="submitClicked(event, this.form)"/>
165             {% endif %}
166         </form>
167     </div>
168 </div>
169 {% endblock %}
170
171 {% block sidebar %}
172 {% include "question_edit_tips.html" %}
173 {% endblock %}
174
175 {% block endjs %}
176 {% endblock %}
177 <!-- end template ask.html -->