Merge branch 'MDL-41667' of git://github.com/timhunt/moodle
[moodle.git] / mod / scorm / view.js
1 M.mod_scormform = {};
2 M.mod_scormform.init = function(Y) {
3     var scormform = document.getElementById('scormviewform');
4     var cwidth = scormplayerdata.cwidth;
5     var cheight = scormplayerdata.cheight;
6     var poptions = scormplayerdata.popupoptions;
7     var courseid = scormplayerdata.courseid;
8     var launch = scormplayerdata.launch;
9     var currentorg = scormplayerdata.currentorg;
10     var sco = scormplayerdata.sco;
11     var scorm = scormplayerdata.scorm;
12     var launch_url = M.cfg.wwwroot+"/mod/scorm/player.php?a="+scorm+"&currentorg="+currentorg+"&scoid="+sco+"&sesskey="+M.cfg.sesskey;
13     var course_url = M.cfg.wwwroot+"/course/view.php?id="+courseid+"&sesskey="+M.cfg.sesskey;
15     if ((cwidth==100) && (cheight==100)) {
16         poptions = poptions+',width='+screen.availWidth+',height='+screen.availHeight+',left=0,top=0';
17     } else {
18         if (cwidth<=100) {
19             cwidth = Math.round(screen.availWidth * cwidth / 100);
20         }
21         if (cheight<=100) {
22             cheight = Math.round(screen.availHeight * cheight / 100);
23         }
24         poptions = poptions+',width='+cwidth+',height='+cheight;
25     }
27     if (launch == true) {
28         launch_url = launch_url+"&display=popup";
29         window.open(launch_url,'Popup', poptions);
30         parent.window.location = course_url;
31     }
32     scormform.onsubmit = function() {window.open('', 'Popup', poptions); this.target='Popup'; parent.window.location = course_url;};
33 }