mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-09 03:37:54 +02:00

* return updated HTML from bookmark actions * open details through URL * fix details update * improve modal behavior * use a frame * make behaviors properly destroy themselves * remove page and details params from tag urls * use separate behavior for details and tags * remove separate details view * make it work with other views * add asset actions * remove asset refresh for now * remove details partial * fix tests * remove old partials * update tests * cache and reuse tags * extract search autocomplete behavior * remove details param from pagination * fix tests * only return details modal when navigating in frame * fix link target * remove unused behaviors * use auto submit behavior for user select * fix import
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
import { Behavior, registerBehavior } from "./index";
|
|
|
|
class BookmarkItem extends Behavior {
|
|
constructor(element) {
|
|
super(element);
|
|
|
|
// Toggle notes
|
|
this.onToggleNotes = this.onToggleNotes.bind(this);
|
|
this.notesToggle = element.querySelector(".toggle-notes");
|
|
if (this.notesToggle) {
|
|
this.notesToggle.addEventListener("click", this.onToggleNotes);
|
|
}
|
|
|
|
// 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;
|
|
}
|
|
});
|
|
}
|
|
|
|
destroy() {
|
|
if (this.notesToggle) {
|
|
this.notesToggle.removeEventListener("click", this.onToggleNotes);
|
|
}
|
|
}
|
|
|
|
onToggleNotes(event) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
this.element.classList.toggle("show-notes");
|
|
}
|
|
}
|
|
|
|
registerBehavior("ld-bookmark-item", BookmarkItem);
|