mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-12 11:52:30 +00:00
[assets] Move interact function.
This commit is contained in:
parent
9d95f54aa2
commit
44040201f9
1 changed files with 24 additions and 24 deletions
|
@ -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.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue