Notes/src/public/app/widgets/spacer.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-05-17 21:46:18 +02:00
import BasicWidget from "./basic_widget.js";
2022-12-22 14:57:00 +01:00
import contextMenu from "../menus/context_menu.js";
import appContext from "../components/app_context.js";
2021-05-17 21:46:18 +02:00
2021-05-24 22:29:49 +02:00
const TPL = `<div class="spacer"></div>`;
2021-05-17 21:46:18 +02:00
export default class SpacerWidget extends BasicWidget {
2022-08-06 13:47:27 +02:00
constructor(baseSize = 0, growthFactor = 1000) {
2021-05-24 22:29:49 +02:00
super();
this.baseSize = baseSize;
2022-08-06 13:47:27 +02:00
this.growthFactor = growthFactor;
2021-05-24 22:29:49 +02:00
}
2021-05-17 21:46:18 +02:00
doRender() {
this.$widget = $(TPL);
this.$widget.css("flex-basis", this.baseSize);
2022-08-06 13:47:27 +02:00
this.$widget.css("flex-grow", this.growthFactor);
this.$widget.css("flex-shrink", 1000);
2022-12-22 14:57:00 +01:00
this.$widget.on("contextmenu", e => {
this.$widget.tooltip("hide");
contextMenu.show({
x: e.pageX,
y: e.pageY,
items: [
{title: "Configure Launchbar", command: "showLaunchBarSubtree", uiIcon: "bx bx-sidebar"}
],
selectMenuItemHandler: ({command}) => {
appContext.triggerCommand(command);
}
});
return false; // blocks default browser right click menu
2022-12-22 14:57:00 +01:00
});
2021-05-17 21:46:18 +02:00
}
}