import { shortcut, emptyFn } from "@/core"; import { Single } from "../0.single"; @shortcut() class LoadingBar extends Single { static xtype = "bi.loading_bar"; _defaultConfig() { const conf = super._defaultConfig.apply(this, arguments); return { ...conf, baseCls: `${conf.baseCls || ""} bi-loading-bar bi-tips`, height: 30, handler: emptyFn, }; } render() { this.loaded = BI.createWidget({ type: "bi.text_button", cls: "loading-text bi-list-item-simple", text: BI.i18nText("BI-Load_More"), width: 120, handler: this.options.handler, }); this.loaded.on(BI.Controller.EVENT_CHANGE, (...args) => { this.fireEvent(BI.Controller.EVENT_CHANGE, args); }); this.loading = BI.createWidget({ type: "bi.layout", width: this.options.height, height: this.options.height, cls: "loading-background cursor-default", }); const loaded = BI.createWidget({ type: "bi.center_adapt", items: [this.loaded], }); const loading = BI.createWidget({ type: "bi.center_adapt", items: [this.loading], }); this.cardLayout = BI.createWidget({ type: "bi.card", element: this, items: [ { el: loaded, cardName: "loaded", }, { el: loading, cardName: "loading", } ], }); this.invisible(); } _reset() { this.visible(); this.loaded.setText(BI.i18nText("BI-Load_More")); this.loaded.enable(); } setLoaded() { this._reset(); this.cardLayout.showCardByName("loaded"); } setEnd() { this.setLoaded(); this.loaded.setText(BI.i18nText("BI-No_More_Data")); this.loaded.disable(); } setLoading() { this._reset(); this.cardLayout.showCardByName("loading"); } }