Biblio for sites

This commit is contained in:
2024-11-28 10:13:14 +01:00
parent 9954c797e0
commit 2129fab101
5 changed files with 71 additions and 18 deletions

View File

@@ -5,11 +5,16 @@ export default class extends Controller {
open(event) {
const biblio = window.Biblio;
const target = event.currentTarget;
const id = target.id.replace('cit-', '');
this.biblioTarget.innerHTML = '<button class="delete" data-action="click->biblio#hideBiblio"></button>';
this.biblioTarget.innerHTML += biblio.getReference(id);
this.trigger = event.currentTarget;
const id = this.trigger.id.replace('cit-', '');
this.ref = this.biblioTarget;
if (this.trigger.parentElement.nodeName === 'TD') {
this.ref = this.biblioTargets.find(t => t.id === 'biblio-detail');
}
this.ref.innerHTML = '<button class="delete" data-action="click->biblio#hideBiblio"></button>';
this.ref.innerHTML += biblio.getReference(id);
this.showBiblio();
}
@@ -19,11 +24,12 @@ export default class extends Controller {
}
showBiblio() {
this.biblioTarget.classList.remove('is-hidden');
this.biblioTarget.scrollIntoView({behavior: 'smooth'});
this.ref.classList.remove('is-hidden');
this.ref.scrollIntoView({behavior: 'smooth'});
}
hideBiblio() {
this.biblioTarget.classList.add('is-hidden');
this.ref.classList.add('is-hidden');
this.trigger.parentElement.scrollIntoView({behavior: 'smooth'});
}
}