From 6b3c2479638365cdf3814c3903bc81e27758d71e Mon Sep 17 00:00:00 2001 From: Andrew Shu Date: Wed, 17 Sep 2025 03:32:26 -0700 Subject: [PATCH] Run prettier on JS files $ node node_modules/.bin/prettier static/js/ --write --- tildes/static/js/behaviors/auto-focus.js | 7 ++-- .../js/behaviors/autocomplete-chip-clear.js | 10 +++--- .../static/js/behaviors/autocomplete-input.js | 33 ++++++++----------- .../js/behaviors/autocomplete-menu-item.js | 20 ++++------- .../static/js/behaviors/autocomplete-menu.js | 4 +-- .../static/js/behaviors/autoselect-input.js | 4 +-- .../js/behaviors/autosubmit-on-change.js | 8 ++--- tildes/static/js/behaviors/cancel-button.js | 16 ++++----- .../behaviors/comment-collapse-all-button.js | 25 +++++++------- .../js/behaviors/comment-collapse-button.js | 4 +-- .../behaviors/comment-collapse-read-button.js | 20 +++++------ .../js/behaviors/comment-expand-all-button.js | 19 +++++------ .../js/behaviors/comment-label-button.js | 27 +++++++-------- .../js/behaviors/comment-parent-button.js | 10 +++--- .../static/js/behaviors/comment-reply-form.js | 4 +-- .../behaviors/confirm-leave-page-unsaved.js | 4 +-- tildes/static/js/behaviors/copy-button.js | 8 ++--- .../js/behaviors/ctrl-enter-submit-form.js | 8 ++--- tildes/static/js/behaviors/dropdown-toggle.js | 10 +++--- .../js/behaviors/external-links-new-tabs.js | 4 +-- .../js/behaviors/fadeout-parent-on-success.js | 8 ++--- .../js/behaviors/group-links-new-tabs.js | 4 +-- .../js/behaviors/hide-sidebar-if-open.js | 4 +-- .../hide-sidebar-no-preventdefault.js | 4 +-- .../static/js/behaviors/markdown-edit-tab.js | 12 +++---- .../js/behaviors/markdown-preview-tab.js | 14 +++----- .../js/behaviors/prevent-double-submit.js | 6 ++-- tildes/static/js/behaviors/remove-on-click.js | 4 +-- .../static/js/behaviors/remove-on-success.js | 4 +-- tildes/static/js/behaviors/sidebar-toggle.js | 4 +-- tildes/static/js/behaviors/stripe-checkout.js | 4 +-- .../static/js/behaviors/stripe-donate-form.js | 4 +-- tildes/static/js/behaviors/tab.js | 8 ++--- tildes/static/js/behaviors/theme-preview.js | 4 +-- tildes/static/js/behaviors/theme-selector.js | 15 +++------ .../static/js/behaviors/time-period-select.js | 6 ++-- .../js/behaviors/user-links-new-tabs.js | 4 +-- tildes/static/js/scripts.js | 10 +++--- 38 files changed, 159 insertions(+), 205 deletions(-) diff --git a/tildes/static/js/behaviors/auto-focus.js b/tildes/static/js/behaviors/auto-focus.js index 17c408e..6e7697a 100644 --- a/tildes/static/js/behaviors/auto-focus.js +++ b/tildes/static/js/behaviors/auto-focus.js @@ -1,14 +1,11 @@ // Copyright (c) 2018 Tildes contributors // SPDX-License-Identifier: AGPL-3.0-or-later -$.onmount("[data-js-auto-focus]", function() { +$.onmount("[data-js-auto-focus]", function () { var $input = $(this); // just calling .focus() will place the cursor at the start of the field, // so un-setting and re-setting the value moves the cursor to the end var original_val = $input.val(); - $input - .focus() - .val("") - .val(original_val); + $input.focus().val("").val(original_val); }); diff --git a/tildes/static/js/behaviors/autocomplete-chip-clear.js b/tildes/static/js/behaviors/autocomplete-chip-clear.js index 5e422bb..bbf85ab 100644 --- a/tildes/static/js/behaviors/autocomplete-chip-clear.js +++ b/tildes/static/js/behaviors/autocomplete-chip-clear.js @@ -1,7 +1,7 @@ // Copyright (c) 2019 Tildes contributors // SPDX-License-Identifier: AGPL-3.0-or-later -$.onmount("[data-js-autocomplete-chip-clear]", function() { +$.onmount("[data-js-autocomplete-chip-clear]", function () { function clearChip($chip) { var $tagsHiddenInput = $("[data-js-autocomplete-hidden-input]"); var $autocompleteInput = $("[data-js-autocomplete-input]"); @@ -11,22 +11,22 @@ $.onmount("[data-js-autocomplete-chip-clear]", function() { $tagsHiddenInput.val( tags - .filter(function(tag) { + .filter(function (tag) { return tag !== tagToRemove; }) - .join(",") + .join(","), ); $chip.remove(); $autocompleteInput.focus(); } - $(this).click(function(event) { + $(this).click(function (event) { event.preventDefault(); clearChip($(this).parent()); }); - $(this).keydown(function(event) { + $(this).keydown(function (event) { switch (event.key) { case "Backspace": event.preventDefault(); diff --git a/tildes/static/js/behaviors/autocomplete-input.js b/tildes/static/js/behaviors/autocomplete-input.js index fb68f6d..cc97edb 100644 --- a/tildes/static/js/behaviors/autocomplete-input.js +++ b/tildes/static/js/behaviors/autocomplete-input.js @@ -1,7 +1,7 @@ // Copyright (c) 2019 Tildes contributors // SPDX-License-Identifier: AGPL-3.0-or-later -$.onmount("[data-js-autocomplete-input]", function() { +$.onmount("[data-js-autocomplete-input]", function () { function addChip($input, userTypedComma) { var $autocompleteContainer = $input .parents("[data-js-autocomplete-container]") @@ -15,10 +15,10 @@ $.onmount("[data-js-autocomplete-input]", function() { var inputTags = $input .val() .split(",") - .map(function(tag) { + .map(function (tag) { return tag.trim(); }) - .filter(function(tag) { + .filter(function (tag) { return tag !== ""; }); @@ -28,7 +28,7 @@ $.onmount("[data-js-autocomplete-input]", function() { inputTags = inputTags.slice(0, 1); } - inputTags.forEach(function(tag) { + inputTags.forEach(function (tag) { if (!$tagsHiddenInput.val().match(new RegExp("(^|,)" + tag + ","))) { var clearIcon = document.createElement("a"); clearIcon.classList.add("btn"); @@ -47,7 +47,7 @@ $.onmount("[data-js-autocomplete-input]", function() { $chip.addClass("error"); $chip.attr( "title", - "Tags may only contain letters, numbers, and spaces." + "Tags may only contain letters, numbers, and spaces.", ); } @@ -74,7 +74,7 @@ $.onmount("[data-js-autocomplete-input]", function() { $(this) .closest("form") /* eslint-disable-next-line no-unused-vars */ - .on("beforeSend.ic", function(evt, elt, data, settings, xhr, requestId) { + .on("beforeSend.ic", function (evt, elt, data, settings, xhr, requestId) { var $autocompleteInput = $(elt) .find("[data-js-autocomplete-input]") .first(); @@ -98,7 +98,7 @@ $.onmount("[data-js-autocomplete-input]", function() { addChip($(this)); } - $(this).focus(function() { + $(this).focus(function () { var $autocompleteContainer = $(this) .parents("[data-js-autocomplete-container]") .first(); @@ -109,7 +109,7 @@ $.onmount("[data-js-autocomplete-input]", function() { $chips.children().removeClass("active"); }); - $(this).keydown(function(event) { + $(this).keydown(function (event) { var $this = $(this); var $autocompleteMenu = $("[data-js-autocomplete-menu]").first(); var $nextActiveItem = null; @@ -121,7 +121,7 @@ $.onmount("[data-js-autocomplete-input]", function() { break; case ",": // wait for comma to be added to text so addChip() sees it - setTimeout(function() { + setTimeout(function () { addChip($this, true); }, 100); break; @@ -171,7 +171,7 @@ $.onmount("[data-js-autocomplete-input]", function() { } }); - $(this).keyup(function() { + $(this).keyup(function () { var $this = $(this); var $autocompleteMenu = $("[data-js-autocomplete-menu]"); if ($autocompleteMenu) { @@ -183,14 +183,9 @@ $.onmount("[data-js-autocomplete-input]", function() { var $tagsHiddenInput = $("[data-js-autocomplete-hidden-input]"); var suggestions = $this .data("js-autocomplete-input") - .filter(function(suggestion) { + .filter(function (suggestion) { return ( - suggestion.startsWith( - $this - .val() - .toLowerCase() - .trim() - ) && + suggestion.startsWith($this.val().toLowerCase().trim()) && !$tagsHiddenInput .val() .match(new RegExp("(^|,)" + suggestion + ",")) @@ -202,7 +197,7 @@ $.onmount("[data-js-autocomplete-input]", function() { var $autocompleteSuggestions = $("[data-js-autocomplete-suggestions]"); $autocompleteMenu = $('