add edit link
This commit is contained in:
parent
d580ec92f6
commit
908aecce15
4 changed files with 31 additions and 4 deletions
|
@ -93,7 +93,8 @@
|
|||
.close:hover {
|
||||
color: white !important;
|
||||
}
|
||||
.download.disabled {
|
||||
.download.disabled,
|
||||
.edit.disabled {
|
||||
display: none;
|
||||
}
|
||||
.download {
|
||||
|
@ -104,7 +105,15 @@
|
|||
right: 24px
|
||||
|
||||
}
|
||||
.download:hover {
|
||||
.edit {
|
||||
color: lightgray !important;
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: 4px
|
||||
}
|
||||
.download:hover,
|
||||
.edit:hover {
|
||||
color: white !important;
|
||||
}
|
||||
@media screen and (max-width: 39.9375em) {
|
||||
|
|
|
@ -28,7 +28,8 @@ function loadGalleries() {
|
|||
let photo = {
|
||||
src: src,
|
||||
caption: img.dataset.caption,
|
||||
orig: img.dataset.orig
|
||||
orig: img.dataset.orig,
|
||||
edit: img.dataset.edit
|
||||
}
|
||||
photos.push(photo)
|
||||
img.parentElement.addEventListener("click", event => {
|
||||
|
@ -82,6 +83,7 @@ function loadGallery(images, idx, main, thumbnails) {
|
|||
<button class="next nav-btn">Next ❯</button>
|
||||
</div>
|
||||
<button class="close">✖</button>
|
||||
<a class="edit disabled" target="_blank" title="edit">✎</a>
|
||||
<a class="download disabled" target="_blank" download title="download original">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 304 384"><path fill="currentColor" d="M299 128L149 277L0 128h85V0h128v128h86zM0 320h299v43H0v-43z"/></svg>
|
||||
</a>
|
||||
|
@ -111,6 +113,7 @@ function loadGallery(images, idx, main, thumbnails) {
|
|||
const prevBtn = gallery.querySelector(".prev.nav-btn");
|
||||
const nextBtn = gallery.querySelector(".next.nav-btn");
|
||||
const download = gallery.querySelector(".download");
|
||||
const edit = gallery.querySelector(".edit");
|
||||
let thumbnailsContainer
|
||||
if (idx != 'inline') {
|
||||
thumbnailsContainer = gallery.querySelector(".thumbnails");
|
||||
|
@ -153,6 +156,13 @@ function loadGallery(images, idx, main, thumbnails) {
|
|||
download.href = ""
|
||||
download.classList.add('disabled')
|
||||
}
|
||||
if (images[index].edit) {
|
||||
edit.href = images[index].edit
|
||||
edit.classList.remove('disabled')
|
||||
} else {
|
||||
edit.href = ""
|
||||
edit.classList.add('disabled')
|
||||
}
|
||||
prevBtn.disabled = index === 0;
|
||||
nextBtn.disabled = index === images.length - 1;
|
||||
if (idx == 'inline') {
|
||||
|
|
|
@ -2,7 +2,12 @@
|
|||
<h6><strong>{{gallery.title}}</strong></h6>
|
||||
<ul class="clearing-thumbs gallery" data-clearing>
|
||||
{% for photo in gallery.public %}
|
||||
<li><a href="{{ gallery.get_absolute_url }}#{{forloop.counter}}"><img src="{{ photo.get_thumbnail_url }}" class="photo" data-caption="{{ photo.caption_html }}"{% if request.user.is_staff %} data-orig="{{ photo.image.url }}"{% endif %}></a></li>
|
||||
<li><a href="{{ gallery.get_absolute_url }}#{{forloop.counter}}"><img src="{{ photo.get_thumbnail_url }}"
|
||||
class="photo"
|
||||
data-caption="{{ photo.caption_html }}"
|
||||
{% if request.user.is_staff %}data-orig="{{ photo.image.url }}"{% endif %}
|
||||
{% if request.user.is_staff %}data-edit="{{ photo.edit_url }}"{% endif %}
|
||||
></a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
|
@ -597,6 +597,9 @@ class Photo(ImageModel):
|
|||
return mark_safe(markdownify(caption))
|
||||
return caption
|
||||
|
||||
def edit_url(self):
|
||||
return '/admin/photologue/photo/%s/change/' % self.id
|
||||
|
||||
class BaseEffect(models.Model):
|
||||
name = models.CharField(_('name'),
|
||||
max_length=30,
|
||||
|
|
Loading…
Add table
Reference in a new issue