Updated the 19 build version to 20101023
[moodle.git] / mod / scorm / rd.js
blob98570e4cb0e5a5ef9a4fe978cd292028f09aa957
1 <!--
2 function scorm_get_element_style(obj, prop, cssProp) {
3     var ret = '';
4     
5     if (obj.currentStyle) {
6         ret = obj.currentStyle[prop];
7     } else if (document.defaultView && document.defaultView.getComputedStyle) {
8         var compStyle = document.defaultView.getComputedStyle(obj, null);
9         ret = compStyle.getPropertyValue(cssProp);
10     }
11     
12     if (ret == 'auto') ret = '0';
13     return ret;
16 function scorm_resize (cwidth, cheight) {
18     var winwidth = 0, winheight = 0;
19     if( typeof( window.innerWidth ) == 'number' ) {
20         //Non-IE
21         winwidth = window.innerWidth;
22         winheight = window.innerHeight;
23     } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
24         //IE 6+ in 'standards compliant mode'
25         winwidth = document.documentElement.clientWidth;
26         winheight = document.documentElement.clientHeight;
27     } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
28         //IE 4 compatible
29         winwidth = document.body.clientWidth;
30         winheight = document.body.clientHeight;
31     }
32                               
33     var header = document.getElementById('header');   
34     var content = document.getElementById('content');
35     var headerheight = 0;
36     if (content) {
37         headerheight = content.offsetTop;
38     }
39     
40     var footer = document.getElementById('footer');
41     var imsnavbar = document.getElementById('tochead');
42     var scormtop = document.getElementById('scormtop');
43     var footerheight = 0;
44     var imsnavheight = 0;
45     var scormtopheight = 0;
46     if (footer) {
47         footerheight = footer.offsetHeight + parseInt(scorm_get_element_style(footer, 'marginTop', 'margin-top')) + parseInt(scorm_get_element_style(footer, 'marginBottom', 'margin-bottom'));
48     }
49     if (imsnavbar) {
50         imsnavheight = imsnavbar.offsetHeight;
51     }
52     if (scormtop) {
53         scormtopheight = scormtop.offsetHeight;
54     }
56     var topmargin = parseInt(scorm_get_element_style(document.getElementsByTagName('body')[0], 'marginTop', 'margin-top'));
57     var bottommargin = parseInt(scorm_get_element_style(document.getElementsByTagName('body')[0], 'marginBottom', 'margin-bottom'));
58     
59     var totalheight = headerheight + 
60                         footerheight + 
61                         scormtopheight+
62                         topmargin +
63                         bottommargin+10; // +10 to save a minor vertical scroll always present!
65     var totalheighttoc = totalheight+imsnavheight;
66     // override total height with configured height if it is defined
67     if (cheight > 0) {
68       winheight = cheight;
69     }
70     var finalheighttoc = winheight - totalheighttoc;
71     if (finalheighttoc <= 0) {
72         finalheighttoc = winheight;
73     }                        
74     var finalheight = winheight - totalheight;
75     if (finalheight <= 0) {
76         finalheight = winheight;
77     }                        
78     var toctree = document.getElementById('toctree');
79     if (toctree != null){
80         var toctreeHeight = toctree.offsetHeight;
81         document.getElementById('toctree').style.height = finalheighttoc + 'px';
82         var scoframe2 = document.getElementById('scoframe1');
83         document.getElementById('scormobject').style.height = finalheight + 'px';
84     }else{
85         var scoframe2 = document.getElementById('scoframe1');
86         document.getElementById('scormobject').style.height = finalheight + 'px';
87     }
89         // resize the content container too to move the footer below the SCORM content
90         var contenti3 = document.getElementById('content-i3');
91         if (contenti3) {
92         contenti3.style.height = (winheight - totalheight + 30) + 'px';
93         } else {
94            document.getElementById('content').style.height = (finalheight + 30) + 'px';
95     }
96      // resize the content container too to move the footer below the SCORM content
97     var contenti3 = document.getElementById('content-i3');
98     if (contenti3) {
99         contenti3.style.height = (finalheight + 30) + 'px';
100     } else {
101         document.getElementById('content').style.height = (finalheight + 30) + 'px';
102     }