diff options
author | 2019-04-19 14:12:28 +0100 | |
---|---|---|
committer | 2019-04-19 14:12:28 +0100 | |
commit | e0f837ddd8ff434b1ef3429f6a709263350194ce (patch) | |
tree | 6f752fa2cb602d63dec09bb3f2d22ecce39d3d7c /pydis_site/templates/wiki/edit.html | |
parent | Initial template cleanup (diff) |
Move JS into files
Diffstat (limited to 'pydis_site/templates/wiki/edit.html')
-rw-r--r-- | pydis_site/templates/wiki/edit.html | 72 |
1 files changed, 1 insertions, 71 deletions
diff --git a/pydis_site/templates/wiki/edit.html b/pydis_site/templates/wiki/edit.html index c0cb8de6..8472d555 100644 --- a/pydis_site/templates/wiki/edit.html +++ b/pydis_site/templates/wiki/edit.html @@ -99,75 +99,5 @@ </div> <script src="{% static "js/wiki/modal.js" %}" type="text/javascript"></script> - - <script type="text/javascript"> - {# I'm sorry this JS sucks, it came with the wiki, just stuck right in here. #} - - $(document).ready(function() { - let article_edit_form = $("#article_edit_form"); - let click_time = 0; - - $("#article_edit_form :input").change(function() { - article_edit_form.data("changed",true); - }); - - if (article_edit_form.find(".alert-danger").length > 0 || article_edit_form.find(".has-error").length > 0 ) { - // Set the forms status as "changed" if there was a submission error - article_edit_form.data("changed",true); - } - - window.onbeforeunload = confirmOnPageExit; - - article_edit_form.on("submit", function (ev) { - now = Date.now(); - elapsed = now-click_time; - click_time = now; - if (elapsed < 3000) - ev.preventDefault(); - window.onbeforeunload = null; - return true; - }); - $("#id_preview").click(function () { - open_modal("previewModal"); - return true; - }); - $("#id_preview_save_changes").on("click", function (ev) { - ev.preventDefault(); - $("#id_save").trigger("click"); - }); - }); - - var confirmOnPageExit = function (e) { - if ($("#article_edit_form").data("changed")) { - e = e || window.event; - var message = "You have unsaved changes!"; - // For IE6-8 and Firefox prior to version 4 - if (e) { - e.returnValue = message; - } - // For Chrome, Safari, IE8+ and Opera 12+ - return message; - } else { - // If the form hasn't been changed, don't display the pop-up - return; - } - }; - </script> - - <script type="text/javascript"> - $(document).ready( function() { - $('.sidebar-form').each(function () { - $(this).submit( function() { - this.unsaved_article_title.value = $('#id_title').val(); - this.unsaved_article_content.value = $('#id_content').val(); - }); - }); - }); - </script> - - <script language="javascript"> - $(document).ready(function() { - $("#id_revision").val('{{ article.current_revision.id }}'); - }); - </script> + <script src="{% static "js/wiki/edit.js" %}" type="text/javascript"></script> {% endblock %} |