Skip to content

Commit

Permalink
Fix #540
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrancart committed Jan 5, 2024
1 parent b5e030e commit 9133b85
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/sparnatural/components/buttons/PlayBtn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ class PlayBtn extends HTMLComponent {
let widgetHtml = $(`${UiuxConfig.ICON_PLAY}`);
super("playBtn", ParentComponent, widgetHtml);
this.callback = callback;
this.html.on("click", (e: JQuery.ClickEvent) => {
callback();
// add clicklistener
let that = this;
this.widgetHtml.on("click", function (e: JQuery.ClickEvent) {
// don't call the callback when the button is disabled
if(!that.isDisabled()) {
callback();
}
});
}

Expand All @@ -19,8 +24,15 @@ class PlayBtn extends HTMLComponent {
return this;
}

/**
* @returns true when the button is disabled
*/
isDisabled():boolean {
return this.html.hasClass('submitDisable');
}

disable() {
// set a disabled CSS class, trigger the loader, and remove click event
// set a disabled CSS class, trigger the loader
this.html.addClass('submitDisable loadingEnabled');
}

Expand All @@ -36,11 +48,6 @@ class PlayBtn extends HTMLComponent {
*/
enable() {
this.html.removeClass('submitDisable');
// re-enable the click event
let that = this;
this.widgetHtml.on("click", (e: JQuery.ClickEvent) => {
that.callback();
});
}

}
Expand Down

0 comments on commit 9133b85

Please sign in to comment.