return false;\r
});\r
\r
- $cancel.click(function() {\r
- if (comment_in_form) {\r
- $comment = $('#comment-' + comment_in_form).slideDown('slow');\r
+ $cancel.click(function(event) {\r
+ if (confirm("You will lose all of your changes in this comment. Do you still wish to proceed?")){\r
+ if (comment_in_form) {\r
+ $comment = $('#comment-' + comment_in_form).slideDown('slow');\r
+ }\r
+ hide_comment_form();\r
+ cleanup_form();\r
}\r
- hide_comment_form();\r
return false;\r
});\r
}\r
});\r
});\r
\r
+function yourWorkWillBeLost(e) {\r
+ if(!e) e = window.event;\r
+ e.cancelBubble = true;\r
+ e.returnValue = 'You sure you want to leave? Your work will be lost.';\r
+\r
+ if (e.stopPropagation) {\r
+ e.stopPropagation();\r
+ e.preventDefault();\r
+ }\r
+ return e;\r
+}
\ No newline at end of file
$('#id_revision').unbind().change(function(){
$("#select_revision").click();
});
-
-
});
+
+ function beforeUnload(e) {
+ if($("textarea#editor")[0].value != "") {
+ yourWorkWillBeLost(e);
+ }
+
+ return false;
+ }
+ window.addEventListener('beforeunload', beforeUnload, true);
</script>
{% endblock %}
<div class="title-desc">
{{ form.summary.help_text }}
</div>
- <input type="submit" value="{% trans "Save edit" %}" class="submit" />
+ <input type="submit" value="{% trans "Save edit" %}" class="submit" onclick="window.removeEventListener('beforeunload', beforeUnload, true)" />
<input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);" />
</form>
</div>
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 beforeUnload(e) {
+ if($("input#id_title")[0].value != "" || $("textarea#editor")[0].value != "" || $("input#id_tags")[0].value != "") {
+ yourWorkWillBeLost(e);
+ }
+ return false;
+ }
+ window.addEventListener('beforeunload', beforeUnload, true);
+
var related_questions_url = "{% url related_questions %}";
</script>
<script src="{% media "/media/js/osqa.ask.js" %}" type="text/javascript"></script>
{% if not request.user.is_authenticated %}
<input name="ask" type="submit" value="{% trans "Login/signup to post your question" %}" class="submit" />
{% 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="window.removeEventListener('beforeunload', beforeUnload, true)" />
{% endif %}
</form>
</div>
{% if can_comment %}\r
<form id="comment-{{ post.id }}-form" method="post" action="{% url comment id=post.id %}" accept-charset="utf-8">\r
<div class="comment-form-widgets-container">\r
- <textarea name="comment"></textarea>\r
+ <textarea name="comment" class="commentBox"></textarea>\r
<div class="comment-form-buttons">\r
<span id="comment-{{ post.id }}-chars-left" class="comment-chars-left">\r
<span class="comments-char-left-count">{{ min_length }}|{{ max_length }}</span>\r
<span class="comments-chars-togo-msg">{% trans "characters needed" %}</span>\r
<span class="comments-chars-left-msg">{% trans "characters left" %}</span>\r
</span>\r
- <input type="submit" class="comment-submit" value="{% trans " comment" %}" />\r
+ <input type="submit" class="comment-submit" value="{% trans " comment" %}" onclick="window.removeEventListener('beforeunload', beforeUnload, true)" />\r
<input type="submit" class="comment-cancel" value="{% trans " cancel" %}" />\r
</div>\r
</div>\r
}\r
\r
$('#editor').TextAreaResizer();\r
- \r
+\r
//toggle preview of editor\r
var display = true;\r
var txt = "[{% trans "hide preview" %}]";\r
$('#previewer').toggle();\r
$('#pre-collapse').text(txt);\r
});\r
+\r
});\r
+\r
+ function beforeUnload(e) {\r
+ if($("textarea#editor")[0].value != "") {\r
+ yourWorkWillBeLost(e);\r
+ }\r
+\r
+ $("textarea.commentBox").each(function() {\r
+ if(this.value != "") {\r
+ yourWorkWillBeLost(e);\r
+ }\r
+ });\r
+\r
+ return false;\r
+ }\r
+ window.addEventListener('beforeunload', beforeUnload, true);\r
+\r
</script>\r
<noscript>\r
<style>\r
value="{% trans "Answer the question" %}" \r
{% endif %}\r
{% endif %}\r
- class="submit" style="float:left"/>\r
+ class="submit" style="float:left" onclick="window.removeEventListener('beforeunload', beforeUnload, true)" />\r
{% endif %}\r
</form>\r
</div>\r
$("#select_revision").click();
});
+ init = $("textarea#editor")[0].value;
});
+
+ function beforeUnload(e) {
+ if($("input#id_title")[0].value != "" || $("textarea#editor")[0].value != "" || $("input#id_tags")[0].value != "") {
+ yourWorkWillBeLost(e);
+ }
+ return false;
+ }
+ window.addEventListener('beforeunload', beforeUnload, true);
+
+ var init = "";
</script>
{% endblock %}
{{ form.summary.help_text }}
</div>
<div class="error" ></div>
- <input type="submit" value="{% trans "Save edit" %}" class="submit" />
- <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);" />
+ <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="window.removeEventListener('beforeunload', beforeUnload, true)" />
+
</form>
</div>
</div>