devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
43 lines (42 loc) • 1.18 kB
JavaScript
/**
* DevExtreme (esm/__internal/scheduler/loading.js)
* Version: 26.1.3
* Build date: Wed Jun 10 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import $ from "../../core/renderer";
import {
value as viewPort
} from "../../core/utils/view_port";
import LoadPanel from "../../ui/load_panel";
let loading = null;
const createLoadPanel = options => {
const $container = $("<div>").appendTo((null === options || void 0 === options ? void 0 : options.container) ?? viewPort());
return new LoadPanel($container.get(0), options)
};
const removeLoadPanel = () => {
if (!loading) {
return
}
loading.$element().remove();
loading = null
};
export function show(options) {
removeLoadPanel();
loading = createLoadPanel(options);
return loading.show()
}
export function hide() {
if (!loading) {
return Promise.resolve(void 0)
}
const instance = loading;
return instance.hide().then(result => {
if (loading === instance) {
removeLoadPanel()
}
return result
})
}