# HG changeset patch # User neko259 # Date 2017-12-15 16:55:24 # Node ID 53ea27702fdbfe7c9739134fdc26485eb119677a # Parent 7718438668e3d63c52ed968ca5482ddbfa543c60 Added form reset diff --git a/boards/static/js/form.js b/boards/static/js/form.js --- a/boards/static/js/form.js +++ b/boards/static/js/form.js @@ -4,6 +4,7 @@ var MIN_INPUT_LENGTH = 3; var URL_DELIMITER = '\n'; // TODO This needs to be the same for attachment download time limit. var POST_AJAX_TIMEOUT = 30000; +var REPLY_TO_MSG = '.reply-to-message'; var pastedImages = []; @@ -198,6 +199,32 @@ function initAjaxForm(openingPostId) { } } +function getForm() { + return $('.post-form-w'); +} + +/** + * Clear all entered values in the form fields + */ +function resetForm() { + var form = getForm(); + + form.find('input:text, input:password, input:file, textarea').val(''); + form.find('input:radio, input:checkbox').removeAttr('checked').removeAttr('selected'); + pastedImages = []; + $('#pasted-images').remove(); + $('.file_wrap').find('.file-thumb').remove(); + $('#preview-text').hide(); + + resetFormPosition(form); +} + +function resetFormPosition(form) { + form.insertBefore($('footer')); + + $(REPLY_TO_MSG).hide(); +} + $(document).ready(function() { var powDifficulty = parseInt($('body').attr('data-pow-difficulty')); if (powDifficulty > 0 && typeof SharedWorker != 'undefined') { diff --git a/boards/static/js/thread.js b/boards/static/js/thread.js --- a/boards/static/js/thread.js +++ b/boards/static/js/thread.js @@ -33,31 +33,6 @@ function moveCaretToEnd(el) { el[0].setSelectionRange(newPos, newPos); } -function getForm() { - return $('.post-form-w'); -} - -/** - * Clear all entered values in the form fields - */ -function resetForm() { - var form = getForm(); - - form.find('input:text, input:password, input:file, textarea').val(''); - form.find('input:radio, input:checkbox').removeAttr('checked').removeAttr('selected'); - pastedImages = []; - $('#pasted-images').remove(); - $('.file_wrap').find('.file-thumb').remove(); - $('#preview-text').hide(); - - resetFormPosition(form); -} - -function resetFormPosition(form) { - form.insertAfter($('.thread')); - - $(REPLY_TO_MSG).hide(); -} function showFormAfter(blockToInsertAfter) { var form = getForm(); diff --git a/boards/templates/boards/form.html b/boards/templates/boards/form.html --- a/boards/templates/boards/form.html +++ b/boards/templates/boards/form.html @@ -23,6 +23,8 @@ +
{% trans 'Reset form' %}
+
{% if new_thread %} {% trans 'Tags must be delimited by spaces. Text or image is required.' %}