Skip to content

Commit

Permalink
fix(iframe): unify horizontal and vertical layout
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoomen authored and stgm committed Apr 9, 2024
1 parent 53f3ff9 commit b9e534e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
6 changes: 3 additions & 3 deletions static/css/main.embed.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/* iframe-specific overwrites */

.examide-embed .lm_splitter.lm_vertical {
.examide-embed .lm_splitter {
display: none;
}

Expand All @@ -23,12 +23,12 @@
border-width: 1px 1px 0 0;
}

.examide-embed .editor-component-container .lm_controls {
.examide-embed .lm_controls {
margin-top: -2px;
}

.examide-embed {
background: #fff;
background: var(--color-white);
border: 1px solid var(--border-color);
padding: 2px 0 0;
}
22 changes: 12 additions & 10 deletions static/js/layout-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,23 @@ class Layout extends GoldenLayout {
</div>
`;

const $editorContainer = $('.editor-component-container');
const $terminalContainer = $('.terminal-component-container');

if (this.iframe && this.vertical) {
$('.editor-component-container')
$editorContainer
.find('.lm_controls')
.append(runCodeButtonHtml)
.append(settingsMenuHtml);
} else if (this.iframe) {
// Horizontal layout.
$terminalContainer.find('.lm_controls')
.append(runCodeButtonHtml)
.append(settingsMenuHtml);
} else {
// horizontal layout (exam and iframe)
const $componentContainer = $('.terminal-component-container');
$componentContainer.find('.lm_header').append(runCodeButtonHtml);
$componentContainer.find('.lm_controls').append(settingsMenuHtml);

// Only add the clear-terminal button in the exam version.
if (!this.iframe) {
$componentContainer.find('.lm_header').append(clearTermButtonHtml);
}
// Exam layout.
$terminalContainer.find('.lm_header').append(runCodeButtonHtml).append(clearTermButtonHtml)
$terminalContainer.find('.lm_controls').append(settingsMenuHtml);
}

// Add custom buttons to the header.
Expand Down
3 changes: 2 additions & 1 deletion static/js/main.shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function generateConfigContent(tabs, fontSize) {
* @returns {Layout} The layout instance.
*/
function createLayout(content, proglang, fontSize, options = {}) {
const isIframe = $('body').hasClass('examide-embed');
const defaultLayoutConfig = {
settings: {
showCloseIcon: false,
Expand All @@ -46,7 +47,7 @@ function createLayout(content, proglang, fontSize, options = {}) {
},
dimensions: {
headerHeight: 30,
borderWidth: options.vertical ? 0 : 10,
borderWidth: isIframe ? 0 : 10,
},
content: [
{
Expand Down

0 comments on commit b9e534e

Please sign in to comment.