2024-08-05 09:49:52 +08:00
|
|
|
import { t } from "../../services/i18n.js";
|
2022-06-21 23:27:34 +02:00
|
|
|
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
|
|
|
|
|
|
|
const TPL = `
|
2022-12-20 20:20:24 +01:00
|
|
|
<div class="relation-map-buttons">
|
|
|
|
<style>
|
2022-12-23 19:47:49 +01:00
|
|
|
.relation-map-buttons {
|
|
|
|
display: flex;
|
|
|
|
gap: 10px;
|
2022-12-20 20:20:24 +01:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2022-07-24 14:30:42 +02:00
|
|
|
<button type="button"
|
2022-12-20 23:20:59 +01:00
|
|
|
class="relation-map-create-child-note floating-button btn bx bx-folder-plus"
|
2025-01-09 18:07:02 +02:00
|
|
|
title="${t("relation_map_buttons.create_child_note_title")}"></button>
|
2025-01-20 22:50:36 +02:00
|
|
|
|
2022-06-21 23:27:34 +02:00
|
|
|
<button type="button"
|
2022-12-20 23:20:59 +01:00
|
|
|
class="relation-map-reset-pan-zoom floating-button btn bx bx-crop"
|
2025-01-09 18:07:02 +02:00
|
|
|
title="${t("relation_map_buttons.reset_pan_zoom_title")}"></button>
|
2025-01-20 22:50:36 +02:00
|
|
|
|
2022-12-20 23:20:59 +01:00
|
|
|
<div class="btn-group">
|
2022-06-21 23:27:34 +02:00
|
|
|
<button type="button"
|
2022-07-24 14:30:42 +02:00
|
|
|
class="relation-map-zoom-in floating-button btn bx bx-zoom-in"
|
2025-01-09 18:07:02 +02:00
|
|
|
title="${t("relation_map_buttons.zoom_in_title")}"></button>
|
2025-01-20 22:50:36 +02:00
|
|
|
|
2022-06-21 23:27:34 +02:00
|
|
|
<button type="button"
|
2022-07-24 14:30:42 +02:00
|
|
|
class="relation-map-zoom-out floating-button btn bx bx-zoom-out"
|
2025-01-09 18:07:02 +02:00
|
|
|
title="${t("relation_map_buttons.zoom_out_title")}"></button>
|
2022-06-21 23:27:34 +02:00
|
|
|
</div>
|
|
|
|
</div>`;
|
|
|
|
|
|
|
|
export default class RelationMapButtons extends NoteContextAwareWidget {
|
2025-02-28 17:55:32 +02:00
|
|
|
|
|
|
|
private $createChildNote!: JQuery<HTMLElement>;
|
|
|
|
private $zoomInButton!: JQuery<HTMLElement>;
|
|
|
|
private $zoomOutButton!: JQuery<HTMLElement>;
|
|
|
|
private $resetPanZoomButton!: JQuery<HTMLElement>;
|
|
|
|
|
2022-07-03 23:10:13 +02:00
|
|
|
isEnabled() {
|
2025-01-09 18:07:02 +02:00
|
|
|
return super.isEnabled() && this.note?.type === "relationMap";
|
2022-07-03 23:10:13 +02:00
|
|
|
}
|
|
|
|
|
2022-06-21 23:27:34 +02:00
|
|
|
doRender() {
|
|
|
|
super.doRender();
|
|
|
|
|
|
|
|
this.$widget = $(TPL);
|
|
|
|
this.$createChildNote = this.$widget.find(".relation-map-create-child-note");
|
|
|
|
this.$zoomInButton = this.$widget.find(".relation-map-zoom-in");
|
|
|
|
this.$zoomOutButton = this.$widget.find(".relation-map-zoom-out");
|
|
|
|
this.$resetPanZoomButton = this.$widget.find(".relation-map-reset-pan-zoom");
|
|
|
|
|
2025-01-20 22:50:36 +02:00
|
|
|
// TODO: Deduplicate object creation here.
|
2025-01-09 18:07:02 +02:00
|
|
|
this.$createChildNote.on("click", () => this.triggerEvent("relationMapCreateChildNote", { ntxId: this.ntxId }));
|
|
|
|
this.$resetPanZoomButton.on("click", () => this.triggerEvent("relationMapResetPanZoom", { ntxId: this.ntxId }));
|
2022-06-21 23:27:34 +02:00
|
|
|
|
2025-01-09 18:07:02 +02:00
|
|
|
this.$zoomInButton.on("click", () => this.triggerEvent("relationMapResetZoomIn", { ntxId: this.ntxId }));
|
|
|
|
this.$zoomOutButton.on("click", () => this.triggerEvent("relationMapResetZoomOut", { ntxId: this.ntxId }));
|
2022-07-24 14:30:42 +02:00
|
|
|
this.contentSized();
|
2022-06-21 23:27:34 +02:00
|
|
|
}
|
|
|
|
}
|