filebrowser/frontend/src/utils/buttons.js

68 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-03-21 11:51:58 +00:00
function loading(button) {
let el = document.querySelector(`#${button}-button > i`);
2018-02-01 12:17:04 +00:00
if (el === undefined || el === null) {
2021-03-21 11:51:58 +00:00
return;
2018-02-01 12:17:04 +00:00
}
2021-03-21 11:51:58 +00:00
if (el.innerHTML == "autorenew" || el.innerHTML == "done") {
return;
2021-03-10 15:32:10 +00:00
}
2021-03-21 11:51:58 +00:00
el.dataset.icon = el.innerHTML;
el.style.opacity = 0;
2018-02-01 12:17:04 +00:00
setTimeout(() => {
2021-03-21 11:51:58 +00:00
el.classList.add("spin");
el.innerHTML = "autorenew";
el.style.opacity = 1;
}, 100);
2018-02-01 12:17:04 +00:00
}
2021-03-21 11:51:58 +00:00
function done(button) {
let el = document.querySelector(`#${button}-button > i`);
2018-02-01 12:17:04 +00:00
if (el === undefined || el === null) {
2021-03-21 11:51:58 +00:00
return;
2018-02-01 12:17:04 +00:00
}
2021-03-21 11:51:58 +00:00
el.style.opacity = 0;
2018-02-01 12:17:04 +00:00
setTimeout(() => {
2021-03-21 11:51:58 +00:00
el.classList.remove("spin");
el.innerHTML = el.dataset.icon;
el.style.opacity = 1;
}, 100);
2018-02-01 12:17:04 +00:00
}
2021-03-21 11:51:58 +00:00
function success(button) {
let el = document.querySelector(`#${button}-button > i`);
2018-02-01 12:17:04 +00:00
if (el === undefined || el === null) {
2021-03-21 11:51:58 +00:00
return;
2018-02-01 12:17:04 +00:00
}
2021-03-21 11:51:58 +00:00
el.style.opacity = 0;
2018-02-01 12:17:04 +00:00
setTimeout(() => {
2021-03-21 11:51:58 +00:00
el.classList.remove("spin");
el.innerHTML = "done";
el.style.opacity = 1;
2018-02-01 12:17:04 +00:00
setTimeout(() => {
2021-03-21 11:51:58 +00:00
el.style.opacity = 0;
2018-02-01 12:17:04 +00:00
setTimeout(() => {
2021-03-21 11:51:58 +00:00
el.innerHTML = el.dataset.icon;
el.style.opacity = 1;
}, 100);
}, 500);
}, 100);
2018-02-01 12:17:04 +00:00
}
export default {
loading,
done,
2021-03-21 11:51:58 +00:00
success,
};