1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/toast/toast.js

42 lines
831 B
JavaScript
Raw Normal View History

2016-06-10 02:54:03 -04:00
define(['css!./toast'], function () {
2016-10-18 01:06:48 -04:00
'use strict';
2016-02-16 11:15:36 -05:00
2016-06-10 02:54:03 -04:00
function remove(elem) {
setTimeout(function () {
elem.parentNode.removeChild(elem);
}, 300);
}
function animateRemove(elem) {
setTimeout(function () {
2016-08-02 01:55:52 -04:00
elem.classList.remove('toastVisible');
2016-06-10 02:54:03 -04:00
remove(elem);
}, 3300);
}
2016-02-16 11:15:36 -05:00
return function (options) {
2016-02-25 01:38:12 -05:00
if (typeof options === 'string') {
options = {
text: options
};
}
2016-06-10 02:54:03 -04:00
var elem = document.createElement("div");
elem.classList.add('toast');
elem.innerHTML = options.text;
2016-02-16 11:15:36 -05:00
document.body.appendChild(elem);
setTimeout(function () {
2016-08-02 01:55:52 -04:00
elem.classList.add('toastVisible');
2016-06-10 02:54:03 -04:00
animateRemove(elem);
2016-02-16 11:15:36 -05:00
}, 300);
};
});