]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/templates/ask.html
fixes problem with always showing alert dialog in chrome. Still working out non...
[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("/matching_tags/", {
37                 minChars: 1,
38                         matchContains: true,
39                 max: 20,
40                 multiple: true,
41                 multipleSeparator: " ",
42
43                         /*
44                         formatItem: function(row, i, max) {
45                                 return row.n + " ("+ row.c +")";
46                         },
47                 formatResult: function(row, i, max){
48                     return row.n;
49                 }
50                 */
51
52                 formatItem: function(row, i, max, value) {
53                     return row[1].split(".")[0] + " (" + row[1].split(".")[1] + ")";
54                 },
55
56                 formatResult: function(row, i, max, value){
57                     return row[0];
58                 }
59
60             });
61
62         });
63
64         function submitClicked(e) {
65             if(!is_chrome)$("input.submit")[0].disabled=true;
66             window.removeEventListener('beforeunload', beforeUnload, true);
67         }
68
69         function beforeUnload(e) {
70             if($("input#id_title")[0].value != "" || $("textarea#editor")[0].value != "" || $("input#id_tags")[0].value != "") {
71                 if(is_chrome) {
72                     return "Are you sure you want to leave?  Your work will be lost.";
73                 } else {
74                     yourWorkWillBeLost(e);
75                 }
76             }
77         }
78         window.addEventListener('beforeunload', beforeUnload, true);
79
80         var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
81         var related_questions_url = "{% url related_questions %}";
82         </script>
83         <script src="{% media "/media/js/osqa.ask.js" %}" type="text/javascript"></script>
84 {% endblock %}
85
86 {% block content %}
87 <div id="main-bar" class="headNormal">
88         {% trans "Ask a question" %}
89 </div>
90 <div id="main-body" class="ask-body">
91     <div id="askform">
92         <form id="fmask" action="" method="post" accept-charset="utf-8">
93                         {% if not request.user.is_authenticated %}
94             <div class="message">
95                 <span class="strong big">{% trans "You are welcome to start submitting your question anonymously." %}</span>
96                 <p>{% blocktrans %}
97                     After submiting your question, you will be redirected to the login/signup page.
98                     Your question will be saved in the current session and will be published after you login with your existing account,
99                     or signup for a new account{% endblocktrans %}{% if "ask"|contained_in:settings.REQUIRE_EMAIL_VALIDATION_TO %}
100                     {% trans "and validate your email." %}{% else %}.{% endif %}</p>
101             </div>
102             {% else %}
103                 {% if not request.user.email_valid_and_can_ask %}
104                     <div class="message">
105                         {% blocktrans %}Remember, your question will not be published until you validate your email.{% endblocktrans %}
106                         <a href="{% url send_validation_email %}">{% trans "Send me a validation link." %}</a>
107                     </div>
108                 {% endif %}
109                         {% endif %}
110             <div class="form-item">
111                 <label for="id_title" ><strong>{{ form.title.label_tag }}:</strong></label> <span class="form-error"></span><br/>
112                 {{ form.title }} {{ form.title.errors }}
113                 <div class="title-desc">
114                     {{ form.title.help_text }}
115                 </div>
116             </div>
117             <div id="ask-related-questions"></div>
118             <div class="form-item">
119                 <div id="wmd-button-bar" class="wmd-panel"></div>
120                 {{ form.text }} {{ form.text.errors }}
121                 <div class="preview-toggle">
122                     <table width="100%">
123                         <tr>
124                             <td>
125                                 <span id="pre-collapse" title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
126                             </td>
127                             {% if settings.WIKI_ON %}
128                             <td class="tright">
129                                 {{ form.wiki }} <span class="help_text" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag }} </span>
130                             </td>
131                             {% endif %}
132                         </tr>
133
134                     </table>
135                 </div>
136                 <div id="previewer" class="wmd-preview"></div>
137                 <span class="form-error"></span>
138             </div>
139             <div class="form-item">
140                 <strong>{{ form.tags.label_tag }}:</strong> {% trans "(required)" %} <span class="form-error"></span><br/>
141                 {{ form.tags }}  {{ form.tags.errors }}
142             </div>
143                         <p class="title-desc">
144                                 {{ form.tags.help_text }}
145                         </p>
146             {% if not request.user.is_authenticated %}                                                                        
147             <input name="ask" type="submit" value="{% trans "Login/signup to post your question" %}" class="submit" onclick="submitClicked(event)"/>
148                         {% else %}
149             <input name="ask" type="submit" value="{% trans "Ask your question" %}" class="submit" onclick="submitClicked(event)"/>
150             {% endif %}
151         </form>
152     </div>
153 </div>
154 {% endblock %}
155
156 {% block sidebar %}
157 {% include "question_edit_tips.html" %}
158 {% endblock %}
159
160 {% block endjs %}
161 {% endblock %}
162 <!-- end template ask.html -->