diff --git a/lms/static/js/student_account/views/FinishAuthView.js b/lms/static/js/student_account/views/FinishAuthView.js
index 870c56b6159..ac09152c828 100644
--- a/lms/static/js/student_account/views/FinishAuthView.js
+++ b/lms/static/js/student_account/views/FinishAuthView.js
@@ -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]) {
@@ -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)) {
@@ -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);
diff --git a/lms/static/lms/js/iframe-render.js b/lms/static/lms/js/iframe-render.js
new file mode 100644
index 00000000000..f5b5bce6b20
--- /dev/null
+++ b/lms/static/lms/js/iframe-render.js
@@ -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');
+ });
+ });
+ }
+});
diff --git a/lms/static/sass/shared-v2/_base.scss b/lms/static/sass/shared-v2/_base.scss
index 584cf5799fa..450a1aa51b7 100644
--- a/lms/static/sass/shared-v2/_base.scss
+++ b/lms/static/sass/shared-v2/_base.scss
@@ -24,3 +24,8 @@
@extend .sr-only;
}
+// Hide element when rendered in iFrame
+.hidden-element {
+ display: none !important;
+}
+
diff --git a/lms/templates/main.html b/lms/templates/main.html
index 48edc767a13..af1d51fe9cb 100644
--- a/lms/templates/main.html
+++ b/lms/templates/main.html
@@ -123,6 +123,7 @@
}).call(this, require || RequireJS.require);
+
<%block name="js_overrides">
${render_require_js_path_overrides(settings.REQUIRE_JS_PATH_OVERRIDES) | n, decode.utf8}
%block>