A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

90 rindas
2.4KB

  1. import GlobalEvents from "/app/js/common/EventCaller.js";
  2. import Input from "/app/js/ui/Input.js";
  3. class Modal{
  4. constructor(){
  5. this.__currentModalEl = null;
  6. window.addEventListener("click", (function(event){
  7. if (event.target === this.__currentModalEl){
  8. this.close_modal();
  9. }
  10. }).bind(this));
  11. GlobalEvents.listen("modal-open", (function(target, event){
  12. if (event.hasOwnProperty("id") && typeof(event.id) === 'string'){
  13. var force = (event.hasOwnProperty("force")) ? event.force === true : false;
  14. this.open_modal_id(event.id, force);
  15. }
  16. }).bind(this));
  17. GlobalEvents.listen("modal-close", (function(target, event){
  18. this.close_modal();
  19. }).bind(this));
  20. GlobalEvents.listen("modal-submit", (function(target, event){
  21. if (target !== this.__currentModalEl)
  22. return;
  23. if (!event.hasOwnProperty("subevent"))
  24. return;
  25. var ename = event.subevent;
  26. var vals = {};
  27. if (event.hasOwnProperty("ids")){
  28. var ids = event.ids.split(",");
  29. var cel = this.__currentModalEl;
  30. ids.forEach((item) => {
  31. var id = item.trim();
  32. var el = cel.querySelector("[name='" + id + "']");
  33. if (el && el.hasOwnProperty("value"))
  34. vals[id] = el.value;
  35. });
  36. }
  37. GlobalEvents.emit(ename, vals);
  38. if (event.hasOwnProperty("closeoncomplete"))
  39. this.close_modal();
  40. }).bind(this));
  41. }
  42. get currentModalElement(){
  43. return this.__currentModalEl;
  44. }
  45. open_modal_id(idname, force=false){
  46. var el = document.getElementById(idname);
  47. if (el.classList.contains("modal") && this.__currentModalEl !== el){
  48. if (this.__currentModalEl !== null && force)
  49. this.close_modal();
  50. if (this.__currentModalEl === null){
  51. if (el){
  52. return this.open_modal_element(el);
  53. }
  54. }
  55. }
  56. return this;
  57. }
  58. open_modal_element(el, force=false){
  59. if (el.classList.contains("modal")){
  60. if (this.__currentModalEl !== null && force)
  61. this.close_modal();
  62. if (this.__currentModalEl === null){
  63. el.classList.add("modal-visible");
  64. this.__currentModalEl = el;
  65. }
  66. }
  67. return this;
  68. }
  69. close_modal(){
  70. if (this.__currentModalEl !== null){
  71. this.__currentModalEl.classList.remove("modal-visible");
  72. this.__currentModalEl = null;
  73. }
  74. return this;
  75. }
  76. }
  77. const instance = new Modal();
  78. export default instance;