/* * Custom LightGallery plugin to add some buttons for administration * * SPDX-License-Identifier: GPL-3.0-or-later */ class lgAdmin { constructor(instance, $LG) { this.core = instance; this.$LG = $LG; this.isStaff = instance.settings.isStaff; return this; } init() { const adminIcon = ""; const deleteIcon = "";; const reportIcon = ""; // Add button linking to Django admin page this.core.$toolbar.append(`${adminIcon}`); document.getElementById("lg-admin").style.display = this.isStaff ? 'block' : 'none'; // Add button to delete photo this.core.$toolbar.append(`${deleteIcon}`); document.getElementById("lg-delete").style.display = this.isStaff ? 'block' : 'none'; // Add button to report photo this.core.$toolbar.append(`${reportIcon}`); this.core.LGel.on("lgAfterSlide.admin", this.onAfterSlide.bind(this)); } onAfterSlide(event) { const photoId = this.core.galleryItems[event.detail.index].slideName; document.getElementById("lg-admin").href = `https://photos.crans.org/admin/photologue/photo/${photoId}/change/`; } // Plugins must have destroy prototype destroy() { } }