Skip to content

Commit 8a34224

Browse files
committed
Attempt add adding a full screen in tab button.
1 parent 96f789e commit 8a34224

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

jupyterlite_sphinx/jupyterlite_sphinx.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ window.tryExamplesHideIframe = (examplesContainerId, iframeParentContainerId) =>
115115
examplesContainer.classList.remove("hidden");
116116
}
117117

118+
window.openInNewTab = (examplesContainerId, iframeParentContainerId) => {
119+
const examplesContainer = document.getElementById(examplesContainerId);
120+
const iframeParentContainer = document.getElementById(
121+
iframeParentContainerId
122+
);
123+
124+
window.open(iframeParentContainer.children[1].getAttribute("src"));
125+
tryExamplesHideIframe(examplesContainerId, iframeParentContainerId);
126+
};
118127

119128
/* Global variable for try_examples iframe minHeight. Defaults to 0 but can be
120129
* modified based on configuration in try_examples.json */

jupyterlite_sphinx/jupyterlite_sphinx.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,17 @@ def run(self):
442442

443443
# Button with the onclick event to swap embedded notebook back to examples.
444444
go_back_button_html = (
445-
'<div class="try_examples_button_container">'
446445
'<button class="try_examples_button" '
447446
f"onclick=\"window.tryExamplesHideIframe('{examples_div_id}',"
448447
f"'{iframe_parent_div_id}')\">"
449448
"Go Back</button>"
450-
"</div>"
449+
)
450+
451+
full_screen_button_html = (
452+
'<button class="try_examples_button" '
453+
f"onclick=\"window.openInNewTab('{examples_div_id}',"
454+
f"'{iframe_parent_div_id}')\">"
455+
"Open In Tab</button>"
451456
)
452457

453458
# Button with the onclick event to swap examples with embedded notebook.
@@ -465,7 +470,10 @@ def run(self):
465470
# Combine everything
466471
notebook_container_html = (
467472
iframe_parent_container_div_start
473+
+ '<div class="try_examples_button_container">'
468474
+ go_back_button_html
475+
+ full_screen_button_html
476+
+ "</div>"
469477
+ iframe_container_div
470478
+ iframe_parent_container_div_end
471479
)

0 commit comments

Comments
 (0)