Skip to content

Commit 6bb729b

Browse files
Merge pull request #1190 from Kotlin/website_docs_df_iframes_fix
fix snippets iframes
2 parents 1f2889a + fbd0a7f commit 6bb729b

File tree

141 files changed

+8414
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+8414
-280
lines changed

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/explainer/SamplesRenderingUtils.kt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,71 @@ val WritersideStyle = DataFrameHtmlData(
3232
padding: 6px;
3333
}
3434
""".trimIndent(),
35+
script =
36+
"""
37+
function sendHeight() {
38+
let totalHeight = 0;
39+
40+
const detailsElements = document.querySelectorAll('details');
41+
42+
detailsElements.forEach(detail => {
43+
44+
const summary = detail.querySelector('summary');
45+
if (summary) {
46+
totalHeight += summary.offsetHeight;
47+
}
48+
49+
50+
if (detail.open) {
51+
const table = detail.querySelector('table.dataframe');
52+
if (table) {
53+
totalHeight += table.offsetHeight;
54+
55+
const styles = getComputedStyle(table);
56+
totalHeight += parseFloat(styles.marginTop) + parseFloat(styles.marginBottom) + 10;
57+
}
58+
59+
const description = detail.querySelector('.dataframe_description');
60+
if (description) {
61+
totalHeight += description.offsetHeight;
62+
}
63+
}
64+
});
65+
66+
totalHeight = Math.ceil(totalHeight + 16);
67+
68+
window.parent.postMessage({type: 'iframeHeight', height: totalHeight}, '*');
69+
}
70+
71+
function repeatHeightCalculation(maxRetries = 10, interval = 100) {
72+
let retries = 0;
73+
const intervalId = setInterval(() => {
74+
sendHeight();
75+
retries++;
76+
if (retries >= maxRetries) clearInterval(intervalId);
77+
}, interval);
78+
}
79+
80+
window.addEventListener('load', () => {
81+
repeatHeightCalculation();
82+
83+
document.querySelectorAll('details').forEach(detail => {
84+
detail.addEventListener('toggle', () => {
85+
setTimeout(sendHeight, 30);
86+
});
87+
});
88+
});
89+
90+
const allObservedTables = document.querySelectorAll('table.dataframe');
91+
allObservedTables.forEach((table) => {
92+
const observer = new MutationObserver(sendHeight);
93+
observer.observe(table, {
94+
childList: true,
95+
subtree: true,
96+
characterData: true,
97+
});
98+
});
99+
""".trimIndent()
35100
)
36101

37102
val WritersideFooter: (DataFrame<*>) -> String = { "" }

docs/StardustDocs/cfg/buildprofiles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<algolia-api-key>bce9ba6ce7419efe813d671244d3bf6a</algolia-api-key>
1414
<search-scopes-provider>https://www.jetbrains.com/search/json/</search-scopes-provider>
1515
<generate-sitemap-url-prefix>https://kotlin.github.io/dataframe/</generate-sitemap-url-prefix>
16-
<analytics-head-script-file>resize-iframes.js</analytics-head-script-file>
16+
<analytics-head-script-file>google-search.html</analytics-head-script-file>
1717
<enable-browser-edits>true</enable-browser-edits>
1818
<browser-edits-url>https://github.com/Kotlin/dataframe/edit/master/docs/StardustDocs/</browser-edits-url>
1919
<include-in-head>include-head.html</include-in-head>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<meta name="google-site-verification" content="Lffz_ab-_S5cmA07ZXVbucHVklaRsnk8gEt8frHKjMk"/>
2+
<!-- Google Analytics -->
3+
<script>
4+
(function (w, d, s, l, i) {
5+
w[l] = w[l] || [];
6+
w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
7+
var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&amp;l=' + l : '';
8+
j.async = true;
9+
j.src = '//www.googletagmanager.com/gtm.js?id=' + i + dl;
10+
f.parentNode.insertBefore(j, f);
11+
})(window, document, 'script', 'dataLayer', 'GTM-5P98');
12+
</script>
13+
<!-- End Google Analytics -->
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
<script src="static/custom.js"></script>
1+
<script src="static/iframe-config.js"></script>
2+
<script src="static/iframe-config-old.js"></script>

docs/StardustDocs/cfg/resize-iframes.js

Lines changed: 0 additions & 129 deletions
This file was deleted.

docs/StardustDocs/d.tree

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,4 @@
198198
</toc-element>
199199
<toc-element topic="Compiler-Plugin.md"/>
200200
<toc-element topic="_shadow_resources.md" hidden="true"/>
201-
<toc-element topic="_shadow_resources_snippets.md" hidden="true"/>
202201
</instance-profile>

docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.byRow.html

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,68 @@
513513
}
514514
})()
515515

516+
function sendHeight() {
517+
let totalHeight = 0;
518+
519+
const detailsElements = document.querySelectorAll('details');
520+
521+
detailsElements.forEach(detail => {
522+
523+
const summary = detail.querySelector('summary');
524+
if (summary) {
525+
totalHeight += summary.offsetHeight;
526+
}
527+
528+
529+
if (detail.open) {
530+
const table = detail.querySelector('table.dataframe');
531+
if (table) {
532+
totalHeight += table.offsetHeight;
533+
534+
const styles = getComputedStyle(table);
535+
totalHeight += parseFloat(styles.marginTop) + parseFloat(styles.marginBottom) + 10;
536+
}
537+
538+
const description = detail.querySelector('.dataframe_description');
539+
if (description) {
540+
totalHeight += description.offsetHeight;
541+
}
542+
}
543+
});
544+
545+
totalHeight = Math.ceil(totalHeight + 16);
546+
547+
window.parent.postMessage({type: 'iframeHeight', height: totalHeight}, '*');
548+
}
549+
550+
function repeatHeightCalculation(maxRetries = 10, interval = 100) {
551+
let retries = 0;
552+
const intervalId = setInterval(() => {
553+
sendHeight();
554+
retries++;
555+
if (retries >= maxRetries) clearInterval(intervalId);
556+
}, interval);
557+
}
558+
559+
window.addEventListener('load', () => {
560+
repeatHeightCalculation();
561+
562+
document.querySelectorAll('details').forEach(detail => {
563+
detail.addEventListener('toggle', () => {
564+
setTimeout(sendHeight, 30);
565+
});
566+
});
567+
});
568+
569+
const allObservedTables = document.querySelectorAll('table.dataframe');
570+
allObservedTables.forEach((table) => {
571+
const observer = new MutationObserver(sendHeight);
572+
observer.observe(table, {
573+
childList: true,
574+
subtree: true,
575+
characterData: true,
576+
});
577+
});
516578
/*<!--*/
517579
call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "<span title=\"firstName: String\">firstName</span>", children: [], rightAlign: false, values: ["Alice","Bob","Charlie","Charlie","Bob","Alice","Charlie"] },
518580
{ name: "<span title=\"lastName: String\">lastName</span>", children: [], rightAlign: false, values: ["Cooper","Dylan","Daniels","Chaplin","Marley","Wolf","Byrd"] },

docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectors.html

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,68 @@
613613
}
614614
})()
615615

616+
function sendHeight() {
617+
let totalHeight = 0;
618+
619+
const detailsElements = document.querySelectorAll('details');
620+
621+
detailsElements.forEach(detail => {
622+
623+
const summary = detail.querySelector('summary');
624+
if (summary) {
625+
totalHeight += summary.offsetHeight;
626+
}
627+
628+
629+
if (detail.open) {
630+
const table = detail.querySelector('table.dataframe');
631+
if (table) {
632+
totalHeight += table.offsetHeight;
633+
634+
const styles = getComputedStyle(table);
635+
totalHeight += parseFloat(styles.marginTop) + parseFloat(styles.marginBottom) + 10;
636+
}
637+
638+
const description = detail.querySelector('.dataframe_description');
639+
if (description) {
640+
totalHeight += description.offsetHeight;
641+
}
642+
}
643+
});
644+
645+
totalHeight = Math.ceil(totalHeight + 16);
646+
647+
window.parent.postMessage({type: 'iframeHeight', height: totalHeight}, '*');
648+
}
649+
650+
function repeatHeightCalculation(maxRetries = 10, interval = 100) {
651+
let retries = 0;
652+
const intervalId = setInterval(() => {
653+
sendHeight();
654+
retries++;
655+
if (retries >= maxRetries) clearInterval(intervalId);
656+
}, interval);
657+
}
658+
659+
window.addEventListener('load', () => {
660+
repeatHeightCalculation();
661+
662+
document.querySelectorAll('details').forEach(detail => {
663+
detail.addEventListener('toggle', () => {
664+
setTimeout(sendHeight, 30);
665+
});
666+
});
667+
});
668+
669+
const allObservedTables = document.querySelectorAll('table.dataframe');
670+
allObservedTables.forEach((table) => {
671+
const observer = new MutationObserver(sendHeight);
672+
observer.observe(table, {
673+
childList: true,
674+
subtree: true,
675+
characterData: true,
676+
});
677+
});
616678
/*<!--*/
617679
call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "<span title=\"firstName: String\">firstName</span>", children: [], rightAlign: false, values: ["Alice","Bob","Charlie","Charlie","Bob","Alice","Charlie"] },
618680
{ name: "<span title=\"lastName: String\">lastName</span>", children: [], rightAlign: false, values: ["Cooper","Dylan","Daniels","Chaplin","Marley","Wolf","Byrd"] },

0 commit comments

Comments
 (0)