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

71 lines
1.8 KiB
JavaScript
Raw Normal View History

import NoteContextAwareWidget from "../note_context_aware_widget.js";
2022-06-21 23:27:34 +02:00
const TPL = `
<div class="floating-buttons">
<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
.floating-buttons-children > *:not(.hidden-int):not(.no-content-hidden) {
margin-left: 10px;
}
2022-12-11 13:20:37 +01:00
.floating-buttons-children > button {
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
}
.floating-buttons.temporarily-hidden {
display: none;
}
2022-06-21 23:27:34 +02:00
</style>
<div class="floating-buttons-children"></div>
</div>`;
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());
}
}
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
}