File tree Expand file tree Collapse file tree 5 files changed +39
-16
lines changed Expand file tree Collapse file tree 5 files changed +39
-16
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 51
51
courseId : $ . url ( '?course_id' ) ,
52
52
courseMode : $ . url ( '?course_mode' ) ,
53
53
emailOptIn : $ . url ( '?email_opt_in' ) ,
54
- purchaseWorkflow : $ . url ( '?purchase_workflow' )
54
+ purchaseWorkflow : $ . url ( '?purchase_workflow' ) ,
55
+ hideElements : $ . url ( '?hide_elements' )
55
56
} ;
56
57
for ( var key in queryParams ) {
57
58
if ( queryParams [ key ] ) {
64
65
this . emailOptIn = queryParams . emailOptIn ;
65
66
this . nextUrl = this . urls . defaultNextUrl ;
66
67
this . purchaseWorkflow = queryParams . purchaseWorkflow ;
68
+ this . hideElements = queryParams . hideElements ;
67
69
if ( queryParams . next ) {
68
70
// Ensure that the next URL is internal for security reasons
69
71
if ( ! window . isExternal ( queryParams . next ) ) {
76
78
try {
77
79
var next = _ . bind ( this . enrollment , this ) ;
78
80
this . checkEmailOptIn ( next ) ;
81
+ if ( this . hideElements ) {
82
+ document . cookie = 'hideElements=' + this . hideElements + '; path=/' ;
83
+ }
79
84
} catch ( err ) {
80
85
this . updateTaskDescription ( gettext ( 'Error' ) + ': ' + err . message ) ;
81
86
this . redirect ( this . nextUrl ) ;
Original file line number Diff line number Diff line change
1
+ // List of the classes to hide while rendered in an iframe
2
+ const classesToHide = [ '.global-header' , '.wrapper-course-material' , '.a--footer' ] ;
3
+
4
+ // Function to get a cookie by name
5
+ function getCookieByName ( name ) {
6
+ let cname = name + "=" ;
7
+ let decodedCookie = decodeURIComponent ( document . cookie ) ;
8
+ let cookies = decodedCookie . split ( ';' ) ;
9
+ for ( let i = 0 ; i < cookies . length ; i ++ ) {
10
+ let c = cookies [ i ] ;
11
+ while ( c . charAt ( 0 ) == ' ' ) {
12
+ c = c . substring ( 1 ) ;
13
+ }
14
+ if ( c . indexOf ( name ) == 0 ) {
15
+ return c . substring ( name . length , c . length ) ;
16
+ }
17
+ }
18
+ return "" ;
19
+ }
20
+
21
+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
22
+ const hideElements = getCookieByName ( 'hideElements' ) ;
23
+
24
+ if ( hideElements ) {
25
+ classesToHide . forEach ( function ( className ) {
26
+ document . querySelectorAll ( className ) . forEach ( function ( element ) {
27
+ element . classList . add ( 'hidden-element' ) ;
28
+ } ) ;
29
+ } ) ;
30
+ }
31
+ } ) ;
Original file line number Diff line number Diff line change 25
25
}
26
26
27
27
// Hide element when rendered in iFrame
28
- .hidden-in-iframe {
28
+ .hidden-element {
29
29
display : none !important ;
30
30
}
31
31
Original file line number Diff line number Diff line change 123
123
} ) . call ( this , require || RequireJS . require ) ;
124
124
</ script >
125
125
< script type ="text/javascript " src ="${static.url( "lms /js/require-config.js")}"> </ script >
126
+ < script type ="text/javascript " src ="${static.url( "lms /js/iframe-render.js")}"> </ script >
126
127
< %block name="js_overrides">
127
128
${render_require_js_path_overrides(settings.REQUIRE_JS_PATH_OVERRIDES) | n, decode.utf8}
128
129
</ %block>
211
212
< script type ="text/javascript " src ="${static.url('js/header/header.js')} "> </ script >
212
213
< %static:optional_include_mako file="body-extra.html" is_theming_enabled="True" />
213
214
< script type ="text/javascript " src ="${static.url('js/src/jquery_extend_patch.js')} "> </ script >
214
- < script type ="text/javascript " src ="${static.url('js/src/iframe-render.js')} "> </ script >
215
215
</ body >
216
216
</ html >
217
217
You can’t perform that action at this time.
0 commit comments