fix: simplify code by using common method
This commit is contained in:
committed by
leangseu-edx
parent
efe40657b4
commit
9e0b59fe87
@@ -162,7 +162,21 @@
|
||||
return this.videoFullScreen.height;
|
||||
}
|
||||
|
||||
/**
|
||||
function notifyParent(fullscreenOpen) {
|
||||
if (window !== window.parent) {
|
||||
// This is used by the Learning MFE to know about changing fullscreen mode.
|
||||
// The MFE is then able to respond appropriately and scroll window to the previous position.
|
||||
window.parent.postMessage({
|
||||
type: 'plugin.videoFullScreen',
|
||||
payload: {
|
||||
open: fullscreenOpen
|
||||
}
|
||||
}, document.referrer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event handler to toggle fullscreen mode.
|
||||
* @param {jquery Event} event
|
||||
*/
|
||||
@@ -194,17 +208,7 @@
|
||||
}
|
||||
this.el.trigger('fullscreen', [this.isFullScreen]);
|
||||
|
||||
if (window !== window.parent) {
|
||||
// This is used by the Learning MFE to know about closing fullscreen mode.
|
||||
// The MFE is then able to respond appropriately and scroll window to the previous position.
|
||||
window.parent.postMessage({
|
||||
type: 'plugin.videoFullScreen',
|
||||
payload: {
|
||||
open: false
|
||||
}
|
||||
}, document.referrer
|
||||
);
|
||||
}
|
||||
this.videoFullScreen.notifyParent(false);
|
||||
}
|
||||
|
||||
function handleEnter() {
|
||||
@@ -215,17 +219,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (window !== window.parent) {
|
||||
// This is used by the Learning MFE to know about opening fullscreen mode.
|
||||
// The MFE is then able to respond appropriately and save the window scroll position.
|
||||
window.parent.postMessage({
|
||||
type: 'plugin.videoFullScreen',
|
||||
payload: {
|
||||
open: true
|
||||
}
|
||||
}, document.referrer
|
||||
);
|
||||
}
|
||||
this.videoFullScreen.notifyParent(true);
|
||||
|
||||
this.videoFullScreen.fullScreenState = this.isFullScreen = true;
|
||||
fullScreenClassNameEl.addClass('video-fullscreen');
|
||||
@@ -292,7 +286,8 @@
|
||||
handleFullscreenChange: handleFullscreenChange,
|
||||
toggle: toggle,
|
||||
toggleHandler: toggleHandler,
|
||||
updateControlsHeight: updateControlsHeight
|
||||
updateControlsHeight: updateControlsHeight,
|
||||
notifyParent: notifyParent
|
||||
};
|
||||
|
||||
state.bindTo(methodsDict, state.videoFullScreen, state);
|
||||
|
||||
Reference in New Issue
Block a user