mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-22 11:23:02 +00:00
1b7731e506
* add destroy hook * refresh details modal in interval * refactor to refresh assets list * disable create snapshot button when there is a pending snapshot
30 lines
861 B
JavaScript
30 lines
861 B
JavaScript
import { Behavior, registerBehavior } from "./index";
|
|
|
|
class BookmarkItem extends Behavior {
|
|
constructor(element) {
|
|
super(element);
|
|
|
|
// Toggle notes
|
|
const notesToggle = element.querySelector(".toggle-notes");
|
|
if (notesToggle) {
|
|
notesToggle.addEventListener("click", this.onToggleNotes.bind(this));
|
|
}
|
|
|
|
// Add tooltip to title if it is truncated
|
|
const titleAnchor = element.querySelector(".title > a");
|
|
const titleSpan = titleAnchor.querySelector("span");
|
|
requestAnimationFrame(() => {
|
|
if (titleSpan.offsetWidth > titleAnchor.offsetWidth) {
|
|
titleAnchor.dataset.tooltip = titleSpan.textContent;
|
|
}
|
|
});
|
|
}
|
|
|
|
onToggleNotes(event) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
this.element.classList.toggle("show-notes");
|
|
}
|
|
}
|
|
|
|
registerBehavior("ld-bookmark-item", BookmarkItem);
|