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 %}
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>
17 <script type="text/javascript">
19 //set current module button style
20 $("#nav_ask").attr('className',"on");
21 $('#editor').TextAreaResizer();
23 //toggle preview of editor
24 //todo remove copy-paste
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" %}]";
31 $('#previewer').toggle();
32 $('#pre-collapse').text(txt);
35 //Tags autocomplete action
36 $("#id_tags").autocomplete("/matching_tags/", {
41 multipleSeparator: " ",
48 formatItem: function(row, i, max) {
49 return row.n + " ("+ row.c +")";
51 formatResult: function(row, i, max){
56 formatItem: function(row, i, max, value) {
57 return row[1] + " (" + row[2] + ")";
60 formatResult: function(row, i, max, value){
68 function submitClicked(e, f) {
69 if(!(browserTester('chrome') || browserTester('safari'))) {
70 $("input.submit")[0].disabled=true;
72 window.removeEventListener('beforeunload', beforeUnload, true);
78 function beforeUnload(e) {
79 if($("input#id_title")[0].value != "" || $("textarea#editor")[0].value != "" || $("input#id_tags")[0].value != "") {
80 return yourWorkWillBeLost(e);
83 window.addEventListener('beforeunload', beforeUnload, true);
85 var related_questions_url = "{% url related_questions %}";
87 <script src="{% media "/media/js/osqa.ask.js" %}" type="text/javascript"></script>
91 <div id="main-bar" class="headNormal">
92 {% trans "Ask a question" %}
94 <div id="main-body" class="ask-body">
96 <form id="fmask" action="" method="post" accept-charset="utf-8">
97 {% if not request.user.is_authenticated %}
99 <span class="strong big">{% trans "You are welcome to start submitting your question anonymously." %}</span>
101 After submiting your question, you will be redirected to the login/signup page.
102 Your question will be saved in the current session and will be published after you login with your existing account,
103 or signup for a new account{% endblocktrans %}{% if "ask"|contained_in:settings.REQUIRE_EMAIL_VALIDATION_TO %}
104 {% trans "and validate your email." %}{% else %}.{% endif %}</p>
107 {% if not request.user.email_valid_and_can_ask %}
108 <div class="message">
109 {% blocktrans %}Remember, your question will not be published until you validate your email.{% endblocktrans %}
110 <a href="{% url send_validation_email %}">{% trans "Send me a validation link." %}</a>
114 <div class="form-item">
115 <label for="id_title" ><strong>{{ form.title.label_tag }}:</strong></label> <span class="form-error"></span><br/>
116 {{ form.title }} {{ form.title.errors }}
117 <div class="title-desc">
118 {{ form.title.help_text }}
121 <div id="ask-related-questions"></div>
122 <div class="form-item">
123 <div id="wmd-button-bar" class="wmd-panel"></div>
124 {{ form.text }} {{ form.text.errors }}
125 <div class="preview-toggle">
129 <span id="pre-collapse" title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
131 <td style="text-align: right;" id="editor-metrics"></td>
132 {% if settings.WIKI_ON %}
134 {{ form.wiki }} <span class="help_text" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag }} </span>
141 <div id="previewer" class="wmd-preview"></div>
142 <span class="form-error"></span>
144 <div class="form-item">
145 <strong>{{ form.tags.label_tag }}:</strong> {% trans "(required)" %} <span class="form-error"></span><br/>
146 {{ form.tags }} {{ form.tags.errors }}
148 <p class="title-desc">
149 {{ form.tags.help_text }}
152 {% if form.captcha %}
153 <div class="question-captcha" style="float: left">
154 {{ form.captcha.errors }}
157 <div class="clear"></div>
160 {% if not request.user.is_authenticated %}
161 <input name="ask" type="button" value="{% trans "Login/signup to post your question" %}" class="submit" onclick="submitClicked(event, this.form)"/>
163 <input name="ask" type="button" value="{% trans "Ask your question" %}" class="submit" onclick="submitClicked(event, this.form)"/>
171 {% include "question_edit_tips.html" %}
176 <!-- end template ask.html -->