2016-06-09 23:54:03 -07:00
|
|
|
define(['css!./toast'], function () {
|
2016-10-17 22:06:48 -07:00
|
|
|
'use strict';
|
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 () {
|
|
|
|
|
2016-08-01 22:55:52 -07:00
|
|
|
elem.classList.remove('toastVisible');
|
2016-06-09 23:54:03 -07:00
|
|
|
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-08-01 22:55:52 -07:00
|
|
|
elem.classList.add('toastVisible');
|
2016-06-09 23:54:03 -07:00
|
|
|
|
|
|
|
animateRemove(elem);
|
|
|
|
|
2016-02-16 09:15:36 -07:00
|
|
|
}, 300);
|
|
|
|
};
|
|
|
|
});
|