Notes/src/public/app/widgets/floating_buttons/relation_map_buttons.js

46 lines
1.9 KiB
JavaScript
Raw Normal View History

2022-06-21 23:27:34 +02:00
import NoteContextAwareWidget from "../note_context_aware_widget.js";
const TPL = `
<div>
2022-07-24 14:30:42 +02:00
<button type="button"
class="relation-map-create-child-note floating-button btn bx bx-folder-plus no-print"
title="Create new child note and add it into this relation map"></button>
2022-06-21 23:27:34 +02:00
<button type="button"
2022-07-24 14:30:42 +02:00
class="relation-map-reset-pan-zoom floating-button btn bx bx-crop no-print"
title="Reset pan & zoom to initial coordinates and magnification"></button>
2022-06-21 23:27:34 +02:00
2022-07-24 14:30:42 +02:00
<div class="btn-group no-print">
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"
2022-06-21 23:27:34 +02:00
title="Zoom In"></button>
<button type="button"
2022-07-24 14:30:42 +02:00
class="relation-map-zoom-out floating-button btn bx bx-zoom-out"
2022-06-21 23:27:34 +02:00
title="Zoom Out"></button>
</div>
</div>`;
export default class RelationMapButtons extends NoteContextAwareWidget {
isEnabled() {
2022-12-06 23:01:42 +01:00
return super.isEnabled() && this.note?.type === 'relationMap';
}
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");
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
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
}
}