2022-08-20 02:42:12 +08:00

45 lines
1.2 KiB
TypeScript

import { Addon } from "./addon";
import AddonModule from "./module";
const { addonRef } = require("../package.json");
class AddonViews extends AddonModule {
// You can store some element in the object attributes
private testButton: XUL.Button;
private progressWindowIcon: object;
constructor(parent: Addon) {
super(parent);
this.progressWindowIcon = {
success: "chrome://zotero/skin/tick.png",
fail: "chrome://zotero/skin/cross.png",
default: `chrome://${addonRef}/skin/favicon.png`,
};
}
public initViews() {
// You can init the UI elements that
// cannot be initialized with overlay.xul
}
public showProgressWindow(
header: string,
context: string,
type: string = "default",
t: number = 5000
) {
// A simple wrapper of the Zotero ProgressWindow
let progressWindow = new Zotero.ProgressWindow({ closeOnClick: true });
progressWindow.changeHeadline(header);
progressWindow.progress = new progressWindow.ItemProgress(
this.progressWindowIcon[type],
context
);
progressWindow.show();
if (t > 0) {
progressWindow.startCloseTimer(t);
}
}
}
export default AddonViews;