|
|
|
@ -77,15 +77,20 @@ class Popup { |
|
|
|
|
buttons.forEach(btn => buttonSection.appendChild(btn)); |
|
|
|
|
|
|
|
|
|
parent.appendChild(outer); |
|
|
|
|
Popup.displayed.push(this); |
|
|
|
|
|
|
|
|
|
const code=await Promise.race(buttons.map(btn => new Promise(ok => { |
|
|
|
|
const btnActions=buttons.map(btn => new Promise(ok => { |
|
|
|
|
btn.addEventListener('click', e => { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
return ok(btn.dataset.code); |
|
|
|
|
}); |
|
|
|
|
}))); |
|
|
|
|
})); |
|
|
|
|
const dismissAction=new Promise(ok => this.dismiss=ok); |
|
|
|
|
|
|
|
|
|
const code=await Promise.race(btnActions.concat([dismissAction])); |
|
|
|
|
|
|
|
|
|
parent.removeChild(outer); |
|
|
|
|
Popup.displayed.splice(Popup.displayed.indexOf(this), 1); |
|
|
|
|
return code; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -93,4 +98,9 @@ class Popup { |
|
|
|
|
Popup.EM=Symbol('EM'); |
|
|
|
|
Popup.STRONG=Symbol('STRONG'); |
|
|
|
|
|
|
|
|
|
Popup.displayed=[]; |
|
|
|
|
Popup.dismiss=arg => { |
|
|
|
|
Popup.displayed.forEach(p => p.dismiss(arg)); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return module.exports=Popup; |
|
|
|
|