From c84dcc74d48bf5e096f7f2b61845d9dc6148d123 Mon Sep 17 00:00:00 2001 From: Rushan Date: Fri, 25 Mar 2022 17:10:14 +0400 Subject: [PATCH] Hide navigation links when loaded inside iframe --- source/_static/js/main.js | 7 +++++++ source/_static/scss/includes/_layout.scss | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/source/_static/js/main.js b/source/_static/js/main.js index fe52121a..85c4c839 100644 --- a/source/_static/js/main.js +++ b/source/_static/js/main.js @@ -1,4 +1,11 @@ window.addEventListener("DOMContentLoaded", (event) => { + // Detect parent iframe. + // This is required to hide the navigation links when viewed via PathFactory for analytics purposes + if (window.location !== window.parent.location) { + document.body.classList.add('inside-iframe'); + } + + // Table of contents var topic = document.getElementById("table-of-contents"); if (topic != null) { document diff --git a/source/_static/scss/includes/_layout.scss b/source/_static/scss/includes/_layout.scss index d419ed0d..9bf6aef2 100644 --- a/source/_static/scss/includes/_layout.scss +++ b/source/_static/scss/includes/_layout.scss @@ -42,4 +42,21 @@ position: sticky; top: 0; overflow: scroll; +} + +// Keep only the main content when the page is loaded inside an iframe. +// Currently we load certain pages inside iframes for PathFactory analytics. +.inside-iframe { + .header, + .sidebar { + display: none; + } + + .content { + height: 100vh; + } + + .content__main { + padding-left: $content-padding; + } } \ No newline at end of file