Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
59bb664f
Unverified
Commit
59bb664f
authored
5 years ago
by
Adam Butterworth
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Report iframed courseware content dimensions to parent window (#22972)
TNL-7044
parent
54b64e70
Branches
Branches containing commit
Tags
release-2020-01-29-05.11
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lms/templates/courseware/courseware-chromeless.html
+47
-0
47 additions, 0 deletions
lms/templates/courseware/courseware-chromeless.html
with
47 additions
and
0 deletions
lms/templates/courseware/courseware-chromeless.html
+
47
−
0
View file @
59bb664f
...
...
@@ -106,3 +106,50 @@ ${HTML(fragment.foot_html())}
% endif
</nav>
% endif
<script
type=
"text/javascript"
>
(
function
()
{
// If this view is rendered in an iframe within the learning microfrontend app
// it will report the height of its contents to the parent window when the
// document loads, window resizes, or DOM mutates.
if
(
window
!==
window
.
parent
)
{
var
learningAppReferrer
=
"
${settings.LEARNING_MICROFRONTEND_URL | n, js_escaped_string}
"
;
if
(
document
.
referrer
===
learningAppReferrer
)
{
var
lastHeight
=
window
.
offsetHeight
;
var
lastWidth
=
window
.
offsetWidth
;
var
contentElement
=
document
.
getElementById
(
'
content
'
);
function
dispatchResizeMessage
()
{
var
newHeight
=
contentElement
.
offsetHeight
;
var
newWidth
=
contentElement
.
offsetWidth
;
if
(
newWidth
===
lastWidth
&&
newHeight
===
lastHeight
)
{
return
;
}
window
.
parent
.
postMessage
({
type
:
'
plugin.resize
'
,
payload
:
{
width
:
newWidth
,
height
:
newHeight
,
}
},
document
.
referrer
);
lastHeight
=
newHeight
;
lastWidth
=
newWidth
;
}
// Create an observer instance linked to the callback function
const
observer
=
new
MutationObserver
(
dispatchResizeMessage
);
// Start observing the target node for configured mutations
observer
.
observe
(
document
.
body
,
{
attributes
:
true
,
childList
:
true
,
subtree
:
true
});
window
.
addEventListener
(
'
load
'
,
dispatchResizeMessage
);
window
.
addEventListener
(
'
resize
'
,
dispatchResizeMessage
);
}
}
}());
</script>
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment