Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from main (production) #1410

Merged
merged 6 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lms/static/js/student_account/views/FinishAuthView.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
courseId: $.url('?course_id'),
courseMode: $.url('?course_mode'),
emailOptIn: $.url('?email_opt_in'),
purchaseWorkflow: $.url('?purchase_workflow')
purchaseWorkflow: $.url('?purchase_workflow'),
hideElements: $.url('?hide_elements')
};
for (var key in queryParams) {
if (queryParams[key]) {
Expand All @@ -64,6 +65,7 @@
this.emailOptIn = queryParams.emailOptIn;
this.nextUrl = this.urls.defaultNextUrl;
this.purchaseWorkflow = queryParams.purchaseWorkflow;
this.hideElements = queryParams.hideElements;
if (queryParams.next) {
// Ensure that the next URL is internal for security reasons
if (! window.isExternal(queryParams.next)) {
Expand All @@ -76,6 +78,9 @@
try {
var next = _.bind(this.enrollment, this);
this.checkEmailOptIn(next);
if (this.hideElements) {
document.cookie = 'hideElements=' + this.hideElements + '; path=/';
}
} catch (err) {
this.updateTaskDescription(gettext('Error') + ': ' + err.message);
this.redirect(this.nextUrl);
Expand Down
31 changes: 31 additions & 0 deletions lms/static/lms/js/iframe-render.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// List of the classes to hide while rendered in an iframe
const classesToHide = ['.global-header', '.wrapper-course-material', '.a--footer'];

// Function to get a cookie by name
function getCookieByName(name) {
let cname = name + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let cookies = decodedCookie.split(';');
for (let i = 0; i < cookies.length; i++) {
let c = cookies[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

document.addEventListener('DOMContentLoaded', function () {
const hideElements = getCookieByName('hideElements');

if (hideElements) {
classesToHide.forEach(function (className) {
document.querySelectorAll(className).forEach(function (element) {
element.classList.add('hidden-element');
});
});
}
});
5 changes: 5 additions & 0 deletions lms/static/sass/shared-v2/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@
@extend .sr-only;
}

// Hide element when rendered in iFrame
.hidden-element {
display: none !important;
}

1 change: 1 addition & 0 deletions lms/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
}).call(this, require || RequireJS.require);
</script>
<script type="text/javascript" src="${static.url("lms/js/require-config.js")}"></script>
<script type="text/javascript" src="${static.url("lms/js/iframe-render.js")}"></script>
<%block name="js_overrides">
${render_require_js_path_overrides(settings.REQUIRE_JS_PATH_OVERRIDES) | n, decode.utf8}
</%block>
Expand Down
Loading