Revert "MDL-43247 SCORM: improve pop-up handling and redirect to homepage on close."
authorDamyon Wiese <damyon@moodle.com>
Thu, 23 Jan 2014 09:13:18 +0000 (17:13 +0800)
committerDamyon Wiese <damyon@moodle.com>
Thu, 23 Jan 2014 09:14:56 +0000 (17:14 +0800)
mod/scorm/lang/en/scorm.php
mod/scorm/locallib.php
mod/scorm/view.js
mod/scorm/view.php

index fddf499..d353e78 100644 (file)
@@ -290,7 +290,6 @@ $string['php5'] = 'PHP 5 (DOMXML native library)';
 $string['pluginadministration'] = 'SCORM package administration';
 $string['pluginname'] = 'SCORM package';
 $string['popup'] = 'New window';
-$string['popuplaunched'] = 'This SCORM package has been launched in a popup window, If you have finished viewing this resource, click here to return to the course page';
 $string['popupmenu'] = 'In a drop down menu';
 $string['popupopen'] = 'Open package in a new window';
 $string['popupsblocked'] = 'It appears that popup windows are blocked, stopping this SCORM package from playing. Please check your browser settings before trying again.';
index 9e7d0b3..eb77ac3 100644 (file)
@@ -822,7 +822,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
     $organization = optional_param('organization', '', PARAM_INT);
 
     if ($scorm->displaycoursestructure == 1) {
-        echo $OUTPUT->box_start('generalbox boxaligncenter toc', 'toc');
+        echo $OUTPUT->box_start('generalbox boxaligncenter toc');
         ?>
         <div class="structurehead"><?php print_string('contents', 'scorm') ?></div>
         <?php
index 51c19d1..055a5b5 100644 (file)
@@ -1,6 +1,6 @@
 M.mod_scormform = {};
 M.mod_scormform.init = function(Y) {
-    var scormform = Y.one('#scormviewform');
+    var scormform = document.getElementById('scormviewform');
     var cwidth = scormplayerdata.cwidth;
     var cheight = scormplayerdata.cheight;
     var poptions = scormplayerdata.popupoptions;
@@ -8,9 +8,8 @@ M.mod_scormform.init = function(Y) {
     var currentorg = scormplayerdata.currentorg;
     var sco = scormplayerdata.sco;
     var scorm = scormplayerdata.scorm;
-    var launch_url = M.cfg.wwwroot+"/mod/scorm/player.php?a="+scorm+"&currentorg="+currentorg+"&scoid="+sco+"&sesskey="+M.cfg.sesskey+"&display=popup";
+    var launch_url = M.cfg.wwwroot+"/mod/scorm/player.php?a="+scorm+"&currentorg="+currentorg+"&scoid="+sco+"&sesskey="+M.cfg.sesskey;
     var course_url = scormplayerdata.courseurl;
-    var winobj = null;
 
     poptions = poptions + ',resizable=yes'; // Added for IE (MDL-32506).
 
@@ -26,56 +25,10 @@ M.mod_scormform.init = function(Y) {
         poptions = poptions+',width='+cwidth+',height='+cheight;
     }
 
-    // Hide the form and toc if it exists - we don't want to allow multiple submissions when a window is open.
-    var scormload = function () {
-        if (scormform) {
-            scormform.hide();
-        }
-
-        var scormtoc = Y.one('#toc');
-        if (scormtoc) {
-            scormtoc.hide();
-        }
-        // Hide the intro and display a message to the user if the window is closed.
-        var scormintro = Y.one('#intro');
-        scormintro.setHTML('<a href="'+ course_url + '">' + M.str.scorm.popuplaunched + '</a>');
-    }
-
-    // When pop-up is closed return to course homepage.
-    var scormunload = function () {
-        // Onunload is called multiple times in the SCORM window - we only want to handle when it is actually closed.
-        setTimeout(function() {
-            if (winobj.closed) {
-                // Redirect the parent window to the course homepage.
-                parent.window.location = course_url;
-            }
-        }, 800)
-    }
-
-    var scormredirect = function (winobj) {
-        Y.on('load', scormload, winobj);
-        Y.on('unload', scormunload, winobj);
-        // Check to make sure pop-up has been launched - if not display a warning,
-        // this shouldn't happen as the pop-up here is launched on user action but good to make sure.
-        setTimeout(function() {
-            if (!winobj) {
-                var scormintro = Y.one('#intro');
-                scormintro.setHTML(M.str.scorm.popupsblocked);
-            }}, 800);
-    }
-
     if (launch == true) {
-        winobj = window.open(launch_url,'Popup', poptions);
-        this.target='Popup';
-        scormredirect(winobj);
-    }
-    // Listen for view form submit and generate popup on user interaction.
-    if (scormform) {
-        Y.on('submit', function(e) {
-            winobj = window.open(launch_url, 'Popup', poptions);
-            this.target='Popup';
-            scormredirect(winobj);
-            e.preventDefault();
-        }, scormform);
+        launch_url = launch_url+"&display=popup";
+        window.open(launch_url,'Popup', poptions);
+        parent.window.location = course_url;
     }
+    scormform.onsubmit = function() {window.open('', 'Popup', poptions); this.target='Popup'; parent.window.location = course_url;};
 }
index b898a47..8f8d5be 100644 (file)
@@ -100,8 +100,6 @@ if (!empty($scorm->popup)) {
                                                            'cwidth' => $scorm->width,
                                                            'cheight' => $scorm->height,
                                                            'popupoptions' => $scorm->options), true);
-    $PAGE->requires->string_for_js('popupsblocked', 'scorm');
-    $PAGE->requires->string_for_js('popuplaunched', 'scorm');
     $PAGE->requires->js('/mod/scorm/view.js', true);
 }