A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

68 líneas
1.7KB

  1. import GlobalEvents from "/app/js/common/EventCaller.js";
  2. class Modal{
  3. constructor(){
  4. this.__currentModalEl = null;
  5. window.addEventListener("click", (function(event){
  6. if (event.target === this.__currentModalEl){
  7. this.close_modal();
  8. }
  9. }).bind(this));
  10. GlobalEvents.listen("modal-open", (function(event){
  11. if (event.hasOwnProperty("id") && typeof(event.id) === 'string'){
  12. var force = (event.hasOwnProperty("force")) ? event.force === true : false;
  13. this.open_modal_id(event.id, force);
  14. }
  15. }).bind(this));
  16. GlobalEvents.listen("modal-close", (function(event){
  17. this.close_modal();
  18. }).bind(this));
  19. }
  20. get currentModalElement(){
  21. return this.__currentModalEl;
  22. }
  23. open_modal_id(idname, force=false){
  24. var el = document.getElementById(idname);
  25. if (el.classList.contains("modal") && this.__currentModalEl !== el){
  26. if (this.__currentModalEl !== null && force)
  27. this.close_modal();
  28. if (this.__currentModalEl === null){
  29. if (el){
  30. return this.open_modal_element(el);
  31. }
  32. }
  33. }
  34. return this;
  35. }
  36. open_modal_element(el, force=false){
  37. if (el.classList.contains("modal")){
  38. if (this.__currentModalEl !== null && force)
  39. this.close_modal();
  40. if (this.__currentModalEl === null){
  41. el.classList.add("modal-visible");
  42. this.__currentModalEl = el;
  43. }
  44. }
  45. return this;
  46. }
  47. close_modal(){
  48. if (this.__currentModalEl !== null){
  49. this.__currentModalEl.classList.remove("modal-visible");
  50. this.__currentModalEl = null;
  51. }
  52. return this;
  53. }
  54. }
  55. const instance = new Modal();
  56. export default instance;