Deduplicated code for image expansion into the page overlay
It now also supports WEBP links, and is compatible with Google Cloud Storage (which adds ?blablabla to links).
This commit is contained in:
@@ -58,27 +58,8 @@ link(href="{{ url_for('static_pillar', filename='assets/css/blog.css', v=1732017
|
||||
| {% endblock %}
|
||||
|
||||
| {% block footer_scripts %}
|
||||
|
||||
script.
|
||||
ProjectUtils.setProjectAttributes({projectId: "{{project._id}}", isProject: false, nodeId: '{{node._id}}'});
|
||||
/* Expand images when their link points to a jpg/png/gif */
|
||||
/* TODO: De-duplicate code from blog index */
|
||||
var page_overlay = document.getElementById('page-overlay');
|
||||
$('.blog_index-item .item-content a img').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var href = $(this).parent().attr('href').split("?")[0];
|
||||
var src = $(this).attr('src');
|
||||
|
||||
if (href.match("jpg$") || href.match("png$") || href.match("gif$")) {
|
||||
|
||||
$(page_overlay)
|
||||
.addClass('active')
|
||||
.html('<img src="' + src + '"/>');
|
||||
} else {
|
||||
window.location.href = href;
|
||||
}
|
||||
});
|
||||
|
||||
/* UI Stuff */
|
||||
var project_container = document.getElementById('project-container');
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
#blog_container(class="{% if project and project._id == config.MAIN_PROJECT_ID %}cloud-blog{% endif %}")
|
||||
|
||||
#blog_post-container
|
||||
#blog_post-container.expand-image-links
|
||||
| {% if project and project._id == config.MAIN_PROJECT_ID %}
|
||||
a.btn.btn-default.button-back(href="{{ url_for('projects.view', project_url=project.url) }}blog")
|
||||
| Back to Blog
|
||||
|
@@ -27,26 +27,6 @@ meta(property="og:image", content="{{ node.picture.thumbnail('l', api=api) }}")
|
||||
|
||||
|
||||
| {% block footer_scripts %}
|
||||
|
||||
script.
|
||||
hopToTop(); // Display jump to top button
|
||||
|
||||
/* Expand images when their link points to a jpg/png/gif */
|
||||
/* TODO: De-duplicate code from view post */
|
||||
var page_overlay = document.getElementById('page-overlay');
|
||||
$('.blog_index-item .item-content a img').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var href = $(this).parent().attr('href').split("?")[0];
|
||||
var src = $(this).attr('src');
|
||||
|
||||
|
||||
if (href.match("jpg$") || href.match("png$") || href.match("gif$")) {
|
||||
$(page_overlay)
|
||||
.addClass('active')
|
||||
.html('<img src="' + src + '"/>');
|
||||
} else {
|
||||
window.location.href = href;
|
||||
}
|
||||
});
|
||||
| {% endblock %}
|
||||
|
Reference in New Issue
Block a user