2016-06-09 23:54:03 -07:00
|
|
|
define(['css!./toast'], function () {
|
2016-02-16 09:15:36 -07:00
|
|
|
|
2016-06-09 23:54:03 -07:00
|
|
|
function remove(elem) {
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
elem.parentNode.removeChild(elem);
|
|
|
|
}, 300);
|
|
|
|
}
|
|
|
|
|
|
|
|
function animateRemove(elem) {
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
|
|
elem.classList.remove('visible');
|
|
|
|
remove(elem);
|
|
|
|
|
|
|
|
}, 3300);
|
|
|
|
}
|
2016-02-16 09:15:36 -07:00
|
|
|
|
|
|
|
return function (options) {
|
|
|
|
|
2016-02-24 23:38:12 -07:00
|
|
|
if (typeof options === 'string') {
|
|
|
|
options = {
|
|
|
|
text: options
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-06-09 23:54:03 -07:00
|
|
|
var elem = document.createElement("div");
|
|
|
|
elem.classList.add('toast');
|
|
|
|
elem.innerHTML = options.text;
|
2016-02-16 09:15:36 -07:00
|
|
|
|
|
|
|
document.body.appendChild(elem);
|
|
|
|
|
|
|
|
setTimeout(function () {
|
2016-06-09 23:54:03 -07:00
|
|
|
elem.classList.add('visible');
|
|
|
|
|
|
|
|
animateRemove(elem);
|
|
|
|
|
2016-02-16 09:15:36 -07:00
|
|
|
}, 300);
|
|
|
|
};
|
|
|
|
});
|