Explorar el Código

Initial work on a Modal popup UI.

dev-tmpl
Bryan Miller hace 6 años
padre
commit
a1263f4b99
Se han modificado 1 ficheros con 66 adiciones y 0 borrados
  1. +66
    -0
      app/js/ui/Modal.js

+ 66
- 0
app/js/ui/Modal.js Ver fichero

@@ -0,0 +1,66 @@
import EventWindow from "/app/js/ui/EventWindow.js";


class Modal{
constructor(){
this.__currentModalEl = null;
this.__initialized = false;

EventWindow.listen("onclick", (function(event){
if (event.target === this.__currentModalEl){
this.close_modal();
}
}).bind(this));
}

get currentModalElement(){
return this.__currentModalEl;
}

open_modal_by_id(idname){
if (this.__initialized === true && this.__currentModalEl === null){
var el = document.getElementById(idname);
if (el){
return this.open_modal_element(el);
}
}
return this;
}

open_modal_element(el){
if (this.__initialized === true, this.__currentModalEl === null && el.classList.contains("modal")){
el.classList.add("modal-visible");
this.__currentModalEl = el;
}
return this;
}

close_modal(){
if (this.__currentModalEl !== null){
this.__currentModalEl.classList.remove("modal-visible");
}
return this;
}

initialize_btn_element(el){
if (this.__initialized === true){
if (el.hasAttribute("data-modal-open")){

} else if (el.hasAttribute("data-modal-close")){

} else if (el.hasAttribute("data-modal-toggle")){

}
}
return this;
}

initialize(){
;
}
}


const instance = new Modal();
Object.freeze(instance);
export default instance;

Cargando…
Cancelar
Guardar