2022-09-18 14:57:44 +02:00
|
|
|
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
2022-06-21 23:27:34 +02:00
|
|
|
|
|
|
|
const TPL = `
|
2022-12-20 23:20:59 +01:00
|
|
|
<div class="floating-buttons no-print">
|
2022-06-21 23:27:34 +02:00
|
|
|
<style>
|
|
|
|
.floating-buttons {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
|
|
|
.floating-buttons-children {
|
|
|
|
position: absolute;
|
|
|
|
top: 10px;
|
|
|
|
right: 10px;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
z-index: 100;
|
|
|
|
}
|
2022-07-24 14:30:42 +02:00
|
|
|
|
2022-09-18 14:57:44 +02:00
|
|
|
.floating-buttons-children > *:not(.hidden-int):not(.no-content-hidden) {
|
2022-07-28 23:59:41 +02:00
|
|
|
margin-left: 10px;
|
|
|
|
}
|
|
|
|
|
2022-12-11 13:20:37 +01:00
|
|
|
.floating-buttons-children > button {
|
2022-12-20 20:20:24 +01:00
|
|
|
font-size: 150%;
|
2022-07-24 14:30:42 +02:00
|
|
|
padding: 5px 10px 4px 10px;
|
2022-12-11 13:20:37 +01:00
|
|
|
width: 40px;
|
|
|
|
cursor: pointer;
|
|
|
|
color: var(--button-text-color);
|
|
|
|
background: var(--button-background-color);
|
|
|
|
border-radius: var(--button-border-radius);
|
|
|
|
border: 1px solid transparent;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-around;
|
|
|
|
}
|
|
|
|
|
|
|
|
.floating-buttons-children > button:hover {
|
|
|
|
text-decoration: none;
|
|
|
|
border-color: var(--button-border-color);
|
2022-07-24 14:30:42 +02:00
|
|
|
}
|
2022-09-18 14:57:44 +02:00
|
|
|
|
|
|
|
.floating-buttons.temporarily-hidden {
|
|
|
|
display: none;
|
|
|
|
}
|
2022-06-21 23:27:34 +02:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<div class="floating-buttons-children"></div>
|
|
|
|
</div>`;
|
|
|
|
|
2022-09-18 14:57:44 +02:00
|
|
|
export default class FloatingButtons extends NoteContextAwareWidget {
|
2022-06-21 23:27:34 +02:00
|
|
|
doRender() {
|
|
|
|
this.$widget = $(TPL);
|
|
|
|
this.$children = this.$widget.find(".floating-buttons-children");
|
|
|
|
|
|
|
|
for (const widget of this.children) {
|
|
|
|
this.$children.append(widget.render());
|
|
|
|
}
|
|
|
|
}
|
2022-09-18 14:57:44 +02:00
|
|
|
|
|
|
|
async refreshWithNote(note) {
|
|
|
|
this.toggle(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
toggle(show) {
|
|
|
|
this.$widget.toggleClass("temporarily-hidden", !show);
|
|
|
|
}
|
|
|
|
|
|
|
|
hideFloatingButtonsCommand() {
|
|
|
|
this.toggle(false);
|
|
|
|
}
|
2022-06-21 23:27:34 +02:00
|
|
|
}
|