forked from ubiquity/pay.ubq.fi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ubiquity#190 from pavlovcik/fix/visible-buttons-on…
…-load Fix/visible buttons on load
- Loading branch information
Showing
18 changed files
with
366 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
const LOADER = "data-loader"; | ||
const MAKE_CLAIM = "data-make-claim"; | ||
const VIEW_CLAIM = "data-view-claim"; | ||
const INVALIDATOR = "data-invalidator"; | ||
export class ButtonController { | ||
private _controls: HTMLDivElement; | ||
|
||
constructor(controls: HTMLDivElement) { | ||
this._controls = controls; | ||
this.hideAll(); | ||
} | ||
|
||
public showLoader(): void { | ||
if (window.ethereum) { | ||
this._controls.setAttribute(LOADER, "true"); | ||
} else { | ||
throw new Error("Can not show loader without `window.ethereum`"); | ||
} | ||
} | ||
|
||
public hideLoader(): void { | ||
this._controls.setAttribute(LOADER, "false"); | ||
} | ||
|
||
public hideMakeClaim(): void { | ||
this._controls.setAttribute(MAKE_CLAIM, "false"); | ||
} | ||
|
||
public showMakeClaim(): void { | ||
if (window.ethereum) { | ||
this._controls.setAttribute(MAKE_CLAIM, "true"); | ||
} else { | ||
throw new Error("Can not show make claim button without `window.ethereum`"); | ||
} | ||
} | ||
|
||
public hideViewClaim(): void { | ||
this._controls.setAttribute(VIEW_CLAIM, "false"); | ||
} | ||
|
||
public showViewClaim(): void { | ||
this._controls.setAttribute(VIEW_CLAIM, "true"); | ||
} | ||
|
||
public hideInvalidator(): void { | ||
this._controls.setAttribute(INVALIDATOR, "false"); | ||
} | ||
|
||
public showInvalidator(): void { | ||
if (window.ethereum) { | ||
this._controls.setAttribute(INVALIDATOR, "true"); | ||
} else { | ||
throw new Error("Can not show invalidator button without `window.ethereum`"); | ||
} | ||
} | ||
|
||
public onlyShowLoader(): void { | ||
this.hideMakeClaim(); | ||
this.hideViewClaim(); | ||
this.hideInvalidator(); | ||
this.showLoader(); | ||
} | ||
|
||
public onlyShowMakeClaim(): void { | ||
this.hideLoader(); | ||
this.showMakeClaim(); | ||
this.hideViewClaim(); | ||
this.hideInvalidator(); | ||
} | ||
|
||
public onlyShowViewClaim(): void { | ||
this.hideLoader(); | ||
this.hideMakeClaim(); | ||
this.showViewClaim(); | ||
this.hideInvalidator(); | ||
} | ||
|
||
public onlyShowInvalidator(): void { | ||
this.hideLoader(); | ||
this.hideMakeClaim(); | ||
this.hideViewClaim(); | ||
this.showInvalidator(); | ||
} | ||
|
||
public hideAll(): void { | ||
this.hideLoader(); | ||
this.hideMakeClaim(); | ||
this.hideViewClaim(); | ||
this.hideInvalidator(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.