2017-11-11 12:03:30 +00:00
|
|
|
function Popup(){this.element={background:document.querySelector("#POPUP-BG"),frame:document.querySelector("#POPUP"),header:document.querySelector("#POPUP .header"),body:document.querySelector("#POPUP .body"),footer:document.querySelector("#POPUP .footer")},this.element.background.addEventListener("click",function(e){this.hide().handler(!1)}.bind(this),!1)}Popup.prototype={handler:null,element:{frame:null,header:null,body:null,footer:null},show:function(){return this.element.frame.addClass("active"),this},hide:function(){return this.element.frame.remClass("active"),this},ask:function(e,n){function t(e){this.hide(),this.handler("grey"!=e.target.className)}if(!(e instanceof Object))return null;if(null==e.title)return null;if(null==e.content)return null;if(null==e.type)return null;if(null==e.action)return null;if(!(n instanceof Function))return null;this.element.header.innerHTML=e.title,this.element.body.innerHTML=e.content,this.handler=n;var r=document.createElement("button");r.className=e.type,r.innerHTML=e.action;var l=document.createElement("button");return l.className="grey",l.innerHTML="Annuler",r.addEventListener("click",t.bind(this),!1),l.addEventListener("click",t.bind(this),!1),this.element.footer.innerHTML="",this.element.footer.appendChild(r),this.element.footer.appendChild(l),this.show()}};
|