toast coloring

This commit is contained in:
ed 2021-07-26 03:00:37 +02:00
parent 980c6fc810
commit 8cd84608a5
3 changed files with 49 additions and 13 deletions

View file

@ -48,12 +48,30 @@ body {
padding: 1em 1.3em; padding: 1em 1.3em;
border-width: .4em 0; border-width: .4em 0;
transform: translateX(100%); transform: translateX(100%);
transition: all .3s cubic-bezier(.2, 1.2, .5, 1);; transition: all .3s cubic-bezier(.2, 1.2, .5, 1);
text-shadow: 1px 1px 0 #000;
color: #fff;
} }
#toast.vis { #toast.vis {
right: 1.3em; right: 1.3em;
transform: unset; transform: unset;
} }
#toast.inf {
background: #07a;
border-color: #0be;
}
#toast.ok {
background: #4a0;
border-color: #8e4;
}
#toast.warn {
background: #a70;
border-color: #fc0;
}
#toast.err {
background: #b00;
border-color: #f00;
}
#tt.b { #tt.b {
padding: 0 2em; padding: 0 2em;
border-radius: .5em; border-radius: .5em;
@ -1009,11 +1027,13 @@ html.light {
background: #eee; background: #eee;
text-shadow: none; text-shadow: none;
} }
html.light #tt, html.light #tt {
html.light #toast {
background: #fff; background: #fff;
border-color: #888 #000 #777 #000; border-color: #888 #000 #777 #000;
box-shadow: 0 .3em 1em rgba(0,0,0,0.4); }
html.light #tt,
html.light #toast {
box-shadow: 0 .3em 1em rgba(0,0,0,0.4);
} }
html.light #tt code { html.light #tt code {
background: #060; background: #060;

View file

@ -1523,11 +1523,11 @@ var fileman = (function () {
vp = vps.shift(); vp = vps.shift();
if (!vp) { if (!vp) {
toast.show('delete OK', 2000); toast.ok(2000, 'delete OK');
treectl.goto(get_evpath()); treectl.goto(get_evpath());
return; return;
} }
toast.show('deleting ' + (vps.length + 1) + ' items<br /><br />' + vp, 2000); toast.inf(2000, 'deleting ' + (vps.length + 1) + ' items<br /><br />' + vp);
xhr.open('GET', vp + '?delete', true); xhr.open('GET', vp + '?delete', true);
xhr.onreadystatechange = delete_cb; xhr.onreadystatechange = delete_cb;
@ -1539,7 +1539,7 @@ var fileman = (function () {
if (this.status !== 200) { if (this.status !== 200) {
var msg = this.responseText; var msg = this.responseText;
toast.show('delete failed:<br />' + msg, 2000); toast.err(2000, 'delete failed:<br />' + msg);
return; return;
} }
deleter(); deleter();
@ -1564,7 +1564,7 @@ var fileman = (function () {
cl.add(inv ? 'c2' : 'c1'); cl.add(inv ? 'c2' : 'c1');
} }
toast.show('cut ' + sel.length + ' items', 1000); toast.inf(1000, 'cut ' + sel.length + ' items');
jwrite('fman_clip', vps); jwrite('fman_clip', vps);
r.tx(); r.tx();
}; };
@ -1597,6 +1597,9 @@ var fileman = (function () {
if (exists.length) if (exists.length)
alert('these ' + exists.length + ' items cannot be pasted here (names already exist):\n\n' + exists.join('\n')); alert('these ' + exists.length + ' items cannot be pasted here (names already exist):\n\n' + exists.join('\n'));
if (!req.length)
return;
if (!confirm('paste these ' + req.length + ' items here?\n\n' + req.join('\n'))) if (!confirm('paste these ' + req.length + ' items here?\n\n' + req.join('\n')))
return; return;
@ -1605,11 +1608,11 @@ var fileman = (function () {
vp = req.shift(); vp = req.shift();
if (!vp) { if (!vp) {
toast.show('paste OK', 2000); toast.ok(2000, 'paste OK');
treectl.goto(get_evpath()); treectl.goto(get_evpath());
return; return;
} }
toast.show('pasting ' + (req.length + 1) + ' items<br /><br />' + vp, 2000); toast.inf(2000, 'pasting ' + (req.length + 1) + ' items<br /><br />' + vp);
var dst = get_evpath() + vp.split('/').slice(-1)[0]; var dst = get_evpath() + vp.split('/').slice(-1)[0];
@ -1623,7 +1626,7 @@ var fileman = (function () {
if (this.status !== 200) { if (this.status !== 200) {
var msg = this.responseText; var msg = this.responseText;
toast.show('paste failed:<br />' + msg, 2000); toast.err(2000, 'paste failed:<br />' + msg);
return; return;
} }
paster(); paster();

View file

@ -654,11 +654,24 @@ var toast = (function () {
clmod(obj, 'vis'); clmod(obj, 'vis');
}; };
r.show = function (txt, ms) { r.show = function (cl, ms, txt) {
clearTimeout(te); clearTimeout(te);
te = setTimeout(r.hide, ms); te = setTimeout(r.hide, ms);
obj.innerHTML = txt; obj.innerHTML = txt;
clmod(obj, 'vis', 1000); obj.className = cl + ' vis';
};
r.ok = function (ms, txt) {
r.show('ok', ms, txt);
};
r.inf = function (ms, txt) {
r.show('inf', ms, txt);
};
r.warn = function (ms, txt) {
r.show('warn', ms, txt);
};
r.err = function (ms, txt) {
r.show('err', ms, txt);
}; };
return r; return r;