Blog: Expand images when clicking on them (and the link is an image)

Duplicated in both index/view post to get it out for today's Cycles post, wrote a note to fix this.
This commit is contained in:
Pablo Vazquez 2017-01-20 12:38:50 +01:00
parent eb5fb4eb09
commit 350577033c
2 changed files with 34 additions and 0 deletions

View File

@ -133,4 +133,21 @@ script.
}
});
/* Expand images when their link points to a jpg/png/gif */
/* TODO: De-duplicate code from view post */
$('.blog_index-item .item-content a img').on('click', function(e){
e.preventDefault();
var href = $(this).parent().attr('href');
var src = $(this).attr('src');
if (href.match("jpg$") || href.match("png$") || href.match("gif$")) {
var page_overlay = document.getElementById('page-overlay');
$(page_overlay)
.addClass('active')
.html('<img src="' + src + '"/>');
} else {
window.location.href = href;
}
});
| {% endblock %}

View File

@ -105,4 +105,21 @@ script.
}
});
/* Expand images when their link points to a jpg/png/gif */
/* TODO: De-duplicate code from blog index */
$('.blog_index-item .item-content a img').on('click', function(e){
e.preventDefault();
var href = $(this).parent().attr('href');
var src = $(this).attr('src');
if (href.match("jpg$") || href.match("png$") || href.match("gif$")) {
var page_overlay = document.getElementById('page-overlay');
$(page_overlay)
.addClass('active')
.html('<img src="' + src + '"/>');
} else {
window.location.href = href;
}
});
| {% endblock %}