forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1411 from appsembler/vladyslav/hide-html-elements…
…-in-iframe Hide html elements if the parameter is set
- Loading branch information
Showing
5 changed files
with
39 additions
and
16 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
} | ||
|
||
// Hide element when rendered in iFrame | ||
.hidden-in-iframe { | ||
.hidden-element { | ||
display: none !important; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters