From d0bfbcb4d1ca2bb7e25a114dd5390da4a698dabe Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 20 Apr 2021 12:38:33 -0500 Subject: [PATCH] js: only apply target="_blank" to IDE build On the web, we want to be able to navigate between the various Pybricks subdomains without opening new tabs. But Pybricks Code is treated as an "app", we don't want links to open in Pybricks Code. --- doc/common/_static/js/{custom.js => ide.js} | 1 + doc/common/conf.py | 5 ----- doc/ide/conf.py | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) rename doc/common/_static/js/{custom.js => ide.js} (68%) diff --git a/doc/common/_static/js/custom.js b/doc/common/_static/js/ide.js similarity index 68% rename from doc/common/_static/js/custom.js rename to doc/common/_static/js/ide.js index 1163a38..1b1a459 100644 --- a/doc/common/_static/js/custom.js +++ b/doc/common/_static/js/ide.js @@ -1,3 +1,4 @@ +// Since Pybricks Code is an "app", all external links get opened in new tab/window // https://stackoverflow.com/a/62742435/1976323 $(document).ready(function () { $('a[href^="http://"], a[href^="https://"]').not('a[class*=internal]').attr('target', '_blank'); diff --git a/doc/common/conf.py b/doc/common/conf.py index c96da1b..4147d0e 100644 --- a/doc/common/conf.py +++ b/doc/common/conf.py @@ -147,11 +147,6 @@ else: html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] -# a little extra javascript -html_js_files = [ - 'js/custom.js' -] - html_context = { 'disclaimer': _DISCLAIMER, } diff --git a/doc/ide/conf.py b/doc/ide/conf.py index 5acd7e0..63bdcd2 100644 --- a/doc/ide/conf.py +++ b/doc/ide/conf.py @@ -18,6 +18,7 @@ html_logo = '../common/images/pybricks-logo-rtd.png' html_show_copyright = False html_show_sphinx = False html_css_files = ['css/ide.css'] +html_js_files = ['js/ide.js'] imgmath_image_format = 'svg' imgmath_use_preview = True # requires Sphinx v3