diff --git a/hypha/static_src/javascript/batch-actions.js b/hypha/static_src/javascript/batch-actions.js index bac984732f..e994baccd5 100644 --- a/hypha/static_src/javascript/batch-actions.js +++ b/hypha/static_src/javascript/batch-actions.js @@ -95,6 +95,9 @@ $batchTitlesList.toggleClass(closedClass); }); + /** + * Prepare the batch listing. + */ function prepareBatchListing() { $batchTitlesList.html(""); $batchTitleCount.html(""); @@ -125,6 +128,9 @@ $hiddenInvoiceIDlist.val(selectedIDs.join(",")); } + /** + * Update the invoice progress button. + */ function updateInvoiceProgressButton() { var actions = $actionInvoiceOptions .map(function () { @@ -159,6 +165,9 @@ } } + /** + * Update the progress button. + */ function updateProgressButton() { var actions = $actionOptions .map(function () { @@ -192,6 +201,9 @@ } } + /** + * Toggle the batch actions. + */ function toggleBatchActions() { if ($(".js-batch-select:checked").length) { $body.addClass(activeClass); @@ -200,10 +212,16 @@ } } + /** + * Update the count of selected checkboxes. + */ function updateCount() { $(".js-total-actions").html($(".js-batch-select:checked").length); } + /** + * Reset the check all input. + */ function resetCheckAllInput() { $allCheckboxInput.prop("checked", false); } diff --git a/hypha/static_src/javascript/behaviours/review-score.js b/hypha/static_src/javascript/behaviours/review-score.js index c51c29fb9b..7629a30042 100644 --- a/hypha/static_src/javascript/behaviours/review-score.js +++ b/hypha/static_src/javascript/behaviours/review-score.js @@ -1,6 +1,6 @@ /** * Alpine.js data component for calculating review scores in the form. - * @returns {Object} The review score component object. + * @returns {object} The review score component object. */ document.addEventListener("alpine:init", () => { Alpine.data("reviewScore", () => { diff --git a/hypha/static_src/javascript/document-category.js b/hypha/static_src/javascript/document-category.js index 5f951f01eb..4694de467f 100644 --- a/hypha/static_src/javascript/document-category.js +++ b/hypha/static_src/javascript/document-category.js @@ -1,3 +1,7 @@ +/** + * Handle the category selection. + * @param {object} category - The category selected. + */ // eslint-disable-next-line no-unused-vars function handleCategory(category) { document.getElementById("id_category").value = category; diff --git a/hypha/static_src/javascript/file-uploads.js b/hypha/static_src/javascript/file-uploads.js index 3fad4d4e8b..407598445a 100644 --- a/hypha/static_src/javascript/file-uploads.js +++ b/hypha/static_src/javascript/file-uploads.js @@ -14,6 +14,10 @@ jQuery(function ($) { } }); + /** + * Initialize django-file-form for a form. + * @param {object} form The form to initialize. + */ function init(form) { if ($(".form__group--file").length) { window.initUploadFields(form); diff --git a/hypha/static_src/javascript/past-reports-pagination.js b/hypha/static_src/javascript/past-reports-pagination.js index 33a32f1c05..9df1a32bcc 100644 --- a/hypha/static_src/javascript/past-reports-pagination.js +++ b/hypha/static_src/javascript/past-reports-pagination.js @@ -1,4 +1,7 @@ (function ($) { + /** + * This script is used to paginate the past reports table. + */ function pastReportsPagination() { $(".js-data-block-pagination").click((e) => { e.preventDefault(); @@ -6,6 +9,9 @@ }); } + /** + * Show next ten. + */ function showNextTen() { const [...nextTen] = $(".js-past-reports-table tr.is-hidden").slice( 0, @@ -15,6 +21,9 @@ checkRemaining(); } + /** + * Check remaning. + */ function checkRemaining() { const [...remaining] = $(".js-past-reports-table tr.is-hidden"); if (remaining.length === 0) { diff --git a/hypha/static_src/javascript/review-form-actions.js b/hypha/static_src/javascript/review-form-actions.js index 4779bbf2a4..f8b4fda8cb 100644 --- a/hypha/static_src/javascript/review-form-actions.js +++ b/hypha/static_src/javascript/review-form-actions.js @@ -1,4 +1,9 @@ (function () { + /** + * Show dialog if user have changed the form and not saved. + * @param {object} f - form element + * @returns {object} - form contents + */ function formContents(f) { // Thanks to https://stackoverflow.com/a/44033425 return Array.from(new FormData(f), function (e) { diff --git a/hypha/static_src/javascript/submission-filters.js b/hypha/static_src/javascript/submission-filters.js index bb015a8c35..8509579d8c 100644 --- a/hypha/static_src/javascript/submission-filters.js +++ b/hypha/static_src/javascript/submission-filters.js @@ -75,7 +75,9 @@ e.target.closest(".filters").classList.remove(filterOpenClass); }); - // redirect to submissions home to clear filters + /** + * Redirect to submissions home to clear filters. + */ function handleClearFilters() { const query = persistedParams.reduce( (query, param) => @@ -88,7 +90,11 @@ window.location.href = window.location.href.split("?")[0] + query; } - // toggle filters button wording + /** + * Toggle filters button wording. + * @param {object} button - button element + * @param {string} filters - filters element + */ function updateButtonText(button, filters) { if (filters.classList.contains(filterOpenClass)) { button.textContent = "Clear filters"; @@ -97,7 +103,10 @@ } } - // corrects spacing of dropdowns when toggled on mobile + /** + * Corrects spacing of dropdowns when toggled on mobile. + * @param {object} element - element to adjust padding for + */ function mobileFilterPadding(element) { const expanded = "expanded-filter-element"; const dropdown = $(element).closest(".select2"); diff --git a/hypha/static_src/javascript/submission-form-copy.js b/hypha/static_src/javascript/submission-form-copy.js index d2b4db8a05..6a24b8ee43 100644 --- a/hypha/static_src/javascript/submission-form-copy.js +++ b/hypha/static_src/javascript/submission-form-copy.js @@ -1,11 +1,18 @@ (function ($) { - // Strip html tags from text. + /** + * Strip html tags from text. + * @param {string} html - The html + * @returns {string} The text without html tags. + */ function strip(html) { var doc = new DOMParser().parseFromString(html, "text/html"); return doc.body.textContent.trim() || ""; } - // Get all questions on the page/form. + /** + * Get all questions on the page/form. + * @returns {string} The questions and user input. + */ function get_questions() { var questions_text = []; var i = 1; diff --git a/hypha/static_src/javascript/tinymce-word-count.js b/hypha/static_src/javascript/tinymce-word-count.js index dc9d8f006b..7f6b33765e 100644 --- a/hypha/static_src/javascript/tinymce-word-count.js +++ b/hypha/static_src/javascript/tinymce-word-count.js @@ -5,6 +5,10 @@ childList: true, }; + /** + * Count the words in the element and set the warning classes. + * @param {object} el - The element to count the words in. + */ function word_count(el) { let word_count; try { @@ -49,6 +53,9 @@ }); }); + /** + * Set the word count on the element and observe for changes. + */ function word_count_alert() { const word_counts = document.querySelectorAll( ".tox-statusbar__wordcount" diff --git a/hypha/static_src/javascript/toggle-payment-block.js b/hypha/static_src/javascript/toggle-payment-block.js index 9b1825ca76..feb4b07a81 100644 --- a/hypha/static_src/javascript/toggle-payment-block.js +++ b/hypha/static_src/javascript/toggle-payment-block.js @@ -1,4 +1,7 @@ (function ($) { + /** + * Toggle payment block + */ function togglePaymentBlock() { $(".js-payment-block-rejected-link").click(function (e) { e.preventDefault();