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