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
+ e.returnValue = 'If you leave your work will be lost.';\r
\r
if (e.stopPropagation) {\r
e.stopPropagation();\r
position: absolute;
background-color:#aaaaaa;
- /*border-color:#aaaaaa;
- border-style:solid;*/
display: inline-block;
list-style: none;
}
color: #FFFFFF;
}
+div.wmd-button {
+ color:white;
+}
+div.wmd-button-bar {
+ float:left;
+}
\ No newline at end of file
$().ready(function(){
$("#nav_questions").attr('className',"on");
$('#editor').TextAreaResizer();
-
+
+
//toggle preview of editor
var display = true;
var txt = "{% trans "hide preview" %}";
$('#pre-collapse').text(txt);
});
-
+
$('#id_revision').unbind().change(function(){
$("#select_revision").click();
});
+
+
+ answer = $("textarea#editor")[0].value;
});
- function beforeUnload(e) {
- if($("textarea#editor")[0].value != "") {
- yourWorkWillBeLost(e);
+
+ function submitClicked(e) {
+ if(!is_chrome) {
+ $("input.submit")[0].disabled=true;
+ $("input.submit")[1].disabled=true;
}
+ window.removeEventListener('beforeunload', beforeUnload, true);
+ }
- return false;
+ function beforeUnload(e) {
+ var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
+ if($("textarea#editor")[0].value != answer) {
+ 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 answer = "";
+ var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
</script>
{% endblock %}
<div class="title-desc">
{{ form.summary.help_text }}
</div>
- <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);" />
+ <input type="submit" value="{% trans "Save edit" %}" class="submit" onclick="submitClicked(event)" />
+ <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);submitClicked(event)" />
</form>
</div>
</div>
}
});
+
});
+ 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 != "") {
- yourWorkWillBeLost(e);
+ 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);
- function submitClicked() {
- window.removeEventListener('beforeunload', beforeUnload, true);
- $("input.submit").each(function() {
- this.disabled=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>
<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" onclick="submitClicked()" />
+ <input name="ask" type="submit" value="{% trans "Ask your question" %}" class="submit" onclick="submitClicked(event)"/>
{% endif %}
</form>
</div>
$('#previewer').toggle();\r
$('#pre-collapse').text(txt);\r
});\r
-\r
});\r
\r
+ function submitClicked(e) {\r
+ if(!is_chrome)$("input.submit")[0].disabled=true;\r
+ window.removeEventListener('beforeunload', beforeUnload, true);\r
+ }\r
+\r
function beforeUnload(e) {\r
+ var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;\r
+\r
if($("textarea#editor")[0].value != "") {\r
- yourWorkWillBeLost(e);\r
+ if(is_chrome) {\r
+ return "You sure you want to leave? Your work will be lost.";\r
+ } else {\r
+ yourWorkWillBeLost(e);\r
+ }\r
+ return false;\r
}\r
\r
- $("textarea.commentBox").each(function() {\r
- if(this.value != "") {\r
- yourWorkWillBeLost(e);\r
- }\r
- });\r
-\r
- return false;\r
+ var commentBoxes = $("textarea.commentBox");\r
+ for(var index = 0; index < commentBoxes.length; index++) {\r
+ if(commentBoxes[index].value != "") {\r
+ if(is_chrome) {\r
+ return "You sure you want to leave? Your work will be lost.";\r
+ } else {\r
+ yourWorkWillBeLost(e);\r
+ }\r
+ return false;\r
+ }\r
+ }\r
}\r
window.addEventListener('beforeunload', beforeUnload, true);\r
\r
- function submitClicked() {\r
- window.removeEventListener('beforeunload', beforeUnload, true);\r
- $("input.submit").each(function() {\r
- this.disabled=true;\r
- });\r
- }\r
-\r
- </script>\r
+ var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;\r
+ </script>\r
<noscript>\r
<style>\r
.comment.not_top_scorer {\r
value="{% trans "Answer the question" %}" \r
{% endif %}\r
{% endif %}\r
- class="submit" style="float:left" onclick="submitClicked()" />\r
+ class="submit" style="float:left" onclick="submitClicked(event)"/>\r
{% endif %}\r
</form>\r
</div>\r
});
init = $("textarea#editor")[0].value;
+
+ title = $("input#id_title")[0].value;
+ body = $("textarea#editor")[0].value;
+ tag = $("input#id_tags")[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);
+ function submitClicked(e) {
+ if(!is_chrome) {
+ $("input.submit")[0].disabled=true;
+ $("input.submit")[1].disabled=true;
+ }
+ window.removeEventListener('beforeunload', beforeUnload, true);
+ }
+
+ function beforeUnload(e) {
+ var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
+
+ if($("input#id_title")[0].value != title || $("textarea#editor")[0].value != body || $("input#id_tags")[0].value != tag) {
+ 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 init = "";
+ var title = "";
+ var body = "";
+ var tag = "";
+ var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
</script>
{% endblock %}
{{ form.summary.help_text }}
</div>
<div class="error" ></div>
- <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="window.removeEventListener('beforeunload', beforeUnload, true)" />
-
+ <input type="submit" value="{% trans "Save edit" %}" class="submit" onclick="submitClicked(event)" />
+ <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);submitClicked(event)" />
</form>
</div>
</div>