related photos

This commit is contained in:
root 2017-12-23 12:19:35 +00:00
parent daf305d123
commit 01afa5aa3f
3 changed files with 57 additions and 53 deletions

View File

@ -51,21 +51,27 @@
<script src="{% static "js/jquery.bxslider.js" %}"></script> <script src="{% static "js/jquery.bxslider.js" %}"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
var slider = $('.slider1').bxSlider({ slider = $('.slider1').bxSlider({
adaptiveHeight : true, adaptiveHeight : true,
pager : false, pager : false,
}); });
document.querySelectorAll('.select-image').forEach(function(a) {
a.onclick = function(event) {
event.preventDefault();
slider.goToSlide(this.dataset.id)
};
});
$(document).keydown(function(e){ $(document).keydown(function(e){
if (e.keyCode == 39) // Right arrow if (e.keyCode == 39) // Right arrow
{ {
slider.goToNextSlide(); slider && slider.goToNextSlide();
return false; return false;
} }
else if (e.keyCode == 37) // left arrow else if (e.keyCode == 37) // left arrow
{ {
slider.goToPrevSlide(); slider && slider.goToPrevSlide();
return false; return false;
} }
}); });

View File

@ -15,5 +15,4 @@
{% endfor %} {% endfor %}
<div><a href="{% url 'photologue:gallery-list' %}" class="btn btn-default">{% trans "View all galleries" %}</a></div> <div><a href="{% url 'photologue:gallery-list' %}" class="btn btn-default">{% trans "View all galleries" %}</a></div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -12,38 +12,37 @@
{% endif %} {% endif %}
<h5>{{ gallery.title }}</h5> <h5>{{ gallery.title }}</h5>
<ul class="slider1"> <ul class="slider1">
{% for photo.pk in gallery.public %}
<li>
<img src="{{ photo.get_display_url }}" alt="{{ photo.title }}">
<br /> <p>{{ photo.caption|safe }} <a href="{{ photo.image.url }}"> Link to original file </a> </p>
</li>
{% for photo in gallery.public %} {% for photo in gallery.public %}
<li> <li id="slide-{{photo.slug}}">
<img src="{{ photo.get_display_url }}" alt="{{ photo.title }}"> <img src="{{ photo.get_display_url }}" alt="{{ photo.title }}">
<br /> <p>{{ photo.caption|safe }} <a href="{{ photo.image.url }}" target="_blank" > Link to original file </a> </p> <p>
{{ photo.caption|safe }}
{% if photo.caption %}<br>{%endif%}
<a href="{{ photo.image.url }}" target="_blank" >Link to original file</a>
</p>
</li> </li>
{% endfor %} {% endfor %}
{% endfor %}
</ul> </ul>
}
</div> </div>
<div class="medium-3 columns"> <div class="medium-3 columns">
{% if object.public_galleries %} {% if object.public_galleries %}
<br>
<p>{% trans "Other photos" %}:</p> <p>{% trans "Other photos" %}:</p>
<table> <div>
{% for photo in gallery.public %} {% for photo in gallery.public %}
<tr> <div style="float: left; padding: 4px">
<td><a href="{{ photo.get_absolute_url }}"> <a href="{{ photo.get_absolute_url }}" class="select-image" data-id="{{forloop.counter}}">
<img src="{{ photo.get_thumbnail_url }}" class="thumbnail" alt="{{ photo.title }}"></a></td> <img src="{{ photo.get_thumbnail_url }}" class="thumbnail" alt="{{ photo.title }}">
<td> </a>
<p>{{ photo.caption|safe }} {{ photo.count }} </p> </div>
</td>
</tr>
{% endfor %} {% endfor %}
</table> </div>
{% endif %} {% endif %}
{% endfor %}
</div> </div>
</div> </div>
{% endfor %}
<script>
</script>
{% endblock %} {% endblock %}