Support options in app.overlay.create()

This commit is contained in:
Niko 2022-02-20 17:58:23 +01:00
parent 0c405137c2
commit 779a7db902
1 changed files with 10 additions and 4 deletions

View File

@ -222,7 +222,8 @@ app.post = {
app.media = {
view: function(url) {
if (url.match(/^.*\.(jpg|jpeg|png|ico|webp)$/))
app.overlay.create('overlay.view_image', { url }, true);
app.overlay.create('overlay.view_image', { url },
{ dark: true, removable: true });
},
}
@ -251,15 +252,20 @@ app.emoji = {
}
app.overlay = {
create: function(template, data, removable) {
create: function(template, data, options) {
options = options || {};
app.template.load(template, function(tpl) {
const id = 'overlay-'+uuidv4();
const div = document.createElement('div');
data['oid'] = id;
div.id = id;
div.className = 'overlay height-mobile dark';
div.className = 'overlay height-mobile';
if (options.dark)
div.className += ' dark';
if (typeof options.css === 'string')
div.className += ` ${options.css}`;
div.innerHTML = app.template.fill(data, tpl);
if (removable)
if (options.removable)
div.setAttribute('onclick', `app.overlay.remove("${id}")`);
document.body.appendChild(div);
calcHeightMobile();