applet.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { dom_manager, type_manager } from "./functions.js";
  2. class applet_builder {
  3. #target;
  4. #show;
  5. #hide;
  6. #change;
  7. #init;
  8. #animation;
  9. constructor() {
  10. this.#target = undefined;
  11. this.#show = undefined;
  12. this.#hide = undefined;
  13. this.#change = undefined;
  14. this.#init = undefined;
  15. this.#animation = undefined;
  16. }
  17. set_target(target) {
  18. if (!dom_manager.is_element(target)) {
  19. throw "Target is not HTML element.";
  20. }
  21. this.#target = target;
  22. }
  23. #is_dualbutton() {
  24. return this.#show !== undefined || this.#hide !== undefined;
  25. }
  26. #is_singlebutton() {
  27. return this.#change !== undefined;
  28. }
  29. set_show(target) {
  30. if (!dom_manager.is_element(target)) {
  31. throw "Show button must be HTML element.";
  32. }
  33. if (this.#is_singlebutton()) {
  34. throw "This is single button applet.";
  35. }
  36. this.#show = target;
  37. }
  38. set_hide(target) {
  39. if (!dom_manager.is_element(target)) {
  40. throw "Hide button must be HTML element.";
  41. }
  42. if (this.#is_singlebutton()) {
  43. throw "This is single button applet.";
  44. }
  45. this.#hide = hide;
  46. }
  47. set_change(target) {
  48. if (!dom_manager.is_element(target)) {
  49. throw "Change button must be HTML element.";
  50. }
  51. if (this.#is_dualbutton()) {
  52. throw "This is dual button applet.";
  53. }
  54. this.#change = target;
  55. }
  56. default_visible() {
  57. this.#init = true;
  58. }
  59. default_hidden() {
  60. this.#init = false;
  61. }
  62. set_animation(target) {
  63. if (!type_manager.is_function(target)) {
  64. throw "Animation must be an function.";
  65. }
  66. }
  67. }
  68. class applet {
  69. }
  70. export { applet };