From d5159fb8d31985eb98025175ee7d708d1e42446c Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Wed, 28 Mar 2012 14:28:19 +1300 Subject: [PATCH] MDL-29975 SCORM improve pop-up generation --- mod/scorm/locallib.php | 5 ++++- mod/scorm/view.js | 19 +++++++++++++++++++ mod/scorm/view.php | 12 ++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 mod/scorm/view.js diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index 3e39b6dcfb9..3a35b2f4a37 100644 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -785,7 +785,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) { if ($scorm->lastattemptlock == 0 || $result->attemptleft > 0) { ?>
-
+ hidebrowse == 0) { print_string('mode', 'scorm'); @@ -805,6 +805,9 @@ function scorm_view_display ($user, $scorm, $action, $cm) { popup)) { + echo ''."\n"; + } ?>
diff --git a/mod/scorm/view.js b/mod/scorm/view.js new file mode 100644 index 00000000000..1fd0a294dac --- /dev/null +++ b/mod/scorm/view.js @@ -0,0 +1,19 @@ +M.mod_scormform = {}; +M.mod_scormform.init = function(Y) { + var scormform = Y.one('#scormviewform'); + var cwidth = scormplayerdata.cwidth; + var cheight = scormplayerdata.cheight; + var poptions = scormplayerdata.popupoptions; + if ((cwidth==100) && (cheight==100)) { + poptions = poptions+',width='+screen.availWidth+',height='+screen.availHeight+',left=0,top=0'; + } else { + if (cwidth<=100) { + cwidth = Math.round(screen.availWidth * cwidth / 100); + } + if (cheight<=100) { + cheight = Math.round(screen.availHeight * cheight / 100); + } + poptions = poptions+',width='+cwidth+',height='+cheight; + } + scormform.setAttribute('onsubmit', "window.open('','Popup','"+poptions+"'); this.target='Popup';"); +} diff --git a/mod/scorm/view.php b/mod/scorm/view.php index 787b8b1f1e1..33796d8e2c6 100644 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -58,6 +58,13 @@ if (!empty($forcejs)) { require_login($course->id, false, $cm); +if (!empty($scorm->popup)) { + $PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width, + 'cheight'=>$scorm->height, + 'popupoptions' => $scorm->options), true); + $PAGE->requires->js('/mod/scorm/view.js', true); +} + $context = get_context_instance(CONTEXT_COURSE, $course->id); $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -125,4 +132,9 @@ if ($scormopen) { if (!empty($forcejs)) { echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage"); } + +if (!empty($scorm->popup)) { + $PAGE->requires->js_init_call('M.mod_scormform.init'); +} + echo $OUTPUT->footer();