Runs prettier

This commit is contained in:
Mouse Reeve 2021-12-16 10:53:38 -08:00
parent 34a16667d8
commit 2b6c9d9d31
5 changed files with 199 additions and 213 deletions

View file

@ -1,9 +1,10 @@
/* exported BlockHref */ /* exported BlockHref */
let BlockHref = new class { let BlockHref = new (class {
constructor() { constructor() {
document.querySelectorAll('[data-href]') document
.forEach(t => t.addEventListener('click', this.followLink.bind(this))); .querySelectorAll("[data-href]")
.forEach((t) => t.addEventListener("click", this.followLink.bind(this)));
} }
/** /**
@ -17,5 +18,4 @@ let BlockHref = new class {
window.location.href = url; window.location.href = url;
} }
}(); })();

View file

@ -1,7 +1,7 @@
/* exported BookWyrm */ /* exported BookWyrm */
/* globals TabGroup */ /* globals TabGroup */
let BookWyrm = new class { let BookWyrm = new (class {
constructor() { constructor() {
this.MAX_FILE_SIZE_BYTES = 10 * 1000000; this.MAX_FILE_SIZE_BYTES = 10 * 1000000;
this.initOnDOMLoaded(); this.initOnDOMLoaded();
@ -10,48 +10,33 @@ let BookWyrm = new class {
} }
initEventListeners() { initEventListeners() {
document.querySelectorAll('[data-controls]') document
.forEach(button => button.addEventListener( .querySelectorAll("[data-controls]")
'click', .forEach((button) => button.addEventListener("click", this.toggleAction.bind(this)));
this.toggleAction.bind(this))
);
document.querySelectorAll('.interaction') document
.forEach(button => button.addEventListener( .querySelectorAll(".interaction")
'submit', .forEach((button) => button.addEventListener("submit", this.interact.bind(this)));
this.interact.bind(this))
);
document.querySelectorAll('.hidden-form input') document
.forEach(button => button.addEventListener( .querySelectorAll(".hidden-form input")
'change', .forEach((button) => button.addEventListener("change", this.revealForm.bind(this)));
this.revealForm.bind(this))
);
document.querySelectorAll('[data-hides]') document
.forEach(button => button.addEventListener( .querySelectorAll("[data-hides]")
'change', .forEach((button) => button.addEventListener("change", this.hideForm.bind(this)));
this.hideForm.bind(this))
);
document.querySelectorAll('[data-back]') document
.forEach(button => button.addEventListener( .querySelectorAll("[data-back]")
'click', .forEach((button) => button.addEventListener("click", this.back));
this.back)
);
document.querySelectorAll('input[type="file"]') document
.forEach(node => node.addEventListener( .querySelectorAll('input[type="file"]')
'change', .forEach((node) => node.addEventListener("change", this.disableIfTooLarge.bind(this)));
this.disableIfTooLarge.bind(this)
)); document
.querySelectorAll("[data-duplicate]")
document.querySelectorAll('[data-duplicate]') .forEach((node) => node.addEventListener("click", this.duplicateInput.bind(this)));
.forEach(node => node.addEventListener(
'click',
this.duplicateInput.bind(this)
))
} }
/** /**
@ -60,15 +45,12 @@ let BookWyrm = new class {
initOnDOMLoaded() { initOnDOMLoaded() {
const bookwyrm = this; const bookwyrm = this;
window.addEventListener('DOMContentLoaded', function() { window.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll('.tab-group') document.querySelectorAll(".tab-group").forEach((tabs) => new TabGroup(tabs));
.forEach(tabs => new TabGroup(tabs)); document
document.querySelectorAll('input[type="file"]').forEach( .querySelectorAll('input[type="file"]')
bookwyrm.disableIfTooLarge.bind(bookwyrm) .forEach(bookwyrm.disableIfTooLarge.bind(bookwyrm));
); document.querySelectorAll("[data-copytext]").forEach(bookwyrm.copyText.bind(bookwyrm));
document.querySelectorAll('[data-copytext]').forEach(
bookwyrm.copyText.bind(bookwyrm)
);
}); });
} }
@ -77,8 +59,7 @@ let BookWyrm = new class {
*/ */
initReccuringTasks() { initReccuringTasks() {
// Polling // Polling
document.querySelectorAll('[data-poll]') document.querySelectorAll("[data-poll]").forEach((liveArea) => this.polling(liveArea));
.forEach(liveArea => this.polling(liveArea));
} }
/** /**
@ -104,15 +85,19 @@ let BookWyrm = new class {
const bookwyrm = this; const bookwyrm = this;
delay = delay || 10000; delay = delay || 10000;
delay += (Math.random() * 1000); delay += Math.random() * 1000;
setTimeout(function() { setTimeout(
fetch('/api/updates/' + counter.dataset.poll) function () {
.then(response => response.json()) fetch("/api/updates/" + counter.dataset.poll)
.then(data => bookwyrm.updateCountElement(counter, data)); .then((response) => response.json())
.then((data) => bookwyrm.updateCountElement(counter, data));
bookwyrm.polling(counter, delay * 1.25); bookwyrm.polling(counter, delay * 1.25);
}, delay, counter); },
delay,
counter
);
} }
/** /**
@ -127,60 +112,56 @@ let BookWyrm = new class {
const count_by_type = data.count_by_type; const count_by_type = data.count_by_type;
const currentCount = counter.innerText; const currentCount = counter.innerText;
const hasMentions = data.has_mentions; const hasMentions = data.has_mentions;
const allowedStatusTypesEl = document.getElementById('unread-notifications-wrapper'); const allowedStatusTypesEl = document.getElementById("unread-notifications-wrapper");
// If we're on the right counter element // If we're on the right counter element
if (counter.closest('[data-poll-wrapper]').contains(allowedStatusTypesEl)) { if (counter.closest("[data-poll-wrapper]").contains(allowedStatusTypesEl)) {
const allowedStatusTypes = JSON.parse(allowedStatusTypesEl.textContent); const allowedStatusTypes = JSON.parse(allowedStatusTypesEl.textContent);
// For keys in common between allowedStatusTypes and count_by_type // For keys in common between allowedStatusTypes and count_by_type
// This concerns 'review', 'quotation', 'comment' // This concerns 'review', 'quotation', 'comment'
count = allowedStatusTypes.reduce(function(prev, currentKey) { count = allowedStatusTypes.reduce(function (prev, currentKey) {
const currentValue = count_by_type[currentKey] | 0; const currentValue = count_by_type[currentKey] | 0;
return prev + currentValue; return prev + currentValue;
}, 0); }, 0);
// Add all the "other" in count_by_type if 'everything' is allowed // Add all the "other" in count_by_type if 'everything' is allowed
if (allowedStatusTypes.includes('everything')) { if (allowedStatusTypes.includes("everything")) {
// Clone count_by_type with 0 for reviews/quotations/comments // Clone count_by_type with 0 for reviews/quotations/comments
const count_by_everything_else = Object.assign( const count_by_everything_else = Object.assign({}, count_by_type, {
{}, review: 0,
count_by_type, quotation: 0,
{review: 0, quotation: 0, comment: 0} comment: 0,
); });
count = Object.keys(count_by_everything_else).reduce( count = Object.keys(count_by_everything_else).reduce(function (prev, currentKey) {
function(prev, currentKey) { const currentValue = count_by_everything_else[currentKey] | 0;
const currentValue =
count_by_everything_else[currentKey] | 0
return prev + currentValue; return prev + currentValue;
}, }, count);
count
);
} }
} }
if (count != currentCount) { if (count != currentCount) {
this.addRemoveClass(counter.closest('[data-poll-wrapper]'), 'is-hidden', count < 1); this.addRemoveClass(counter.closest("[data-poll-wrapper]"), "is-hidden", count < 1);
counter.innerText = count; counter.innerText = count;
this.addRemoveClass(counter.closest('[data-poll-wrapper]'), 'is-danger', hasMentions); this.addRemoveClass(counter.closest("[data-poll-wrapper]"), "is-danger", hasMentions);
} }
} }
/** /**
* Show form. * Show form.
* *
* @param {Event} event * @param {Event} event
* @return {undefined} * @return {undefined}
*/ */
revealForm(event) { revealForm(event) {
let trigger = event.currentTarget; let trigger = event.currentTarget;
let hidden = trigger.closest('.hidden-form').querySelectorAll('.is-hidden')[0]; let hidden = trigger.closest(".hidden-form").querySelectorAll(".is-hidden")[0];
if (hidden) { if (hidden) {
this.addRemoveClass(hidden, 'is-hidden', !hidden); this.addRemoveClass(hidden, "is-hidden", !hidden);
} }
} }
@ -192,10 +173,10 @@ let BookWyrm = new class {
*/ */
hideForm(event) { hideForm(event) {
let trigger = event.currentTarget; let trigger = event.currentTarget;
let targetId = trigger.dataset.hides let targetId = trigger.dataset.hides;
let visible = document.getElementById(targetId) let visible = document.getElementById(targetId);
this.addRemoveClass(visible, 'is-hidden', true); this.addRemoveClass(visible, "is-hidden", true);
} }
/** /**
@ -210,31 +191,34 @@ let BookWyrm = new class {
if (!trigger.dataset.allowDefault || event.currentTarget == event.target) { if (!trigger.dataset.allowDefault || event.currentTarget == event.target) {
event.preventDefault(); event.preventDefault();
} }
let pressed = trigger.getAttribute('aria-pressed') === 'false'; let pressed = trigger.getAttribute("aria-pressed") === "false";
let targetId = trigger.dataset.controls; let targetId = trigger.dataset.controls;
// Toggle pressed status on all triggers controlling the same target. // Toggle pressed status on all triggers controlling the same target.
document.querySelectorAll('[data-controls="' + targetId + '"]') document
.forEach(otherTrigger => otherTrigger.setAttribute( .querySelectorAll('[data-controls="' + targetId + '"]')
'aria-pressed', .forEach((otherTrigger) =>
otherTrigger.getAttribute('aria-pressed') === 'false' otherTrigger.setAttribute(
)); "aria-pressed",
otherTrigger.getAttribute("aria-pressed") === "false"
)
);
// @todo Find a better way to handle the exception. // @todo Find a better way to handle the exception.
if (targetId && ! trigger.classList.contains('pulldown-menu')) { if (targetId && !trigger.classList.contains("pulldown-menu")) {
let target = document.getElementById(targetId); let target = document.getElementById(targetId);
this.addRemoveClass(target, 'is-hidden', !pressed); this.addRemoveClass(target, "is-hidden", !pressed);
this.addRemoveClass(target, 'is-active', pressed); this.addRemoveClass(target, "is-active", pressed);
} }
// Show/hide pulldown-menus. // Show/hide pulldown-menus.
if (trigger.classList.contains('pulldown-menu')) { if (trigger.classList.contains("pulldown-menu")) {
this.toggleMenu(trigger, targetId); this.toggleMenu(trigger, targetId);
} }
// Show/hide container. // Show/hide container.
let container = document.getElementById('hide_' + targetId); let container = document.getElementById("hide_" + targetId);
if (container) { if (container) {
this.toggleContainer(container, pressed); this.toggleContainer(container, pressed);
@ -271,14 +255,14 @@ let BookWyrm = new class {
* @return {undefined} * @return {undefined}
*/ */
toggleMenu(trigger, targetId) { toggleMenu(trigger, targetId) {
let expanded = trigger.getAttribute('aria-expanded') == 'false'; let expanded = trigger.getAttribute("aria-expanded") == "false";
trigger.setAttribute('aria-expanded', expanded); trigger.setAttribute("aria-expanded", expanded);
if (targetId) { if (targetId) {
let target = document.getElementById(targetId); let target = document.getElementById(targetId);
this.addRemoveClass(target, 'is-active', expanded); this.addRemoveClass(target, "is-active", expanded);
} }
} }
@ -290,7 +274,7 @@ let BookWyrm = new class {
* @return {undefined} * @return {undefined}
*/ */
toggleContainer(container, pressed) { toggleContainer(container, pressed) {
this.addRemoveClass(container, 'is-hidden', pressed); this.addRemoveClass(container, "is-hidden", pressed);
} }
/** /**
@ -327,7 +311,7 @@ let BookWyrm = new class {
node.focus(); node.focus();
setTimeout(function() { setTimeout(function () {
node.selectionStart = node.selectionEnd = 10000; node.selectionStart = node.selectionEnd = 10000;
}, 0); }, 0);
} }
@ -347,15 +331,17 @@ let BookWyrm = new class {
const relatedforms = document.querySelectorAll(`.${form.dataset.id}`); const relatedforms = document.querySelectorAll(`.${form.dataset.id}`);
// Toggle class on all related forms. // Toggle class on all related forms.
relatedforms.forEach(relatedForm => bookwyrm.addRemoveClass( relatedforms.forEach((relatedForm) =>
relatedForm, bookwyrm.addRemoveClass(
'is-hidden', relatedForm,
relatedForm.className.indexOf('is-hidden') == -1 "is-hidden",
)); relatedForm.className.indexOf("is-hidden") == -1
)
);
this.ajaxPost(form).catch(error => { this.ajaxPost(form).catch((error) => {
// @todo Display a notification in the UI instead. // @todo Display a notification in the UI instead.
console.warn('Request failed:', error); console.warn("Request failed:", error);
}); });
} }
@ -367,11 +353,11 @@ let BookWyrm = new class {
*/ */
ajaxPost(form) { ajaxPost(form) {
return fetch(form.action, { return fetch(form.action, {
method : "POST", method: "POST",
body: new FormData(form), body: new FormData(form),
headers: { headers: {
'Accept': 'application/json', Accept: "application/json",
} },
}); });
} }
@ -396,21 +382,16 @@ let BookWyrm = new class {
const element = eventOrElement.currentTarget || eventOrElement; const element = eventOrElement.currentTarget || eventOrElement;
const submits = element.form.querySelectorAll('[type="submit"]'); const submits = element.form.querySelectorAll('[type="submit"]');
const warns = element.parentElement.querySelectorAll('.file-too-big'); const warns = element.parentElement.querySelectorAll(".file-too-big");
const isTooBig = element.files && const isTooBig =
element.files[0] && element.files && element.files[0] && element.files[0].size > MAX_FILE_SIZE_BYTES;
element.files[0].size > MAX_FILE_SIZE_BYTES;
if (isTooBig) { if (isTooBig) {
submits.forEach(submitter => submitter.disabled = true); submits.forEach((submitter) => (submitter.disabled = true));
warns.forEach( warns.forEach((sib) => addRemoveClass(sib, "is-hidden", false));
sib => addRemoveClass(sib, 'is-hidden', false)
);
} else { } else {
submits.forEach(submitter => submitter.disabled = false); submits.forEach((submitter) => (submitter.disabled = false));
warns.forEach( warns.forEach((sib) => addRemoveClass(sib, "is-hidden", true));
sib => addRemoveClass(sib, 'is-hidden', true)
);
} }
} }
@ -422,31 +403,27 @@ let BookWyrm = new class {
* @return {undefined} * @return {undefined}
*/ */
displayPopUp(url, windowName) { displayPopUp(url, windowName) {
window.open( window.open(url, windowName, "left=100,top=100,width=430,height=600");
url,
windowName,
"left=100,top=100,width=430,height=600"
);
} }
duplicateInput (event ) { duplicateInput(event) {
const trigger = event.currentTarget; const trigger = event.currentTarget;
const input_id = trigger.dataset['duplicate'] const input_id = trigger.dataset["duplicate"];
const orig = document.getElementById(input_id); const orig = document.getElementById(input_id);
const parent = orig.parentNode; const parent = orig.parentNode;
const new_count = parent.querySelectorAll("input").length + 1 const new_count = parent.querySelectorAll("input").length + 1;
let input = orig.cloneNode(); let input = orig.cloneNode();
input.id += ("-" + (new_count)) input.id += "-" + new_count;
input.value = "" input.value = "";
let label = parent.querySelector("label").cloneNode(); let label = parent.querySelector("label").cloneNode();
label.setAttribute("for", input.id) label.setAttribute("for", input.id);
parent.appendChild(label) parent.appendChild(label);
parent.appendChild(input) parent.appendChild(input);
} }
/** /**
@ -461,7 +438,7 @@ let BookWyrm = new class {
copyText(textareaEl) { copyText(textareaEl) {
const text = textareaEl.textContent; const text = textareaEl.textContent;
const copyButtonEl = document.createElement('button'); const copyButtonEl = document.createElement("button");
copyButtonEl.textContent = textareaEl.dataset.copytextLabel; copyButtonEl.textContent = textareaEl.dataset.copytextLabel;
copyButtonEl.classList.add( copyButtonEl.classList.add(
@ -472,14 +449,14 @@ let BookWyrm = new class {
"is-primary", "is-primary",
"is-light" "is-light"
); );
copyButtonEl.addEventListener('click', () => { copyButtonEl.addEventListener("click", () => {
navigator.clipboard.writeText(text).then(function() { navigator.clipboard.writeText(text).then(function () {
textareaEl.classList.add('is-success'); textareaEl.classList.add("is-success");
copyButtonEl.classList.replace('is-primary', 'is-success'); copyButtonEl.classList.replace("is-primary", "is-success");
copyButtonEl.textContent = textareaEl.dataset.copytextSuccess; copyButtonEl.textContent = textareaEl.dataset.copytextSuccess;
}); });
}); });
textareaEl.parentNode.appendChild(copyButtonEl) textareaEl.parentNode.appendChild(copyButtonEl);
} }
}(); })();

View file

@ -1,6 +1,5 @@
(function () {
(function() { "use strict";
'use strict';
/** /**
* Toggle all descendant checkboxes of a target. * Toggle all descendant checkboxes of a target.
@ -23,12 +22,10 @@
document document
.querySelectorAll(`#${mainCheckbox.dataset.target} [type="checkbox"]`) .querySelectorAll(`#${mainCheckbox.dataset.target} [type="checkbox"]`)
.forEach(checkbox => checkbox.checked = mainCheckbox.checked); .forEach((checkbox) => (checkbox.checked = mainCheckbox.checked));
} }
document document.querySelectorAll('[data-action="toggle-all"]').forEach((input) => {
.querySelectorAll('[data-action="toggle-all"]') input.addEventListener("change", toggleAllCheckboxes);
.forEach(input => { });
input.addEventListener('change', toggleAllCheckboxes);
});
})(); })();

View file

@ -1,13 +1,13 @@
/* exported LocalStorageTools */ /* exported LocalStorageTools */
/* globals BookWyrm */ /* globals BookWyrm */
let LocalStorageTools = new class { let LocalStorageTools = new (class {
constructor() { constructor() {
document.querySelectorAll('[data-hide]') document.querySelectorAll("[data-hide]").forEach((t) => this.setDisplay(t));
.forEach(t => this.setDisplay(t));
document.querySelectorAll('.set-display') document
.forEach(t => t.addEventListener('click', this.updateDisplay.bind(this))); .querySelectorAll(".set-display")
.forEach((t) => t.addEventListener("click", this.updateDisplay.bind(this)));
} }
/** /**
@ -23,8 +23,9 @@ let LocalStorageTools = new class {
window.localStorage.setItem(key, value); window.localStorage.setItem(key, value);
document.querySelectorAll('[data-hide="' + key + '"]') document
.forEach(node => this.setDisplay(node)); .querySelectorAll('[data-hide="' + key + '"]')
.forEach((node) => this.setDisplay(node));
} }
/** /**
@ -38,6 +39,6 @@ let LocalStorageTools = new class {
let key = node.dataset.hide; let key = node.dataset.hide;
let value = window.localStorage.getItem(key); let value = window.localStorage.getItem(key);
BookWyrm.addRemoveClass(node, 'is-hidden', value); BookWyrm.addRemoveClass(node, "is-hidden", value);
} }
}(); })();

View file

@ -1,22 +1,21 @@
/* exported StatusCache */ /* exported StatusCache */
/* globals BookWyrm */ /* globals BookWyrm */
let StatusCache = new class { let StatusCache = new (class {
constructor() { constructor() {
document.querySelectorAll('[data-cache-draft]') document
.forEach(t => t.addEventListener('change', this.updateDraft.bind(this))); .querySelectorAll("[data-cache-draft]")
.forEach((t) => t.addEventListener("change", this.updateDraft.bind(this)));
document.querySelectorAll('[data-cache-draft]') document.querySelectorAll("[data-cache-draft]").forEach((t) => this.populateDraft(t));
.forEach(t => this.populateDraft(t));
document.querySelectorAll('.submit-status') document
.forEach(button => button.addEventListener( .querySelectorAll(".submit-status")
'submit', .forEach((button) => button.addEventListener("submit", this.submitStatus.bind(this)));
this.submitStatus.bind(this))
);
document.querySelectorAll('.form-rate-stars label.icon') document
.forEach(button => button.addEventListener('click', this.toggleStar.bind(this))); .querySelectorAll(".form-rate-stars label.icon")
.forEach((button) => button.addEventListener("click", this.toggleStar.bind(this)));
} }
/** /**
@ -80,25 +79,26 @@ let StatusCache = new class {
event.preventDefault(); event.preventDefault();
BookWyrm.addRemoveClass(form, 'is-processing', true); BookWyrm.addRemoveClass(form, "is-processing", true);
trigger.setAttribute('disabled', null); trigger.setAttribute("disabled", null);
BookWyrm.ajaxPost(form).finally(() => { BookWyrm.ajaxPost(form)
// Change icon to remove ongoing activity on the current UI. .finally(() => {
// Enable back the element used to submit the form. // Change icon to remove ongoing activity on the current UI.
BookWyrm.addRemoveClass(form, 'is-processing', false); // Enable back the element used to submit the form.
trigger.removeAttribute('disabled'); BookWyrm.addRemoveClass(form, "is-processing", false);
}) trigger.removeAttribute("disabled");
.then(response => { })
if (!response.ok) { .then((response) => {
throw new Error(); if (!response.ok) {
} throw new Error();
this.submitStatusSuccess(form); }
}) this.submitStatusSuccess(form);
.catch(error => { })
console.warn(error); .catch((error) => {
this.announceMessage('status-error-message'); console.warn(error);
}); this.announceMessage("status-error-message");
});
} }
/** /**
@ -112,12 +112,16 @@ let StatusCache = new class {
let copy = element.cloneNode(true); let copy = element.cloneNode(true);
copy.id = null; copy.id = null;
element.insertAdjacentElement('beforebegin', copy); element.insertAdjacentElement("beforebegin", copy);
BookWyrm.addRemoveClass(copy, 'is-hidden', false); BookWyrm.addRemoveClass(copy, "is-hidden", false);
setTimeout(function() { setTimeout(
copy.remove(); function () {
}, 10000, copy); copy.remove();
},
10000,
copy
);
} }
/** /**
@ -131,8 +135,9 @@ let StatusCache = new class {
form.reset(); form.reset();
// Clear localstorage // Clear localstorage
form.querySelectorAll('[data-cache-draft]') form.querySelectorAll("[data-cache-draft]").forEach((node) =>
.forEach(node => window.localStorage.removeItem(node.dataset.cacheDraft)); window.localStorage.removeItem(node.dataset.cacheDraft)
);
// Close modals // Close modals
let modal = form.closest(".modal.is-active"); let modal = form.closest(".modal.is-active");
@ -142,8 +147,11 @@ let StatusCache = new class {
// Update shelve buttons // Update shelve buttons
if (form.reading_status) { if (form.reading_status) {
document.querySelectorAll("[data-shelve-button-book='" + form.book.value +"']") document
.forEach(button => this.cycleShelveButtons(button, form.reading_status.value)); .querySelectorAll("[data-shelve-button-book='" + form.book.value + "']")
.forEach((button) =>
this.cycleShelveButtons(button, form.reading_status.value)
);
} }
return; return;
@ -156,7 +164,7 @@ let StatusCache = new class {
document.querySelector("[data-controls=" + reply.id + "]").click(); document.querySelector("[data-controls=" + reply.id + "]").click();
} }
this.announceMessage('status-success-message'); this.announceMessage("status-success-message");
} }
/** /**
@ -172,8 +180,9 @@ let StatusCache = new class {
let next_identifier = shelf.dataset.shelfNext; let next_identifier = shelf.dataset.shelfNext;
// Set all buttons to hidden // Set all buttons to hidden
button.querySelectorAll("[data-shelf-identifier]") button
.forEach(item => BookWyrm.addRemoveClass(item, "is-hidden", true)); .querySelectorAll("[data-shelf-identifier]")
.forEach((item) => BookWyrm.addRemoveClass(item, "is-hidden", true));
// Button that should be visible now // Button that should be visible now
let next = button.querySelector("[data-shelf-identifier=" + next_identifier + "]"); let next = button.querySelector("[data-shelf-identifier=" + next_identifier + "]");
@ -183,15 +192,17 @@ let StatusCache = new class {
// ------ update the dropdown buttons // ------ update the dropdown buttons
// Remove existing hidden class // Remove existing hidden class
button.querySelectorAll("[data-shelf-dropdown-identifier]") button
.forEach(item => BookWyrm.addRemoveClass(item, "is-hidden", false)); .querySelectorAll("[data-shelf-dropdown-identifier]")
.forEach((item) => BookWyrm.addRemoveClass(item, "is-hidden", false));
// Remove existing disabled states // Remove existing disabled states
button.querySelectorAll("[data-shelf-dropdown-identifier] button") button
.forEach(item => item.disabled = false); .querySelectorAll("[data-shelf-dropdown-identifier] button")
.forEach((item) => (item.disabled = false));
next_identifier = next_identifier == 'complete' ? 'read' : next_identifier; next_identifier = next_identifier == "complete" ? "read" : next_identifier;
// Disable the current state // Disable the current state
button.querySelector( button.querySelector(
@ -206,8 +217,9 @@ let StatusCache = new class {
BookWyrm.addRemoveClass(main_button, "is-hidden", true); BookWyrm.addRemoveClass(main_button, "is-hidden", true);
// Just hide the other two menu options, idk what to do with them // Just hide the other two menu options, idk what to do with them
button.querySelectorAll("[data-extra-options]") button
.forEach(item => BookWyrm.addRemoveClass(item, "is-hidden", true)); .querySelectorAll("[data-extra-options]")
.forEach((item) => BookWyrm.addRemoveClass(item, "is-hidden", true));
// Close menu // Close menu
let menu = button.querySelector("details[open]"); let menu = button.querySelector("details[open]");
@ -235,5 +247,4 @@ let StatusCache = new class {
halfStar.checked = "checked"; halfStar.checked = "checked";
} }
} }
}(); })();