[assets] Move interact function.

This commit is contained in:
Fabien Basmaison 2021-04-06 17:57:39 +02:00
parent 9d95f54aa2
commit 44040201f9

View file

@ -174,30 +174,6 @@ let BookWyrm = new class {
} }
} }
/**
* Make a request and update the UI accordingly.
* This function is used for boosts and favourites.
*
* @todo Only update status if the promise is successful.
*
* @param {Event} event
*
* @return {undefined}
*/
interact(event) {
event.preventDefault();
this.ajaxPost(event.target);
// @todo This probably should be done with IDs.
document.querySelectorAll(`.${event.target.dataset.id}`)
.forEach(node => this.addRemoveClass(
node,
'hidden',
node.className.indexOf('hidden') == -1
));
}
/** /**
* Show or hide menus. * Show or hide menus.
* *
@ -260,6 +236,30 @@ let BookWyrm = new class {
}, 0); }, 0);
} }
/**
* Make a request and update the UI accordingly.
* This function is used for boosts and favourites.
*
* @todo Only update status if the promise is successful.
*
* @param {Event} event
*
* @return {undefined}
*/
interact(event) {
event.preventDefault();
this.ajaxPost(event.target);
// @todo This probably should be done with IDs.
document.querySelectorAll(`.${event.target.dataset.id}`)
.forEach(node => this.addRemoveClass(
node,
'hidden',
node.className.indexOf('hidden') == -1
));
}
/** /**
* Submit a form using POST. * Submit a form using POST.
* *