]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/skins/default/templates/ask.html
hopefully this will clear up all issues concerning the adding/editing of answers...
[osqa.git] / forum / skins / default / templates / ask.html
index 2f2b92e1463cf16dd56a835a3bdb6047d141cf64..c65bf9f676f37bc1136452e4b40b04b4d3d61638 100644 (file)
@@ -1,7 +1,6 @@
 {% extends "base.html" %}
 <!-- template ask.html -->
-{% load i18n %}
-{% load extra_tags %}
+{% load i18n extra_tags extra_filters %}
 {% block title %}{% spaceless %}{% trans "Ask a question" %}{% endspaceless %}{% endblock %}
 {% block forejs %}
         <script type='text/javascript' src='{% media  "/media/js/wmd/showdown.js" %}'></script>
                 max: 20,
                 multiple: true,
                 multipleSeparator: " ",
-                       /*formatItem: function(row, i, max) {
+
+                       /*
+                       formatItem: function(row, i, max) {
                                return row.n + " ("+ row.c +")";
                        },
                 formatResult: function(row, i, max){
                     return row.n;
-                }*/
+                }
+                */
+
                 formatItem: function(row, i, max, value) {
                     return row[1].split(".")[0] + " (" + row[1].split(".")[1] + ")";
                 },
                 }
 
             });
+
         });
 
+        function submitClicked(e) {
+            if(!is_chrome)$("input.submit")[0].disabled=true;
+            window.removeEventListener('beforeunload', beforeUnload, true);
+        }
+
+        function beforeUnload(e) {
+            if($("input#id_title")[0].value != "" || $("textarea#editor")[0].value != "" || $("input#id_tags")[0].value != "") {
+                if(is_chrome) {
+                    return "You sure you want to leave?  Your work will be lost.";
+                } else {
+                    yourWorkWillBeLost(e);
+                }
+            }
+            return false;
+        }
+        window.addEventListener('beforeunload', beforeUnload, true);
+
+        var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
         var related_questions_url = "{% url related_questions %}";
         </script>
         <script src="{% media "/media/js/osqa.ask.js" %}" type="text/javascript"></script>
@@ -75,7 +97,7 @@
                 <p>{% blocktrans %}
                     After submiting your question, you will be redirected to the login/signup page.
                     Your question will be saved in the current session and will be published after you login with your existing account,
-                    or signup for a new account{% endblocktrans %}{% if "ask" in settings.REQUIRE_EMAIL_VALIDATION_TO %}
+                    or signup for a new account{% endblocktrans %}{% if "ask"|contained_in:settings.REQUIRE_EMAIL_VALIDATION_TO %}
                     {% trans "and validate your email." %}{% else %}.{% endif %}</p>
             </div>
             {% else %}
                        <p class="title-desc">
                                {{ form.tags.help_text }}
                        </p>
-            {% if not request.user.is_authenticated %}
-            <input name="ask" type="submit" value="{% trans "Login/signup to post your question" %}" class="submit" />
+            {% if not request.user.is_authenticated %}                                                                        
+            <input name="ask" type="submit" value="{% trans "Login/signup to post your question" %}" class="submit" onclick="submitClicked(event)"/>
                        {% else %}
-            <input name="ask" type="submit" value="{% trans "Ask your question" %}" class="submit" />
+            <input name="ask" type="submit" value="{% trans "Ask your question" %}" class="submit" onclick="submitClicked(event)"/>
             {% endif %}
         </form>
     </div>