Added the ability to cancel bakes

This commit is contained in:
n1474335 2017-07-28 16:38:53 +01:00
parent 98884d851a
commit f1ebab0c2d
4 changed files with 57 additions and 11 deletions

View file

@ -78,7 +78,11 @@ ControlsWaiter.prototype.setAutoBake = function(value) {
* Handler to trigger baking.
*/
ControlsWaiter.prototype.bakeClick = function() {
this.app.bake();
if (document.getElementById("bake").textContent.indexOf("Bake") > 0) {
this.app.bake();
} else {
this.app.cancelBake();
}
};
@ -386,4 +390,25 @@ ControlsWaiter.prototype.hideStaleIndicator = function() {
staleIndicator.style.visibility = "hidden";
};
/**
* Switches the Bake button between 'Bake' and 'Cancel' functions.
*
* @param {boolean} cancel - Whether to change to cancel or not
*/
ControlsWaiter.prototype.toggleBakeButtonFunction = function(cancel) {
const bakeButton = document.getElementById("bake"),
btnText = bakeButton.querySelector("span");
if (cancel) {
btnText.innerText = "Cancel";
bakeButton.classList.remove("btn-success");
bakeButton.classList.add("btn-danger");
} else {
btnText.innerText = "Bake!";
bakeButton.classList.remove("btn-danger");
bakeButton.classList.add("btn-success");
}
};
export default ControlsWaiter;