From 350577033c86e49d91185df52c68b939e44d6d3a Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Fri, 20 Jan 2017 12:38:50 +0100 Subject: [PATCH] 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. --- src/templates/nodes/custom/blog/index.jade | 17 +++++++++++++++++ src/templates/nodes/custom/post/view.jade | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/templates/nodes/custom/blog/index.jade b/src/templates/nodes/custom/blog/index.jade index 718c84a4..79c05b63 100644 --- a/src/templates/nodes/custom/blog/index.jade +++ b/src/templates/nodes/custom/blog/index.jade @@ -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(''); + } else { + window.location.href = href; + } + }); | {% endblock %} diff --git a/src/templates/nodes/custom/post/view.jade b/src/templates/nodes/custom/post/view.jade index 77abd8ea..9b6d873c 100644 --- a/src/templates/nodes/custom/post/view.jade +++ b/src/templates/nodes/custom/post/view.jade @@ -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(''); + } else { + window.location.href = href; + } + }); | {% endblock %}