xx-common
Version:
the functions of yd common
43 lines (42 loc) • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var global = {
toast: function (msg, duration) {
if (duration === void 0) { duration = 2500; }
var messageRoot = document.createElement("div");
messageRoot.className = "yd-message";
var message = document.createElement("span");
if (message.insertAdjacentText) {
message.insertAdjacentText("afterbegin", msg);
}
else {
message.appendChild(msg);
}
if (messageRoot.insertAdjacentElement)
messageRoot.insertAdjacentElement("afterbegin", message);
else
messageRoot.appendChild(message);
var rootId = document.getElementById("app");
var ydMessage = document.querySelector(".yd-message");
if (ydMessage)
ydMessage.remove();
if (!rootId)
return;
if (rootId.insertAdjacentElement) {
rootId.insertAdjacentElement("afterbegin", messageRoot);
}
else {
rootId.appendChild(messageRoot);
}
setTimeout(function () {
ydMessage = document.querySelector(".yd-message");
if (ydMessage)
ydMessage.remove();
}, duration);
},
};
exports.default = (function () {
if (typeof window.global == "undefined") {
window.global = global;
}
});