ok-admin/lib/loading/okLoading.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-11-08 07:28:28 +00:00
var ok_load_options = {
time: 1000,
content: "ok-admin..."
};
!function (content, options) {
2019-12-08 15:13:34 +00:00
2019-11-07 16:58:19 +00:00
function templateFun(options) {
2019-11-08 07:28:28 +00:00
return `<div class="ok-loading">
2019-12-08 15:13:34 +00:00
<div class="ball-loader">
<span></span><span></span><span></span><span></span>
</div>
</div>`;
2019-11-07 16:58:19 +00:00
}
function headerInit(content, options) {
options = options || {};
if (typeof content == "string") {
2019-11-08 07:28:28 +00:00
options["content"] = content || ok_load_options.content;
2019-11-07 16:58:19 +00:00
} else if (typeof content == "object") {
options = content;
}
2019-11-08 07:28:28 +00:00
options.time = options.time || ok_load_options.time;
options.content = options.content || ok_load_options.content;
2019-11-07 16:58:19 +00:00
return options;
}
2019-11-08 07:28:28 +00:00
ok_load_options = headerInit(content, options);
var template = templateFun(ok_load_options);
document.writeln(template);
}();
var okLoading = {
2019-12-08 15:13:34 +00:00
close: function (time, dom) {
2019-11-08 07:28:28 +00:00
time = time || ok_load_options.time;
2019-11-08 15:54:40 +00:00
dom = dom || document.getElementsByClassName("ok-loading")[0];
2019-12-08 15:13:34 +00:00
var setTime1 = setTimeout(function () {
clearTimeout(setTime1);
dom.classList.add("close");
var setTime2 = setTimeout(function () {
clearTimeout(setTime2);
dom.parentNode.removeChild(dom);/**删除当前节点*/
}, 800);
}, time);
2019-11-08 07:28:28 +00:00
}
};