From f3665549b8cf5904b665b86b484772f5dcd45074 Mon Sep 17 00:00:00 2001 From: samhemelryk Date: Mon, 29 Jun 2009 02:38:22 +0000 Subject: [PATCH] mod-scorm MDL-16706 Replaced inline JS with new PAGE methods and created player.js --- mod/scorm/player.js | 17 +++++++++++++++++ mod/scorm/player.php | 35 ++++++----------------------------- mod/scorm/rd.js | 8 ++++---- 3 files changed, 27 insertions(+), 33 deletions(-) create mode 100644 mod/scorm/player.js diff --git a/mod/scorm/player.js b/mod/scorm/player.js new file mode 100644 index 0000000000..7efb130599 --- /dev/null +++ b/mod/scorm/player.js @@ -0,0 +1,17 @@ +function scorm_openpopup(url,name,options,width,height) { + fullurl = moodle_cfg.wwwroot + '/mod/scorm/' + url; + windowobj = window.open(fullurl,name,options); + if ((width==100) && (height==100)) { + // Fullscreen + windowobj.moveTo(0,0); + } + if (width<=100) { + width = Math.round(screen.availWidth * width / 100); + } + if (height<=100) { + height = Math.round(screen.availHeight * height / 100); + } + windowobj.resizeTo(width,height); + windowobj.focus(); + return windowobj; +} \ No newline at end of file diff --git a/mod/scorm/player.php b/mod/scorm/player.php index dd5a48dbb2..e51788a3ba 100755 --- a/mod/scorm/player.php +++ b/mod/scorm/player.php @@ -158,7 +158,7 @@ $navigation, '', '', true, $exitlink.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript); - echo $PAGE->requires->data_for_js('scormdata', Array('cwidth'=>$scorm->width,'cheight'=>$scorm->height))->asap(); + echo $PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,'cheight'=>$scorm->height))->asap(); echo $PAGE->requires->js('mod/scorm/request.js')->asap(); echo $PAGE->requires->js('mod/scorm/loaddatamodel.php?id='.$cm->id.$scoidstr.$modestr.$attemptstr)->asap(); echo $PAGE->requires->js('mod/scorm/rd.js')->asap(); @@ -296,7 +296,7 @@ if ($scorm->popup == 0) { $fullurl="loadSCO.php?id=".$cm->id.$scoidstr.$modestr; echo " \n"; - $PAGE->requires->js_function_call('scorm_resize', Array($scorm->width, $scorm->height)); + $PAGE->requires->js_function_call('scorm_resize'); } else { // Clean the name for the window as IE is fussy $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name); @@ -304,34 +304,11 @@ $name = 'DefaultPlayerWindow'; } $name = 'scorm_'.$name; - ?> - + echo $PAGE->requires->js_function_call('scorm_resize')->asap(); + echo $PAGE->requires->js('mod/scorm/player.js')->asap(); + echo $PAGE->requires->js_function_call('scorm_openpopup', Array("loadSCO.php?id=".$cm->id.$scoidpop, p($name), p($scorm->options), p($scorm->width), p($scorm->height)))->asap(); + ?>