diff --git a/src/templates/nodes/custom/_scripts.jade b/src/templates/nodes/custom/_scripts.jade index 2853cad8..7c72d4d4 100644 --- a/src/templates/nodes/custom/_scripts.jade +++ b/src/templates/nodes/custom/_scripts.jade @@ -14,6 +14,22 @@ script(type="text/javascript"). ProjectUtils.setProjectAttributes({isProject: false}); + // Click anywhere in the page to hide the overlay + var page_overlay = document.getElementById('page-overlay'); + + function hidePageOverlay() { + $(page_overlay) + .removeAttr('class') + .html(''); + } + + $(page_overlay).click(function(e) { + e.stopPropagation(); + e.preventDefault(); + + hidePageOverlay(); + }); + {% if node %} ProjectUtils.setProjectAttributes({ nodeId: '{{node._id}}', @@ -38,8 +54,6 @@ script(type="text/javascript"). // If we are im preview mode, update the image source - var page_overlay = document.getElementById('page-overlay'); - if (page_overlay.classList.contains('active')) { var node_preview = document.getElementById('node-preview'); @@ -80,20 +94,6 @@ script(type="text/javascript"). {% endif %} - // Click anywhere in the page to hide the overlay - function hidePageOverlay() { - $(page_overlay) - .removeAttr('class') - .html(''); - } - - $(page_overlay).click(function(e) { - e.stopPropagation(); - e.preventDefault(); - - hidePageOverlay(); - }); - function navigateTree(prev){ var tree = $('#project_tree').jstree(true); var curr = tree.get_selected(false); diff --git a/src/templates/nodes/custom/blog/index.jade b/src/templates/nodes/custom/blog/index.jade index 79c05b63..0cb80c8b 100644 --- a/src/templates/nodes/custom/blog/index.jade +++ b/src/templates/nodes/custom/blog/index.jade @@ -122,19 +122,7 @@ link(href="{{ url_for('static_pillar', filename='assets/css/blog.css', v=2122016 | {% block footer_scripts %} include ../_scripts script. - var project_container = document.getElementById('project-container'); - - /* UI Stuff */ - $(window).on("load resize",function(){ - containerResizeY($(window).height()); - - if ($(window).width() > 480) { - project_container.style.height = (window.innerHeight - project_container.offsetTop) + "px"; - } - }); - /* 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(); @@ -142,7 +130,6 @@ script. 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(''); @@ -150,4 +137,5 @@ script. window.location.href = href; } }); + | {% endblock %} diff --git a/src/templates/nodes/custom/blog/index_main_project.jade b/src/templates/nodes/custom/blog/index_main_project.jade index 2726897f..7cd998a5 100644 --- a/src/templates/nodes/custom/blog/index_main_project.jade +++ b/src/templates/nodes/custom/blog/index_main_project.jade @@ -90,6 +90,25 @@ | {% block footer_scripts %} include ../_scripts -script hopToTop(); // Display jump to top button +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'); + var src = $(this).attr('src'); + + if (href.match("jpg$") || href.match("png$") || href.match("gif$")) { + $(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 9b6d873c..cfbe1ca4 100644 --- a/src/templates/nodes/custom/post/view.jade +++ b/src/templates/nodes/custom/post/view.jade @@ -94,17 +94,6 @@ script. }); {% endif %} - var project_container = document.getElementById('project-container'); - - /* UI Stuff */ - $(window).on("load resize",function(){ - containerResizeY($(window).height()); - - if ($(window).width() > 480) { - project_container.style.height = (window.innerHeight - project_container.offsetTop) + "px"; - } - }); - /* 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){ diff --git a/src/templates/nodes/custom/post/view_embed.jade b/src/templates/nodes/custom/post/view_embed.jade index 52206e47..9766f6e3 100644 --- a/src/templates/nodes/custom/post/view_embed.jade +++ b/src/templates/nodes/custom/post/view_embed.jade @@ -123,6 +123,24 @@ meta(name="twitter:description", content="{{ node.properties.content }}") | {% block footer_scripts %} include ../_scripts -script hopToTop(); // Display jump to top button +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'); + var src = $(this).attr('src'); + + if (href.match("jpg$") || href.match("png$") || href.match("gif$")) { + $(page_overlay) + .addClass('active') + .html(''); + } else { + window.location.href = href; + } + }); | {% endblock %}