Support options in app.overlay.create()
This commit is contained in:
parent
0c405137c2
commit
779a7db902
|
@ -222,7 +222,8 @@ app.post = {
|
||||||
app.media = {
|
app.media = {
|
||||||
view: function(url) {
|
view: function(url) {
|
||||||
if (url.match(/^.*\.(jpg|jpeg|png|ico|webp)$/))
|
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 = {
|
app.overlay = {
|
||||||
create: function(template, data, removable) {
|
create: function(template, data, options) {
|
||||||
|
options = options || {};
|
||||||
app.template.load(template, function(tpl) {
|
app.template.load(template, function(tpl) {
|
||||||
const id = 'overlay-'+uuidv4();
|
const id = 'overlay-'+uuidv4();
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
data['oid'] = id;
|
data['oid'] = id;
|
||||||
div.id = 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);
|
div.innerHTML = app.template.fill(data, tpl);
|
||||||
if (removable)
|
if (options.removable)
|
||||||
div.setAttribute('onclick', `app.overlay.remove("${id}")`);
|
div.setAttribute('onclick', `app.overlay.remove("${id}")`);
|
||||||
document.body.appendChild(div);
|
document.body.appendChild(div);
|
||||||
calcHeightMobile();
|
calcHeightMobile();
|
||||||
|
|
Loading…
Reference in New Issue