mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-06 18:38:31 +02:00

* extract generic behaviors * preserve query string when refreshing content * refactor details modal refresh * refactor bulk edit * update tests * restore tag modal * Make IntelliJ aware of custom attributes * improve e2e test coverage
29 lines
794 B
JavaScript
29 lines
794 B
JavaScript
import { registerBehavior } from "./index";
|
|
|
|
class BookmarkItem {
|
|
constructor(element) {
|
|
this.element = 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");
|
|
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);
|