Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-29975 SCORM improve pop-up generation

  • Loading branch information...
commit d5159fb8d31985eb98025175ee7d708d1e42446c 1 parent ead4f18
Dan Marsden danmarsden authored
Showing with 35 additions and 1 deletion.
  1. +4 −1 mod/scorm/locallib.php
  2. +19 −0 mod/scorm/view.js
  3. +12 −0 mod/scorm/view.php
5 mod/scorm/locallib.php
View
@@ -785,7 +785,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
if ($scorm->lastattemptlock == 0 || $result->attemptleft > 0) {
?>
<div class="scorm-center">
- <form id="theform" method="post" action="<?php echo $CFG->wwwroot ?>/mod/scorm/player.php">
+ <form id="scormviewform" method="post" action="<?php echo $CFG->wwwroot ?>/mod/scorm/player.php">
<?php
if ($scorm->hidebrowse == 0) {
print_string('mode', 'scorm');
@@ -805,6 +805,9 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
<label for="a"><?php print_string('newattempt', 'scorm') ?></label>
<?php
}
+ if (!empty($scorm->popup)) {
+ echo '<input type="hidden" name="display" value="popup" />'."\n";
+ }
?>
<br />
<input type="hidden" name="scoid"/>
19 mod/scorm/view.js
View
@@ -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';");
+}
12 mod/scorm/view.php
View
@@ -58,6 +58,13 @@
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 (!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();
Please sign in to comment.
Something went wrong with that request. Please try again.