Skip to content

Commit

Permalink
Add missing jsdocs (#4206)
Browse files Browse the repository at this point in the history
  • Loading branch information
frjo authored Nov 8, 2024
1 parent 8f16bd2 commit b9bd67e
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 6 deletions.
18 changes: 18 additions & 0 deletions hypha/static_src/javascript/batch-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
$batchTitlesList.toggleClass(closedClass);
});

/**
* Prepare the batch listing.
*/
function prepareBatchListing() {
$batchTitlesList.html("");
$batchTitleCount.html("");
Expand Down Expand Up @@ -125,6 +128,9 @@
$hiddenInvoiceIDlist.val(selectedIDs.join(","));
}

/**
* Update the invoice progress button.
*/
function updateInvoiceProgressButton() {
var actions = $actionInvoiceOptions
.map(function () {
Expand Down Expand Up @@ -159,6 +165,9 @@
}
}

/**
* Update the progress button.
*/
function updateProgressButton() {
var actions = $actionOptions
.map(function () {
Expand Down Expand Up @@ -192,6 +201,9 @@
}
}

/**
* Toggle the batch actions.
*/
function toggleBatchActions() {
if ($(".js-batch-select:checked").length) {
$body.addClass(activeClass);
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion hypha/static_src/javascript/behaviours/review-score.js
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
4 changes: 4 additions & 0 deletions hypha/static_src/javascript/document-category.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 4 additions & 0 deletions hypha/static_src/javascript/file-uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions hypha/static_src/javascript/past-reports-pagination.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
(function ($) {
/**
* This script is used to paginate the past reports table.
*/
function pastReportsPagination() {
$(".js-data-block-pagination").click((e) => {
e.preventDefault();
showNextTen();
});
}

/**
* Show next ten.
*/
function showNextTen() {
const [...nextTen] = $(".js-past-reports-table tr.is-hidden").slice(
0,
Expand All @@ -15,6 +21,9 @@
checkRemaining();
}

/**
* Check remaning.
*/
function checkRemaining() {
const [...remaining] = $(".js-past-reports-table tr.is-hidden");
if (remaining.length === 0) {
Expand Down
5 changes: 5 additions & 0 deletions hypha/static_src/javascript/review-form-actions.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
15 changes: 12 additions & 3 deletions hypha/static_src/javascript/submission-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand All @@ -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";
Expand All @@ -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");
Expand Down
11 changes: 9 additions & 2 deletions hypha/static_src/javascript/submission-form-copy.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
7 changes: 7 additions & 0 deletions hypha/static_src/javascript/tinymce-word-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions hypha/static_src/javascript/toggle-payment-block.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
(function ($) {
/**
* Toggle payment block
*/
function togglePaymentBlock() {
$(".js-payment-block-rejected-link").click(function (e) {
e.preventDefault();
Expand Down

0 comments on commit b9bd67e

Please sign in to comment.