@@ -22,6 +22,13 @@ define(['jquery', 'mod_hvp/communicator'], function($, H5PEmbedCommunicator) {
22
22
var resizeDelay ;
23
23
var instance = H5P . instances [ 0 ] ;
24
24
var parentIsFriendly = false ;
25
+ var completionheight = 0 ;
26
+ if ( globalThis . completion ) {
27
+ var completionactivity = document . getElementsByClassName ( 'activity-header' ) [ 0 ] ;
28
+ var completionmargin = document . defaultView . getComputedStyle ( completionactivity , '' )
29
+ . getPropertyValue ( 'margin-bottom' ) ;
30
+ completionheight = completionactivity . scrollHeight + parseInt ( completionmargin , 10 ) ; // We want the first element.
31
+ }
25
32
26
33
// Handle that the resizer is loaded after the iframe.
27
34
H5PEmbedCommunicator . on ( 'ready' , function ( ) {
@@ -41,11 +48,10 @@ define(['jquery', 'mod_hvp/communicator'], function($, H5PEmbedCommunicator) {
41
48
// Content need to be resized to fit the new iframe size.
42
49
H5P . trigger ( instance , 'resize' ) ;
43
50
} ) ;
44
-
45
51
// When resize has been prepared tell parent window to resize.
46
52
H5PEmbedCommunicator . on ( 'resizePrepared' , function ( ) {
47
53
H5PEmbedCommunicator . send ( 'resize' , {
48
- scrollHeight : iFrame . contentDocument . body . scrollHeight
54
+ scrollHeight : iFrame . contentDocument . body . scrollHeight + ( ( globalThis . completion ) ? completionheight : 0 )
49
55
} ) ;
50
56
} ) ;
51
57
@@ -66,7 +72,7 @@ define(['jquery', 'mod_hvp/communicator'], function($, H5PEmbedCommunicator) {
66
72
H5PEmbedCommunicator . send ( 'prepareResize' ,
67
73
{
68
74
scrollHeight : iFrame . contentDocument . body . scrollHeight ,
69
- clientHeight : iFrame . contentDocument . body . clientHeight
75
+ clientHeight : iFrame . contentDocument . body . clientHeight + ( ( globalThis . completion ) ? completionheight : 0 )
70
76
}
71
77
) ;
72
78
} else {
@@ -93,5 +99,13 @@ define(['jquery', 'mod_hvp/communicator'], function($, H5PEmbedCommunicator) {
93
99
}
94
100
} ) ;
95
101
} ) ;
96
-
97
- } ) ;
102
+ return /** @alias module:mod_hvp/embed */ {
103
+ /**
104
+ * Initialise embed instance.
105
+ * @param {boolean } completion a boolean about displaying the completion information
106
+ */
107
+ init : function ( completion ) {
108
+ globalThis . completion = completion ;
109
+ } ,
110
+ } ;
111
+ } ) ;
0 commit comments